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/renderer/media/media_stream_impl.h" | 5 #include "content/renderer/media/media_stream_impl.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 712 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
723 bool notify_dispatcher) { | 723 bool notify_dispatcher) { |
724 MediaStreamSourceExtraData* extra_data = | 724 MediaStreamSourceExtraData* extra_data = |
725 static_cast<MediaStreamSourceExtraData*> (source.extraData()); | 725 static_cast<MediaStreamSourceExtraData*> (source.extraData()); |
726 CHECK(extra_data); | 726 CHECK(extra_data); |
727 DVLOG(1) << "MediaStreamImpl::StopLocalSource(" | 727 DVLOG(1) << "MediaStreamImpl::StopLocalSource(" |
728 << "{device_id = " << extra_data->device_info().device.id << "})"; | 728 << "{device_id = " << extra_data->device_info().device.id << "})"; |
729 | 729 |
730 if (source.type() == blink::WebMediaStreamSource::TypeAudio) { | 730 if (source.type() == blink::WebMediaStreamSource::TypeAudio) { |
731 if (extra_data->GetAudioCapturer()) { | 731 if (extra_data->GetAudioCapturer()) { |
732 extra_data->GetAudioCapturer()->Stop(); | 732 extra_data->GetAudioCapturer()->Stop(); |
733 | |
734 // Remove the capturer object from the WebRtcAudioDeviceImpl after it | |
735 // stops. | |
736 WebRtcAudioDeviceImpl* audio_device = | |
perkj_chrome
2014/01/12 21:53:06
Can this be moved to AudioCapturer::Stop instead?
| |
737 dependency_factory_->GetWebRtcAudioDevice(); | |
738 if (audio_device) | |
739 audio_device->RemoveAudioCapturer(extra_data->GetAudioCapturer()); | |
733 } | 740 } |
734 } | 741 } |
735 | 742 |
736 if (notify_dispatcher) | 743 if (notify_dispatcher) |
737 media_stream_dispatcher_->StopStreamDevice(extra_data->device_info()); | 744 media_stream_dispatcher_->StopStreamDevice(extra_data->device_info()); |
738 | 745 |
739 blink::WebMediaStreamSource writable_source(source); | 746 blink::WebMediaStreamSource writable_source(source); |
740 writable_source.setReadyState( | 747 writable_source.setReadyState( |
741 blink::WebMediaStreamSource::ReadyStateEnded); | 748 blink::WebMediaStreamSource::ReadyStateEnded); |
742 writable_source.setExtraData(NULL); | 749 writable_source.setExtraData(NULL); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
795 session_id, | 802 session_id, |
796 buffer_size); | 803 buffer_size); |
797 } | 804 } |
798 | 805 |
799 bool MediaStreamImpl::GetAuthorizedDeviceInfoForAudioRenderer( | 806 bool MediaStreamImpl::GetAuthorizedDeviceInfoForAudioRenderer( |
800 int* session_id, | 807 int* session_id, |
801 int* output_sample_rate, | 808 int* output_sample_rate, |
802 int* output_frames_per_buffer) { | 809 int* output_frames_per_buffer) { |
803 DCHECK(CalledOnValidThread()); | 810 DCHECK(CalledOnValidThread()); |
804 | 811 |
805 WebRtcAudioDeviceImpl* audio_device = | 812 // Loop through the sources and find out the capturer that can provide |
806 dependency_factory_->GetWebRtcAudioDevice(); | 813 // the paired device information for the audio renderer. |
807 if (!audio_device) | 814 scoped_refptr<WebRtcAudioCapturer> capturer; |
815 for (LocalStreamSources::const_iterator it = local_sources_.begin(); | |
perkj_chrome
2014/01/12 21:53:06
This is kind of backwards. We moved this info to t
no longer working on chromium
2014/01/13 16:59:59
Done.
| |
816 it != local_sources_.end(); ++it) { | |
817 MediaStreamSourceExtraData* extra_data = | |
818 static_cast<MediaStreamSourceExtraData*>(it->source.extraData()); | |
819 if (it->source.type() == blink::WebMediaStreamSource::TypeAudio && | |
820 extra_data->GetAudioCapturer() && | |
821 !extra_data->GetAudioCapturer()->device_id().empty()) { | |
perkj_chrome
2014/01/12 21:53:06
GetAudioCapturer()->device_id().empty() ?
Can thi
no longer working on chromium
2014/01/13 16:59:59
Remove now.
| |
822 // If there are more than one open capture devices, return false because | |
823 // we have no way to pick an appropriate device. | |
824 if (capturer) { | |
825 DLOG(WARNING) << "Failed to get the authorized paired playout device " | |
826 << "since there are more than one open capture devices."; | |
827 return false; | |
828 } | |
829 capturer = extra_data->GetAudioCapturer(); | |
830 } | |
831 } | |
832 | |
833 if (!capturer) | |
808 return false; | 834 return false; |
809 | 835 |
810 if (!audio_device->GetDefaultCapturer()) | 836 return capturer->GetPairedOutputParameters(session_id, |
811 return false; | 837 output_sample_rate, |
812 | 838 output_frames_per_buffer); |
813 return audio_device->GetDefaultCapturer()->GetPairedOutputParameters( | |
814 session_id, | |
815 output_sample_rate, | |
816 output_frames_per_buffer); | |
817 } | 839 } |
818 | 840 |
819 MediaStreamSourceExtraData::MediaStreamSourceExtraData( | 841 MediaStreamSourceExtraData::MediaStreamSourceExtraData( |
820 const StreamDeviceInfo& device_info, | 842 const StreamDeviceInfo& device_info, |
821 const SourceStopCallback& stop_callback) | 843 const SourceStopCallback& stop_callback) |
822 : device_info_(device_info), | 844 : device_info_(device_info), |
823 stop_callback_(stop_callback) { | 845 stop_callback_(stop_callback) { |
824 } | 846 } |
825 | 847 |
826 MediaStreamSourceExtraData::MediaStreamSourceExtraData() { | 848 MediaStreamSourceExtraData::MediaStreamSourceExtraData() { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
862 enable_automatic_output_device_selection( | 884 enable_automatic_output_device_selection( |
863 enable_automatic_output_device_selection), | 885 enable_automatic_output_device_selection), |
864 frame(frame), | 886 frame(frame), |
865 request(request) { | 887 request(request) { |
866 } | 888 } |
867 | 889 |
868 MediaStreamImpl::UserMediaRequestInfo::~UserMediaRequestInfo() { | 890 MediaStreamImpl::UserMediaRequestInfo::~UserMediaRequestInfo() { |
869 } | 891 } |
870 | 892 |
871 } // namespace content | 893 } // namespace content |
OLD | NEW |