Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(54)

Side by Side Diff: content/renderer/media/media_stream_dependency_factory.cc

Issue 11369171: Add chromium support for MediaStreamAudioDestinationNode (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_dependency_factory.h" 5 #include "content/renderer/media/media_stream_dependency_factory.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/synchronization/waitable_event.h" 9 #include "base/synchronization/waitable_event.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 CreateVideoSource(source_data->device_info().session_id, 221 CreateVideoSource(source_data->device_info().session_id,
222 is_screencast, 222 is_screencast,
223 &native_video_constraints)); 223 &native_video_constraints));
224 source_observer->AddSource(source_data->video_source()); 224 source_observer->AddSource(source_data->video_source());
225 } 225 }
226 source_observer->StartObservering(); 226 source_observer->StartObservering();
227 } 227 }
228 228
229 void MediaStreamDependencyFactory::CreateNativeLocalMediaStream( 229 void MediaStreamDependencyFactory::CreateNativeLocalMediaStream(
230 WebKit::WebMediaStreamDescriptor* description) { 230 WebKit::WebMediaStreamDescriptor* description) {
231 DCHECK(PeerConnectionFactoryCreated()); 231 DCHECK(PeerConnectionFactoryCreated());
perkj_chrome 2012/12/17 10:59:20 Change this to if (!EnsurePeerConnectionFactory()
232 232
233 std::string label = UTF16ToUTF8(description->label()); 233 std::string label = UTF16ToUTF8(description->label());
234 scoped_refptr<webrtc::LocalMediaStreamInterface> native_stream = 234 scoped_refptr<webrtc::LocalMediaStreamInterface> native_stream =
235 CreateLocalMediaStream(label); 235 CreateLocalMediaStream(label);
236 236
237 // Add audio tracks. 237 // Add audio tracks.
238 WebKit::WebVector<WebKit::WebMediaStreamComponent> audio_components; 238 WebKit::WebVector<WebKit::WebMediaStreamComponent> audio_components;
239 description->audioSources(audio_components); 239 description->audioSources(audio_components);
240
240 for (size_t i = 0; i < audio_components.size(); ++i) { 241 for (size_t i = 0; i < audio_components.size(); ++i) {
241 const WebKit::WebMediaStreamSource& source = audio_components[i].source(); 242 WebKit::WebMediaStreamSource source = audio_components[i].source();
242 MediaStreamSourceExtraData* source_data = 243
243 static_cast<MediaStreamSourceExtraData*>(source.extraData()); 244 // See if we're adding a WebAudio MediaStream.
244 if (!source_data) { 245 if (source.requiresAudioConsumer()) {
245 // TODO(perkj): Implement support for sources from remote MediaStreams. 246 if (!webaudio_capturer_source_.get()) {
246 NOTIMPLEMENTED(); 247 DVLOG(1) << "CreateNativeLocalMediaStream: WebAudio MediaStream.";
247 continue; 248 DCHECK(GetWebRtcAudioDevice());
249
250 // TODO(crogers, xians): In reality we should be able to send a unique
251 // audio stream to each PeerConnection separately. But currently WebRTC
252 // is only able to handle a global audio stream sent to ALL peers.
253 webaudio_capturer_source_ = new WebAudioCapturerSource();
perkj_chrome 2012/12/17 10:59:20 Why is webauido_capturer_source_ stored at all in
254 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
255 capturer->SetCapturerSource(webaudio_capturer_source_);
256 capturer->Start();
257
258 // For lifetime, we're relying on the fact that
259 // |webaudio_capturer_source_| will live longer than any
260 // MediaStreamSource, since we're never calling removeAudioConsumer().
261 source.addAudioConsumer(webaudio_capturer_source_.get());
perkj_chrome 2012/12/17 10:59:20 Does addAudioConsumer ref count webaudio_capturer_
262 } else {
263 // TODO(crogers): this is very likely to be less important, but
264 // in theory we should be able to "connect" multiple WebAudio
265 // MediaStreams to a single peer, mixing their results.
perkj_chrome 2012/12/17 10:59:20 Multiple MediaStreams will result in multiple call
266 // Instead we just ignore additional ones after the first.
267 DVLOG(1)
268 << "Multiple MediaStreamAudioDestinationNodes not yet supported!";
269 }
270 } else {
271 MediaStreamSourceExtraData* source_data =
272 static_cast<MediaStreamSourceExtraData*>(source.extraData());
273
274 if (!source_data) {
275 // TODO(perkj): Implement support for sources from
276 // remote MediaStreams.
277 NOTIMPLEMENTED();
278 continue;
279 }
280
281 // TODO(perkj): Refactor the creation of audio tracks to use a proper
282 // interface for receiving audio input data. Currently NULL is passed
283 // since the |audio_device| is the wrong class and is unused.
284 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
285 CreateLocalAudioTrack(UTF16ToUTF8(source.id()), NULL));
286 native_stream->AddTrack(audio_track);
287 audio_track->set_enabled(audio_components[i].isEnabled());
288 // TODO(xians): This set the source of all audio tracks to the same
289 // microphone. Implement support for setting the source per audio track
290 // instead.
291 SetAudioDeviceSessionId(source_data->device_info().session_id);
248 } 292 }
249 // TODO(perkj): Refactor the creation of audio tracks to use a proper
250 // interface for receiving audio input data. Currently NULL is passed since
251 // the |audio_device| is the wrong class and is unused.
252 scoped_refptr<webrtc::LocalAudioTrackInterface> audio_track(
253 CreateLocalAudioTrack(UTF16ToUTF8(source.id()), NULL));
254 native_stream->AddTrack(audio_track);
255 audio_track->set_enabled(audio_components[i].isEnabled());
256 // TODO(xians): This set the source of all audio tracks to the same
257 // microphone. Implement support for setting the source per audio track
258 // instead.
259 SetAudioDeviceSessionId(source_data->device_info().session_id);
260 } 293 }
261 294
262 // Add video tracks. 295 // Add video tracks.
263 WebKit::WebVector<WebKit::WebMediaStreamComponent> video_components; 296 WebKit::WebVector<WebKit::WebMediaStreamComponent> video_components;
264 description->videoSources(video_components); 297 description->videoSources(video_components);
265 for (size_t i = 0; i < video_components.size(); ++i) { 298 for (size_t i = 0; i < video_components.size(); ++i) {
266 const WebKit::WebMediaStreamSource& source = video_components[i].source(); 299 const WebKit::WebMediaStreamSource& source = video_components[i].source();
267 MediaStreamSourceExtraData* source_data = 300 MediaStreamSourceExtraData* source_data =
268 static_cast<MediaStreamSourceExtraData*>(source.extraData()); 301 static_cast<MediaStreamSourceExtraData*>(source.extraData());
269 if (!source_data || !source_data->video_source()) { 302 if (!source_data || !source_data->video_source()) {
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 // processed before returning. We wait for the above task to finish before 517 // processed before returning. We wait for the above task to finish before
485 // letting the the function continue to avoid any potential race issues. 518 // letting the the function continue to avoid any potential race issues.
486 chrome_worker_thread_.Stop(); 519 chrome_worker_thread_.Stop();
487 } else { 520 } else {
488 NOTREACHED() << "Worker thread not running."; 521 NOTREACHED() << "Worker thread not running.";
489 } 522 }
490 } 523 }
491 } 524 }
492 525
493 } // namespace content 526 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698