diff options
author | Andreas Huber <andih@google.com> | 2010-09-08 14:32:20 -0700 |
---|---|---|
committer | Andreas Huber <andih@google.com> | 2010-10-07 11:41:43 -0700 |
commit | 2a4d22d79e927f2245537921e10fc5fda1c47a29 (patch) | |
tree | 1452ec4c157a5f701d4aea84f2107477d5324d94 /media/libstagefright/mpeg2ts/AnotherPacketSource.cpp | |
parent | 2b82e9652ba049e754c2cc74e381282f231d5fbf (diff) | |
download | frameworks_av-2a4d22d79e927f2245537921e10fc5fda1c47a29.zip frameworks_av-2a4d22d79e927f2245537921e10fc5fda1c47a29.tar.gz frameworks_av-2a4d22d79e927f2245537921e10fc5fda1c47a29.tar.bz2 |
Work to support switching transport streams mid-stream and signalling discontinuities to the decoder.
Change-Id: I7150e5e7342e1117c524856b204aadcb763e06ed
related-to-bug: 2368598
Diffstat (limited to 'media/libstagefright/mpeg2ts/AnotherPacketSource.cpp')
-rw-r--r-- | media/libstagefright/mpeg2ts/AnotherPacketSource.cpp | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/media/libstagefright/mpeg2ts/AnotherPacketSource.cpp b/media/libstagefright/mpeg2ts/AnotherPacketSource.cpp index 3d51177..3f76820 100644 --- a/media/libstagefright/mpeg2ts/AnotherPacketSource.cpp +++ b/media/libstagefright/mpeg2ts/AnotherPacketSource.cpp @@ -59,21 +59,26 @@ status_t AnotherPacketSource::read( if (!mBuffers.empty()) { const sp<ABuffer> buffer = *mBuffers.begin(); + mBuffers.erase(mBuffers.begin()); - uint64_t timeUs; - CHECK(buffer->meta()->findInt64( - "time", (int64_t *)&timeUs)); - - MediaBuffer *mediaBuffer = new MediaBuffer(buffer->size()); - mediaBuffer->meta_data()->setInt64(kKeyTime, timeUs); + int32_t discontinuity; + if (buffer->meta()->findInt32("discontinuity", &discontinuity) + && discontinuity) { + return INFO_DISCONTINUITY; + } else { + uint64_t timeUs; + CHECK(buffer->meta()->findInt64( + "time", (int64_t *)&timeUs)); - // hexdump(buffer->data(), buffer->size()); + MediaBuffer *mediaBuffer = new MediaBuffer(buffer->size()); + mediaBuffer->meta_data()->setInt64(kKeyTime, timeUs); - memcpy(mediaBuffer->data(), buffer->data(), buffer->size()); - *out = mediaBuffer; + // hexdump(buffer->data(), buffer->size()); - mBuffers.erase(mBuffers.begin()); - return OK; + memcpy(mediaBuffer->data(), buffer->data(), buffer->size()); + *out = mediaBuffer; + return OK; + } } return mEOSResult; @@ -91,6 +96,15 @@ void AnotherPacketSource::queueAccessUnit(const sp<ABuffer> &buffer) { mCondition.signal(); } +void AnotherPacketSource::queueDiscontinuity() { + sp<ABuffer> buffer = new ABuffer(0); + buffer->meta()->setInt32("discontinuity", true); + + Mutex::Autolock autoLock(mLock); + mBuffers.push_back(buffer); + mCondition.signal(); +} + void AnotherPacketSource::signalEOS(status_t result) { CHECK(result != OK); |