Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(597)

Side by Side Diff: content/renderer/media/media_stream_impl.cc

Issue 83023005: Add VideoTrackSink interface to content/public (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
719 while (source_it != local_sources_.end()) { 720 while (source_it != local_sources_.end()) {
720 if (!FindSourceInRequests(source_it->source)) { 721 if (!FindSourceInRequests(source_it->source)) {
721 StopLocalSource(source_it->source, notify_dispatcher); 722 StopLocalSource(source_it->source, notify_dispatcher);
722 source_it = local_sources_.erase(source_it); 723 source_it = local_sources_.erase(source_it);
723 } else { 724 } else {
724 ++source_it; 725 ++source_it;
725 } 726 }
726 } 727 }
727 } 728 }
728 729
729 scoped_refptr<VideoFrameProvider>
730 MediaStreamImpl::CreateVideoFrameProvider(
731 webrtc::MediaStreamInterface* stream,
732 const base::Closure& error_cb,
733 const VideoFrameProvider::RepaintCB& repaint_cb) {
734 if (stream->GetVideoTracks().empty())
735 return NULL;
736
737 DVLOG(1) << "MediaStreamImpl::CreateRemoteVideoFrameProvider label:"
738 << stream->label();
739
740 return new RTCVideoRenderer(
741 stream->GetVideoTracks()[0],
742 error_cb,
743 repaint_cb);
744 }
745
746 scoped_refptr<WebRtcAudioRenderer> MediaStreamImpl::CreateRemoteAudioRenderer( 730 scoped_refptr<WebRtcAudioRenderer> MediaStreamImpl::CreateRemoteAudioRenderer(
747 webrtc::MediaStreamInterface* stream) { 731 webrtc::MediaStreamInterface* stream) {
748 if (stream->GetAudioTracks().empty()) 732 if (stream->GetAudioTracks().empty())
749 return NULL; 733 return NULL;
750 734
751 DVLOG(1) << "MediaStreamImpl::CreateRemoteAudioRenderer label:" 735 DVLOG(1) << "MediaStreamImpl::CreateRemoteAudioRenderer label:"
752 << stream->label(); 736 << stream->label();
753 737
754 // TODO(tommi): Change the default value of session_id to be 738 // TODO(tommi): Change the default value of session_id to be
755 // StreamDeviceInfo::kNoId. Also update AudioOutputDevice etc. 739 // StreamDeviceInfo::kNoId. Also update AudioOutputDevice etc.
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
863 enable_automatic_output_device_selection( 847 enable_automatic_output_device_selection(
864 enable_automatic_output_device_selection), 848 enable_automatic_output_device_selection),
865 frame(frame), 849 frame(frame),
866 request(request) { 850 request(request) {
867 } 851 }
868 852
869 MediaStreamImpl::UserMediaRequestInfo::~UserMediaRequestInfo() { 853 MediaStreamImpl::UserMediaRequestInfo::~UserMediaRequestInfo() {
870 } 854 }
871 855
872 } // namespace content 856 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698