| 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 | 80 |
| 81 broadcaster.AddOrUpdateSink(&sink2, wants2); | 81 broadcaster.AddOrUpdateSink(&sink2, wants2); |
| 82 EXPECT_TRUE(broadcaster.wants().rotation_applied); | 82 EXPECT_TRUE(broadcaster.wants().rotation_applied); |
| 83 | 83 |
| 84 broadcaster.RemoveSink(&sink2); | 84 broadcaster.RemoveSink(&sink2); |
| 85 EXPECT_FALSE(broadcaster.wants().rotation_applied); | 85 EXPECT_FALSE(broadcaster.wants().rotation_applied); |
| 86 } | 86 } |
| 87 | 87 |
| 88 TEST(VideoBroadcasterTest, AppliesMinOfSinkWantsMaxPixelCount) { | 88 TEST(VideoBroadcasterTest, AppliesMinOfSinkWantsMaxPixelCount) { |
| 89 VideoBroadcaster broadcaster; | 89 VideoBroadcaster broadcaster; |
| 90 EXPECT_EQ(std::numeric_limits<int>::max(), | 90 EXPECT_TRUE(!broadcaster.wants().max_pixel_count); |
| 91 broadcaster.wants().max_pixel_count); | |
| 92 | 91 |
| 93 FakeVideoRenderer sink1; | 92 FakeVideoRenderer sink1; |
| 94 VideoSinkWants wants1; | 93 VideoSinkWants wants1; |
| 95 wants1.max_pixel_count = 1280 * 720; | 94 wants1.max_pixel_count = rtc::Optional<int>(1280 * 720); |
| 96 | 95 |
| 97 broadcaster.AddOrUpdateSink(&sink1, wants1); | 96 broadcaster.AddOrUpdateSink(&sink1, wants1); |
| 98 EXPECT_EQ(1280 * 720, broadcaster.wants().max_pixel_count); | 97 EXPECT_EQ(1280 * 720, *broadcaster.wants().max_pixel_count); |
| 99 | 98 |
| 100 FakeVideoRenderer sink2; | 99 FakeVideoRenderer sink2; |
| 101 VideoSinkWants wants2; | 100 VideoSinkWants wants2; |
| 102 wants2.max_pixel_count = 640 * 360; | 101 wants2.max_pixel_count = rtc::Optional<int>(640 * 360); |
| 103 broadcaster.AddOrUpdateSink(&sink2, wants2); | 102 broadcaster.AddOrUpdateSink(&sink2, wants2); |
| 104 EXPECT_EQ(640 * 360, broadcaster.wants().max_pixel_count); | 103 EXPECT_EQ(640 * 360, *broadcaster.wants().max_pixel_count); |
| 105 | 104 |
| 106 broadcaster.RemoveSink(&sink2); | 105 broadcaster.RemoveSink(&sink2); |
| 107 EXPECT_EQ(1280 * 720, broadcaster.wants().max_pixel_count); | 106 EXPECT_EQ(1280 * 720, *broadcaster.wants().max_pixel_count); |
| 108 } | 107 } |
| 109 | 108 |
| 110 TEST(VideoBroadcasterTest, AppliesMinOfSinkWantsMaxAndTargetPixelCount) { | 109 TEST(VideoBroadcasterTest, AppliesMinOfSinkWantsMaxAndTargetPixelCount) { |
| 111 VideoBroadcaster broadcaster; | 110 VideoBroadcaster broadcaster; |
| 112 EXPECT_TRUE(!broadcaster.wants().target_pixel_count); | 111 EXPECT_TRUE(!broadcaster.wants().target_pixel_count); |
| 113 | 112 |
| 114 FakeVideoRenderer sink1; | 113 FakeVideoRenderer sink1; |
| 115 VideoSinkWants wants1; | 114 VideoSinkWants wants1; |
| 116 wants1.target_pixel_count = rtc::Optional<int>(1280 * 720); | 115 wants1.target_pixel_count = rtc::Optional<int>(1280 * 720); |
| 117 | 116 |
| 118 broadcaster.AddOrUpdateSink(&sink1, wants1); | 117 broadcaster.AddOrUpdateSink(&sink1, wants1); |
| 119 EXPECT_EQ(1280 * 720, *broadcaster.wants().target_pixel_count); | 118 EXPECT_EQ(1280 * 720, *broadcaster.wants().target_pixel_count); |
| 120 | 119 |
| 121 FakeVideoRenderer sink2; | 120 FakeVideoRenderer sink2; |
| 122 VideoSinkWants wants2; | 121 VideoSinkWants wants2; |
| 123 wants2.target_pixel_count = rtc::Optional<int>(640 * 360); | 122 wants2.target_pixel_count = rtc::Optional<int>(640 * 360); |
| 124 broadcaster.AddOrUpdateSink(&sink2, wants2); | 123 broadcaster.AddOrUpdateSink(&sink2, wants2); |
| 125 EXPECT_EQ(640 * 360, *broadcaster.wants().target_pixel_count); | 124 EXPECT_EQ(640 * 360, *broadcaster.wants().target_pixel_count); |
| 126 | 125 |
| 127 broadcaster.RemoveSink(&sink2); | 126 broadcaster.RemoveSink(&sink2); |
| 128 EXPECT_EQ(1280 * 720, *broadcaster.wants().target_pixel_count); | 127 EXPECT_EQ(1280 * 720, *broadcaster.wants().target_pixel_count); |
| 129 } | 128 } |
| 130 | 129 |
| 131 TEST(VideoBroadcasterTest, AppliesMinOfSinkWantsMaxFramerate) { | |
| 132 VideoBroadcaster broadcaster; | |
| 133 EXPECT_EQ(std::numeric_limits<int>::max(), | |
| 134 broadcaster.wants().max_framerate_fps); | |
| 135 | |
| 136 FakeVideoRenderer sink1; | |
| 137 VideoSinkWants wants1; | |
| 138 wants1.max_framerate_fps = 30; | |
| 139 | |
| 140 broadcaster.AddOrUpdateSink(&sink1, wants1); | |
| 141 EXPECT_EQ(30, broadcaster.wants().max_framerate_fps); | |
| 142 | |
| 143 FakeVideoRenderer sink2; | |
| 144 VideoSinkWants wants2; | |
| 145 wants2.max_framerate_fps = 15; | |
| 146 broadcaster.AddOrUpdateSink(&sink2, wants2); | |
| 147 EXPECT_EQ(15, broadcaster.wants().max_framerate_fps); | |
| 148 | |
| 149 broadcaster.RemoveSink(&sink2); | |
| 150 EXPECT_EQ(30, broadcaster.wants().max_framerate_fps); | |
| 151 } | |
| 152 | |
| 153 TEST(VideoBroadcasterTest, SinkWantsBlackFrames) { | 130 TEST(VideoBroadcasterTest, SinkWantsBlackFrames) { |
| 154 VideoBroadcaster broadcaster; | 131 VideoBroadcaster broadcaster; |
| 155 EXPECT_TRUE(!broadcaster.wants().black_frames); | 132 EXPECT_TRUE(!broadcaster.wants().black_frames); |
| 156 | 133 |
| 157 FakeVideoRenderer sink1; | 134 FakeVideoRenderer sink1; |
| 158 VideoSinkWants wants1; | 135 VideoSinkWants wants1; |
| 159 wants1.black_frames = true; | 136 wants1.black_frames = true; |
| 160 broadcaster.AddOrUpdateSink(&sink1, wants1); | 137 broadcaster.AddOrUpdateSink(&sink1, wants1); |
| 161 | 138 |
| 162 FakeVideoRenderer sink2; | 139 FakeVideoRenderer sink2; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 184 broadcaster.AddOrUpdateSink(&sink2, wants2); | 161 broadcaster.AddOrUpdateSink(&sink2, wants2); |
| 185 | 162 |
| 186 webrtc::VideoFrame frame2(buffer, webrtc::kVideoRotation_0, | 163 webrtc::VideoFrame frame2(buffer, webrtc::kVideoRotation_0, |
| 187 30 /* timestamp_us */); | 164 30 /* timestamp_us */); |
| 188 broadcaster.OnFrame(frame2); | 165 broadcaster.OnFrame(frame2); |
| 189 EXPECT_FALSE(sink1.black_frame()); | 166 EXPECT_FALSE(sink1.black_frame()); |
| 190 EXPECT_EQ(30, sink1.timestamp_us()); | 167 EXPECT_EQ(30, sink1.timestamp_us()); |
| 191 EXPECT_TRUE(sink2.black_frame()); | 168 EXPECT_TRUE(sink2.black_frame()); |
| 192 EXPECT_EQ(30, sink2.timestamp_us()); | 169 EXPECT_EQ(30, sink2.timestamp_us()); |
| 193 } | 170 } |
| OLD | NEW |