| 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/utf_string_conversions.h" | 6 #include "base/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" |
| 11 #include "third_party/WebKit/Source/Platform/chromium/public/WebMediaStream.h" | 11 #include "third_party/WebKit/Source/Platform/chromium/public/WebMediaStream.h" |
| 12 #include "third_party/WebKit/Source/Platform/chromium/public/WebMediaStreamSourc
e.h" | 12 #include "third_party/WebKit/Source/Platform/chromium/public/WebMediaStreamSourc
e.h" |
| 13 #include "third_party/WebKit/Source/Platform/chromium/public/WebMediaStreamTrack
.h" | 13 #include "third_party/WebKit/Source/Platform/chromium/public/WebMediaStreamTrack
.h" |
| 14 #include "third_party/WebKit/Source/Platform/chromium/public/WebRTCICECandidate.
h" | 14 #include "third_party/WebKit/Source/Platform/chromium/public/WebRTCICECandidate.
h" |
| 15 #include "third_party/WebKit/Source/Platform/chromium/public/WebRTCPeerConnectio
nHandlerClient.h" | 15 #include "third_party/WebKit/Source/Platform/chromium/public/WebRTCPeerConnectio
nHandlerClient.h" |
| 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" | 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" |
| 17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
| 18 | 18 |
| 19 using std::string; | 19 using std::string; |
| 20 using webrtc::MediaConstraintsInterface; | 20 using webrtc::MediaConstraintsInterface; |
| 21 using WebKit::WebRTCPeerConnectionHandlerClient; | 21 using WebKit::WebRTCPeerConnectionHandlerClient; |
| 22 | 22 |
| 23 namespace content { | 23 namespace content { |
| 24 | 24 |
| 25 static string SerializeServers( | 25 static string SerializeServers( |
| 26 const std::vector<webrtc::JsepInterface::IceServer>& servers) { | 26 const std::vector<webrtc::PeerConnectionInterface::IceServer>& servers) { |
| 27 string result = "["; | 27 string result = "["; |
| 28 for (size_t i = 0; i < servers.size(); ++i) { | 28 for (size_t i = 0; i < servers.size(); ++i) { |
| 29 result += servers[i].uri; | 29 result += servers[i].uri; |
| 30 if (i != servers.size() - 1) | 30 if (i != servers.size() - 1) |
| 31 result += ", "; | 31 result += ", "; |
| 32 } | 32 } |
| 33 result += "]"; | 33 result += "]"; |
| 34 return result; | 34 return result; |
| 35 } | 35 } |
| 36 | 36 |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 | 234 |
| 235 talk_base::scoped_refptr<InternalStatsObserver> observer( | 235 talk_base::scoped_refptr<InternalStatsObserver> observer( |
| 236 new talk_base::RefCountedObject<InternalStatsObserver>(it->second)); | 236 new talk_base::RefCountedObject<InternalStatsObserver>(it->second)); |
| 237 | 237 |
| 238 it->first->GetStats(observer, NULL); | 238 it->first->GetStats(observer, NULL); |
| 239 } | 239 } |
| 240 } | 240 } |
| 241 | 241 |
| 242 void PeerConnectionTracker::RegisterPeerConnection( | 242 void PeerConnectionTracker::RegisterPeerConnection( |
| 243 RTCPeerConnectionHandler* pc_handler, | 243 RTCPeerConnectionHandler* pc_handler, |
| 244 const std::vector<webrtc::JsepInterface::IceServer>& servers, | 244 const std::vector<webrtc::PeerConnectionInterface::IceServer>& servers, |
| 245 const RTCMediaConstraints& constraints, | 245 const RTCMediaConstraints& constraints, |
| 246 const WebKit::WebFrame* frame) { | 246 const WebKit::WebFrame* frame) { |
| 247 DVLOG(1) << "PeerConnectionTracker::RegisterPeerConnection()"; | 247 DVLOG(1) << "PeerConnectionTracker::RegisterPeerConnection()"; |
| 248 PeerConnectionInfo info; | 248 PeerConnectionInfo info; |
| 249 | 249 |
| 250 info.lid = GetNextLocalID(); | 250 info.lid = GetNextLocalID(); |
| 251 info.servers = SerializeServers(servers); | 251 info.servers = SerializeServers(servers); |
| 252 info.constraints = SerializeMediaConstraints(constraints); | 252 info.constraints = SerializeMediaConstraints(constraints); |
| 253 info.url = frame->document().url().spec(); | 253 info.url = frame->document().url().spec(); |
| 254 RenderThreadImpl::current()->Send( | 254 RenderThreadImpl::current()->Send( |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 | 303 |
| 304 string value = "type: " + desc->type() + ", sdp: " + sdp; | 304 string value = "type: " + desc->type() + ", sdp: " + sdp; |
| 305 SendPeerConnectionUpdate( | 305 SendPeerConnectionUpdate( |
| 306 pc_handler, | 306 pc_handler, |
| 307 source == SOURCE_LOCAL ? "setLocalDescription" : "setRemoteDescription", | 307 source == SOURCE_LOCAL ? "setLocalDescription" : "setRemoteDescription", |
| 308 value); | 308 value); |
| 309 } | 309 } |
| 310 | 310 |
| 311 void PeerConnectionTracker::TrackUpdateIce( | 311 void PeerConnectionTracker::TrackUpdateIce( |
| 312 RTCPeerConnectionHandler* pc_handler, | 312 RTCPeerConnectionHandler* pc_handler, |
| 313 const std::vector<webrtc::JsepInterface::IceServer>& servers, | 313 const std::vector<webrtc::PeerConnectionInterface::IceServer>& servers, |
| 314 const RTCMediaConstraints& options) { | 314 const RTCMediaConstraints& options) { |
| 315 string servers_string = "servers: " + SerializeServers(servers); | 315 string servers_string = "servers: " + SerializeServers(servers); |
| 316 string constraints = | 316 string constraints = |
| 317 "constraints: {" + SerializeMediaConstraints(options) + "}"; | 317 "constraints: {" + SerializeMediaConstraints(options) + "}"; |
| 318 | 318 |
| 319 SendPeerConnectionUpdate( | 319 SendPeerConnectionUpdate( |
| 320 pc_handler, "updateIce", servers_string + ", " + constraints); | 320 pc_handler, "updateIce", servers_string + ", " + constraints); |
| 321 } | 321 } |
| 322 | 322 |
| 323 void PeerConnectionTracker::TrackAddIceCandidate( | 323 void PeerConnectionTracker::TrackAddIceCandidate( |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 const std::string& value) { | 421 const std::string& value) { |
| 422 if (peer_connection_id_map_.find(pc_handler) == peer_connection_id_map_.end()) | 422 if (peer_connection_id_map_.find(pc_handler) == peer_connection_id_map_.end()) |
| 423 return; | 423 return; |
| 424 | 424 |
| 425 RenderThreadImpl::current()->Send( | 425 RenderThreadImpl::current()->Send( |
| 426 new PeerConnectionTrackerHost_UpdatePeerConnection( | 426 new PeerConnectionTrackerHost_UpdatePeerConnection( |
| 427 peer_connection_id_map_[pc_handler], type, value)); | 427 peer_connection_id_map_[pc_handler], type, value)); |
| 428 } | 428 } |
| 429 | 429 |
| 430 } // namespace content | 430 } // namespace content |
| OLD | NEW |