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

Side by Side Diff: webrtc/media/base/videobroadcaster_unittest.cc

Issue 2716643002: Add framerate to VideoSinkWants and ability to signal on overuse (Closed)
Patch Set: Fix wireup, keep scale state per degradation pref Created 3 years, 9 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
OLDNEW
1 /* 1 /*
2 * Copyright 2016 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2016 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include "webrtc/api/video/i420_buffer.h" 11 #include "webrtc/api/video/i420_buffer.h"
12 #include "webrtc/api/video/video_frame.h" 12 #include "webrtc/api/video/video_frame.h"
13 #include "webrtc/base/gunit.h" 13 //#include "webrtc/base/gunit.h"
kthelgason 2017/02/27 14:02:39 I guess this should not have been included?
sprang_webrtc 2017/02/28 08:46:28 Oops. Removed
14 #include "webrtc/media/base/fakevideorenderer.h" 14 #include "webrtc/media/base/fakevideorenderer.h"
15 #include "webrtc/media/base/videobroadcaster.h" 15 #include "webrtc/media/base/videobroadcaster.h"
16 #include "webrtc/test/gtest.h"
16 17
17 using rtc::VideoBroadcaster; 18 using rtc::VideoBroadcaster;
18 using rtc::VideoSinkWants; 19 using rtc::VideoSinkWants;
19 using cricket::FakeVideoRenderer; 20 using cricket::FakeVideoRenderer;
20 21
21 22
22 TEST(VideoBroadcasterTest, frame_wanted) { 23 TEST(VideoBroadcasterTest, frame_wanted) {
23 VideoBroadcaster broadcaster; 24 VideoBroadcaster broadcaster;
24 EXPECT_FALSE(broadcaster.frame_wanted()); 25 EXPECT_FALSE(broadcaster.frame_wanted());
25 26
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 FakeVideoRenderer sink2; 121 FakeVideoRenderer sink2;
121 VideoSinkWants wants2; 122 VideoSinkWants wants2;
122 wants2.target_pixel_count = rtc::Optional<int>(640 * 360); 123 wants2.target_pixel_count = rtc::Optional<int>(640 * 360);
123 broadcaster.AddOrUpdateSink(&sink2, wants2); 124 broadcaster.AddOrUpdateSink(&sink2, wants2);
124 EXPECT_EQ(640 * 360, *broadcaster.wants().target_pixel_count); 125 EXPECT_EQ(640 * 360, *broadcaster.wants().target_pixel_count);
125 126
126 broadcaster.RemoveSink(&sink2); 127 broadcaster.RemoveSink(&sink2);
127 EXPECT_EQ(1280 * 720, *broadcaster.wants().target_pixel_count); 128 EXPECT_EQ(1280 * 720, *broadcaster.wants().target_pixel_count);
128 } 129 }
129 130
131 TEST(VideoBroadcasterTest, AppliesMinOfSinkWantsMaxFramerate) {
132 VideoBroadcaster broadcaster;
133 EXPECT_TRUE(!broadcaster.wants().max_framerate_fps_);
magjed_webrtc 2017/02/27 09:30:35 Use EXPECT_FALSE instead and remove the negation?
sprang_webrtc 2017/02/27 12:51:49 Done.
134
135 FakeVideoRenderer sink1;
136 VideoSinkWants wants1;
137 wants1.max_framerate_fps_.emplace(30);
138
139 broadcaster.AddOrUpdateSink(&sink1, wants1);
140 EXPECT_EQ(30, *broadcaster.wants().max_framerate_fps_);
141
142 FakeVideoRenderer sink2;
143 VideoSinkWants wants2;
144 wants2.max_framerate_fps_.emplace(15);
145 broadcaster.AddOrUpdateSink(&sink2, wants2);
146 EXPECT_EQ(15, *broadcaster.wants().max_framerate_fps_);
147
148 broadcaster.RemoveSink(&sink2);
149 EXPECT_EQ(30, *broadcaster.wants().max_framerate_fps_);
150 }
151
130 TEST(VideoBroadcasterTest, SinkWantsBlackFrames) { 152 TEST(VideoBroadcasterTest, SinkWantsBlackFrames) {
131 VideoBroadcaster broadcaster; 153 VideoBroadcaster broadcaster;
132 EXPECT_TRUE(!broadcaster.wants().black_frames); 154 EXPECT_TRUE(!broadcaster.wants().black_frames);
133 155
134 FakeVideoRenderer sink1; 156 FakeVideoRenderer sink1;
135 VideoSinkWants wants1; 157 VideoSinkWants wants1;
136 wants1.black_frames = true; 158 wants1.black_frames = true;
137 broadcaster.AddOrUpdateSink(&sink1, wants1); 159 broadcaster.AddOrUpdateSink(&sink1, wants1);
138 160
139 FakeVideoRenderer sink2; 161 FakeVideoRenderer sink2;
(...skipping 21 matching lines...) Expand all
161 broadcaster.AddOrUpdateSink(&sink2, wants2); 183 broadcaster.AddOrUpdateSink(&sink2, wants2);
162 184
163 webrtc::VideoFrame frame2(buffer, webrtc::kVideoRotation_0, 185 webrtc::VideoFrame frame2(buffer, webrtc::kVideoRotation_0,
164 30 /* timestamp_us */); 186 30 /* timestamp_us */);
165 broadcaster.OnFrame(frame2); 187 broadcaster.OnFrame(frame2);
166 EXPECT_FALSE(sink1.black_frame()); 188 EXPECT_FALSE(sink1.black_frame());
167 EXPECT_EQ(30, sink1.timestamp_us()); 189 EXPECT_EQ(30, sink1.timestamp_us());
168 EXPECT_TRUE(sink2.black_frame()); 190 EXPECT_TRUE(sink2.black_frame());
169 EXPECT_EQ(30, sink2.timestamp_us()); 191 EXPECT_EQ(30, sink2.timestamp_us());
170 } 192 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698