OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2004 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2004 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 |
11 #include <algorithm> | |
12 #include <iterator> | |
11 #include <utility> | 13 #include <utility> |
12 | 14 |
13 #include "webrtc/pc/channel.h" | 15 #include "webrtc/pc/channel.h" |
14 | 16 |
15 #include "webrtc/api/call/audio_sink.h" | 17 #include "webrtc/api/call/audio_sink.h" |
16 #include "webrtc/base/bind.h" | 18 #include "webrtc/base/bind.h" |
17 #include "webrtc/base/byteorder.h" | 19 #include "webrtc/base/byteorder.h" |
18 #include "webrtc/base/checks.h" | 20 #include "webrtc/base/checks.h" |
19 #include "webrtc/base/copyonwritebuffer.h" | 21 #include "webrtc/base/copyonwritebuffer.h" |
20 #include "webrtc/base/dscp.h" | 22 #include "webrtc/base/dscp.h" |
(...skipping 18 matching lines...) Expand all Loading... | |
39 std::unique_ptr<webrtc::AudioSinkInterface>* sink) { | 41 std::unique_ptr<webrtc::AudioSinkInterface>* sink) { |
40 channel->SetRawAudioSink(ssrc, std::move(*sink)); | 42 channel->SetRawAudioSink(ssrc, std::move(*sink)); |
41 return true; | 43 return true; |
42 } | 44 } |
43 | 45 |
44 struct SendPacketMessageData : public rtc::MessageData { | 46 struct SendPacketMessageData : public rtc::MessageData { |
45 rtc::CopyOnWriteBuffer packet; | 47 rtc::CopyOnWriteBuffer packet; |
46 rtc::PacketOptions options; | 48 rtc::PacketOptions options; |
47 }; | 49 }; |
48 | 50 |
49 #if defined(ENABLE_EXTERNAL_AUTH) | |
50 // Returns the named header extension if found among all extensions, | |
51 // nullptr otherwise. | |
52 const webrtc::RtpExtension* FindHeaderExtension( | |
53 const std::vector<webrtc::RtpExtension>& extensions, | |
54 const std::string& uri) { | |
55 for (const auto& extension : extensions) { | |
56 if (extension.uri == uri) | |
57 return &extension; | |
58 } | |
59 return nullptr; | |
60 } | |
61 #endif | |
62 | |
63 } // namespace | 51 } // namespace |
64 | 52 |
65 enum { | 53 enum { |
66 MSG_EARLYMEDIATIMEOUT = 1, | 54 MSG_EARLYMEDIATIMEOUT = 1, |
67 MSG_SEND_RTP_PACKET, | 55 MSG_SEND_RTP_PACKET, |
68 MSG_SEND_RTCP_PACKET, | 56 MSG_SEND_RTCP_PACKET, |
69 MSG_CHANNEL_ERROR, | 57 MSG_CHANNEL_ERROR, |
70 MSG_READYTOSENDDATA, | 58 MSG_READYTOSENDDATA, |
71 MSG_DATARECEIVED, | 59 MSG_DATARECEIVED, |
72 MSG_FIRSTPACKETRECEIVED, | 60 MSG_FIRSTPACKETRECEIVED, |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
123 static const MediaContentDescription* GetContentDescription( | 111 static const MediaContentDescription* GetContentDescription( |
124 const ContentInfo* cinfo) { | 112 const ContentInfo* cinfo) { |
125 if (cinfo == NULL) | 113 if (cinfo == NULL) |
126 return NULL; | 114 return NULL; |
127 return static_cast<const MediaContentDescription*>(cinfo->description); | 115 return static_cast<const MediaContentDescription*>(cinfo->description); |
128 } | 116 } |
129 | 117 |
130 template <class Codec> | 118 template <class Codec> |
131 void RtpParametersFromMediaDescription( | 119 void RtpParametersFromMediaDescription( |
132 const MediaContentDescriptionImpl<Codec>* desc, | 120 const MediaContentDescriptionImpl<Codec>* desc, |
121 const RtpHeaderExtensions& extensions, | |
133 RtpParameters<Codec>* params) { | 122 RtpParameters<Codec>* params) { |
134 // TODO(pthatcher): Remove this once we're sure no one will give us | 123 // TODO(pthatcher): Remove this once we're sure no one will give us |
135 // a description without codecs (currently a CA_UPDATE with just | 124 // a description without codecs (currently a CA_UPDATE with just |
136 // streams can). | 125 // streams can). |
137 if (desc->has_codecs()) { | 126 if (desc->has_codecs()) { |
138 params->codecs = desc->codecs(); | 127 params->codecs = desc->codecs(); |
139 } | 128 } |
140 // TODO(pthatcher): See if we really need | 129 // TODO(pthatcher): See if we really need |
141 // rtp_header_extensions_set() and remove it if we don't. | 130 // rtp_header_extensions_set() and remove it if we don't. |
142 if (desc->rtp_header_extensions_set()) { | 131 if (desc->rtp_header_extensions_set()) { |
143 params->extensions = desc->rtp_header_extensions(); | 132 params->extensions = extensions; |
144 } | 133 } |
145 params->rtcp.reduced_size = desc->rtcp_reduced_size(); | 134 params->rtcp.reduced_size = desc->rtcp_reduced_size(); |
146 } | 135 } |
147 | 136 |
148 template <class Codec> | 137 template <class Codec> |
149 void RtpSendParametersFromMediaDescription( | 138 void RtpSendParametersFromMediaDescription( |
150 const MediaContentDescriptionImpl<Codec>* desc, | 139 const MediaContentDescriptionImpl<Codec>* desc, |
140 const RtpHeaderExtensions& extensions, | |
151 RtpSendParameters<Codec>* send_params) { | 141 RtpSendParameters<Codec>* send_params) { |
152 RtpParametersFromMediaDescription(desc, send_params); | 142 RtpParametersFromMediaDescription(desc, extensions, send_params); |
153 send_params->max_bandwidth_bps = desc->bandwidth(); | 143 send_params->max_bandwidth_bps = desc->bandwidth(); |
154 } | 144 } |
155 | 145 |
156 BaseChannel::BaseChannel(rtc::Thread* worker_thread, | 146 BaseChannel::BaseChannel(rtc::Thread* worker_thread, |
157 rtc::Thread* network_thread, | 147 rtc::Thread* network_thread, |
158 rtc::Thread* signaling_thread, | 148 rtc::Thread* signaling_thread, |
159 MediaChannel* media_channel, | 149 MediaChannel* media_channel, |
160 const std::string& content_name, | 150 const std::string& content_name, |
161 bool rtcp_mux_required, | 151 bool rtcp_mux_required, |
162 bool srtp_required) | 152 bool srtp_required) |
(...skipping 828 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
991 } | 981 } |
992 | 982 |
993 if (role == rtc::SSL_SERVER) { | 983 if (role == rtc::SSL_SERVER) { |
994 send_key = &server_write_key; | 984 send_key = &server_write_key; |
995 recv_key = &client_write_key; | 985 recv_key = &client_write_key; |
996 } else { | 986 } else { |
997 send_key = &client_write_key; | 987 send_key = &client_write_key; |
998 recv_key = &server_write_key; | 988 recv_key = &server_write_key; |
999 } | 989 } |
1000 | 990 |
1001 if (rtcp) { | 991 if (!srtp_filter_.IsActive()) { |
1002 ret = srtp_filter_.SetRtcpParams(selected_crypto_suite, &(*send_key)[0], | 992 if (rtcp) { |
1003 static_cast<int>(send_key->size()), | 993 ret = srtp_filter_.SetRtcpParams(selected_crypto_suite, &(*send_key)[0], |
1004 selected_crypto_suite, &(*recv_key)[0], | 994 static_cast<int>(send_key->size()), |
1005 static_cast<int>(recv_key->size())); | 995 selected_crypto_suite, &(*recv_key)[0], |
996 static_cast<int>(recv_key->size())); | |
997 } else { | |
998 ret = srtp_filter_.SetRtpParams(selected_crypto_suite, &(*send_key)[0], | |
999 static_cast<int>(send_key->size()), | |
1000 selected_crypto_suite, &(*recv_key)[0], | |
1001 static_cast<int>(recv_key->size())); | |
1002 } | |
1006 } else { | 1003 } else { |
1007 ret = srtp_filter_.SetRtpParams(selected_crypto_suite, &(*send_key)[0], | 1004 if (rtcp) { |
1008 static_cast<int>(send_key->size()), | 1005 // RTCP doesn't need to be updated because UpdateRtpParams is only used |
1009 selected_crypto_suite, &(*recv_key)[0], | 1006 // to update the set of encrypted RTP header extension IDs. |
1010 static_cast<int>(recv_key->size())); | 1007 ret = true; |
1008 } else { | |
1009 ret = srtp_filter_.UpdateRtpParams( | |
1010 selected_crypto_suite, | |
1011 &(*send_key)[0], static_cast<int>(send_key->size()), | |
1012 selected_crypto_suite, | |
1013 &(*recv_key)[0], static_cast<int>(recv_key->size())); | |
1014 } | |
1011 } | 1015 } |
1012 | 1016 |
1013 if (!ret) { | 1017 if (!ret) { |
1014 LOG(LS_WARNING) << "DTLS-SRTP key installation failed"; | 1018 LOG(LS_WARNING) << "DTLS-SRTP key installation failed"; |
1015 } else { | 1019 } else { |
1016 dtls_keyed_ = true; | 1020 dtls_keyed_ = true; |
1017 UpdateTransportOverhead(); | 1021 UpdateTransportOverhead(); |
1018 } | 1022 } |
1019 return ret; | 1023 return ret; |
1020 } | 1024 } |
(...skipping 27 matching lines...) Expand all Loading... | |
1048 | 1052 |
1049 LOG(LS_INFO) << "Channel not writable (" << content_name_ << ")"; | 1053 LOG(LS_INFO) << "Channel not writable (" << content_name_ << ")"; |
1050 writable_ = false; | 1054 writable_ = false; |
1051 UpdateMediaSendRecvState(); | 1055 UpdateMediaSendRecvState(); |
1052 } | 1056 } |
1053 | 1057 |
1054 bool BaseChannel::SetRtpTransportParameters( | 1058 bool BaseChannel::SetRtpTransportParameters( |
1055 const MediaContentDescription* content, | 1059 const MediaContentDescription* content, |
1056 ContentAction action, | 1060 ContentAction action, |
1057 ContentSource src, | 1061 ContentSource src, |
1062 const RtpHeaderExtensions& extensions, | |
1058 std::string* error_desc) { | 1063 std::string* error_desc) { |
1059 if (action == CA_UPDATE) { | 1064 if (action == CA_UPDATE) { |
1060 // These parameters never get changed by a CA_UDPATE. | 1065 // These parameters never get changed by a CA_UDPATE. |
1061 return true; | 1066 return true; |
1062 } | 1067 } |
1063 | 1068 |
1069 std::vector<int> encrypted_extension_ids; | |
1070 for (const webrtc::RtpExtension& extension : extensions) { | |
1071 if (extension.encrypt) { | |
1072 LOG(LS_INFO) << "Using " << (src == CS_LOCAL ? "local" : "remote") | |
1073 << " encrypted extension: " << extension.ToString(); | |
1074 encrypted_extension_ids.push_back(extension.id); | |
1075 } | |
1076 } | |
1077 | |
1064 // Cache srtp_required_ for belt and suspenders check on SendPacket | 1078 // Cache srtp_required_ for belt and suspenders check on SendPacket |
1065 return network_thread_->Invoke<bool>( | 1079 return network_thread_->Invoke<bool>( |
1066 RTC_FROM_HERE, Bind(&BaseChannel::SetRtpTransportParameters_n, this, | 1080 RTC_FROM_HERE, Bind(&BaseChannel::SetRtpTransportParameters_n, this, |
1067 content, action, src, error_desc)); | 1081 content, action, src, encrypted_extension_ids, |
1082 error_desc)); | |
1068 } | 1083 } |
1069 | 1084 |
1070 bool BaseChannel::SetRtpTransportParameters_n( | 1085 bool BaseChannel::SetRtpTransportParameters_n( |
1071 const MediaContentDescription* content, | 1086 const MediaContentDescription* content, |
1072 ContentAction action, | 1087 ContentAction action, |
1073 ContentSource src, | 1088 ContentSource src, |
1089 const std::vector<int>& encrypted_extension_ids, | |
1074 std::string* error_desc) { | 1090 std::string* error_desc) { |
1075 RTC_DCHECK(network_thread_->IsCurrent()); | 1091 RTC_DCHECK(network_thread_->IsCurrent()); |
1076 | 1092 |
1077 if (!SetSrtp_n(content->cryptos(), action, src, error_desc)) { | 1093 if (!SetSrtp_n(content->cryptos(), action, src, encrypted_extension_ids, |
1094 error_desc)) { | |
1078 return false; | 1095 return false; |
1079 } | 1096 } |
1080 | 1097 |
1081 if (!SetRtcpMux_n(content->rtcp_mux(), action, src, error_desc)) { | 1098 if (!SetRtcpMux_n(content->rtcp_mux(), action, src, error_desc)) { |
1082 return false; | 1099 return false; |
1083 } | 1100 } |
1084 | 1101 |
1085 return true; | 1102 return true; |
1086 } | 1103 } |
1087 | 1104 |
1088 // |dtls| will be set to true if DTLS is active for transport and crypto is | 1105 // |dtls| will be set to true if DTLS is active for transport and crypto is |
1089 // empty. | 1106 // empty. |
1090 bool BaseChannel::CheckSrtpConfig_n(const std::vector<CryptoParams>& cryptos, | 1107 bool BaseChannel::CheckSrtpConfig_n(const std::vector<CryptoParams>& cryptos, |
1091 bool* dtls, | 1108 bool* dtls, |
1092 std::string* error_desc) { | 1109 std::string* error_desc) { |
1093 *dtls = rtp_dtls_transport_ && rtp_dtls_transport_->IsDtlsActive(); | 1110 *dtls = rtp_dtls_transport_ && rtp_dtls_transport_->IsDtlsActive(); |
1094 if (*dtls && !cryptos.empty()) { | 1111 if (*dtls && !cryptos.empty()) { |
1095 SafeSetError("Cryptos must be empty when DTLS is active.", error_desc); | 1112 SafeSetError("Cryptos must be empty when DTLS is active.", error_desc); |
1096 return false; | 1113 return false; |
1097 } | 1114 } |
1098 return true; | 1115 return true; |
1099 } | 1116 } |
1100 | 1117 |
1101 bool BaseChannel::SetSrtp_n(const std::vector<CryptoParams>& cryptos, | 1118 bool BaseChannel::SetSrtp_n(const std::vector<CryptoParams>& cryptos, |
1102 ContentAction action, | 1119 ContentAction action, |
1103 ContentSource src, | 1120 ContentSource src, |
1121 const std::vector<int>& encrypted_extension_ids, | |
1104 std::string* error_desc) { | 1122 std::string* error_desc) { |
1105 TRACE_EVENT0("webrtc", "BaseChannel::SetSrtp_w"); | 1123 TRACE_EVENT0("webrtc", "BaseChannel::SetSrtp_w"); |
1106 if (action == CA_UPDATE) { | 1124 if (action == CA_UPDATE) { |
1107 // no crypto params. | 1125 // no crypto params. |
1108 return true; | 1126 return true; |
1109 } | 1127 } |
1110 bool ret = false; | 1128 bool ret = false; |
1111 bool dtls = false; | 1129 bool dtls = false; |
1112 ret = CheckSrtpConfig_n(cryptos, &dtls, error_desc); | 1130 ret = CheckSrtpConfig_n(cryptos, &dtls, error_desc); |
1113 if (!ret) { | 1131 if (!ret) { |
1114 return false; | 1132 return false; |
1115 } | 1133 } |
1134 srtp_filter_.SetEncryptedHeaderExtensionIds(src, encrypted_extension_ids); | |
1116 switch (action) { | 1135 switch (action) { |
1117 case CA_OFFER: | 1136 case CA_OFFER: |
1118 // If DTLS is already active on the channel, we could be renegotiating | 1137 // If DTLS is already active on the channel, we could be renegotiating |
1119 // here. We don't update the srtp filter. | 1138 // here. We don't update the srtp filter. |
1120 if (!dtls) { | 1139 if (!dtls) { |
1121 ret = srtp_filter_.SetOffer(cryptos, src); | 1140 ret = srtp_filter_.SetOffer(cryptos, src); |
1122 } | 1141 } |
1123 break; | 1142 break; |
1124 case CA_PRANSWER: | 1143 case CA_PRANSWER: |
1125 // If we're doing DTLS-SRTP, we don't want to update the filter | 1144 // If we're doing DTLS-SRTP, we don't want to update the filter |
1126 // with an answer, because we already have SRTP parameters. | 1145 // with an answer, because we already have SRTP parameters. |
1127 if (!dtls) { | 1146 if (!dtls) { |
1128 ret = srtp_filter_.SetProvisionalAnswer(cryptos, src); | 1147 ret = srtp_filter_.SetProvisionalAnswer(cryptos, src); |
1129 } | 1148 } |
1130 break; | 1149 break; |
1131 case CA_ANSWER: | 1150 case CA_ANSWER: |
1132 // If we're doing DTLS-SRTP, we don't want to update the filter | 1151 // If we're doing DTLS-SRTP, we don't want to update the filter |
1133 // with an answer, because we already have SRTP parameters. | 1152 // with an answer, because we already have SRTP parameters. |
1134 if (!dtls) { | 1153 if (!dtls) { |
1135 ret = srtp_filter_.SetAnswer(cryptos, src); | 1154 ret = srtp_filter_.SetAnswer(cryptos, src); |
1136 } | 1155 } |
1137 break; | 1156 break; |
1138 default: | 1157 default: |
1139 break; | 1158 break; |
1140 } | 1159 } |
1160 // Only update SRTP filter if using DTLS. SDES is handled internally | |
1161 // by the SRTP filter. | |
1162 // TODO(jbauch): Only update if encrypted extension ids have changed. | |
1163 if (ret && dtls_keyed_ && rtp_dtls_transport_ && | |
1164 (rtp_dtls_transport_->dtls_state() == DTLS_TRANSPORT_NEW || | |
Taylor Brandstetter
2017/06/28 11:28:20
Why DTLS_TRANSPORT_NEW? If the state is DTLS_TRANS
joachim
2017/06/28 17:03:05
Right. I got confused by the otherwise failing "Te
Taylor Brandstetter
2017/06/29 06:59:09
Ah, understood.
| |
1165 rtp_dtls_transport_->dtls_state() == DTLS_TRANSPORT_CONNECTED)) { | |
1166 bool rtcp = false; | |
1167 ret = SetupDtlsSrtp_n(rtcp); | |
1168 } | |
1141 if (!ret) { | 1169 if (!ret) { |
1142 SafeSetError("Failed to setup SRTP filter.", error_desc); | 1170 SafeSetError("Failed to setup SRTP filter.", error_desc); |
1143 return false; | 1171 return false; |
1144 } | 1172 } |
1145 return true; | 1173 return true; |
1146 } | 1174 } |
1147 | 1175 |
1148 bool BaseChannel::SetRtcpMux_n(bool enable, | 1176 bool BaseChannel::SetRtcpMux_n(bool enable, |
1149 ContentAction action, | 1177 ContentAction action, |
1150 ContentSource src, | 1178 ContentSource src, |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1362 desc << "Failed to add remote stream ssrc: " << it->first_ssrc(); | 1390 desc << "Failed to add remote stream ssrc: " << it->first_ssrc(); |
1363 SafeSetError(desc.str(), error_desc); | 1391 SafeSetError(desc.str(), error_desc); |
1364 ret = false; | 1392 ret = false; |
1365 } | 1393 } |
1366 } | 1394 } |
1367 } | 1395 } |
1368 remote_streams_ = streams; | 1396 remote_streams_ = streams; |
1369 return ret; | 1397 return ret; |
1370 } | 1398 } |
1371 | 1399 |
1400 RtpHeaderExtensions BaseChannel::GetFilteredRtpHeaderExtensions( | |
1401 const RtpHeaderExtensions& extensions) { | |
1402 if (!rtp_dtls_transport_ || | |
1403 !rtp_dtls_transport_->crypto_options() | |
1404 .enable_encrypted_rtp_header_extensions) { | |
1405 RtpHeaderExtensions filtered; | |
1406 auto pred = [](const webrtc::RtpExtension& extension) { | |
1407 return !extension.encrypt; | |
1408 }; | |
1409 std::copy_if(extensions.begin(), extensions.end(), | |
1410 std::back_inserter(filtered), pred); | |
1411 return filtered; | |
1412 } | |
1413 | |
1414 return webrtc::RtpExtension::FilterDuplicateNonEncrypted(extensions); | |
1415 } | |
1416 | |
1372 void BaseChannel::MaybeCacheRtpAbsSendTimeHeaderExtension_w( | 1417 void BaseChannel::MaybeCacheRtpAbsSendTimeHeaderExtension_w( |
1373 const std::vector<webrtc::RtpExtension>& extensions) { | 1418 const std::vector<webrtc::RtpExtension>& extensions) { |
1374 // Absolute Send Time extension id is used only with external auth, | 1419 // Absolute Send Time extension id is used only with external auth, |
1375 // so do not bother searching for it and making asyncronious call to set | 1420 // so do not bother searching for it and making asyncronious call to set |
1376 // something that is not used. | 1421 // something that is not used. |
1377 #if defined(ENABLE_EXTERNAL_AUTH) | 1422 #if defined(ENABLE_EXTERNAL_AUTH) |
1378 const webrtc::RtpExtension* send_time_extension = | 1423 const webrtc::RtpExtension* send_time_extension = |
1379 FindHeaderExtension(extensions, webrtc::RtpExtension::kAbsSendTimeUri); | 1424 webrtc::RtpExtension::FindHeaderExtensionByUri( |
1425 extensions, webrtc::RtpExtension::kAbsSendTimeUri); | |
1380 int rtp_abs_sendtime_extn_id = | 1426 int rtp_abs_sendtime_extn_id = |
1381 send_time_extension ? send_time_extension->id : -1; | 1427 send_time_extension ? send_time_extension->id : -1; |
1382 invoker_.AsyncInvoke<void>( | 1428 invoker_.AsyncInvoke<void>( |
1383 RTC_FROM_HERE, network_thread_, | 1429 RTC_FROM_HERE, network_thread_, |
1384 Bind(&BaseChannel::CacheRtpAbsSendTimeHeaderExtension_n, this, | 1430 Bind(&BaseChannel::CacheRtpAbsSendTimeHeaderExtension_n, this, |
1385 rtp_abs_sendtime_extn_id)); | 1431 rtp_abs_sendtime_extn_id)); |
1386 #endif | 1432 #endif |
1387 } | 1433 } |
1388 | 1434 |
1389 void BaseChannel::CacheRtpAbsSendTimeHeaderExtension_n( | 1435 void BaseChannel::CacheRtpAbsSendTimeHeaderExtension_n( |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1717 LOG(LS_INFO) << "Setting local voice description"; | 1763 LOG(LS_INFO) << "Setting local voice description"; |
1718 | 1764 |
1719 const AudioContentDescription* audio = | 1765 const AudioContentDescription* audio = |
1720 static_cast<const AudioContentDescription*>(content); | 1766 static_cast<const AudioContentDescription*>(content); |
1721 RTC_DCHECK(audio != NULL); | 1767 RTC_DCHECK(audio != NULL); |
1722 if (!audio) { | 1768 if (!audio) { |
1723 SafeSetError("Can't find audio content in local description.", error_desc); | 1769 SafeSetError("Can't find audio content in local description.", error_desc); |
1724 return false; | 1770 return false; |
1725 } | 1771 } |
1726 | 1772 |
1727 if (!SetRtpTransportParameters(content, action, CS_LOCAL, error_desc)) { | 1773 RtpHeaderExtensions rtp_header_extensions = |
1774 GetFilteredRtpHeaderExtensions(audio->rtp_header_extensions()); | |
1775 | |
1776 if (!SetRtpTransportParameters(content, action, CS_LOCAL, | |
1777 rtp_header_extensions, error_desc)) { | |
1728 return false; | 1778 return false; |
1729 } | 1779 } |
1730 | 1780 |
1731 AudioRecvParameters recv_params = last_recv_params_; | 1781 AudioRecvParameters recv_params = last_recv_params_; |
1732 RtpParametersFromMediaDescription(audio, &recv_params); | 1782 RtpParametersFromMediaDescription(audio, rtp_header_extensions, &recv_params); |
1733 if (!media_channel()->SetRecvParameters(recv_params)) { | 1783 if (!media_channel()->SetRecvParameters(recv_params)) { |
1734 SafeSetError("Failed to set local audio description recv parameters.", | 1784 SafeSetError("Failed to set local audio description recv parameters.", |
1735 error_desc); | 1785 error_desc); |
1736 return false; | 1786 return false; |
1737 } | 1787 } |
1738 for (const AudioCodec& codec : audio->codecs()) { | 1788 for (const AudioCodec& codec : audio->codecs()) { |
1739 AddHandledPayloadType(codec.id); | 1789 AddHandledPayloadType(codec.id); |
1740 } | 1790 } |
1741 last_recv_params_ = recv_params; | 1791 last_recv_params_ = recv_params; |
1742 | 1792 |
(...skipping 19 matching lines...) Expand all Loading... | |
1762 LOG(LS_INFO) << "Setting remote voice description"; | 1812 LOG(LS_INFO) << "Setting remote voice description"; |
1763 | 1813 |
1764 const AudioContentDescription* audio = | 1814 const AudioContentDescription* audio = |
1765 static_cast<const AudioContentDescription*>(content); | 1815 static_cast<const AudioContentDescription*>(content); |
1766 RTC_DCHECK(audio != NULL); | 1816 RTC_DCHECK(audio != NULL); |
1767 if (!audio) { | 1817 if (!audio) { |
1768 SafeSetError("Can't find audio content in remote description.", error_desc); | 1818 SafeSetError("Can't find audio content in remote description.", error_desc); |
1769 return false; | 1819 return false; |
1770 } | 1820 } |
1771 | 1821 |
1772 if (!SetRtpTransportParameters(content, action, CS_REMOTE, error_desc)) { | 1822 RtpHeaderExtensions rtp_header_extensions = |
1823 GetFilteredRtpHeaderExtensions(audio->rtp_header_extensions()); | |
1824 | |
1825 if (!SetRtpTransportParameters(content, action, CS_REMOTE, | |
1826 rtp_header_extensions, error_desc)) { | |
1773 return false; | 1827 return false; |
1774 } | 1828 } |
1775 | 1829 |
1776 AudioSendParameters send_params = last_send_params_; | 1830 AudioSendParameters send_params = last_send_params_; |
1777 RtpSendParametersFromMediaDescription(audio, &send_params); | 1831 RtpSendParametersFromMediaDescription(audio, rtp_header_extensions, |
1832 &send_params); | |
1778 if (audio->agc_minus_10db()) { | 1833 if (audio->agc_minus_10db()) { |
1779 send_params.options.adjust_agc_delta = rtc::Optional<int>(kAgcMinus10db); | 1834 send_params.options.adjust_agc_delta = rtc::Optional<int>(kAgcMinus10db); |
1780 } | 1835 } |
1781 | 1836 |
1782 bool parameters_applied = media_channel()->SetSendParameters(send_params); | 1837 bool parameters_applied = media_channel()->SetSendParameters(send_params); |
1783 if (!parameters_applied) { | 1838 if (!parameters_applied) { |
1784 SafeSetError("Failed to set remote audio description send parameters.", | 1839 SafeSetError("Failed to set remote audio description send parameters.", |
1785 error_desc); | 1840 error_desc); |
1786 return false; | 1841 return false; |
1787 } | 1842 } |
1788 last_send_params_ = send_params; | 1843 last_send_params_ = send_params; |
1789 | 1844 |
1790 // TODO(pthatcher): Move remote streams into AudioRecvParameters, | 1845 // TODO(pthatcher): Move remote streams into AudioRecvParameters, |
1791 // and only give it to the media channel once we have a local | 1846 // and only give it to the media channel once we have a local |
1792 // description too (without a local description, we won't be able to | 1847 // description too (without a local description, we won't be able to |
1793 // recv them anyway). | 1848 // recv them anyway). |
1794 if (!UpdateRemoteStreams_w(audio->streams(), action, error_desc)) { | 1849 if (!UpdateRemoteStreams_w(audio->streams(), action, error_desc)) { |
1795 SafeSetError("Failed to set remote audio description streams.", error_desc); | 1850 SafeSetError("Failed to set remote audio description streams.", error_desc); |
1796 return false; | 1851 return false; |
1797 } | 1852 } |
1798 | 1853 |
1799 if (audio->rtp_header_extensions_set()) { | 1854 if (audio->rtp_header_extensions_set()) { |
1800 MaybeCacheRtpAbsSendTimeHeaderExtension_w(audio->rtp_header_extensions()); | 1855 MaybeCacheRtpAbsSendTimeHeaderExtension_w(rtp_header_extensions); |
1801 } | 1856 } |
1802 | 1857 |
1803 set_remote_content_direction(content->direction()); | 1858 set_remote_content_direction(content->direction()); |
1804 UpdateMediaSendRecvState_w(); | 1859 UpdateMediaSendRecvState_w(); |
1805 return true; | 1860 return true; |
1806 } | 1861 } |
1807 | 1862 |
1808 void VoiceChannel::HandleEarlyMediaTimeout() { | 1863 void VoiceChannel::HandleEarlyMediaTimeout() { |
1809 // This occurs on the main thread, not the worker thread. | 1864 // This occurs on the main thread, not the worker thread. |
1810 if (!received_media_) { | 1865 if (!received_media_) { |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1995 LOG(LS_INFO) << "Setting local video description"; | 2050 LOG(LS_INFO) << "Setting local video description"; |
1996 | 2051 |
1997 const VideoContentDescription* video = | 2052 const VideoContentDescription* video = |
1998 static_cast<const VideoContentDescription*>(content); | 2053 static_cast<const VideoContentDescription*>(content); |
1999 RTC_DCHECK(video != NULL); | 2054 RTC_DCHECK(video != NULL); |
2000 if (!video) { | 2055 if (!video) { |
2001 SafeSetError("Can't find video content in local description.", error_desc); | 2056 SafeSetError("Can't find video content in local description.", error_desc); |
2002 return false; | 2057 return false; |
2003 } | 2058 } |
2004 | 2059 |
2005 if (!SetRtpTransportParameters(content, action, CS_LOCAL, error_desc)) { | 2060 RtpHeaderExtensions rtp_header_extensions = |
2061 GetFilteredRtpHeaderExtensions(video->rtp_header_extensions()); | |
2062 | |
2063 if (!SetRtpTransportParameters(content, action, CS_LOCAL, | |
2064 rtp_header_extensions, error_desc)) { | |
2006 return false; | 2065 return false; |
2007 } | 2066 } |
2008 | 2067 |
2009 VideoRecvParameters recv_params = last_recv_params_; | 2068 VideoRecvParameters recv_params = last_recv_params_; |
2010 RtpParametersFromMediaDescription(video, &recv_params); | 2069 RtpParametersFromMediaDescription(video, rtp_header_extensions, &recv_params); |
2011 if (!media_channel()->SetRecvParameters(recv_params)) { | 2070 if (!media_channel()->SetRecvParameters(recv_params)) { |
2012 SafeSetError("Failed to set local video description recv parameters.", | 2071 SafeSetError("Failed to set local video description recv parameters.", |
2013 error_desc); | 2072 error_desc); |
2014 return false; | 2073 return false; |
2015 } | 2074 } |
2016 for (const VideoCodec& codec : video->codecs()) { | 2075 for (const VideoCodec& codec : video->codecs()) { |
2017 AddHandledPayloadType(codec.id); | 2076 AddHandledPayloadType(codec.id); |
2018 } | 2077 } |
2019 last_recv_params_ = recv_params; | 2078 last_recv_params_ = recv_params; |
2020 | 2079 |
(...skipping 19 matching lines...) Expand all Loading... | |
2040 LOG(LS_INFO) << "Setting remote video description"; | 2099 LOG(LS_INFO) << "Setting remote video description"; |
2041 | 2100 |
2042 const VideoContentDescription* video = | 2101 const VideoContentDescription* video = |
2043 static_cast<const VideoContentDescription*>(content); | 2102 static_cast<const VideoContentDescription*>(content); |
2044 RTC_DCHECK(video != NULL); | 2103 RTC_DCHECK(video != NULL); |
2045 if (!video) { | 2104 if (!video) { |
2046 SafeSetError("Can't find video content in remote description.", error_desc); | 2105 SafeSetError("Can't find video content in remote description.", error_desc); |
2047 return false; | 2106 return false; |
2048 } | 2107 } |
2049 | 2108 |
2050 if (!SetRtpTransportParameters(content, action, CS_REMOTE, error_desc)) { | 2109 RtpHeaderExtensions rtp_header_extensions = |
2110 GetFilteredRtpHeaderExtensions(video->rtp_header_extensions()); | |
2111 | |
2112 if (!SetRtpTransportParameters(content, action, CS_REMOTE, | |
2113 rtp_header_extensions, error_desc)) { | |
2051 return false; | 2114 return false; |
2052 } | 2115 } |
2053 | 2116 |
2054 VideoSendParameters send_params = last_send_params_; | 2117 VideoSendParameters send_params = last_send_params_; |
2055 RtpSendParametersFromMediaDescription(video, &send_params); | 2118 RtpSendParametersFromMediaDescription(video, rtp_header_extensions, |
2119 &send_params); | |
2056 if (video->conference_mode()) { | 2120 if (video->conference_mode()) { |
2057 send_params.conference_mode = true; | 2121 send_params.conference_mode = true; |
2058 } | 2122 } |
2059 | 2123 |
2060 bool parameters_applied = media_channel()->SetSendParameters(send_params); | 2124 bool parameters_applied = media_channel()->SetSendParameters(send_params); |
2061 | 2125 |
2062 if (!parameters_applied) { | 2126 if (!parameters_applied) { |
2063 SafeSetError("Failed to set remote video description send parameters.", | 2127 SafeSetError("Failed to set remote video description send parameters.", |
2064 error_desc); | 2128 error_desc); |
2065 return false; | 2129 return false; |
2066 } | 2130 } |
2067 last_send_params_ = send_params; | 2131 last_send_params_ = send_params; |
2068 | 2132 |
2069 // TODO(pthatcher): Move remote streams into VideoRecvParameters, | 2133 // TODO(pthatcher): Move remote streams into VideoRecvParameters, |
2070 // and only give it to the media channel once we have a local | 2134 // and only give it to the media channel once we have a local |
2071 // description too (without a local description, we won't be able to | 2135 // description too (without a local description, we won't be able to |
2072 // recv them anyway). | 2136 // recv them anyway). |
2073 if (!UpdateRemoteStreams_w(video->streams(), action, error_desc)) { | 2137 if (!UpdateRemoteStreams_w(video->streams(), action, error_desc)) { |
2074 SafeSetError("Failed to set remote video description streams.", error_desc); | 2138 SafeSetError("Failed to set remote video description streams.", error_desc); |
2075 return false; | 2139 return false; |
2076 } | 2140 } |
2077 | 2141 |
2078 if (video->rtp_header_extensions_set()) { | 2142 if (video->rtp_header_extensions_set()) { |
2079 MaybeCacheRtpAbsSendTimeHeaderExtension_w(video->rtp_header_extensions()); | 2143 MaybeCacheRtpAbsSendTimeHeaderExtension_w(rtp_header_extensions); |
2080 } | 2144 } |
2081 | 2145 |
2082 set_remote_content_direction(content->direction()); | 2146 set_remote_content_direction(content->direction()); |
2083 UpdateMediaSendRecvState_w(); | 2147 UpdateMediaSendRecvState_w(); |
2084 return true; | 2148 return true; |
2085 } | 2149 } |
2086 | 2150 |
2087 void VideoChannel::OnMessage(rtc::Message *pmsg) { | 2151 void VideoChannel::OnMessage(rtc::Message *pmsg) { |
2088 switch (pmsg->message_id) { | 2152 switch (pmsg->message_id) { |
2089 case MSG_CHANNEL_ERROR: { | 2153 case MSG_CHANNEL_ERROR: { |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2190 RTC_DCHECK(data != NULL); | 2254 RTC_DCHECK(data != NULL); |
2191 if (!data) { | 2255 if (!data) { |
2192 SafeSetError("Can't find data content in local description.", error_desc); | 2256 SafeSetError("Can't find data content in local description.", error_desc); |
2193 return false; | 2257 return false; |
2194 } | 2258 } |
2195 | 2259 |
2196 if (!CheckDataChannelTypeFromContent(data, error_desc)) { | 2260 if (!CheckDataChannelTypeFromContent(data, error_desc)) { |
2197 return false; | 2261 return false; |
2198 } | 2262 } |
2199 | 2263 |
2200 if (!SetRtpTransportParameters(content, action, CS_LOCAL, error_desc)) { | 2264 RtpHeaderExtensions rtp_header_extensions = |
2265 GetFilteredRtpHeaderExtensions(data->rtp_header_extensions()); | |
2266 | |
2267 if (!SetRtpTransportParameters(content, action, CS_LOCAL, | |
2268 rtp_header_extensions, error_desc)) { | |
2201 return false; | 2269 return false; |
2202 } | 2270 } |
2203 | 2271 |
2204 DataRecvParameters recv_params = last_recv_params_; | 2272 DataRecvParameters recv_params = last_recv_params_; |
2205 RtpParametersFromMediaDescription(data, &recv_params); | 2273 RtpParametersFromMediaDescription(data, rtp_header_extensions, &recv_params); |
2206 if (!media_channel()->SetRecvParameters(recv_params)) { | 2274 if (!media_channel()->SetRecvParameters(recv_params)) { |
2207 SafeSetError("Failed to set remote data description recv parameters.", | 2275 SafeSetError("Failed to set remote data description recv parameters.", |
2208 error_desc); | 2276 error_desc); |
2209 return false; | 2277 return false; |
2210 } | 2278 } |
2211 for (const DataCodec& codec : data->codecs()) { | 2279 for (const DataCodec& codec : data->codecs()) { |
2212 AddHandledPayloadType(codec.id); | 2280 AddHandledPayloadType(codec.id); |
2213 } | 2281 } |
2214 last_recv_params_ = recv_params; | 2282 last_recv_params_ = recv_params; |
2215 | 2283 |
(...skipping 28 matching lines...) Expand all Loading... | |
2244 // If the remote data doesn't have codecs and isn't an update, it | 2312 // If the remote data doesn't have codecs and isn't an update, it |
2245 // must be empty, so ignore it. | 2313 // must be empty, so ignore it. |
2246 if (!data->has_codecs() && action != CA_UPDATE) { | 2314 if (!data->has_codecs() && action != CA_UPDATE) { |
2247 return true; | 2315 return true; |
2248 } | 2316 } |
2249 | 2317 |
2250 if (!CheckDataChannelTypeFromContent(data, error_desc)) { | 2318 if (!CheckDataChannelTypeFromContent(data, error_desc)) { |
2251 return false; | 2319 return false; |
2252 } | 2320 } |
2253 | 2321 |
2322 RtpHeaderExtensions rtp_header_extensions = | |
2323 GetFilteredRtpHeaderExtensions(data->rtp_header_extensions()); | |
2324 | |
2254 LOG(LS_INFO) << "Setting remote data description"; | 2325 LOG(LS_INFO) << "Setting remote data description"; |
2255 if (!SetRtpTransportParameters(content, action, CS_REMOTE, error_desc)) { | 2326 if (!SetRtpTransportParameters(content, action, CS_REMOTE, |
2327 rtp_header_extensions, error_desc)) { | |
2256 return false; | 2328 return false; |
2257 } | 2329 } |
2258 | 2330 |
2259 DataSendParameters send_params = last_send_params_; | 2331 DataSendParameters send_params = last_send_params_; |
2260 RtpSendParametersFromMediaDescription<DataCodec>(data, &send_params); | 2332 RtpSendParametersFromMediaDescription<DataCodec>(data, rtp_header_extensions, |
2333 &send_params); | |
2261 if (!media_channel()->SetSendParameters(send_params)) { | 2334 if (!media_channel()->SetSendParameters(send_params)) { |
2262 SafeSetError("Failed to set remote data description send parameters.", | 2335 SafeSetError("Failed to set remote data description send parameters.", |
2263 error_desc); | 2336 error_desc); |
2264 return false; | 2337 return false; |
2265 } | 2338 } |
2266 last_send_params_ = send_params; | 2339 last_send_params_ = send_params; |
2267 | 2340 |
2268 // TODO(pthatcher): Move remote streams into DataRecvParameters, | 2341 // TODO(pthatcher): Move remote streams into DataRecvParameters, |
2269 // and only give it to the media channel once we have a local | 2342 // and only give it to the media channel once we have a local |
2270 // description too (without a local description, we won't be able to | 2343 // description too (without a local description, we won't be able to |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2375 | 2448 |
2376 void RtpDataChannel::OnDataChannelReadyToSend(bool writable) { | 2449 void RtpDataChannel::OnDataChannelReadyToSend(bool writable) { |
2377 // This is usded for congestion control to indicate that the stream is ready | 2450 // This is usded for congestion control to indicate that the stream is ready |
2378 // to send by the MediaChannel, as opposed to OnReadyToSend, which indicates | 2451 // to send by the MediaChannel, as opposed to OnReadyToSend, which indicates |
2379 // that the transport channel is ready. | 2452 // that the transport channel is ready. |
2380 signaling_thread()->Post(RTC_FROM_HERE, this, MSG_READYTOSENDDATA, | 2453 signaling_thread()->Post(RTC_FROM_HERE, this, MSG_READYTOSENDDATA, |
2381 new DataChannelReadyToSendMessageData(writable)); | 2454 new DataChannelReadyToSendMessageData(writable)); |
2382 } | 2455 } |
2383 | 2456 |
2384 } // namespace cricket | 2457 } // namespace cricket |
OLD | NEW |