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

Commit e0b7ddcd authored by Robert Shih's avatar Robert Shih Committed by Android (Google) Code Review
Browse files

Merge "PlaylistFetcher: check ts program streams before disabling a/v" into lmp-mr1-dev

parents 869e0798 bf20727f
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -963,8 +963,8 @@ void PlaylistFetcher::onDownloadNext() {
    } while (bytesRead != 0);

    if (bufferStartsWithTsSyncByte(buffer)) {
        // If we still don't see a stream after fetching a full ts segment mark it as
        // nonexistent.
        // If we don't see a stream in the program table after fetching a full ts segment
        // mark it as nonexistent.
        const size_t kNumTypes = ATSParser::NUM_SOURCE_TYPES;
        ATSParser::SourceType srcTypes[kNumTypes] =
                { ATSParser::VIDEO, ATSParser::AUDIO };
@@ -979,7 +979,7 @@ void PlaylistFetcher::onDownloadNext() {
                static_cast<AnotherPacketSource *>(
                    mTSParser->getSource(srcType).get());

            if (source == NULL) {
            if (!mTSParser->hasSource(srcType)) {
                ALOGW("MPEG2 Transport stream does not contain %s data.",
                      srcType == ATSParser::VIDEO ? "video" : "audio");

+28 −3
Original line number Diff line number Diff line
@@ -63,6 +63,7 @@ struct ATSParser::Program : public RefBase {
    void signalEOS(status_t finalResult);

    sp<MediaSource> getSource(SourceType type);
    bool hasSource(SourceType type) const;

    int64_t convertPTSToTimestamp(uint64_t PTS);

@@ -119,6 +120,9 @@ struct ATSParser::Stream : public RefBase {

    sp<MediaSource> getSource(SourceType type);

    bool isAudio() const;
    bool isVideo() const;

protected:
    virtual ~Stream();

@@ -146,9 +150,6 @@ private:

    void extractAACFrames(const sp<ABuffer> &buffer);

    bool isAudio() const;
    bool isVideo() const;

    DISALLOW_EVIL_CONSTRUCTORS(Stream);
};

@@ -440,6 +441,19 @@ sp<MediaSource> ATSParser::Program::getSource(SourceType type) {
    return NULL;
}

bool ATSParser::Program::hasSource(SourceType type) const {
    for (size_t i = 0; i < mStreams.size(); ++i) {
        const sp<Stream> &stream = mStreams.valueAt(i);
        if (type == AUDIO && stream->isAudio()) {
            return true;
        } else if (type == VIDEO && stream->isVideo()) {
            return true;
        }
    }

    return false;
}

int64_t ATSParser::Program::convertPTSToTimestamp(uint64_t PTS) {
    if (!(mParser->mFlags & TS_TIMESTAMPS_ARE_ABSOLUTE)) {
        if (!mFirstPTSValid) {
@@ -1278,6 +1292,17 @@ sp<MediaSource> ATSParser::getSource(SourceType type) {
    return NULL;
}

bool ATSParser::hasSource(SourceType type) const {
    for (size_t i = 0; i < mPrograms.size(); ++i) {
        const sp<Program> &program = mPrograms.itemAt(i);
        if (program->hasSource(type)) {
            return true;
        }
    }

    return false;
}

bool ATSParser::PTSTimeDeltaEstablished() {
    if (mPrograms.isEmpty()) {
        return false;
+1 −0
Original line number Diff line number Diff line
@@ -74,6 +74,7 @@ struct ATSParser : public RefBase {
        NUM_SOURCE_TYPES = 2
    };
    sp<MediaSource> getSource(SourceType type);
    bool hasSource(SourceType type) const;

    bool PTSTimeDeltaEstablished();