diff options
author | Chong Zhang <chz@google.com> | 2015-04-08 20:28:01 -0700 |
---|---|---|
committer | Chong Zhang <chz@google.com> | 2015-04-09 13:00:26 -0700 |
commit | 8464d7decb34a3044e92b4085f1bbaafb51410e8 (patch) | |
tree | 651466c37638fbe1fc231227ad9be0d896d1db8b /media/libstagefright/mpeg2ts | |
parent | b6347ac62b36b4d9578d181ba83bf8e6446298e8 (diff) | |
download | frameworks_av-8464d7decb34a3044e92b4085f1bbaafb51410e8.zip frameworks_av-8464d7decb34a3044e92b4085f1bbaafb51410e8.tar.gz frameworks_av-8464d7decb34a3044e92b4085f1bbaafb51410e8.tar.bz2 |
HLS: allow down switch during prepare
to avoid having to immediately down switch (and pause)
after playback starts.
do not count "discard" packet when estimating duration.
bug: 19567254
Change-Id: I0cdd37a06ca800dd81a91cca5eb9b46a1eab7b20
Diffstat (limited to 'media/libstagefright/mpeg2ts')
-rw-r--r-- | media/libstagefright/mpeg2ts/AnotherPacketSource.cpp | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/media/libstagefright/mpeg2ts/AnotherPacketSource.cpp b/media/libstagefright/mpeg2ts/AnotherPacketSource.cpp index 0676a33..c7912c0 100644 --- a/media/libstagefright/mpeg2ts/AnotherPacketSource.cpp +++ b/media/libstagefright/mpeg2ts/AnotherPacketSource.cpp @@ -355,10 +355,15 @@ int64_t AnotherPacketSource::getBufferedDurationUs_l(status_t *finalResult) { int64_t time2 = -1; int64_t durationUs = 0; - List<sp<ABuffer> >::iterator it = mBuffers.begin(); - while (it != mBuffers.end()) { + List<sp<ABuffer> >::iterator it; + for (it = mBuffers.begin(); it != mBuffers.end(); it++) { const sp<ABuffer> &buffer = *it; + int32_t discard; + if (buffer->meta()->findInt32("discard", &discard) && discard) { + continue; + } + int64_t timeUs; if (buffer->meta()->findInt64("timeUs", &timeUs)) { if (time1 < 0 || timeUs < time1) { @@ -373,8 +378,6 @@ int64_t AnotherPacketSource::getBufferedDurationUs_l(status_t *finalResult) { durationUs += time2 - time1; time1 = time2 = -1; } - - ++it; } return durationUs + (time2 - time1); @@ -393,11 +396,19 @@ int64_t AnotherPacketSource::getEstimatedDurationUs() { return getBufferedDurationUs_l(&finalResult); } - List<sp<ABuffer> >::iterator it = mBuffers.begin(); - sp<ABuffer> buffer = *it; + sp<ABuffer> buffer; + int32_t discard; + int64_t startTimeUs = -1ll; + List<sp<ABuffer> >::iterator it; + for (it = mBuffers.begin(); it != mBuffers.end(); it++) { + buffer = *it; + if (buffer->meta()->findInt32("discard", &discard) && discard) { + continue; + } + buffer->meta()->findInt64("timeUs", &startTimeUs); + break; + } - int64_t startTimeUs; - buffer->meta()->findInt64("timeUs", &startTimeUs); if (startTimeUs < 0) { return 0; } |