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(MediaStreamType type, | 808 bool MediaStreamManager::PickDeviceId(const std::string& salt, |
809 const std::string& salt, | |
810 const url::Origin& security_origin, | 809 const url::Origin& security_origin, |
811 const TrackControls& controls, | 810 const TrackControls& controls, |
812 const MediaDeviceInfoArray& devices, | 811 const MediaDeviceInfoArray& devices, |
813 std::string* device_id) const { | 812 std::string* device_id) const { |
814 if (controls.device_id.empty()) | 813 if (controls.device_id.empty()) |
815 return true; | 814 return true; |
816 if (type == MEDIA_DEVICE_AUDIO_CAPTURE && | |
817 media::AudioDeviceDescription::IsDefaultDevice(controls.device_id)) { | |
818 return true; | |
819 } | |
820 | 815 |
821 if (!GetDeviceIDFromHMAC(salt, security_origin, controls.device_id, devices, | 816 if (!GetDeviceIDFromHMAC(salt, security_origin, controls.device_id, devices, |
822 device_id)) { | 817 device_id)) { |
823 LOG(WARNING) << "Invalid device ID = " << controls.device_id; | 818 LOG(WARNING) << "Invalid device ID = " << controls.device_id; |
824 return false; | 819 return false; |
825 } | 820 } |
826 return true; | 821 return true; |
827 } | 822 } |
828 | 823 |
829 bool MediaStreamManager::GetRequestedDeviceCaptureId( | 824 bool MediaStreamManager::GetRequestedDeviceCaptureId( |
830 const DeviceRequest* request, | 825 const DeviceRequest* request, |
831 MediaStreamType type, | 826 MediaStreamType type, |
832 const MediaDeviceInfoArray& devices, | 827 const MediaDeviceInfoArray& devices, |
833 std::string* device_id) const { | 828 std::string* device_id) const { |
834 if (type == MEDIA_DEVICE_AUDIO_CAPTURE) { | 829 if (type == MEDIA_DEVICE_AUDIO_CAPTURE) { |
835 return PickDeviceId(type, request->salt, request->security_origin, | 830 return PickDeviceId(request->salt, request->security_origin, |
836 request->controls.audio, devices, device_id); | 831 request->controls.audio, devices, device_id); |
837 } else if (type == MEDIA_DEVICE_VIDEO_CAPTURE) { | 832 } else if (type == MEDIA_DEVICE_VIDEO_CAPTURE) { |
838 return PickDeviceId(type, request->salt, request->security_origin, | 833 return PickDeviceId(request->salt, request->security_origin, |
839 request->controls.video, devices, device_id); | 834 request->controls.video, devices, device_id); |
840 } else { | 835 } else { |
841 NOTREACHED(); | 836 NOTREACHED(); |
842 } | 837 } |
843 return false; | 838 return false; |
844 } | 839 } |
845 | 840 |
846 void MediaStreamManager::TranslateDeviceIdToSourceId( | 841 void MediaStreamManager::TranslateDeviceIdToSourceId( |
847 DeviceRequest* request, | 842 DeviceRequest* request, |
848 MediaStreamDevice* device) { | 843 MediaStreamDevice* device) { |
(...skipping 931 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1780 request->ui_proxy->OnStarted( | 1775 request->ui_proxy->OnStarted( |
1781 base::Bind(&MediaStreamManager::StopMediaStreamFromBrowser, | 1776 base::Bind(&MediaStreamManager::StopMediaStreamFromBrowser, |
1782 base::Unretained(this), label), | 1777 base::Unretained(this), label), |
1783 base::Bind(&MediaStreamManager::OnMediaStreamUIWindowId, | 1778 base::Bind(&MediaStreamManager::OnMediaStreamUIWindowId, |
1784 base::Unretained(this), request->video_type(), | 1779 base::Unretained(this), request->video_type(), |
1785 request->devices)); | 1780 request->devices)); |
1786 } | 1781 } |
1787 } | 1782 } |
1788 | 1783 |
1789 } // namespace content | 1784 } // namespace content |
OLD | NEW |