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

Commit 78461efd authored by Marco Nelissen's avatar Marco Nelissen Committed by Android (Google) Code Review
Browse files

Merge "Explicitly use AnotherPacketSource where possible"

parents d21fb560 45d54c6e
Loading
Loading
Loading
Loading
+6 −13
Original line number Diff line number Diff line
@@ -202,9 +202,7 @@ void MPEG2TSExtractor::init() {
            break;
        }
        if (!haveVideo) {
            sp<AnotherPacketSource> impl =
                (AnotherPacketSource *)mParser->getSource(
                        ATSParser::VIDEO).get();
            sp<AnotherPacketSource> impl = mParser->getSource(ATSParser::VIDEO);

            if (impl != NULL) {
                sp<MetaData> format = impl->getFormat();
@@ -220,9 +218,7 @@ void MPEG2TSExtractor::init() {
        }

        if (!haveAudio) {
            sp<AnotherPacketSource> impl =
                (AnotherPacketSource *)mParser->getSource(
                        ATSParser::AUDIO).get();
            sp<AnotherPacketSource> impl = mParser->getSource(ATSParser::AUDIO);

            if (impl != NULL) {
                sp<MetaData> format = impl->getFormat();
@@ -261,10 +257,8 @@ void MPEG2TSExtractor::init() {
    off64_t size;
    if (mDataSource->getSize(&size) == OK && (haveAudio || haveVideo)) {
        sp<AnotherPacketSource> impl = haveVideo
                ? (AnotherPacketSource *)mParser->getSource(
                        ATSParser::VIDEO).get()
                : (AnotherPacketSource *)mParser->getSource(
                        ATSParser::AUDIO).get();
                ? mParser->getSource(ATSParser::VIDEO)
                : mParser->getSource(ATSParser::AUDIO);
        size_t prevSyncSize = 1;
        int64_t durationUs = -1;
        List<int64_t> durations;
@@ -420,8 +414,7 @@ status_t MPEG2TSExtractor::estimateDurationsFromTimesUsAtEnd() {
                ev.reset();

                int64_t firstTimeUs;
                sp<AnotherPacketSource> src =
                    (AnotherPacketSource *)mParser->getSource(type).get();
                sp<AnotherPacketSource> src = mParser->getSource(type);
                if (src == NULL || src->nextBufferTime(&firstTimeUs) != OK) {
                    continue;
                }
@@ -449,7 +442,7 @@ status_t MPEG2TSExtractor::estimateDurationsFromTimesUsAtEnd() {
        if (!allDurationsFound) {
            allDurationsFound = true;
            for (auto t: {ATSParser::VIDEO, ATSParser::AUDIO}) {
                sp<AnotherPacketSource> src = (AnotherPacketSource *)mParser->getSource(t).get();
                sp<AnotherPacketSource> src = mParser->getSource(t);
                if (src == NULL) {
                    continue;
                }
+9 −9
Original line number Diff line number Diff line
@@ -77,7 +77,7 @@ struct ATSParser::Program : public RefBase {

    void signalEOS(status_t finalResult);

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

    int64_t convertPTSToTimestamp(uint64_t PTS);
@@ -170,7 +170,7 @@ struct ATSParser::Stream : public RefBase {
    void signalEOS(status_t finalResult);

    SourceType getSourceType();
    sp<MediaSource> getSource(SourceType type);
    sp<AnotherPacketSource> getSource(SourceType type);

    bool isAudio() const;
    bool isVideo() const;
@@ -274,7 +274,7 @@ private:
ATSParser::SyncEvent::SyncEvent(off64_t offset)
    : mHasReturnedData(false), mOffset(offset), mTimeUs(0) {}

void ATSParser::SyncEvent::init(off64_t offset, const sp<MediaSource> &source,
void ATSParser::SyncEvent::init(off64_t offset, const sp<AnotherPacketSource> &source,
        int64_t timeUs, SourceType type) {
    mHasReturnedData = true;
    mOffset = offset;
@@ -641,9 +641,9 @@ int64_t ATSParser::Program::recoverPTS(uint64_t PTS_33bit) {
    return mLastRecoveredPTS;
}

sp<MediaSource> ATSParser::Program::getSource(SourceType type) {
sp<AnotherPacketSource> ATSParser::Program::getSource(SourceType type) {
    for (size_t i = 0; i < mStreams.size(); ++i) {
        sp<MediaSource> source = mStreams.editValueAt(i)->getSource(type);
        sp<AnotherPacketSource> source = mStreams.editValueAt(i)->getSource(type);
        if (source != NULL) {
            return source;
        }
@@ -1607,7 +1607,7 @@ ATSParser::SourceType ATSParser::Stream::getSourceType() {
    return NUM_SOURCE_TYPES;
}

sp<MediaSource> ATSParser::Stream::getSource(SourceType type) {
sp<AnotherPacketSource> ATSParser::Stream::getSource(SourceType type) {
    switch (type) {
        case VIDEO:
        {
@@ -2042,11 +2042,11 @@ status_t ATSParser::parseTS(ABitReader *br, SyncEvent *event) {
    return err;
}

sp<MediaSource> ATSParser::getSource(SourceType type) {
    sp<MediaSource> firstSourceFound;
sp<AnotherPacketSource> ATSParser::getSource(SourceType type) {
    sp<AnotherPacketSource> firstSourceFound;
    for (size_t i = 0; i < mPrograms.size(); ++i) {
        const sp<Program> &program = mPrograms.editItemAt(i);
        sp<MediaSource> source = program->getSource(type);
        sp<AnotherPacketSource> source = program->getSource(type);
        if (source == NULL) {
            continue;
        }
+4 −4
Original line number Diff line number Diff line
@@ -81,13 +81,13 @@ struct ATSParser : public RefBase {
    struct SyncEvent {
        explicit SyncEvent(off64_t offset);

        void init(off64_t offset, const sp<MediaSource> &source,
        void init(off64_t offset, const sp<AnotherPacketSource> &source,
                int64_t timeUs, SourceType type);

        bool hasReturnedData() const { return mHasReturnedData; }
        void reset();
        off64_t getOffset() const { return mOffset; }
        const sp<MediaSource> &getMediaSource() const { return mMediaSource; }
        const sp<AnotherPacketSource> &getMediaSource() const { return mMediaSource; }
        int64_t getTimeUs() const { return mTimeUs; }
        SourceType getType() const { return mType; }

@@ -100,7 +100,7 @@ struct ATSParser : public RefBase {
         */
        off64_t mOffset;
        /* The media source object for this event. */
        sp<MediaSource> mMediaSource;
        sp<AnotherPacketSource> mMediaSource;
        /* The timestamp of the sync frame. */
        int64_t mTimeUs;
        SourceType mType;
@@ -126,7 +126,7 @@ struct ATSParser : public RefBase {

    void signalEOS(status_t finalResult);

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

    bool PTSTimeDeltaEstablished();