| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 #include "content/renderer/media/peer_connection_tracker.h" | 4 #include "content/renderer/media/peer_connection_tracker.h" |
| 5 | 5 |
| 6 #include "base/strings/utf_string_conversions.h" | 6 #include "base/strings/utf_string_conversions.h" |
| 7 #include "content/common/media/peer_connection_tracker_messages.h" | 7 #include "content/common/media/peer_connection_tracker_messages.h" |
| 8 #include "content/renderer/media/rtc_media_constraints.h" | 8 #include "content/renderer/media/rtc_media_constraints.h" |
| 9 #include "content/renderer/media/rtc_peer_connection_handler.h" | 9 #include "content/renderer/media/rtc_peer_connection_handler.h" |
| 10 #include "content/renderer/render_thread_impl.h" | 10 #include "content/renderer/render_thread_impl.h" |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 for (size_t i = 0; i < tracks.size(); ++i) { | 91 for (size_t i = 0; i < tracks.size(); ++i) { |
| 92 result += SerializeMediaStreamComponent(tracks[i]); | 92 result += SerializeMediaStreamComponent(tracks[i]); |
| 93 if (i != tracks.size() - 1) | 93 if (i != tracks.size() - 1) |
| 94 result += ", "; | 94 result += ", "; |
| 95 } | 95 } |
| 96 result += "]"; | 96 result += "]"; |
| 97 } | 97 } |
| 98 return result; | 98 return result; |
| 99 } | 99 } |
| 100 | 100 |
| 101 static std::string SerializeIceTransportType( |
| 102 webrtc::PeerConnectionInterface::IceTransportsType type) { |
| 103 string transport_type; |
| 104 switch (type) { |
| 105 case webrtc::PeerConnectionInterface::kNone: |
| 106 transport_type = "none"; |
| 107 break; |
| 108 case webrtc::PeerConnectionInterface::kRelay: |
| 109 transport_type = "relay"; |
| 110 break; |
| 111 case webrtc::PeerConnectionInterface::kAll: |
| 112 transport_type = "all"; |
| 113 break; |
| 114 case webrtc::PeerConnectionInterface::kNoHost: |
| 115 transport_type = "noHost"; |
| 116 break; |
| 117 default: |
| 118 NOTREACHED(); |
| 119 }; |
| 120 return transport_type; |
| 121 } |
| 122 |
| 101 #define GET_STRING_OF_STATE(state) \ | 123 #define GET_STRING_OF_STATE(state) \ |
| 102 case WebRTCPeerConnectionHandlerClient::state: \ | 124 case WebRTCPeerConnectionHandlerClient::state: \ |
| 103 result = #state; \ | 125 result = #state; \ |
| 104 break; | 126 break; |
| 105 | 127 |
| 106 static string GetSignalingStateString( | 128 static string GetSignalingStateString( |
| 107 WebRTCPeerConnectionHandlerClient::SignalingState state) { | 129 WebRTCPeerConnectionHandlerClient::SignalingState state) { |
| 108 string result; | 130 string result; |
| 109 switch (state) { | 131 switch (state) { |
| 110 GET_STRING_OF_STATE(SignalingStateStable) | 132 GET_STRING_OF_STATE(SignalingStateStable) |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 | 269 |
| 248 it->first->GetStats( | 270 it->first->GetStats( |
| 249 observer, | 271 observer, |
| 250 NULL, | 272 NULL, |
| 251 webrtc::PeerConnectionInterface::kStatsOutputLevelDebug); | 273 webrtc::PeerConnectionInterface::kStatsOutputLevelDebug); |
| 252 } | 274 } |
| 253 } | 275 } |
| 254 | 276 |
| 255 void PeerConnectionTracker::RegisterPeerConnection( | 277 void PeerConnectionTracker::RegisterPeerConnection( |
| 256 RTCPeerConnectionHandler* pc_handler, | 278 RTCPeerConnectionHandler* pc_handler, |
| 257 const std::vector<webrtc::PeerConnectionInterface::IceServer>& servers, | 279 const webrtc::PeerConnectionInterface::RTCConfiguration& config, |
| 258 const RTCMediaConstraints& constraints, | 280 const RTCMediaConstraints& constraints, |
| 259 const blink::WebFrame* frame) { | 281 const blink::WebFrame* frame) { |
| 260 DVLOG(1) << "PeerConnectionTracker::RegisterPeerConnection()"; | 282 DVLOG(1) << "PeerConnectionTracker::RegisterPeerConnection()"; |
| 261 PeerConnectionInfo info; | 283 PeerConnectionInfo info; |
| 262 | 284 |
| 263 info.lid = GetNextLocalID(); | 285 info.lid = GetNextLocalID(); |
| 264 info.servers = SerializeServers(servers); | 286 info.rtc_configuration = |
| 287 "{ servers: " + SerializeServers(config.servers) + ", " + |
| 288 "iceTransportType: " + SerializeIceTransportType(config.type) + " }"; |
| 289 |
| 265 info.constraints = SerializeMediaConstraints(constraints); | 290 info.constraints = SerializeMediaConstraints(constraints); |
| 266 info.url = frame->document().url().spec(); | 291 info.url = frame->document().url().spec(); |
| 267 RenderThreadImpl::current()->Send( | 292 RenderThreadImpl::current()->Send( |
| 268 new PeerConnectionTrackerHost_AddPeerConnection(info)); | 293 new PeerConnectionTrackerHost_AddPeerConnection(info)); |
| 269 | 294 |
| 270 DCHECK(peer_connection_id_map_.find(pc_handler) == | 295 DCHECK(peer_connection_id_map_.find(pc_handler) == |
| 271 peer_connection_id_map_.end()); | 296 peer_connection_id_map_.end()); |
| 272 peer_connection_id_map_[pc_handler] = info.lid; | 297 peer_connection_id_map_[pc_handler] = info.lid; |
| 273 } | 298 } |
| 274 | 299 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 | 341 |
| 317 string value = "type: " + type + ", sdp: " + sdp; | 342 string value = "type: " + type + ", sdp: " + sdp; |
| 318 SendPeerConnectionUpdate( | 343 SendPeerConnectionUpdate( |
| 319 pc_handler, | 344 pc_handler, |
| 320 source == SOURCE_LOCAL ? "setLocalDescription" : "setRemoteDescription", | 345 source == SOURCE_LOCAL ? "setLocalDescription" : "setRemoteDescription", |
| 321 value); | 346 value); |
| 322 } | 347 } |
| 323 | 348 |
| 324 void PeerConnectionTracker::TrackUpdateIce( | 349 void PeerConnectionTracker::TrackUpdateIce( |
| 325 RTCPeerConnectionHandler* pc_handler, | 350 RTCPeerConnectionHandler* pc_handler, |
| 326 const std::vector<webrtc::PeerConnectionInterface::IceServer>& servers, | 351 const webrtc::PeerConnectionInterface::RTCConfiguration& config, |
| 327 const RTCMediaConstraints& options) { | 352 const RTCMediaConstraints& options) { |
| 328 string servers_string = "servers: " + SerializeServers(servers); | 353 string servers_string = "servers: " + SerializeServers(config.servers); |
| 354 |
| 355 string transport_type = |
| 356 "iceTransportType: " + SerializeIceTransportType(config.type); |
| 357 |
| 329 string constraints = | 358 string constraints = |
| 330 "constraints: {" + SerializeMediaConstraints(options) + "}"; | 359 "constraints: {" + SerializeMediaConstraints(options) + "}"; |
| 331 | 360 |
| 332 SendPeerConnectionUpdate( | 361 SendPeerConnectionUpdate( |
| 333 pc_handler, "updateIce", servers_string + ", " + constraints); | 362 pc_handler, |
| 363 "updateIce", |
| 364 servers_string + ", " + transport_type + ", " + constraints); |
| 334 } | 365 } |
| 335 | 366 |
| 336 void PeerConnectionTracker::TrackAddIceCandidate( | 367 void PeerConnectionTracker::TrackAddIceCandidate( |
| 337 RTCPeerConnectionHandler* pc_handler, | 368 RTCPeerConnectionHandler* pc_handler, |
| 338 const blink::WebRTCICECandidate& candidate, | 369 const blink::WebRTCICECandidate& candidate, |
| 339 Source source) { | 370 Source source) { |
| 340 string value = "mid: " + base::UTF16ToUTF8(candidate.sdpMid()) + ", " + | 371 string value = "mid: " + base::UTF16ToUTF8(candidate.sdpMid()) + ", " + |
| 341 "candidate: " + base::UTF16ToUTF8(candidate.candidate()); | 372 "candidate: " + base::UTF16ToUTF8(candidate.candidate()); |
| 342 SendPeerConnectionUpdate( | 373 SendPeerConnectionUpdate( |
| 343 pc_handler, | 374 pc_handler, |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 const std::string& value) { | 493 const std::string& value) { |
| 463 if (peer_connection_id_map_.find(pc_handler) == peer_connection_id_map_.end()) | 494 if (peer_connection_id_map_.find(pc_handler) == peer_connection_id_map_.end()) |
| 464 return; | 495 return; |
| 465 | 496 |
| 466 RenderThreadImpl::current()->Send( | 497 RenderThreadImpl::current()->Send( |
| 467 new PeerConnectionTrackerHost_UpdatePeerConnection( | 498 new PeerConnectionTrackerHost_UpdatePeerConnection( |
| 468 peer_connection_id_map_[pc_handler], type, value)); | 499 peer_connection_id_map_[pc_handler], type, value)); |
| 469 } | 500 } |
| 470 | 501 |
| 471 } // namespace content | 502 } // namespace content |
| OLD | NEW |