Chromium Code Reviews| Index: content/renderer/media/media_stream_dependency_factory.cc |
| diff --git a/content/renderer/media/media_stream_dependency_factory.cc b/content/renderer/media/media_stream_dependency_factory.cc |
| index 69a35727ac7c413317e4292452788668680f0e03..7512cce0caff59ba1a22375bc147c1f9fd37d36a 100644 |
| --- a/content/renderer/media/media_stream_dependency_factory.cc |
| +++ b/content/renderer/media/media_stream_dependency_factory.cc |
| @@ -190,6 +190,7 @@ void MediaStreamDependencyFactory::CreateNativeMediaSources( |
| const WebKit::WebMediaConstraints& video_constraints, |
| WebKit::WebMediaStreamDescriptor* description, |
| const MediaSourcesCreatedCallback& sources_created) { |
| + DVLOG(1) << "MediaStreamDependencyFactory::CreateNativeMediaSources()"; |
| if (!EnsurePeerConnectionFactory()) { |
| sources_created.Run(description, false); |
| return; |
| @@ -223,11 +224,59 @@ void MediaStreamDependencyFactory::CreateNativeMediaSources( |
| &native_video_constraints)); |
| source_observer->AddSource(source_data->video_source()); |
| } |
| + |
| + // Do additional source initialization if the audio source is a valid |
| + // microphone. |
| + WebKit::WebVector<WebKit::WebMediaStreamComponent> audio_components; |
| + description->audioSources(audio_components); |
| + for (size_t i = 0; i < audio_components.size(); ++i) { |
| + const WebKit::WebMediaStreamSource& source = audio_components[i].source(); |
| + MediaStreamSourceExtraData* source_data = |
| + static_cast<MediaStreamSourceExtraData*>(source.extraData()); |
| + if (!source_data) { |
| + // TODO(henrika): Implement support for sources from remote MediaStreams. |
| + NOTIMPLEMENTED(); |
| + continue; |
| + } |
| + |
| + const MediaStreamDevice device = source_data->device_info().device; |
| + if (device.type == content::MEDIA_DEVICE_AUDIO_CAPTURE) { |
| + // Initialize the source using audio parameters for the selected |
| + // capture device. |
| + WebRtcAudioCapturer* capturer = GetWebRtcAudioDevice()->capturer(); |
| + // TODO(henrika): refactor \content\public\common\media_stream_request.h |
| + // to allow dependency of media::ChannelLayout and avoid static_cast. |
| + if (!capturer->Initialize( |
| + static_cast<media::ChannelLayout>(device.channel_layout), |
|
tommi (sloooow) - chröme
2013/01/15 17:43:49
indent
henrika (OOO until Aug 14)
2013/01/16 16:37:17
Done.
|
| + device.sample_rate)) { |
| + // The capturer does not support all possible sample rates. |
| + sources_created.Run(description, false); |
| + return; |
| + } |
| + |
| + // Specify which capture device to use. The acquired session id is used |
| + // for identification. |
| + // TODO(henrika): the current design does not support a uniqe source |
| + // for each audio track. |
| + if (source_data->device_info().session_id <= 0) { |
| + LOG(ERROR) << "Invalid audio session id"; |
| + sources_created.Run(description, false); |
| + return; |
| + } |
| + capturer->SetDevice(source_data->device_info().session_id); |
| + } else { |
| + DLOG(WARNING) << "Unsupported audio source"; |
| + sources_created.Run(description, false); |
| + return; |
| + } |
| + } |
| + |
| source_observer->StartObservering(); |
| } |
| void MediaStreamDependencyFactory::CreateNativeLocalMediaStream( |
| WebKit::WebMediaStreamDescriptor* description) { |
| + DVLOG(1) << "MediaStreamDependencyFactory::CreateNativeLocalMediaStream()"; |
| DCHECK(PeerConnectionFactoryCreated()); |
| std::string label = UTF16ToUTF8(description->label()); |
| @@ -253,10 +302,6 @@ void MediaStreamDependencyFactory::CreateNativeLocalMediaStream( |
| CreateLocalAudioTrack(UTF16ToUTF8(source.id()), NULL)); |
| native_stream->AddTrack(audio_track); |
| audio_track->set_enabled(audio_components[i].isEnabled()); |
| - // TODO(xians): This set the source of all audio tracks to the same |
| - // microphone. Implement support for setting the source per audio track |
| - // instead. |
| - SetAudioDeviceSessionId(source_data->device_info().session_id); |
| } |
| // Add video tracks. |
| @@ -295,6 +340,7 @@ void MediaStreamDependencyFactory::CreateNativeLocalMediaStream( |
| } |
| bool MediaStreamDependencyFactory::CreatePeerConnectionFactory() { |
| + DVLOG(1) << "MediaStreamDependencyFactory::CreatePeerConnectionFactory()"; |
| if (!pc_factory_.get()) { |
| DCHECK(!audio_device_); |
| audio_device_ = new WebRtcAudioDeviceImpl(); |
| @@ -389,10 +435,6 @@ MediaStreamDependencyFactory::GetWebRtcAudioDevice() { |
| return audio_device_; |
| } |
| -void MediaStreamDependencyFactory::SetAudioDeviceSessionId(int session_id) { |
| - audio_device_->SetSessionId(session_id); |
| -} |
| - |
| void MediaStreamDependencyFactory::InitializeWorkerThread( |
| talk_base::Thread** thread, |
| base::WaitableEvent* event) { |