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

Commit b69e0c39 authored by Lajos Molnar's avatar Lajos Molnar Committed by Android (Google) Code Review
Browse files

Merge "stagefright: Fix issue with tracking media format in packet source"

parents bd72d220 fd9b01b9
Loading
Loading
Loading
Loading
+5 −4
Original line number Original line Diff line number Diff line
@@ -861,11 +861,12 @@ status_t PlaylistFetcher::extractAndQueueAccessUnits(
                    && source->dequeueAccessUnit(&accessUnit) == OK) {
                    && source->dequeueAccessUnit(&accessUnit) == OK) {
                // Note that we do NOT dequeue any discontinuities.
                // Note that we do NOT dequeue any discontinuities.


                packetSource->queueAccessUnit(accessUnit);
                // for simplicity, store a reference to the format in each unit
                sp<MetaData> format = source->getFormat();
                if (format != NULL) {
                    accessUnit->meta()->setObject("format", format);
                }
                }

                packetSource->queueAccessUnit(accessUnit);
            if (packetSource->getFormat() == NULL) {
                packetSource->setFormat(source->getFormat());
            }
            }
        }
        }


+39 −9
Original line number Original line Diff line number Diff line
@@ -70,9 +70,29 @@ status_t AnotherPacketSource::stop() {
}
}


sp<MetaData> AnotherPacketSource::getFormat() {
sp<MetaData> AnotherPacketSource::getFormat() {
    Mutex::Autolock autoLock(mLock);
    if (mFormat != NULL) {
        return mFormat;
        return mFormat;
    }
    }


    List<sp<ABuffer> >::iterator it = mBuffers.begin();
    while (it != mBuffers.end()) {
        sp<ABuffer> buffer = *it;
        int32_t discontinuity;
        if (buffer->meta()->findInt32("discontinuity", &discontinuity)) {
            break;
        }

        sp<RefBase> object;
        if (buffer->meta()->findObject("format", &object)) {
            return static_cast<MetaData*>(object.get());
        }

        ++it;
    }
    return NULL;
}

status_t AnotherPacketSource::dequeueAccessUnit(sp<ABuffer> *buffer) {
status_t AnotherPacketSource::dequeueAccessUnit(sp<ABuffer> *buffer) {
    buffer->clear();
    buffer->clear();


@@ -94,6 +114,11 @@ status_t AnotherPacketSource::dequeueAccessUnit(sp<ABuffer> *buffer) {
            return INFO_DISCONTINUITY;
            return INFO_DISCONTINUITY;
        }
        }


        sp<RefBase> object;
        if ((*buffer)->meta()->findObject("format", &object)) {
            mFormat = static_cast<MetaData*>(object.get());
        }

        return OK;
        return OK;
    }
    }


@@ -120,7 +145,13 @@ status_t AnotherPacketSource::read(
            }
            }


            return INFO_DISCONTINUITY;
            return INFO_DISCONTINUITY;
        } else {
        }

        sp<RefBase> object;
        if (buffer->meta()->findObject("format", &object)) {
            mFormat = static_cast<MetaData*>(object.get());
        }

        int64_t timeUs;
        int64_t timeUs;
        CHECK(buffer->meta()->findInt64("timeUs", &timeUs));
        CHECK(buffer->meta()->findInt64("timeUs", &timeUs));


@@ -131,7 +162,6 @@ status_t AnotherPacketSource::read(
        *out = mediaBuffer;
        *out = mediaBuffer;
        return OK;
        return OK;
    }
    }
    }


    return mEOSResult;
    return mEOSResult;
}
}