OLD | NEW |
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 Loading... |
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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 cricket::CA_ANSWER, nullptr)) { | 244 cricket::CA_ANSWER, nullptr)) { |
246 break; | 245 break; |
247 } | 246 } |
248 } | 247 } |
249 return RTCError::OK(); | 248 return RTCError::OK(); |
250 } while (false); | 249 } while (false); |
251 LOG_AND_RETURN_ERROR(RTCErrorType::INTERNAL_ERROR, | 250 LOG_AND_RETURN_ERROR(RTCErrorType::INTERNAL_ERROR, |
252 "Failed to apply new RTCP parameters."); | 251 "Failed to apply new RTCP parameters."); |
253 } | 252 } |
254 | 253 |
| 254 RTCError RtpTransportControllerAdapter::SetRtpTransportParameters( |
| 255 const RtpTransportParameters& parameters) { |
| 256 if (!call_->SetRtpKeepAliveConfig(parameters.keepalive)) { |
| 257 LOG_AND_RETURN_ERROR(RTCErrorType::INTERNAL_ERROR, |
| 258 "Failed to apply new RTP transport parameters."); |
| 259 } |
| 260 return RTCError::OK(); |
| 261 } |
| 262 |
255 RTCError RtpTransportControllerAdapter::ValidateAndApplyAudioSenderParameters( | 263 RTCError RtpTransportControllerAdapter::ValidateAndApplyAudioSenderParameters( |
256 const RtpParameters& parameters, | 264 const RtpParameters& parameters, |
257 uint32_t* primary_ssrc) { | 265 uint32_t* primary_ssrc) { |
258 RTC_DCHECK(voice_channel_); | 266 RTC_DCHECK(voice_channel_); |
259 RTC_DCHECK(have_audio_sender_); | 267 RTC_DCHECK(have_audio_sender_); |
260 | 268 |
261 auto codecs_result = ToCricketCodecs<cricket::AudioCodec>(parameters.codecs); | 269 auto codecs_result = ToCricketCodecs<cricket::AudioCodec>(parameters.codecs); |
262 if (!codecs_result.ok()) { | 270 if (!codecs_result.ok()) { |
263 return codecs_result.MoveError(); | 271 return codecs_result.MoveError(); |
264 } | 272 } |
265 | 273 |
266 auto extensions_result = | 274 auto extensions_result = |
267 ToCricketRtpHeaderExtensions(parameters.header_extensions); | 275 ToCricketRtpHeaderExtensions(parameters.header_extensions); |
268 if (!extensions_result.ok()) { | 276 if (!extensions_result.ok()) { |
269 return extensions_result.MoveError(); | 277 return extensions_result.MoveError(); |
270 } | 278 } |
271 | 279 |
272 auto stream_params_result = MakeSendStreamParamsVec( | 280 auto stream_params_result = MakeSendStreamParamsVec( |
273 parameters.encodings, inner_audio_transport_->GetRtcpParameters().cname, | 281 parameters.encodings, inner_audio_transport_->GetParameters().rtcp.cname, |
274 local_audio_description_); | 282 local_audio_description_); |
275 if (!stream_params_result.ok()) { | 283 if (!stream_params_result.ok()) { |
276 return stream_params_result.MoveError(); | 284 return stream_params_result.MoveError(); |
277 } | 285 } |
278 | 286 |
279 // Check that audio/video sender aren't using the same IDs to refer to | 287 // Check that audio/video sender aren't using the same IDs to refer to |
280 // different things, if they share the same transport. | 288 // different things, if they share the same transport. |
281 if (inner_audio_transport_ == inner_video_transport_) { | 289 if (inner_audio_transport_ == inner_video_transport_) { |
282 RTCError err = CheckForIdConflicts( | 290 RTCError err = CheckForIdConflicts( |
283 codecs_result.value(), extensions_result.value(), | 291 codecs_result.value(), extensions_result.value(), |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 return codecs_result.MoveError(); | 360 return codecs_result.MoveError(); |
353 } | 361 } |
354 | 362 |
355 auto extensions_result = | 363 auto extensions_result = |
356 ToCricketRtpHeaderExtensions(parameters.header_extensions); | 364 ToCricketRtpHeaderExtensions(parameters.header_extensions); |
357 if (!extensions_result.ok()) { | 365 if (!extensions_result.ok()) { |
358 return extensions_result.MoveError(); | 366 return extensions_result.MoveError(); |
359 } | 367 } |
360 | 368 |
361 auto stream_params_result = MakeSendStreamParamsVec( | 369 auto stream_params_result = MakeSendStreamParamsVec( |
362 parameters.encodings, inner_video_transport_->GetRtcpParameters().cname, | 370 parameters.encodings, inner_video_transport_->GetParameters().rtcp.cname, |
363 local_video_description_); | 371 local_video_description_); |
364 if (!stream_params_result.ok()) { | 372 if (!stream_params_result.ok()) { |
365 return stream_params_result.MoveError(); | 373 return stream_params_result.MoveError(); |
366 } | 374 } |
367 | 375 |
368 // Check that audio/video sender aren't using the same IDs to refer to | 376 // Check that audio/video sender aren't using the same IDs to refer to |
369 // different things, if they share the same transport. | 377 // different things, if they share the same transport. |
370 if (inner_audio_transport_ == inner_video_transport_) { | 378 if (inner_audio_transport_ == inner_video_transport_) { |
371 RTCError err = CheckForIdConflicts( | 379 RTCError err = CheckForIdConflicts( |
372 codecs_result.value(), extensions_result.value(), | 380 codecs_result.value(), extensions_result.value(), |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
649 "supported."); | 657 "supported."); |
650 } | 658 } |
651 RTCError err = MaybeSetCryptos(inner_transport, &local_audio_description_, | 659 RTCError err = MaybeSetCryptos(inner_transport, &local_audio_description_, |
652 &remote_audio_description_); | 660 &remote_audio_description_); |
653 if (!err.ok()) { | 661 if (!err.ok()) { |
654 return err; | 662 return err; |
655 } | 663 } |
656 // If setting new transport, extract its RTCP parameters and create voice | 664 // If setting new transport, extract its RTCP parameters and create voice |
657 // channel. | 665 // channel. |
658 if (!inner_audio_transport_) { | 666 if (!inner_audio_transport_) { |
659 CopyRtcpParametersToDescriptions(inner_transport->GetRtcpParameters(), | 667 CopyRtcpParametersToDescriptions(inner_transport->GetParameters().rtcp, |
660 &local_audio_description_, | 668 &local_audio_description_, |
661 &remote_audio_description_); | 669 &remote_audio_description_); |
662 inner_audio_transport_ = inner_transport; | 670 inner_audio_transport_ = inner_transport; |
663 CreateVoiceChannel(); | 671 CreateVoiceChannel(); |
664 } | 672 } |
665 have_audio_sender_ = true; | 673 have_audio_sender_ = true; |
666 sender->SignalDestroyed.connect( | 674 sender->SignalDestroyed.connect( |
667 this, &RtpTransportControllerAdapter::OnAudioSenderDestroyed); | 675 this, &RtpTransportControllerAdapter::OnAudioSenderDestroyed); |
668 return RTCError::OK(); | 676 return RTCError::OK(); |
669 } | 677 } |
(...skipping 14 matching lines...) Expand all Loading... |
684 "supported."); | 692 "supported."); |
685 } | 693 } |
686 RTCError err = MaybeSetCryptos(inner_transport, &local_video_description_, | 694 RTCError err = MaybeSetCryptos(inner_transport, &local_video_description_, |
687 &remote_video_description_); | 695 &remote_video_description_); |
688 if (!err.ok()) { | 696 if (!err.ok()) { |
689 return err; | 697 return err; |
690 } | 698 } |
691 // If setting new transport, extract its RTCP parameters and create video | 699 // If setting new transport, extract its RTCP parameters and create video |
692 // channel. | 700 // channel. |
693 if (!inner_video_transport_) { | 701 if (!inner_video_transport_) { |
694 CopyRtcpParametersToDescriptions(inner_transport->GetRtcpParameters(), | 702 CopyRtcpParametersToDescriptions(inner_transport->GetParameters().rtcp, |
695 &local_video_description_, | 703 &local_video_description_, |
696 &remote_video_description_); | 704 &remote_video_description_); |
697 inner_video_transport_ = inner_transport; | 705 inner_video_transport_ = inner_transport; |
698 CreateVideoChannel(); | 706 CreateVideoChannel(); |
699 } | 707 } |
700 have_video_sender_ = true; | 708 have_video_sender_ = true; |
701 sender->SignalDestroyed.connect( | 709 sender->SignalDestroyed.connect( |
702 this, &RtpTransportControllerAdapter::OnVideoSenderDestroyed); | 710 this, &RtpTransportControllerAdapter::OnVideoSenderDestroyed); |
703 return RTCError::OK(); | 711 return RTCError::OK(); |
704 } | 712 } |
(...skipping 14 matching lines...) Expand all Loading... |
719 "supported."); | 727 "supported."); |
720 } | 728 } |
721 RTCError err = MaybeSetCryptos(inner_transport, &local_audio_description_, | 729 RTCError err = MaybeSetCryptos(inner_transport, &local_audio_description_, |
722 &remote_audio_description_); | 730 &remote_audio_description_); |
723 if (!err.ok()) { | 731 if (!err.ok()) { |
724 return err; | 732 return err; |
725 } | 733 } |
726 // If setting new transport, extract its RTCP parameters and create voice | 734 // If setting new transport, extract its RTCP parameters and create voice |
727 // channel. | 735 // channel. |
728 if (!inner_audio_transport_) { | 736 if (!inner_audio_transport_) { |
729 CopyRtcpParametersToDescriptions(inner_transport->GetRtcpParameters(), | 737 CopyRtcpParametersToDescriptions(inner_transport->GetParameters().rtcp, |
730 &local_audio_description_, | 738 &local_audio_description_, |
731 &remote_audio_description_); | 739 &remote_audio_description_); |
732 inner_audio_transport_ = inner_transport; | 740 inner_audio_transport_ = inner_transport; |
733 CreateVoiceChannel(); | 741 CreateVoiceChannel(); |
734 } | 742 } |
735 have_audio_receiver_ = true; | 743 have_audio_receiver_ = true; |
736 receiver->SignalDestroyed.connect( | 744 receiver->SignalDestroyed.connect( |
737 this, &RtpTransportControllerAdapter::OnAudioReceiverDestroyed); | 745 this, &RtpTransportControllerAdapter::OnAudioReceiverDestroyed); |
738 return RTCError::OK(); | 746 return RTCError::OK(); |
739 } | 747 } |
(...skipping 14 matching lines...) Expand all Loading... |
754 "supported."); | 762 "supported."); |
755 } | 763 } |
756 RTCError err = MaybeSetCryptos(inner_transport, &local_video_description_, | 764 RTCError err = MaybeSetCryptos(inner_transport, &local_video_description_, |
757 &remote_video_description_); | 765 &remote_video_description_); |
758 if (!err.ok()) { | 766 if (!err.ok()) { |
759 return err; | 767 return err; |
760 } | 768 } |
761 // If setting new transport, extract its RTCP parameters and create video | 769 // If setting new transport, extract its RTCP parameters and create video |
762 // channel. | 770 // channel. |
763 if (!inner_video_transport_) { | 771 if (!inner_video_transport_) { |
764 CopyRtcpParametersToDescriptions(inner_transport->GetRtcpParameters(), | 772 CopyRtcpParametersToDescriptions(inner_transport->GetParameters().rtcp, |
765 &local_video_description_, | 773 &local_video_description_, |
766 &remote_video_description_); | 774 &remote_video_description_); |
767 inner_video_transport_ = inner_transport; | 775 inner_video_transport_ = inner_transport; |
768 CreateVideoChannel(); | 776 CreateVideoChannel(); |
769 } | 777 } |
770 have_video_receiver_ = true; | 778 have_video_receiver_ = true; |
771 receiver->SignalDestroyed.connect( | 779 receiver->SignalDestroyed.connect( |
772 this, &RtpTransportControllerAdapter::OnVideoReceiverDestroyed); | 780 this, &RtpTransportControllerAdapter::OnVideoReceiverDestroyed); |
773 return RTCError::OK(); | 781 return RTCError::OK(); |
774 } | 782 } |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
974 local_description->set_cryptos(cryptos); | 982 local_description->set_cryptos(cryptos); |
975 | 983 |
976 cryptos.clear(); | 984 cryptos.clear(); |
977 cryptos.push_back(*(rtp_transport->GetInternal()->send_key())); | 985 cryptos.push_back(*(rtp_transport->GetInternal()->send_key())); |
978 remote_description->set_cryptos(cryptos); | 986 remote_description->set_cryptos(cryptos); |
979 } | 987 } |
980 return RTCError::OK(); | 988 return RTCError::OK(); |
981 } | 989 } |
982 | 990 |
983 } // namespace webrtc | 991 } // namespace webrtc |
OLD | NEW |