| OLD | NEW |
| 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/media_stream_dependency_factory.h" | 13 #include "content/renderer/media/media_stream_dependency_factory.h" |
| 14 #include "content/renderer/media/media_stream_dispatcher.h" | 14 #include "content/renderer/media/media_stream_dispatcher.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/rtc_video_decoder.h" | |
| 18 #include "content/renderer/media/rtc_video_renderer.h" | 17 #include "content/renderer/media/rtc_video_renderer.h" |
| 19 #include "content/renderer/media/video_capture_impl_manager.h" | 18 #include "content/renderer/media/video_capture_impl_manager.h" |
| 20 #include "content/renderer/media/webrtc_audio_capturer.h" | 19 #include "content/renderer/media/webrtc_audio_capturer.h" |
| 21 #include "content/renderer/media/webrtc_audio_renderer.h" | 20 #include "content/renderer/media/webrtc_audio_renderer.h" |
| 22 #include "content/renderer/media/webrtc_local_audio_renderer.h" | 21 #include "content/renderer/media/webrtc_local_audio_renderer.h" |
| 23 #include "content/renderer/media/webrtc_uma_histograms.h" | 22 #include "content/renderer/media/webrtc_uma_histograms.h" |
| 24 #include "third_party/WebKit/Source/Platform/chromium/public/WebMediaConstraints
.h" | 23 #include "third_party/WebKit/Source/Platform/chromium/public/WebMediaConstraints
.h" |
| 25 #include "third_party/WebKit/Source/Platform/chromium/public/WebMediaStreamSourc
e.h" | 24 #include "third_party/WebKit/Source/Platform/chromium/public/WebMediaStreamSourc
e.h" |
| 26 #include "third_party/WebKit/Source/Platform/chromium/public/WebMediaStreamTrack
.h" | 25 #include "third_party/WebKit/Source/Platform/chromium/public/WebMediaStreamTrack
.h" |
| 27 #include "third_party/WebKit/Source/Platform/chromium/public/WebVector.h" | 26 #include "third_party/WebKit/Source/Platform/chromium/public/WebVector.h" |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 DVLOG(1) << "MediaStreamImpl::GetVideoFrameProvider stream:" | 240 DVLOG(1) << "MediaStreamImpl::GetVideoFrameProvider stream:" |
| 242 << UTF16ToUTF8(descriptor.label()); | 241 << UTF16ToUTF8(descriptor.label()); |
| 243 | 242 |
| 244 webrtc::MediaStreamInterface* stream = GetNativeMediaStream(descriptor); | 243 webrtc::MediaStreamInterface* stream = GetNativeMediaStream(descriptor); |
| 245 if (stream) | 244 if (stream) |
| 246 return CreateVideoFrameProvider(stream, error_cb, repaint_cb); | 245 return CreateVideoFrameProvider(stream, error_cb, repaint_cb); |
| 247 NOTREACHED(); | 246 NOTREACHED(); |
| 248 return NULL; | 247 return NULL; |
| 249 } | 248 } |
| 250 | 249 |
| 251 scoped_refptr<media::VideoDecoder> MediaStreamImpl::GetVideoDecoder( | |
| 252 const GURL& url, | |
| 253 const scoped_refptr<base::MessageLoopProxy>& message_loop) { | |
| 254 DCHECK(CalledOnValidThread()); | |
| 255 WebKit::WebMediaStream descriptor(GetMediaStream(url)); | |
| 256 | |
| 257 if (descriptor.isNull() || !descriptor.extraData()) | |
| 258 return NULL; // This is not a valid stream. | |
| 259 | |
| 260 DVLOG(1) << "MediaStreamImpl::GetVideoDecoder stream:" | |
| 261 << UTF16ToUTF8(descriptor.label()); | |
| 262 | |
| 263 webrtc::MediaStreamInterface* stream = GetNativeMediaStream(descriptor); | |
| 264 if (stream) | |
| 265 return CreateVideoDecoder(stream, message_loop); | |
| 266 NOTREACHED(); | |
| 267 return NULL; | |
| 268 } | |
| 269 | |
| 270 scoped_refptr<webkit_media::MediaStreamAudioRenderer> | 250 scoped_refptr<webkit_media::MediaStreamAudioRenderer> |
| 271 MediaStreamImpl::GetAudioRenderer(const GURL& url) { | 251 MediaStreamImpl::GetAudioRenderer(const GURL& url) { |
| 272 DCHECK(CalledOnValidThread()); | 252 DCHECK(CalledOnValidThread()); |
| 273 WebKit::WebMediaStream descriptor(GetMediaStream(url)); | 253 WebKit::WebMediaStream descriptor(GetMediaStream(url)); |
| 274 | 254 |
| 275 if (descriptor.isNull() || !descriptor.extraData()) | 255 if (descriptor.isNull() || !descriptor.extraData()) |
| 276 return NULL; // This is not a valid stream. | 256 return NULL; // This is not a valid stream. |
| 277 | 257 |
| 278 DVLOG(1) << "MediaStreamImpl::GetAudioRenderer stream:" | 258 DVLOG(1) << "MediaStreamImpl::GetAudioRenderer stream:" |
| 279 << UTF16ToUTF8(descriptor.label()); | 259 << UTF16ToUTF8(descriptor.label()); |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 530 | 510 |
| 531 DVLOG(1) << "MediaStreamImpl::CreateRemoteVideoFrameProvider label:" | 511 DVLOG(1) << "MediaStreamImpl::CreateRemoteVideoFrameProvider label:" |
| 532 << stream->label(); | 512 << stream->label(); |
| 533 | 513 |
| 534 return new RTCVideoRenderer( | 514 return new RTCVideoRenderer( |
| 535 stream->GetVideoTracks()[0], | 515 stream->GetVideoTracks()[0], |
| 536 error_cb, | 516 error_cb, |
| 537 repaint_cb); | 517 repaint_cb); |
| 538 } | 518 } |
| 539 | 519 |
| 540 scoped_refptr<media::VideoDecoder> MediaStreamImpl::CreateVideoDecoder( | |
| 541 webrtc::MediaStreamInterface* stream, | |
| 542 const scoped_refptr<base::MessageLoopProxy>& message_loop) { | |
| 543 if (stream->GetVideoTracks().empty()) | |
| 544 return NULL; | |
| 545 | |
| 546 | |
| 547 DVLOG(1) << "MediaStreamImpl::CreateRemoteVideoDecoder label:" | |
| 548 << stream->label(); | |
| 549 | |
| 550 return new RTCVideoDecoder( | |
| 551 message_loop, | |
| 552 base::MessageLoopProxy::current(), | |
| 553 stream->GetVideoTracks()[0].get()); | |
| 554 } | |
| 555 | |
| 556 scoped_refptr<WebRtcAudioRenderer> MediaStreamImpl::CreateRemoteAudioRenderer( | 520 scoped_refptr<WebRtcAudioRenderer> MediaStreamImpl::CreateRemoteAudioRenderer( |
| 557 webrtc::MediaStreamInterface* stream) { | 521 webrtc::MediaStreamInterface* stream) { |
| 558 if (stream->GetAudioTracks().empty()) | 522 if (stream->GetAudioTracks().empty()) |
| 559 return NULL; | 523 return NULL; |
| 560 | 524 |
| 561 DVLOG(1) << "MediaStreamImpl::CreateRemoteAudioRenderer label:" | 525 DVLOG(1) << "MediaStreamImpl::CreateRemoteAudioRenderer label:" |
| 562 << stream->label(); | 526 << stream->label(); |
| 563 | 527 |
| 564 return new WebRtcAudioRenderer(RenderViewObserver::routing_id()); | 528 return new WebRtcAudioRenderer(RenderViewObserver::routing_id()); |
| 565 } | 529 } |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 609 const StreamStopCallback& stop_callback) { | 573 const StreamStopCallback& stop_callback) { |
| 610 stream_stop_callback_ = stop_callback; | 574 stream_stop_callback_ = stop_callback; |
| 611 } | 575 } |
| 612 | 576 |
| 613 void MediaStreamExtraData::OnLocalStreamStop() { | 577 void MediaStreamExtraData::OnLocalStreamStop() { |
| 614 if (!stream_stop_callback_.is_null()) | 578 if (!stream_stop_callback_.is_null()) |
| 615 stream_stop_callback_.Run(stream_->label()); | 579 stream_stop_callback_.Run(stream_->label()); |
| 616 } | 580 } |
| 617 | 581 |
| 618 } // namespace content | 582 } // namespace content |
| OLD | NEW |