| 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 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 DVLOG(1) << "MediaStreamImpl::GetVideoFrameProvider stream:" | 237 DVLOG(1) << "MediaStreamImpl::GetVideoFrameProvider stream:" |
| 239 << UTF16ToUTF8(descriptor.label()); | 238 << UTF16ToUTF8(descriptor.label()); |
| 240 | 239 |
| 241 webrtc::MediaStreamInterface* stream = GetNativeMediaStream(descriptor); | 240 webrtc::MediaStreamInterface* stream = GetNativeMediaStream(descriptor); |
| 242 if (stream) | 241 if (stream) |
| 243 return CreateVideoFrameProvider(stream, error_cb, repaint_cb); | 242 return CreateVideoFrameProvider(stream, error_cb, repaint_cb); |
| 244 NOTREACHED(); | 243 NOTREACHED(); |
| 245 return NULL; | 244 return NULL; |
| 246 } | 245 } |
| 247 | 246 |
| 248 scoped_refptr<media::VideoDecoder> MediaStreamImpl::GetVideoDecoder( | |
| 249 const GURL& url, | |
| 250 const scoped_refptr<base::MessageLoopProxy>& message_loop) { | |
| 251 DCHECK(CalledOnValidThread()); | |
| 252 WebKit::WebMediaStream descriptor(GetMediaStream(url)); | |
| 253 | |
| 254 if (descriptor.isNull() || !descriptor.extraData()) | |
| 255 return NULL; // This is not a valid stream. | |
| 256 | |
| 257 DVLOG(1) << "MediaStreamImpl::GetVideoDecoder stream:" | |
| 258 << UTF16ToUTF8(descriptor.label()); | |
| 259 | |
| 260 webrtc::MediaStreamInterface* stream = GetNativeMediaStream(descriptor); | |
| 261 if (stream) | |
| 262 return CreateVideoDecoder(stream, message_loop); | |
| 263 NOTREACHED(); | |
| 264 return NULL; | |
| 265 } | |
| 266 | |
| 267 scoped_refptr<webkit_media::MediaStreamAudioRenderer> | 247 scoped_refptr<webkit_media::MediaStreamAudioRenderer> |
| 268 MediaStreamImpl::GetAudioRenderer(const GURL& url) { | 248 MediaStreamImpl::GetAudioRenderer(const GURL& url) { |
| 269 DCHECK(CalledOnValidThread()); | 249 DCHECK(CalledOnValidThread()); |
| 270 WebKit::WebMediaStream descriptor(GetMediaStream(url)); | 250 WebKit::WebMediaStream descriptor(GetMediaStream(url)); |
| 271 | 251 |
| 272 if (descriptor.isNull() || !descriptor.extraData()) | 252 if (descriptor.isNull() || !descriptor.extraData()) |
| 273 return NULL; // This is not a valid stream. | 253 return NULL; // This is not a valid stream. |
| 274 | 254 |
| 275 DVLOG(1) << "MediaStreamImpl::GetAudioRenderer stream:" | 255 DVLOG(1) << "MediaStreamImpl::GetAudioRenderer stream:" |
| 276 << UTF16ToUTF8(descriptor.label()); | 256 << UTF16ToUTF8(descriptor.label()); |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 527 | 507 |
| 528 DVLOG(1) << "MediaStreamImpl::CreateRemoteVideoFrameProvider label:" | 508 DVLOG(1) << "MediaStreamImpl::CreateRemoteVideoFrameProvider label:" |
| 529 << stream->label(); | 509 << stream->label(); |
| 530 | 510 |
| 531 return new RTCVideoRenderer( | 511 return new RTCVideoRenderer( |
| 532 stream->GetVideoTracks()[0], | 512 stream->GetVideoTracks()[0], |
| 533 error_cb, | 513 error_cb, |
| 534 repaint_cb); | 514 repaint_cb); |
| 535 } | 515 } |
| 536 | 516 |
| 537 scoped_refptr<media::VideoDecoder> MediaStreamImpl::CreateVideoDecoder( | |
| 538 webrtc::MediaStreamInterface* stream, | |
| 539 const scoped_refptr<base::MessageLoopProxy>& message_loop) { | |
| 540 if (stream->GetVideoTracks().empty()) | |
| 541 return NULL; | |
| 542 | |
| 543 | |
| 544 DVLOG(1) << "MediaStreamImpl::CreateRemoteVideoDecoder label:" | |
| 545 << stream->label(); | |
| 546 | |
| 547 return new RTCVideoDecoder( | |
| 548 message_loop, | |
| 549 base::MessageLoopProxy::current(), | |
| 550 stream->GetVideoTracks()[0].get()); | |
| 551 } | |
| 552 | |
| 553 scoped_refptr<WebRtcAudioRenderer> MediaStreamImpl::CreateRemoteAudioRenderer( | 517 scoped_refptr<WebRtcAudioRenderer> MediaStreamImpl::CreateRemoteAudioRenderer( |
| 554 webrtc::MediaStreamInterface* stream) { | 518 webrtc::MediaStreamInterface* stream) { |
| 555 if (stream->GetAudioTracks().empty()) | 519 if (stream->GetAudioTracks().empty()) |
| 556 return NULL; | 520 return NULL; |
| 557 | 521 |
| 558 DVLOG(1) << "MediaStreamImpl::CreateRemoteAudioRenderer label:" | 522 DVLOG(1) << "MediaStreamImpl::CreateRemoteAudioRenderer label:" |
| 559 << stream->label(); | 523 << stream->label(); |
| 560 | 524 |
| 561 return new WebRtcAudioRenderer(RenderViewObserver::routing_id()); | 525 return new WebRtcAudioRenderer(RenderViewObserver::routing_id()); |
| 562 } | 526 } |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 606 const StreamStopCallback& stop_callback) { | 570 const StreamStopCallback& stop_callback) { |
| 607 stream_stop_callback_ = stop_callback; | 571 stream_stop_callback_ = stop_callback; |
| 608 } | 572 } |
| 609 | 573 |
| 610 void MediaStreamExtraData::OnLocalStreamStop() { | 574 void MediaStreamExtraData::OnLocalStreamStop() { |
| 611 if (!stream_stop_callback_.is_null()) | 575 if (!stream_stop_callback_.is_null()) |
| 612 stream_stop_callback_.Run(stream_->label()); | 576 stream_stop_callback_.Run(stream_->label()); |
| 613 } | 577 } |
| 614 | 578 |
| 615 } // namespace content | 579 } // namespace content |
| OLD | NEW |