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

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

Issue 11270012: Adding audio support to the new webmediaplyer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: added a lock to protect the |renderer_| Created 8 years, 1 month 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_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/string_number_conversions.h" 10 #include "base/string_number_conversions.h"
11 #include "base/stringprintf.h" 11 #include "base/stringprintf.h"
12 #include "base/utf_string_conversions.h" 12 #include "base/utf_string_conversions.h"
13 #include "content/renderer/media/capture_video_decoder.h" 13 #include "content/renderer/media/capture_video_decoder.h"
14 #include "content/renderer/media/local_video_capture.h" 14 #include "content/renderer/media/local_video_capture.h"
15 #include "content/renderer/media/media_stream_extra_data.h" 15 #include "content/renderer/media/media_stream_extra_data.h"
16 #include "content/renderer/media/media_stream_source_extra_data.h" 16 #include "content/renderer/media/media_stream_source_extra_data.h"
17 #include "content/renderer/media/media_stream_dependency_factory.h" 17 #include "content/renderer/media/media_stream_dependency_factory.h"
18 #include "content/renderer/media/media_stream_dispatcher.h" 18 #include "content/renderer/media/media_stream_dispatcher.h"
19 #include "content/renderer/media/rtc_video_decoder.h" 19 #include "content/renderer/media/rtc_video_decoder.h"
20 #include "content/renderer/media/rtc_video_renderer.h" 20 #include "content/renderer/media/rtc_video_renderer.h"
21 #include "content/renderer/media/video_capture_impl_manager.h" 21 #include "content/renderer/media/video_capture_impl_manager.h"
22 #include "content/renderer/media/webrtc_uma_histograms.h" 22 #include "content/renderer/media/webrtc_uma_histograms.h"
23 #include "content/renderer/media/webrtc_audio_renderer.h"
23 #include "media/base/message_loop_factory.h" 24 #include "media/base/message_loop_factory.h"
25 #include "media/base/rtc_audio_renderer.h"
24 #include "third_party/WebKit/Source/Platform/chromium/public/WebMediaConstraints .h" 26 #include "third_party/WebKit/Source/Platform/chromium/public/WebMediaConstraints .h"
25 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" 27 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h"
26 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" 28 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
27 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaStreamRegistr y.h" 29 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaStreamRegistr y.h"
28 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" 30 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h"
29 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebMediaStre amComponent.h" 31 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebMediaStre amComponent.h"
30 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebMediaStre amDescriptor.h" 32 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebMediaStre amDescriptor.h"
31 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebMediaStre amSource.h" 33 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebMediaStre amSource.h"
32 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h" 34 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h"
33 35
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 if (extra_data->local_stream()) 257 if (extra_data->local_stream())
256 return CreateLocalVideoDecoder(extra_data->local_stream(), 258 return CreateLocalVideoDecoder(extra_data->local_stream(),
257 message_loop_factory); 259 message_loop_factory);
258 if (extra_data->remote_stream()) 260 if (extra_data->remote_stream())
259 return CreateRemoteVideoDecoder(extra_data->remote_stream(), 261 return CreateRemoteVideoDecoder(extra_data->remote_stream(),
260 message_loop_factory); 262 message_loop_factory);
261 NOTREACHED(); 263 NOTREACHED();
262 return NULL; 264 return NULL;
263 } 265 }
264 266
267 scoped_refptr<media::RtcAudioRenderer> MediaStreamImpl::GetAudioRenderer(
268 const GURL& url) {
269 DCHECK(CalledOnValidThread());
270 WebKit::WebMediaStreamDescriptor descriptor(GetMediaStream(url));
271
272 if (descriptor.isNull() || !descriptor.extraData())
273 return NULL; // This is not a valid stream.
274
275 DVLOG(1) << "MediaStreamImpl::GetAudioRenderer stream:"
276 << UTF16ToUTF8(descriptor.label());
277
278 MediaStreamExtraData* extra_data =
279 static_cast<MediaStreamExtraData*>(descriptor.extraData());
280 if (extra_data->remote_stream()) {
281 scoped_refptr<content::WebRtcAudioRenderer> renderer =
wjia(left Chromium) 2012/10/24 22:05:15 nit: no need content::
no longer working on chromium 2012/10/25 10:19:41 Done.
282 CreateRemoteAudioRenderer(extra_data->remote_stream());
283
284 dependency_factory_->GetWebRtcAudioDevice()->SetRenderer(renderer);
285 return renderer;
286 }
287
288 if (extra_data->local_stream()) {
289 // TODO(xians): Implement a WebRtcAudioFIFO to handle the local loopback.
290 return NULL;
291 }
292
293 NOTREACHED();
294 return NULL;
295 }
296
265 // Callback from MediaStreamDispatcher. 297 // Callback from MediaStreamDispatcher.
266 // The requested stream have been generated. 298 // The requested stream have been generated.
267 void MediaStreamImpl::OnStreamGenerated( 299 void MediaStreamImpl::OnStreamGenerated(
268 int request_id, 300 int request_id,
269 const std::string& label, 301 const std::string& label,
270 const media_stream::StreamDeviceInfoArray& audio_array, 302 const media_stream::StreamDeviceInfoArray& audio_array,
271 const media_stream::StreamDeviceInfoArray& video_array) { 303 const media_stream::StreamDeviceInfoArray& video_array) {
272 DCHECK(CalledOnValidThread()); 304 DCHECK(CalledOnValidThread());
273 305
274 WebKit::WebVector<WebKit::WebMediaStreamSource> audio_source_vector( 306 WebKit::WebVector<WebKit::WebMediaStreamSource> audio_source_vector(
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 497
466 DVLOG(1) << "MediaStreamImpl::CreateRemoteVideoDecoder label:" 498 DVLOG(1) << "MediaStreamImpl::CreateRemoteVideoDecoder label:"
467 << stream->label(); 499 << stream->label();
468 500
469 return new RTCVideoDecoder( 501 return new RTCVideoDecoder(
470 message_loop_factory->GetMessageLoop(media::MessageLoopFactory::kDecoder), 502 message_loop_factory->GetMessageLoop(media::MessageLoopFactory::kDecoder),
471 base::MessageLoopProxy::current(), 503 base::MessageLoopProxy::current(),
472 stream->video_tracks()->at(0)); 504 stream->video_tracks()->at(0));
473 } 505 }
474 506
507 scoped_refptr<content::WebRtcAudioRenderer>
wjia(left Chromium) 2012/10/24 22:05:15 nit: no need content::
no longer working on chromium 2012/10/25 10:19:41 Done.
508 MediaStreamImpl::CreateRemoteAudioRenderer(
509 webrtc::MediaStreamInterface* stream) {
510 if (!stream->audio_tracks() || stream->audio_tracks()->count() == 0)
511 return NULL;
512
513 DVLOG(1) << "MediaStreamImpl::CreateRemoteAudioRenderer label:"
514 << stream->label();
515
516 return new content::WebRtcAudioRenderer();
wjia(left Chromium) 2012/10/24 22:05:15 ditto.
no longer working on chromium 2012/10/25 10:19:41 Done.
517 }
518
475 MediaStreamExtraData::MediaStreamExtraData( 519 MediaStreamExtraData::MediaStreamExtraData(
476 webrtc::MediaStreamInterface* remote_stream) 520 webrtc::MediaStreamInterface* remote_stream)
477 : remote_stream_(remote_stream) { 521 : remote_stream_(remote_stream) {
478 } 522 }
479 523
480 MediaStreamExtraData::MediaStreamExtraData( 524 MediaStreamExtraData::MediaStreamExtraData(
481 webrtc::LocalMediaStreamInterface* local_stream) 525 webrtc::LocalMediaStreamInterface* local_stream)
482 : local_stream_(local_stream) { 526 : local_stream_(local_stream) {
483 } 527 }
484 528
485 MediaStreamExtraData::~MediaStreamExtraData() { 529 MediaStreamExtraData::~MediaStreamExtraData() {
486 } 530 }
487 531
488 void MediaStreamExtraData::SetLocalStreamStopCallback( 532 void MediaStreamExtraData::SetLocalStreamStopCallback(
489 const StreamStopCallback& stop_callback) { 533 const StreamStopCallback& stop_callback) {
490 stream_stop_callback_ = stop_callback; 534 stream_stop_callback_ = stop_callback;
491 } 535 }
492 536
493 void MediaStreamExtraData::OnLocalStreamStop() { 537 void MediaStreamExtraData::OnLocalStreamStop() {
494 if (!stream_stop_callback_.is_null()) 538 if (!stream_stop_callback_.is_null())
495 stream_stop_callback_.Run(local_stream_->label()); 539 stream_stop_callback_.Run(local_stream_->label());
496 } 540 }
497 541
498 } // namespace content 542 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698