From ca810e06d5222991bb9fbaa98de8f86d28313853 Mon Sep 17 00:00:00 2001 From: KongQun Yang Date: Wed, 1 Aug 2018 15:05:37 -0700 Subject: [PATCH] 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 --- .../audio-video-with-two-trick-play/output.mpd | 12 ++++++------ .../encryption-and-two-trick-plays/output.mpd | 12 ++++++------ packager/packager.cc | 11 ++++++----- 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/packager/app/test/testdata/audio-video-with-two-trick-play/output.mpd b/packager/app/test/testdata/audio-video-with-two-trick-play/output.mpd index 785c185548..06363446d4 100644 --- a/packager/app/test/testdata/audio-video-with-two-trick-play/output.mpd +++ b/packager/app/test/testdata/audio-video-with-two-trick-play/output.mpd @@ -12,15 +12,15 @@ - - bear-640x360-video-trick_play_factor_2.mp4 - + + bear-640x360-video-trick_play_factor_1.mp4 + - - bear-640x360-video-trick_play_factor_1.mp4 - + + bear-640x360-video-trick_play_factor_2.mp4 + diff --git a/packager/app/test/testdata/encryption-and-two-trick-plays/output.mpd b/packager/app/test/testdata/encryption-and-two-trick-plays/output.mpd index f2cb141877..29c07d0482 100644 --- a/packager/app/test/testdata/encryption-and-two-trick-plays/output.mpd +++ b/packager/app/test/testdata/encryption-and-two-trick-plays/output.mpd @@ -20,15 +20,15 @@ AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA== - - bear-640x360-video-trick_play_factor_2.mp4 - + + bear-640x360-video-trick_play_factor_1.mp4 + - - bear-640x360-video-trick_play_factor_1.mp4 - + + bear-640x360-video-trick_play_factor_2.mp4 + diff --git a/packager/packager.cc b/packager/packager.cc index 82ba9a2ab5..b3a2aafd25 100644 --- a/packager/packager.cc +++ b/packager/packager.cc @@ -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; }