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 |
(...skipping 19 matching lines...) Expand all Loading... |
30 EXPECT_FALSE(broadcaster.frame_wanted()); | 30 EXPECT_FALSE(broadcaster.frame_wanted()); |
31 } | 31 } |
32 | 32 |
33 TEST(VideoBroadcasterTest, OnFrame) { | 33 TEST(VideoBroadcasterTest, OnFrame) { |
34 VideoBroadcaster broadcaster; | 34 VideoBroadcaster broadcaster; |
35 | 35 |
36 FakeVideoRenderer sink1; | 36 FakeVideoRenderer sink1; |
37 FakeVideoRenderer sink2; | 37 FakeVideoRenderer sink2; |
38 broadcaster.AddOrUpdateSink(&sink1, rtc::VideoSinkWants()); | 38 broadcaster.AddOrUpdateSink(&sink1, rtc::VideoSinkWants()); |
39 broadcaster.AddOrUpdateSink(&sink2, rtc::VideoSinkWants()); | 39 broadcaster.AddOrUpdateSink(&sink2, rtc::VideoSinkWants()); |
| 40 static int kWidth = 100; |
| 41 static int kHeight = 50; |
40 | 42 |
41 webrtc::VideoFrame frame; | 43 rtc::scoped_refptr<webrtc::I420Buffer> buffer( |
| 44 webrtc::I420Buffer::Create(kWidth, kHeight)); |
| 45 // Initialize, to avoid warnings on use of initialized values. |
| 46 buffer->SetToBlack(); |
| 47 |
| 48 webrtc::VideoFrame frame(buffer, webrtc::kVideoRotation_0, 0); |
42 | 49 |
43 broadcaster.OnFrame(frame); | 50 broadcaster.OnFrame(frame); |
44 EXPECT_EQ(1, sink1.num_rendered_frames()); | 51 EXPECT_EQ(1, sink1.num_rendered_frames()); |
45 EXPECT_EQ(1, sink2.num_rendered_frames()); | 52 EXPECT_EQ(1, sink2.num_rendered_frames()); |
46 | 53 |
47 broadcaster.RemoveSink(&sink1); | 54 broadcaster.RemoveSink(&sink1); |
48 broadcaster.OnFrame(frame); | 55 broadcaster.OnFrame(frame); |
49 EXPECT_EQ(1, sink1.num_rendered_frames()); | 56 EXPECT_EQ(1, sink1.num_rendered_frames()); |
50 EXPECT_EQ(2, sink2.num_rendered_frames()); | 57 EXPECT_EQ(2, sink2.num_rendered_frames()); |
51 | 58 |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 broadcaster.AddOrUpdateSink(&sink2, wants2); | 160 broadcaster.AddOrUpdateSink(&sink2, wants2); |
154 | 161 |
155 webrtc::VideoFrame frame2(buffer, webrtc::kVideoRotation_0, | 162 webrtc::VideoFrame frame2(buffer, webrtc::kVideoRotation_0, |
156 30 /* timestamp_us */); | 163 30 /* timestamp_us */); |
157 broadcaster.OnFrame(frame2); | 164 broadcaster.OnFrame(frame2); |
158 EXPECT_FALSE(sink1.black_frame()); | 165 EXPECT_FALSE(sink1.black_frame()); |
159 EXPECT_EQ(30, sink1.timestamp_us()); | 166 EXPECT_EQ(30, sink1.timestamp_us()); |
160 EXPECT_TRUE(sink2.black_frame()); | 167 EXPECT_TRUE(sink2.black_frame()); |
161 EXPECT_EQ(30, sink2.timestamp_us()); | 168 EXPECT_EQ(30, sink2.timestamp_us()); |
162 } | 169 } |
OLD | NEW |