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

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

Issue 429253003: Webrtc deps roll. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 6 years, 4 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 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 } 285 }
286 } 286 }
287 287
288 void AddStatistic(int idx, const std::string& name, 288 void AddStatistic(int idx, const std::string& name,
289 const std::string& value) { 289 const std::string& value) {
290 response_->addStatistic(idx, 290 response_->addStatistic(idx,
291 blink::WebString::fromUTF8(name), 291 blink::WebString::fromUTF8(name),
292 blink::WebString::fromUTF8(value)); 292 blink::WebString::fromUTF8(value));
293 } 293 }
294 294
295 talk_base::scoped_refptr<LocalRTCStatsRequest> request_; 295 rtc::scoped_refptr<LocalRTCStatsRequest> request_;
296 talk_base::scoped_refptr<LocalRTCStatsResponse> response_; 296 rtc::scoped_refptr<LocalRTCStatsResponse> response_;
297 }; 297 };
298 298
299 // Implementation of LocalRTCStatsRequest. 299 // Implementation of LocalRTCStatsRequest.
300 LocalRTCStatsRequest::LocalRTCStatsRequest(blink::WebRTCStatsRequest impl) 300 LocalRTCStatsRequest::LocalRTCStatsRequest(blink::WebRTCStatsRequest impl)
301 : impl_(impl), 301 : impl_(impl),
302 response_(NULL) { 302 response_(NULL) {
303 } 303 }
304 304
305 LocalRTCStatsRequest::LocalRTCStatsRequest() {} 305 LocalRTCStatsRequest::LocalRTCStatsRequest() {}
306 LocalRTCStatsRequest::~LocalRTCStatsRequest() {} 306 LocalRTCStatsRequest::~LocalRTCStatsRequest() {}
307 307
308 bool LocalRTCStatsRequest::hasSelector() const { 308 bool LocalRTCStatsRequest::hasSelector() const {
309 return impl_.hasSelector(); 309 return impl_.hasSelector();
310 } 310 }
311 311
312 blink::WebMediaStreamTrack LocalRTCStatsRequest::component() const { 312 blink::WebMediaStreamTrack LocalRTCStatsRequest::component() const {
313 return impl_.component(); 313 return impl_.component();
314 } 314 }
315 315
316 scoped_refptr<LocalRTCStatsResponse> LocalRTCStatsRequest::createResponse() { 316 scoped_refptr<LocalRTCStatsResponse> LocalRTCStatsRequest::createResponse() {
317 DCHECK(!response_); 317 DCHECK(!response_);
318 response_ = new talk_base::RefCountedObject<LocalRTCStatsResponse>( 318 response_ = new rtc::RefCountedObject<LocalRTCStatsResponse>(
319 impl_.createResponse()); 319 impl_.createResponse());
320 return response_.get(); 320 return response_.get();
321 } 321 }
322 322
323 void LocalRTCStatsRequest::requestSucceeded( 323 void LocalRTCStatsRequest::requestSucceeded(
324 const LocalRTCStatsResponse* response) { 324 const LocalRTCStatsResponse* response) {
325 impl_.requestSucceeded(response->webKitStatsResponse()); 325 impl_.requestSucceeded(response->webKitStatsResponse());
326 } 326 }
327 327
328 // Implementation of LocalRTCStatsResponse. 328 // Implementation of LocalRTCStatsResponse.
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 config, &constraints, frame_, this); 465 config, &constraints, frame_, this);
466 466
467 if (!native_peer_connection_.get()) { 467 if (!native_peer_connection_.get()) {
468 LOG(ERROR) << "Failed to initialize native PeerConnection."; 468 LOG(ERROR) << "Failed to initialize native PeerConnection.";
469 return false; 469 return false;
470 } 470 }
471 if (peer_connection_tracker_) 471 if (peer_connection_tracker_)
472 peer_connection_tracker_->RegisterPeerConnection( 472 peer_connection_tracker_->RegisterPeerConnection(
473 this, config, constraints, frame_); 473 this, config, constraints, frame_);
474 474
475 uma_observer_ = new talk_base::RefCountedObject<PeerConnectionUMAObserver>(); 475 uma_observer_ = new rtc::RefCountedObject<PeerConnectionUMAObserver>();
476 native_peer_connection_->RegisterUMAObserver(uma_observer_.get()); 476 native_peer_connection_->RegisterUMAObserver(uma_observer_.get());
477 return true; 477 return true;
478 } 478 }
479 479
480 bool RTCPeerConnectionHandler::InitializeForTest( 480 bool RTCPeerConnectionHandler::InitializeForTest(
481 const blink::WebRTCConfiguration& server_configuration, 481 const blink::WebRTCConfiguration& server_configuration,
482 const blink::WebMediaConstraints& options, 482 const blink::WebMediaConstraints& options,
483 PeerConnectionTracker* peer_connection_tracker) { 483 PeerConnectionTracker* peer_connection_tracker) {
484 webrtc::PeerConnectionInterface::RTCConfiguration config; 484 webrtc::PeerConnectionInterface::RTCConfiguration config;
485 GetNativeRtcConfiguration(server_configuration, &config); 485 GetNativeRtcConfiguration(server_configuration, &config);
486 486
487 RTCMediaConstraints constraints(options); 487 RTCMediaConstraints constraints(options);
488 native_peer_connection_ = 488 native_peer_connection_ =
489 dependency_factory_->CreatePeerConnection( 489 dependency_factory_->CreatePeerConnection(
490 config, &constraints, NULL, this); 490 config, &constraints, NULL, this);
491 if (!native_peer_connection_.get()) { 491 if (!native_peer_connection_.get()) {
492 LOG(ERROR) << "Failed to initialize native PeerConnection."; 492 LOG(ERROR) << "Failed to initialize native PeerConnection.";
493 return false; 493 return false;
494 } 494 }
495 peer_connection_tracker_ = peer_connection_tracker; 495 peer_connection_tracker_ = peer_connection_tracker;
496 return true; 496 return true;
497 } 497 }
498 498
499 void RTCPeerConnectionHandler::createOffer( 499 void RTCPeerConnectionHandler::createOffer(
500 const blink::WebRTCSessionDescriptionRequest& request, 500 const blink::WebRTCSessionDescriptionRequest& request,
501 const blink::WebMediaConstraints& options) { 501 const blink::WebMediaConstraints& options) {
502 scoped_refptr<CreateSessionDescriptionRequest> description_request( 502 scoped_refptr<CreateSessionDescriptionRequest> description_request(
503 new talk_base::RefCountedObject<CreateSessionDescriptionRequest>( 503 new rtc::RefCountedObject<CreateSessionDescriptionRequest>(
504 request, this, PeerConnectionTracker::ACTION_CREATE_OFFER)); 504 request, this, PeerConnectionTracker::ACTION_CREATE_OFFER));
505 RTCMediaConstraints constraints(options); 505 RTCMediaConstraints constraints(options);
506 native_peer_connection_->CreateOffer(description_request.get(), &constraints); 506 native_peer_connection_->CreateOffer(description_request.get(), &constraints);
507 507
508 if (peer_connection_tracker_) 508 if (peer_connection_tracker_)
509 peer_connection_tracker_->TrackCreateOffer(this, constraints); 509 peer_connection_tracker_->TrackCreateOffer(this, constraints);
510 } 510 }
511 511
512 void RTCPeerConnectionHandler::createOffer( 512 void RTCPeerConnectionHandler::createOffer(
513 const blink::WebRTCSessionDescriptionRequest& request, 513 const blink::WebRTCSessionDescriptionRequest& request,
514 const blink::WebRTCOfferOptions& options) { 514 const blink::WebRTCOfferOptions& options) {
515 scoped_refptr<CreateSessionDescriptionRequest> description_request( 515 scoped_refptr<CreateSessionDescriptionRequest> description_request(
516 new talk_base::RefCountedObject<CreateSessionDescriptionRequest>( 516 new rtc::RefCountedObject<CreateSessionDescriptionRequest>(
517 request, this, PeerConnectionTracker::ACTION_CREATE_OFFER)); 517 request, this, PeerConnectionTracker::ACTION_CREATE_OFFER));
518 518
519 RTCMediaConstraints constraints; 519 RTCMediaConstraints constraints;
520 ConvertOfferOptionsToConstraints(options, &constraints); 520 ConvertOfferOptionsToConstraints(options, &constraints);
521 native_peer_connection_->CreateOffer(description_request.get(), &constraints); 521 native_peer_connection_->CreateOffer(description_request.get(), &constraints);
522 522
523 if (peer_connection_tracker_) 523 if (peer_connection_tracker_)
524 peer_connection_tracker_->TrackCreateOffer(this, constraints); 524 peer_connection_tracker_->TrackCreateOffer(this, constraints);
525 } 525 }
526 526
527 void RTCPeerConnectionHandler::createAnswer( 527 void RTCPeerConnectionHandler::createAnswer(
528 const blink::WebRTCSessionDescriptionRequest& request, 528 const blink::WebRTCSessionDescriptionRequest& request,
529 const blink::WebMediaConstraints& options) { 529 const blink::WebMediaConstraints& options) {
530 scoped_refptr<CreateSessionDescriptionRequest> description_request( 530 scoped_refptr<CreateSessionDescriptionRequest> description_request(
531 new talk_base::RefCountedObject<CreateSessionDescriptionRequest>( 531 new rtc::RefCountedObject<CreateSessionDescriptionRequest>(
532 request, this, PeerConnectionTracker::ACTION_CREATE_ANSWER)); 532 request, this, PeerConnectionTracker::ACTION_CREATE_ANSWER));
533 RTCMediaConstraints constraints(options); 533 RTCMediaConstraints constraints(options);
534 native_peer_connection_->CreateAnswer(description_request.get(), 534 native_peer_connection_->CreateAnswer(description_request.get(),
535 &constraints); 535 &constraints);
536 536
537 if (peer_connection_tracker_) 537 if (peer_connection_tracker_)
538 peer_connection_tracker_->TrackCreateAnswer(this, constraints); 538 peer_connection_tracker_->TrackCreateAnswer(this, constraints);
539 } 539 }
540 540
541 void RTCPeerConnectionHandler::setLocalDescription( 541 void RTCPeerConnectionHandler::setLocalDescription(
542 const blink::WebRTCVoidRequest& request, 542 const blink::WebRTCVoidRequest& request,
543 const blink::WebRTCSessionDescription& description) { 543 const blink::WebRTCSessionDescription& description) {
544 webrtc::SdpParseError error; 544 webrtc::SdpParseError error;
545 webrtc::SessionDescriptionInterface* native_desc = 545 webrtc::SessionDescriptionInterface* native_desc =
546 CreateNativeSessionDescription(description, &error); 546 CreateNativeSessionDescription(description, &error);
547 if (!native_desc) { 547 if (!native_desc) {
548 std::string reason_str = "Failed to parse SessionDescription. "; 548 std::string reason_str = "Failed to parse SessionDescription. ";
549 reason_str.append(error.line); 549 reason_str.append(error.line);
550 reason_str.append(" "); 550 reason_str.append(" ");
551 reason_str.append(error.description); 551 reason_str.append(error.description);
552 LOG(ERROR) << reason_str; 552 LOG(ERROR) << reason_str;
553 request.requestFailed(blink::WebString::fromUTF8(reason_str)); 553 request.requestFailed(blink::WebString::fromUTF8(reason_str));
554 return; 554 return;
555 } 555 }
556 if (peer_connection_tracker_) 556 if (peer_connection_tracker_)
557 peer_connection_tracker_->TrackSetSessionDescription( 557 peer_connection_tracker_->TrackSetSessionDescription(
558 this, description, PeerConnectionTracker::SOURCE_LOCAL); 558 this, description, PeerConnectionTracker::SOURCE_LOCAL);
559 559
560 scoped_refptr<SetSessionDescriptionRequest> set_request( 560 scoped_refptr<SetSessionDescriptionRequest> set_request(
561 new talk_base::RefCountedObject<SetSessionDescriptionRequest>( 561 new rtc::RefCountedObject<SetSessionDescriptionRequest>(
562 request, this, PeerConnectionTracker::ACTION_SET_LOCAL_DESCRIPTION)); 562 request, this, PeerConnectionTracker::ACTION_SET_LOCAL_DESCRIPTION));
563 native_peer_connection_->SetLocalDescription(set_request.get(), native_desc); 563 native_peer_connection_->SetLocalDescription(set_request.get(), native_desc);
564 } 564 }
565 565
566 void RTCPeerConnectionHandler::setRemoteDescription( 566 void RTCPeerConnectionHandler::setRemoteDescription(
567 const blink::WebRTCVoidRequest& request, 567 const blink::WebRTCVoidRequest& request,
568 const blink::WebRTCSessionDescription& description) { 568 const blink::WebRTCSessionDescription& description) {
569 webrtc::SdpParseError error; 569 webrtc::SdpParseError error;
570 webrtc::SessionDescriptionInterface* native_desc = 570 webrtc::SessionDescriptionInterface* native_desc =
571 CreateNativeSessionDescription(description, &error); 571 CreateNativeSessionDescription(description, &error);
572 if (!native_desc) { 572 if (!native_desc) {
573 std::string reason_str = "Failed to parse SessionDescription. "; 573 std::string reason_str = "Failed to parse SessionDescription. ";
574 reason_str.append(error.line); 574 reason_str.append(error.line);
575 reason_str.append(" "); 575 reason_str.append(" ");
576 reason_str.append(error.description); 576 reason_str.append(error.description);
577 LOG(ERROR) << reason_str; 577 LOG(ERROR) << reason_str;
578 request.requestFailed(blink::WebString::fromUTF8(reason_str)); 578 request.requestFailed(blink::WebString::fromUTF8(reason_str));
579 return; 579 return;
580 } 580 }
581 if (peer_connection_tracker_) 581 if (peer_connection_tracker_)
582 peer_connection_tracker_->TrackSetSessionDescription( 582 peer_connection_tracker_->TrackSetSessionDescription(
583 this, description, PeerConnectionTracker::SOURCE_REMOTE); 583 this, description, PeerConnectionTracker::SOURCE_REMOTE);
584 584
585 scoped_refptr<SetSessionDescriptionRequest> set_request( 585 scoped_refptr<SetSessionDescriptionRequest> set_request(
586 new talk_base::RefCountedObject<SetSessionDescriptionRequest>( 586 new rtc::RefCountedObject<SetSessionDescriptionRequest>(
587 request, this, PeerConnectionTracker::ACTION_SET_REMOTE_DESCRIPTION)); 587 request, this, PeerConnectionTracker::ACTION_SET_REMOTE_DESCRIPTION));
588 native_peer_connection_->SetRemoteDescription(set_request.get(), native_desc); 588 native_peer_connection_->SetRemoteDescription(set_request.get(), native_desc);
589 } 589 }
590 590
591 blink::WebRTCSessionDescription 591 blink::WebRTCSessionDescription
592 RTCPeerConnectionHandler::localDescription() { 592 RTCPeerConnectionHandler::localDescription() {
593 const webrtc::SessionDescriptionInterface* native_desc = 593 const webrtc::SessionDescriptionInterface* native_desc =
594 native_peer_connection_->local_description(); 594 native_peer_connection_->local_description();
595 blink::WebRTCSessionDescription description = 595 blink::WebRTCSessionDescription description =
596 CreateWebKitSessionDescription(native_desc); 596 CreateWebKitSessionDescription(native_desc);
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
721 peer_connection_tracker_->TrackRemoveStream( 721 peer_connection_tracker_->TrackRemoveStream(
722 this, stream, PeerConnectionTracker::SOURCE_LOCAL); 722 this, stream, PeerConnectionTracker::SOURCE_LOCAL);
723 PerSessionWebRTCAPIMetrics::GetInstance()->DecrementStreamCounter(); 723 PerSessionWebRTCAPIMetrics::GetInstance()->DecrementStreamCounter();
724 track_metrics_.RemoveStream(MediaStreamTrackMetrics::SENT_STREAM, 724 track_metrics_.RemoveStream(MediaStreamTrackMetrics::SENT_STREAM,
725 webrtc_stream); 725 webrtc_stream);
726 } 726 }
727 727
728 void RTCPeerConnectionHandler::getStats( 728 void RTCPeerConnectionHandler::getStats(
729 const blink::WebRTCStatsRequest& request) { 729 const blink::WebRTCStatsRequest& request) {
730 scoped_refptr<LocalRTCStatsRequest> inner_request( 730 scoped_refptr<LocalRTCStatsRequest> inner_request(
731 new talk_base::RefCountedObject<LocalRTCStatsRequest>(request)); 731 new rtc::RefCountedObject<LocalRTCStatsRequest>(request));
732 getStats(inner_request.get()); 732 getStats(inner_request.get());
733 } 733 }
734 734
735 void RTCPeerConnectionHandler::getStats(LocalRTCStatsRequest* request) { 735 void RTCPeerConnectionHandler::getStats(LocalRTCStatsRequest* request) {
736 talk_base::scoped_refptr<webrtc::StatsObserver> observer( 736 rtc::scoped_refptr<webrtc::StatsObserver> observer(
737 new talk_base::RefCountedObject<StatsResponse>(request)); 737 new rtc::RefCountedObject<StatsResponse>(request));
738 webrtc::MediaStreamTrackInterface* track = NULL; 738 webrtc::MediaStreamTrackInterface* track = NULL;
739 if (request->hasSelector()) { 739 if (request->hasSelector()) {
740 blink::WebMediaStreamSource::Type type = 740 blink::WebMediaStreamSource::Type type =
741 request->component().source().type(); 741 request->component().source().type();
742 std::string track_id = request->component().id().utf8(); 742 std::string track_id = request->component().id().utf8();
743 if (type == blink::WebMediaStreamSource::TypeAudio) { 743 if (type == blink::WebMediaStreamSource::TypeAudio) {
744 track = 744 track =
745 native_peer_connection_->local_streams()->FindAudioTrack(track_id); 745 native_peer_connection_->local_streams()->FindAudioTrack(track_id);
746 if (!track) { 746 if (!track) {
747 track = 747 track =
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
791 // TODO(jiayl): remove the deprecated reliable field once Libjingle is updated 791 // TODO(jiayl): remove the deprecated reliable field once Libjingle is updated
792 // to handle that. 792 // to handle that.
793 config.reliable = false; 793 config.reliable = false;
794 config.id = init.id; 794 config.id = init.id;
795 config.ordered = init.ordered; 795 config.ordered = init.ordered;
796 config.negotiated = init.negotiated; 796 config.negotiated = init.negotiated;
797 config.maxRetransmits = init.maxRetransmits; 797 config.maxRetransmits = init.maxRetransmits;
798 config.maxRetransmitTime = init.maxRetransmitTime; 798 config.maxRetransmitTime = init.maxRetransmitTime;
799 config.protocol = base::UTF16ToUTF8(init.protocol); 799 config.protocol = base::UTF16ToUTF8(init.protocol);
800 800
801 talk_base::scoped_refptr<webrtc::DataChannelInterface> webrtc_channel( 801 rtc::scoped_refptr<webrtc::DataChannelInterface> webrtc_channel(
802 native_peer_connection_->CreateDataChannel(base::UTF16ToUTF8(label), 802 native_peer_connection_->CreateDataChannel(base::UTF16ToUTF8(label),
803 &config)); 803 &config));
804 if (!webrtc_channel) { 804 if (!webrtc_channel) {
805 DLOG(ERROR) << "Could not create native data channel."; 805 DLOG(ERROR) << "Could not create native data channel.";
806 return NULL; 806 return NULL;
807 } 807 }
808 if (peer_connection_tracker_) 808 if (peer_connection_tracker_)
809 peer_connection_tracker_->TrackCreateDataChannel( 809 peer_connection_tracker_->TrackCreateDataChannel(
810 this, webrtc_channel.get(), PeerConnectionTracker::SOURCE_LOCAL); 810 this, webrtc_channel.get(), PeerConnectionTracker::SOURCE_LOCAL);
811 811
812 ++num_data_channels_created_; 812 ++num_data_channels_created_;
813 813
814 return new RtcDataChannelHandler(webrtc_channel); 814 return new RtcDataChannelHandler(webrtc_channel);
815 } 815 }
816 816
817 blink::WebRTCDTMFSenderHandler* RTCPeerConnectionHandler::createDTMFSender( 817 blink::WebRTCDTMFSenderHandler* RTCPeerConnectionHandler::createDTMFSender(
818 const blink::WebMediaStreamTrack& track) { 818 const blink::WebMediaStreamTrack& track) {
819 DVLOG(1) << "createDTMFSender."; 819 DVLOG(1) << "createDTMFSender.";
820 820
821 MediaStreamTrack* native_track = MediaStreamTrack::GetTrack(track); 821 MediaStreamTrack* native_track = MediaStreamTrack::GetTrack(track);
822 if (!native_track || 822 if (!native_track ||
823 track.source().type() != blink::WebMediaStreamSource::TypeAudio) { 823 track.source().type() != blink::WebMediaStreamSource::TypeAudio) {
824 DLOG(ERROR) << "Could not create DTMF sender from a non-audio track."; 824 DLOG(ERROR) << "Could not create DTMF sender from a non-audio track.";
825 return NULL; 825 return NULL;
826 } 826 }
827 827
828 webrtc::AudioTrackInterface* audio_track = native_track->GetAudioAdapter(); 828 webrtc::AudioTrackInterface* audio_track = native_track->GetAudioAdapter();
829 talk_base::scoped_refptr<webrtc::DtmfSenderInterface> sender( 829 rtc::scoped_refptr<webrtc::DtmfSenderInterface> sender(
830 native_peer_connection_->CreateDtmfSender(audio_track)); 830 native_peer_connection_->CreateDtmfSender(audio_track));
831 if (!sender) { 831 if (!sender) {
832 DLOG(ERROR) << "Could not create native DTMF sender."; 832 DLOG(ERROR) << "Could not create native DTMF sender.";
833 return NULL; 833 return NULL;
834 } 834 }
835 if (peer_connection_tracker_) 835 if (peer_connection_tracker_)
836 peer_connection_tracker_->TrackCreateDTMFSender(this, track); 836 peer_connection_tracker_->TrackCreateDTMFSender(this, track);
837 837
838 return new RtcDtmfSenderHandler(sender); 838 return new RtcDtmfSenderHandler(sender);
839 } 839 }
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
998 webrtc::SessionDescriptionInterface* native_desc = 998 webrtc::SessionDescriptionInterface* native_desc =
999 dependency_factory_->CreateSessionDescription(type, sdp, error); 999 dependency_factory_->CreateSessionDescription(type, sdp, error);
1000 1000
1001 LOG_IF(ERROR, !native_desc) << "Failed to create native session description." 1001 LOG_IF(ERROR, !native_desc) << "Failed to create native session description."
1002 << " Type: " << type << " SDP: " << sdp; 1002 << " Type: " << type << " SDP: " << sdp;
1003 1003
1004 return native_desc; 1004 return native_desc;
1005 } 1005 }
1006 1006
1007 } // namespace content 1007 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/rtc_peer_connection_handler.h ('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