From 2379b4879d4a8efb93f514227c13132206ee7393 Mon Sep 17 00:00:00 2001 From: Petri Hintukainen Date: Sat, 19 Apr 2014 00:02:26 +0300 Subject: demux_avformat: add support for recent versions of libav fork. --- src/combined/ffmpeg/demux_avformat.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/combined/ffmpeg/demux_avformat.c b/src/combined/ffmpeg/demux_avformat.c index d73b491a2..5e717b375 100644 --- a/src/combined/ffmpeg/demux_avformat.c +++ b/src/combined/ffmpeg/demux_avformat.c @@ -319,6 +319,24 @@ static uint32_t audio_codec_lookup(avformat_demux_plugin_t *this, int id) { return 0; } +/* copied from libavformat/utils.c (not available in recent libav API) */ +static AVProgram *_find_program_from_stream(AVFormatContext *ic, AVProgram *last, int s) +{ + int i, j; + + for (i = 0; i < ic->nb_programs; i++) { + if (ic->programs[i] == last) { + last = NULL; + } else { + if (!last) + for (j = 0; j < ic->programs[i]->nb_stream_indexes; j++) + if (ic->programs[i]->stream_index[j] == s) + return ic->programs[i]; + } + } + return NULL; +} + static int find_avformat_streams(avformat_demux_plugin_t *this) { AVProgram *p = NULL; @@ -360,7 +378,7 @@ static int find_avformat_streams(avformat_demux_plugin_t *this) { /* get audio tracks of the program */ if (this->video_stream_idx >= 0) { - p = av_find_program_from_stream(this->fmt_ctx, NULL, this->video_stream_idx); + p = _find_program_from_stream(this->fmt_ctx, NULL, this->video_stream_idx); } nb_streams = p ? p->nb_stream_indexes : this->fmt_ctx->nb_streams; -- cgit v1.2.3