Chromium Code Reviews| Index: content/renderer/media/rtc_peer_connection_handler.cc |
| =================================================================== |
| --- content/renderer/media/rtc_peer_connection_handler.cc (revision 166546) |
| +++ content/renderer/media/rtc_peer_connection_handler.cc (working copy) |
| @@ -12,7 +12,10 @@ |
| #include "base/utf_string_conversions.h" |
| #include "content/renderer/media/media_stream_dependency_factory.h" |
| #include "content/renderer/media/rtc_media_constraints.h" |
| +#include "content/renderer/media/webrtc_audio_device_impl.h" |
| #include "third_party/WebKit/Source/Platform/chromium/public/WebMediaConstraints.h" |
| +#include "third_party/WebKit/Source/Platform/chromium/public/WebMediaStreamComponent.h" |
| +#include "third_party/WebKit/Source/Platform/chromium/public/WebMediaStreamSource.h" |
| #include "third_party/WebKit/Source/Platform/chromium/public/WebRTCConfiguration.h" |
| #include "third_party/WebKit/Source/Platform/chromium/public/WebRTCICECandidate.h" |
| #include "third_party/WebKit/Source/Platform/chromium/public/WebRTCPeerConnectionHandlerClient.h" |
| @@ -306,6 +309,24 @@ |
| bool RTCPeerConnectionHandler::addStream( |
| const WebKit::WebMediaStreamDescriptor& stream, |
| const WebKit::WebMediaConstraints& options) { |
| + // See if we're adding a WebAudio MediaStream. |
| + WebKit::WebVector<WebKit::WebMediaStreamComponent> audioComponents; |
| + stream.audioSources(audioComponents); |
| + if (audioComponents.size() > 0) { |
|
perkj_chrome
2012/11/12 10:35:11
This seems to be in the wrong place and should be
|
| + if (audioComponents[0].source().isWebAudioSource()) { |
| + DVLOG(1) << "RTCPeerConnectionHandler: adding WebAudio MediaStream."; |
| + // 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. |
| + base::AutoLock auto_lock(audio_lock_); |
| + webaudio_capturer_source_ = new WebAudioCapturerSource(); |
|
tommi (sloooow) - chröme
2012/11/12 09:46:18
Should we first DCHECK that webaudioÖcapturer_sour
|
| + WebRtcAudioCapturer* capturer = |
| + dependency_factory_->GetWebRtcAudioDevice()->capturer(); |
|
tommi (sloooow) - chröme
2012/11/12 09:46:18
no chance that GetWebRtcAudioDevice() returns NULL
|
| + capturer->SetCapturerSource(webaudio_capturer_source_); |
| + capturer->Start(); |
| + } |
| + } |
| + |
| RTCMediaConstraints constraints(options); |
| return AddStream(stream, &constraints); |
| } |
| @@ -320,6 +341,14 @@ |
| native_peer_connection_ = NULL; |
| } |
| +void RTCPeerConnectionHandler::consumeAudio( |
| + const WebKit::WebVector<const float*>& audio_data, |
| + size_t number_of_frames) { |
| + base::AutoLock auto_lock(audio_lock_); |
| + if (webaudio_capturer_source_.get()) |
|
tommi (sloooow) - chröme
2012/11/12 09:46:18
nit: scoped_refptr supports checking validity with
|
| + webaudio_capturer_source_->HandleCapture(audio_data, number_of_frames); |
| +} |
| + |
| void RTCPeerConnectionHandler::OnError() { |
| // TODO(perkj): Implement. |
| NOTIMPLEMENTED(); |