| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/browser/renderer_host/media/media_stream_dispatcher_host.h" | 5 #include "content/browser/renderer_host/media/media_stream_dispatcher_host.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <queue> | 9 #include <queue> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 466 GenerateStreamAndWaitForResult(kRenderId, kPageRequestId, controls); | 466 GenerateStreamAndWaitForResult(kRenderId, kPageRequestId, controls); |
| 467 | 467 |
| 468 EXPECT_EQ(host_->audio_devices_.size(), 1u); | 468 EXPECT_EQ(host_->audio_devices_.size(), 1u); |
| 469 EXPECT_EQ(host_->video_devices_.size(), 1u); | 469 EXPECT_EQ(host_->video_devices_.size(), 1u); |
| 470 } | 470 } |
| 471 | 471 |
| 472 TEST_F(MediaStreamDispatcherHostTest, GenerateStreamWithDepthVideo) { | 472 TEST_F(MediaStreamDispatcherHostTest, GenerateStreamWithDepthVideo) { |
| 473 // Video device on index 1 is depth video capture device. The number of fake | 473 // Video device on index 1 is depth video capture device. The number of fake |
| 474 // devices is 2. | 474 // devices is 2. |
| 475 physical_video_devices_.clear(); | 475 physical_video_devices_.clear(); |
| 476 video_capture_device_factory_->set_number_of_devices(2); | 476 video_capture_device_factory_->SetToDefaultDevicesConfig(2); |
| 477 video_capture_device_factory_->GetDeviceDescriptors(&physical_video_devices_); | 477 video_capture_device_factory_->GetDeviceDescriptors(&physical_video_devices_); |
| 478 // We specify to generate both audio and video stream. | 478 // We specify to generate both audio and video stream. |
| 479 StreamControls controls(true, true); | 479 StreamControls controls(true, true); |
| 480 std::string source_id = content::GetHMACForMediaDeviceID( | 480 std::string source_id = content::GetHMACForMediaDeviceID( |
| 481 browser_context_.GetResourceContext()->GetMediaDeviceIDSalt(), origin_, | 481 browser_context_.GetResourceContext()->GetMediaDeviceIDSalt(), origin_, |
| 482 physical_video_devices_[1].device_id); | 482 physical_video_devices_[1].device_id); |
| 483 // |source_id| is related to depth device (the device on index 1). As we can | 483 // |source_id| is related to depth device (the device on index 1). As we can |
| 484 // generate only one video stream using GenerateStreamAndWaitForResult, we | 484 // generate only one video stream using GenerateStreamAndWaitForResult, we |
| 485 // use controls.video.source_id to specify that the stream is depth video. | 485 // use controls.video.source_id to specify that the stream is depth video. |
| 486 // See also MediaStreamManager::GenerateStream and other tests here. | 486 // See also MediaStreamManager::GenerateStream and other tests here. |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 673 TEST_F(MediaStreamDispatcherHostTest, GenerateStreamsWithInvalidAudioSourceId) { | 673 TEST_F(MediaStreamDispatcherHostTest, GenerateStreamsWithInvalidAudioSourceId) { |
| 674 StreamControls controls(true, true); | 674 StreamControls controls(true, true); |
| 675 controls.audio.device_id = "invalid source id"; | 675 controls.audio.device_id = "invalid source id"; |
| 676 | 676 |
| 677 GenerateStreamAndWaitForFailure(kRenderId, kPageRequestId, controls, | 677 GenerateStreamAndWaitForFailure(kRenderId, kPageRequestId, controls, |
| 678 MEDIA_DEVICE_NO_HARDWARE); | 678 MEDIA_DEVICE_NO_HARDWARE); |
| 679 } | 679 } |
| 680 | 680 |
| 681 TEST_F(MediaStreamDispatcherHostTest, GenerateStreamsNoAvailableVideoDevice) { | 681 TEST_F(MediaStreamDispatcherHostTest, GenerateStreamsNoAvailableVideoDevice) { |
| 682 physical_video_devices_.clear(); | 682 physical_video_devices_.clear(); |
| 683 video_capture_device_factory_->set_number_of_devices(0); | 683 video_capture_device_factory_->SetToDefaultDevicesConfig(0); |
| 684 video_capture_device_factory_->GetDeviceDescriptors(&physical_video_devices_); | 684 video_capture_device_factory_->GetDeviceDescriptors(&physical_video_devices_); |
| 685 StreamControls controls(true, true); | 685 StreamControls controls(true, true); |
| 686 | 686 |
| 687 SetupFakeUI(false); | 687 SetupFakeUI(false); |
| 688 GenerateStreamAndWaitForFailure(kRenderId, kPageRequestId, controls, | 688 GenerateStreamAndWaitForFailure(kRenderId, kPageRequestId, controls, |
| 689 MEDIA_DEVICE_NO_HARDWARE); | 689 MEDIA_DEVICE_NO_HARDWARE); |
| 690 } | 690 } |
| 691 | 691 |
| 692 // Test that if a OnStopStreamDevice message is received for a device that has | 692 // Test that if a OnStopStreamDevice message is received for a device that has |
| 693 // been opened in a MediaStream and by pepper, the device is only stopped for | 693 // been opened in a MediaStream and by pepper, the device is only stopped for |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 830 | 830 |
| 831 // Test that the dispatcher is notified if a video device that is in use is | 831 // Test that the dispatcher is notified if a video device that is in use is |
| 832 // being unplugged. | 832 // being unplugged. |
| 833 TEST_F(MediaStreamDispatcherHostTest, VideoDeviceUnplugged) { | 833 TEST_F(MediaStreamDispatcherHostTest, VideoDeviceUnplugged) { |
| 834 StreamControls controls(true, true); | 834 StreamControls controls(true, true); |
| 835 SetupFakeUI(true); | 835 SetupFakeUI(true); |
| 836 GenerateStreamAndWaitForResult(kRenderId, kPageRequestId, controls); | 836 GenerateStreamAndWaitForResult(kRenderId, kPageRequestId, controls); |
| 837 EXPECT_EQ(host_->audio_devices_.size(), 1u); | 837 EXPECT_EQ(host_->audio_devices_.size(), 1u); |
| 838 EXPECT_EQ(host_->video_devices_.size(), 1u); | 838 EXPECT_EQ(host_->video_devices_.size(), 1u); |
| 839 | 839 |
| 840 video_capture_device_factory_->set_number_of_devices(0); | 840 video_capture_device_factory_->SetToDefaultDevicesConfig(0); |
| 841 | 841 |
| 842 base::RunLoop run_loop; | 842 base::RunLoop run_loop; |
| 843 EXPECT_CALL(*host_.get(), OnDeviceStopped(kRenderId)) | 843 EXPECT_CALL(*host_.get(), OnDeviceStopped(kRenderId)) |
| 844 .WillOnce(testing::InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit)); | 844 .WillOnce(testing::InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit)); |
| 845 media_stream_manager_->media_devices_manager()->OnDevicesChanged( | 845 media_stream_manager_->media_devices_manager()->OnDevicesChanged( |
| 846 base::SystemMonitor::DEVTYPE_VIDEO_CAPTURE); | 846 base::SystemMonitor::DEVTYPE_VIDEO_CAPTURE); |
| 847 | 847 |
| 848 run_loop.Run(); | 848 run_loop.Run(); |
| 849 } | 849 } |
| 850 | 850 |
| 851 }; // namespace content | 851 }; // namespace content |
| OLD | NEW |