Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(231)

Side by Side Diff: content/renderer/media/rtc_peer_connection_handler.cc

Issue 16294003: Update content/ to use scoped_refptr<T>::get() rather than implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 private: 222 private:
223 WebKit::WebRTCVoidRequest webkit_request_; 223 WebKit::WebRTCVoidRequest webkit_request_;
224 SessionDescriptionRequestTracker tracker_; 224 SessionDescriptionRequestTracker tracker_;
225 }; 225 };
226 226
227 // Class mapping responses from calls to libjingle 227 // Class mapping responses from calls to libjingle
228 // GetStats into a WebKit::WebRTCStatsCallback. 228 // GetStats into a WebKit::WebRTCStatsCallback.
229 class StatsResponse : public webrtc::StatsObserver { 229 class StatsResponse : public webrtc::StatsObserver {
230 public: 230 public:
231 explicit StatsResponse(const scoped_refptr<LocalRTCStatsRequest>& request) 231 explicit StatsResponse(const scoped_refptr<LocalRTCStatsRequest>& request)
232 : request_(request), 232 : request_(request.get()), response_(request_->createResponse()) {}
233 response_(request_->createResponse()) {}
234 233
235 virtual void OnComplete( 234 virtual void OnComplete(
236 const std::vector<webrtc::StatsReport>& reports) OVERRIDE { 235 const std::vector<webrtc::StatsReport>& reports) OVERRIDE {
237 for (std::vector<webrtc::StatsReport>::const_iterator it = reports.begin(); 236 for (std::vector<webrtc::StatsReport>::const_iterator it = reports.begin();
238 it != reports.end(); ++it) { 237 it != reports.end(); ++it) {
239 if (it->values.size() > 0) { 238 if (it->values.size() > 0) {
240 AddReport(*it); 239 AddReport(*it);
241 } 240 }
242 } 241 }
243 request_->requestSucceeded(response_); 242 request_->requestSucceeded(response_);
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 switches::kEnableSCTPDataChannels)) { 352 switches::kEnableSCTPDataChannels)) {
354 // TODO(jiayl): replace the hard coded string with 353 // TODO(jiayl): replace the hard coded string with
355 // webrtc::MediaConstraintsInterface::kEnableSctpDataChannels when 354 // webrtc::MediaConstraintsInterface::kEnableSctpDataChannels when
356 // the Libjingle change is rolled. 355 // the Libjingle change is rolled.
357 constraints.AddOptional("internalSctpDataChannels", "true"); 356 constraints.AddOptional("internalSctpDataChannels", "true");
358 } 357 }
359 358
360 native_peer_connection_ = 359 native_peer_connection_ =
361 dependency_factory_->CreatePeerConnection( 360 dependency_factory_->CreatePeerConnection(
362 servers, &constraints, frame_, this); 361 servers, &constraints, frame_, this);
363 if (!native_peer_connection_) { 362 if (!native_peer_connection_.get()) {
364 LOG(ERROR) << "Failed to initialize native PeerConnection."; 363 LOG(ERROR) << "Failed to initialize native PeerConnection.";
365 return false; 364 return false;
366 } 365 }
367 if (peer_connection_tracker_) 366 if (peer_connection_tracker_)
368 peer_connection_tracker_->RegisterPeerConnection( 367 peer_connection_tracker_->RegisterPeerConnection(
369 this, servers, constraints, frame_); 368 this, servers, constraints, frame_);
370 369
371 return true; 370 return true;
372 } 371 }
373 372
374 bool RTCPeerConnectionHandler::InitializeForTest( 373 bool RTCPeerConnectionHandler::InitializeForTest(
375 const WebKit::WebRTCConfiguration& server_configuration, 374 const WebKit::WebRTCConfiguration& server_configuration,
376 const WebKit::WebMediaConstraints& options, 375 const WebKit::WebMediaConstraints& options,
377 PeerConnectionTracker* peer_connection_tracker) { 376 PeerConnectionTracker* peer_connection_tracker) {
378 webrtc::PeerConnectionInterface::IceServers servers; 377 webrtc::PeerConnectionInterface::IceServers servers;
379 GetNativeIceServers(server_configuration, &servers); 378 GetNativeIceServers(server_configuration, &servers);
380 379
381 RTCMediaConstraints constraints(options); 380 RTCMediaConstraints constraints(options);
382 native_peer_connection_ = 381 native_peer_connection_ =
383 dependency_factory_->CreatePeerConnection( 382 dependency_factory_->CreatePeerConnection(
384 servers, &constraints, NULL, this); 383 servers, &constraints, NULL, this);
385 if (!native_peer_connection_) { 384 if (!native_peer_connection_.get()) {
386 LOG(ERROR) << "Failed to initialize native PeerConnection."; 385 LOG(ERROR) << "Failed to initialize native PeerConnection.";
387 return false; 386 return false;
388 } 387 }
389 peer_connection_tracker_ = peer_connection_tracker; 388 peer_connection_tracker_ = peer_connection_tracker;
390 return true; 389 return true;
391 } 390 }
392 391
393 void RTCPeerConnectionHandler::createOffer( 392 void RTCPeerConnectionHandler::createOffer(
394 const WebKit::WebRTCSessionDescriptionRequest& request, 393 const WebKit::WebRTCSessionDescriptionRequest& request,
395 const WebKit::WebMediaConstraints& options) { 394 const WebKit::WebMediaConstraints& options) {
396 scoped_refptr<CreateSessionDescriptionRequest> description_request( 395 scoped_refptr<CreateSessionDescriptionRequest> description_request(
397 new talk_base::RefCountedObject<CreateSessionDescriptionRequest>( 396 new talk_base::RefCountedObject<CreateSessionDescriptionRequest>(
398 request, this, PeerConnectionTracker::ACTION_CREATE_OFFER)); 397 request, this, PeerConnectionTracker::ACTION_CREATE_OFFER));
399 RTCMediaConstraints constraints(options); 398 RTCMediaConstraints constraints(options);
400 native_peer_connection_->CreateOffer(description_request, &constraints); 399 native_peer_connection_->CreateOffer(description_request.get(), &constraints);
401 400
402 if (peer_connection_tracker_) 401 if (peer_connection_tracker_)
403 peer_connection_tracker_->TrackCreateOffer(this, constraints); 402 peer_connection_tracker_->TrackCreateOffer(this, constraints);
404 } 403 }
405 404
406 void RTCPeerConnectionHandler::createAnswer( 405 void RTCPeerConnectionHandler::createAnswer(
407 const WebKit::WebRTCSessionDescriptionRequest& request, 406 const WebKit::WebRTCSessionDescriptionRequest& request,
408 const WebKit::WebMediaConstraints& options) { 407 const WebKit::WebMediaConstraints& options) {
409 scoped_refptr<CreateSessionDescriptionRequest> description_request( 408 scoped_refptr<CreateSessionDescriptionRequest> description_request(
410 new talk_base::RefCountedObject<CreateSessionDescriptionRequest>( 409 new talk_base::RefCountedObject<CreateSessionDescriptionRequest>(
411 request, this, PeerConnectionTracker::ACTION_CREATE_ANSWER)); 410 request, this, PeerConnectionTracker::ACTION_CREATE_ANSWER));
412 RTCMediaConstraints constraints(options); 411 RTCMediaConstraints constraints(options);
413 native_peer_connection_->CreateAnswer(description_request, &constraints); 412 native_peer_connection_->CreateAnswer(description_request.get(),
413 &constraints);
414 414
415 if (peer_connection_tracker_) 415 if (peer_connection_tracker_)
416 peer_connection_tracker_->TrackCreateAnswer(this, constraints); 416 peer_connection_tracker_->TrackCreateAnswer(this, constraints);
417 } 417 }
418 418
419 void RTCPeerConnectionHandler::setLocalDescription( 419 void RTCPeerConnectionHandler::setLocalDescription(
420 const WebKit::WebRTCVoidRequest& request, 420 const WebKit::WebRTCVoidRequest& request,
421 const WebKit::WebRTCSessionDescription& description) { 421 const WebKit::WebRTCSessionDescription& description) {
422 webrtc::SdpParseError error; 422 webrtc::SdpParseError error;
423 webrtc::SessionDescriptionInterface* native_desc = 423 webrtc::SessionDescriptionInterface* native_desc =
424 CreateNativeSessionDescription(description, &error); 424 CreateNativeSessionDescription(description, &error);
425 if (!native_desc) { 425 if (!native_desc) {
426 std::string reason_str = "Failed to parse SessionDescription. "; 426 std::string reason_str = "Failed to parse SessionDescription. ";
427 reason_str.append(error.line); 427 reason_str.append(error.line);
428 reason_str.append(" "); 428 reason_str.append(" ");
429 reason_str.append(error.description); 429 reason_str.append(error.description);
430 LOG(ERROR) << reason_str; 430 LOG(ERROR) << reason_str;
431 request.requestFailed(WebKit::WebString::fromUTF8(reason_str)); 431 request.requestFailed(WebKit::WebString::fromUTF8(reason_str));
432 return; 432 return;
433 } 433 }
434 if (peer_connection_tracker_) 434 if (peer_connection_tracker_)
435 peer_connection_tracker_->TrackSetSessionDescription( 435 peer_connection_tracker_->TrackSetSessionDescription(
436 this, description, PeerConnectionTracker::SOURCE_LOCAL); 436 this, description, PeerConnectionTracker::SOURCE_LOCAL);
437 437
438 scoped_refptr<SetSessionDescriptionRequest> set_request( 438 scoped_refptr<SetSessionDescriptionRequest> set_request(
439 new talk_base::RefCountedObject<SetSessionDescriptionRequest>( 439 new talk_base::RefCountedObject<SetSessionDescriptionRequest>(
440 request, this, PeerConnectionTracker::ACTION_SET_LOCAL_DESCRIPTION)); 440 request, this, PeerConnectionTracker::ACTION_SET_LOCAL_DESCRIPTION));
441 native_peer_connection_->SetLocalDescription(set_request, native_desc); 441 native_peer_connection_->SetLocalDescription(set_request.get(), native_desc);
442 } 442 }
443 443
444 void RTCPeerConnectionHandler::setRemoteDescription( 444 void RTCPeerConnectionHandler::setRemoteDescription(
445 const WebKit::WebRTCVoidRequest& request, 445 const WebKit::WebRTCVoidRequest& request,
446 const WebKit::WebRTCSessionDescription& description) { 446 const WebKit::WebRTCSessionDescription& description) {
447 webrtc::SdpParseError error; 447 webrtc::SdpParseError error;
448 webrtc::SessionDescriptionInterface* native_desc = 448 webrtc::SessionDescriptionInterface* native_desc =
449 CreateNativeSessionDescription(description, &error); 449 CreateNativeSessionDescription(description, &error);
450 if (!native_desc) { 450 if (!native_desc) {
451 std::string reason_str = "Failed to parse SessionDescription. "; 451 std::string reason_str = "Failed to parse SessionDescription. ";
452 reason_str.append(error.line); 452 reason_str.append(error.line);
453 reason_str.append(" "); 453 reason_str.append(" ");
454 reason_str.append(error.description); 454 reason_str.append(error.description);
455 LOG(ERROR) << reason_str; 455 LOG(ERROR) << reason_str;
456 request.requestFailed(WebKit::WebString::fromUTF8(reason_str)); 456 request.requestFailed(WebKit::WebString::fromUTF8(reason_str));
457 return; 457 return;
458 } 458 }
459 if (peer_connection_tracker_) 459 if (peer_connection_tracker_)
460 peer_connection_tracker_->TrackSetSessionDescription( 460 peer_connection_tracker_->TrackSetSessionDescription(
461 this, description, PeerConnectionTracker::SOURCE_REMOTE); 461 this, description, PeerConnectionTracker::SOURCE_REMOTE);
462 462
463 scoped_refptr<SetSessionDescriptionRequest> set_request( 463 scoped_refptr<SetSessionDescriptionRequest> set_request(
464 new talk_base::RefCountedObject<SetSessionDescriptionRequest>( 464 new talk_base::RefCountedObject<SetSessionDescriptionRequest>(
465 request, this, PeerConnectionTracker::ACTION_SET_REMOTE_DESCRIPTION)); 465 request, this, PeerConnectionTracker::ACTION_SET_REMOTE_DESCRIPTION));
466 native_peer_connection_->SetRemoteDescription(set_request, native_desc); 466 native_peer_connection_->SetRemoteDescription(set_request.get(), native_desc);
467 } 467 }
468 468
469 WebKit::WebRTCSessionDescription 469 WebKit::WebRTCSessionDescription
470 RTCPeerConnectionHandler::localDescription() { 470 RTCPeerConnectionHandler::localDescription() {
471 const webrtc::SessionDescriptionInterface* native_desc = 471 const webrtc::SessionDescriptionInterface* native_desc =
472 native_peer_connection_->local_description(); 472 native_peer_connection_->local_description();
473 WebKit::WebRTCSessionDescription description = 473 WebKit::WebRTCSessionDescription description =
474 CreateWebKitSessionDescription(native_desc); 474 CreateWebKitSessionDescription(native_desc);
475 return description; 475 return description;
476 } 476 }
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 RemoveStream(stream); 537 RemoveStream(stream);
538 if (peer_connection_tracker_) 538 if (peer_connection_tracker_)
539 peer_connection_tracker_->TrackRemoveStream( 539 peer_connection_tracker_->TrackRemoveStream(
540 this, stream, PeerConnectionTracker::SOURCE_LOCAL); 540 this, stream, PeerConnectionTracker::SOURCE_LOCAL);
541 } 541 }
542 542
543 void RTCPeerConnectionHandler::getStats( 543 void RTCPeerConnectionHandler::getStats(
544 const WebKit::WebRTCStatsRequest& request) { 544 const WebKit::WebRTCStatsRequest& request) {
545 scoped_refptr<LocalRTCStatsRequest> inner_request( 545 scoped_refptr<LocalRTCStatsRequest> inner_request(
546 new talk_base::RefCountedObject<LocalRTCStatsRequest>(request)); 546 new talk_base::RefCountedObject<LocalRTCStatsRequest>(request));
547 getStats(inner_request); 547 getStats(inner_request.get());
548 } 548 }
549 549
550 void RTCPeerConnectionHandler::getStats(LocalRTCStatsRequest* request) { 550 void RTCPeerConnectionHandler::getStats(LocalRTCStatsRequest* request) {
551 talk_base::scoped_refptr<webrtc::StatsObserver> observer( 551 talk_base::scoped_refptr<webrtc::StatsObserver> observer(
552 new talk_base::RefCountedObject<StatsResponse>(request)); 552 new talk_base::RefCountedObject<StatsResponse>(request));
553 webrtc::MediaStreamTrackInterface* track = NULL; 553 webrtc::MediaStreamTrackInterface* track = NULL;
554 if (request->hasSelector()) { 554 if (request->hasSelector()) {
555 track = GetNativeMediaStreamTrack(request->stream(), 555 track = GetNativeMediaStreamTrack(request->stream(),
556 request->component()); 556 request->component());
557 if (!track) { 557 if (!track) {
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
760 webrtc::SessionDescriptionInterface* native_desc = 760 webrtc::SessionDescriptionInterface* native_desc =
761 dependency_factory_->CreateSessionDescription(type, sdp, error); 761 dependency_factory_->CreateSessionDescription(type, sdp, error);
762 762
763 LOG_IF(ERROR, !native_desc) << "Failed to create native session description." 763 LOG_IF(ERROR, !native_desc) << "Failed to create native session description."
764 << " Type: " << type << " SDP: " << sdp; 764 << " Type: " << type << " SDP: " << sdp;
765 765
766 return native_desc; 766 return native_desc;
767 } 767 }
768 768
769 } // namespace content 769 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/renderer_webaudiodevice_impl.cc ('k') | content/renderer/media/rtc_peer_connection_handler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698