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