Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 12a3d2f5 authored by Jaesung Chung's avatar Jaesung Chung
Browse files

mpeg2ts: MPEG2TSExtractor detects A/V streams until timed out

Bug: 20433028
Change-Id: I6145eae8d64ad9150477a8ac52545e68768c75eb
parent 4a95e694
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -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 @@ sp<MetaData> 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() {