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/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/stringprintf.h" | 13 #include "base/stringprintf.h" |
14 #include "base/synchronization/waitable_event.h" | 14 #include "base/synchronization/waitable_event.h" |
15 #include "base/utf_string_conversions.h" | 15 #include "base/utf_string_conversions.h" |
16 #include "content/common/child_thread.h" | 16 #include "content/common/child_thread.h" |
17 #include "content/renderer/media/capture_video_decoder.h" | 17 #include "content/renderer/media/capture_video_decoder.h" |
18 #include "content/renderer/media/media_stream_extra_data.h" | 18 #include "content/renderer/media/media_stream_extra_data.h" |
19 #include "content/renderer/media/media_stream_dependency_factory.h" | 19 #include "content/renderer/media/media_stream_dependency_factory.h" |
20 #include "content/renderer/media/media_stream_dispatcher.h" | 20 #include "content/renderer/media/media_stream_dispatcher.h" |
21 #include "content/renderer/media/peer_connection_handler.h" | |
22 #include "content/renderer/media/peer_connection_handler_jsep.h" | 21 #include "content/renderer/media/peer_connection_handler_jsep.h" |
23 #include "content/renderer/media/video_capture_impl_manager.h" | 22 #include "content/renderer/media/video_capture_impl_manager.h" |
24 #include "content/renderer/media/video_capture_module_impl.h" | 23 #include "content/renderer/media/video_capture_module_impl.h" |
25 #include "content/renderer/media/webrtc_audio_device_impl.h" | 24 #include "content/renderer/media/webrtc_audio_device_impl.h" |
26 #include "content/renderer/p2p/ipc_network_manager.h" | 25 #include "content/renderer/p2p/ipc_network_manager.h" |
27 #include "content/renderer/p2p/ipc_socket_factory.h" | 26 #include "content/renderer/p2p/ipc_socket_factory.h" |
28 #include "jingle/glue/thread_wrapper.h" | 27 #include "jingle/glue/thread_wrapper.h" |
29 #include "media/base/message_loop_factory.h" | 28 #include "media/base/message_loop_factory.h" |
30 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 29 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
31 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaStreamRegistr
y.h" | 30 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaStreamRegistr
y.h" |
32 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" | 31 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.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
amComponent.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
amDescriptor.h" |
35 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebMediaStre
amSource.h" | 34 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebMediaStre
amSource.h" |
36 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h" | 35 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h" |
37 | 36 |
38 namespace { | 37 namespace { |
39 const int kVideoCaptureWidth = 640; | 38 const int kVideoCaptureWidth = 640; |
40 const int kVideoCaptureHeight = 480; | 39 const int kVideoCaptureHeight = 480; |
41 const int kVideoCaptureFramePerSecond = 30; | 40 const int kVideoCaptureFramePerSecond = 30; |
42 | 41 |
43 // Helper enum used for histogramming calls to WebRTC APIs from JavaScript. | 42 // Helper enum used for histogramming calls to WebRTC APIs from JavaScript. |
44 enum JavaScriptAPIName { | 43 enum JavaScriptAPIName { |
45 kWebkitGetUserMedia, | 44 kWebkitGetUserMedia, |
46 kWebkitPeerConnection, | 45 kWebkitPeerConnection, |
47 kWebkitDeprecatedPeerConnection, | |
48 kInvalidName | 46 kInvalidName |
49 }; | 47 }; |
50 } // namespace | 48 } // namespace |
51 | 49 |
52 // Helper method used to collect information about the number of times | 50 // Helper method used to collect information about the number of times |
53 // different WebRTC API:s are called from JavaScript. | 51 // different WebRTC API:s are called from JavaScript. |
54 // The histogram can be viewed at chrome://histograms/WebRTC.webkitApiCount. | 52 // The histogram can be viewed at chrome://histograms/WebRTC.webkitApiCount. |
55 static void UpdateWebRTCMethodCount(JavaScriptAPIName api_name) { | 53 static void UpdateWebRTCMethodCount(JavaScriptAPIName api_name) { |
56 UMA_HISTOGRAM_ENUMERATION("WebRTC.webkitApiCount", api_name, kInvalidName); | 54 UMA_HISTOGRAM_ENUMERATION("WebRTC.webkitApiCount", api_name, kInvalidName); |
57 } | 55 } |
(...skipping 30 matching lines...) Expand all Loading... |
88 vc_manager_(vc_manager), | 86 vc_manager_(vc_manager), |
89 signaling_thread_(NULL), | 87 signaling_thread_(NULL), |
90 worker_thread_(NULL), | 88 worker_thread_(NULL), |
91 chrome_worker_thread_("Chrome_libJingle_WorkerThread") { | 89 chrome_worker_thread_("Chrome_libJingle_WorkerThread") { |
92 } | 90 } |
93 | 91 |
94 MediaStreamImpl::~MediaStreamImpl() { | 92 MediaStreamImpl::~MediaStreamImpl() { |
95 CleanupPeerConnectionFactory(); | 93 CleanupPeerConnectionFactory(); |
96 } | 94 } |
97 | 95 |
98 WebKit::WebPeerConnectionHandler* MediaStreamImpl::CreatePeerConnectionHandler( | |
99 WebKit::WebPeerConnectionHandlerClient* client) { | |
100 // Save histogram data so we can see how much PeerConnetion is used. | |
101 // The histogram counts the number of calls to the JS API | |
102 // webKitDeprecatedPeerConnection. | |
103 UpdateWebRTCMethodCount(kWebkitDeprecatedPeerConnection); | |
104 DCHECK(CalledOnValidThread()); | |
105 if (!EnsurePeerConnectionFactory()) | |
106 return NULL; | |
107 | |
108 PeerConnectionHandler* pc_handler = new PeerConnectionHandler( | |
109 client, | |
110 dependency_factory_.get()); | |
111 return pc_handler; | |
112 } | |
113 | |
114 WebKit::WebPeerConnection00Handler* | 96 WebKit::WebPeerConnection00Handler* |
115 MediaStreamImpl::CreatePeerConnectionHandlerJsep( | 97 MediaStreamImpl::CreatePeerConnectionHandlerJsep( |
116 WebKit::WebPeerConnection00HandlerClient* client) { | 98 WebKit::WebPeerConnection00HandlerClient* client) { |
117 // Save histogram data so we can see how much PeerConnetion is used. | 99 // Save histogram data so we can see how much PeerConnetion is used. |
118 // The histogram counts the number of calls to the JS API | 100 // The histogram counts the number of calls to the JS API |
119 // webKitPeerConnection00. | 101 // webKitPeerConnection00. |
120 UpdateWebRTCMethodCount(kWebkitPeerConnection); | 102 UpdateWebRTCMethodCount(kWebkitPeerConnection); |
121 DCHECK(CalledOnValidThread()); | 103 DCHECK(CalledOnValidThread()); |
122 if (!EnsurePeerConnectionFactory()) | 104 if (!EnsurePeerConnectionFactory()) |
123 return NULL; | 105 return NULL; |
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
571 MediaStreamExtraData::MediaStreamExtraData( | 553 MediaStreamExtraData::MediaStreamExtraData( |
572 webrtc::MediaStreamInterface* remote_stream) | 554 webrtc::MediaStreamInterface* remote_stream) |
573 : remote_stream_(remote_stream) { | 555 : remote_stream_(remote_stream) { |
574 } | 556 } |
575 MediaStreamExtraData::MediaStreamExtraData( | 557 MediaStreamExtraData::MediaStreamExtraData( |
576 webrtc::LocalMediaStreamInterface* local_stream) | 558 webrtc::LocalMediaStreamInterface* local_stream) |
577 : local_stream_(local_stream) { | 559 : local_stream_(local_stream) { |
578 } | 560 } |
579 MediaStreamExtraData::~MediaStreamExtraData() { | 561 MediaStreamExtraData::~MediaStreamExtraData() { |
580 } | 562 } |
OLD | NEW |