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 // TODO(hbos): Add serialization of certificate. |
| 180 oss << "{ iceServers: " << SerializeServers(config.servers) << ", " |
| 181 << "iceTransportPolicy: " << SerializeIceTransportType(config.type) |
| 182 << ", " |
| 183 << "bundlePolicy: " << SerializeBundlePolicy(config.bundle_policy) << ", " |
| 184 << "rtcpMuxPolicy: " << SerializeRtcpMuxPolicy(config.rtcp_mux_policy) |
| 185 << "iceCandidatePoolSize: " << config.ice_candidate_pool_size << " }"; |
| 186 return oss.str(); |
| 187 } |
| 188 |
176 #define GET_STRING_OF_STATE(state) \ | 189 #define GET_STRING_OF_STATE(state) \ |
177 case WebRTCPeerConnectionHandlerClient::state: \ | 190 case WebRTCPeerConnectionHandlerClient::state: \ |
178 result = #state; \ | 191 result = #state; \ |
179 break; | 192 break; |
180 | 193 |
181 static const char* GetSignalingStateString( | 194 static const char* GetSignalingStateString( |
182 WebRTCPeerConnectionHandlerClient::SignalingState state) { | 195 WebRTCPeerConnectionHandlerClient::SignalingState state) { |
183 const char* result = ""; | 196 const char* result = ""; |
184 switch (state) { | 197 switch (state) { |
185 GET_STRING_OF_STATE(SignalingStateStable) | 198 GET_STRING_OF_STATE(SignalingStateStable) |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
421 RTCPeerConnectionHandler* pc_handler, | 434 RTCPeerConnectionHandler* pc_handler, |
422 const webrtc::PeerConnectionInterface::RTCConfiguration& config, | 435 const webrtc::PeerConnectionInterface::RTCConfiguration& config, |
423 const blink::WebMediaConstraints& constraints, | 436 const blink::WebMediaConstraints& constraints, |
424 const blink::WebFrame* frame) { | 437 const blink::WebFrame* frame) { |
425 DCHECK(main_thread_.CalledOnValidThread()); | 438 DCHECK(main_thread_.CalledOnValidThread()); |
426 DCHECK_EQ(GetLocalIDForHandler(pc_handler), -1); | 439 DCHECK_EQ(GetLocalIDForHandler(pc_handler), -1); |
427 DVLOG(1) << "PeerConnectionTracker::RegisterPeerConnection()"; | 440 DVLOG(1) << "PeerConnectionTracker::RegisterPeerConnection()"; |
428 PeerConnectionInfo info; | 441 PeerConnectionInfo info; |
429 | 442 |
430 info.lid = GetNextLocalID(); | 443 info.lid = GetNextLocalID(); |
431 info.rtc_configuration = | 444 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 | 445 |
437 info.constraints = SerializeMediaConstraints(constraints); | 446 info.constraints = SerializeMediaConstraints(constraints); |
438 if (frame) | 447 if (frame) |
439 info.url = frame->document().url().string().utf8(); | 448 info.url = frame->document().url().string().utf8(); |
440 else | 449 else |
441 info.url = "test:testing"; | 450 info.url = "test:testing"; |
442 SendTarget()->Send(new PeerConnectionTrackerHost_AddPeerConnection(info)); | 451 SendTarget()->Send(new PeerConnectionTrackerHost_AddPeerConnection(info)); |
443 | 452 |
444 peer_connection_id_map_.insert(std::make_pair(pc_handler, info.lid)); | 453 peer_connection_id_map_.insert(std::make_pair(pc_handler, info.lid)); |
445 } | 454 } |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
525 } | 534 } |
526 | 535 |
527 void PeerConnectionTracker::TrackSetConfiguration( | 536 void PeerConnectionTracker::TrackSetConfiguration( |
528 RTCPeerConnectionHandler* pc_handler, | 537 RTCPeerConnectionHandler* pc_handler, |
529 const webrtc::PeerConnectionInterface::RTCConfiguration& config) { | 538 const webrtc::PeerConnectionInterface::RTCConfiguration& config) { |
530 DCHECK(main_thread_.CalledOnValidThread()); | 539 DCHECK(main_thread_.CalledOnValidThread()); |
531 int id = GetLocalIDForHandler(pc_handler); | 540 int id = GetLocalIDForHandler(pc_handler); |
532 if (id == -1) | 541 if (id == -1) |
533 return; | 542 return; |
534 | 543 |
535 std::ostringstream result; | 544 SendPeerConnectionUpdate(id, "setConfiguration", |
536 result << "servers: " << SerializeServers(config.servers) | 545 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 } | 546 } |
544 | 547 |
545 void PeerConnectionTracker::TrackAddIceCandidate( | 548 void PeerConnectionTracker::TrackAddIceCandidate( |
546 RTCPeerConnectionHandler* pc_handler, | 549 RTCPeerConnectionHandler* pc_handler, |
547 const blink::WebRTCICECandidate& candidate, | 550 const blink::WebRTCICECandidate& candidate, |
548 Source source, | 551 Source source, |
549 bool succeeded) { | 552 bool succeeded) { |
550 DCHECK(main_thread_.CalledOnValidThread()); | 553 DCHECK(main_thread_.CalledOnValidThread()); |
551 int id = GetLocalIDForHandler(pc_handler); | 554 int id = GetLocalIDForHandler(pc_handler); |
552 if (id == -1) | 555 if (id == -1) |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
738 DCHECK(main_thread_.CalledOnValidThread()); | 741 DCHECK(main_thread_.CalledOnValidThread()); |
739 SendTarget()->Send(new PeerConnectionTrackerHost_UpdatePeerConnection( | 742 SendTarget()->Send(new PeerConnectionTrackerHost_UpdatePeerConnection( |
740 local_id, std::string(callback_type), value)); | 743 local_id, std::string(callback_type), value)); |
741 } | 744 } |
742 | 745 |
743 void PeerConnectionTracker::OverrideSendTargetForTesting(RenderThread* target) { | 746 void PeerConnectionTracker::OverrideSendTargetForTesting(RenderThread* target) { |
744 send_target_for_test_ = target; | 747 send_target_for_test_ = target; |
745 } | 748 } |
746 | 749 |
747 } // namespace content | 750 } // namespace content |
OLD | NEW |