diff --git a/packager/media/base/media_handler_test_base.cc b/packager/media/base/media_handler_test_base.cc index 38ef98f8be..3127a2422d 100644 --- a/packager/media/base/media_handler_test_base.cc +++ b/packager/media/base/media_handler_test_base.cc @@ -81,6 +81,21 @@ bool TryMatchStreamDataType(const StreamDataType& actual, return true; } +bool TryMatchStreamType(const StreamType& actual, + const StreamType& expected, + ::testing::MatchResultListener* listener) { + if (actual != expected) { + std::string expected_as_string = StreamTypeToString(expected); + std::string actual_as_string = StreamTypeToString(actual); + + *listener << "which is " << actual_as_string << " (expected " + << expected_as_string << ")"; + return false; + } + + return true; +} + std::string ToPrettyString(const std::string& str) { std::string out; diff --git a/packager/media/base/media_handler_test_base.h b/packager/media/base/media_handler_test_base.h index 60a83b1939..68fbfa793c 100644 --- a/packager/media/base/media_handler_test_base.h +++ b/packager/media/base/media_handler_test_base.h @@ -12,6 +12,7 @@ #include "packager/base/strings/string_number_conversions.h" #include "packager/media/base/media_handler.h" +#include "packager/media/base/video_stream_info.h" namespace shaka { namespace media { @@ -23,6 +24,10 @@ bool TryMatchStreamDataType(const StreamDataType& actual, const StreamDataType& expected, ::testing::MatchResultListener* listener); +bool TryMatchStreamType(const StreamType& actual, + const StreamType& expected, + ::testing::MatchResultListener* listener); + template bool TryMatch(const T& value, const M& matcher, @@ -62,6 +67,32 @@ MATCHER_P4(IsStreamInfo, stream_index, time_scale, encrypted, language, "") { "language"); } +MATCHER_P3(IsVideoStream, stream_index, trick_play_factor, playback_rate, "") { + if (!TryMatchStreamDataType(arg->stream_data_type, + StreamDataType::kStreamInfo, result_listener)) { + return false; + } + + if (!TryMatchStreamType(arg->stream_info->stream_type(), kStreamVideo, + result_listener)) { + return false; + } + + const VideoStreamInfo* info = + static_cast(arg->stream_info.get()); + + *result_listener << "which is (" << arg->stream_index << ", " + << info->trick_play_factor() << ", " << info->playback_rate() + << ")"; + + return TryMatch(arg->stream_index, stream_index, result_listener, + "stream_index") && + TryMatch(info->trick_play_factor(), trick_play_factor, result_listener, + "trick_play_factor") && + TryMatch(info->playback_rate(), playback_rate, result_listener, + "playback_rate"); +} + MATCHER_P5(IsSegmentInfo, stream_index, start_timestamp,