From 12a3d2f50dc52d8d05f5d0e932445f368248f520 Mon Sep 17 00:00:00 2001 From: Jaesung Chung Date: Mon, 18 May 2015 15:57:32 +0900 Subject: mpeg2ts: MPEG2TSExtractor detects A/V streams until timed out Bug: 20433028 Change-Id: I6145eae8d64ad9150477a8ac52545e68768c75eb --- media/libstagefright/mpeg2ts/MPEG2TSExtractor.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'media/libstagefright/mpeg2ts') diff --git a/media/libstagefright/mpeg2ts/MPEG2TSExtractor.cpp b/media/libstagefright/mpeg2ts/MPEG2TSExtractor.cpp index f5c33cf..3a8e2ab 100644 --- a/media/libstagefright/mpeg2ts/MPEG2TSExtractor.cpp +++ b/media/libstagefright/mpeg2ts/MPEG2TSExtractor.cpp @@ -22,6 +22,7 @@ #include "include/NuCachedSource2.h" #include +#include #include #include #include @@ -164,7 +165,7 @@ sp MPEG2TSExtractor::getMetaData() { void MPEG2TSExtractor::init() { bool haveAudio = false; bool haveVideo = false; - int numPacketsParsed = 0; + int64_t startTime = ALooper::GetNowUs(); while (feedMore() == OK) { if (haveAudio && haveVideo) { @@ -192,12 +193,14 @@ void MPEG2TSExtractor::init() { } } - if (++numPacketsParsed > 10000) { + // Wait only for 2 seconds to detect audio/video streams. + if (ALooper::GetNowUs() - startTime > 2000000ll) { break; } } - ALOGI("haveAudio=%d, haveVideo=%d", haveAudio, haveVideo); + ALOGI("haveAudio=%d, haveVideo=%d, elaspedTime=%lld", + haveAudio, haveVideo, ALooper::GetNowUs() - startTime); } status_t MPEG2TSExtractor::feedMore() { -- cgit v1.1