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

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

Issue 10534004: Implement CancelUserMediaRequest for the browser part (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 6 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/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/metrics/histogram.h" 11 #include "base/metrics/histogram.h"
12 #include "base/string_number_conversions.h" 12 #include "base/string_number_conversions.h"
13 #include "base/synchronization/waitable_event.h" 13 #include "base/synchronization/waitable_event.h"
14 #include "base/utf_string_conversions.h" 14 #include "base/utf_string_conversions.h"
15 #include "content/renderer/media/capture_video_decoder.h" 15 #include "content/renderer/media/capture_video_decoder.h"
16 #include "content/renderer/media/media_stream_extra_data.h" 16 #include "content/renderer/media/media_stream_extra_data.h"
17 #include "content/renderer/media/media_stream_dependency_factory.h" 17 #include "content/renderer/media/media_stream_dependency_factory.h"
18 #include "content/renderer/media/media_stream_dispatcher.h" 18 #include "content/renderer/media/media_stream_dispatcher.h"
19 #include "content/renderer/media/peer_connection_handler.h" 19 #include "content/renderer/media/peer_connection_handler.h"
20 #include "content/renderer/media/peer_connection_handler_jsep.h" 20 #include "content/renderer/media/peer_connection_handler_jsep.h"
21 #include "content/renderer/media/video_capture_impl_manager.h" 21 #include "content/renderer/media/video_capture_impl_manager.h"
22 #include "content/renderer/media/video_capture_module_impl.h" 22 #include "content/renderer/media/video_capture_module_impl.h"
23 #include "content/renderer/media/webrtc_audio_device_impl.h" 23 #include "content/renderer/media/webrtc_audio_device_impl.h"
24 #include "content/renderer/p2p/ipc_network_manager.h" 24 #include "content/renderer/p2p/ipc_network_manager.h"
25 #include "content/renderer/p2p/ipc_socket_factory.h" 25 #include "content/renderer/p2p/ipc_socket_factory.h"
26 #include "jingle/glue/thread_wrapper.h" 26 #include "jingle/glue/thread_wrapper.h"
27 #include "media/base/message_loop_factory.h" 27 #include "media/base/message_loop_factory.h"
28 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDataSource.h"
28 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" 29 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
29 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaStreamRegistr y.h" 30 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaStreamRegistr y.h"
31 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNavigationType.h"
30 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" 32 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h"
31 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebMediaStre amComponent.h" 33 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebMediaStre amComponent.h"
32 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebMediaStre amDescriptor.h" 34 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebMediaStre amDescriptor.h"
33 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebMediaStre amSource.h" 35 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebMediaStre amSource.h"
34 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h" 36 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h"
35 37
36 namespace { 38 namespace {
37 const int kVideoCaptureWidth = 640; 39 const int kVideoCaptureWidth = 640;
38 const int kVideoCaptureHeight = 480; 40 const int kVideoCaptureHeight = 480;
39 const int kVideoCaptureFramePerSecond = 30; 41 const int kVideoCaptureFramePerSecond = 30;
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 CreateWebKitSourceVector(label, audio_array, 255 CreateWebKitSourceVector(label, audio_array,
254 WebKit::WebMediaStreamSource::TypeAudio, 256 WebKit::WebMediaStreamSource::TypeAudio,
255 audio_source_vector); 257 audio_source_vector);
256 WebKit::WebVector<WebKit::WebMediaStreamSource> video_source_vector( 258 WebKit::WebVector<WebKit::WebMediaStreamSource> video_source_vector(
257 video_array.size()); 259 video_array.size());
258 CreateWebKitSourceVector(label, video_array, 260 CreateWebKitSourceVector(label, video_array,
259 WebKit::WebMediaStreamSource::TypeVideo, 261 WebKit::WebMediaStreamSource::TypeVideo,
260 video_source_vector); 262 video_source_vector);
261 263
262 MediaRequestMap::iterator it = user_media_requests_.find(request_id); 264 MediaRequestMap::iterator it = user_media_requests_.find(request_id);
263 if (it == user_media_requests_.end()) { 265 if (it == user_media_requests_.end()) {
wjia(left Chromium) 2012/06/06 06:18:21 Since the request could be asynchronously canceled
264 DVLOG(1) << "Request ID not found"; 266 DVLOG(1) << "Request ID not found";
265 return; 267 return;
266 } 268 }
267 269
268 LocalNativeStreamPtr native_stream(CreateNativeLocalMediaStream( 270 LocalNativeStreamPtr native_stream(CreateNativeLocalMediaStream(
269 label, it->second.frame_, audio_source_vector, video_source_vector)); 271 label, it->second.frame_, audio_source_vector, video_source_vector));
270 if (!native_stream.get()) { 272 if (!native_stream.get()) {
271 DVLOG(1) << "Failed to create native stream in OnStreamGenerated."; 273 DVLOG(1) << "Failed to create native stream in OnStreamGenerated.";
272 media_stream_dispatcher_->StopStream(label); 274 media_stream_dispatcher_->StopStream(label);
273 it->second.request_.requestFailed(); 275 it->second.request_.requestFailed();
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 NOTIMPLEMENTED(); 349 NOTIMPLEMENTED();
348 } 350 }
349 351
350 void MediaStreamImpl::OnDeviceOpenFailed(int request_id) { 352 void MediaStreamImpl::OnDeviceOpenFailed(int request_id) {
351 DVLOG(1) << "MediaStreamImpl::VideoDeviceOpenFailed(" 353 DVLOG(1) << "MediaStreamImpl::VideoDeviceOpenFailed("
352 << request_id << ")"; 354 << request_id << ")";
353 NOTIMPLEMENTED(); 355 NOTIMPLEMENTED();
354 } 356 }
355 357
356 void MediaStreamImpl::FrameWillClose(WebKit::WebFrame* frame) { 358 void MediaStreamImpl::FrameWillClose(WebKit::WebFrame* frame) {
359 if (frame->provisionalDataSource()->navigationType() ==
360 WebKit::WebNavigationTypeReload) {
wjia(left Chromium) 2012/06/06 06:18:21 Should this be done for all navigation types?
361 MediaRequestMap::iterator it = user_media_requests_.begin();
362 while (it != user_media_requests_.end()) {
363 if (it->second.frame_ == frame) {
364 cancelUserMediaRequest(it->second.request_);
365 it = user_media_requests_.begin();
366 } else {
367 ++it;
368 }
369 }
370 }
357 LocalNativeStreamMap::iterator it = local_media_streams_.begin(); 371 LocalNativeStreamMap::iterator it = local_media_streams_.begin();
358 while (it != local_media_streams_.end()) { 372 while (it != local_media_streams_.end()) {
359 if (it->second == frame) { 373 if (it->second == frame) {
360 DVLOG(1) << "MediaStreamImpl::FrameWillClose: " 374 DVLOG(1) << "MediaStreamImpl::FrameWillClose: "
361 << "Stopping stream " << it->first; 375 << "Stopping stream " << it->first;
362 media_stream_dispatcher_->StopStream(it->first); 376 media_stream_dispatcher_->StopStream(it->first);
363 local_media_streams_.erase(it); 377 local_media_streams_.erase(it);
364 it = local_media_streams_.begin(); 378 it = local_media_streams_.begin();
365 } else { 379 } else {
366 ++it; 380 ++it;
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 MediaStreamExtraData::MediaStreamExtraData( 583 MediaStreamExtraData::MediaStreamExtraData(
570 webrtc::MediaStreamInterface* remote_stream) 584 webrtc::MediaStreamInterface* remote_stream)
571 : remote_stream_(remote_stream) { 585 : remote_stream_(remote_stream) {
572 } 586 }
573 MediaStreamExtraData::MediaStreamExtraData( 587 MediaStreamExtraData::MediaStreamExtraData(
574 webrtc::LocalMediaStreamInterface* local_stream) 588 webrtc::LocalMediaStreamInterface* local_stream)
575 : local_stream_(local_stream) { 589 : local_stream_(local_stream) {
576 } 590 }
577 MediaStreamExtraData::~MediaStreamExtraData() { 591 MediaStreamExtraData::~MediaStreamExtraData() {
578 } 592 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698