Order trickplay outputs in trickplay factor ASC order

This also ensures that it does not violate std::sort() requirement on
strict ordering, which is enforced in gcc/g++ though not in clang.

std::sort() strict ordering requirement:
std::sort() need a comparator that return true iff the first argument is
strictly lower than the second one. That is: must return false when they
are equal.

Change-Id: I781cf4ed4125fcad212eba5430a264f3a3d71c16
This commit is contained in:
KongQun Yang 2018-08-01 15:05:37 -07:00
parent 32e3ff3e25
commit ca810e06d5
3 changed files with 18 additions and 17 deletions

View File

@ -12,15 +12,15 @@
</AdaptationSet>
<AdaptationSet id="1" contentType="video" width="640" height="360" maxFrameRate="30000/30030" par="16:9">
<EssentialProperty schemeIdUri="http://dashif.org/guidelines/trickmode" value="0"/>
<Representation id="1" bandwidth="211545" codecs="avc1.64001e" mimeType="video/mp4" sar="1:1" frameRate="30000/60060" maxPlayoutRate="60" codingDependency="false">
<BaseURL>bear-640x360-video-trick_play_factor_2.mp4</BaseURL>
<SegmentBase indexRange="859-914" timescale="30000">
<Representation id="1" bandwidth="211545" codecs="avc1.64001e" mimeType="video/mp4" sar="1:1" frameRate="30000/30030" maxPlayoutRate="30" codingDependency="false">
<BaseURL>bear-640x360-video-trick_play_factor_1.mp4</BaseURL>
<SegmentBase indexRange="859-926" timescale="30000">
<Initialization range="0-858"/>
</SegmentBase>
</Representation>
<Representation id="2" bandwidth="211545" codecs="avc1.64001e" mimeType="video/mp4" sar="1:1" frameRate="30000/30030" maxPlayoutRate="30" codingDependency="false">
<BaseURL>bear-640x360-video-trick_play_factor_1.mp4</BaseURL>
<SegmentBase indexRange="859-926" timescale="30000">
<Representation id="2" bandwidth="211545" codecs="avc1.64001e" mimeType="video/mp4" sar="1:1" frameRate="30000/60060" maxPlayoutRate="60" codingDependency="false">
<BaseURL>bear-640x360-video-trick_play_factor_2.mp4</BaseURL>
<SegmentBase indexRange="859-914" timescale="30000">
<Initialization range="0-858"/>
</SegmentBase>
</Representation>

View File

@ -20,15 +20,15 @@
<cenc:pssh>AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA==</cenc:pssh>
</ContentProtection>
<EssentialProperty schemeIdUri="http://dashif.org/guidelines/trickmode" value="0"/>
<Representation id="1" bandwidth="212297" codecs="avc1.64001e" mimeType="video/mp4" sar="1:1" frameRate="30000/60060" maxPlayoutRate="60" codingDependency="false">
<BaseURL>bear-640x360-video-trick_play_factor_2.mp4</BaseURL>
<SegmentBase indexRange="1127-1182" timescale="30000">
<Representation id="1" bandwidth="212297" codecs="avc1.64001e" mimeType="video/mp4" sar="1:1" frameRate="30000/30030" maxPlayoutRate="30" codingDependency="false">
<BaseURL>bear-640x360-video-trick_play_factor_1.mp4</BaseURL>
<SegmentBase indexRange="1127-1194" timescale="30000">
<Initialization range="0-1126"/>
</SegmentBase>
</Representation>
<Representation id="2" bandwidth="212297" codecs="avc1.64001e" mimeType="video/mp4" sar="1:1" frameRate="30000/30030" maxPlayoutRate="30" codingDependency="false">
<BaseURL>bear-640x360-video-trick_play_factor_1.mp4</BaseURL>
<SegmentBase indexRange="1127-1194" timescale="30000">
<Representation id="2" bandwidth="212297" codecs="avc1.64001e" mimeType="video/mp4" sar="1:1" frameRate="30000/60060" maxPlayoutRate="60" codingDependency="false">
<BaseURL>bear-640x360-video-trick_play_factor_2.mp4</BaseURL>
<SegmentBase indexRange="1127-1182" timescale="30000">
<Initialization range="0-1126"/>
</SegmentBase>
</Representation>

View File

@ -317,15 +317,16 @@ Status ValidateParams(const PackagingParams& packaging_params,
bool StreamDescriptorCompareFn(const StreamDescriptor& a,
const StreamDescriptor& b) {
// This function is used by std::sort() to sort the stream descriptors.
// Note that std::sort() need a comparator that return true iff the first
// argument is strictly lower than the second one. That is: must return false
// when they are equal. The requirement is enforced in gcc/g++ but not in
// clang.
if (a.input == b.input) {
if (a.stream_selector == b.stream_selector) {
// The MPD notifier requires that the main track comes first, so make
// sure that happens.
if (a.trick_play_factor == 0 || b.trick_play_factor == 0) {
return a.trick_play_factor == 0;
} else {
return a.trick_play_factor > b.trick_play_factor;
}
return a.trick_play_factor < b.trick_play_factor;
} else {
return a.stream_selector < b.stream_selector;
}