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 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
758 while (source_it != local_sources_.end()) { | 759 while (source_it != local_sources_.end()) { |
759 if (!FindSourceInRequests(source_it->source)) { | 760 if (!FindSourceInRequests(source_it->source)) { |
760 StopLocalSource(source_it->source, notify_dispatcher); | 761 StopLocalSource(source_it->source, notify_dispatcher); |
761 source_it = local_sources_.erase(source_it); | 762 source_it = local_sources_.erase(source_it); |
762 } else { | 763 } else { |
763 ++source_it; | 764 ++source_it; |
764 } | 765 } |
765 } | 766 } |
766 } | 767 } |
767 | 768 |
768 scoped_refptr<VideoFrameProvider> | |
769 MediaStreamImpl::CreateVideoFrameProvider( | |
770 webrtc::MediaStreamInterface* stream, | |
771 const base::Closure& error_cb, | |
772 const VideoFrameProvider::RepaintCB& repaint_cb) { | |
773 if (stream->GetVideoTracks().empty()) | |
774 return NULL; | |
775 | |
776 DVLOG(1) << "MediaStreamImpl::CreateRemoteVideoFrameProvider label:" | |
777 << stream->label(); | |
778 | |
779 return new RTCVideoRenderer( | |
780 stream->GetVideoTracks()[0], | |
781 error_cb, | |
782 repaint_cb); | |
783 } | |
784 | |
785 scoped_refptr<WebRtcAudioRenderer> MediaStreamImpl::CreateRemoteAudioRenderer( | 769 scoped_refptr<WebRtcAudioRenderer> MediaStreamImpl::CreateRemoteAudioRenderer( |
786 webrtc::MediaStreamInterface* stream) { | 770 webrtc::MediaStreamInterface* stream) { |
787 if (stream->GetAudioTracks().empty()) | 771 if (stream->GetAudioTracks().empty()) |
788 return NULL; | 772 return NULL; |
789 | 773 |
790 DVLOG(1) << "MediaStreamImpl::CreateRemoteAudioRenderer label:" | 774 DVLOG(1) << "MediaStreamImpl::CreateRemoteAudioRenderer label:" |
791 << stream->label(); | 775 << stream->label(); |
792 | 776 |
793 // TODO(tommi): Change the default value of session_id to be | 777 // TODO(tommi): Change the default value of session_id to be |
794 // StreamDeviceInfo::kNoId. Also update AudioOutputDevice etc. | 778 // StreamDeviceInfo::kNoId. Also update AudioOutputDevice etc. |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
901 enable_automatic_output_device_selection( | 885 enable_automatic_output_device_selection( |
902 enable_automatic_output_device_selection), | 886 enable_automatic_output_device_selection), |
903 frame(frame), | 887 frame(frame), |
904 request(request) { | 888 request(request) { |
905 } | 889 } |
906 | 890 |
907 MediaStreamImpl::UserMediaRequestInfo::~UserMediaRequestInfo() { | 891 MediaStreamImpl::UserMediaRequestInfo::~UserMediaRequestInfo() { |
908 } | 892 } |
909 | 893 |
910 } // namespace content | 894 } // namespace content |
OLD | NEW |