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 <list> | 7 #include <list> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
202 options(options), | 202 options(options), |
203 salt_callback(salt_callback), | 203 salt_callback(salt_callback), |
204 state_(NUM_MEDIA_TYPES, MEDIA_REQUEST_STATE_NOT_REQUESTED), | 204 state_(NUM_MEDIA_TYPES, MEDIA_REQUEST_STATE_NOT_REQUESTED), |
205 audio_type_(MEDIA_NO_SERVICE), | 205 audio_type_(MEDIA_NO_SERVICE), |
206 video_type_(MEDIA_NO_SERVICE) { | 206 video_type_(MEDIA_NO_SERVICE) { |
207 } | 207 } |
208 | 208 |
209 ~DeviceRequest() {} | 209 ~DeviceRequest() {} |
210 | 210 |
211 void SetAudioType(MediaStreamType audio_type) { | 211 void SetAudioType(MediaStreamType audio_type) { |
212 DCHECK(IsAudioMediaType(audio_type) || audio_type == MEDIA_NO_SERVICE); | 212 DCHECK(IsAudioInputMediaType(audio_type) || |
213 audio_type == MEDIA_DEVICE_AUDIO_OUTPUT || | |
214 audio_type == MEDIA_NO_SERVICE); | |
213 audio_type_ = audio_type; | 215 audio_type_ = audio_type; |
214 } | 216 } |
215 | 217 |
216 MediaStreamType audio_type() const { return audio_type_; } | 218 MediaStreamType audio_type() const { return audio_type_; } |
217 | 219 |
218 void SetVideoType(MediaStreamType video_type) { | 220 void SetVideoType(MediaStreamType video_type) { |
219 DCHECK(IsVideoMediaType(video_type) || video_type == MEDIA_NO_SERVICE); | 221 DCHECK(IsVideoMediaType(video_type) || video_type == MEDIA_NO_SERVICE); |
220 video_type_ = video_type; | 222 video_type_ = video_type; |
221 } | 223 } |
222 | 224 |
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
648 int render_process_id, | 650 int render_process_id, |
649 int render_view_id, | 651 int render_view_id, |
650 const ResourceContext::SaltCallback& sc, | 652 const ResourceContext::SaltCallback& sc, |
651 int page_request_id, | 653 int page_request_id, |
652 MediaStreamType type, | 654 MediaStreamType type, |
653 const GURL& security_origin, | 655 const GURL& security_origin, |
654 bool have_permission) { | 656 bool have_permission) { |
655 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 657 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
656 DCHECK(requester); | 658 DCHECK(requester); |
657 DCHECK(type == MEDIA_DEVICE_AUDIO_CAPTURE || | 659 DCHECK(type == MEDIA_DEVICE_AUDIO_CAPTURE || |
658 type == MEDIA_DEVICE_VIDEO_CAPTURE); | 660 type == MEDIA_DEVICE_VIDEO_CAPTURE || |
661 type == MEDIA_DEVICE_AUDIO_OUTPUT); | |
659 | 662 |
660 DeviceRequest* request = new DeviceRequest(requester, | 663 DeviceRequest* request = new DeviceRequest(requester, |
661 render_process_id, | 664 render_process_id, |
662 render_view_id, | 665 render_view_id, |
663 page_request_id, | 666 page_request_id, |
664 security_origin, | 667 security_origin, |
665 have_permission, | 668 have_permission, |
666 false, // user gesture | 669 false, // user gesture |
667 MEDIA_ENUMERATE_DEVICES, | 670 MEDIA_ENUMERATE_DEVICES, |
668 StreamOptions(), | 671 StreamOptions(), |
669 sc); | 672 sc); |
670 if (IsAudioMediaType(type)) | 673 if (IsAudioInputMediaType(type) || type == MEDIA_DEVICE_AUDIO_OUTPUT) |
671 request->SetAudioType(type); | 674 request->SetAudioType(type); |
672 else if (IsVideoMediaType(type)) | 675 else if (IsVideoMediaType(type)) |
673 request->SetVideoType(type); | 676 request->SetVideoType(type); |
674 | 677 |
675 const std::string& label = AddRequest(request); | 678 const std::string& label = AddRequest(request); |
676 // Post a task and handle the request asynchronously. The reason is that the | 679 // Post a task and handle the request asynchronously. The reason is that the |
677 // requester won't have a label for the request until this function returns | 680 // requester won't have a label for the request until this function returns |
678 // and thus can not handle a response. Using base::Unretained is safe since | 681 // and thus can not handle a response. Using base::Unretained is safe since |
679 // MediaStreamManager is deleted on the UI thread, after the IO thread has | 682 // MediaStreamManager is deleted on the UI thread, after the IO thread has |
680 // been stopped. | 683 // been stopped. |
681 BrowserThread::PostTask( | 684 BrowserThread::PostTask( |
682 BrowserThread::IO, FROM_HERE, | 685 BrowserThread::IO, FROM_HERE, |
683 base::Bind(&MediaStreamManager::DoEnumerateDevices, | 686 base::Bind(&MediaStreamManager::DoEnumerateDevices, |
684 base::Unretained(this), label)); | 687 base::Unretained(this), label)); |
685 return label; | 688 return label; |
686 } | 689 } |
687 | 690 |
688 void MediaStreamManager::DoEnumerateDevices(const std::string& label) { | 691 void MediaStreamManager::DoEnumerateDevices(const std::string& label) { |
689 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 692 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
690 DeviceRequest* request = FindRequest(label); | 693 DeviceRequest* request = FindRequest(label); |
691 if (!request) | 694 if (!request) |
692 return; // This can happen if the request has been canceled. | 695 return; // This can happen if the request has been canceled. |
693 | 696 |
697 if (request->audio_type() == MEDIA_DEVICE_AUDIO_OUTPUT) { | |
698 DCHECK_EQ(MEDIA_NO_SERVICE, request->video_type()); | |
699 DCHECK_GE(active_enumeration_ref_count_[MEDIA_DEVICE_AUDIO_OUTPUT], 0); | |
700 request->SetState(MEDIA_DEVICE_AUDIO_OUTPUT, MEDIA_REQUEST_STATE_REQUESTED); | |
701 if (active_enumeration_ref_count_[MEDIA_DEVICE_AUDIO_OUTPUT] == 0) { | |
702 ++active_enumeration_ref_count_[MEDIA_DEVICE_AUDIO_OUTPUT]; | |
703 device_task_runner_->PostTask( | |
704 FROM_HERE, | |
705 base::Bind(&MediaStreamManager::EnumerateAudioOutputDevices, | |
706 base::Unretained(this), | |
707 label)); | |
708 } | |
709 return; | |
tommi (sloooow) - chröme
2014/06/03 13:38:37
no chance that video_type could get incorrectly ig
Henrik Grunell
2014/06/03 14:33:16
Hmm, there's already this above:
DCHECK_EQ(MEDIA_N
tommi (sloooow) - chröme
2014/06/03 16:42:42
Ah, yes that's it. Thanks.
| |
710 } | |
711 | |
694 MediaStreamType type; | 712 MediaStreamType type; |
695 EnumerationCache* cache; | 713 EnumerationCache* cache; |
696 if (request->audio_type() == MEDIA_DEVICE_AUDIO_CAPTURE) { | 714 if (request->audio_type() == MEDIA_DEVICE_AUDIO_CAPTURE) { |
697 DCHECK_EQ(MEDIA_NO_SERVICE, request->video_type()); | 715 DCHECK_EQ(MEDIA_NO_SERVICE, request->video_type()); |
698 type = MEDIA_DEVICE_AUDIO_CAPTURE; | 716 type = MEDIA_DEVICE_AUDIO_CAPTURE; |
699 cache = &audio_enumeration_cache_; | 717 cache = &audio_enumeration_cache_; |
700 } else { | 718 } else { |
701 DCHECK_EQ(MEDIA_DEVICE_VIDEO_CAPTURE, request->video_type()); | 719 DCHECK_EQ(MEDIA_DEVICE_VIDEO_CAPTURE, request->video_type()); |
702 DCHECK_EQ(MEDIA_NO_SERVICE, request->audio_type()); | 720 DCHECK_EQ(MEDIA_NO_SERVICE, request->audio_type()); |
703 type = MEDIA_DEVICE_VIDEO_CAPTURE; | 721 type = MEDIA_DEVICE_VIDEO_CAPTURE; |
704 cache = &video_enumeration_cache_; | 722 cache = &video_enumeration_cache_; |
705 } | 723 } |
706 | 724 |
707 if (!EnumerationRequired(cache, type)) { | 725 if (!EnumerationRequired(cache, type)) { |
708 // Cached device list of this type exists. Just send it out. | 726 // Cached device list of this type exists. Just send it out. |
709 request->SetState(type, MEDIA_REQUEST_STATE_REQUESTED); | 727 request->SetState(type, MEDIA_REQUEST_STATE_REQUESTED); |
710 request->devices = cache->devices; | 728 request->devices = cache->devices; |
711 FinalizeEnumerateDevices(label, request); | 729 FinalizeEnumerateDevices(label, request); |
712 } else { | 730 } else { |
713 StartEnumeration(request); | 731 StartEnumeration(request); |
714 } | 732 } |
715 DVLOG(1) << "Enumerate Devices ({label = " << label << "})"; | 733 DVLOG(1) << "Enumerate Devices ({label = " << label << "})"; |
716 } | 734 } |
717 | 735 |
736 void MediaStreamManager::EnumerateAudioOutputDevices( | |
737 const std::string& label) { | |
738 DCHECK(device_task_runner_); | |
tommi (sloooow) - chröme
2014/06/03 13:38:37
no need for this dcheck if you deref on the next l
Henrik Grunell
2014/06/03 14:33:16
Done.
| |
739 DCHECK(device_task_runner_->BelongsToCurrentThread()); | |
740 | |
741 scoped_ptr<media::AudioDeviceNames> device_names(new media::AudioDeviceNames); | |
tommi (sloooow) - chröme
2014/06/03 13:38:37
nit: AudioDeviceNames()
Henrik Grunell
2014/06/03 14:33:16
Done.
| |
742 audio_manager_->GetAudioOutputDeviceNames(device_names.get()); | |
743 StreamDeviceInfoArray devices; | |
744 for (media::AudioDeviceNames::iterator it = device_names->begin(); | |
745 it != device_names->end(); ++it) { | |
746 StreamDeviceInfo device(MEDIA_DEVICE_AUDIO_OUTPUT, | |
747 it->device_name, | |
748 it->unique_id); | |
749 devices.push_back(device); | |
750 } | |
751 | |
752 BrowserThread::PostTask( | |
753 BrowserThread::IO, FROM_HERE, | |
754 base::Bind(&MediaStreamManager::AudioOutputDevicesEnumerated, | |
755 base::Unretained(this), | |
756 devices)); | |
757 } | |
758 | |
759 void MediaStreamManager::AudioOutputDevicesEnumerated( | |
760 const StreamDeviceInfoArray& devices) { | |
761 DCHECK_CURRENTLY_ON(BrowserThread::IO); | |
762 DVLOG(1) << "AudioOutputDevicesEnumerated()"; | |
763 | |
764 std::string log_message = "New device enumeration result:\n" + | |
765 GetLogMessageString(MEDIA_DEVICE_AUDIO_OUTPUT, | |
766 devices); | |
767 SendMessageToNativeLog(log_message); | |
768 | |
769 // Publish the result for all requests waiting for device list(s). | |
770 for (DeviceRequests::iterator it = requests_.begin(); it != requests_.end(); | |
771 ++it) { | |
772 if (it->second->state(MEDIA_DEVICE_AUDIO_OUTPUT) == | |
773 MEDIA_REQUEST_STATE_REQUESTED && | |
774 it->second->audio_type() == MEDIA_DEVICE_AUDIO_OUTPUT) { | |
775 DCHECK_EQ(MEDIA_ENUMERATE_DEVICES, it->second->request_type); | |
776 it->second->SetState(MEDIA_DEVICE_AUDIO_OUTPUT, | |
777 MEDIA_REQUEST_STATE_PENDING_APPROVAL); | |
778 it->second->devices = devices; | |
779 FinalizeEnumerateDevices(it->first, it->second); | |
780 } | |
781 } | |
782 | |
783 --active_enumeration_ref_count_[MEDIA_DEVICE_AUDIO_OUTPUT]; | |
784 DCHECK_GE(active_enumeration_ref_count_[MEDIA_DEVICE_AUDIO_OUTPUT], 0); | |
785 } | |
786 | |
718 void MediaStreamManager::OpenDevice(MediaStreamRequester* requester, | 787 void MediaStreamManager::OpenDevice(MediaStreamRequester* requester, |
719 int render_process_id, | 788 int render_process_id, |
720 int render_view_id, | 789 int render_view_id, |
721 const ResourceContext::SaltCallback& sc, | 790 const ResourceContext::SaltCallback& sc, |
722 int page_request_id, | 791 int page_request_id, |
723 const std::string& device_id, | 792 const std::string& device_id, |
724 MediaStreamType type, | 793 MediaStreamType type, |
725 const GURL& security_origin) { | 794 const GURL& security_origin) { |
726 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 795 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
727 DCHECK(type == MEDIA_DEVICE_AUDIO_CAPTURE || | 796 DCHECK(type == MEDIA_DEVICE_AUDIO_CAPTURE || |
728 type == MEDIA_DEVICE_VIDEO_CAPTURE); | 797 type == MEDIA_DEVICE_VIDEO_CAPTURE); |
729 DVLOG(1) << "OpenDevice ({page_request_id = " << page_request_id << "})"; | 798 DVLOG(1) << "OpenDevice ({page_request_id = " << page_request_id << "})"; |
730 StreamOptions options; | 799 StreamOptions options; |
731 if (IsAudioMediaType(type)) { | 800 if (IsAudioInputMediaType(type)) { |
732 options.audio_requested = true; | 801 options.audio_requested = true; |
733 options.mandatory_audio.push_back( | 802 options.mandatory_audio.push_back( |
734 StreamOptions::Constraint(kMediaStreamSourceInfoId, device_id)); | 803 StreamOptions::Constraint(kMediaStreamSourceInfoId, device_id)); |
735 } else if (IsVideoMediaType(type)) { | 804 } else if (IsVideoMediaType(type)) { |
736 options.video_requested = true; | 805 options.video_requested = true; |
737 options.mandatory_video.push_back( | 806 options.mandatory_video.push_back( |
738 StreamOptions::Constraint(kMediaStreamSourceInfoId, device_id)); | 807 StreamOptions::Constraint(kMediaStreamSourceInfoId, device_id)); |
739 } else { | 808 } else { |
740 NOTREACHED(); | 809 NOTREACHED(); |
741 } | 810 } |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1053 void MediaStreamManager::PostRequestToUI(const std::string& label, | 1122 void MediaStreamManager::PostRequestToUI(const std::string& label, |
1054 DeviceRequest* request) { | 1123 DeviceRequest* request) { |
1055 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 1124 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
1056 DCHECK(request->UIRequest()); | 1125 DCHECK(request->UIRequest()); |
1057 DVLOG(1) << "PostRequestToUI({label= " << label << "})"; | 1126 DVLOG(1) << "PostRequestToUI({label= " << label << "})"; |
1058 | 1127 |
1059 const MediaStreamType audio_type = request->audio_type(); | 1128 const MediaStreamType audio_type = request->audio_type(); |
1060 const MediaStreamType video_type = request->video_type(); | 1129 const MediaStreamType video_type = request->video_type(); |
1061 | 1130 |
1062 // Post the request to UI and set the state. | 1131 // Post the request to UI and set the state. |
1063 if (IsAudioMediaType(audio_type)) | 1132 if (IsAudioInputMediaType(audio_type)) |
1064 request->SetState(audio_type, MEDIA_REQUEST_STATE_PENDING_APPROVAL); | 1133 request->SetState(audio_type, MEDIA_REQUEST_STATE_PENDING_APPROVAL); |
1065 if (IsVideoMediaType(video_type)) | 1134 if (IsVideoMediaType(video_type)) |
1066 request->SetState(video_type, MEDIA_REQUEST_STATE_PENDING_APPROVAL); | 1135 request->SetState(video_type, MEDIA_REQUEST_STATE_PENDING_APPROVAL); |
1067 | 1136 |
1068 if (use_fake_ui_) { | 1137 if (use_fake_ui_) { |
1069 if (!fake_ui_) | 1138 if (!fake_ui_) |
1070 fake_ui_.reset(new FakeMediaStreamUIProxy()); | 1139 fake_ui_.reset(new FakeMediaStreamUIProxy()); |
1071 | 1140 |
1072 MediaStreamDevices devices; | 1141 MediaStreamDevices devices; |
1073 if (audio_enumeration_cache_.valid) { | 1142 if (audio_enumeration_cache_.valid) { |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1334 void MediaStreamManager::FinalizeGenerateStream(const std::string& label, | 1403 void MediaStreamManager::FinalizeGenerateStream(const std::string& label, |
1335 DeviceRequest* request) { | 1404 DeviceRequest* request) { |
1336 DVLOG(1) << "FinalizeGenerateStream label " << label; | 1405 DVLOG(1) << "FinalizeGenerateStream label " << label; |
1337 const StreamDeviceInfoArray& requested_devices = request->devices; | 1406 const StreamDeviceInfoArray& requested_devices = request->devices; |
1338 | 1407 |
1339 // Partition the array of devices into audio vs video. | 1408 // Partition the array of devices into audio vs video. |
1340 StreamDeviceInfoArray audio_devices, video_devices; | 1409 StreamDeviceInfoArray audio_devices, video_devices; |
1341 for (StreamDeviceInfoArray::const_iterator device_it = | 1410 for (StreamDeviceInfoArray::const_iterator device_it = |
1342 requested_devices.begin(); | 1411 requested_devices.begin(); |
1343 device_it != requested_devices.end(); ++device_it) { | 1412 device_it != requested_devices.end(); ++device_it) { |
1344 if (IsAudioMediaType(device_it->device.type)) { | 1413 if (IsAudioInputMediaType(device_it->device.type)) { |
1345 audio_devices.push_back(*device_it); | 1414 audio_devices.push_back(*device_it); |
1346 } else if (IsVideoMediaType(device_it->device.type)) { | 1415 } else if (IsVideoMediaType(device_it->device.type)) { |
1347 video_devices.push_back(*device_it); | 1416 video_devices.push_back(*device_it); |
1348 } else { | 1417 } else { |
1349 NOTREACHED(); | 1418 NOTREACHED(); |
1350 } | 1419 } |
1351 } | 1420 } |
1352 | 1421 |
1353 request->requester->StreamGenerated( | 1422 request->requester->StreamGenerated( |
1354 request->requesting_view_id, | 1423 request->requesting_view_id, |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1486 StreamDeviceInfoArray* devices = &(request->devices); | 1555 StreamDeviceInfoArray* devices = &(request->devices); |
1487 for (StreamDeviceInfoArray::iterator device_it = devices->begin(); | 1556 for (StreamDeviceInfoArray::iterator device_it = devices->begin(); |
1488 device_it != devices->end(); ++device_it) { | 1557 device_it != devices->end(); ++device_it) { |
1489 if (device_it->device.type == stream_type && | 1558 if (device_it->device.type == stream_type && |
1490 device_it->session_id == capture_session_id) { | 1559 device_it->session_id == capture_session_id) { |
1491 CHECK(request->state(device_it->device.type) == | 1560 CHECK(request->state(device_it->device.type) == |
1492 MEDIA_REQUEST_STATE_OPENING); | 1561 MEDIA_REQUEST_STATE_OPENING); |
1493 // We've found a matching request. | 1562 // We've found a matching request. |
1494 request->SetState(device_it->device.type, MEDIA_REQUEST_STATE_DONE); | 1563 request->SetState(device_it->device.type, MEDIA_REQUEST_STATE_DONE); |
1495 | 1564 |
1496 if (IsAudioMediaType(device_it->device.type)) { | 1565 if (IsAudioInputMediaType(device_it->device.type)) { |
1497 // Store the native audio parameters in the device struct. | 1566 // Store the native audio parameters in the device struct. |
1498 // TODO(xians): Handle the tab capture sample rate/channel layout | 1567 // TODO(xians): Handle the tab capture sample rate/channel layout |
1499 // in AudioInputDeviceManager::Open(). | 1568 // in AudioInputDeviceManager::Open(). |
1500 if (device_it->device.type != content::MEDIA_TAB_AUDIO_CAPTURE) { | 1569 if (device_it->device.type != content::MEDIA_TAB_AUDIO_CAPTURE) { |
1501 const StreamDeviceInfo* info = | 1570 const StreamDeviceInfo* info = |
1502 audio_input_device_manager_->GetOpenedDeviceInfoById( | 1571 audio_input_device_manager_->GetOpenedDeviceInfoById( |
1503 device_it->session_id); | 1572 device_it->session_id); |
1504 device_it->device.input = info->device.input; | 1573 device_it->device.input = info->device.input; |
1505 device_it->device.matched_output = info->device.matched_output; | 1574 device_it->device.matched_output = info->device.matched_output; |
1506 } | 1575 } |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1789 request->devices.push_back(device_info); | 1858 request->devices.push_back(device_info); |
1790 | 1859 |
1791 request->SetState(device_info.device.type, MEDIA_REQUEST_STATE_OPENING); | 1860 request->SetState(device_info.device.type, MEDIA_REQUEST_STATE_OPENING); |
1792 DVLOG(1) << "HandleAccessRequestResponse - opening device " | 1861 DVLOG(1) << "HandleAccessRequestResponse - opening device " |
1793 << ", {label = " << label << "}" | 1862 << ", {label = " << label << "}" |
1794 << ", {device_id = " << device_info.device.id << "}" | 1863 << ", {device_id = " << device_info.device.id << "}" |
1795 << ", {session_id = " << device_info.session_id << "}"; | 1864 << ", {session_id = " << device_info.session_id << "}"; |
1796 } | 1865 } |
1797 | 1866 |
1798 // Check whether we've received all stream types requested. | 1867 // Check whether we've received all stream types requested. |
1799 if (!found_audio && IsAudioMediaType(request->audio_type())) { | 1868 if (!found_audio && IsAudioInputMediaType(request->audio_type())) { |
1800 request->SetState(request->audio_type(), MEDIA_REQUEST_STATE_ERROR); | 1869 request->SetState(request->audio_type(), MEDIA_REQUEST_STATE_ERROR); |
1801 DVLOG(1) << "Set no audio found label " << label; | 1870 DVLOG(1) << "Set no audio found label " << label; |
1802 } | 1871 } |
1803 | 1872 |
1804 if (!found_video && IsVideoMediaType(request->video_type())) | 1873 if (!found_video && IsVideoMediaType(request->video_type())) |
1805 request->SetState(request->video_type(), MEDIA_REQUEST_STATE_ERROR); | 1874 request->SetState(request->video_type(), MEDIA_REQUEST_STATE_ERROR); |
1806 | 1875 |
1807 if (RequestDone(*request)) | 1876 if (RequestDone(*request)) |
1808 HandleRequestDone(label, request); | 1877 HandleRequestDone(label, request); |
1809 } | 1878 } |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1857 MediaObserver* media_observer = | 1926 MediaObserver* media_observer = |
1858 GetContentClient()->browser()->GetMediaObserver(); | 1927 GetContentClient()->browser()->GetMediaObserver(); |
1859 | 1928 |
1860 // Map the devices to MediaStreamDevices. | 1929 // Map the devices to MediaStreamDevices. |
1861 MediaStreamDevices new_devices; | 1930 MediaStreamDevices new_devices; |
1862 for (StreamDeviceInfoArray::const_iterator it = devices.begin(); | 1931 for (StreamDeviceInfoArray::const_iterator it = devices.begin(); |
1863 it != devices.end(); ++it) { | 1932 it != devices.end(); ++it) { |
1864 new_devices.push_back(it->device); | 1933 new_devices.push_back(it->device); |
1865 } | 1934 } |
1866 | 1935 |
1867 if (IsAudioMediaType(stream_type)) { | 1936 if (IsAudioInputMediaType(stream_type)) { |
1868 MediaCaptureDevicesImpl::GetInstance()->OnAudioCaptureDevicesChanged( | 1937 MediaCaptureDevicesImpl::GetInstance()->OnAudioCaptureDevicesChanged( |
1869 new_devices); | 1938 new_devices); |
1870 if (media_observer) | 1939 if (media_observer) |
1871 media_observer->OnAudioCaptureDevicesChanged(); | 1940 media_observer->OnAudioCaptureDevicesChanged(); |
1872 } else if (IsVideoMediaType(stream_type)) { | 1941 } else if (IsVideoMediaType(stream_type)) { |
1873 MediaCaptureDevicesImpl::GetInstance()->OnVideoCaptureDevicesChanged( | 1942 MediaCaptureDevicesImpl::GetInstance()->OnVideoCaptureDevicesChanged( |
1874 new_devices); | 1943 new_devices); |
1875 if (media_observer) | 1944 if (media_observer) |
1876 media_observer->OnVideoCaptureDevicesChanged(); | 1945 media_observer->OnVideoCaptureDevicesChanged(); |
1877 } else { | 1946 } else { |
1878 NOTREACHED(); | 1947 NOTREACHED(); |
1879 } | 1948 } |
1880 } | 1949 } |
1881 | 1950 |
1882 bool MediaStreamManager::RequestDone(const DeviceRequest& request) const { | 1951 bool MediaStreamManager::RequestDone(const DeviceRequest& request) const { |
1883 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 1952 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
1884 | 1953 |
1885 const bool requested_audio = IsAudioMediaType(request.audio_type()); | 1954 const bool requested_audio = IsAudioInputMediaType(request.audio_type()); |
1886 const bool requested_video = IsVideoMediaType(request.video_type()); | 1955 const bool requested_video = IsVideoMediaType(request.video_type()); |
1887 | 1956 |
1888 const bool audio_done = | 1957 const bool audio_done = |
1889 !requested_audio || | 1958 !requested_audio || |
1890 request.state(request.audio_type()) == MEDIA_REQUEST_STATE_DONE || | 1959 request.state(request.audio_type()) == MEDIA_REQUEST_STATE_DONE || |
1891 request.state(request.audio_type()) == MEDIA_REQUEST_STATE_ERROR; | 1960 request.state(request.audio_type()) == MEDIA_REQUEST_STATE_ERROR; |
1892 if (!audio_done) | 1961 if (!audio_done) |
1893 return false; | 1962 return false; |
1894 | 1963 |
1895 const bool video_done = | 1964 const bool video_done = |
1896 !requested_video || | 1965 !requested_video || |
1897 request.state(request.video_type()) == MEDIA_REQUEST_STATE_DONE || | 1966 request.state(request.video_type()) == MEDIA_REQUEST_STATE_DONE || |
1898 request.state(request.video_type()) == MEDIA_REQUEST_STATE_ERROR; | 1967 request.state(request.video_type()) == MEDIA_REQUEST_STATE_ERROR; |
1899 if (!video_done) | 1968 if (!video_done) |
1900 return false; | 1969 return false; |
1901 | 1970 |
1902 return true; | 1971 return true; |
1903 } | 1972 } |
1904 | 1973 |
1905 MediaStreamProvider* MediaStreamManager::GetDeviceManager( | 1974 MediaStreamProvider* MediaStreamManager::GetDeviceManager( |
1906 MediaStreamType stream_type) { | 1975 MediaStreamType stream_type) { |
1907 if (IsVideoMediaType(stream_type)) { | 1976 if (IsVideoMediaType(stream_type)) { |
1908 return video_capture_manager(); | 1977 return video_capture_manager(); |
1909 } else if (IsAudioMediaType(stream_type)) { | 1978 } else if (IsAudioInputMediaType(stream_type)) { |
1910 return audio_input_device_manager(); | 1979 return audio_input_device_manager(); |
1911 } | 1980 } |
1912 NOTREACHED(); | 1981 NOTREACHED(); |
1913 return NULL; | 1982 return NULL; |
1914 } | 1983 } |
1915 | 1984 |
1916 void MediaStreamManager::OnDevicesChanged( | 1985 void MediaStreamManager::OnDevicesChanged( |
1917 base::SystemMonitor::DeviceType device_type) { | 1986 base::SystemMonitor::DeviceType device_type) { |
1918 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 1987 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
1919 | 1988 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1951 if (it->device.type == MEDIA_DESKTOP_VIDEO_CAPTURE) { | 2020 if (it->device.type == MEDIA_DESKTOP_VIDEO_CAPTURE) { |
1952 video_capture_manager_->SetDesktopCaptureWindowId(it->session_id, | 2021 video_capture_manager_->SetDesktopCaptureWindowId(it->session_id, |
1953 window_id); | 2022 window_id); |
1954 break; | 2023 break; |
1955 } | 2024 } |
1956 } | 2025 } |
1957 } | 2026 } |
1958 } | 2027 } |
1959 | 2028 |
1960 } // namespace content | 2029 } // namespace content |
OLD | NEW |