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; | |
42 | 40 |
43 rtc::scoped_refptr<webrtc::I420Buffer> buffer( | 41 webrtc::VideoFrame frame; |
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); | |
49 | 42 |
50 broadcaster.OnFrame(frame); | 43 broadcaster.OnFrame(frame); |
51 EXPECT_EQ(1, sink1.num_rendered_frames()); | 44 EXPECT_EQ(1, sink1.num_rendered_frames()); |
52 EXPECT_EQ(1, sink2.num_rendered_frames()); | 45 EXPECT_EQ(1, sink2.num_rendered_frames()); |
53 | 46 |
54 broadcaster.RemoveSink(&sink1); | 47 broadcaster.RemoveSink(&sink1); |
55 broadcaster.OnFrame(frame); | 48 broadcaster.OnFrame(frame); |
56 EXPECT_EQ(1, sink1.num_rendered_frames()); | 49 EXPECT_EQ(1, sink1.num_rendered_frames()); |
57 EXPECT_EQ(2, sink2.num_rendered_frames()); | 50 EXPECT_EQ(2, sink2.num_rendered_frames()); |
58 | 51 |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 broadcaster.AddOrUpdateSink(&sink2, wants2); | 153 broadcaster.AddOrUpdateSink(&sink2, wants2); |
161 | 154 |
162 webrtc::VideoFrame frame2(buffer, webrtc::kVideoRotation_0, | 155 webrtc::VideoFrame frame2(buffer, webrtc::kVideoRotation_0, |
163 30 /* timestamp_us */); | 156 30 /* timestamp_us */); |
164 broadcaster.OnFrame(frame2); | 157 broadcaster.OnFrame(frame2); |
165 EXPECT_FALSE(sink1.black_frame()); | 158 EXPECT_FALSE(sink1.black_frame()); |
166 EXPECT_EQ(30, sink1.timestamp_us()); | 159 EXPECT_EQ(30, sink1.timestamp_us()); |
167 EXPECT_TRUE(sink2.black_frame()); | 160 EXPECT_TRUE(sink2.black_frame()); |
168 EXPECT_EQ(30, sink2.timestamp_us()); | 161 EXPECT_EQ(30, sink2.timestamp_us()); |
169 } | 162 } |
OLD | NEW |