Chromium Code Reviews| 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 62 MediaStreamDependencyFactory* dependency_factory) | 62 MediaStreamDependencyFactory* dependency_factory) |
| 63 : content::RenderViewObserver(render_view), | 63 : content::RenderViewObserver(render_view), |
| 64 dependency_factory_(dependency_factory), | 64 dependency_factory_(dependency_factory), |
| 65 media_stream_dispatcher_(media_stream_dispatcher), | 65 media_stream_dispatcher_(media_stream_dispatcher), |
| 66 vc_manager_(vc_manager) { | 66 vc_manager_(vc_manager) { |
| 67 } | 67 } |
| 68 | 68 |
| 69 MediaStreamImpl::~MediaStreamImpl() { | 69 MediaStreamImpl::~MediaStreamImpl() { |
| 70 } | 70 } |
| 71 | 71 |
| 72 void MediaStreamImpl::StopLocalMediaStream( | 72 void MediaStreamImpl::OnLocalMediaStreamStop(const std::string& label) { |
| 73 const WebKit::WebMediaStreamDescriptor& stream) { | 73 DVLOG(1) << "MediaStreamImpl::OnLocalMediaStreamStop"; |
| 74 DVLOG(1) << "MediaStreamImpl::StopLocalMediaStream"; | 74 media_stream_dispatcher_->StopStream(label); |
| 75 | 75 local_media_streams_.erase(label); |
| 76 MediaStreamExtraData* extra_data = | |
| 77 static_cast<MediaStreamExtraData*>(stream.extraData()); | |
| 78 if (extra_data && extra_data->local_stream()) { | |
| 79 media_stream_dispatcher_->StopStream(extra_data->local_stream()->label()); | |
| 80 local_media_streams_.erase(extra_data->local_stream()->label()); | |
| 81 } else { | |
| 82 NOTREACHED(); | |
| 83 } | |
| 84 } | 76 } |
| 85 | 77 |
| 86 void MediaStreamImpl::requestUserMedia( | 78 void MediaStreamImpl::requestUserMedia( |
| 87 const WebKit::WebUserMediaRequest& user_media_request, | 79 const WebKit::WebUserMediaRequest& user_media_request, |
| 88 const WebKit::WebVector<WebKit::WebMediaStreamSource>& audio_sources, | 80 const WebKit::WebVector<WebKit::WebMediaStreamSource>& audio_sources, |
| 89 const WebKit::WebVector<WebKit::WebMediaStreamSource>& video_sources) { | 81 const WebKit::WebVector<WebKit::WebMediaStreamSource>& video_sources) { |
| 90 // Save histogram data so we can see how much GetUserMedia is used. | 82 // Save histogram data so we can see how much GetUserMedia is used. |
| 91 // The histogram counts the number of calls to the JS API | 83 // The histogram counts the number of calls to the JS API |
| 92 // webGetUserMedia. | 84 // webGetUserMedia. |
| 93 UpdateWebRTCMethodCount(WEBKIT_GET_USER_MEDIA); | 85 UpdateWebRTCMethodCount(WEBKIT_GET_USER_MEDIA); |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 198 DVLOG(1) << "Request ID not found"; | 190 DVLOG(1) << "Request ID not found"; |
| 199 media_stream_dispatcher_->StopStream(label); | 191 media_stream_dispatcher_->StopStream(label); |
| 200 return; | 192 return; |
| 201 } | 193 } |
| 202 | 194 |
| 203 WebKit::WebString webkit_label = UTF8ToUTF16(label); | 195 WebKit::WebString webkit_label = UTF8ToUTF16(label); |
| 204 WebKit::WebMediaStreamDescriptor description; | 196 WebKit::WebMediaStreamDescriptor description; |
| 205 description.initialize(webkit_label, audio_source_vector, | 197 description.initialize(webkit_label, audio_source_vector, |
| 206 video_source_vector); | 198 video_source_vector); |
| 207 | 199 |
| 208 if (!dependency_factory_->CreateNativeLocalMediaStream(&description)) { | 200 if (!dependency_factory_->CreateNativeLocalMediaStream( |
| 201 &description, base::Bind(&MediaStreamImpl::OnLocalMediaStreamStop, | |
|
tommi (sloooow) - chröme
2012/09/21 09:18:03
indent
perkj_chrome
2012/09/21 10:47:10
? What is wrong with this?
tommi (sloooow) - chröme
2012/09/21 11:23:53
MyFunction(
bar, baz);
should in Chrome be
MyFun
| |
| 202 base::Unretained(this)))) { | |
| 209 DVLOG(1) << "Failed to create native stream in OnStreamGenerated."; | 203 DVLOG(1) << "Failed to create native stream in OnStreamGenerated."; |
| 210 media_stream_dispatcher_->StopStream(label); | 204 media_stream_dispatcher_->StopStream(label); |
| 211 it->second.request_.requestFailed(); | 205 it->second.request_.requestFailed(); |
| 212 user_media_requests_.erase(it); | 206 user_media_requests_.erase(it); |
| 213 return; | 207 return; |
| 214 } | 208 } |
| 215 local_media_streams_[label] = it->second.frame_; | 209 local_media_streams_[label] = it->second.frame_; |
| 216 CompleteGetUserMediaRequest(description, &it->second.request_); | 210 CompleteGetUserMediaRequest(description, &it->second.request_); |
| 217 user_media_requests_.erase(it); | 211 user_media_requests_.erase(it); |
| 218 } | 212 } |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 350 return new RTCVideoDecoder( | 344 return new RTCVideoDecoder( |
| 351 message_loop_factory->GetMessageLoop(media::MessageLoopFactory::kDecoder), | 345 message_loop_factory->GetMessageLoop(media::MessageLoopFactory::kDecoder), |
| 352 base::MessageLoopProxy::current(), | 346 base::MessageLoopProxy::current(), |
| 353 stream->video_tracks()->at(0)); | 347 stream->video_tracks()->at(0)); |
| 354 } | 348 } |
| 355 | 349 |
| 356 MediaStreamExtraData::MediaStreamExtraData( | 350 MediaStreamExtraData::MediaStreamExtraData( |
| 357 webrtc::MediaStreamInterface* remote_stream) | 351 webrtc::MediaStreamInterface* remote_stream) |
| 358 : remote_stream_(remote_stream) { | 352 : remote_stream_(remote_stream) { |
| 359 } | 353 } |
| 354 | |
| 360 MediaStreamExtraData::MediaStreamExtraData( | 355 MediaStreamExtraData::MediaStreamExtraData( |
| 361 webrtc::LocalMediaStreamInterface* local_stream) | 356 webrtc::LocalMediaStreamInterface* local_stream) |
| 362 : local_stream_(local_stream) { | 357 : local_stream_(local_stream) { |
| 363 } | 358 } |
| 359 | |
| 360 void MediaStreamExtraData::SetLocalStreamStopCallback( | |
| 361 const StreamStopCallback& stop_callback) { | |
| 362 stream_stop_callback_ = stop_callback; | |
| 363 } | |
| 364 | |
| 364 MediaStreamExtraData::~MediaStreamExtraData() { | 365 MediaStreamExtraData::~MediaStreamExtraData() { |
| 365 } | 366 } |
| 367 | |
| 368 void MediaStreamExtraData::RunStreamStopCallback() { | |
| 369 if (!stream_stop_callback_.is_null()) { | |
| 370 stream_stop_callback_.Run(local_stream_->label()); | |
| 371 } | |
| 372 } | |
| OLD | NEW |