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

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

Issue 2981513002: Wire up RTP keep-alive in ortc api. (Closed)
Patch Set: Test Created 3 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
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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 DestroyVideoChannel(); 122 DestroyVideoChannel();
123 } 123 }
124 // Call must be destroyed on the worker thread. 124 // Call must be destroyed on the worker thread.
125 worker_thread_->Invoke<void>( 125 worker_thread_->Invoke<void>(
126 RTC_FROM_HERE, 126 RTC_FROM_HERE,
127 rtc::Bind(&RtpTransportControllerAdapter::Close_w, this)); 127 rtc::Bind(&RtpTransportControllerAdapter::Close_w, this));
128 } 128 }
129 129
130 RTCErrorOr<std::unique_ptr<RtpTransportInterface>> 130 RTCErrorOr<std::unique_ptr<RtpTransportInterface>>
131 RtpTransportControllerAdapter::CreateProxiedRtpTransport( 131 RtpTransportControllerAdapter::CreateProxiedRtpTransport(
132 const RtcpParameters& rtcp_parameters, 132 const RtpTransportParameters& parameters,
133 PacketTransportInterface* rtp, 133 PacketTransportInterface* rtp,
134 PacketTransportInterface* rtcp) { 134 PacketTransportInterface* rtcp) {
135 auto result = 135 auto result = RtpTransportAdapter::CreateProxied(parameters, rtp, rtcp, this);
136 RtpTransportAdapter::CreateProxied(rtcp_parameters, rtp, rtcp, this);
137 if (result.ok()) { 136 if (result.ok()) {
138 transport_proxies_.push_back(result.value().get()); 137 transport_proxies_.push_back(result.value().get());
139 transport_proxies_.back()->GetInternal()->SignalDestroyed.connect( 138 transport_proxies_.back()->GetInternal()->SignalDestroyed.connect(
140 this, &RtpTransportControllerAdapter::OnRtpTransportDestroyed); 139 this, &RtpTransportControllerAdapter::OnRtpTransportDestroyed);
141 } 140 }
142 return result; 141 return result;
143 } 142 }
144 143
145 RTCErrorOr<std::unique_ptr<SrtpTransportInterface>> 144 RTCErrorOr<std::unique_ptr<SrtpTransportInterface>>
146 RtpTransportControllerAdapter::CreateProxiedSrtpTransport( 145 RtpTransportControllerAdapter::CreateProxiedSrtpTransport(
147 const RtcpParameters& rtcp_parameters, 146 const RtpTransportParameters& parameters,
148 PacketTransportInterface* rtp, 147 PacketTransportInterface* rtp,
149 PacketTransportInterface* rtcp) { 148 PacketTransportInterface* rtcp) {
150 auto result = 149 auto result =
151 RtpTransportAdapter::CreateSrtpProxied(rtcp_parameters, rtp, rtcp, this); 150 RtpTransportAdapter::CreateSrtpProxied(parameters, rtp, rtcp, this);
152 if (result.ok()) { 151 if (result.ok()) {
153 transport_proxies_.push_back(result.value().get()); 152 transport_proxies_.push_back(result.value().get());
154 transport_proxies_.back()->GetInternal()->SignalDestroyed.connect( 153 transport_proxies_.back()->GetInternal()->SignalDestroyed.connect(
155 this, &RtpTransportControllerAdapter::OnRtpTransportDestroyed); 154 this, &RtpTransportControllerAdapter::OnRtpTransportDestroyed);
156 } 155 }
157 return result; 156 return result;
158 } 157 }
159 158
160 RTCErrorOr<std::unique_ptr<OrtcRtpSenderInterface>> 159 RTCErrorOr<std::unique_ptr<OrtcRtpSenderInterface>>
161 RtpTransportControllerAdapter::CreateProxiedRtpSender( 160 RtpTransportControllerAdapter::CreateProxiedRtpSender(
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 211
213 return OrtcRtpReceiverAdapter::CreateProxy(std::move(new_receiver)); 212 return OrtcRtpReceiverAdapter::CreateProxy(std::move(new_receiver));
214 } 213 }
215 214
216 std::vector<RtpTransportInterface*> 215 std::vector<RtpTransportInterface*>
217 RtpTransportControllerAdapter::GetTransports() const { 216 RtpTransportControllerAdapter::GetTransports() const {
218 RTC_DCHECK_RUN_ON(signaling_thread_); 217 RTC_DCHECK_RUN_ON(signaling_thread_);
219 return transport_proxies_; 218 return transport_proxies_;
220 } 219 }
221 220
222 RTCError RtpTransportControllerAdapter::SetRtcpParameters( 221 RTCError RtpTransportControllerAdapter::SetRtpTransportAndRtcpParameters(
223 const RtcpParameters& parameters, 222 const RtpTransportParameters& parameters,
224 RtpTransportInterface* inner_transport) { 223 RtpTransportInterface* inner_transport) {
224 if (!call_->SetRtpKeepAliveConfig(parameters.keepalive)) {
225 LOG_AND_RETURN_ERROR(RTCErrorType::INTERNAL_ERROR,
226 "Failed to apply new RTP transport parameters.");
227 }
225 do { 228 do {
226 if (inner_transport == inner_audio_transport_) { 229 if (inner_transport == inner_audio_transport_) {
227 CopyRtcpParametersToDescriptions(parameters, &local_audio_description_, 230 CopyRtcpParametersToDescriptions(parameters.rtcp,
231 &local_audio_description_,
228 &remote_audio_description_); 232 &remote_audio_description_);
229 if (!voice_channel_->SetLocalContent(&local_audio_description_, 233 if (!voice_channel_->SetLocalContent(&local_audio_description_,
230 cricket::CA_OFFER, nullptr)) { 234 cricket::CA_OFFER, nullptr)) {
231 break; 235 break;
232 } 236 }
233 if (!voice_channel_->SetRemoteContent(&remote_audio_description_, 237 if (!voice_channel_->SetRemoteContent(&remote_audio_description_,
234 cricket::CA_ANSWER, nullptr)) { 238 cricket::CA_ANSWER, nullptr)) {
235 break; 239 break;
236 } 240 }
237 } else if (inner_transport == inner_video_transport_) { 241 } else if (inner_transport == inner_video_transport_) {
238 CopyRtcpParametersToDescriptions(parameters, &local_video_description_, 242 CopyRtcpParametersToDescriptions(parameters.rtcp,
243 &local_video_description_,
239 &remote_video_description_); 244 &remote_video_description_);
240 if (!video_channel_->SetLocalContent(&local_video_description_, 245 if (!video_channel_->SetLocalContent(&local_video_description_,
241 cricket::CA_OFFER, nullptr)) { 246 cricket::CA_OFFER, nullptr)) {
242 break; 247 break;
243 } 248 }
244 if (!video_channel_->SetRemoteContent(&remote_video_description_, 249 if (!video_channel_->SetRemoteContent(&remote_video_description_,
245 cricket::CA_ANSWER, nullptr)) { 250 cricket::CA_ANSWER, nullptr)) {
246 break; 251 break;
247 } 252 }
248 } 253 }
(...skipping 14 matching lines...) Expand all
263 return codecs_result.MoveError(); 268 return codecs_result.MoveError();
264 } 269 }
265 270
266 auto extensions_result = 271 auto extensions_result =
267 ToCricketRtpHeaderExtensions(parameters.header_extensions); 272 ToCricketRtpHeaderExtensions(parameters.header_extensions);
268 if (!extensions_result.ok()) { 273 if (!extensions_result.ok()) {
269 return extensions_result.MoveError(); 274 return extensions_result.MoveError();
270 } 275 }
271 276
272 auto stream_params_result = MakeSendStreamParamsVec( 277 auto stream_params_result = MakeSendStreamParamsVec(
273 parameters.encodings, inner_audio_transport_->GetRtcpParameters().cname, 278 parameters.encodings, inner_audio_transport_->GetParameters().rtcp.cname,
274 local_audio_description_); 279 local_audio_description_);
275 if (!stream_params_result.ok()) { 280 if (!stream_params_result.ok()) {
276 return stream_params_result.MoveError(); 281 return stream_params_result.MoveError();
277 } 282 }
278 283
279 // Check that audio/video sender aren't using the same IDs to refer to 284 // Check that audio/video sender aren't using the same IDs to refer to
280 // different things, if they share the same transport. 285 // different things, if they share the same transport.
281 if (inner_audio_transport_ == inner_video_transport_) { 286 if (inner_audio_transport_ == inner_video_transport_) {
282 RTCError err = CheckForIdConflicts( 287 RTCError err = CheckForIdConflicts(
283 codecs_result.value(), extensions_result.value(), 288 codecs_result.value(), extensions_result.value(),
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 return codecs_result.MoveError(); 357 return codecs_result.MoveError();
353 } 358 }
354 359
355 auto extensions_result = 360 auto extensions_result =
356 ToCricketRtpHeaderExtensions(parameters.header_extensions); 361 ToCricketRtpHeaderExtensions(parameters.header_extensions);
357 if (!extensions_result.ok()) { 362 if (!extensions_result.ok()) {
358 return extensions_result.MoveError(); 363 return extensions_result.MoveError();
359 } 364 }
360 365
361 auto stream_params_result = MakeSendStreamParamsVec( 366 auto stream_params_result = MakeSendStreamParamsVec(
362 parameters.encodings, inner_video_transport_->GetRtcpParameters().cname, 367 parameters.encodings, inner_video_transport_->GetParameters().rtcp.cname,
363 local_video_description_); 368 local_video_description_);
364 if (!stream_params_result.ok()) { 369 if (!stream_params_result.ok()) {
365 return stream_params_result.MoveError(); 370 return stream_params_result.MoveError();
366 } 371 }
367 372
368 // Check that audio/video sender aren't using the same IDs to refer to 373 // Check that audio/video sender aren't using the same IDs to refer to
369 // different things, if they share the same transport. 374 // different things, if they share the same transport.
370 if (inner_audio_transport_ == inner_video_transport_) { 375 if (inner_audio_transport_ == inner_video_transport_) {
371 RTCError err = CheckForIdConflicts( 376 RTCError err = CheckForIdConflicts(
372 codecs_result.value(), extensions_result.value(), 377 codecs_result.value(), extensions_result.value(),
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
649 "supported."); 654 "supported.");
650 } 655 }
651 RTCError err = MaybeSetCryptos(inner_transport, &local_audio_description_, 656 RTCError err = MaybeSetCryptos(inner_transport, &local_audio_description_,
652 &remote_audio_description_); 657 &remote_audio_description_);
653 if (!err.ok()) { 658 if (!err.ok()) {
654 return err; 659 return err;
655 } 660 }
656 // If setting new transport, extract its RTCP parameters and create voice 661 // If setting new transport, extract its RTCP parameters and create voice
657 // channel. 662 // channel.
658 if (!inner_audio_transport_) { 663 if (!inner_audio_transport_) {
659 CopyRtcpParametersToDescriptions(inner_transport->GetRtcpParameters(), 664 CopyRtcpParametersToDescriptions(inner_transport->GetParameters().rtcp,
660 &local_audio_description_, 665 &local_audio_description_,
661 &remote_audio_description_); 666 &remote_audio_description_);
662 inner_audio_transport_ = inner_transport; 667 inner_audio_transport_ = inner_transport;
663 CreateVoiceChannel(); 668 CreateVoiceChannel();
664 } 669 }
665 have_audio_sender_ = true; 670 have_audio_sender_ = true;
666 sender->SignalDestroyed.connect( 671 sender->SignalDestroyed.connect(
667 this, &RtpTransportControllerAdapter::OnAudioSenderDestroyed); 672 this, &RtpTransportControllerAdapter::OnAudioSenderDestroyed);
668 return RTCError::OK(); 673 return RTCError::OK();
669 } 674 }
(...skipping 14 matching lines...) Expand all
684 "supported."); 689 "supported.");
685 } 690 }
686 RTCError err = MaybeSetCryptos(inner_transport, &local_video_description_, 691 RTCError err = MaybeSetCryptos(inner_transport, &local_video_description_,
687 &remote_video_description_); 692 &remote_video_description_);
688 if (!err.ok()) { 693 if (!err.ok()) {
689 return err; 694 return err;
690 } 695 }
691 // If setting new transport, extract its RTCP parameters and create video 696 // If setting new transport, extract its RTCP parameters and create video
692 // channel. 697 // channel.
693 if (!inner_video_transport_) { 698 if (!inner_video_transport_) {
694 CopyRtcpParametersToDescriptions(inner_transport->GetRtcpParameters(), 699 CopyRtcpParametersToDescriptions(inner_transport->GetParameters().rtcp,
695 &local_video_description_, 700 &local_video_description_,
696 &remote_video_description_); 701 &remote_video_description_);
697 inner_video_transport_ = inner_transport; 702 inner_video_transport_ = inner_transport;
698 CreateVideoChannel(); 703 CreateVideoChannel();
699 } 704 }
700 have_video_sender_ = true; 705 have_video_sender_ = true;
701 sender->SignalDestroyed.connect( 706 sender->SignalDestroyed.connect(
702 this, &RtpTransportControllerAdapter::OnVideoSenderDestroyed); 707 this, &RtpTransportControllerAdapter::OnVideoSenderDestroyed);
703 return RTCError::OK(); 708 return RTCError::OK();
704 } 709 }
(...skipping 14 matching lines...) Expand all
719 "supported."); 724 "supported.");
720 } 725 }
721 RTCError err = MaybeSetCryptos(inner_transport, &local_audio_description_, 726 RTCError err = MaybeSetCryptos(inner_transport, &local_audio_description_,
722 &remote_audio_description_); 727 &remote_audio_description_);
723 if (!err.ok()) { 728 if (!err.ok()) {
724 return err; 729 return err;
725 } 730 }
726 // If setting new transport, extract its RTCP parameters and create voice 731 // If setting new transport, extract its RTCP parameters and create voice
727 // channel. 732 // channel.
728 if (!inner_audio_transport_) { 733 if (!inner_audio_transport_) {
729 CopyRtcpParametersToDescriptions(inner_transport->GetRtcpParameters(), 734 CopyRtcpParametersToDescriptions(inner_transport->GetParameters().rtcp,
730 &local_audio_description_, 735 &local_audio_description_,
731 &remote_audio_description_); 736 &remote_audio_description_);
732 inner_audio_transport_ = inner_transport; 737 inner_audio_transport_ = inner_transport;
733 CreateVoiceChannel(); 738 CreateVoiceChannel();
734 } 739 }
735 have_audio_receiver_ = true; 740 have_audio_receiver_ = true;
736 receiver->SignalDestroyed.connect( 741 receiver->SignalDestroyed.connect(
737 this, &RtpTransportControllerAdapter::OnAudioReceiverDestroyed); 742 this, &RtpTransportControllerAdapter::OnAudioReceiverDestroyed);
738 return RTCError::OK(); 743 return RTCError::OK();
739 } 744 }
(...skipping 14 matching lines...) Expand all
754 "supported."); 759 "supported.");
755 } 760 }
756 RTCError err = MaybeSetCryptos(inner_transport, &local_video_description_, 761 RTCError err = MaybeSetCryptos(inner_transport, &local_video_description_,
757 &remote_video_description_); 762 &remote_video_description_);
758 if (!err.ok()) { 763 if (!err.ok()) {
759 return err; 764 return err;
760 } 765 }
761 // If setting new transport, extract its RTCP parameters and create video 766 // If setting new transport, extract its RTCP parameters and create video
762 // channel. 767 // channel.
763 if (!inner_video_transport_) { 768 if (!inner_video_transport_) {
764 CopyRtcpParametersToDescriptions(inner_transport->GetRtcpParameters(), 769 CopyRtcpParametersToDescriptions(inner_transport->GetParameters().rtcp,
765 &local_video_description_, 770 &local_video_description_,
766 &remote_video_description_); 771 &remote_video_description_);
767 inner_video_transport_ = inner_transport; 772 inner_video_transport_ = inner_transport;
768 CreateVideoChannel(); 773 CreateVideoChannel();
769 } 774 }
770 have_video_receiver_ = true; 775 have_video_receiver_ = true;
771 receiver->SignalDestroyed.connect( 776 receiver->SignalDestroyed.connect(
772 this, &RtpTransportControllerAdapter::OnVideoReceiverDestroyed); 777 this, &RtpTransportControllerAdapter::OnVideoReceiverDestroyed);
773 return RTCError::OK(); 778 return RTCError::OK();
774 } 779 }
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
974 local_description->set_cryptos(cryptos); 979 local_description->set_cryptos(cryptos);
975 980
976 cryptos.clear(); 981 cryptos.clear();
977 cryptos.push_back(*(rtp_transport->GetInternal()->send_key())); 982 cryptos.push_back(*(rtp_transport->GetInternal()->send_key()));
978 remote_description->set_cryptos(cryptos); 983 remote_description->set_cryptos(cryptos);
979 } 984 }
980 return RTCError::OK(); 985 return RTCError::OK();
981 } 986 }
982 987
983 } // namespace webrtc 988 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698