diff options
author | Chong Zhang <chz@google.com> | 2015-03-18 10:31:13 -0700 |
---|---|---|
committer | Chong Zhang <chz@google.com> | 2015-03-20 15:30:53 -0700 |
commit | a48d372833ccec13c96ece9efcc226e8beac7f59 (patch) | |
tree | d525483a442a026414d9ff33550153f65d007b93 /media/libstagefright/mpeg2ts | |
parent | 7c963e92bc11d4b6a22696c51f9abf42987a1f74 (diff) | |
download | frameworks_av-a48d372833ccec13c96ece9efcc226e8beac7f59.zip frameworks_av-a48d372833ccec13c96ece9efcc226e8beac7f59.tar.gz frameworks_av-a48d372833ccec13c96ece9efcc226e8beac7f59.tar.bz2 |
HLS: allow pause/resume in the middle of a segment
- when down switching, decide whether to finish current segment
based on bandwidth settings, abort current segment if needed.
- when switching, pause new fetcher after the first 47K chunk,
and go back to resume old fethcer to stop point immediately.
- when old fetcher reaches stop point, swap packet sources and
resume new fetcher.
- mark switching as done as soon as old fecther reaches stop
point. This allows us to resume bandwidth monitoring earlier,
and do subsequent switches sooner.
bug: 19567254
Change-Id: Iba4b5fb9b06541bb1e49592536648f5d4cbc69ab
Diffstat (limited to 'media/libstagefright/mpeg2ts')
-rw-r--r-- | media/libstagefright/mpeg2ts/ATSParser.h | 3 | ||||
-rw-r--r-- | media/libstagefright/mpeg2ts/AnotherPacketSource.cpp | 16 | ||||
-rw-r--r-- | media/libstagefright/mpeg2ts/AnotherPacketSource.h | 4 |
3 files changed, 23 insertions, 0 deletions
diff --git a/media/libstagefright/mpeg2ts/ATSParser.h b/media/libstagefright/mpeg2ts/ATSParser.h index 75d76dc..5c50747 100644 --- a/media/libstagefright/mpeg2ts/ATSParser.h +++ b/media/libstagefright/mpeg2ts/ATSParser.h @@ -46,6 +46,9 @@ struct ATSParser : public RefBase { DISCONTINUITY_AUDIO_FORMAT | DISCONTINUITY_VIDEO_FORMAT | DISCONTINUITY_TIME, + DISCONTINUITY_FORMAT_ONLY = + DISCONTINUITY_AUDIO_FORMAT + | DISCONTINUITY_VIDEO_FORMAT, }; enum Flags { diff --git a/media/libstagefright/mpeg2ts/AnotherPacketSource.cpp b/media/libstagefright/mpeg2ts/AnotherPacketSource.cpp index 79a9b04..9f42217 100644 --- a/media/libstagefright/mpeg2ts/AnotherPacketSource.cpp +++ b/media/libstagefright/mpeg2ts/AnotherPacketSource.cpp @@ -298,6 +298,7 @@ void AnotherPacketSource::signalEOS(status_t result) { bool AnotherPacketSource::hasBufferAvailable(status_t *finalResult) { Mutex::Autolock autoLock(mLock); + *finalResult = OK; if (!mBuffers.empty()) { return true; } @@ -306,6 +307,21 @@ bool AnotherPacketSource::hasBufferAvailable(status_t *finalResult) { return false; } +bool AnotherPacketSource::hasDataBufferAvailable(status_t *finalResult) { + Mutex::Autolock autoLock(mLock); + *finalResult = OK; + List<sp<ABuffer> >::iterator it; + for (it = mBuffers.begin(); it != mBuffers.end(); it++) { + int32_t discontinuity; + if (!(*it)->meta()->findInt32("discontinuity", &discontinuity)) { + return true; + } + } + + *finalResult = mEOSResult; + return false; +} + int64_t AnotherPacketSource::getBufferedDurationUs(status_t *finalResult) { Mutex::Autolock autoLock(mLock); return getBufferedDurationUs_l(finalResult); diff --git a/media/libstagefright/mpeg2ts/AnotherPacketSource.h b/media/libstagefright/mpeg2ts/AnotherPacketSource.h index 809a858..d4fde7c 100644 --- a/media/libstagefright/mpeg2ts/AnotherPacketSource.h +++ b/media/libstagefright/mpeg2ts/AnotherPacketSource.h @@ -43,8 +43,12 @@ struct AnotherPacketSource : public MediaSource { void clear(); + // Returns true if we have any packets including discontinuities bool hasBufferAvailable(status_t *finalResult); + // Returns true if we have packets that's not discontinuities + bool hasDataBufferAvailable(status_t *finalResult); + // Returns the difference between the last and the first queued // presentation timestamps since the last discontinuity (if any). int64_t getBufferedDurationUs(status_t *finalResult); |