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

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

Issue 2981513002: Wire up RTP keep-alive in ortc api. (Closed)
Patch Set: Add workaround for gcc 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 if (!transport_proxies_.empty() && (parameters.keepalive != keepalive_)) {
136 RtpTransportAdapter::CreateProxied(rtcp_parameters, rtp, rtcp, this); 136 LOG_AND_RETURN_ERROR(RTCErrorType::INVALID_MODIFICATION,
137 "Cannot create RtpTransport with different keep-alive "
138 "from the RtpTransports already associated with this "
139 "transport controller.");
140 }
141 auto result = RtpTransportAdapter::CreateProxied(parameters, rtp, rtcp, this);
137 if (result.ok()) { 142 if (result.ok()) {
138 transport_proxies_.push_back(result.value().get()); 143 transport_proxies_.push_back(result.value().get());
139 transport_proxies_.back()->GetInternal()->SignalDestroyed.connect( 144 transport_proxies_.back()->GetInternal()->SignalDestroyed.connect(
140 this, &RtpTransportControllerAdapter::OnRtpTransportDestroyed); 145 this, &RtpTransportControllerAdapter::OnRtpTransportDestroyed);
141 } 146 }
142 return result; 147 return result;
143 } 148 }
144 149
145 RTCErrorOr<std::unique_ptr<SrtpTransportInterface>> 150 RTCErrorOr<std::unique_ptr<SrtpTransportInterface>>
146 RtpTransportControllerAdapter::CreateProxiedSrtpTransport( 151 RtpTransportControllerAdapter::CreateProxiedSrtpTransport(
147 const RtcpParameters& rtcp_parameters, 152 const RtpTransportParameters& parameters,
148 PacketTransportInterface* rtp, 153 PacketTransportInterface* rtp,
149 PacketTransportInterface* rtcp) { 154 PacketTransportInterface* rtcp) {
150 auto result = 155 auto result =
151 RtpTransportAdapter::CreateSrtpProxied(rtcp_parameters, rtp, rtcp, this); 156 RtpTransportAdapter::CreateSrtpProxied(parameters, rtp, rtcp, this);
152 if (result.ok()) { 157 if (result.ok()) {
153 transport_proxies_.push_back(result.value().get()); 158 transport_proxies_.push_back(result.value().get());
154 transport_proxies_.back()->GetInternal()->SignalDestroyed.connect( 159 transport_proxies_.back()->GetInternal()->SignalDestroyed.connect(
155 this, &RtpTransportControllerAdapter::OnRtpTransportDestroyed); 160 this, &RtpTransportControllerAdapter::OnRtpTransportDestroyed);
156 } 161 }
157 return result; 162 return result;
158 } 163 }
159 164
160 RTCErrorOr<std::unique_ptr<OrtcRtpSenderInterface>> 165 RTCErrorOr<std::unique_ptr<OrtcRtpSenderInterface>>
161 RtpTransportControllerAdapter::CreateProxiedRtpSender( 166 RtpTransportControllerAdapter::CreateProxiedRtpSender(
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 217
213 return OrtcRtpReceiverAdapter::CreateProxy(std::move(new_receiver)); 218 return OrtcRtpReceiverAdapter::CreateProxy(std::move(new_receiver));
214 } 219 }
215 220
216 std::vector<RtpTransportInterface*> 221 std::vector<RtpTransportInterface*>
217 RtpTransportControllerAdapter::GetTransports() const { 222 RtpTransportControllerAdapter::GetTransports() const {
218 RTC_DCHECK_RUN_ON(signaling_thread_); 223 RTC_DCHECK_RUN_ON(signaling_thread_);
219 return transport_proxies_; 224 return transport_proxies_;
220 } 225 }
221 226
222 RTCError RtpTransportControllerAdapter::SetRtcpParameters( 227 RTCError RtpTransportControllerAdapter::SetRtpTransportParameters(
223 const RtcpParameters& parameters, 228 const RtpTransportParameters& parameters,
224 RtpTransportInterface* inner_transport) { 229 RtpTransportInterface* inner_transport) {
230 if ((video_channel_ != nullptr || voice_channel_ != nullptr) &&
231 (parameters.keepalive != keepalive_)) {
232 LOG_AND_RETURN_ERROR(RTCErrorType::INVALID_MODIFICATION,
233 "Cannot change keep-alive settings after creating "
234 "media streams or additional transports for the same "
235 "transport controller.");
236 }
237 RTC_CHECK(call_->SetRtpKeepAliveConfig(parameters.keepalive));
225 do { 238 do {
226 if (inner_transport == inner_audio_transport_) { 239 if (inner_transport == inner_audio_transport_) {
227 CopyRtcpParametersToDescriptions(parameters, &local_audio_description_, 240 CopyRtcpParametersToDescriptions(parameters.rtcp,
241 &local_audio_description_,
228 &remote_audio_description_); 242 &remote_audio_description_);
229 if (!voice_channel_->SetLocalContent(&local_audio_description_, 243 if (!voice_channel_->SetLocalContent(&local_audio_description_,
230 cricket::CA_OFFER, nullptr)) { 244 cricket::CA_OFFER, nullptr)) {
231 break; 245 break;
232 } 246 }
233 if (!voice_channel_->SetRemoteContent(&remote_audio_description_, 247 if (!voice_channel_->SetRemoteContent(&remote_audio_description_,
234 cricket::CA_ANSWER, nullptr)) { 248 cricket::CA_ANSWER, nullptr)) {
235 break; 249 break;
236 } 250 }
237 } else if (inner_transport == inner_video_transport_) { 251 } else if (inner_transport == inner_video_transport_) {
238 CopyRtcpParametersToDescriptions(parameters, &local_video_description_, 252 CopyRtcpParametersToDescriptions(parameters.rtcp,
253 &local_video_description_,
239 &remote_video_description_); 254 &remote_video_description_);
240 if (!video_channel_->SetLocalContent(&local_video_description_, 255 if (!video_channel_->SetLocalContent(&local_video_description_,
241 cricket::CA_OFFER, nullptr)) { 256 cricket::CA_OFFER, nullptr)) {
242 break; 257 break;
243 } 258 }
244 if (!video_channel_->SetRemoteContent(&remote_video_description_, 259 if (!video_channel_->SetRemoteContent(&remote_video_description_,
245 cricket::CA_ANSWER, nullptr)) { 260 cricket::CA_ANSWER, nullptr)) {
246 break; 261 break;
247 } 262 }
248 } 263 }
(...skipping 14 matching lines...) Expand all
263 return codecs_result.MoveError(); 278 return codecs_result.MoveError();
264 } 279 }
265 280
266 auto extensions_result = 281 auto extensions_result =
267 ToCricketRtpHeaderExtensions(parameters.header_extensions); 282 ToCricketRtpHeaderExtensions(parameters.header_extensions);
268 if (!extensions_result.ok()) { 283 if (!extensions_result.ok()) {
269 return extensions_result.MoveError(); 284 return extensions_result.MoveError();
270 } 285 }
271 286
272 auto stream_params_result = MakeSendStreamParamsVec( 287 auto stream_params_result = MakeSendStreamParamsVec(
273 parameters.encodings, inner_audio_transport_->GetRtcpParameters().cname, 288 parameters.encodings, inner_audio_transport_->GetParameters().rtcp.cname,
274 local_audio_description_); 289 local_audio_description_);
275 if (!stream_params_result.ok()) { 290 if (!stream_params_result.ok()) {
276 return stream_params_result.MoveError(); 291 return stream_params_result.MoveError();
277 } 292 }
278 293
279 // Check that audio/video sender aren't using the same IDs to refer to 294 // Check that audio/video sender aren't using the same IDs to refer to
280 // different things, if they share the same transport. 295 // different things, if they share the same transport.
281 if (inner_audio_transport_ == inner_video_transport_) { 296 if (inner_audio_transport_ == inner_video_transport_) {
282 RTCError err = CheckForIdConflicts( 297 RTCError err = CheckForIdConflicts(
283 codecs_result.value(), extensions_result.value(), 298 codecs_result.value(), extensions_result.value(),
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 return codecs_result.MoveError(); 367 return codecs_result.MoveError();
353 } 368 }
354 369
355 auto extensions_result = 370 auto extensions_result =
356 ToCricketRtpHeaderExtensions(parameters.header_extensions); 371 ToCricketRtpHeaderExtensions(parameters.header_extensions);
357 if (!extensions_result.ok()) { 372 if (!extensions_result.ok()) {
358 return extensions_result.MoveError(); 373 return extensions_result.MoveError();
359 } 374 }
360 375
361 auto stream_params_result = MakeSendStreamParamsVec( 376 auto stream_params_result = MakeSendStreamParamsVec(
362 parameters.encodings, inner_video_transport_->GetRtcpParameters().cname, 377 parameters.encodings, inner_video_transport_->GetParameters().rtcp.cname,
363 local_video_description_); 378 local_video_description_);
364 if (!stream_params_result.ok()) { 379 if (!stream_params_result.ok()) {
365 return stream_params_result.MoveError(); 380 return stream_params_result.MoveError();
366 } 381 }
367 382
368 // Check that audio/video sender aren't using the same IDs to refer to 383 // Check that audio/video sender aren't using the same IDs to refer to
369 // different things, if they share the same transport. 384 // different things, if they share the same transport.
370 if (inner_audio_transport_ == inner_video_transport_) { 385 if (inner_audio_transport_ == inner_video_transport_) {
371 RTCError err = CheckForIdConflicts( 386 RTCError err = CheckForIdConflicts(
372 codecs_result.value(), extensions_result.value(), 387 codecs_result.value(), extensions_result.value(),
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
649 "supported."); 664 "supported.");
650 } 665 }
651 RTCError err = MaybeSetCryptos(inner_transport, &local_audio_description_, 666 RTCError err = MaybeSetCryptos(inner_transport, &local_audio_description_,
652 &remote_audio_description_); 667 &remote_audio_description_);
653 if (!err.ok()) { 668 if (!err.ok()) {
654 return err; 669 return err;
655 } 670 }
656 // If setting new transport, extract its RTCP parameters and create voice 671 // If setting new transport, extract its RTCP parameters and create voice
657 // channel. 672 // channel.
658 if (!inner_audio_transport_) { 673 if (!inner_audio_transport_) {
659 CopyRtcpParametersToDescriptions(inner_transport->GetRtcpParameters(), 674 CopyRtcpParametersToDescriptions(inner_transport->GetParameters().rtcp,
660 &local_audio_description_, 675 &local_audio_description_,
661 &remote_audio_description_); 676 &remote_audio_description_);
662 inner_audio_transport_ = inner_transport; 677 inner_audio_transport_ = inner_transport;
663 CreateVoiceChannel(); 678 CreateVoiceChannel();
664 } 679 }
665 have_audio_sender_ = true; 680 have_audio_sender_ = true;
666 sender->SignalDestroyed.connect( 681 sender->SignalDestroyed.connect(
667 this, &RtpTransportControllerAdapter::OnAudioSenderDestroyed); 682 this, &RtpTransportControllerAdapter::OnAudioSenderDestroyed);
668 return RTCError::OK(); 683 return RTCError::OK();
669 } 684 }
(...skipping 14 matching lines...) Expand all
684 "supported."); 699 "supported.");
685 } 700 }
686 RTCError err = MaybeSetCryptos(inner_transport, &local_video_description_, 701 RTCError err = MaybeSetCryptos(inner_transport, &local_video_description_,
687 &remote_video_description_); 702 &remote_video_description_);
688 if (!err.ok()) { 703 if (!err.ok()) {
689 return err; 704 return err;
690 } 705 }
691 // If setting new transport, extract its RTCP parameters and create video 706 // If setting new transport, extract its RTCP parameters and create video
692 // channel. 707 // channel.
693 if (!inner_video_transport_) { 708 if (!inner_video_transport_) {
694 CopyRtcpParametersToDescriptions(inner_transport->GetRtcpParameters(), 709 CopyRtcpParametersToDescriptions(inner_transport->GetParameters().rtcp,
695 &local_video_description_, 710 &local_video_description_,
696 &remote_video_description_); 711 &remote_video_description_);
697 inner_video_transport_ = inner_transport; 712 inner_video_transport_ = inner_transport;
698 CreateVideoChannel(); 713 CreateVideoChannel();
699 } 714 }
700 have_video_sender_ = true; 715 have_video_sender_ = true;
701 sender->SignalDestroyed.connect( 716 sender->SignalDestroyed.connect(
702 this, &RtpTransportControllerAdapter::OnVideoSenderDestroyed); 717 this, &RtpTransportControllerAdapter::OnVideoSenderDestroyed);
703 return RTCError::OK(); 718 return RTCError::OK();
704 } 719 }
(...skipping 14 matching lines...) Expand all
719 "supported."); 734 "supported.");
720 } 735 }
721 RTCError err = MaybeSetCryptos(inner_transport, &local_audio_description_, 736 RTCError err = MaybeSetCryptos(inner_transport, &local_audio_description_,
722 &remote_audio_description_); 737 &remote_audio_description_);
723 if (!err.ok()) { 738 if (!err.ok()) {
724 return err; 739 return err;
725 } 740 }
726 // If setting new transport, extract its RTCP parameters and create voice 741 // If setting new transport, extract its RTCP parameters and create voice
727 // channel. 742 // channel.
728 if (!inner_audio_transport_) { 743 if (!inner_audio_transport_) {
729 CopyRtcpParametersToDescriptions(inner_transport->GetRtcpParameters(), 744 CopyRtcpParametersToDescriptions(inner_transport->GetParameters().rtcp,
730 &local_audio_description_, 745 &local_audio_description_,
731 &remote_audio_description_); 746 &remote_audio_description_);
732 inner_audio_transport_ = inner_transport; 747 inner_audio_transport_ = inner_transport;
733 CreateVoiceChannel(); 748 CreateVoiceChannel();
734 } 749 }
735 have_audio_receiver_ = true; 750 have_audio_receiver_ = true;
736 receiver->SignalDestroyed.connect( 751 receiver->SignalDestroyed.connect(
737 this, &RtpTransportControllerAdapter::OnAudioReceiverDestroyed); 752 this, &RtpTransportControllerAdapter::OnAudioReceiverDestroyed);
738 return RTCError::OK(); 753 return RTCError::OK();
739 } 754 }
(...skipping 14 matching lines...) Expand all
754 "supported."); 769 "supported.");
755 } 770 }
756 RTCError err = MaybeSetCryptos(inner_transport, &local_video_description_, 771 RTCError err = MaybeSetCryptos(inner_transport, &local_video_description_,
757 &remote_video_description_); 772 &remote_video_description_);
758 if (!err.ok()) { 773 if (!err.ok()) {
759 return err; 774 return err;
760 } 775 }
761 // If setting new transport, extract its RTCP parameters and create video 776 // If setting new transport, extract its RTCP parameters and create video
762 // channel. 777 // channel.
763 if (!inner_video_transport_) { 778 if (!inner_video_transport_) {
764 CopyRtcpParametersToDescriptions(inner_transport->GetRtcpParameters(), 779 CopyRtcpParametersToDescriptions(inner_transport->GetParameters().rtcp,
765 &local_video_description_, 780 &local_video_description_,
766 &remote_video_description_); 781 &remote_video_description_);
767 inner_video_transport_ = inner_transport; 782 inner_video_transport_ = inner_transport;
768 CreateVideoChannel(); 783 CreateVideoChannel();
769 } 784 }
770 have_video_receiver_ = true; 785 have_video_receiver_ = true;
771 receiver->SignalDestroyed.connect( 786 receiver->SignalDestroyed.connect(
772 this, &RtpTransportControllerAdapter::OnVideoReceiverDestroyed); 787 this, &RtpTransportControllerAdapter::OnVideoReceiverDestroyed);
773 return RTCError::OK(); 788 return RTCError::OK();
774 } 789 }
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
974 local_description->set_cryptos(cryptos); 989 local_description->set_cryptos(cryptos);
975 990
976 cryptos.clear(); 991 cryptos.clear();
977 cryptos.push_back(*(rtp_transport->GetInternal()->send_key())); 992 cryptos.push_back(*(rtp_transport->GetInternal()->send_key()));
978 remote_description->set_cryptos(cryptos); 993 remote_description->set_cryptos(cryptos);
979 } 994 }
980 return RTCError::OK(); 995 return RTCError::OK();
981 } 996 }
982 997
983 } // namespace webrtc 998 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698