summaryrefslogtreecommitdiff
path: root/src/lib/ffmpeg_content.h
blob: 95e24b7b3ef29e8e29e20ca63340c05ee4b4c167 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#ifndef DVDOMATIC_FFMPEG_CONTENT_H
#define DVDOMATIC_FFMPEG_CONTENT_H

#include <boost/enable_shared_from_this.hpp>
#include "video_content.h"
#include "audio_content.h"

class FFmpegAudioStream
{
public:
        FFmpegAudioStream (std::string n, int i, int f, int64_t c)
                : name (n)
                , id (i)
                , frame_rate (f)
                , channel_layout (c)
        {}

	FFmpegAudioStream (boost::shared_ptr<const cxml::Node>);

	void as_xml (xmlpp::Node *) const;
	
        int channels () const {
                return av_get_channel_layout_nb_channels (channel_layout);
        }
        
        std::string name;
        int id;
        int frame_rate;
        int64_t channel_layout;
};

extern bool operator== (FFmpegAudioStream const & a, FFmpegAudioStream const & b);

class FFmpegSubtitleStream
{
public:
        FFmpegSubtitleStream (std::string n, int i)
                : name (n)
                , id (i)
        {}
        
	FFmpegSubtitleStream (boost::shared_ptr<const cxml::Node>);

	void as_xml (xmlpp::Node *) const;
	
        std::string name;
        int id;
};

extern bool operator== (FFmpegSubtitleStream const & a, FFmpegSubtitleStream const & b);

class FFmpegContentProperty : public VideoContentProperty
{
public:
        static int const SUBTITLE_STREAMS;
        static int const SUBTITLE_STREAM;
        static int const AUDIO_STREAMS;
        static int const AUDIO_STREAM;
};

class FFmpegContent : public VideoContent, public AudioContent, public boost::enable_shared_from_this<FFmpegContent>
{
public:
	FFmpegContent (boost::filesystem::path);
	FFmpegContent (boost::shared_ptr<const cxml::Node>);
	
	void examine (boost::shared_ptr<Film>, boost::shared_ptr<Job>, bool);
	std::string summary () const;
	void as_xml (xmlpp::Node *) const;

        /* AudioContent */
        int audio_channels () const;
        ContentAudioFrame audio_length () const;
        int audio_frame_rate () const;
        int64_t audio_channel_layout () const;
	
        std::vector<FFmpegSubtitleStream> subtitle_streams () const {
                boost::mutex::scoped_lock lm (_mutex);
                return _subtitle_streams;
        }

        boost::optional<FFmpegSubtitleStream> subtitle_stream () const {
                boost::mutex::scoped_lock lm (_mutex);
                return _subtitle_stream;
        }

        std::vector<FFmpegAudioStream> audio_streams () const {
                boost::mutex::scoped_lock lm (_mutex);
                return _audio_streams;
        }
        
        boost::optional<FFmpegAudioStream> audio_stream () const {
                boost::mutex::scoped_lock lm (_mutex);
                return _audio_stream;
        }

        void set_subtitle_stream (FFmpegSubtitleStream);
        void set_audio_stream (FFmpegAudioStream);
	
private:
	std::vector<FFmpegSubtitleStream> _subtitle_streams;
	boost::optional<FFmpegSubtitleStream> _subtitle_stream;
	std::vector<FFmpegAudioStream> _audio_streams;
	boost::optional<FFmpegAudioStream> _audio_stream;
};

#endif