From patchwork Sat Nov 5 16:39:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anssi Hannula X-Patchwork-Id: 1310 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.90.1 with SMTP id o1csp372603vsb; Sat, 5 Nov 2016 09:39:33 -0700 (PDT) X-Received: by 10.28.127.14 with SMTP id a14mr2101243wmd.80.1478363973256; Sat, 05 Nov 2016 09:39:33 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id lj8si21344008wjc.252.2016.11.05.09.39.32; Sat, 05 Nov 2016 09:39:33 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1EC3D689EC2; Sat, 5 Nov 2016 18:39:19 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from webmail.tpnet.fi (webmail.tpnet.fi [62.106.63.33]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2949C689746 for ; Sat, 5 Nov 2016 18:39:11 +0200 (EET) Received: from mail.onse.fi (host-109-204-145-182.tp-fne.tampereenpuhelin.net [109.204.145.182]) by webmail.tpnet.fi (Postfix) with ESMTPS id 582FB24E31; Sat, 5 Nov 2016 18:39:14 +0200 (EET) Received: by mail.onse.fi (Postfix, from userid 501) id 3277C40EE4; Sat, 5 Nov 2016 18:39:14 +0200 (EET) From: Anssi Hannula To: ffmpeg-devel@ffmpeg.org Date: Sat, 5 Nov 2016 18:39:00 +0200 Message-Id: <1478363940-21822-3-git-send-email-anssi.hannula@iki.fi> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1478363940-21822-1-git-send-email-anssi.hannula@iki.fi> References: <2a3ab49d-6854-df7b-139c-cc5af823f7fb@googlemail.com> <1478363940-21822-1-git-send-email-anssi.hannula@iki.fi> Subject: [FFmpeg-devel] [PATCH 2/2] avformat/hls: Fix probing mpegts audio streams that use probing X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Andreas Cadhalpun MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Commit 04964ac311abe670f ("avformat/hls: Fix missing streams in some cases with MPEG TS") caused a regression where subdemuxer streams that use probing (e.g. dts/eac3/mp2 in mpegts) no longer get probed properly. This is because the codec parameters from the subdemuxer stream, once probed, are not passed on to the main stream. Fix that by updating the codec parameters if the codec id changes. Signed-off-by: Anssi Hannula --- libavformat/hls.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/libavformat/hls.c b/libavformat/hls.c index 6fb652c..8527f33 100644 --- a/libavformat/hls.c +++ b/libavformat/hls.c @@ -1950,6 +1950,8 @@ static int hls_read_packet(AVFormatContext *s, AVPacket *pkt) /* If we got a packet, return it */ if (minplaylist >= 0) { struct playlist *pls = c->playlists[minplaylist]; + AVStream *ist; + AVStream *st; ret = update_streams_from_subdemuxer(s, pls); if (ret < 0) { @@ -1972,8 +1974,11 @@ static int hls_read_packet(AVFormatContext *s, AVPacket *pkt) return AVERROR_BUG; } + ist = pls->ctx->streams[pls->pkt.stream_index]; + st = pls->main_streams[pls->pkt.stream_index]; + *pkt = pls->pkt; - pkt->stream_index = pls->main_streams[pls->pkt.stream_index]->index; + pkt->stream_index = st->index; reset_packet(&c->playlists[minplaylist]->pkt); if (pkt->dts != AV_NOPTS_VALUE) @@ -1981,6 +1986,11 @@ static int hls_read_packet(AVFormatContext *s, AVPacket *pkt) pls->ctx->streams[pls->pkt.stream_index]->time_base, AV_TIME_BASE_Q); + /* There may be more situations where this would be useful, but this at least + * handles newly probed codecs properly (i.e. request_probe by mpegts). */ + if (ist->codecpar->codec_id != st->codecpar->codec_id) + set_stream_info_from_input_stream(st, pls, ist); + return 0; } return AVERROR_EOF;