| 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/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 const VideoFrameProvider::RepaintCB& repaint_cb) { | 235 const VideoFrameProvider::RepaintCB& repaint_cb) { |
| 236 DCHECK(CalledOnValidThread()); | 236 DCHECK(CalledOnValidThread()); |
| 237 blink::WebMediaStream web_stream(GetMediaStream(url)); | 237 blink::WebMediaStream web_stream(GetMediaStream(url)); |
| 238 | 238 |
| 239 if (web_stream.isNull() || !web_stream.extraData()) | 239 if (web_stream.isNull() || !web_stream.extraData()) |
| 240 return NULL; // This is not a valid stream. | 240 return NULL; // This is not a valid stream. |
| 241 | 241 |
| 242 DVLOG(1) << "MediaStreamImpl::GetVideoFrameProvider stream:" | 242 DVLOG(1) << "MediaStreamImpl::GetVideoFrameProvider stream:" |
| 243 << UTF16ToUTF8(web_stream.id()); | 243 << UTF16ToUTF8(web_stream.id()); |
| 244 | 244 |
| 245 webrtc::MediaStreamInterface* stream = GetNativeMediaStream(web_stream); | 245 blink::WebVector<blink::WebMediaStreamTrack> video_tracks; |
| 246 if (stream) | 246 web_stream.videoTracks(video_tracks); |
| 247 return CreateVideoFrameProvider(stream, error_cb, repaint_cb); | 247 if (video_tracks.isEmpty()) |
| 248 NOTREACHED(); | 248 return NULL; |
| 249 return NULL; | 249 |
| 250 return new RTCVideoRenderer(video_tracks[0], error_cb, repaint_cb); |
| 250 } | 251 } |
| 251 | 252 |
| 252 scoped_refptr<MediaStreamAudioRenderer> | 253 scoped_refptr<MediaStreamAudioRenderer> |
| 253 MediaStreamImpl::GetAudioRenderer(const GURL& url) { | 254 MediaStreamImpl::GetAudioRenderer(const GURL& url) { |
| 254 DCHECK(CalledOnValidThread()); | 255 DCHECK(CalledOnValidThread()); |
| 255 blink::WebMediaStream web_stream(GetMediaStream(url)); | 256 blink::WebMediaStream web_stream(GetMediaStream(url)); |
| 256 | 257 |
| 257 if (web_stream.isNull() || !web_stream.extraData()) | 258 if (web_stream.isNull() || !web_stream.extraData()) |
| 258 return NULL; // This is not a valid stream. | 259 return NULL; // This is not a valid stream. |
| 259 | 260 |
| (...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 749 while (source_it != local_sources_.end()) { | 750 while (source_it != local_sources_.end()) { |
| 750 if (!FindSourceInRequests(source_it->source)) { | 751 if (!FindSourceInRequests(source_it->source)) { |
| 751 StopLocalSource(source_it->source, notify_dispatcher); | 752 StopLocalSource(source_it->source, notify_dispatcher); |
| 752 source_it = local_sources_.erase(source_it); | 753 source_it = local_sources_.erase(source_it); |
| 753 } else { | 754 } else { |
| 754 ++source_it; | 755 ++source_it; |
| 755 } | 756 } |
| 756 } | 757 } |
| 757 } | 758 } |
| 758 | 759 |
| 759 scoped_refptr<VideoFrameProvider> | |
| 760 MediaStreamImpl::CreateVideoFrameProvider( | |
| 761 webrtc::MediaStreamInterface* stream, | |
| 762 const base::Closure& error_cb, | |
| 763 const VideoFrameProvider::RepaintCB& repaint_cb) { | |
| 764 if (stream->GetVideoTracks().empty()) | |
| 765 return NULL; | |
| 766 | |
| 767 DVLOG(1) << "MediaStreamImpl::CreateRemoteVideoFrameProvider label:" | |
| 768 << stream->label(); | |
| 769 | |
| 770 return new RTCVideoRenderer( | |
| 771 stream->GetVideoTracks()[0], | |
| 772 error_cb, | |
| 773 repaint_cb); | |
| 774 } | |
| 775 | |
| 776 scoped_refptr<WebRtcAudioRenderer> MediaStreamImpl::CreateRemoteAudioRenderer( | 760 scoped_refptr<WebRtcAudioRenderer> MediaStreamImpl::CreateRemoteAudioRenderer( |
| 777 webrtc::MediaStreamInterface* stream) { | 761 webrtc::MediaStreamInterface* stream) { |
| 778 if (stream->GetAudioTracks().empty()) | 762 if (stream->GetAudioTracks().empty()) |
| 779 return NULL; | 763 return NULL; |
| 780 | 764 |
| 781 DVLOG(1) << "MediaStreamImpl::CreateRemoteAudioRenderer label:" | 765 DVLOG(1) << "MediaStreamImpl::CreateRemoteAudioRenderer label:" |
| 782 << stream->label(); | 766 << stream->label(); |
| 783 | 767 |
| 784 // TODO(tommi): Change the default value of session_id to be | 768 // TODO(tommi): Change the default value of session_id to be |
| 785 // StreamDeviceInfo::kNoId. Also update AudioOutputDevice etc. | 769 // StreamDeviceInfo::kNoId. Also update AudioOutputDevice etc. |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 892 enable_automatic_output_device_selection( | 876 enable_automatic_output_device_selection( |
| 893 enable_automatic_output_device_selection), | 877 enable_automatic_output_device_selection), |
| 894 frame(frame), | 878 frame(frame), |
| 895 request(request) { | 879 request(request) { |
| 896 } | 880 } |
| 897 | 881 |
| 898 MediaStreamImpl::UserMediaRequestInfo::~UserMediaRequestInfo() { | 882 MediaStreamImpl::UserMediaRequestInfo::~UserMediaRequestInfo() { |
| 899 } | 883 } |
| 900 | 884 |
| 901 } // namespace content | 885 } // namespace content |
| OLD | NEW |