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_jsep.h" | 21 #include "content/renderer/media/peer_connection_handler_jsep.h" |
22 #include "content/renderer/media/rtc_peer_connection_handler.h" | |
22 #include "content/renderer/media/video_capture_impl_manager.h" | 23 #include "content/renderer/media/video_capture_impl_manager.h" |
23 #include "content/renderer/media/video_capture_module_impl.h" | 24 #include "content/renderer/media/video_capture_module_impl.h" |
24 #include "content/renderer/media/webrtc_audio_device_impl.h" | 25 #include "content/renderer/media/webrtc_audio_device_impl.h" |
25 #include "content/renderer/p2p/ipc_network_manager.h" | 26 #include "content/renderer/p2p/ipc_network_manager.h" |
26 #include "content/renderer/p2p/ipc_socket_factory.h" | 27 #include "content/renderer/p2p/ipc_socket_factory.h" |
27 #include "jingle/glue/thread_wrapper.h" | 28 #include "jingle/glue/thread_wrapper.h" |
28 #include "media/base/message_loop_factory.h" | 29 #include "media/base/message_loop_factory.h" |
29 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 30 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
30 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaStreamRegistr y.h" | 31 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaStreamRegistr y.h" |
31 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" | 32 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" |
32 #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" |
33 #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" |
34 #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" |
35 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h" | 36 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h" |
36 | 37 |
37 namespace { | 38 namespace { |
38 const int kVideoCaptureWidth = 640; | 39 const int kVideoCaptureWidth = 640; |
39 const int kVideoCaptureHeight = 480; | 40 const int kVideoCaptureHeight = 480; |
40 const int kVideoCaptureFramePerSecond = 30; | 41 const int kVideoCaptureFramePerSecond = 30; |
41 | 42 |
42 // Helper enum used for histogramming calls to WebRTC APIs from JavaScript. | 43 // Helper enum used for histogramming calls to WebRTC APIs from JavaScript. |
43 enum JavaScriptAPIName { | 44 enum JavaScriptAPIName { |
44 kWebkitGetUserMedia, | 45 kWebkitGetUserMedia, |
45 kWebkitPeerConnection, | 46 kWebkitPeerConnection, |
47 kWebkitRtcPeerConnection, | |
46 kInvalidName | 48 kInvalidName |
47 }; | 49 }; |
48 } // namespace | 50 } // namespace |
49 | 51 |
50 // Helper method used to collect information about the number of times | 52 // Helper method used to collect information about the number of times |
51 // different WebRTC API:s are called from JavaScript. | 53 // different WebRTC API:s are called from JavaScript. |
52 // The histogram can be viewed at chrome://histograms/WebRTC.webkitApiCount. | 54 // The histogram can be viewed at chrome://histograms/WebRTC.webkitApiCount. |
53 static void UpdateWebRTCMethodCount(JavaScriptAPIName api_name) { | 55 static void UpdateWebRTCMethodCount(JavaScriptAPIName api_name) { |
54 UMA_HISTOGRAM_ENUMERATION("WebRTC.webkitApiCount", api_name, kInvalidName); | 56 UMA_HISTOGRAM_ENUMERATION("WebRTC.webkitApiCount", api_name, kInvalidName); |
55 } | 57 } |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
103 DCHECK(CalledOnValidThread()); | 105 DCHECK(CalledOnValidThread()); |
104 if (!EnsurePeerConnectionFactory()) | 106 if (!EnsurePeerConnectionFactory()) |
105 return NULL; | 107 return NULL; |
106 | 108 |
107 PeerConnectionHandlerJsep* pc_handler = new PeerConnectionHandlerJsep( | 109 PeerConnectionHandlerJsep* pc_handler = new PeerConnectionHandlerJsep( |
108 client, | 110 client, |
109 dependency_factory_.get()); | 111 dependency_factory_.get()); |
110 return pc_handler; | 112 return pc_handler; |
111 } | 113 } |
112 | 114 |
115 WebKit::WebRTCPeerConnectionHandler* | |
116 MediaStreamImpl::CreateRTCPeerConnectionHandler( | |
117 WebKit::WebRTCPeerConnectionHandlerClient* client) { | |
wjia(left Chromium)
2012/08/12 17:06:52
indent.
perkj_chrome
2012/08/13 07:35:46
Done.
| |
118 // Save histogram data so we can see how much PeerConnetion is used. | |
119 // The histogram counts the number of calls to the JS API | |
120 // webKitRTCPeerConnection. | |
121 UpdateWebRTCMethodCount(kWebkitRtcPeerConnection); | |
122 DCHECK(CalledOnValidThread()); | |
123 if (!EnsurePeerConnectionFactory()) | |
124 return NULL; | |
125 | |
126 RTCPeerConnectionHandler* pc_handler = new RTCPeerConnectionHandler( | |
127 client, | |
128 dependency_factory_.get()); | |
129 return pc_handler; | |
130 } | |
131 | |
113 void MediaStreamImpl::StopLocalMediaStream( | 132 void MediaStreamImpl::StopLocalMediaStream( |
114 const WebKit::WebMediaStreamDescriptor& stream) { | 133 const WebKit::WebMediaStreamDescriptor& stream) { |
115 DVLOG(1) << "MediaStreamImpl::StopLocalMediaStream"; | 134 DVLOG(1) << "MediaStreamImpl::StopLocalMediaStream"; |
116 | 135 |
117 MediaStreamExtraData* extra_data = | 136 MediaStreamExtraData* extra_data = |
118 static_cast<MediaStreamExtraData*>(stream.extraData()); | 137 static_cast<MediaStreamExtraData*>(stream.extraData()); |
119 if (extra_data && extra_data->local_stream()) { | 138 if (extra_data && extra_data->local_stream()) { |
120 media_stream_dispatcher_->StopStream(extra_data->local_stream()->label()); | 139 media_stream_dispatcher_->StopStream(extra_data->local_stream()->label()); |
121 local_media_streams_.erase(extra_data->local_stream()->label()); | 140 local_media_streams_.erase(extra_data->local_stream()->label()); |
122 } else { | 141 } else { |
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
553 MediaStreamExtraData::MediaStreamExtraData( | 572 MediaStreamExtraData::MediaStreamExtraData( |
554 webrtc::MediaStreamInterface* remote_stream) | 573 webrtc::MediaStreamInterface* remote_stream) |
555 : remote_stream_(remote_stream) { | 574 : remote_stream_(remote_stream) { |
556 } | 575 } |
557 MediaStreamExtraData::MediaStreamExtraData( | 576 MediaStreamExtraData::MediaStreamExtraData( |
558 webrtc::LocalMediaStreamInterface* local_stream) | 577 webrtc::LocalMediaStreamInterface* local_stream) |
559 : local_stream_(local_stream) { | 578 : local_stream_(local_stream) { |
560 } | 579 } |
561 MediaStreamExtraData::~MediaStreamExtraData() { | 580 MediaStreamExtraData::~MediaStreamExtraData() { |
562 } | 581 } |
OLD | NEW |