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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 user_media_requests_.erase(it); | 139 user_media_requests_.erase(it); |
140 } | 140 } |
141 } | 141 } |
142 | 142 |
143 WebKit::WebMediaStreamDescriptor MediaStreamImpl::GetMediaStream( | 143 WebKit::WebMediaStreamDescriptor MediaStreamImpl::GetMediaStream( |
144 const GURL& url) { | 144 const GURL& url) { |
145 return WebKit::WebMediaStreamRegistry::lookupMediaStreamDescriptor(url); | 145 return WebKit::WebMediaStreamRegistry::lookupMediaStreamDescriptor(url); |
146 } | 146 } |
147 | 147 |
148 bool MediaStreamImpl::IsMediaStream(const GURL& url) { | 148 bool MediaStreamImpl::IsMediaStream(const GURL& url) { |
149 DCHECK(CalledOnValidThread()); | 149 return CheckMediaStream(url); |
150 WebKit::WebMediaStreamDescriptor descriptor(GetMediaStream(url)); | 150 } |
| 151 |
| 152 // static |
| 153 bool MediaStreamImpl::CheckMediaStream(const GURL& url) { |
| 154 WebKit::WebMediaStreamDescriptor descriptor( |
| 155 WebKit::WebMediaStreamRegistry::lookupMediaStreamDescriptor(url)); |
151 | 156 |
152 if (descriptor.isNull() || !descriptor.extraData()) | 157 if (descriptor.isNull() || !descriptor.extraData()) |
153 return false; // This is not a valid stream. | 158 return false; // This is not a valid stream. |
154 | 159 |
155 MediaStreamExtraData* extra_data = | 160 MediaStreamExtraData* extra_data = |
156 static_cast<MediaStreamExtraData*>(descriptor.extraData()); | 161 static_cast<MediaStreamExtraData*>(descriptor.extraData()); |
157 webrtc::MediaStreamInterface* stream = extra_data->local_stream(); | 162 webrtc::MediaStreamInterface* stream = extra_data->local_stream(); |
158 if (stream && stream->video_tracks() && stream->video_tracks()->count() > 0) | 163 if (stream && stream->video_tracks() && stream->video_tracks()->count() > 0) |
159 return true; | 164 return true; |
160 stream = extra_data->remote_stream(); | 165 stream = extra_data->remote_stream(); |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
456 | 461 |
457 void MediaStreamExtraData::SetLocalStreamStopCallback( | 462 void MediaStreamExtraData::SetLocalStreamStopCallback( |
458 const StreamStopCallback& stop_callback) { | 463 const StreamStopCallback& stop_callback) { |
459 stream_stop_callback_ = stop_callback; | 464 stream_stop_callback_ = stop_callback; |
460 } | 465 } |
461 | 466 |
462 void MediaStreamExtraData::OnLocalStreamStop() { | 467 void MediaStreamExtraData::OnLocalStreamStop() { |
463 if (!stream_stop_callback_.is_null()) | 468 if (!stream_stop_callback_.is_null()) |
464 stream_stop_callback_.Run(local_stream_->label()); | 469 stream_stop_callback_.Run(local_stream_->label()); |
465 } | 470 } |
OLD | NEW |