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" |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
218 WebKit::WebMediaStreamRegistry::lookupMediaStreamDescriptor(url)); | 218 WebKit::WebMediaStreamRegistry::lookupMediaStreamDescriptor(url)); |
219 | 219 |
220 if (descriptor.isNull() || !descriptor.extraData()) | 220 if (descriptor.isNull() || !descriptor.extraData()) |
221 return false; // This is not a valid stream. | 221 return false; // This is not a valid stream. |
222 | 222 |
223 webrtc::MediaStreamInterface* stream = GetNativeMediaStream(descriptor); | 223 webrtc::MediaStreamInterface* stream = GetNativeMediaStream(descriptor); |
224 return (stream && | 224 return (stream && |
225 (!stream->GetVideoTracks().empty() || !stream->GetAudioTracks().empty())); | 225 (!stream->GetVideoTracks().empty() || !stream->GetAudioTracks().empty())); |
226 } | 226 } |
227 | 227 |
228 // static | |
229 void MediaStreamImpl::ReleaseSourceObservers( | |
perkj_chrome
2013/04/18 13:36:20
Why does this method has to be static?
You only c
tommi (sloooow) - chröme
2013/04/23 09:50:55
...and file a bug as well?
| |
230 WebKit::WebMediaStream descriptor) { | |
231 if (descriptor.isNull()) | |
232 return; | |
233 | |
234 WebKit::WebVector<WebKit::WebMediaStreamTrack> audio_tracks; | |
235 descriptor.audioSources(audio_tracks); | |
perkj_chrome
2013/04/18 13:36:20
use audioTracks
| |
236 for (size_t i = 0; i < audio_tracks.size(); ++i) { | |
237 const WebKit::WebMediaStreamSource& source = audio_tracks[i].source(); | |
perkj_chrome
2013/04/18 13:36:20
Thinking about this- You can do
source.setExtraDa
tommi (sloooow) - chröme
2013/04/23 09:50:55
If you create a new source object from another con
| |
238 content::MediaStreamSourceExtraData* source_data = | |
239 static_cast<content::MediaStreamSourceExtraData*>(source.extraData()); | |
240 if (source_data) { | |
241 source_data->SetSourceObserver(NULL); | |
242 } | |
243 } | |
244 | |
245 WebKit::WebVector<WebKit::WebMediaStreamTrack> video_tracks; | |
246 descriptor.videoSources(video_tracks); | |
perkj_chrome
2013/04/18 13:36:20
use videoTracks
| |
247 for (size_t i = 0; i < video_tracks.size(); ++i) { | |
248 const WebKit::WebMediaStreamSource& source = video_tracks[i].source(); | |
249 content::MediaStreamSourceExtraData* source_data = | |
250 static_cast<content::MediaStreamSourceExtraData*>(source.extraData()); | |
251 if (source_data) { | |
252 source_data->SetSourceObserver(NULL); | |
253 } | |
254 } | |
255 } | |
256 | |
228 scoped_refptr<webkit_media::VideoFrameProvider> | 257 scoped_refptr<webkit_media::VideoFrameProvider> |
229 MediaStreamImpl::GetVideoFrameProvider( | 258 MediaStreamImpl::GetVideoFrameProvider( |
230 const GURL& url, | 259 const GURL& url, |
231 const base::Closure& error_cb, | 260 const base::Closure& error_cb, |
232 const webkit_media::VideoFrameProvider::RepaintCB& repaint_cb) { | 261 const webkit_media::VideoFrameProvider::RepaintCB& repaint_cb) { |
233 DCHECK(CalledOnValidThread()); | 262 DCHECK(CalledOnValidThread()); |
234 WebKit::WebMediaStream descriptor(GetMediaStream(url)); | 263 WebKit::WebMediaStream descriptor(GetMediaStream(url)); |
235 | 264 |
236 if (descriptor.isNull() || !descriptor.extraData()) | 265 if (descriptor.isNull() || !descriptor.extraData()) |
237 return NULL; // This is not a valid stream. | 266 return NULL; // This is not a valid stream. |
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
586 void MediaStreamExtraData::SetLocalStreamStopCallback( | 615 void MediaStreamExtraData::SetLocalStreamStopCallback( |
587 const StreamStopCallback& stop_callback) { | 616 const StreamStopCallback& stop_callback) { |
588 stream_stop_callback_ = stop_callback; | 617 stream_stop_callback_ = stop_callback; |
589 } | 618 } |
590 | 619 |
591 void MediaStreamExtraData::OnLocalStreamStop() { | 620 void MediaStreamExtraData::OnLocalStreamStop() { |
592 if (!stream_stop_callback_.is_null()) | 621 if (!stream_stop_callback_.is_null()) |
593 stream_stop_callback_.Run(stream_->label()); | 622 stream_stop_callback_.Run(stream_->label()); |
594 } | 623 } |
595 | 624 |
625 MediaStreamImpl::UserMediaRequestInfo::~UserMediaRequestInfo() { | |
626 ReleaseSourceObservers(descriptor); | |
perkj_chrome
2013/04/18 13:36:20
Did I miss something or can you move the ReleaseSo
| |
627 } | |
628 | |
596 } // namespace content | 629 } // namespace content |
OLD | NEW |