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 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 const WebKit::WebRTCConfiguration& server_configuration, | 172 const WebKit::WebRTCConfiguration& server_configuration, |
173 const WebKit::WebMediaConstraints& options) { | 173 const WebKit::WebMediaConstraints& options) { |
174 DCHECK(frame_); | 174 DCHECK(frame_); |
175 webrtc::JsepInterface::IceServers servers; | 175 webrtc::JsepInterface::IceServers servers; |
176 GetNativeIceServers(server_configuration, &servers); | 176 GetNativeIceServers(server_configuration, &servers); |
177 | 177 |
178 RTCMediaConstraints constraints(options); | 178 RTCMediaConstraints constraints(options); |
179 native_peer_connection_ = | 179 native_peer_connection_ = |
180 dependency_factory_->CreatePeerConnection( | 180 dependency_factory_->CreatePeerConnection( |
181 servers, &constraints, frame_, this); | 181 servers, &constraints, frame_, this); |
182 if (!native_peer_connection_) { | 182 if (!native_peer_connection_.get()) { |
183 LOG(ERROR) << "Failed to initialize native PeerConnection."; | 183 LOG(ERROR) << "Failed to initialize native PeerConnection."; |
184 return false; | 184 return false; |
185 } | 185 } |
186 return true; | 186 return true; |
187 } | 187 } |
188 | 188 |
189 bool RTCPeerConnectionHandler::InitializeForTest( | 189 bool RTCPeerConnectionHandler::InitializeForTest( |
190 const WebKit::WebRTCConfiguration& server_configuration, | 190 const WebKit::WebRTCConfiguration& server_configuration, |
191 const WebKit::WebMediaConstraints& options) { | 191 const WebKit::WebMediaConstraints& options) { |
192 webrtc::JsepInterface::IceServers servers; | 192 webrtc::JsepInterface::IceServers servers; |
193 GetNativeIceServers(server_configuration, &servers); | 193 GetNativeIceServers(server_configuration, &servers); |
194 | 194 |
195 RTCMediaConstraints constraints(options); | 195 RTCMediaConstraints constraints(options); |
196 native_peer_connection_ = | 196 native_peer_connection_ = |
197 dependency_factory_->CreatePeerConnection( | 197 dependency_factory_->CreatePeerConnection( |
198 servers, &constraints, NULL, this); | 198 servers, &constraints, NULL, this); |
199 if (!native_peer_connection_) { | 199 if (!native_peer_connection_.get()) { |
200 LOG(ERROR) << "Failed to initialize native PeerConnection."; | 200 LOG(ERROR) << "Failed to initialize native PeerConnection."; |
201 return false; | 201 return false; |
202 } | 202 } |
203 return true; | 203 return true; |
204 } | 204 } |
205 | 205 |
206 void RTCPeerConnectionHandler::createOffer( | 206 void RTCPeerConnectionHandler::createOffer( |
207 const WebKit::WebRTCSessionDescriptionRequest& request, | 207 const WebKit::WebRTCSessionDescriptionRequest& request, |
208 const WebKit::WebMediaConstraints& options) { | 208 const WebKit::WebMediaConstraints& options) { |
209 scoped_refptr<CreateSessionDescriptionRequest> description_request( | 209 scoped_refptr<CreateSessionDescriptionRequest> description_request( |
210 new talk_base::RefCountedObject<CreateSessionDescriptionRequest>( | 210 new talk_base::RefCountedObject<CreateSessionDescriptionRequest>( |
211 request)); | 211 request)); |
212 RTCMediaConstraints constraints(options); | 212 RTCMediaConstraints constraints(options); |
213 native_peer_connection_->CreateOffer(description_request, &constraints); | 213 native_peer_connection_->CreateOffer(description_request.get(), &constraints); |
214 } | 214 } |
215 | 215 |
216 void RTCPeerConnectionHandler::createAnswer( | 216 void RTCPeerConnectionHandler::createAnswer( |
217 const WebKit::WebRTCSessionDescriptionRequest& request, | 217 const WebKit::WebRTCSessionDescriptionRequest& request, |
218 const WebKit::WebMediaConstraints& options) { | 218 const WebKit::WebMediaConstraints& options) { |
219 scoped_refptr<CreateSessionDescriptionRequest> description_request( | 219 scoped_refptr<CreateSessionDescriptionRequest> description_request( |
220 new talk_base::RefCountedObject<CreateSessionDescriptionRequest>( | 220 new talk_base::RefCountedObject<CreateSessionDescriptionRequest>( |
221 request)); | 221 request)); |
222 RTCMediaConstraints constraints(options); | 222 RTCMediaConstraints constraints(options); |
223 native_peer_connection_->CreateAnswer(description_request, &constraints); | 223 native_peer_connection_-> |
| 224 CreateAnswer(description_request.get(), &constraints); |
224 } | 225 } |
225 | 226 |
226 void RTCPeerConnectionHandler::setLocalDescription( | 227 void RTCPeerConnectionHandler::setLocalDescription( |
227 const WebKit::WebRTCVoidRequest& request, | 228 const WebKit::WebRTCVoidRequest& request, |
228 const WebKit::WebRTCSessionDescription& description) { | 229 const WebKit::WebRTCSessionDescription& description) { |
229 webrtc::SessionDescriptionInterface* native_desc = | 230 webrtc::SessionDescriptionInterface* native_desc = |
230 CreateNativeSessionDescription(description); | 231 CreateNativeSessionDescription(description); |
231 if (!native_desc) { | 232 if (!native_desc) { |
232 const char kReason[] = "Failed to parse SessionDescription."; | 233 const char kReason[] = "Failed to parse SessionDescription."; |
233 LOG(ERROR) << kReason; | 234 LOG(ERROR) << kReason; |
234 WebKit::WebString reason(kReason); | 235 WebKit::WebString reason(kReason); |
235 request.requestFailed(reason); | 236 request.requestFailed(reason); |
236 return; | 237 return; |
237 } | 238 } |
238 scoped_refptr<SetSessionDescriptionRequest> set_request( | 239 scoped_refptr<SetSessionDescriptionRequest> set_request( |
239 new talk_base::RefCountedObject<SetSessionDescriptionRequest>(request)); | 240 new talk_base::RefCountedObject<SetSessionDescriptionRequest>(request)); |
240 native_peer_connection_->SetLocalDescription(set_request, native_desc); | 241 native_peer_connection_->SetLocalDescription(set_request.get(), native_desc); |
241 } | 242 } |
242 | 243 |
243 void RTCPeerConnectionHandler::setRemoteDescription( | 244 void RTCPeerConnectionHandler::setRemoteDescription( |
244 const WebKit::WebRTCVoidRequest& request, | 245 const WebKit::WebRTCVoidRequest& request, |
245 const WebKit::WebRTCSessionDescription& description) { | 246 const WebKit::WebRTCSessionDescription& description) { |
246 webrtc::SessionDescriptionInterface* native_desc = | 247 webrtc::SessionDescriptionInterface* native_desc = |
247 CreateNativeSessionDescription(description); | 248 CreateNativeSessionDescription(description); |
248 if (!native_desc) { | 249 if (!native_desc) { |
249 const char kReason[] = "Failed to parse SessionDescription."; | 250 const char kReason[] = "Failed to parse SessionDescription."; |
250 LOG(ERROR) << kReason; | 251 LOG(ERROR) << kReason; |
251 WebKit::WebString reason(kReason); | 252 WebKit::WebString reason(kReason); |
252 request.requestFailed(reason); | 253 request.requestFailed(reason); |
253 return; | 254 return; |
254 } | 255 } |
255 scoped_refptr<SetSessionDescriptionRequest> set_request( | 256 scoped_refptr<SetSessionDescriptionRequest> set_request( |
256 new talk_base::RefCountedObject<SetSessionDescriptionRequest>(request)); | 257 new talk_base::RefCountedObject<SetSessionDescriptionRequest>(request)); |
257 native_peer_connection_->SetRemoteDescription(set_request, native_desc); | 258 native_peer_connection_->SetRemoteDescription(set_request.get(), native_desc); |
258 } | 259 } |
259 | 260 |
260 WebKit::WebRTCSessionDescription | 261 WebKit::WebRTCSessionDescription |
261 RTCPeerConnectionHandler::localDescription() { | 262 RTCPeerConnectionHandler::localDescription() { |
262 const webrtc::SessionDescriptionInterface* native_desc = | 263 const webrtc::SessionDescriptionInterface* native_desc = |
263 native_peer_connection_->local_description(); | 264 native_peer_connection_->local_description(); |
264 WebKit::WebRTCSessionDescription description = | 265 WebKit::WebRTCSessionDescription description = |
265 CreateWebKitSessionDescription(native_desc); | 266 CreateWebKitSessionDescription(native_desc); |
266 return description; | 267 return description; |
267 } | 268 } |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 webrtc::SessionDescriptionInterface* native_desc = | 405 webrtc::SessionDescriptionInterface* native_desc = |
405 dependency_factory_->CreateSessionDescription(type, sdp); | 406 dependency_factory_->CreateSessionDescription(type, sdp); |
406 | 407 |
407 LOG_IF(ERROR, !native_desc) << "Failed to create native session description." | 408 LOG_IF(ERROR, !native_desc) << "Failed to create native session description." |
408 << " Type: " << type << " SDP: " << sdp; | 409 << " Type: " << type << " SDP: " << sdp; |
409 | 410 |
410 return native_desc; | 411 return native_desc; |
411 } | 412 } |
412 | 413 |
413 } // namespace content | 414 } // namespace content |
OLD | NEW |