diff options
author | Chong Zhang <chz@google.com> | 2015-03-27 15:53:45 -0700 |
---|---|---|
committer | Chong Zhang <chz@google.com> | 2015-04-02 16:31:09 -0700 |
commit | d47dfcb5a2e5901c96fc92662cec7aa30f7f8843 (patch) | |
tree | ac077cfad563e38bf91e4b2c95e7e28056bf7439 /media/libstagefright/Utils.cpp | |
parent | ac41a6f253a69671f6e018fcc84daf0030615ca9 (diff) | |
download | frameworks_av-d47dfcb5a2e5901c96fc92662cec7aa30f7f8843.zip frameworks_av-d47dfcb5a2e5901c96fc92662cec7aa30f7f8843.tar.gz frameworks_av-d47dfcb5a2e5901c96fc92662cec7aa30f7f8843.tar.bz2 |
HLS: misc bug fixes
- fix no target-duration case
- fix for audio-only <=> audio/video switching
- disable audio-only variants if there is at least
one variant with video
- fix mpeg2ts PTS wraparound when bandwidth adapting
- tweak up/down switch marks
bug: 19567254
Change-Id: Ib46144203c56dfc96eccd6ddaa3867e8a4f2c6a9
Diffstat (limited to 'media/libstagefright/Utils.cpp')
-rw-r--r-- | media/libstagefright/Utils.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/media/libstagefright/Utils.cpp b/media/libstagefright/Utils.cpp index c0be136..8506e37 100644 --- a/media/libstagefright/Utils.cpp +++ b/media/libstagefright/Utils.cpp @@ -822,5 +822,36 @@ AString uriDebugString(const AString &uri, bool incognito) { return AString("<no-scheme URI suppressed>"); } +HLSTime::HLSTime(const sp<AMessage>& meta) : + mSeq(-1), + mTimeUs(-1ll), + mMeta(meta) { + if (meta != NULL) { + CHECK(meta->findInt32("discontinuitySeq", &mSeq)); + CHECK(meta->findInt64("timeUs", &mTimeUs)); + } +} + +int64_t HLSTime::getSegmentTimeUs(bool midpoint) const { + int64_t segmentStartTimeUs = -1ll; + if (mMeta != NULL) { + CHECK(mMeta->findInt64("segmentStartTimeUs", &segmentStartTimeUs)); + if (midpoint) { + int64_t durationUs; + CHECK(mMeta->findInt64("segmentDurationUs", &durationUs)); + segmentStartTimeUs += durationUs / 2; + } + } + return segmentStartTimeUs; +} + +bool operator <(const HLSTime &t0, const HLSTime &t1) { + // we can only compare discontinuity sequence and timestamp. + // (mSegmentTimeUs is not reliable in live streaming case, it's the + // time starting from beginning of playlist but playlist could change.) + return t0.mSeq < t1.mSeq + || (t0.mSeq == t1.mSeq && t0.mTimeUs < t1.mTimeUs); +} + } // namespace android |