Pull some emacs mode lines.
[dcpomatic.git] / src / lib / ffmpeg_content.h
1 /*
2     Copyright (C) 2013 Carl Hetherington <cth@carlh.net>
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 #ifndef DCPOMATIC_FFMPEG_CONTENT_H
21 #define DCPOMATIC_FFMPEG_CONTENT_H
22
23 #include <boost/enable_shared_from_this.hpp>
24 #include "video_content.h"
25 #include "audio_content.h"
26
27 class Filter;
28
29 class FFmpegAudioStream
30 {
31 public:
32         FFmpegAudioStream (std::string n, int i, int f, int c)
33                 : name (n)
34                 , id (i)
35                 , frame_rate (f)
36                 , channels (c)
37                 , mapping (c)
38         {}
39
40         FFmpegAudioStream (boost::shared_ptr<const cxml::Node>);
41
42         void as_xml (xmlpp::Node *) const;
43         
44         std::string name;
45         int id;
46         int frame_rate;
47         int channels;
48         AudioMapping mapping;
49 };
50
51 extern bool operator== (FFmpegAudioStream const & a, FFmpegAudioStream const & b);
52
53 class FFmpegSubtitleStream
54 {
55 public:
56         FFmpegSubtitleStream (std::string n, int i)
57                 : name (n)
58                 , id (i)
59         {}
60         
61         FFmpegSubtitleStream (boost::shared_ptr<const cxml::Node>);
62
63         void as_xml (xmlpp::Node *) const;
64         
65         std::string name;
66         int id;
67 };
68
69 extern bool operator== (FFmpegSubtitleStream const & a, FFmpegSubtitleStream const & b);
70
71 class FFmpegContentProperty : public VideoContentProperty
72 {
73 public:
74         static int const SUBTITLE_STREAMS;
75         static int const SUBTITLE_STREAM;
76         static int const AUDIO_STREAMS;
77         static int const AUDIO_STREAM;
78         static int const FILTERS;
79 };
80
81 class FFmpegContent : public VideoContent, public AudioContent
82 {
83 public:
84         FFmpegContent (boost::shared_ptr<const Film>, boost::filesystem::path);
85         FFmpegContent (boost::shared_ptr<const Film>, boost::shared_ptr<const cxml::Node>);
86         FFmpegContent (FFmpegContent const &);
87
88         boost::shared_ptr<FFmpegContent> shared_from_this () {
89                 return boost::dynamic_pointer_cast<FFmpegContent> (Content::shared_from_this ());
90         }
91         
92         void examine (boost::shared_ptr<Job>);
93         std::string summary () const;
94         std::string information () const;
95         void as_xml (xmlpp::Node *) const;
96         boost::shared_ptr<Content> clone () const;
97         Time length () const;
98
99         /* AudioContent */
100         int audio_channels () const;
101         ContentAudioFrame audio_length () const;
102         int content_audio_frame_rate () const;
103         int output_audio_frame_rate () const;
104         AudioMapping audio_mapping () const;
105         void set_audio_mapping (AudioMapping);
106
107         void set_filters (std::vector<Filter const *> const &);
108         
109         std::vector<boost::shared_ptr<FFmpegSubtitleStream> > subtitle_streams () const {
110                 boost::mutex::scoped_lock lm (_mutex);
111                 return _subtitle_streams;
112         }
113
114         boost::shared_ptr<FFmpegSubtitleStream> subtitle_stream () const {
115                 boost::mutex::scoped_lock lm (_mutex);
116                 return _subtitle_stream;
117         }
118
119         std::vector<boost::shared_ptr<FFmpegAudioStream> > audio_streams () const {
120                 boost::mutex::scoped_lock lm (_mutex);
121                 return _audio_streams;
122         }
123         
124         boost::shared_ptr<FFmpegAudioStream> audio_stream () const {
125                 boost::mutex::scoped_lock lm (_mutex);
126                 return _audio_stream;
127         }
128
129         std::vector<Filter const *> filters () const {
130                 boost::mutex::scoped_lock lm (_mutex);
131                 return _filters;
132         }
133
134         void set_subtitle_stream (boost::shared_ptr<FFmpegSubtitleStream>);
135         void set_audio_stream (boost::shared_ptr<FFmpegAudioStream>);
136         
137 private:
138         std::vector<boost::shared_ptr<FFmpegSubtitleStream> > _subtitle_streams;
139         boost::shared_ptr<FFmpegSubtitleStream> _subtitle_stream;
140         std::vector<boost::shared_ptr<FFmpegAudioStream> > _audio_streams;
141         boost::shared_ptr<FFmpegAudioStream> _audio_stream;
142         /** Video filters that should be used when generating DCPs */
143         std::vector<Filter const *> _filters;
144 };
145
146 #endif