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_manager.h" | 5 #include "content/browser/renderer_host/media/media_stream_manager.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 787 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
798 StopDevice(stream_type, session_id); | 798 StopDevice(stream_type, session_id); |
799 | 799 |
800 AddLogMessageOnIOThread( | 800 AddLogMessageOnIOThread( |
801 base::StringPrintf( | 801 base::StringPrintf( |
802 "Media input device removed: type=%s, id=%s, name=%s ", | 802 "Media input device removed: type=%s, id=%s, name=%s ", |
803 (stream_type == MEDIA_DEVICE_AUDIO_CAPTURE ? "audio" : "video"), | 803 (stream_type == MEDIA_DEVICE_AUDIO_CAPTURE ? "audio" : "video"), |
804 device.device_id.c_str(), device.label.c_str()) | 804 device.device_id.c_str(), device.label.c_str()) |
805 .c_str()); | 805 .c_str()); |
806 } | 806 } |
807 | 807 |
808 bool MediaStreamManager::PickDeviceId(const std::string& salt, | 808 bool MediaStreamManager::PickDeviceId(MediaStreamType type, |
| 809 const std::string& salt, |
809 const url::Origin& security_origin, | 810 const url::Origin& security_origin, |
810 const TrackControls& controls, | 811 const TrackControls& controls, |
811 const MediaDeviceInfoArray& devices, | 812 const MediaDeviceInfoArray& devices, |
812 std::string* device_id) const { | 813 std::string* device_id) const { |
813 if (controls.device_id.empty()) | 814 if (controls.device_id.empty()) |
814 return true; | 815 return true; |
| 816 if (type == MEDIA_DEVICE_AUDIO_CAPTURE && |
| 817 media::AudioDeviceDescription::IsDefaultDevice(controls.device_id)) { |
| 818 return true; |
| 819 } |
815 | 820 |
816 if (!GetDeviceIDFromHMAC(salt, security_origin, controls.device_id, devices, | 821 if (!GetDeviceIDFromHMAC(salt, security_origin, controls.device_id, devices, |
817 device_id)) { | 822 device_id)) { |
818 LOG(WARNING) << "Invalid device ID = " << controls.device_id; | 823 LOG(WARNING) << "Invalid device ID = " << controls.device_id; |
819 return false; | 824 return false; |
820 } | 825 } |
821 return true; | 826 return true; |
822 } | 827 } |
823 | 828 |
824 bool MediaStreamManager::GetRequestedDeviceCaptureId( | 829 bool MediaStreamManager::GetRequestedDeviceCaptureId( |
825 const DeviceRequest* request, | 830 const DeviceRequest* request, |
826 MediaStreamType type, | 831 MediaStreamType type, |
827 const MediaDeviceInfoArray& devices, | 832 const MediaDeviceInfoArray& devices, |
828 std::string* device_id) const { | 833 std::string* device_id) const { |
829 if (type == MEDIA_DEVICE_AUDIO_CAPTURE) { | 834 if (type == MEDIA_DEVICE_AUDIO_CAPTURE) { |
830 return PickDeviceId(request->salt, request->security_origin, | 835 return PickDeviceId(type, request->salt, request->security_origin, |
831 request->controls.audio, devices, device_id); | 836 request->controls.audio, devices, device_id); |
832 } else if (type == MEDIA_DEVICE_VIDEO_CAPTURE) { | 837 } else if (type == MEDIA_DEVICE_VIDEO_CAPTURE) { |
833 return PickDeviceId(request->salt, request->security_origin, | 838 return PickDeviceId(type, request->salt, request->security_origin, |
834 request->controls.video, devices, device_id); | 839 request->controls.video, devices, device_id); |
835 } else { | 840 } else { |
836 NOTREACHED(); | 841 NOTREACHED(); |
837 } | 842 } |
838 return false; | 843 return false; |
839 } | 844 } |
840 | 845 |
841 void MediaStreamManager::TranslateDeviceIdToSourceId( | 846 void MediaStreamManager::TranslateDeviceIdToSourceId( |
842 DeviceRequest* request, | 847 DeviceRequest* request, |
843 MediaStreamDevice* device) { | 848 MediaStreamDevice* device) { |
(...skipping 931 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1775 request->ui_proxy->OnStarted( | 1780 request->ui_proxy->OnStarted( |
1776 base::Bind(&MediaStreamManager::StopMediaStreamFromBrowser, | 1781 base::Bind(&MediaStreamManager::StopMediaStreamFromBrowser, |
1777 base::Unretained(this), label), | 1782 base::Unretained(this), label), |
1778 base::Bind(&MediaStreamManager::OnMediaStreamUIWindowId, | 1783 base::Bind(&MediaStreamManager::OnMediaStreamUIWindowId, |
1779 base::Unretained(this), request->video_type(), | 1784 base::Unretained(this), request->video_type(), |
1780 request->devices)); | 1785 request->devices)); |
1781 } | 1786 } |
1782 } | 1787 } |
1783 | 1788 |
1784 } // namespace content | 1789 } // namespace content |
OLD | NEW |