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

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

Issue 10947030: Removed the use of WebFrame::frameForCurrentContext() in MediaStreamCenter::didStopLocalMediaStream (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Addresses code review comments. Created 8 years, 3 months 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
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/string_number_conversions.h" 10 #include "base/string_number_conversions.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(
73 const WebKit::WebMediaStreamDescriptor& stream) { 73 const WebKit::WebMediaStreamDescriptor& stream) {
74 DVLOG(1) << "MediaStreamImpl::StopLocalMediaStream"; 74 DVLOG(1) << "MediaStreamImpl::OnLocalMediaStreamStop";
75 75 std::string label = UTF16ToUTF8(stream.label());
76 MediaStreamExtraData* extra_data = 76 media_stream_dispatcher_->StopStream(label);
77 static_cast<MediaStreamExtraData*>(stream.extraData()); 77 local_media_streams_.erase(label);
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 } 78 }
85 79
86 void MediaStreamImpl::requestUserMedia( 80 void MediaStreamImpl::requestUserMedia(
87 const WebKit::WebUserMediaRequest& user_media_request, 81 const WebKit::WebUserMediaRequest& user_media_request,
88 const WebKit::WebVector<WebKit::WebMediaStreamSource>& audio_sources, 82 const WebKit::WebVector<WebKit::WebMediaStreamSource>& audio_sources,
89 const WebKit::WebVector<WebKit::WebMediaStreamSource>& video_sources) { 83 const WebKit::WebVector<WebKit::WebMediaStreamSource>& video_sources) {
90 // Save histogram data so we can see how much GetUserMedia is used. 84 // Save histogram data so we can see how much GetUserMedia is used.
91 // The histogram counts the number of calls to the JS API 85 // The histogram counts the number of calls to the JS API
92 // webGetUserMedia. 86 // webGetUserMedia.
93 UpdateWebRTCMethodCount(WEBKIT_GET_USER_MEDIA); 87 UpdateWebRTCMethodCount(WEBKIT_GET_USER_MEDIA);
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 DVLOG(1) << "Request ID not found"; 192 DVLOG(1) << "Request ID not found";
199 media_stream_dispatcher_->StopStream(label); 193 media_stream_dispatcher_->StopStream(label);
200 return; 194 return;
201 } 195 }
202 196
203 WebKit::WebString webkit_label = UTF8ToUTF16(label); 197 WebKit::WebString webkit_label = UTF8ToUTF16(label);
204 WebKit::WebMediaStreamDescriptor description; 198 WebKit::WebMediaStreamDescriptor description;
205 description.initialize(webkit_label, audio_source_vector, 199 description.initialize(webkit_label, audio_source_vector,
206 video_source_vector); 200 video_source_vector);
207 201
208 if (!dependency_factory_->CreateNativeLocalMediaStream(&description)) { 202 if (!dependency_factory_->CreateNativeLocalMediaStream(
203 &description, base::Bind(&MediaStreamImpl::OnLocalMediaStreamStop,
204 base::Unretained(this)))) {
209 DVLOG(1) << "Failed to create native stream in OnStreamGenerated."; 205 DVLOG(1) << "Failed to create native stream in OnStreamGenerated.";
210 media_stream_dispatcher_->StopStream(label); 206 media_stream_dispatcher_->StopStream(label);
211 it->second.request_.requestFailed(); 207 it->second.request_.requestFailed();
212 user_media_requests_.erase(it); 208 user_media_requests_.erase(it);
213 return; 209 return;
214 } 210 }
215 local_media_streams_[label] = it->second.frame_; 211 local_media_streams_[label] = it->second.frame_;
216 CompleteGetUserMediaRequest(description, &it->second.request_); 212 CompleteGetUserMediaRequest(description, &it->second.request_);
217 user_media_requests_.erase(it); 213 user_media_requests_.erase(it);
218 } 214 }
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 return new RTCVideoDecoder( 346 return new RTCVideoDecoder(
351 message_loop_factory->GetMessageLoop(media::MessageLoopFactory::kDecoder), 347 message_loop_factory->GetMessageLoop(media::MessageLoopFactory::kDecoder),
352 base::MessageLoopProxy::current(), 348 base::MessageLoopProxy::current(),
353 stream->video_tracks()->at(0)); 349 stream->video_tracks()->at(0));
354 } 350 }
355 351
356 MediaStreamExtraData::MediaStreamExtraData( 352 MediaStreamExtraData::MediaStreamExtraData(
357 webrtc::MediaStreamInterface* remote_stream) 353 webrtc::MediaStreamInterface* remote_stream)
358 : remote_stream_(remote_stream) { 354 : remote_stream_(remote_stream) {
359 } 355 }
356
360 MediaStreamExtraData::MediaStreamExtraData( 357 MediaStreamExtraData::MediaStreamExtraData(
361 webrtc::LocalMediaStreamInterface* local_stream) 358 webrtc::LocalMediaStreamInterface* local_stream)
362 : local_stream_(local_stream) { 359 : local_stream_(local_stream) {
363 } 360 }
361
362 void MediaStreamExtraData::SetLocalStreamStopCallback(
363 const StreamStopCallback& stop_callback) {
364 stream_stop_callback_ = stop_callback;
365 }
366
364 MediaStreamExtraData::~MediaStreamExtraData() { 367 MediaStreamExtraData::~MediaStreamExtraData() {
365 } 368 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698