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> | 7 #include <string> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 23 matching lines...) Expand all Loading... |
34 #include "third_party/WebKit/public/platform/WebRTCSessionDescription.h" | 34 #include "third_party/WebKit/public/platform/WebRTCSessionDescription.h" |
35 #include "third_party/WebKit/public/platform/WebRTCSessionDescriptionRequest.h" | 35 #include "third_party/WebKit/public/platform/WebRTCSessionDescriptionRequest.h" |
36 #include "third_party/WebKit/public/platform/WebRTCStatsRequest.h" | 36 #include "third_party/WebKit/public/platform/WebRTCStatsRequest.h" |
37 #include "third_party/WebKit/public/platform/WebRTCVoidRequest.h" | 37 #include "third_party/WebKit/public/platform/WebRTCVoidRequest.h" |
38 #include "third_party/WebKit/public/platform/WebURL.h" | 38 #include "third_party/WebKit/public/platform/WebURL.h" |
39 #include "third_party/WebKit/public/web/WebFrame.h" | 39 #include "third_party/WebKit/public/web/WebFrame.h" |
40 | 40 |
41 namespace content { | 41 namespace content { |
42 | 42 |
43 // Converter functions from libjingle types to WebKit types. | 43 // Converter functions from libjingle types to WebKit types. |
44 WebKit::WebRTCPeerConnectionHandlerClient::ICEGatheringState | 44 blink::WebRTCPeerConnectionHandlerClient::ICEGatheringState |
45 GetWebKitIceGatheringState( | 45 GetWebKitIceGatheringState( |
46 webrtc::PeerConnectionInterface::IceGatheringState state) { | 46 webrtc::PeerConnectionInterface::IceGatheringState state) { |
47 using WebKit::WebRTCPeerConnectionHandlerClient; | 47 using blink::WebRTCPeerConnectionHandlerClient; |
48 switch (state) { | 48 switch (state) { |
49 case webrtc::PeerConnectionInterface::kIceGatheringNew: | 49 case webrtc::PeerConnectionInterface::kIceGatheringNew: |
50 return WebRTCPeerConnectionHandlerClient::ICEGatheringStateNew; | 50 return WebRTCPeerConnectionHandlerClient::ICEGatheringStateNew; |
51 case webrtc::PeerConnectionInterface::kIceGatheringGathering: | 51 case webrtc::PeerConnectionInterface::kIceGatheringGathering: |
52 return WebRTCPeerConnectionHandlerClient::ICEGatheringStateGathering; | 52 return WebRTCPeerConnectionHandlerClient::ICEGatheringStateGathering; |
53 case webrtc::PeerConnectionInterface::kIceGatheringComplete: | 53 case webrtc::PeerConnectionInterface::kIceGatheringComplete: |
54 return WebRTCPeerConnectionHandlerClient::ICEGatheringStateComplete; | 54 return WebRTCPeerConnectionHandlerClient::ICEGatheringStateComplete; |
55 default: | 55 default: |
56 NOTREACHED(); | 56 NOTREACHED(); |
57 return WebRTCPeerConnectionHandlerClient::ICEGatheringStateNew; | 57 return WebRTCPeerConnectionHandlerClient::ICEGatheringStateNew; |
58 } | 58 } |
59 } | 59 } |
60 | 60 |
61 static WebKit::WebRTCPeerConnectionHandlerClient::ICEConnectionState | 61 static blink::WebRTCPeerConnectionHandlerClient::ICEConnectionState |
62 GetWebKitIceConnectionState( | 62 GetWebKitIceConnectionState( |
63 webrtc::PeerConnectionInterface::IceConnectionState ice_state) { | 63 webrtc::PeerConnectionInterface::IceConnectionState ice_state) { |
64 using WebKit::WebRTCPeerConnectionHandlerClient; | 64 using blink::WebRTCPeerConnectionHandlerClient; |
65 switch (ice_state) { | 65 switch (ice_state) { |
66 case webrtc::PeerConnectionInterface::kIceConnectionNew: | 66 case webrtc::PeerConnectionInterface::kIceConnectionNew: |
67 return WebRTCPeerConnectionHandlerClient::ICEConnectionStateStarting; | 67 return WebRTCPeerConnectionHandlerClient::ICEConnectionStateStarting; |
68 case webrtc::PeerConnectionInterface::kIceConnectionChecking: | 68 case webrtc::PeerConnectionInterface::kIceConnectionChecking: |
69 return WebRTCPeerConnectionHandlerClient::ICEConnectionStateChecking; | 69 return WebRTCPeerConnectionHandlerClient::ICEConnectionStateChecking; |
70 case webrtc::PeerConnectionInterface::kIceConnectionConnected: | 70 case webrtc::PeerConnectionInterface::kIceConnectionConnected: |
71 return WebRTCPeerConnectionHandlerClient::ICEConnectionStateConnected; | 71 return WebRTCPeerConnectionHandlerClient::ICEConnectionStateConnected; |
72 case webrtc::PeerConnectionInterface::kIceConnectionCompleted: | 72 case webrtc::PeerConnectionInterface::kIceConnectionCompleted: |
73 return WebRTCPeerConnectionHandlerClient::ICEConnectionStateCompleted; | 73 return WebRTCPeerConnectionHandlerClient::ICEConnectionStateCompleted; |
74 case webrtc::PeerConnectionInterface::kIceConnectionFailed: | 74 case webrtc::PeerConnectionInterface::kIceConnectionFailed: |
75 return WebRTCPeerConnectionHandlerClient::ICEConnectionStateFailed; | 75 return WebRTCPeerConnectionHandlerClient::ICEConnectionStateFailed; |
76 case webrtc::PeerConnectionInterface::kIceConnectionDisconnected: | 76 case webrtc::PeerConnectionInterface::kIceConnectionDisconnected: |
77 return WebRTCPeerConnectionHandlerClient::ICEConnectionStateDisconnected; | 77 return WebRTCPeerConnectionHandlerClient::ICEConnectionStateDisconnected; |
78 case webrtc::PeerConnectionInterface::kIceConnectionClosed: | 78 case webrtc::PeerConnectionInterface::kIceConnectionClosed: |
79 return WebRTCPeerConnectionHandlerClient::ICEConnectionStateClosed; | 79 return WebRTCPeerConnectionHandlerClient::ICEConnectionStateClosed; |
80 default: | 80 default: |
81 NOTREACHED(); | 81 NOTREACHED(); |
82 return WebRTCPeerConnectionHandlerClient::ICEConnectionStateClosed; | 82 return WebRTCPeerConnectionHandlerClient::ICEConnectionStateClosed; |
83 } | 83 } |
84 } | 84 } |
85 | 85 |
86 static WebKit::WebRTCPeerConnectionHandlerClient::SignalingState | 86 static blink::WebRTCPeerConnectionHandlerClient::SignalingState |
87 GetWebKitSignalingState(webrtc::PeerConnectionInterface::SignalingState state) { | 87 GetWebKitSignalingState(webrtc::PeerConnectionInterface::SignalingState state) { |
88 using WebKit::WebRTCPeerConnectionHandlerClient; | 88 using blink::WebRTCPeerConnectionHandlerClient; |
89 switch (state) { | 89 switch (state) { |
90 case webrtc::PeerConnectionInterface::kStable: | 90 case webrtc::PeerConnectionInterface::kStable: |
91 return WebRTCPeerConnectionHandlerClient::SignalingStateStable; | 91 return WebRTCPeerConnectionHandlerClient::SignalingStateStable; |
92 case webrtc::PeerConnectionInterface::kHaveLocalOffer: | 92 case webrtc::PeerConnectionInterface::kHaveLocalOffer: |
93 return WebRTCPeerConnectionHandlerClient::SignalingStateHaveLocalOffer; | 93 return WebRTCPeerConnectionHandlerClient::SignalingStateHaveLocalOffer; |
94 case webrtc::PeerConnectionInterface::kHaveLocalPrAnswer: | 94 case webrtc::PeerConnectionInterface::kHaveLocalPrAnswer: |
95 return WebRTCPeerConnectionHandlerClient::SignalingStateHaveLocalPrAnswer; | 95 return WebRTCPeerConnectionHandlerClient::SignalingStateHaveLocalPrAnswer; |
96 case webrtc::PeerConnectionInterface::kHaveRemoteOffer: | 96 case webrtc::PeerConnectionInterface::kHaveRemoteOffer: |
97 return WebRTCPeerConnectionHandlerClient::SignalingStateHaveRemoteOffer; | 97 return WebRTCPeerConnectionHandlerClient::SignalingStateHaveRemoteOffer; |
98 case webrtc::PeerConnectionInterface::kHaveRemotePrAnswer: | 98 case webrtc::PeerConnectionInterface::kHaveRemotePrAnswer: |
99 return | 99 return |
100 WebRTCPeerConnectionHandlerClient::SignalingStateHaveRemotePrAnswer; | 100 WebRTCPeerConnectionHandlerClient::SignalingStateHaveRemotePrAnswer; |
101 case webrtc::PeerConnectionInterface::kClosed: | 101 case webrtc::PeerConnectionInterface::kClosed: |
102 return WebRTCPeerConnectionHandlerClient::SignalingStateClosed; | 102 return WebRTCPeerConnectionHandlerClient::SignalingStateClosed; |
103 default: | 103 default: |
104 NOTREACHED(); | 104 NOTREACHED(); |
105 return WebRTCPeerConnectionHandlerClient::SignalingStateClosed; | 105 return WebRTCPeerConnectionHandlerClient::SignalingStateClosed; |
106 } | 106 } |
107 } | 107 } |
108 | 108 |
109 static WebKit::WebRTCSessionDescription | 109 static blink::WebRTCSessionDescription |
110 CreateWebKitSessionDescription( | 110 CreateWebKitSessionDescription( |
111 const webrtc::SessionDescriptionInterface* native_desc) { | 111 const webrtc::SessionDescriptionInterface* native_desc) { |
112 WebKit::WebRTCSessionDescription description; | 112 blink::WebRTCSessionDescription description; |
113 if (!native_desc) { | 113 if (!native_desc) { |
114 LOG(ERROR) << "Native session description is null."; | 114 LOG(ERROR) << "Native session description is null."; |
115 return description; | 115 return description; |
116 } | 116 } |
117 | 117 |
118 std::string sdp; | 118 std::string sdp; |
119 if (!native_desc->ToString(&sdp)) { | 119 if (!native_desc->ToString(&sdp)) { |
120 LOG(ERROR) << "Failed to get SDP string of native session description."; | 120 LOG(ERROR) << "Failed to get SDP string of native session description."; |
121 return description; | 121 return description; |
122 } | 122 } |
123 | 123 |
124 description.initialize(UTF8ToUTF16(native_desc->type()), UTF8ToUTF16(sdp)); | 124 description.initialize(UTF8ToUTF16(native_desc->type()), UTF8ToUTF16(sdp)); |
125 return description; | 125 return description; |
126 } | 126 } |
127 | 127 |
128 // Converter functions from WebKit types to libjingle types. | 128 // Converter functions from WebKit types to libjingle types. |
129 | 129 |
130 static void GetNativeIceServers( | 130 static void GetNativeIceServers( |
131 const WebKit::WebRTCConfiguration& server_configuration, | 131 const blink::WebRTCConfiguration& server_configuration, |
132 webrtc::PeerConnectionInterface::IceServers* servers) { | 132 webrtc::PeerConnectionInterface::IceServers* servers) { |
133 if (server_configuration.isNull() || !servers) | 133 if (server_configuration.isNull() || !servers) |
134 return; | 134 return; |
135 for (size_t i = 0; i < server_configuration.numberOfServers(); ++i) { | 135 for (size_t i = 0; i < server_configuration.numberOfServers(); ++i) { |
136 webrtc::PeerConnectionInterface::IceServer server; | 136 webrtc::PeerConnectionInterface::IceServer server; |
137 const WebKit::WebRTCICEServer& webkit_server = | 137 const blink::WebRTCICEServer& webkit_server = |
138 server_configuration.server(i); | 138 server_configuration.server(i); |
139 server.username = UTF16ToUTF8(webkit_server.username()); | 139 server.username = UTF16ToUTF8(webkit_server.username()); |
140 server.password = UTF16ToUTF8(webkit_server.credential()); | 140 server.password = UTF16ToUTF8(webkit_server.credential()); |
141 server.uri = webkit_server.uri().spec(); | 141 server.uri = webkit_server.uri().spec(); |
142 servers->push_back(server); | 142 servers->push_back(server); |
143 } | 143 } |
144 } | 144 } |
145 | 145 |
146 class SessionDescriptionRequestTracker { | 146 class SessionDescriptionRequestTracker { |
147 public: | 147 public: |
(...skipping 17 matching lines...) Expand all Loading... |
165 handler_->peer_connection_tracker()->TrackSessionDescriptionCallback( | 165 handler_->peer_connection_tracker()->TrackSessionDescriptionCallback( |
166 handler_, action_, "OnFailure", error); | 166 handler_, action_, "OnFailure", error); |
167 } | 167 } |
168 | 168 |
169 private: | 169 private: |
170 RTCPeerConnectionHandler* handler_; | 170 RTCPeerConnectionHandler* handler_; |
171 PeerConnectionTracker::Action action_; | 171 PeerConnectionTracker::Action action_; |
172 }; | 172 }; |
173 | 173 |
174 // Class mapping responses from calls to libjingle CreateOffer/Answer and | 174 // Class mapping responses from calls to libjingle CreateOffer/Answer and |
175 // the WebKit::WebRTCSessionDescriptionRequest. | 175 // the blink::WebRTCSessionDescriptionRequest. |
176 class CreateSessionDescriptionRequest | 176 class CreateSessionDescriptionRequest |
177 : public webrtc::CreateSessionDescriptionObserver { | 177 : public webrtc::CreateSessionDescriptionObserver { |
178 public: | 178 public: |
179 explicit CreateSessionDescriptionRequest( | 179 explicit CreateSessionDescriptionRequest( |
180 const WebKit::WebRTCSessionDescriptionRequest& request, | 180 const blink::WebRTCSessionDescriptionRequest& request, |
181 RTCPeerConnectionHandler* handler, | 181 RTCPeerConnectionHandler* handler, |
182 PeerConnectionTracker::Action action) | 182 PeerConnectionTracker::Action action) |
183 : webkit_request_(request), tracker_(handler, action) {} | 183 : webkit_request_(request), tracker_(handler, action) {} |
184 | 184 |
185 virtual void OnSuccess(webrtc::SessionDescriptionInterface* desc) OVERRIDE { | 185 virtual void OnSuccess(webrtc::SessionDescriptionInterface* desc) OVERRIDE { |
186 tracker_.TrackOnSuccess(desc); | 186 tracker_.TrackOnSuccess(desc); |
187 webkit_request_.requestSucceeded(CreateWebKitSessionDescription(desc)); | 187 webkit_request_.requestSucceeded(CreateWebKitSessionDescription(desc)); |
188 } | 188 } |
189 virtual void OnFailure(const std::string& error) OVERRIDE { | 189 virtual void OnFailure(const std::string& error) OVERRIDE { |
190 tracker_.TrackOnFailure(error); | 190 tracker_.TrackOnFailure(error); |
191 webkit_request_.requestFailed(UTF8ToUTF16(error)); | 191 webkit_request_.requestFailed(UTF8ToUTF16(error)); |
192 } | 192 } |
193 | 193 |
194 protected: | 194 protected: |
195 virtual ~CreateSessionDescriptionRequest() {} | 195 virtual ~CreateSessionDescriptionRequest() {} |
196 | 196 |
197 private: | 197 private: |
198 WebKit::WebRTCSessionDescriptionRequest webkit_request_; | 198 blink::WebRTCSessionDescriptionRequest webkit_request_; |
199 SessionDescriptionRequestTracker tracker_; | 199 SessionDescriptionRequestTracker tracker_; |
200 }; | 200 }; |
201 | 201 |
202 // Class mapping responses from calls to libjingle | 202 // Class mapping responses from calls to libjingle |
203 // SetLocalDescription/SetRemoteDescription and a WebKit::WebRTCVoidRequest. | 203 // SetLocalDescription/SetRemoteDescription and a blink::WebRTCVoidRequest. |
204 class SetSessionDescriptionRequest | 204 class SetSessionDescriptionRequest |
205 : public webrtc::SetSessionDescriptionObserver { | 205 : public webrtc::SetSessionDescriptionObserver { |
206 public: | 206 public: |
207 explicit SetSessionDescriptionRequest( | 207 explicit SetSessionDescriptionRequest( |
208 const WebKit::WebRTCVoidRequest& request, | 208 const blink::WebRTCVoidRequest& request, |
209 RTCPeerConnectionHandler* handler, | 209 RTCPeerConnectionHandler* handler, |
210 PeerConnectionTracker::Action action) | 210 PeerConnectionTracker::Action action) |
211 : webkit_request_(request), tracker_(handler, action) {} | 211 : webkit_request_(request), tracker_(handler, action) {} |
212 | 212 |
213 virtual void OnSuccess() OVERRIDE { | 213 virtual void OnSuccess() OVERRIDE { |
214 tracker_.TrackOnSuccess(NULL); | 214 tracker_.TrackOnSuccess(NULL); |
215 webkit_request_.requestSucceeded(); | 215 webkit_request_.requestSucceeded(); |
216 } | 216 } |
217 virtual void OnFailure(const std::string& error) OVERRIDE { | 217 virtual void OnFailure(const std::string& error) OVERRIDE { |
218 tracker_.TrackOnFailure(error); | 218 tracker_.TrackOnFailure(error); |
219 webkit_request_.requestFailed(UTF8ToUTF16(error)); | 219 webkit_request_.requestFailed(UTF8ToUTF16(error)); |
220 } | 220 } |
221 | 221 |
222 protected: | 222 protected: |
223 virtual ~SetSessionDescriptionRequest() {} | 223 virtual ~SetSessionDescriptionRequest() {} |
224 | 224 |
225 private: | 225 private: |
226 WebKit::WebRTCVoidRequest webkit_request_; | 226 blink::WebRTCVoidRequest webkit_request_; |
227 SessionDescriptionRequestTracker tracker_; | 227 SessionDescriptionRequestTracker tracker_; |
228 }; | 228 }; |
229 | 229 |
230 // Class mapping responses from calls to libjingle | 230 // Class mapping responses from calls to libjingle |
231 // GetStats into a WebKit::WebRTCStatsCallback. | 231 // GetStats into a blink::WebRTCStatsCallback. |
232 class StatsResponse : public webrtc::StatsObserver { | 232 class StatsResponse : public webrtc::StatsObserver { |
233 public: | 233 public: |
234 explicit StatsResponse(const scoped_refptr<LocalRTCStatsRequest>& request) | 234 explicit StatsResponse(const scoped_refptr<LocalRTCStatsRequest>& request) |
235 : request_(request.get()), response_(request_->createResponse().get()) {} | 235 : request_(request.get()), response_(request_->createResponse().get()) {} |
236 | 236 |
237 virtual void OnComplete( | 237 virtual void OnComplete( |
238 const std::vector<webrtc::StatsReport>& reports) OVERRIDE { | 238 const std::vector<webrtc::StatsReport>& reports) OVERRIDE { |
239 for (std::vector<webrtc::StatsReport>::const_iterator it = reports.begin(); | 239 for (std::vector<webrtc::StatsReport>::const_iterator it = reports.begin(); |
240 it != reports.end(); ++it) { | 240 it != reports.end(); ++it) { |
241 if (it->values.size() > 0) { | 241 if (it->values.size() > 0) { |
242 AddReport(*it); | 242 AddReport(*it); |
243 } | 243 } |
244 } | 244 } |
245 request_->requestSucceeded(response_); | 245 request_->requestSucceeded(response_); |
246 } | 246 } |
247 | 247 |
248 private: | 248 private: |
249 void AddReport(const webrtc::StatsReport& report) { | 249 void AddReport(const webrtc::StatsReport& report) { |
250 int idx = response_->addReport(WebKit::WebString::fromUTF8(report.id), | 250 int idx = response_->addReport(blink::WebString::fromUTF8(report.id), |
251 WebKit::WebString::fromUTF8(report.type), | 251 blink::WebString::fromUTF8(report.type), |
252 report.timestamp); | 252 report.timestamp); |
253 for (webrtc::StatsReport::Values::const_iterator value_it = | 253 for (webrtc::StatsReport::Values::const_iterator value_it = |
254 report.values.begin(); | 254 report.values.begin(); |
255 value_it != report.values.end(); ++value_it) { | 255 value_it != report.values.end(); ++value_it) { |
256 AddStatistic(idx, value_it->name, value_it->value); | 256 AddStatistic(idx, value_it->name, value_it->value); |
257 } | 257 } |
258 } | 258 } |
259 | 259 |
260 void AddStatistic(int idx, const std::string& name, | 260 void AddStatistic(int idx, const std::string& name, |
261 const std::string& value) { | 261 const std::string& value) { |
262 response_->addStatistic(idx, | 262 response_->addStatistic(idx, |
263 WebKit::WebString::fromUTF8(name), | 263 blink::WebString::fromUTF8(name), |
264 WebKit::WebString::fromUTF8(value)); | 264 blink::WebString::fromUTF8(value)); |
265 } | 265 } |
266 | 266 |
267 talk_base::scoped_refptr<LocalRTCStatsRequest> request_; | 267 talk_base::scoped_refptr<LocalRTCStatsRequest> request_; |
268 talk_base::scoped_refptr<LocalRTCStatsResponse> response_; | 268 talk_base::scoped_refptr<LocalRTCStatsResponse> response_; |
269 }; | 269 }; |
270 | 270 |
271 // Implementation of LocalRTCStatsRequest. | 271 // Implementation of LocalRTCStatsRequest. |
272 LocalRTCStatsRequest::LocalRTCStatsRequest(WebKit::WebRTCStatsRequest impl) | 272 LocalRTCStatsRequest::LocalRTCStatsRequest(blink::WebRTCStatsRequest impl) |
273 : impl_(impl), | 273 : impl_(impl), |
274 response_(NULL) { | 274 response_(NULL) { |
275 } | 275 } |
276 | 276 |
277 LocalRTCStatsRequest::LocalRTCStatsRequest() {} | 277 LocalRTCStatsRequest::LocalRTCStatsRequest() {} |
278 LocalRTCStatsRequest::~LocalRTCStatsRequest() {} | 278 LocalRTCStatsRequest::~LocalRTCStatsRequest() {} |
279 | 279 |
280 bool LocalRTCStatsRequest::hasSelector() const { | 280 bool LocalRTCStatsRequest::hasSelector() const { |
281 return impl_.hasSelector(); | 281 return impl_.hasSelector(); |
282 } | 282 } |
283 | 283 |
284 WebKit::WebMediaStreamTrack LocalRTCStatsRequest::component() const { | 284 blink::WebMediaStreamTrack LocalRTCStatsRequest::component() const { |
285 return impl_.component(); | 285 return impl_.component(); |
286 } | 286 } |
287 | 287 |
288 scoped_refptr<LocalRTCStatsResponse> LocalRTCStatsRequest::createResponse() { | 288 scoped_refptr<LocalRTCStatsResponse> LocalRTCStatsRequest::createResponse() { |
289 DCHECK(!response_); | 289 DCHECK(!response_); |
290 response_ = new talk_base::RefCountedObject<LocalRTCStatsResponse>( | 290 response_ = new talk_base::RefCountedObject<LocalRTCStatsResponse>( |
291 impl_.createResponse()); | 291 impl_.createResponse()); |
292 return response_.get(); | 292 return response_.get(); |
293 } | 293 } |
294 | 294 |
295 void LocalRTCStatsRequest::requestSucceeded( | 295 void LocalRTCStatsRequest::requestSucceeded( |
296 const LocalRTCStatsResponse* response) { | 296 const LocalRTCStatsResponse* response) { |
297 impl_.requestSucceeded(response->webKitStatsResponse()); | 297 impl_.requestSucceeded(response->webKitStatsResponse()); |
298 } | 298 } |
299 | 299 |
300 // Implementation of LocalRTCStatsResponse. | 300 // Implementation of LocalRTCStatsResponse. |
301 WebKit::WebRTCStatsResponse LocalRTCStatsResponse::webKitStatsResponse() const { | 301 blink::WebRTCStatsResponse LocalRTCStatsResponse::webKitStatsResponse() const { |
302 return impl_; | 302 return impl_; |
303 } | 303 } |
304 | 304 |
305 size_t LocalRTCStatsResponse::addReport(WebKit::WebString type, | 305 size_t LocalRTCStatsResponse::addReport(blink::WebString type, |
306 WebKit::WebString id, | 306 blink::WebString id, |
307 double timestamp) { | 307 double timestamp) { |
308 return impl_.addReport(type, id, timestamp); | 308 return impl_.addReport(type, id, timestamp); |
309 } | 309 } |
310 | 310 |
311 void LocalRTCStatsResponse::addStatistic(size_t report, | 311 void LocalRTCStatsResponse::addStatistic(size_t report, |
312 WebKit::WebString name, | 312 blink::WebString name, |
313 WebKit::WebString value) { | 313 blink::WebString value) { |
314 impl_.addStatistic(report, name, value); | 314 impl_.addStatistic(report, name, value); |
315 } | 315 } |
316 | 316 |
317 RTCPeerConnectionHandler::RTCPeerConnectionHandler( | 317 RTCPeerConnectionHandler::RTCPeerConnectionHandler( |
318 WebKit::WebRTCPeerConnectionHandlerClient* client, | 318 blink::WebRTCPeerConnectionHandlerClient* client, |
319 MediaStreamDependencyFactory* dependency_factory) | 319 MediaStreamDependencyFactory* dependency_factory) |
320 : PeerConnectionHandlerBase(dependency_factory), | 320 : PeerConnectionHandlerBase(dependency_factory), |
321 client_(client), | 321 client_(client), |
322 frame_(NULL), | 322 frame_(NULL), |
323 peer_connection_tracker_(NULL) { | 323 peer_connection_tracker_(NULL) { |
324 } | 324 } |
325 | 325 |
326 RTCPeerConnectionHandler::~RTCPeerConnectionHandler() { | 326 RTCPeerConnectionHandler::~RTCPeerConnectionHandler() { |
327 if (peer_connection_tracker_) | 327 if (peer_connection_tracker_) |
328 peer_connection_tracker_->UnregisterPeerConnection(this); | 328 peer_connection_tracker_->UnregisterPeerConnection(this); |
329 STLDeleteValues(&remote_streams_); | 329 STLDeleteValues(&remote_streams_); |
330 } | 330 } |
331 | 331 |
332 void RTCPeerConnectionHandler::associateWithFrame(WebKit::WebFrame* frame) { | 332 void RTCPeerConnectionHandler::associateWithFrame(blink::WebFrame* frame) { |
333 DCHECK(frame); | 333 DCHECK(frame); |
334 frame_ = frame; | 334 frame_ = frame; |
335 } | 335 } |
336 | 336 |
337 bool RTCPeerConnectionHandler::initialize( | 337 bool RTCPeerConnectionHandler::initialize( |
338 const WebKit::WebRTCConfiguration& server_configuration, | 338 const blink::WebRTCConfiguration& server_configuration, |
339 const WebKit::WebMediaConstraints& options) { | 339 const blink::WebMediaConstraints& options) { |
340 DCHECK(frame_); | 340 DCHECK(frame_); |
341 | 341 |
342 peer_connection_tracker_ = | 342 peer_connection_tracker_ = |
343 RenderThreadImpl::current()->peer_connection_tracker(); | 343 RenderThreadImpl::current()->peer_connection_tracker(); |
344 | 344 |
345 webrtc::PeerConnectionInterface::IceServers servers; | 345 webrtc::PeerConnectionInterface::IceServers servers; |
346 GetNativeIceServers(server_configuration, &servers); | 346 GetNativeIceServers(server_configuration, &servers); |
347 | 347 |
348 RTCMediaConstraints constraints(options); | 348 RTCMediaConstraints constraints(options); |
349 | 349 |
350 native_peer_connection_ = | 350 native_peer_connection_ = |
351 dependency_factory_->CreatePeerConnection( | 351 dependency_factory_->CreatePeerConnection( |
352 servers, &constraints, frame_, this); | 352 servers, &constraints, frame_, this); |
353 if (!native_peer_connection_.get()) { | 353 if (!native_peer_connection_.get()) { |
354 LOG(ERROR) << "Failed to initialize native PeerConnection."; | 354 LOG(ERROR) << "Failed to initialize native PeerConnection."; |
355 return false; | 355 return false; |
356 } | 356 } |
357 if (peer_connection_tracker_) | 357 if (peer_connection_tracker_) |
358 peer_connection_tracker_->RegisterPeerConnection( | 358 peer_connection_tracker_->RegisterPeerConnection( |
359 this, servers, constraints, frame_); | 359 this, servers, constraints, frame_); |
360 | 360 |
361 return true; | 361 return true; |
362 } | 362 } |
363 | 363 |
364 bool RTCPeerConnectionHandler::InitializeForTest( | 364 bool RTCPeerConnectionHandler::InitializeForTest( |
365 const WebKit::WebRTCConfiguration& server_configuration, | 365 const blink::WebRTCConfiguration& server_configuration, |
366 const WebKit::WebMediaConstraints& options, | 366 const blink::WebMediaConstraints& options, |
367 PeerConnectionTracker* peer_connection_tracker) { | 367 PeerConnectionTracker* peer_connection_tracker) { |
368 webrtc::PeerConnectionInterface::IceServers servers; | 368 webrtc::PeerConnectionInterface::IceServers servers; |
369 GetNativeIceServers(server_configuration, &servers); | 369 GetNativeIceServers(server_configuration, &servers); |
370 | 370 |
371 RTCMediaConstraints constraints(options); | 371 RTCMediaConstraints constraints(options); |
372 native_peer_connection_ = | 372 native_peer_connection_ = |
373 dependency_factory_->CreatePeerConnection( | 373 dependency_factory_->CreatePeerConnection( |
374 servers, &constraints, NULL, this); | 374 servers, &constraints, NULL, this); |
375 if (!native_peer_connection_.get()) { | 375 if (!native_peer_connection_.get()) { |
376 LOG(ERROR) << "Failed to initialize native PeerConnection."; | 376 LOG(ERROR) << "Failed to initialize native PeerConnection."; |
377 return false; | 377 return false; |
378 } | 378 } |
379 peer_connection_tracker_ = peer_connection_tracker; | 379 peer_connection_tracker_ = peer_connection_tracker; |
380 return true; | 380 return true; |
381 } | 381 } |
382 | 382 |
383 void RTCPeerConnectionHandler::createOffer( | 383 void RTCPeerConnectionHandler::createOffer( |
384 const WebKit::WebRTCSessionDescriptionRequest& request, | 384 const blink::WebRTCSessionDescriptionRequest& request, |
385 const WebKit::WebMediaConstraints& options) { | 385 const blink::WebMediaConstraints& options) { |
386 scoped_refptr<CreateSessionDescriptionRequest> description_request( | 386 scoped_refptr<CreateSessionDescriptionRequest> description_request( |
387 new talk_base::RefCountedObject<CreateSessionDescriptionRequest>( | 387 new talk_base::RefCountedObject<CreateSessionDescriptionRequest>( |
388 request, this, PeerConnectionTracker::ACTION_CREATE_OFFER)); | 388 request, this, PeerConnectionTracker::ACTION_CREATE_OFFER)); |
389 RTCMediaConstraints constraints(options); | 389 RTCMediaConstraints constraints(options); |
390 native_peer_connection_->CreateOffer(description_request.get(), &constraints); | 390 native_peer_connection_->CreateOffer(description_request.get(), &constraints); |
391 | 391 |
392 if (peer_connection_tracker_) | 392 if (peer_connection_tracker_) |
393 peer_connection_tracker_->TrackCreateOffer(this, constraints); | 393 peer_connection_tracker_->TrackCreateOffer(this, constraints); |
394 } | 394 } |
395 | 395 |
396 void RTCPeerConnectionHandler::createAnswer( | 396 void RTCPeerConnectionHandler::createAnswer( |
397 const WebKit::WebRTCSessionDescriptionRequest& request, | 397 const blink::WebRTCSessionDescriptionRequest& request, |
398 const WebKit::WebMediaConstraints& options) { | 398 const blink::WebMediaConstraints& options) { |
399 scoped_refptr<CreateSessionDescriptionRequest> description_request( | 399 scoped_refptr<CreateSessionDescriptionRequest> description_request( |
400 new talk_base::RefCountedObject<CreateSessionDescriptionRequest>( | 400 new talk_base::RefCountedObject<CreateSessionDescriptionRequest>( |
401 request, this, PeerConnectionTracker::ACTION_CREATE_ANSWER)); | 401 request, this, PeerConnectionTracker::ACTION_CREATE_ANSWER)); |
402 RTCMediaConstraints constraints(options); | 402 RTCMediaConstraints constraints(options); |
403 native_peer_connection_->CreateAnswer(description_request.get(), | 403 native_peer_connection_->CreateAnswer(description_request.get(), |
404 &constraints); | 404 &constraints); |
405 | 405 |
406 if (peer_connection_tracker_) | 406 if (peer_connection_tracker_) |
407 peer_connection_tracker_->TrackCreateAnswer(this, constraints); | 407 peer_connection_tracker_->TrackCreateAnswer(this, constraints); |
408 } | 408 } |
409 | 409 |
410 void RTCPeerConnectionHandler::setLocalDescription( | 410 void RTCPeerConnectionHandler::setLocalDescription( |
411 const WebKit::WebRTCVoidRequest& request, | 411 const blink::WebRTCVoidRequest& request, |
412 const WebKit::WebRTCSessionDescription& description) { | 412 const blink::WebRTCSessionDescription& description) { |
413 webrtc::SdpParseError error; | 413 webrtc::SdpParseError error; |
414 webrtc::SessionDescriptionInterface* native_desc = | 414 webrtc::SessionDescriptionInterface* native_desc = |
415 CreateNativeSessionDescription(description, &error); | 415 CreateNativeSessionDescription(description, &error); |
416 if (!native_desc) { | 416 if (!native_desc) { |
417 std::string reason_str = "Failed to parse SessionDescription. "; | 417 std::string reason_str = "Failed to parse SessionDescription. "; |
418 reason_str.append(error.line); | 418 reason_str.append(error.line); |
419 reason_str.append(" "); | 419 reason_str.append(" "); |
420 reason_str.append(error.description); | 420 reason_str.append(error.description); |
421 LOG(ERROR) << reason_str; | 421 LOG(ERROR) << reason_str; |
422 request.requestFailed(WebKit::WebString::fromUTF8(reason_str)); | 422 request.requestFailed(blink::WebString::fromUTF8(reason_str)); |
423 return; | 423 return; |
424 } | 424 } |
425 if (peer_connection_tracker_) | 425 if (peer_connection_tracker_) |
426 peer_connection_tracker_->TrackSetSessionDescription( | 426 peer_connection_tracker_->TrackSetSessionDescription( |
427 this, description, PeerConnectionTracker::SOURCE_LOCAL); | 427 this, description, PeerConnectionTracker::SOURCE_LOCAL); |
428 | 428 |
429 scoped_refptr<SetSessionDescriptionRequest> set_request( | 429 scoped_refptr<SetSessionDescriptionRequest> set_request( |
430 new talk_base::RefCountedObject<SetSessionDescriptionRequest>( | 430 new talk_base::RefCountedObject<SetSessionDescriptionRequest>( |
431 request, this, PeerConnectionTracker::ACTION_SET_LOCAL_DESCRIPTION)); | 431 request, this, PeerConnectionTracker::ACTION_SET_LOCAL_DESCRIPTION)); |
432 native_peer_connection_->SetLocalDescription(set_request.get(), native_desc); | 432 native_peer_connection_->SetLocalDescription(set_request.get(), native_desc); |
433 } | 433 } |
434 | 434 |
435 void RTCPeerConnectionHandler::setRemoteDescription( | 435 void RTCPeerConnectionHandler::setRemoteDescription( |
436 const WebKit::WebRTCVoidRequest& request, | 436 const blink::WebRTCVoidRequest& request, |
437 const WebKit::WebRTCSessionDescription& description) { | 437 const blink::WebRTCSessionDescription& description) { |
438 webrtc::SdpParseError error; | 438 webrtc::SdpParseError error; |
439 webrtc::SessionDescriptionInterface* native_desc = | 439 webrtc::SessionDescriptionInterface* native_desc = |
440 CreateNativeSessionDescription(description, &error); | 440 CreateNativeSessionDescription(description, &error); |
441 if (!native_desc) { | 441 if (!native_desc) { |
442 std::string reason_str = "Failed to parse SessionDescription. "; | 442 std::string reason_str = "Failed to parse SessionDescription. "; |
443 reason_str.append(error.line); | 443 reason_str.append(error.line); |
444 reason_str.append(" "); | 444 reason_str.append(" "); |
445 reason_str.append(error.description); | 445 reason_str.append(error.description); |
446 LOG(ERROR) << reason_str; | 446 LOG(ERROR) << reason_str; |
447 request.requestFailed(WebKit::WebString::fromUTF8(reason_str)); | 447 request.requestFailed(blink::WebString::fromUTF8(reason_str)); |
448 return; | 448 return; |
449 } | 449 } |
450 if (peer_connection_tracker_) | 450 if (peer_connection_tracker_) |
451 peer_connection_tracker_->TrackSetSessionDescription( | 451 peer_connection_tracker_->TrackSetSessionDescription( |
452 this, description, PeerConnectionTracker::SOURCE_REMOTE); | 452 this, description, PeerConnectionTracker::SOURCE_REMOTE); |
453 | 453 |
454 scoped_refptr<SetSessionDescriptionRequest> set_request( | 454 scoped_refptr<SetSessionDescriptionRequest> set_request( |
455 new talk_base::RefCountedObject<SetSessionDescriptionRequest>( | 455 new talk_base::RefCountedObject<SetSessionDescriptionRequest>( |
456 request, this, PeerConnectionTracker::ACTION_SET_REMOTE_DESCRIPTION)); | 456 request, this, PeerConnectionTracker::ACTION_SET_REMOTE_DESCRIPTION)); |
457 native_peer_connection_->SetRemoteDescription(set_request.get(), native_desc); | 457 native_peer_connection_->SetRemoteDescription(set_request.get(), native_desc); |
458 } | 458 } |
459 | 459 |
460 WebKit::WebRTCSessionDescription | 460 blink::WebRTCSessionDescription |
461 RTCPeerConnectionHandler::localDescription() { | 461 RTCPeerConnectionHandler::localDescription() { |
462 const webrtc::SessionDescriptionInterface* native_desc = | 462 const webrtc::SessionDescriptionInterface* native_desc = |
463 native_peer_connection_->local_description(); | 463 native_peer_connection_->local_description(); |
464 WebKit::WebRTCSessionDescription description = | 464 blink::WebRTCSessionDescription description = |
465 CreateWebKitSessionDescription(native_desc); | 465 CreateWebKitSessionDescription(native_desc); |
466 return description; | 466 return description; |
467 } | 467 } |
468 | 468 |
469 WebKit::WebRTCSessionDescription | 469 blink::WebRTCSessionDescription |
470 RTCPeerConnectionHandler::remoteDescription() { | 470 RTCPeerConnectionHandler::remoteDescription() { |
471 const webrtc::SessionDescriptionInterface* native_desc = | 471 const webrtc::SessionDescriptionInterface* native_desc = |
472 native_peer_connection_->remote_description(); | 472 native_peer_connection_->remote_description(); |
473 WebKit::WebRTCSessionDescription description = | 473 blink::WebRTCSessionDescription description = |
474 CreateWebKitSessionDescription(native_desc); | 474 CreateWebKitSessionDescription(native_desc); |
475 return description; | 475 return description; |
476 } | 476 } |
477 | 477 |
478 bool RTCPeerConnectionHandler::updateICE( | 478 bool RTCPeerConnectionHandler::updateICE( |
479 const WebKit::WebRTCConfiguration& server_configuration, | 479 const blink::WebRTCConfiguration& server_configuration, |
480 const WebKit::WebMediaConstraints& options) { | 480 const blink::WebMediaConstraints& options) { |
481 webrtc::PeerConnectionInterface::IceServers servers; | 481 webrtc::PeerConnectionInterface::IceServers servers; |
482 GetNativeIceServers(server_configuration, &servers); | 482 GetNativeIceServers(server_configuration, &servers); |
483 RTCMediaConstraints constraints(options); | 483 RTCMediaConstraints constraints(options); |
484 | 484 |
485 if (peer_connection_tracker_) | 485 if (peer_connection_tracker_) |
486 peer_connection_tracker_->TrackUpdateIce(this, servers, constraints); | 486 peer_connection_tracker_->TrackUpdateIce(this, servers, constraints); |
487 | 487 |
488 return native_peer_connection_->UpdateIce(servers, | 488 return native_peer_connection_->UpdateIce(servers, |
489 &constraints); | 489 &constraints); |
490 } | 490 } |
491 | 491 |
492 bool RTCPeerConnectionHandler::addICECandidate( | 492 bool RTCPeerConnectionHandler::addICECandidate( |
493 const WebKit::WebRTCICECandidate& candidate) { | 493 const blink::WebRTCICECandidate& candidate) { |
494 scoped_ptr<webrtc::IceCandidateInterface> native_candidate( | 494 scoped_ptr<webrtc::IceCandidateInterface> native_candidate( |
495 dependency_factory_->CreateIceCandidate( | 495 dependency_factory_->CreateIceCandidate( |
496 UTF16ToUTF8(candidate.sdpMid()), | 496 UTF16ToUTF8(candidate.sdpMid()), |
497 candidate.sdpMLineIndex(), | 497 candidate.sdpMLineIndex(), |
498 UTF16ToUTF8(candidate.candidate()))); | 498 UTF16ToUTF8(candidate.candidate()))); |
499 if (!native_candidate) { | 499 if (!native_candidate) { |
500 LOG(ERROR) << "Could not create native ICE candidate."; | 500 LOG(ERROR) << "Could not create native ICE candidate."; |
501 return false; | 501 return false; |
502 } | 502 } |
503 | 503 |
504 bool return_value = | 504 bool return_value = |
505 native_peer_connection_->AddIceCandidate(native_candidate.get()); | 505 native_peer_connection_->AddIceCandidate(native_candidate.get()); |
506 LOG_IF(ERROR, !return_value) << "Error processing ICE candidate."; | 506 LOG_IF(ERROR, !return_value) << "Error processing ICE candidate."; |
507 | 507 |
508 if (peer_connection_tracker_) | 508 if (peer_connection_tracker_) |
509 peer_connection_tracker_->TrackAddIceCandidate( | 509 peer_connection_tracker_->TrackAddIceCandidate( |
510 this, candidate, PeerConnectionTracker::SOURCE_REMOTE); | 510 this, candidate, PeerConnectionTracker::SOURCE_REMOTE); |
511 | 511 |
512 return return_value; | 512 return return_value; |
513 } | 513 } |
514 | 514 |
515 bool RTCPeerConnectionHandler::addStream( | 515 bool RTCPeerConnectionHandler::addStream( |
516 const WebKit::WebMediaStream& stream, | 516 const blink::WebMediaStream& stream, |
517 const WebKit::WebMediaConstraints& options) { | 517 const blink::WebMediaConstraints& options) { |
518 RTCMediaConstraints constraints(options); | 518 RTCMediaConstraints constraints(options); |
519 | 519 |
520 if (peer_connection_tracker_) | 520 if (peer_connection_tracker_) |
521 peer_connection_tracker_->TrackAddStream( | 521 peer_connection_tracker_->TrackAddStream( |
522 this, stream, PeerConnectionTracker::SOURCE_LOCAL); | 522 this, stream, PeerConnectionTracker::SOURCE_LOCAL); |
523 | 523 |
524 // A media stream is connected to a peer connection, enable the | 524 // A media stream is connected to a peer connection, enable the |
525 // peer connection mode for the capturer. | 525 // peer connection mode for the capturer. |
526 WebRtcAudioDeviceImpl* audio_device = | 526 WebRtcAudioDeviceImpl* audio_device = |
527 dependency_factory_->GetWebRtcAudioDevice(); | 527 dependency_factory_->GetWebRtcAudioDevice(); |
528 if (audio_device) { | 528 if (audio_device) { |
529 WebRtcAudioCapturer* capturer = audio_device->GetDefaultCapturer(); | 529 WebRtcAudioCapturer* capturer = audio_device->GetDefaultCapturer(); |
530 if (capturer) | 530 if (capturer) |
531 capturer->EnablePeerConnectionMode(); | 531 capturer->EnablePeerConnectionMode(); |
532 } | 532 } |
533 | 533 |
534 return AddStream(stream, &constraints); | 534 return AddStream(stream, &constraints); |
535 } | 535 } |
536 | 536 |
537 void RTCPeerConnectionHandler::removeStream( | 537 void RTCPeerConnectionHandler::removeStream( |
538 const WebKit::WebMediaStream& stream) { | 538 const blink::WebMediaStream& stream) { |
539 RemoveStream(stream); | 539 RemoveStream(stream); |
540 if (peer_connection_tracker_) | 540 if (peer_connection_tracker_) |
541 peer_connection_tracker_->TrackRemoveStream( | 541 peer_connection_tracker_->TrackRemoveStream( |
542 this, stream, PeerConnectionTracker::SOURCE_LOCAL); | 542 this, stream, PeerConnectionTracker::SOURCE_LOCAL); |
543 } | 543 } |
544 | 544 |
545 void RTCPeerConnectionHandler::getStats( | 545 void RTCPeerConnectionHandler::getStats( |
546 const WebKit::WebRTCStatsRequest& request) { | 546 const blink::WebRTCStatsRequest& request) { |
547 scoped_refptr<LocalRTCStatsRequest> inner_request( | 547 scoped_refptr<LocalRTCStatsRequest> inner_request( |
548 new talk_base::RefCountedObject<LocalRTCStatsRequest>(request)); | 548 new talk_base::RefCountedObject<LocalRTCStatsRequest>(request)); |
549 getStats(inner_request.get()); | 549 getStats(inner_request.get()); |
550 } | 550 } |
551 | 551 |
552 void RTCPeerConnectionHandler::getStats(LocalRTCStatsRequest* request) { | 552 void RTCPeerConnectionHandler::getStats(LocalRTCStatsRequest* request) { |
553 talk_base::scoped_refptr<webrtc::StatsObserver> observer( | 553 talk_base::scoped_refptr<webrtc::StatsObserver> observer( |
554 new talk_base::RefCountedObject<StatsResponse>(request)); | 554 new talk_base::RefCountedObject<StatsResponse>(request)); |
555 webrtc::MediaStreamTrackInterface* track = NULL; | 555 webrtc::MediaStreamTrackInterface* track = NULL; |
556 if (request->hasSelector()) { | 556 if (request->hasSelector()) { |
(...skipping 15 matching lines...) Expand all Loading... |
572 webrtc::MediaStreamTrackInterface* track) { | 572 webrtc::MediaStreamTrackInterface* track) { |
573 if (!native_peer_connection_->GetStats(observer, track)) { | 573 if (!native_peer_connection_->GetStats(observer, track)) { |
574 DVLOG(1) << "GetStats failed."; | 574 DVLOG(1) << "GetStats failed."; |
575 // TODO(hta): Consider how to get an error back. | 575 // TODO(hta): Consider how to get an error back. |
576 std::vector<webrtc::StatsReport> no_reports; | 576 std::vector<webrtc::StatsReport> no_reports; |
577 observer->OnComplete(no_reports); | 577 observer->OnComplete(no_reports); |
578 return; | 578 return; |
579 } | 579 } |
580 } | 580 } |
581 | 581 |
582 WebKit::WebRTCDataChannelHandler* RTCPeerConnectionHandler::createDataChannel( | 582 blink::WebRTCDataChannelHandler* RTCPeerConnectionHandler::createDataChannel( |
583 const WebKit::WebString& label, const WebKit::WebRTCDataChannelInit& init) { | 583 const blink::WebString& label, const blink::WebRTCDataChannelInit& init) { |
584 DVLOG(1) << "createDataChannel label " << UTF16ToUTF8(label); | 584 DVLOG(1) << "createDataChannel label " << UTF16ToUTF8(label); |
585 | 585 |
586 webrtc::DataChannelInit config; | 586 webrtc::DataChannelInit config; |
587 // TODO(jiayl): remove the deprecated reliable field once Libjingle is updated | 587 // TODO(jiayl): remove the deprecated reliable field once Libjingle is updated |
588 // to handle that. | 588 // to handle that. |
589 config.reliable = false; | 589 config.reliable = false; |
590 config.id = init.id; | 590 config.id = init.id; |
591 config.ordered = init.ordered; | 591 config.ordered = init.ordered; |
592 config.negotiated = init.negotiated; | 592 config.negotiated = init.negotiated; |
593 config.maxRetransmits = init.maxRetransmits; | 593 config.maxRetransmits = init.maxRetransmits; |
594 config.maxRetransmitTime = init.maxRetransmitTime; | 594 config.maxRetransmitTime = init.maxRetransmitTime; |
595 config.protocol = UTF16ToUTF8(init.protocol); | 595 config.protocol = UTF16ToUTF8(init.protocol); |
596 | 596 |
597 talk_base::scoped_refptr<webrtc::DataChannelInterface> webrtc_channel( | 597 talk_base::scoped_refptr<webrtc::DataChannelInterface> webrtc_channel( |
598 native_peer_connection_->CreateDataChannel(UTF16ToUTF8(label), &config)); | 598 native_peer_connection_->CreateDataChannel(UTF16ToUTF8(label), &config)); |
599 if (!webrtc_channel) { | 599 if (!webrtc_channel) { |
600 DLOG(ERROR) << "Could not create native data channel."; | 600 DLOG(ERROR) << "Could not create native data channel."; |
601 return NULL; | 601 return NULL; |
602 } | 602 } |
603 if (peer_connection_tracker_) | 603 if (peer_connection_tracker_) |
604 peer_connection_tracker_->TrackCreateDataChannel( | 604 peer_connection_tracker_->TrackCreateDataChannel( |
605 this, webrtc_channel.get(), PeerConnectionTracker::SOURCE_LOCAL); | 605 this, webrtc_channel.get(), PeerConnectionTracker::SOURCE_LOCAL); |
606 | 606 |
607 return new RtcDataChannelHandler(webrtc_channel); | 607 return new RtcDataChannelHandler(webrtc_channel); |
608 } | 608 } |
609 | 609 |
610 WebKit::WebRTCDTMFSenderHandler* RTCPeerConnectionHandler::createDTMFSender( | 610 blink::WebRTCDTMFSenderHandler* RTCPeerConnectionHandler::createDTMFSender( |
611 const WebKit::WebMediaStreamTrack& track) { | 611 const blink::WebMediaStreamTrack& track) { |
612 DVLOG(1) << "createDTMFSender."; | 612 DVLOG(1) << "createDTMFSender."; |
613 | 613 |
614 if (track.source().type() != WebKit::WebMediaStreamSource::TypeAudio) { | 614 if (track.source().type() != blink::WebMediaStreamSource::TypeAudio) { |
615 DLOG(ERROR) << "Could not create DTMF sender from a non-audio track."; | 615 DLOG(ERROR) << "Could not create DTMF sender from a non-audio track."; |
616 return NULL; | 616 return NULL; |
617 } | 617 } |
618 | 618 |
619 webrtc::AudioTrackInterface* audio_track = | 619 webrtc::AudioTrackInterface* audio_track = |
620 static_cast<webrtc::AudioTrackInterface*>( | 620 static_cast<webrtc::AudioTrackInterface*>( |
621 MediaStreamDependencyFactory::GetNativeMediaStreamTrack(track)); | 621 MediaStreamDependencyFactory::GetNativeMediaStreamTrack(track)); |
622 | 622 |
623 talk_base::scoped_refptr<webrtc::DtmfSenderInterface> sender( | 623 talk_base::scoped_refptr<webrtc::DtmfSenderInterface> sender( |
624 native_peer_connection_->CreateDtmfSender(audio_track)); | 624 native_peer_connection_->CreateDtmfSender(audio_track)); |
(...skipping 15 matching lines...) Expand all Loading... |
640 native_peer_connection_->Close(); | 640 native_peer_connection_->Close(); |
641 } | 641 } |
642 | 642 |
643 void RTCPeerConnectionHandler::OnError() { | 643 void RTCPeerConnectionHandler::OnError() { |
644 // TODO(perkj): Implement. | 644 // TODO(perkj): Implement. |
645 NOTIMPLEMENTED(); | 645 NOTIMPLEMENTED(); |
646 } | 646 } |
647 | 647 |
648 void RTCPeerConnectionHandler::OnSignalingChange( | 648 void RTCPeerConnectionHandler::OnSignalingChange( |
649 webrtc::PeerConnectionInterface::SignalingState new_state) { | 649 webrtc::PeerConnectionInterface::SignalingState new_state) { |
650 WebKit::WebRTCPeerConnectionHandlerClient::SignalingState state = | 650 blink::WebRTCPeerConnectionHandlerClient::SignalingState state = |
651 GetWebKitSignalingState(new_state); | 651 GetWebKitSignalingState(new_state); |
652 if (peer_connection_tracker_) | 652 if (peer_connection_tracker_) |
653 peer_connection_tracker_->TrackSignalingStateChange(this, state); | 653 peer_connection_tracker_->TrackSignalingStateChange(this, state); |
654 client_->didChangeSignalingState(state); | 654 client_->didChangeSignalingState(state); |
655 } | 655 } |
656 | 656 |
657 // Called any time the IceConnectionState changes | 657 // Called any time the IceConnectionState changes |
658 void RTCPeerConnectionHandler::OnIceConnectionChange( | 658 void RTCPeerConnectionHandler::OnIceConnectionChange( |
659 webrtc::PeerConnectionInterface::IceConnectionState new_state) { | 659 webrtc::PeerConnectionInterface::IceConnectionState new_state) { |
660 WebKit::WebRTCPeerConnectionHandlerClient::ICEConnectionState state = | 660 blink::WebRTCPeerConnectionHandlerClient::ICEConnectionState state = |
661 GetWebKitIceConnectionState(new_state); | 661 GetWebKitIceConnectionState(new_state); |
662 if (peer_connection_tracker_) | 662 if (peer_connection_tracker_) |
663 peer_connection_tracker_->TrackIceConnectionStateChange(this, state); | 663 peer_connection_tracker_->TrackIceConnectionStateChange(this, state); |
664 client_->didChangeICEConnectionState(state); | 664 client_->didChangeICEConnectionState(state); |
665 } | 665 } |
666 | 666 |
667 // Called any time the IceGatheringState changes | 667 // Called any time the IceGatheringState changes |
668 void RTCPeerConnectionHandler::OnIceGatheringChange( | 668 void RTCPeerConnectionHandler::OnIceGatheringChange( |
669 webrtc::PeerConnectionInterface::IceGatheringState new_state) { | 669 webrtc::PeerConnectionInterface::IceGatheringState new_state) { |
670 if (new_state == webrtc::PeerConnectionInterface::kIceGatheringComplete) { | 670 if (new_state == webrtc::PeerConnectionInterface::kIceGatheringComplete) { |
671 // If ICE gathering is completed, generate a NULL ICE candidate, | 671 // If ICE gathering is completed, generate a NULL ICE candidate, |
672 // to signal end of candidates. | 672 // to signal end of candidates. |
673 WebKit::WebRTCICECandidate null_candidate; | 673 blink::WebRTCICECandidate null_candidate; |
674 client_->didGenerateICECandidate(null_candidate); | 674 client_->didGenerateICECandidate(null_candidate); |
675 } | 675 } |
676 | 676 |
677 WebKit::WebRTCPeerConnectionHandlerClient::ICEGatheringState state = | 677 blink::WebRTCPeerConnectionHandlerClient::ICEGatheringState state = |
678 GetWebKitIceGatheringState(new_state); | 678 GetWebKitIceGatheringState(new_state); |
679 if (peer_connection_tracker_) | 679 if (peer_connection_tracker_) |
680 peer_connection_tracker_->TrackIceGatheringStateChange(this, state); | 680 peer_connection_tracker_->TrackIceGatheringStateChange(this, state); |
681 client_->didChangeICEGatheringState(state); | 681 client_->didChangeICEGatheringState(state); |
682 } | 682 } |
683 | 683 |
684 void RTCPeerConnectionHandler::OnAddStream( | 684 void RTCPeerConnectionHandler::OnAddStream( |
685 webrtc::MediaStreamInterface* stream_interface) { | 685 webrtc::MediaStreamInterface* stream_interface) { |
686 DCHECK(stream_interface); | 686 DCHECK(stream_interface); |
687 DCHECK(remote_streams_.find(stream_interface) == remote_streams_.end()); | 687 DCHECK(remote_streams_.find(stream_interface) == remote_streams_.end()); |
(...skipping 15 matching lines...) Expand all Loading... |
703 void RTCPeerConnectionHandler::OnRemoveStream( | 703 void RTCPeerConnectionHandler::OnRemoveStream( |
704 webrtc::MediaStreamInterface* stream_interface) { | 704 webrtc::MediaStreamInterface* stream_interface) { |
705 DCHECK(stream_interface); | 705 DCHECK(stream_interface); |
706 RemoteStreamMap::iterator it = remote_streams_.find(stream_interface); | 706 RemoteStreamMap::iterator it = remote_streams_.find(stream_interface); |
707 if (it == remote_streams_.end()) { | 707 if (it == remote_streams_.end()) { |
708 NOTREACHED() << "Stream not found"; | 708 NOTREACHED() << "Stream not found"; |
709 return; | 709 return; |
710 } | 710 } |
711 | 711 |
712 scoped_ptr<RemoteMediaStreamImpl> remote_stream(it->second); | 712 scoped_ptr<RemoteMediaStreamImpl> remote_stream(it->second); |
713 const WebKit::WebMediaStream& webkit_stream = remote_stream->webkit_stream(); | 713 const blink::WebMediaStream& webkit_stream = remote_stream->webkit_stream(); |
714 DCHECK(!webkit_stream.isNull()); | 714 DCHECK(!webkit_stream.isNull()); |
715 remote_streams_.erase(it); | 715 remote_streams_.erase(it); |
716 | 716 |
717 if (peer_connection_tracker_) | 717 if (peer_connection_tracker_) |
718 peer_connection_tracker_->TrackRemoveStream( | 718 peer_connection_tracker_->TrackRemoveStream( |
719 this, webkit_stream, PeerConnectionTracker::SOURCE_REMOTE); | 719 this, webkit_stream, PeerConnectionTracker::SOURCE_REMOTE); |
720 | 720 |
721 client_->didRemoveRemoteStream(webkit_stream); | 721 client_->didRemoveRemoteStream(webkit_stream); |
722 } | 722 } |
723 | 723 |
724 void RTCPeerConnectionHandler::OnIceCandidate( | 724 void RTCPeerConnectionHandler::OnIceCandidate( |
725 const webrtc::IceCandidateInterface* candidate) { | 725 const webrtc::IceCandidateInterface* candidate) { |
726 DCHECK(candidate); | 726 DCHECK(candidate); |
727 std::string sdp; | 727 std::string sdp; |
728 if (!candidate->ToString(&sdp)) { | 728 if (!candidate->ToString(&sdp)) { |
729 NOTREACHED() << "OnIceCandidate: Could not get SDP string."; | 729 NOTREACHED() << "OnIceCandidate: Could not get SDP string."; |
730 return; | 730 return; |
731 } | 731 } |
732 WebKit::WebRTCICECandidate web_candidate; | 732 blink::WebRTCICECandidate web_candidate; |
733 web_candidate.initialize(UTF8ToUTF16(sdp), | 733 web_candidate.initialize(UTF8ToUTF16(sdp), |
734 UTF8ToUTF16(candidate->sdp_mid()), | 734 UTF8ToUTF16(candidate->sdp_mid()), |
735 candidate->sdp_mline_index()); | 735 candidate->sdp_mline_index()); |
736 if (peer_connection_tracker_) | 736 if (peer_connection_tracker_) |
737 peer_connection_tracker_->TrackAddIceCandidate( | 737 peer_connection_tracker_->TrackAddIceCandidate( |
738 this, web_candidate, PeerConnectionTracker::SOURCE_LOCAL); | 738 this, web_candidate, PeerConnectionTracker::SOURCE_LOCAL); |
739 | 739 |
740 client_->didGenerateICECandidate(web_candidate); | 740 client_->didGenerateICECandidate(web_candidate); |
741 } | 741 } |
742 | 742 |
(...skipping 13 matching lines...) Expand all Loading... |
756 peer_connection_tracker_->TrackOnRenegotiationNeeded(this); | 756 peer_connection_tracker_->TrackOnRenegotiationNeeded(this); |
757 client_->negotiationNeeded(); | 757 client_->negotiationNeeded(); |
758 } | 758 } |
759 | 759 |
760 PeerConnectionTracker* RTCPeerConnectionHandler::peer_connection_tracker() { | 760 PeerConnectionTracker* RTCPeerConnectionHandler::peer_connection_tracker() { |
761 return peer_connection_tracker_; | 761 return peer_connection_tracker_; |
762 } | 762 } |
763 | 763 |
764 webrtc::SessionDescriptionInterface* | 764 webrtc::SessionDescriptionInterface* |
765 RTCPeerConnectionHandler::CreateNativeSessionDescription( | 765 RTCPeerConnectionHandler::CreateNativeSessionDescription( |
766 const WebKit::WebRTCSessionDescription& description, | 766 const blink::WebRTCSessionDescription& description, |
767 webrtc::SdpParseError* error) { | 767 webrtc::SdpParseError* error) { |
768 std::string sdp = UTF16ToUTF8(description.sdp()); | 768 std::string sdp = UTF16ToUTF8(description.sdp()); |
769 std::string type = UTF16ToUTF8(description.type()); | 769 std::string type = UTF16ToUTF8(description.type()); |
770 webrtc::SessionDescriptionInterface* native_desc = | 770 webrtc::SessionDescriptionInterface* native_desc = |
771 dependency_factory_->CreateSessionDescription(type, sdp, error); | 771 dependency_factory_->CreateSessionDescription(type, sdp, error); |
772 | 772 |
773 LOG_IF(ERROR, !native_desc) << "Failed to create native session description." | 773 LOG_IF(ERROR, !native_desc) << "Failed to create native session description." |
774 << " Type: " << type << " SDP: " << sdp; | 774 << " Type: " << type << " SDP: " << sdp; |
775 | 775 |
776 return native_desc; | 776 return native_desc; |
777 } | 777 } |
778 | 778 |
779 } // namespace content | 779 } // namespace content |
OLD | NEW |