Chromium Code Reviews| 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 | 4 |
| 5 #include "content/renderer/media/peer_connection_tracker.h" | 5 #include "content/renderer/media/peer_connection_tracker.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 166 break; | 166 break; |
| 167 case webrtc::PeerConnectionInterface::kRtcpMuxPolicyRequire: | 167 case webrtc::PeerConnectionInterface::kRtcpMuxPolicyRequire: |
| 168 policy_str = "require"; | 168 policy_str = "require"; |
| 169 break; | 169 break; |
| 170 default: | 170 default: |
| 171 NOTREACHED(); | 171 NOTREACHED(); |
| 172 }; | 172 }; |
| 173 return policy_str; | 173 return policy_str; |
| 174 } | 174 } |
| 175 | 175 |
| 176 static std::string SerializeConfiguration( | |
| 177 const webrtc::PeerConnectionInterface::RTCConfiguration& config) { | |
| 178 std::ostringstream oss; | |
| 179 oss << "{ iceServers: " << SerializeServers(config.servers) << ", " | |
| 180 << "iceTransportPolicy: " << SerializeIceTransportType(config.type) | |
| 181 << ", " | |
| 182 << "bundlePolicy: " << SerializeBundlePolicy(config.bundle_policy) << ", " | |
| 183 << "rtcpMuxPolicy: " << SerializeRtcpMuxPolicy(config.rtcp_mux_policy) | |
|
hbos_chromium
2017/03/03 11:56:06
I noticed there's no "certificates", even though c
Taylor_Brandstetter
2017/03/03 18:44:46
TODO added.
| |
| 184 << "iceCandidatePoolSize: " << config.ice_candidate_pool_size << " }"; | |
| 185 return oss.str(); | |
| 186 } | |
| 187 | |
| 176 #define GET_STRING_OF_STATE(state) \ | 188 #define GET_STRING_OF_STATE(state) \ |
| 177 case WebRTCPeerConnectionHandlerClient::state: \ | 189 case WebRTCPeerConnectionHandlerClient::state: \ |
| 178 result = #state; \ | 190 result = #state; \ |
| 179 break; | 191 break; |
| 180 | 192 |
| 181 static const char* GetSignalingStateString( | 193 static const char* GetSignalingStateString( |
| 182 WebRTCPeerConnectionHandlerClient::SignalingState state) { | 194 WebRTCPeerConnectionHandlerClient::SignalingState state) { |
| 183 const char* result = ""; | 195 const char* result = ""; |
| 184 switch (state) { | 196 switch (state) { |
| 185 GET_STRING_OF_STATE(SignalingStateStable) | 197 GET_STRING_OF_STATE(SignalingStateStable) |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 421 RTCPeerConnectionHandler* pc_handler, | 433 RTCPeerConnectionHandler* pc_handler, |
| 422 const webrtc::PeerConnectionInterface::RTCConfiguration& config, | 434 const webrtc::PeerConnectionInterface::RTCConfiguration& config, |
| 423 const blink::WebMediaConstraints& constraints, | 435 const blink::WebMediaConstraints& constraints, |
| 424 const blink::WebFrame* frame) { | 436 const blink::WebFrame* frame) { |
| 425 DCHECK(main_thread_.CalledOnValidThread()); | 437 DCHECK(main_thread_.CalledOnValidThread()); |
| 426 DCHECK_EQ(GetLocalIDForHandler(pc_handler), -1); | 438 DCHECK_EQ(GetLocalIDForHandler(pc_handler), -1); |
| 427 DVLOG(1) << "PeerConnectionTracker::RegisterPeerConnection()"; | 439 DVLOG(1) << "PeerConnectionTracker::RegisterPeerConnection()"; |
| 428 PeerConnectionInfo info; | 440 PeerConnectionInfo info; |
| 429 | 441 |
| 430 info.lid = GetNextLocalID(); | 442 info.lid = GetNextLocalID(); |
| 431 info.rtc_configuration = | 443 info.rtc_configuration = SerializeConfiguration(config); |
| 432 "{ iceServers: " + SerializeServers(config.servers) + ", " + | |
| 433 "iceTransportPolicy: " + SerializeIceTransportType(config.type) + ", " + | |
| 434 "bundlePolicy: " + SerializeBundlePolicy(config.bundle_policy) + ", " + | |
| 435 "rtcpMuxPolicy: " + SerializeRtcpMuxPolicy(config.rtcp_mux_policy) + " }"; | |
| 436 | 444 |
| 437 info.constraints = SerializeMediaConstraints(constraints); | 445 info.constraints = SerializeMediaConstraints(constraints); |
| 438 if (frame) | 446 if (frame) |
| 439 info.url = frame->document().url().string().utf8(); | 447 info.url = frame->document().url().string().utf8(); |
| 440 else | 448 else |
| 441 info.url = "test:testing"; | 449 info.url = "test:testing"; |
| 442 SendTarget()->Send(new PeerConnectionTrackerHost_AddPeerConnection(info)); | 450 SendTarget()->Send(new PeerConnectionTrackerHost_AddPeerConnection(info)); |
| 443 | 451 |
| 444 peer_connection_id_map_.insert(std::make_pair(pc_handler, info.lid)); | 452 peer_connection_id_map_.insert(std::make_pair(pc_handler, info.lid)); |
| 445 } | 453 } |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 525 } | 533 } |
| 526 | 534 |
| 527 void PeerConnectionTracker::TrackSetConfiguration( | 535 void PeerConnectionTracker::TrackSetConfiguration( |
| 528 RTCPeerConnectionHandler* pc_handler, | 536 RTCPeerConnectionHandler* pc_handler, |
| 529 const webrtc::PeerConnectionInterface::RTCConfiguration& config) { | 537 const webrtc::PeerConnectionInterface::RTCConfiguration& config) { |
| 530 DCHECK(main_thread_.CalledOnValidThread()); | 538 DCHECK(main_thread_.CalledOnValidThread()); |
| 531 int id = GetLocalIDForHandler(pc_handler); | 539 int id = GetLocalIDForHandler(pc_handler); |
| 532 if (id == -1) | 540 if (id == -1) |
| 533 return; | 541 return; |
| 534 | 542 |
| 535 std::ostringstream result; | 543 SendPeerConnectionUpdate(id, "setConfiguration", |
| 536 result << "servers: " << SerializeServers(config.servers) | 544 SerializeConfiguration(config)); |
| 537 << "iceTransportType: " << SerializeIceTransportType(config.type) | |
| 538 << "bundlePolicy: " << SerializeBundlePolicy(config.bundle_policy) | |
| 539 << "rtcpMuxPolicy: " << SerializeRtcpMuxPolicy(config.rtcp_mux_policy) | |
| 540 << "}"; | |
| 541 | |
| 542 SendPeerConnectionUpdate(id, "setConfiguration", result.str()); | |
| 543 } | 545 } |
| 544 | 546 |
| 545 void PeerConnectionTracker::TrackAddIceCandidate( | 547 void PeerConnectionTracker::TrackAddIceCandidate( |
| 546 RTCPeerConnectionHandler* pc_handler, | 548 RTCPeerConnectionHandler* pc_handler, |
| 547 const blink::WebRTCICECandidate& candidate, | 549 const blink::WebRTCICECandidate& candidate, |
| 548 Source source, | 550 Source source, |
| 549 bool succeeded) { | 551 bool succeeded) { |
| 550 DCHECK(main_thread_.CalledOnValidThread()); | 552 DCHECK(main_thread_.CalledOnValidThread()); |
| 551 int id = GetLocalIDForHandler(pc_handler); | 553 int id = GetLocalIDForHandler(pc_handler); |
| 552 if (id == -1) | 554 if (id == -1) |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 738 DCHECK(main_thread_.CalledOnValidThread()); | 740 DCHECK(main_thread_.CalledOnValidThread()); |
| 739 SendTarget()->Send(new PeerConnectionTrackerHost_UpdatePeerConnection( | 741 SendTarget()->Send(new PeerConnectionTrackerHost_UpdatePeerConnection( |
| 740 local_id, std::string(callback_type), value)); | 742 local_id, std::string(callback_type), value)); |
| 741 } | 743 } |
| 742 | 744 |
| 743 void PeerConnectionTracker::OverrideSendTargetForTesting(RenderThread* target) { | 745 void PeerConnectionTracker::OverrideSendTargetForTesting(RenderThread* target) { |
| 744 send_target_for_test_ = target; | 746 send_target_for_test_ = target; |
| 745 } | 747 } |
| 746 | 748 |
| 747 } // namespace content | 749 } // namespace content |
| OLD | NEW |