Loading media/libstagefright/mpeg2ts/ATSParser.cpp +26 −14 Original line number Diff line number Diff line Loading @@ -524,16 +524,11 @@ int64_t ATSParser::Program::recoverPTS(uint64_t PTS_33bit) { } sp<MediaSource> ATSParser::Program::getSource(SourceType type) { size_t index = (type == AUDIO) ? 0 : 0; for (size_t i = 0; i < mStreams.size(); ++i) { sp<MediaSource> source = mStreams.editValueAt(i)->getSource(type); if (source != NULL) { if (index == 0) { return source; } --index; } } return NULL; Loading @@ -546,6 +541,8 @@ bool ATSParser::Program::hasSource(SourceType type) const { return true; } else if (type == VIDEO && stream->isVideo()) { return true; } else if (type == META && stream->isMeta()) { return true; } } Loading Loading @@ -1499,23 +1496,38 @@ status_t ATSParser::parseTS(ABitReader *br, SyncEvent *event) { } sp<MediaSource> ATSParser::getSource(SourceType type) { int which = -1; // any sp<MediaSource> firstSourceFound; for (size_t i = 0; i < mPrograms.size(); ++i) { const sp<Program> &program = mPrograms.editItemAt(i); if (which >= 0 && (int)program->number() != which) { sp<MediaSource> source = program->getSource(type); if (source == NULL) { continue; } if (firstSourceFound == NULL) { firstSourceFound = source; } // Prefer programs with both audio/video switch (type) { case VIDEO: { if (program->hasSource(AUDIO)) { return source; } break; } sp<MediaSource> source = program->getSource(type); case AUDIO: { if (program->hasSource(VIDEO)) { return source; } break; } if (source != NULL) { default: return source; } } return NULL; return firstSourceFound; } bool ATSParser::hasSource(SourceType type) const { Loading Loading
media/libstagefright/mpeg2ts/ATSParser.cpp +26 −14 Original line number Diff line number Diff line Loading @@ -524,16 +524,11 @@ int64_t ATSParser::Program::recoverPTS(uint64_t PTS_33bit) { } sp<MediaSource> ATSParser::Program::getSource(SourceType type) { size_t index = (type == AUDIO) ? 0 : 0; for (size_t i = 0; i < mStreams.size(); ++i) { sp<MediaSource> source = mStreams.editValueAt(i)->getSource(type); if (source != NULL) { if (index == 0) { return source; } --index; } } return NULL; Loading @@ -546,6 +541,8 @@ bool ATSParser::Program::hasSource(SourceType type) const { return true; } else if (type == VIDEO && stream->isVideo()) { return true; } else if (type == META && stream->isMeta()) { return true; } } Loading Loading @@ -1499,23 +1496,38 @@ status_t ATSParser::parseTS(ABitReader *br, SyncEvent *event) { } sp<MediaSource> ATSParser::getSource(SourceType type) { int which = -1; // any sp<MediaSource> firstSourceFound; for (size_t i = 0; i < mPrograms.size(); ++i) { const sp<Program> &program = mPrograms.editItemAt(i); if (which >= 0 && (int)program->number() != which) { sp<MediaSource> source = program->getSource(type); if (source == NULL) { continue; } if (firstSourceFound == NULL) { firstSourceFound = source; } // Prefer programs with both audio/video switch (type) { case VIDEO: { if (program->hasSource(AUDIO)) { return source; } break; } sp<MediaSource> source = program->getSource(type); case AUDIO: { if (program->hasSource(VIDEO)) { return source; } break; } if (source != NULL) { default: return source; } } return NULL; return firstSourceFound; } bool ATSParser::hasSource(SourceType type) const { Loading