mpeg2ts: MPEG2TSExtractor detects A/V streams until timed out
Bug: 20433028
Change-Id: I6145eae8d64ad9150477a8ac52545e68768c75eb
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 <media/stagefright/foundation/ADebug.h>
+#include <media/stagefright/foundation/ALooper.h>
#include <media/stagefright/DataSource.h>
#include <media/stagefright/MediaDefs.h>
#include <media/stagefright/MediaErrors.h>
@@ -164,7 +165,7 @@
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 @@
}
}
- 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() {