#include "ffmpeg.h"
#include "ffmpeg_content.h"
#include "ffmpeg_audio_stream.h"
+#include "ffmpeg_subtitle_stream.h"
#include "exceptions.h"
#include "util.h"
return _ffmpeg_content->audio_stream()->stream(_format_context)->codec;
}
+AVCodecContext *
+FFmpeg::subtitle_codec_context () const
+{
+ if (!_ffmpeg_content->subtitle_stream ()) {
+ return 0;
+ }
+
+ return _ffmpeg_content->subtitle_stream()->stream(_format_context)->codec;
+}
+
int
FFmpeg::avio_read (uint8_t* buffer, int const amount)
{
protected:
AVCodecContext* video_codec_context () const;
AVCodecContext* audio_codec_context () const;
+ AVCodecContext* subtitle_codec_context () const;
boost::shared_ptr<const FFmpegContent> _ffmpeg_content;
, SubtitleDecoder (c)
, FFmpeg (c)
, _log (log)
- , _subtitle_codec_context (0)
- , _subtitle_codec (0)
{
/* Audio and video frame PTS values may not start with 0. We want
to fiddle them so that:
}
}
-FFmpegDecoder::~FFmpegDecoder ()
-{
- boost::mutex::scoped_lock lm (_mutex);
-
- if (_subtitle_codec_context) {
- avcodec_close (_subtitle_codec_context);
- }
-}
-
void
FFmpegDecoder::flush ()
{
if (audio_codec_context ()) {
avcodec_flush_buffers (audio_codec_context ());
}
- if (_subtitle_codec_context) {
- avcodec_flush_buffers (_subtitle_codec_context);
+ if (subtitle_codec_context ()) {
+ avcodec_flush_buffers (subtitle_codec_context ());
}
}
{
int got_subtitle;
AVSubtitle sub;
- if (avcodec_decode_subtitle2 (_subtitle_codec_context, &sub, &got_subtitle, &_packet) < 0 || !got_subtitle) {
+ if (avcodec_decode_subtitle2 (subtitle_codec_context(), &sub, &got_subtitle, &_packet) < 0 || !got_subtitle) {
return;
}
{
public:
FFmpegDecoder (boost::shared_ptr<const FFmpegContent>, boost::shared_ptr<Log>);
- ~FFmpegDecoder ();
private:
friend class ::ffmpeg_pts_offset_test;
bool has_subtitle_during (ContentTimePeriod) const;
boost::shared_ptr<Log> _log;
- AVCodecContext* _subtitle_codec_context; ///< may be 0 if there is no subtitle
- AVCodec* _subtitle_codec; ///< may be 0 if there is no subtitle
std::list<boost::shared_ptr<FilterGraph> > _filter_graphs;
boost::mutex _filter_graphs_mutex;