Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(880)

Side by Side Diff: talk/media/webrtc/webrtcvideoengine2_unittest.cc

Issue 1407693005: Remove simulcast bitrate modes. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: remove constants Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « talk/media/webrtc/webrtcvideoengine2.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * libjingle 2 * libjingle
3 * Copyright 2004 Google Inc. 3 * Copyright 2004 Google Inc.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright notice, 8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer. 9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice, 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
(...skipping 2071 matching lines...) Expand 10 before | Expand all | Expand 10 after
2082 // Send a frame to make sure this scales up to >1 stream (simulcast). 2082 // Send a frame to make sure this scales up to >1 stream (simulcast).
2083 cricket::FakeVideoCapturer capturer; 2083 cricket::FakeVideoCapturer capturer;
2084 EXPECT_TRUE(channel_->SetCapturer(kSsrcs3[0], &capturer)); 2084 EXPECT_TRUE(channel_->SetCapturer(kSsrcs3[0], &capturer));
2085 EXPECT_EQ(cricket::CS_RUNNING, 2085 EXPECT_EQ(cricket::CS_RUNNING,
2086 capturer.Start(capturer.GetSupportedFormats()->front())); 2086 capturer.Start(capturer.GetSupportedFormats()->front()));
2087 EXPECT_TRUE(capturer.CaptureFrame()); 2087 EXPECT_TRUE(capturer.CaptureFrame());
2088 2088
2089 std::vector<webrtc::VideoStream> streams = stream->GetVideoStreams(); 2089 std::vector<webrtc::VideoStream> streams = stream->GetVideoStreams();
2090 ASSERT_GT(streams.size(), 1u) 2090 ASSERT_GT(streams.size(), 1u)
2091 << "Without simulcast this test doesn't make sense."; 2091 << "Without simulcast this test doesn't make sense.";
2092 int initial_max_bitrate_bps = 0; 2092 int initial_max_bitrate_bps = GetTotalMaxBitrateBps(streams);
2093 for (auto& video_stream : streams)
2094 initial_max_bitrate_bps += video_stream.max_bitrate_bps;
2095 EXPECT_GT(initial_max_bitrate_bps, 0); 2093 EXPECT_GT(initial_max_bitrate_bps, 0);
2096 2094
2097 parameters.max_bandwidth_bps = initial_max_bitrate_bps * 2; 2095 parameters.max_bandwidth_bps = initial_max_bitrate_bps * 2;
2098 EXPECT_TRUE(channel_->SetSendParameters(parameters)); 2096 EXPECT_TRUE(channel_->SetSendParameters(parameters));
2099 streams = stream->GetVideoStreams(); 2097 streams = stream->GetVideoStreams();
2100 int increased_max_bitrate_bps = 0; 2098 int increased_max_bitrate_bps = GetTotalMaxBitrateBps(streams);
2101 for (auto& video_stream : streams)
2102 increased_max_bitrate_bps += video_stream.max_bitrate_bps;
2103 EXPECT_EQ(initial_max_bitrate_bps * 2, increased_max_bitrate_bps); 2099 EXPECT_EQ(initial_max_bitrate_bps * 2, increased_max_bitrate_bps);
2104 2100
2105 EXPECT_TRUE(channel_->SetCapturer(kSsrcs3[0], nullptr)); 2101 EXPECT_TRUE(channel_->SetCapturer(kSsrcs3[0], nullptr));
2106 } 2102 }
2107 2103
2108 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithMaxQuantization) { 2104 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithMaxQuantization) {
2109 static const char* kMaxQuantization = "21"; 2105 static const char* kMaxQuantization = "21";
2110 cricket::VideoSendParameters parameters; 2106 cricket::VideoSendParameters parameters;
2111 parameters.codecs.push_back(kVp8Codec); 2107 parameters.codecs.push_back(kVp8Codec);
2112 parameters.codecs[0].params[kCodecParamMaxQuantization] = kMaxQuantization; 2108 parameters.codecs[0].params[kCodecParamMaxQuantization] = kMaxQuantization;
(...skipping 886 matching lines...) Expand 10 before | Expand all | Expand 10 after
2999 WebRtcVideoChannel2SimulcastTest() : fake_call_(webrtc::Call::Config()) {} 2995 WebRtcVideoChannel2SimulcastTest() : fake_call_(webrtc::Call::Config()) {}
3000 2996
3001 void SetUp() override { 2997 void SetUp() override {
3002 engine_.Init(); 2998 engine_.Init();
3003 channel_.reset(engine_.CreateChannel(&fake_call_, VideoOptions())); 2999 channel_.reset(engine_.CreateChannel(&fake_call_, VideoOptions()));
3004 last_ssrc_ = 123; 3000 last_ssrc_ = 123;
3005 } 3001 }
3006 3002
3007 protected: 3003 protected:
3008 void VerifySimulcastSettings(const VideoCodec& codec, 3004 void VerifySimulcastSettings(const VideoCodec& codec,
3009 VideoOptions::HighestBitrate bitrate_mode,
3010 size_t num_configured_streams, 3005 size_t num_configured_streams,
3011 size_t expected_num_streams, 3006 size_t expected_num_streams) {
3012 SimulcastBitrateMode simulcast_bitrate_mode) {
3013 cricket::VideoSendParameters parameters; 3007 cricket::VideoSendParameters parameters;
3014 parameters.options.video_highest_bitrate.Set(bitrate_mode);
3015 parameters.codecs.push_back(codec); 3008 parameters.codecs.push_back(codec);
3016 ASSERT_TRUE(channel_->SetSendParameters(parameters)); 3009 ASSERT_TRUE(channel_->SetSendParameters(parameters));
3017 3010
3018 std::vector<uint32_t> ssrcs = MAKE_VECTOR(kSsrcs3); 3011 std::vector<uint32_t> ssrcs = MAKE_VECTOR(kSsrcs3);
3019 RTC_DCHECK(num_configured_streams <= ssrcs.size()); 3012 RTC_DCHECK(num_configured_streams <= ssrcs.size());
3020 ssrcs.resize(num_configured_streams); 3013 ssrcs.resize(num_configured_streams);
3021 3014
3022 FakeVideoSendStream* stream = 3015 FakeVideoSendStream* stream =
3023 AddSendStream(CreateSimStreamParams("cname", ssrcs)); 3016 AddSendStream(CreateSimStreamParams("cname", ssrcs));
3024 // Send a full-size frame to trigger a stream reconfiguration to use all 3017 // Send a full-size frame to trigger a stream reconfiguration to use all
3025 // expected simulcast layers. 3018 // expected simulcast layers.
3026 cricket::FakeVideoCapturer capturer; 3019 cricket::FakeVideoCapturer capturer;
3027 EXPECT_TRUE(channel_->SetCapturer(ssrcs.front(), &capturer)); 3020 EXPECT_TRUE(channel_->SetCapturer(ssrcs.front(), &capturer));
3028 EXPECT_EQ(cricket::CS_RUNNING, capturer.Start(cricket::VideoFormat( 3021 EXPECT_EQ(cricket::CS_RUNNING, capturer.Start(cricket::VideoFormat(
3029 codec.width, codec.height, 3022 codec.width, codec.height,
3030 cricket::VideoFormat::FpsToInterval(30), 3023 cricket::VideoFormat::FpsToInterval(30),
3031 cricket::FOURCC_I420))); 3024 cricket::FOURCC_I420)));
3032 channel_->SetSend(true); 3025 channel_->SetSend(true);
3033 EXPECT_TRUE(capturer.CaptureFrame()); 3026 EXPECT_TRUE(capturer.CaptureFrame());
3034 3027
3035 std::vector<webrtc::VideoStream> video_streams = stream->GetVideoStreams(); 3028 std::vector<webrtc::VideoStream> video_streams = stream->GetVideoStreams();
3036 ASSERT_EQ(expected_num_streams, video_streams.size()); 3029 ASSERT_EQ(expected_num_streams, video_streams.size());
3037 3030
3038 std::vector<webrtc::VideoStream> expected_streams = GetSimulcastConfig( 3031 std::vector<webrtc::VideoStream> expected_streams = GetSimulcastConfig(
3039 num_configured_streams, 3032 num_configured_streams, codec.width, codec.height, 0, kDefaultQpMax,
3040 simulcast_bitrate_mode,
3041 codec.width,
3042 codec.height,
3043 0,
3044 kDefaultQpMax,
3045 codec.framerate != 0 ? codec.framerate : kDefaultFramerate); 3033 codec.framerate != 0 ? codec.framerate : kDefaultFramerate);
3046 3034
3047 ASSERT_EQ(expected_streams.size(), video_streams.size()); 3035 ASSERT_EQ(expected_streams.size(), video_streams.size());
3048 3036
3049 size_t num_streams = video_streams.size(); 3037 size_t num_streams = video_streams.size();
3050 int total_max_bitrate_bps = 0; 3038 int total_max_bitrate_bps = 0;
3051 for (size_t i = 0; i < num_streams; ++i) { 3039 for (size_t i = 0; i < num_streams; ++i) {
3052 EXPECT_EQ(expected_streams[i].width, video_streams[i].width); 3040 EXPECT_EQ(expected_streams[i].width, video_streams[i].width);
3053 EXPECT_EQ(expected_streams[i].height, video_streams[i].height); 3041 EXPECT_EQ(expected_streams[i].height, video_streams[i].height);
3054 3042
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
3121 return streams[streams.size() - 1]; 3109 return streams[streams.size() - 1];
3122 } 3110 }
3123 3111
3124 FakeCall fake_call_; 3112 FakeCall fake_call_;
3125 WebRtcVideoEngine2 engine_; 3113 WebRtcVideoEngine2 engine_;
3126 rtc::scoped_ptr<VideoMediaChannel> channel_; 3114 rtc::scoped_ptr<VideoMediaChannel> channel_;
3127 uint32_t last_ssrc_; 3115 uint32_t last_ssrc_;
3128 }; 3116 };
3129 3117
3130 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWith2SimulcastStreams) { 3118 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWith2SimulcastStreams) {
3131 VerifySimulcastSettings(kVp8Codec, VideoOptions::NORMAL, 2, 2, SBM_NORMAL); 3119 VerifySimulcastSettings(kVp8Codec, 2, 2);
3132 } 3120 }
3133 3121
3134 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWith3SimulcastStreams) { 3122 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWith3SimulcastStreams) {
3135 VerifySimulcastSettings( 3123 VerifySimulcastSettings(kVp8Codec720p, 3, 3);
3136 kVp8Codec720p, VideoOptions::NORMAL, 3, 3, SBM_NORMAL);
3137 }
3138
3139 TEST_F(WebRtcVideoChannel2SimulcastTest,
3140 SetSendCodecsWith2SimulcastStreamsHighBitrateMode) {
3141 VerifySimulcastSettings(kVp8Codec, VideoOptions::HIGH, 2, 2, SBM_HIGH);
3142 }
3143
3144 TEST_F(WebRtcVideoChannel2SimulcastTest,
3145 SetSendCodecsWith3SimulcastStreamsHighBitrateMode) {
3146 VerifySimulcastSettings(kVp8Codec720p, VideoOptions::HIGH, 3, 3, SBM_HIGH);
3147 }
3148
3149 TEST_F(WebRtcVideoChannel2SimulcastTest,
3150 SetSendCodecsWith2SimulcastStreamsVeryHighBitrateMode) {
3151 VerifySimulcastSettings(
3152 kVp8Codec, VideoOptions::VERY_HIGH, 2, 2, SBM_VERY_HIGH);
3153 }
3154
3155 TEST_F(WebRtcVideoChannel2SimulcastTest,
3156 SetSendCodecsWith3SimulcastStreamsVeryHighBitrateMode) {
3157 VerifySimulcastSettings(
3158 kVp8Codec720p, VideoOptions::VERY_HIGH, 3, 3, SBM_VERY_HIGH);
3159 } 3124 }
3160 3125
3161 // Test that we normalize send codec format size in simulcast. 3126 // Test that we normalize send codec format size in simulcast.
3162 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWithOddSizeInSimulcast) { 3127 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWithOddSizeInSimulcast) {
3163 cricket::VideoCodec codec(kVp8Codec270p); 3128 cricket::VideoCodec codec(kVp8Codec270p);
3164 codec.width += 1; 3129 codec.width += 1;
3165 codec.height += 1; 3130 codec.height += 1;
3166 VerifySimulcastSettings(codec, VideoOptions::NORMAL, 2, 2, SBM_NORMAL); 3131 VerifySimulcastSettings(codec, 2, 2);
3167 } 3132 }
3168 3133
3169 TEST_F(WebRtcVideoChannel2SimulcastTest, DISABLED_SimulcastSend_1280x800) { 3134 TEST_F(WebRtcVideoChannel2SimulcastTest, DISABLED_SimulcastSend_1280x800) {
3170 // TODO(pbos): Implement. 3135 // TODO(pbos): Implement.
3171 FAIL() << "Not implemented."; 3136 FAIL() << "Not implemented.";
3172 } 3137 }
3173 3138
3174 TEST_F(WebRtcVideoChannel2SimulcastTest, DISABLED_SimulcastSend_1280x720) { 3139 TEST_F(WebRtcVideoChannel2SimulcastTest, DISABLED_SimulcastSend_1280x720) {
3175 // TODO(pbos): Implement. 3140 // TODO(pbos): Implement.
3176 FAIL() << "Not implemented."; 3141 FAIL() << "Not implemented.";
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
3241 // Ensures that the correct settings are applied to the codec when two temporal 3206 // Ensures that the correct settings are applied to the codec when two temporal
3242 // layer screencasting is enabled, and that the correct simulcast settings are 3207 // layer screencasting is enabled, and that the correct simulcast settings are
3243 // reapplied when disabling screencasting. 3208 // reapplied when disabling screencasting.
3244 TEST_F(WebRtcVideoChannel2SimulcastTest, 3209 TEST_F(WebRtcVideoChannel2SimulcastTest,
3245 DISABLED_TwoTemporalLayerScreencastSettings) { 3210 DISABLED_TwoTemporalLayerScreencastSettings) {
3246 // TODO(pbos): Implement. 3211 // TODO(pbos): Implement.
3247 FAIL() << "Not implemented."; 3212 FAIL() << "Not implemented.";
3248 } 3213 }
3249 3214
3250 } // namespace cricket 3215 } // namespace cricket
OLDNEW
« no previous file with comments | « talk/media/webrtc/webrtcvideoengine2.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698