Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d47dfcb5 authored by Chong Zhang's avatar Chong Zhang
Browse files

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
parent ac41a6f2
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -81,6 +81,13 @@ struct IStreamListener : public IInterface {
    // with the next PTS occuring in the stream. The value is of type int64_t.
    static const char *const kKeyMediaTimeUs;

    // Optionally signalled as part of a discontinuity that includes
    // DISCONTINUITY_TIME. It indicates the media time (in us) of a recent
    // sample from the same content, and is used as a hint for the parser to
    // handle PTS wraparound. This is required when a new parser is created
    // to continue parsing content from the same timeline.
    static const char *const kKeyRecentMediaTimeUs;

    virtual void issueCommand(
            Command cmd, bool synchronous, const sp<AMessage> &msg = NULL) = 0;
};
+11 −0
Original line number Diff line number Diff line
@@ -65,6 +65,17 @@ bool canOffloadStream(const sp<MetaData>& meta, bool hasVideo,

AString uriDebugString(const AString &uri, bool incognito = false);

struct HLSTime {
    int32_t mSeq;
    int64_t mTimeUs;
    sp<AMessage> mMeta;

    HLSTime(const sp<AMessage> &meta = NULL);
    int64_t getSegmentTimeUs(bool midpoint = false) const;
};

bool operator <(const HLSTime &t0, const HLSTime &t1);

}  // namespace android

#endif  // UTILS_H_
+3 −0
Original line number Diff line number Diff line
@@ -35,6 +35,9 @@ const char *const IStreamListener::kKeyDiscontinuityMask = "discontinuity-mask";
// static
const char *const IStreamListener::kKeyMediaTimeUs = "media-time-us";

// static
const char *const IStreamListener::kKeyRecentMediaTimeUs = "recent-media-time-us";

enum {
    // IStreamSource
    SET_LISTENER = IBinder::FIRST_CALL_TRANSACTION,
+31 −0
Original line number Diff line number Diff line
@@ -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
+121 −154

File changed.

Preview size limit exceeded, changes collapsed.

Loading