OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/renderer/media/media_stream_video_capturer_source.h" | 5 #include "content/renderer/media/media_stream_video_capturer_source.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 void EnumerateDeviceFormats(const VideoCaptureDeviceFormatsCB& callback) { | 50 void EnumerateDeviceFormats(const VideoCaptureDeviceFormatsCB& callback) { |
51 media::VideoCaptureFormat kFormatSmall(gfx::Size(640, 480), 30.0, | 51 media::VideoCaptureFormat kFormatSmall(gfx::Size(640, 480), 30.0, |
52 media::PIXEL_FORMAT_I420); | 52 media::PIXEL_FORMAT_I420); |
53 media::VideoCaptureFormat kFormatLarge(gfx::Size(1920, 1080), 30.0, | 53 media::VideoCaptureFormat kFormatLarge(gfx::Size(1920, 1080), 30.0, |
54 media::PIXEL_FORMAT_I420); | 54 media::PIXEL_FORMAT_I420); |
55 media::VideoCaptureFormats formats; | 55 media::VideoCaptureFormats formats; |
56 formats.push_back(kFormatSmall); | 56 formats.push_back(kFormatSmall); |
57 formats.push_back(kFormatLarge); | 57 formats.push_back(kFormatLarge); |
58 callback.Run(formats); | 58 callback.Run(formats); |
59 } | 59 } |
60 | |
61 }; | 60 }; |
62 | 61 |
63 class MediaStreamVideoCapturerSourceTest : public testing::Test { | 62 class MediaStreamVideoCapturerSourceTest : public testing::Test { |
64 public: | 63 public: |
65 MediaStreamVideoCapturerSourceTest() | 64 MediaStreamVideoCapturerSourceTest() |
66 : child_process_(new ChildProcess()), | 65 : child_process_(new ChildProcess()), |
67 source_(nullptr), | 66 source_(nullptr), |
68 delegate_(nullptr), | 67 delegate_(nullptr), |
69 source_stopped_(false) {} | 68 source_stopped_(false) {} |
70 | 69 |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 expected_params.resolution_change_policy = | 206 expected_params.resolution_change_policy = |
208 media::RESOLUTION_POLICY_FIXED_ASPECT_RATIO; | 207 media::RESOLUTION_POLICY_FIXED_ASPECT_RATIO; |
209 | 208 |
210 InSequence s; | 209 InSequence s; |
211 EXPECT_CALL(mock_delegate(), GetCurrentSupportedFormats(_, _, _, _)); | 210 EXPECT_CALL(mock_delegate(), GetCurrentSupportedFormats(_, _, _, _)); |
212 EXPECT_CALL( | 211 EXPECT_CALL( |
213 mock_delegate(), | 212 mock_delegate(), |
214 StartCapture( | 213 StartCapture( |
215 testing::Field(&media::VideoCaptureParams::resolution_change_policy, | 214 testing::Field(&media::VideoCaptureParams::resolution_change_policy, |
216 media::RESOLUTION_POLICY_FIXED_ASPECT_RATIO), | 215 media::RESOLUTION_POLICY_FIXED_ASPECT_RATIO), |
217 _, _)) | 216 _, _)); |
218 ; | |
219 blink::WebMediaStreamTrack track = StartSource(); | 217 blink::WebMediaStreamTrack track = StartSource(); |
220 // When the track goes out of scope, the source will be stopped. | 218 // When the track goes out of scope, the source will be stopped. |
221 EXPECT_CALL(mock_delegate(), StopCapture()); | 219 EXPECT_CALL(mock_delegate(), StopCapture()); |
222 } | 220 } |
223 | 221 |
224 TEST_F(MediaStreamVideoCapturerSourceTest, | 222 TEST_F(MediaStreamVideoCapturerSourceTest, |
225 TabCaptureConstraintsImplyAllowingAnyResolutionChange) { | 223 TabCaptureConstraintsImplyAllowingAnyResolutionChange) { |
226 StreamDeviceInfo device_info; | 224 StreamDeviceInfo device_info; |
227 device_info.device.type = MEDIA_TAB_VIDEO_CAPTURE; | 225 device_info.device.type = MEDIA_TAB_VIDEO_CAPTURE; |
228 InitWithDeviceInfo(device_info); | 226 InitWithDeviceInfo(device_info); |
(...skipping 13 matching lines...) Expand all Loading... |
242 expected_params.resolution_change_policy = | 240 expected_params.resolution_change_policy = |
243 media::RESOLUTION_POLICY_ANY_WITHIN_LIMIT; | 241 media::RESOLUTION_POLICY_ANY_WITHIN_LIMIT; |
244 | 242 |
245 InSequence s; | 243 InSequence s; |
246 EXPECT_CALL(mock_delegate(), GetCurrentSupportedFormats(_, _, _, _)); | 244 EXPECT_CALL(mock_delegate(), GetCurrentSupportedFormats(_, _, _, _)); |
247 EXPECT_CALL( | 245 EXPECT_CALL( |
248 mock_delegate(), | 246 mock_delegate(), |
249 StartCapture( | 247 StartCapture( |
250 testing::Field(&media::VideoCaptureParams::resolution_change_policy, | 248 testing::Field(&media::VideoCaptureParams::resolution_change_policy, |
251 media::RESOLUTION_POLICY_ANY_WITHIN_LIMIT), | 249 media::RESOLUTION_POLICY_ANY_WITHIN_LIMIT), |
252 _, _)) | 250 _, _)); |
253 ; | |
254 blink::WebMediaStreamTrack track = StartSource(); | 251 blink::WebMediaStreamTrack track = StartSource(); |
255 // When the track goes out of scope, the source will be stopped. | 252 // When the track goes out of scope, the source will be stopped. |
256 EXPECT_CALL(mock_delegate(), StopCapture()); | 253 EXPECT_CALL(mock_delegate(), StopCapture()); |
257 } | 254 } |
258 | 255 |
259 TEST_F(MediaStreamVideoCapturerSourceTest, | 256 TEST_F(MediaStreamVideoCapturerSourceTest, |
260 DeviceCaptureConstraintsSupportPowerLineFrequency) { | 257 DeviceCaptureConstraintsSupportPowerLineFrequency) { |
261 for (int frequency = -100; frequency < 100; ++frequency) { | 258 for (int frequency = -100; frequency < 100; ++frequency) { |
262 StreamDeviceInfo device_info; | 259 StreamDeviceInfo device_info; |
263 device_info.device.type = MEDIA_DEVICE_VIDEO_CAPTURE; | 260 device_info.device.type = MEDIA_DEVICE_VIDEO_CAPTURE; |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
426 run_loop.Run(); | 423 run_loop.Run(); |
427 FakeMediaStreamVideoSink::RemoveFromVideoTrack(&fake_sink, track); | 424 FakeMediaStreamVideoSink::RemoveFromVideoTrack(&fake_sink, track); |
428 EXPECT_EQ(reference_capture_time, capture_time); | 425 EXPECT_EQ(reference_capture_time, capture_time); |
429 double metadata_value; | 426 double metadata_value; |
430 EXPECT_TRUE(metadata.GetDouble(media::VideoFrameMetadata::FRAME_RATE, | 427 EXPECT_TRUE(metadata.GetDouble(media::VideoFrameMetadata::FRAME_RATE, |
431 &metadata_value)); | 428 &metadata_value)); |
432 EXPECT_EQ(30.0, metadata_value); | 429 EXPECT_EQ(30.0, metadata_value); |
433 } | 430 } |
434 | 431 |
435 } // namespace content | 432 } // namespace content |
OLD | NEW |