summaryrefslogtreecommitdiffstats
path: root/media/libstagefright/Utils.cpp
diff options
context:
space:
mode:
authorChong Zhang <chz@google.com>2015-04-12 01:03:51 -0700
committerChong Zhang <chz@google.com>2015-04-17 14:26:32 -0700
commit978449984366946a2e5c9f7cf350746f4306caf8 (patch)
tree21d406ec763c97554a5db234b49807ecb7a659b2 /media/libstagefright/Utils.cpp
parent2170233c49e50f3986cdc4f726016d6003cb5b8e (diff)
downloadframeworks_av-978449984366946a2e5c9f7cf350746f4306caf8.zip
frameworks_av-978449984366946a2e5c9f7cf350746f4306caf8.tar.gz
frameworks_av-978449984366946a2e5c9f7cf350746f4306caf8.tar.bz2
HLS: reduce number of guessed wrong seq numbers
- account for playlist age in live streaming when calculating segment time - be more conservative on downswitching if bandwidth is unstable - adjust forward or backward if guessed wrong seq number - code refactor bug: 19567254 Change-Id: I0b61cea888fdffd1b3ee2446747ed10152e9e7d7
Diffstat (limited to 'media/libstagefright/Utils.cpp')
-rw-r--r--media/libstagefright/Utils.cpp24
1 files changed, 21 insertions, 3 deletions
diff --git a/media/libstagefright/Utils.cpp b/media/libstagefright/Utils.cpp
index dfe8ad1..0d8e64a 100644
--- a/media/libstagefright/Utils.cpp
+++ b/media/libstagefright/Utils.cpp
@@ -852,14 +852,32 @@ HLSTime::HLSTime(const sp<AMessage>& meta) :
}
}
-int64_t HLSTime::getSegmentTimeUs(bool midpoint) const {
+int64_t HLSTime::getSegmentTimeUs() const {
int64_t segmentStartTimeUs = -1ll;
if (mMeta != NULL) {
CHECK(mMeta->findInt64("segmentStartTimeUs", &segmentStartTimeUs));
- if (midpoint) {
+
+ int64_t segmentFirstTimeUs;
+ if (mMeta->findInt64("segmentFirstTimeUs", &segmentFirstTimeUs)) {
+ segmentStartTimeUs += mTimeUs - segmentFirstTimeUs;
+ }
+
+ // adjust segment time by playlist age (for live streaming)
+ int64_t playlistTimeUs;
+ if (mMeta->findInt64("playlistTimeUs", &playlistTimeUs)) {
+ int64_t playlistAgeUs = ALooper::GetNowUs() - playlistTimeUs;
+
int64_t durationUs;
CHECK(mMeta->findInt64("segmentDurationUs", &durationUs));
- segmentStartTimeUs += durationUs / 2;
+
+ // round to nearest whole segment
+ playlistAgeUs = (playlistAgeUs + durationUs / 2)
+ / durationUs * durationUs;
+
+ segmentStartTimeUs -= playlistAgeUs;
+ if (segmentStartTimeUs < 0) {
+ segmentStartTimeUs = 0;
+ }
}
}
return segmentStartTimeUs;