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

Side by Side Diff: webrtc/ortc/rtptransportcontrolleradapter.cc

Issue 2794943002: Delete MediaController class, move Call ownership to PeerConnection. (Closed)
Patch Set: Revert DCHECK addition. Created 3 years, 7 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
« no previous file with comments | « webrtc/ortc/rtptransportcontrolleradapter.h ('k') | webrtc/pc/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2017 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2017 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 if (voice_channel_) { 114 if (voice_channel_) {
115 // This would mean audio RTP senders/receivers that are using us haven't 115 // This would mean audio RTP senders/receivers that are using us haven't
116 // been destroyed. This isn't safe (see error log above). 116 // been destroyed. This isn't safe (see error log above).
117 DestroyVoiceChannel(); 117 DestroyVoiceChannel();
118 } 118 }
119 if (voice_channel_) { 119 if (voice_channel_) {
120 // This would mean video RTP senders/receivers that are using us haven't 120 // This would mean video RTP senders/receivers that are using us haven't
121 // been destroyed. This isn't safe (see error log above). 121 // been destroyed. This isn't safe (see error log above).
122 DestroyVideoChannel(); 122 DestroyVideoChannel();
123 } 123 }
124 // Call must be destroyed on the worker thread.
125 worker_thread_->Invoke<void>(
126 RTC_FROM_HERE,
127 rtc::Bind(&RtpTransportControllerAdapter::Close_w, this));
124 } 128 }
125 129
126 RTCErrorOr<std::unique_ptr<RtpTransportInterface>> 130 RTCErrorOr<std::unique_ptr<RtpTransportInterface>>
127 RtpTransportControllerAdapter::CreateProxiedRtpTransport( 131 RtpTransportControllerAdapter::CreateProxiedRtpTransport(
128 const RtcpParameters& rtcp_parameters, 132 const RtcpParameters& rtcp_parameters,
129 PacketTransportInterface* rtp, 133 PacketTransportInterface* rtp,
130 PacketTransportInterface* rtcp) { 134 PacketTransportInterface* rtcp) {
131 auto result = 135 auto result =
132 RtpTransportAdapter::CreateProxied(rtcp_parameters, rtp, rtcp, this); 136 RtpTransportAdapter::CreateProxied(rtcp_parameters, rtp, rtcp, this);
133 if (result.ok()) { 137 if (result.ok()) {
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 } 581 }
578 582
579 RtpTransportControllerAdapter::RtpTransportControllerAdapter( 583 RtpTransportControllerAdapter::RtpTransportControllerAdapter(
580 const cricket::MediaConfig& config, 584 const cricket::MediaConfig& config,
581 cricket::ChannelManager* channel_manager, 585 cricket::ChannelManager* channel_manager,
582 webrtc::RtcEventLog* event_log, 586 webrtc::RtcEventLog* event_log,
583 rtc::Thread* signaling_thread, 587 rtc::Thread* signaling_thread,
584 rtc::Thread* worker_thread) 588 rtc::Thread* worker_thread)
585 : signaling_thread_(signaling_thread), 589 : signaling_thread_(signaling_thread),
586 worker_thread_(worker_thread), 590 worker_thread_(worker_thread),
587 media_controller_(MediaControllerInterface::Create(config, 591 media_config_(config),
588 worker_thread, 592 channel_manager_(channel_manager),
589 channel_manager, 593 event_log_(event_log) {
590 event_log)) {
591 RTC_DCHECK_RUN_ON(signaling_thread_); 594 RTC_DCHECK_RUN_ON(signaling_thread_);
592 RTC_DCHECK(channel_manager); 595 RTC_DCHECK(channel_manager_);
593 // MediaControllerInterface::Create should never fail.
594 RTC_DCHECK(media_controller_);
595 // Add "dummy" codecs to the descriptions, because the media engines 596 // Add "dummy" codecs to the descriptions, because the media engines
596 // currently reject empty lists of codecs. Note that these codecs will never 597 // currently reject empty lists of codecs. Note that these codecs will never
597 // actually be used, because when parameters are set, the dummy codecs will 598 // actually be used, because when parameters are set, the dummy codecs will
598 // be replaced by actual codecs before any send/receive streams are created. 599 // be replaced by actual codecs before any send/receive streams are created.
599 static const cricket::AudioCodec dummy_audio(0, cricket::kPcmuCodecName, 8000, 600 static const cricket::AudioCodec dummy_audio(0, cricket::kPcmuCodecName, 8000,
600 0, 1); 601 0, 1);
601 static const cricket::VideoCodec dummy_video(96, cricket::kVp8CodecName); 602 static const cricket::VideoCodec dummy_video(96, cricket::kVp8CodecName);
602 local_audio_description_.AddCodec(dummy_audio); 603 local_audio_description_.AddCodec(dummy_audio);
603 remote_audio_description_.AddCodec(dummy_audio); 604 remote_audio_description_.AddCodec(dummy_audio);
604 local_video_description_.AddCodec(dummy_video); 605 local_video_description_.AddCodec(dummy_video);
605 remote_video_description_.AddCodec(dummy_video); 606 remote_video_description_.AddCodec(dummy_video);
607
608 worker_thread_->Invoke<void>(
609 RTC_FROM_HERE,
610 rtc::Bind(&RtpTransportControllerAdapter::Init_w, this));
611 }
612
613 // TODO(nisse): Duplicates corresponding method in PeerConnection (used
614 // to be in MediaController).
stefan-webrtc 2017/05/05 08:47:05 I think this TODO should say when these duplicates
stefan-webrtc 2017/05/05 08:53:50 Talked offline, and duplicates are needed since th
nisse-webrtc 2017/05/05 09:02:37 I'm afraid I'm not at all familiar with the new or
Taylor Brandstetter 2017/05/05 16:32:01 I wouldn't worry about reducing this duplication.
615 void RtpTransportControllerAdapter::Init_w() {
616 RTC_DCHECK(worker_thread_->IsCurrent());
617 RTC_DCHECK(!call_);
618
619 const int kMinBandwidthBps = 30000;
620 const int kStartBandwidthBps = 300000;
621 const int kMaxBandwidthBps = 2000000;
622
623 webrtc::Call::Config call_config(event_log_);
624 call_config.audio_state = channel_manager_->media_engine()->GetAudioState();
625 call_config.bitrate_config.min_bitrate_bps = kMinBandwidthBps;
626 call_config.bitrate_config.start_bitrate_bps = kStartBandwidthBps;
627 call_config.bitrate_config.max_bitrate_bps = kMaxBandwidthBps;
628
629 call_.reset(webrtc::Call::Create(call_config));
630 }
631
632 void RtpTransportControllerAdapter::Close_w() {
633 call_.reset();
606 } 634 }
607 635
608 RTCError RtpTransportControllerAdapter::AttachAudioSender( 636 RTCError RtpTransportControllerAdapter::AttachAudioSender(
609 OrtcRtpSenderAdapter* sender, 637 OrtcRtpSenderAdapter* sender,
610 RtpTransportInterface* inner_transport) { 638 RtpTransportInterface* inner_transport) {
611 if (have_audio_sender_) { 639 if (have_audio_sender_) {
612 LOG_AND_RETURN_ERROR(RTCErrorType::UNSUPPORTED_OPERATION, 640 LOG_AND_RETURN_ERROR(RTCErrorType::UNSUPPORTED_OPERATION,
613 "Using two audio RtpSenders with the same " 641 "Using two audio RtpSenders with the same "
614 "RtpTransportControllerAdapter is not currently " 642 "RtpTransportControllerAdapter is not currently "
615 "supported."); 643 "supported.");
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
811 // Empty parameters should result in receiving being stopped. 839 // Empty parameters should result in receiving being stopped.
812 RTCError err = ValidateAndApplyVideoReceiverParameters(RtpParameters()); 840 RTCError err = ValidateAndApplyVideoReceiverParameters(RtpParameters());
813 RTC_DCHECK(err.ok()); 841 RTC_DCHECK(err.ok());
814 have_video_receiver_ = false; 842 have_video_receiver_ = false;
815 if (!have_video_sender_) { 843 if (!have_video_sender_) {
816 DestroyVideoChannel(); 844 DestroyVideoChannel();
817 } 845 }
818 } 846 }
819 847
820 void RtpTransportControllerAdapter::CreateVoiceChannel() { 848 void RtpTransportControllerAdapter::CreateVoiceChannel() {
821 voice_channel_ = media_controller_->channel_manager()->CreateVoiceChannel( 849 voice_channel_ = channel_manager_->CreateVoiceChannel(
822 media_controller_.get(), 850 call_.get(), media_config_,
823 inner_audio_transport_->GetRtpPacketTransport()->GetInternal(), 851 inner_audio_transport_->GetRtpPacketTransport()->GetInternal(),
824 inner_audio_transport_->GetRtcpPacketTransport() 852 inner_audio_transport_->GetRtcpPacketTransport()
825 ? inner_audio_transport_->GetRtcpPacketTransport()->GetInternal() 853 ? inner_audio_transport_->GetRtcpPacketTransport()->GetInternal()
826 : nullptr, 854 : nullptr,
827 signaling_thread_, "audio", false, cricket::AudioOptions()); 855 signaling_thread_, "audio", false, cricket::AudioOptions());
828 RTC_DCHECK(voice_channel_); 856 RTC_DCHECK(voice_channel_);
829 voice_channel_->Enable(true); 857 voice_channel_->Enable(true);
830 } 858 }
831 859
832 void RtpTransportControllerAdapter::CreateVideoChannel() { 860 void RtpTransportControllerAdapter::CreateVideoChannel() {
833 video_channel_ = media_controller_->channel_manager()->CreateVideoChannel( 861 video_channel_ = channel_manager_->CreateVideoChannel(
834 media_controller_.get(), 862 call_.get(), media_config_,
835 inner_video_transport_->GetRtpPacketTransport()->GetInternal(), 863 inner_video_transport_->GetRtpPacketTransport()->GetInternal(),
836 inner_video_transport_->GetRtcpPacketTransport() 864 inner_video_transport_->GetRtcpPacketTransport()
837 ? inner_video_transport_->GetRtcpPacketTransport()->GetInternal() 865 ? inner_video_transport_->GetRtcpPacketTransport()->GetInternal()
838 : nullptr, 866 : nullptr,
839 signaling_thread_, "video", false, cricket::VideoOptions()); 867 signaling_thread_, "video", false, cricket::VideoOptions());
840 RTC_DCHECK(video_channel_); 868 RTC_DCHECK(video_channel_);
841 video_channel_->Enable(true); 869 video_channel_->Enable(true);
842 } 870 }
843 871
844 void RtpTransportControllerAdapter::DestroyVoiceChannel() { 872 void RtpTransportControllerAdapter::DestroyVoiceChannel() {
845 RTC_DCHECK(voice_channel_); 873 RTC_DCHECK(voice_channel_);
846 media_controller_->channel_manager()->DestroyVoiceChannel(voice_channel_); 874 channel_manager_->DestroyVoiceChannel(voice_channel_);
847 voice_channel_ = nullptr; 875 voice_channel_ = nullptr;
848 inner_audio_transport_ = nullptr; 876 inner_audio_transport_ = nullptr;
849 } 877 }
850 878
851 void RtpTransportControllerAdapter::DestroyVideoChannel() { 879 void RtpTransportControllerAdapter::DestroyVideoChannel() {
852 RTC_DCHECK(video_channel_); 880 RTC_DCHECK(video_channel_);
853 media_controller_->channel_manager()->DestroyVideoChannel(video_channel_); 881 channel_manager_->DestroyVideoChannel(video_channel_);
854 video_channel_ = nullptr; 882 video_channel_ = nullptr;
855 inner_video_transport_ = nullptr; 883 inner_video_transport_ = nullptr;
856 } 884 }
857 885
858 void RtpTransportControllerAdapter::CopyRtcpParametersToDescriptions( 886 void RtpTransportControllerAdapter::CopyRtcpParametersToDescriptions(
859 const RtcpParameters& params, 887 const RtcpParameters& params,
860 cricket::MediaContentDescription* local, 888 cricket::MediaContentDescription* local,
861 cricket::MediaContentDescription* remote) { 889 cricket::MediaContentDescription* remote) {
862 local->set_rtcp_mux(params.mux); 890 local->set_rtcp_mux(params.mux);
863 remote->set_rtcp_mux(params.mux); 891 remote->set_rtcp_mux(params.mux);
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
946 local_description->set_cryptos(cryptos); 974 local_description->set_cryptos(cryptos);
947 975
948 cryptos.clear(); 976 cryptos.clear();
949 cryptos.push_back(*(rtp_transport->GetInternal()->send_key())); 977 cryptos.push_back(*(rtp_transport->GetInternal()->send_key()));
950 remote_description->set_cryptos(cryptos); 978 remote_description->set_cryptos(cryptos);
951 } 979 }
952 return RTCError::OK(); 980 return RTCError::OK();
953 } 981 }
954 982
955 } // namespace webrtc 983 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/ortc/rtptransportcontrolleradapter.h ('k') | webrtc/pc/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698