From c4547ba77f78632172db3647a09659d9863d3b5c Mon Sep 17 00:00:00 2001 From: Chong Zhang Date: Fri, 6 Mar 2015 14:00:54 -0800 Subject: HLS: some fixes for seek with discontinuity. - keep old fetcher when seeking, unless the URI is changing. - when restarting after a seek, check discontinuity seq, and queue format change if it's changed. - add a simple kill switch to abort when stop (or pause for seek). - when seeking, if searching for start time goes into 2nd segment, do not signal time discontinuity or reset first PTS. - use setFormat() to set format in AnotherPacketSource, otherwise video/audio flags are not updated and format are not cleared on discontinuities. - do not start queueing video access unit until first IDR after start bug: 19656539 Change-Id: I79108d26964f59ea00d2eeac8f5f9318747f8541 --- media/libstagefright/mpeg2ts/AnotherPacketSource.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'media/libstagefright/mpeg2ts') diff --git a/media/libstagefright/mpeg2ts/AnotherPacketSource.cpp b/media/libstagefright/mpeg2ts/AnotherPacketSource.cpp index bb05417..79a9b04 100644 --- a/media/libstagefright/mpeg2ts/AnotherPacketSource.cpp +++ b/media/libstagefright/mpeg2ts/AnotherPacketSource.cpp @@ -48,7 +48,10 @@ AnotherPacketSource::AnotherPacketSource(const sp &meta) } void AnotherPacketSource::setFormat(const sp &meta) { - CHECK(mFormat == NULL); + if (mFormat != NULL) { + // Only allowed to be set once. Requires explicit clear to reset. + return; + } mIsAudio = false; mIsVideo = false; @@ -94,7 +97,8 @@ sp AnotherPacketSource::getFormat() { if (!buffer->meta()->findInt32("discontinuity", &discontinuity)) { sp object; if (buffer->meta()->findObject("format", &object)) { - return mFormat = static_cast(object.get()); + setFormat(static_cast(object.get())); + return mFormat; } } @@ -129,7 +133,7 @@ status_t AnotherPacketSource::dequeueAccessUnit(sp *buffer) { sp object; if ((*buffer)->meta()->findObject("format", &object)) { - mFormat = static_cast(object.get()); + setFormat(static_cast(object.get())); } return OK; @@ -164,7 +168,7 @@ status_t AnotherPacketSource::read( sp object; if (buffer->meta()->findObject("format", &object)) { - mFormat = static_cast(object.get()); + setFormat(static_cast(object.get())); } int64_t timeUs; -- cgit v1.1