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/rtc_peer_connection_handler.h" | 5 #include "content/renderer/media/rtc_peer_connection_handler.h" |
6 | 6 |
7 #include <string.h> | 7 #include <string.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
(...skipping 22 matching lines...) Expand all Loading... | |
33 #include "content/renderer/media/webrtc/rtc_stats.h" | 33 #include "content/renderer/media/webrtc/rtc_stats.h" |
34 #include "content/renderer/media/webrtc/webrtc_media_stream_adapter.h" | 34 #include "content/renderer/media/webrtc/webrtc_media_stream_adapter.h" |
35 #include "content/renderer/media/webrtc_audio_device_impl.h" | 35 #include "content/renderer/media/webrtc_audio_device_impl.h" |
36 #include "content/renderer/media/webrtc_uma_histograms.h" | 36 #include "content/renderer/media/webrtc_uma_histograms.h" |
37 #include "content/renderer/render_thread_impl.h" | 37 #include "content/renderer/render_thread_impl.h" |
38 #include "media/base/media_switches.h" | 38 #include "media/base/media_switches.h" |
39 #include "third_party/WebKit/public/platform/WebMediaConstraints.h" | 39 #include "third_party/WebKit/public/platform/WebMediaConstraints.h" |
40 #include "third_party/WebKit/public/platform/WebRTCAnswerOptions.h" | 40 #include "third_party/WebKit/public/platform/WebRTCAnswerOptions.h" |
41 #include "third_party/WebKit/public/platform/WebRTCConfiguration.h" | 41 #include "third_party/WebKit/public/platform/WebRTCConfiguration.h" |
42 #include "third_party/WebKit/public/platform/WebRTCDataChannelInit.h" | 42 #include "third_party/WebKit/public/platform/WebRTCDataChannelInit.h" |
43 #include "third_party/WebKit/public/platform/WebRTCError.h" | |
43 #include "third_party/WebKit/public/platform/WebRTCICECandidate.h" | 44 #include "third_party/WebKit/public/platform/WebRTCICECandidate.h" |
44 #include "third_party/WebKit/public/platform/WebRTCLegacyStats.h" | 45 #include "third_party/WebKit/public/platform/WebRTCLegacyStats.h" |
45 #include "third_party/WebKit/public/platform/WebRTCOfferOptions.h" | 46 #include "third_party/WebKit/public/platform/WebRTCOfferOptions.h" |
46 #include "third_party/WebKit/public/platform/WebRTCSessionDescription.h" | 47 #include "third_party/WebKit/public/platform/WebRTCSessionDescription.h" |
47 #include "third_party/WebKit/public/platform/WebRTCSessionDescriptionRequest.h" | 48 #include "third_party/WebKit/public/platform/WebRTCSessionDescriptionRequest.h" |
48 #include "third_party/WebKit/public/platform/WebRTCVoidRequest.h" | 49 #include "third_party/WebKit/public/platform/WebRTCVoidRequest.h" |
49 #include "third_party/WebKit/public/platform/WebURL.h" | 50 #include "third_party/WebKit/public/platform/WebURL.h" |
50 #include "third_party/webrtc/pc/mediasession.h" | 51 #include "third_party/webrtc/pc/mediasession.h" |
51 | 52 |
52 using webrtc::DataChannelInterface; | 53 using webrtc::DataChannelInterface; |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
153 | 154 |
154 std::string sdp; | 155 std::string sdp; |
155 if (!native_desc->ToString(&sdp)) { | 156 if (!native_desc->ToString(&sdp)) { |
156 LOG(ERROR) << "Failed to get SDP string of native session description."; | 157 LOG(ERROR) << "Failed to get SDP string of native session description."; |
157 return blink::WebRTCSessionDescription(); | 158 return blink::WebRTCSessionDescription(); |
158 } | 159 } |
159 | 160 |
160 return CreateWebKitSessionDescription(sdp, native_desc->type()); | 161 return CreateWebKitSessionDescription(sdp, native_desc->type()); |
161 } | 162 } |
162 | 163 |
164 void ConvertToWebKitRTCError(const webrtc::RTCError& webrtc_error, | |
165 blink::WebRTCError* blink_error) { | |
166 switch (webrtc_error.type()) { | |
167 case webrtc::RTCErrorType::NONE: | |
168 blink_error->setType(blink::WebRTCErrorType::kNone); | |
169 break; | |
170 case webrtc::RTCErrorType::UNSUPPORTED_PARAMETER: | |
171 blink_error->setType(blink::WebRTCErrorType::kUnsupportedParameter); | |
172 break; | |
173 case webrtc::RTCErrorType::INVALID_PARAMETER: | |
174 blink_error->setType(blink::WebRTCErrorType::kInvalidParameter); | |
175 break; | |
176 case webrtc::RTCErrorType::INVALID_RANGE: | |
177 blink_error->setType(blink::WebRTCErrorType::kInvalidRange); | |
178 break; | |
179 case webrtc::RTCErrorType::SYNTAX_ERROR: | |
180 blink_error->setType(blink::WebRTCErrorType::kSyntaxError); | |
181 break; | |
182 case webrtc::RTCErrorType::INVALID_STATE: | |
183 blink_error->setType(blink::WebRTCErrorType::kInvalidState); | |
184 break; | |
185 case webrtc::RTCErrorType::INVALID_MODIFICATION: | |
186 blink_error->setType(blink::WebRTCErrorType::kInvalidModification); | |
187 break; | |
188 case webrtc::RTCErrorType::NETWORK_ERROR: | |
189 blink_error->setType(blink::WebRTCErrorType::kNetworkError); | |
190 break; | |
191 case webrtc::RTCErrorType::INTERNAL_ERROR: | |
192 blink_error->setType(blink::WebRTCErrorType::kInternalError); | |
193 break; | |
194 default: | |
195 // If adding a new error type, need 3 CLs: One to add the enum to webrtc, | |
196 // one to update this mapping code, and one to start using the enum in | |
197 // webrtc. | |
198 DCHECK(false) << "webrtc::RTCErrorType " << webrtc_error.type() << | |
perkj_chrome
2017/01/13 09:14:06
NOTREACHED()
| |
199 " not covered by switch statement."; | |
200 break; | |
201 } | |
202 } | |
203 | |
163 void RunClosureWithTrace(const base::Closure& closure, | 204 void RunClosureWithTrace(const base::Closure& closure, |
164 const char* trace_event_name) { | 205 const char* trace_event_name) { |
165 TRACE_EVENT0("webrtc", trace_event_name); | 206 TRACE_EVENT0("webrtc", trace_event_name); |
166 closure.Run(); | 207 closure.Run(); |
167 } | 208 } |
168 | 209 |
169 void RunSynchronousClosure(const base::Closure& closure, | 210 void RunSynchronousClosure(const base::Closure& closure, |
170 const char* trace_event_name, | 211 const char* trace_event_name, |
171 base::WaitableEvent* event) { | 212 base::WaitableEvent* event) { |
172 { | 213 { |
(...skipping 1214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1387 native_peer_connection_); | 1428 native_peer_connection_); |
1388 RunSynchronousClosureOnSignalingThread( | 1429 RunSynchronousClosureOnSignalingThread( |
1389 base::Bind(&GetSdpAndTypeFromSessionDescription, description_cb, | 1430 base::Bind(&GetSdpAndTypeFromSessionDescription, description_cb, |
1390 base::Unretained(&sdp), base::Unretained(&type)), | 1431 base::Unretained(&sdp), base::Unretained(&type)), |
1391 "remoteDescription"); | 1432 "remoteDescription"); |
1392 | 1433 |
1393 return CreateWebKitSessionDescription(sdp, type); | 1434 return CreateWebKitSessionDescription(sdp, type); |
1394 } | 1435 } |
1395 | 1436 |
1396 bool RTCPeerConnectionHandler::setConfiguration( | 1437 bool RTCPeerConnectionHandler::setConfiguration( |
1397 const blink::WebRTCConfiguration& blink_config) { | 1438 const blink::WebRTCConfiguration& blink_config, |
1439 blink::WebRTCError& error) { | |
1398 DCHECK(thread_checker_.CalledOnValidThread()); | 1440 DCHECK(thread_checker_.CalledOnValidThread()); |
1399 TRACE_EVENT0("webrtc", "RTCPeerConnectionHandler::setConfiguration"); | 1441 TRACE_EVENT0("webrtc", "RTCPeerConnectionHandler::setConfiguration"); |
1400 GetNativeRtcConfiguration(blink_config, &configuration_); | 1442 GetNativeRtcConfiguration(blink_config, &configuration_); |
1401 | 1443 |
1402 if (peer_connection_tracker_) | 1444 if (peer_connection_tracker_) |
1403 peer_connection_tracker_->TrackSetConfiguration(this, configuration_); | 1445 peer_connection_tracker_->TrackSetConfiguration(this, configuration_); |
1404 | 1446 |
1405 return native_peer_connection_->SetConfiguration(configuration_); | 1447 webrtc::RTCError webrtc_error; |
1448 bool ret = | |
1449 native_peer_connection_->SetConfiguration(configuration_, &webrtc_error); | |
1450 ConvertToWebKitRTCError(webrtc_error, &error); | |
1451 return ret; | |
1406 } | 1452 } |
1407 | 1453 |
1408 bool RTCPeerConnectionHandler::addICECandidate( | 1454 bool RTCPeerConnectionHandler::addICECandidate( |
1409 const blink::WebRTCVoidRequest& request, | 1455 const blink::WebRTCVoidRequest& request, |
1410 const blink::WebRTCICECandidate& candidate) { | 1456 const blink::WebRTCICECandidate& candidate) { |
1411 DCHECK(thread_checker_.CalledOnValidThread()); | 1457 DCHECK(thread_checker_.CalledOnValidThread()); |
1412 TRACE_EVENT0("webrtc", "RTCPeerConnectionHandler::addICECandidate"); | 1458 TRACE_EVENT0("webrtc", "RTCPeerConnectionHandler::addICECandidate"); |
1413 // Libjingle currently does not accept callbacks for addICECandidate. | 1459 // Libjingle currently does not accept callbacks for addICECandidate. |
1414 // For that reason we are going to call callbacks from here. | 1460 // For that reason we are going to call callbacks from here. |
1415 | 1461 |
(...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1955 } | 2001 } |
1956 | 2002 |
1957 void RTCPeerConnectionHandler::ResetUMAStats() { | 2003 void RTCPeerConnectionHandler::ResetUMAStats() { |
1958 DCHECK(thread_checker_.CalledOnValidThread()); | 2004 DCHECK(thread_checker_.CalledOnValidThread()); |
1959 num_local_candidates_ipv6_ = 0; | 2005 num_local_candidates_ipv6_ = 0; |
1960 num_local_candidates_ipv4_ = 0; | 2006 num_local_candidates_ipv4_ = 0; |
1961 ice_connection_checking_start_ = base::TimeTicks(); | 2007 ice_connection_checking_start_ = base::TimeTicks(); |
1962 memset(ice_state_seen_, 0, sizeof(ice_state_seen_)); | 2008 memset(ice_state_seen_, 0, sizeof(ice_state_seen_)); |
1963 } | 2009 } |
1964 } // namespace content | 2010 } // namespace content |
OLD | NEW |