Do audio/video pts sync in a hopefully much more sensible way.
[dcpomatic.git] / src / lib / ffmpeg_decoder.h
index 4e5445f673acfcd53ebb573f1cf23cf12c644ab4..ac4cd6fcfa1dae4ad18258bad2e349c5186abc91 100644 (file)
@@ -39,6 +39,7 @@ struct AVFormatContext;
 struct AVFrame;
 struct AVBufferContext;
 struct AVCodec;
+struct AVStream;
 class Job;
 class FilmState;
 class Options;
@@ -63,6 +64,10 @@ public:
        int audio_sample_rate () const;
        AVSampleFormat audio_sample_format () const;
        int64_t audio_channel_layout () const;
+       bool has_subtitles () const;
+
+       std::vector<AudioStream> audio_streams () const;
+       std::vector<SubtitleStream> subtitle_streams () const;
 
 private:
 
@@ -76,16 +81,30 @@ private:
        void setup_general ();
        void setup_video ();
        void setup_audio ();
+       void setup_subtitle ();
+
+       void maybe_add_subtitle ();
+
+       std::string stream_name (AVStream* s) const;
 
        AVFormatContext* _format_context;
        int _video_stream;
        int _audio_stream; ///< may be < 0 if there is no audio
+       int _subtitle_stream; ///< may be < 0 if there is no subtitle
        AVFrame* _frame;
+
+       std::vector<AudioStream> _audio_streams;
+       std::vector<SubtitleStream> _subtitle_streams;
        
        AVCodecContext* _video_codec_context;
        AVCodec* _video_codec;
-       AVCodecContext* _audio_codec_context; ///< may be 0 if there is no audio
-       AVCodec* _audio_codec;                ///< may be 0 if there is no audio
+       AVCodecContext* _audio_codec_context;    ///< may be 0 if there is no audio
+       AVCodec* _audio_codec;                   ///< may be 0 if there is no audio
+       AVCodecContext* _subtitle_codec_context; ///< may be 0 if there is no subtitle
+       AVCodec* _subtitle_codec;                ///< may be 0 if there is no subtitle
 
        AVPacket _packet;
+
+       int64_t _first_video_pts;
+       int64_t _first_audio_pts;
 };