OLD | NEW |
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" |
| 12 #include "webrtc/api/video/video_frame.h" |
11 #include "webrtc/base/gunit.h" | 13 #include "webrtc/base/gunit.h" |
12 #include "webrtc/media/base/fakevideorenderer.h" | 14 #include "webrtc/media/base/fakevideorenderer.h" |
13 #include "webrtc/media/base/videobroadcaster.h" | 15 #include "webrtc/media/base/videobroadcaster.h" |
14 #include "webrtc/video_frame.h" | |
15 | 16 |
16 using rtc::VideoBroadcaster; | 17 using rtc::VideoBroadcaster; |
17 using rtc::VideoSinkWants; | 18 using rtc::VideoSinkWants; |
18 using cricket::FakeVideoRenderer; | 19 using cricket::FakeVideoRenderer; |
19 | 20 |
20 | 21 |
21 TEST(VideoBroadcasterTest, frame_wanted) { | 22 TEST(VideoBroadcasterTest, frame_wanted) { |
22 VideoBroadcaster broadcaster; | 23 VideoBroadcaster broadcaster; |
23 EXPECT_FALSE(broadcaster.frame_wanted()); | 24 EXPECT_FALSE(broadcaster.frame_wanted()); |
24 | 25 |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 VideoSinkWants wants1; | 128 VideoSinkWants wants1; |
128 wants1.black_frames = true; | 129 wants1.black_frames = true; |
129 broadcaster.AddOrUpdateSink(&sink1, wants1); | 130 broadcaster.AddOrUpdateSink(&sink1, wants1); |
130 | 131 |
131 FakeVideoRenderer sink2; | 132 FakeVideoRenderer sink2; |
132 VideoSinkWants wants2; | 133 VideoSinkWants wants2; |
133 wants2.black_frames = false; | 134 wants2.black_frames = false; |
134 broadcaster.AddOrUpdateSink(&sink2, wants2); | 135 broadcaster.AddOrUpdateSink(&sink2, wants2); |
135 | 136 |
136 rtc::scoped_refptr<webrtc::I420Buffer> buffer( | 137 rtc::scoped_refptr<webrtc::I420Buffer> buffer( |
137 new rtc::RefCountedObject<webrtc::I420Buffer>(100, 200)); | 138 webrtc::I420Buffer::Create(100, 200)); |
138 // Makes it not all black. | 139 // Makes it not all black. |
139 buffer->InitializeData(); | 140 buffer->InitializeData(); |
140 | 141 |
141 webrtc::VideoFrame frame1(buffer, webrtc::kVideoRotation_0, | 142 webrtc::VideoFrame frame1(buffer, webrtc::kVideoRotation_0, |
142 10 /* timestamp_us */); | 143 10 /* timestamp_us */); |
143 broadcaster.OnFrame(frame1); | 144 broadcaster.OnFrame(frame1); |
144 EXPECT_TRUE(sink1.black_frame()); | 145 EXPECT_TRUE(sink1.black_frame()); |
145 EXPECT_EQ(10, sink1.timestamp_us()); | 146 EXPECT_EQ(10, sink1.timestamp_us()); |
146 EXPECT_FALSE(sink2.black_frame()); | 147 EXPECT_FALSE(sink2.black_frame()); |
147 EXPECT_EQ(10, sink2.timestamp_us()); | 148 EXPECT_EQ(10, sink2.timestamp_us()); |
148 | 149 |
149 // Switch the sink wants. | 150 // Switch the sink wants. |
150 wants1.black_frames = false; | 151 wants1.black_frames = false; |
151 broadcaster.AddOrUpdateSink(&sink1, wants1); | 152 broadcaster.AddOrUpdateSink(&sink1, wants1); |
152 wants2.black_frames = true; | 153 wants2.black_frames = true; |
153 broadcaster.AddOrUpdateSink(&sink2, wants2); | 154 broadcaster.AddOrUpdateSink(&sink2, wants2); |
154 | 155 |
155 webrtc::VideoFrame frame2(buffer, webrtc::kVideoRotation_0, | 156 webrtc::VideoFrame frame2(buffer, webrtc::kVideoRotation_0, |
156 30 /* timestamp_us */); | 157 30 /* timestamp_us */); |
157 broadcaster.OnFrame(frame2); | 158 broadcaster.OnFrame(frame2); |
158 EXPECT_FALSE(sink1.black_frame()); | 159 EXPECT_FALSE(sink1.black_frame()); |
159 EXPECT_EQ(30, sink1.timestamp_us()); | 160 EXPECT_EQ(30, sink1.timestamp_us()); |
160 EXPECT_TRUE(sink2.black_frame()); | 161 EXPECT_TRUE(sink2.black_frame()); |
161 EXPECT_EQ(30, sink2.timestamp_us()); | 162 EXPECT_EQ(30, sink2.timestamp_us()); |
162 } | 163 } |
OLD | NEW |