Chromium Code Reviews| Index: content/renderer/media/media_stream_dependency_factory.cc |
| =================================================================== |
| --- content/renderer/media/media_stream_dependency_factory.cc (revision 172673) |
| +++ content/renderer/media/media_stream_dependency_factory.cc (working copy) |
| @@ -237,26 +237,59 @@ |
| // Add audio tracks. |
| 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(perkj): Implement support for sources from remote MediaStreams. |
| - NOTIMPLEMENTED(); |
| - continue; |
| + WebKit::WebMediaStreamSource source = audio_components[i].source(); |
| + |
| + // See if we're adding a WebAudio MediaStream. |
| + if (source.requiresAudioConsumer()) { |
| + if (!webaudio_capturer_source_.get()) { |
| + DVLOG(1) << "CreateNativeLocalMediaStream: WebAudio MediaStream."; |
| + DCHECK(GetWebRtcAudioDevice()); |
| + |
| + // TODO(crogers, xians): In reality we should be able to send a unique |
| + // audio stream to each PeerConnection separately. But currently WebRTC |
| + // is only able to handle a global audio stream sent to ALL peers. |
| + webaudio_capturer_source_ = new WebAudioCapturerSource(); |
|
perkj_chrome
2012/12/17 10:59:20
Why is webauido_capturer_source_ stored at all in
|
| + WebRtcAudioCapturer* capturer = GetWebRtcAudioDevice()->capturer(); |
|
henrika (OOO until Aug 14)
2012/12/18 12:23:02
Note that this guy can return NULL for non-support
|
| + capturer->SetCapturerSource(webaudio_capturer_source_); |
| + capturer->Start(); |
| + |
| + // For lifetime, we're relying on the fact that |
| + // |webaudio_capturer_source_| will live longer than any |
| + // MediaStreamSource, since we're never calling removeAudioConsumer(). |
| + source.addAudioConsumer(webaudio_capturer_source_.get()); |
|
perkj_chrome
2012/12/17 10:59:20
Does addAudioConsumer ref count webaudio_capturer_
|
| + } else { |
| + // TODO(crogers): this is very likely to be less important, but |
| + // in theory we should be able to "connect" multiple WebAudio |
| + // MediaStreams to a single peer, mixing their results. |
|
perkj_chrome
2012/12/17 10:59:20
Multiple MediaStreams will result in multiple call
|
| + // Instead we just ignore additional ones after the first. |
| + DVLOG(1) |
| + << "Multiple MediaStreamAudioDestinationNodes not yet supported!"; |
| + } |
| + } else { |
| + MediaStreamSourceExtraData* source_data = |
| + static_cast<MediaStreamSourceExtraData*>(source.extraData()); |
| + |
| + if (!source_data) { |
| + // TODO(perkj): Implement support for sources from |
| + // remote MediaStreams. |
| + NOTIMPLEMENTED(); |
| + continue; |
| + } |
| + |
| + // TODO(perkj): Refactor the creation of audio tracks to use a proper |
| + // interface for receiving audio input data. Currently NULL is passed |
| + // since the |audio_device| is the wrong class and is unused. |
| + scoped_refptr<webrtc::LocalAudioTrackInterface> audio_track( |
|
perkj_chrome
2012/12/17 15:38:24
line 284 to 287 must be done even for webaudio sou
henrika (OOO until Aug 14)
2012/12/18 13:35:15
I tried this but it did not work. Per adviced me t
perkj_chrome
2012/12/18 14:09:04
Yes- the tracks labels must follow the msid rfc (s
|
| + 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); |
| } |
| - // TODO(perkj): Refactor the creation of audio tracks to use a proper |
| - // interface for receiving audio input data. Currently NULL is passed since |
| - // the |audio_device| is the wrong class and is unused. |
| - scoped_refptr<webrtc::LocalAudioTrackInterface> audio_track( |
| - 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. |