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> |
11 #include <utility> | 12 #include <utility> |
12 | 13 |
13 #include "webrtc/pc/channel.h" | 14 #include "webrtc/pc/channel.h" |
14 | 15 |
15 #include "webrtc/api/call/audio_sink.h" | 16 #include "webrtc/api/call/audio_sink.h" |
16 #include "webrtc/base/bind.h" | 17 #include "webrtc/base/bind.h" |
17 #include "webrtc/base/byteorder.h" | 18 #include "webrtc/base/byteorder.h" |
18 #include "webrtc/base/checks.h" | 19 #include "webrtc/base/checks.h" |
19 #include "webrtc/base/copyonwritebuffer.h" | 20 #include "webrtc/base/copyonwritebuffer.h" |
20 #include "webrtc/base/dscp.h" | 21 #include "webrtc/base/dscp.h" |
(...skipping 15 matching lines...) Expand all Loading... |
36 std::unique_ptr<webrtc::AudioSinkInterface>* sink) { | 37 std::unique_ptr<webrtc::AudioSinkInterface>* sink) { |
37 channel->SetRawAudioSink(ssrc, std::move(*sink)); | 38 channel->SetRawAudioSink(ssrc, std::move(*sink)); |
38 return true; | 39 return true; |
39 } | 40 } |
40 | 41 |
41 struct SendPacketMessageData : public rtc::MessageData { | 42 struct SendPacketMessageData : public rtc::MessageData { |
42 rtc::CopyOnWriteBuffer packet; | 43 rtc::CopyOnWriteBuffer packet; |
43 rtc::PacketOptions options; | 44 rtc::PacketOptions options; |
44 }; | 45 }; |
45 | 46 |
46 #if defined(ENABLE_EXTERNAL_AUTH) | |
47 // Returns the named header extension if found among all extensions, | |
48 // nullptr otherwise. | |
49 const webrtc::RtpExtension* FindHeaderExtension( | |
50 const std::vector<webrtc::RtpExtension>& extensions, | |
51 const std::string& uri) { | |
52 for (const auto& extension : extensions) { | |
53 if (extension.uri == uri) | |
54 return &extension; | |
55 } | |
56 return nullptr; | |
57 } | |
58 #endif | |
59 | |
60 } // namespace | 47 } // namespace |
61 | 48 |
62 enum { | 49 enum { |
63 MSG_EARLYMEDIATIMEOUT = 1, | 50 MSG_EARLYMEDIATIMEOUT = 1, |
64 MSG_SEND_RTP_PACKET, | 51 MSG_SEND_RTP_PACKET, |
65 MSG_SEND_RTCP_PACKET, | 52 MSG_SEND_RTCP_PACKET, |
66 MSG_CHANNEL_ERROR, | 53 MSG_CHANNEL_ERROR, |
67 MSG_READYTOSENDDATA, | 54 MSG_READYTOSENDDATA, |
68 MSG_DATARECEIVED, | 55 MSG_DATARECEIVED, |
69 MSG_FIRSTPACKETRECEIVED, | 56 MSG_FIRSTPACKETRECEIVED, |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 static const MediaContentDescription* GetContentDescription( | 113 static const MediaContentDescription* GetContentDescription( |
127 const ContentInfo* cinfo) { | 114 const ContentInfo* cinfo) { |
128 if (cinfo == NULL) | 115 if (cinfo == NULL) |
129 return NULL; | 116 return NULL; |
130 return static_cast<const MediaContentDescription*>(cinfo->description); | 117 return static_cast<const MediaContentDescription*>(cinfo->description); |
131 } | 118 } |
132 | 119 |
133 template <class Codec> | 120 template <class Codec> |
134 void RtpParametersFromMediaDescription( | 121 void RtpParametersFromMediaDescription( |
135 const MediaContentDescriptionImpl<Codec>* desc, | 122 const MediaContentDescriptionImpl<Codec>* desc, |
| 123 const RtpHeaderExtensions& extensions, |
136 RtpParameters<Codec>* params) { | 124 RtpParameters<Codec>* params) { |
137 // TODO(pthatcher): Remove this once we're sure no one will give us | 125 // TODO(pthatcher): Remove this once we're sure no one will give us |
138 // a description without codecs (currently a CA_UPDATE with just | 126 // a description without codecs (currently a CA_UPDATE with just |
139 // streams can). | 127 // streams can). |
140 if (desc->has_codecs()) { | 128 if (desc->has_codecs()) { |
141 params->codecs = desc->codecs(); | 129 params->codecs = desc->codecs(); |
142 } | 130 } |
143 // TODO(pthatcher): See if we really need | 131 // TODO(pthatcher): See if we really need |
144 // rtp_header_extensions_set() and remove it if we don't. | 132 // rtp_header_extensions_set() and remove it if we don't. |
145 if (desc->rtp_header_extensions_set()) { | 133 if (desc->rtp_header_extensions_set()) { |
146 params->extensions = desc->rtp_header_extensions(); | 134 params->extensions = extensions; |
147 } | 135 } |
148 params->rtcp.reduced_size = desc->rtcp_reduced_size(); | 136 params->rtcp.reduced_size = desc->rtcp_reduced_size(); |
149 } | 137 } |
150 | 138 |
151 template <class Codec> | 139 template <class Codec> |
152 void RtpSendParametersFromMediaDescription( | 140 void RtpSendParametersFromMediaDescription( |
153 const MediaContentDescriptionImpl<Codec>* desc, | 141 const MediaContentDescriptionImpl<Codec>* desc, |
| 142 const RtpHeaderExtensions& extensions, |
154 RtpSendParameters<Codec>* send_params) { | 143 RtpSendParameters<Codec>* send_params) { |
155 RtpParametersFromMediaDescription(desc, send_params); | 144 RtpParametersFromMediaDescription(desc, extensions, send_params); |
156 send_params->max_bandwidth_bps = desc->bandwidth(); | 145 send_params->max_bandwidth_bps = desc->bandwidth(); |
157 } | 146 } |
158 | 147 |
159 BaseChannel::BaseChannel(rtc::Thread* worker_thread, | 148 BaseChannel::BaseChannel(rtc::Thread* worker_thread, |
160 rtc::Thread* network_thread, | 149 rtc::Thread* network_thread, |
161 rtc::Thread* signaling_thread, | 150 rtc::Thread* signaling_thread, |
162 MediaChannel* media_channel, | 151 MediaChannel* media_channel, |
163 const std::string& content_name, | 152 const std::string& content_name, |
164 bool rtcp_mux_required, | 153 bool rtcp_mux_required, |
165 bool srtp_required) | 154 bool srtp_required) |
(...skipping 920 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1086 } | 1075 } |
1087 | 1076 |
1088 if (role == rtc::SSL_SERVER) { | 1077 if (role == rtc::SSL_SERVER) { |
1089 send_key = &server_write_key; | 1078 send_key = &server_write_key; |
1090 recv_key = &client_write_key; | 1079 recv_key = &client_write_key; |
1091 } else { | 1080 } else { |
1092 send_key = &client_write_key; | 1081 send_key = &client_write_key; |
1093 recv_key = &server_write_key; | 1082 recv_key = &server_write_key; |
1094 } | 1083 } |
1095 | 1084 |
1096 if (rtcp) { | 1085 if (!srtp_filter_.IsActive()) { |
1097 ret = srtp_filter_.SetRtcpParams(selected_crypto_suite, &(*send_key)[0], | 1086 if (rtcp) { |
1098 static_cast<int>(send_key->size()), | 1087 ret = srtp_filter_.SetRtcpParams(selected_crypto_suite, &(*send_key)[0], |
1099 selected_crypto_suite, &(*recv_key)[0], | 1088 static_cast<int>(send_key->size()), |
1100 static_cast<int>(recv_key->size())); | 1089 selected_crypto_suite, &(*recv_key)[0], |
| 1090 static_cast<int>(recv_key->size())); |
| 1091 } else { |
| 1092 ret = srtp_filter_.SetRtpParams(selected_crypto_suite, &(*send_key)[0], |
| 1093 static_cast<int>(send_key->size()), |
| 1094 selected_crypto_suite, &(*recv_key)[0], |
| 1095 static_cast<int>(recv_key->size())); |
| 1096 } |
1101 } else { | 1097 } else { |
1102 ret = srtp_filter_.SetRtpParams(selected_crypto_suite, &(*send_key)[0], | 1098 if (rtcp) { |
1103 static_cast<int>(send_key->size()), | 1099 // RTCP doesn't need to be updated because UpdateRtpParams is only used |
1104 selected_crypto_suite, &(*recv_key)[0], | 1100 // to update the set of encrypted RTP header extension IDs. |
1105 static_cast<int>(recv_key->size())); | 1101 ret = true; |
| 1102 } else { |
| 1103 ret = srtp_filter_.UpdateRtpParams( |
| 1104 selected_crypto_suite, |
| 1105 &(*send_key)[0], static_cast<int>(send_key->size()), |
| 1106 selected_crypto_suite, |
| 1107 &(*recv_key)[0], static_cast<int>(recv_key->size())); |
| 1108 } |
1106 } | 1109 } |
1107 | 1110 |
1108 if (!ret) { | 1111 if (!ret) { |
1109 LOG(LS_WARNING) << "DTLS-SRTP key installation failed"; | 1112 LOG(LS_WARNING) << "DTLS-SRTP key installation failed"; |
1110 } else { | 1113 } else { |
1111 dtls_keyed_ = true; | 1114 dtls_keyed_ = true; |
1112 UpdateTransportOverhead(); | 1115 UpdateTransportOverhead(); |
1113 } | 1116 } |
1114 return ret; | 1117 return ret; |
1115 } | 1118 } |
(...skipping 27 matching lines...) Expand all Loading... |
1143 | 1146 |
1144 LOG(LS_INFO) << "Channel not writable (" << content_name_ << ")"; | 1147 LOG(LS_INFO) << "Channel not writable (" << content_name_ << ")"; |
1145 writable_ = false; | 1148 writable_ = false; |
1146 UpdateMediaSendRecvState(); | 1149 UpdateMediaSendRecvState(); |
1147 } | 1150 } |
1148 | 1151 |
1149 bool BaseChannel::SetRtpTransportParameters( | 1152 bool BaseChannel::SetRtpTransportParameters( |
1150 const MediaContentDescription* content, | 1153 const MediaContentDescription* content, |
1151 ContentAction action, | 1154 ContentAction action, |
1152 ContentSource src, | 1155 ContentSource src, |
| 1156 const RtpHeaderExtensions& extensions, |
1153 std::string* error_desc) { | 1157 std::string* error_desc) { |
1154 if (action == CA_UPDATE) { | 1158 if (action == CA_UPDATE) { |
1155 // These parameters never get changed by a CA_UDPATE. | 1159 // These parameters never get changed by a CA_UDPATE. |
1156 return true; | 1160 return true; |
1157 } | 1161 } |
1158 | 1162 |
| 1163 std::vector<int> encrypted_extension_ids; |
| 1164 for (const webrtc::RtpExtension& extension : extensions) { |
| 1165 if (extension.encrypt) { |
| 1166 LOG(LS_INFO) << "Using " << (src == CS_LOCAL ? "local" : "remote") |
| 1167 << " encrypted extension: " << extension.ToString(); |
| 1168 encrypted_extension_ids.push_back(extension.id); |
| 1169 } |
| 1170 } |
| 1171 |
1159 // Cache srtp_required_ for belt and suspenders check on SendPacket | 1172 // Cache srtp_required_ for belt and suspenders check on SendPacket |
1160 return network_thread_->Invoke<bool>( | 1173 return network_thread_->Invoke<bool>( |
1161 RTC_FROM_HERE, Bind(&BaseChannel::SetRtpTransportParameters_n, this, | 1174 RTC_FROM_HERE, Bind(&BaseChannel::SetRtpTransportParameters_n, this, |
1162 content, action, src, error_desc)); | 1175 content, action, src, encrypted_extension_ids, |
| 1176 error_desc)); |
1163 } | 1177 } |
1164 | 1178 |
1165 bool BaseChannel::SetRtpTransportParameters_n( | 1179 bool BaseChannel::SetRtpTransportParameters_n( |
1166 const MediaContentDescription* content, | 1180 const MediaContentDescription* content, |
1167 ContentAction action, | 1181 ContentAction action, |
1168 ContentSource src, | 1182 ContentSource src, |
| 1183 const std::vector<int>& encrypted_extension_ids, |
1169 std::string* error_desc) { | 1184 std::string* error_desc) { |
1170 RTC_DCHECK(network_thread_->IsCurrent()); | 1185 RTC_DCHECK(network_thread_->IsCurrent()); |
1171 | 1186 |
1172 if (!SetSrtp_n(content->cryptos(), action, src, error_desc)) { | 1187 if (!SetSrtp_n(content->cryptos(), action, src, encrypted_extension_ids, |
| 1188 error_desc)) { |
1173 return false; | 1189 return false; |
1174 } | 1190 } |
1175 | 1191 |
1176 if (!SetRtcpMux_n(content->rtcp_mux(), action, src, error_desc)) { | 1192 if (!SetRtcpMux_n(content->rtcp_mux(), action, src, error_desc)) { |
1177 return false; | 1193 return false; |
1178 } | 1194 } |
1179 | 1195 |
1180 return true; | 1196 return true; |
1181 } | 1197 } |
1182 | 1198 |
1183 // |dtls| will be set to true if DTLS is active for transport and crypto is | 1199 // |dtls| will be set to true if DTLS is active for transport and crypto is |
1184 // empty. | 1200 // empty. |
1185 bool BaseChannel::CheckSrtpConfig_n(const std::vector<CryptoParams>& cryptos, | 1201 bool BaseChannel::CheckSrtpConfig_n(const std::vector<CryptoParams>& cryptos, |
1186 bool* dtls, | 1202 bool* dtls, |
1187 std::string* error_desc) { | 1203 std::string* error_desc) { |
1188 *dtls = rtp_dtls_transport_ && rtp_dtls_transport_->IsDtlsActive(); | 1204 *dtls = rtp_dtls_transport_ && rtp_dtls_transport_->IsDtlsActive(); |
1189 if (*dtls && !cryptos.empty()) { | 1205 if (*dtls && !cryptos.empty()) { |
1190 SafeSetError("Cryptos must be empty when DTLS is active.", error_desc); | 1206 SafeSetError("Cryptos must be empty when DTLS is active.", error_desc); |
1191 return false; | 1207 return false; |
1192 } | 1208 } |
1193 return true; | 1209 return true; |
1194 } | 1210 } |
1195 | 1211 |
1196 bool BaseChannel::SetSrtp_n(const std::vector<CryptoParams>& cryptos, | 1212 bool BaseChannel::SetSrtp_n(const std::vector<CryptoParams>& cryptos, |
1197 ContentAction action, | 1213 ContentAction action, |
1198 ContentSource src, | 1214 ContentSource src, |
| 1215 const std::vector<int>& encrypted_extension_ids, |
1199 std::string* error_desc) { | 1216 std::string* error_desc) { |
1200 TRACE_EVENT0("webrtc", "BaseChannel::SetSrtp_w"); | 1217 TRACE_EVENT0("webrtc", "BaseChannel::SetSrtp_w"); |
1201 if (action == CA_UPDATE) { | 1218 if (action == CA_UPDATE) { |
1202 // no crypto params. | 1219 // no crypto params. |
1203 return true; | 1220 return true; |
1204 } | 1221 } |
1205 bool ret = false; | 1222 bool ret = false; |
1206 bool dtls = false; | 1223 bool dtls = false; |
1207 ret = CheckSrtpConfig_n(cryptos, &dtls, error_desc); | 1224 ret = CheckSrtpConfig_n(cryptos, &dtls, error_desc); |
1208 if (!ret) { | 1225 if (!ret) { |
1209 return false; | 1226 return false; |
1210 } | 1227 } |
| 1228 srtp_filter_.SetEncryptedHeaderExtensionIds(src, encrypted_extension_ids); |
1211 switch (action) { | 1229 switch (action) { |
1212 case CA_OFFER: | 1230 case CA_OFFER: |
1213 // If DTLS is already active on the channel, we could be renegotiating | 1231 // If DTLS is already active on the channel, we could be renegotiating |
1214 // here. We don't update the srtp filter. | 1232 // here. We don't update the srtp filter. |
1215 if (!dtls) { | 1233 if (!dtls) { |
1216 ret = srtp_filter_.SetOffer(cryptos, src); | 1234 ret = srtp_filter_.SetOffer(cryptos, src); |
1217 } | 1235 } |
1218 break; | 1236 break; |
1219 case CA_PRANSWER: | 1237 case CA_PRANSWER: |
1220 // If we're doing DTLS-SRTP, we don't want to update the filter | 1238 // If we're doing DTLS-SRTP, we don't want to update the filter |
1221 // with an answer, because we already have SRTP parameters. | 1239 // with an answer, because we already have SRTP parameters. |
1222 if (!dtls) { | 1240 if (!dtls) { |
1223 ret = srtp_filter_.SetProvisionalAnswer(cryptos, src); | 1241 ret = srtp_filter_.SetProvisionalAnswer(cryptos, src); |
1224 } | 1242 } |
1225 break; | 1243 break; |
1226 case CA_ANSWER: | 1244 case CA_ANSWER: |
1227 // If we're doing DTLS-SRTP, we don't want to update the filter | 1245 // If we're doing DTLS-SRTP, we don't want to update the filter |
1228 // with an answer, because we already have SRTP parameters. | 1246 // with an answer, because we already have SRTP parameters. |
1229 if (!dtls) { | 1247 if (!dtls) { |
1230 ret = srtp_filter_.SetAnswer(cryptos, src); | 1248 ret = srtp_filter_.SetAnswer(cryptos, src); |
1231 } | 1249 } |
1232 break; | 1250 break; |
1233 default: | 1251 default: |
1234 break; | 1252 break; |
1235 } | 1253 } |
| 1254 // Only update SRTP filter if using DTLS. SDES is handled internally |
| 1255 // by the SRTP filter. |
| 1256 // TODO(jbauch): Only update if encrypted extension ids have changed. |
| 1257 if (ret && dtls_keyed_) { |
| 1258 bool rtcp = false; |
| 1259 ret = SetupDtlsSrtp_n(rtcp); |
| 1260 } |
1236 if (!ret) { | 1261 if (!ret) { |
1237 SafeSetError("Failed to setup SRTP filter.", error_desc); | 1262 SafeSetError("Failed to setup SRTP filter.", error_desc); |
1238 return false; | 1263 return false; |
1239 } | 1264 } |
1240 return true; | 1265 return true; |
1241 } | 1266 } |
1242 | 1267 |
1243 bool BaseChannel::SetRtcpMux_n(bool enable, | 1268 bool BaseChannel::SetRtcpMux_n(bool enable, |
1244 ContentAction action, | 1269 ContentAction action, |
1245 ContentSource src, | 1270 ContentSource src, |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1456 desc << "Failed to add remote stream ssrc: " << it->first_ssrc(); | 1481 desc << "Failed to add remote stream ssrc: " << it->first_ssrc(); |
1457 SafeSetError(desc.str(), error_desc); | 1482 SafeSetError(desc.str(), error_desc); |
1458 ret = false; | 1483 ret = false; |
1459 } | 1484 } |
1460 } | 1485 } |
1461 } | 1486 } |
1462 remote_streams_ = streams; | 1487 remote_streams_ = streams; |
1463 return ret; | 1488 return ret; |
1464 } | 1489 } |
1465 | 1490 |
| 1491 RtpHeaderExtensions BaseChannel::GetFilteredRtpHeaderExtensions( |
| 1492 const RtpHeaderExtensions& extensions) { |
| 1493 if (!crypto_options_.enable_encrypted_rtp_header_extensions) { |
| 1494 RtpHeaderExtensions filtered; |
| 1495 auto pred = [](const webrtc::RtpExtension& extension) { |
| 1496 return !extension.encrypt; |
| 1497 }; |
| 1498 std::copy_if(extensions.begin(), extensions.end(), |
| 1499 std::back_inserter(filtered), pred); |
| 1500 return filtered; |
| 1501 } |
| 1502 |
| 1503 return webrtc::RtpExtension::FilterDuplicateNonEncrypted(extensions); |
| 1504 } |
| 1505 |
1466 void BaseChannel::MaybeCacheRtpAbsSendTimeHeaderExtension_w( | 1506 void BaseChannel::MaybeCacheRtpAbsSendTimeHeaderExtension_w( |
1467 const std::vector<webrtc::RtpExtension>& extensions) { | 1507 const std::vector<webrtc::RtpExtension>& extensions) { |
1468 // Absolute Send Time extension id is used only with external auth, | 1508 // Absolute Send Time extension id is used only with external auth, |
1469 // so do not bother searching for it and making asyncronious call to set | 1509 // so do not bother searching for it and making asyncronious call to set |
1470 // something that is not used. | 1510 // something that is not used. |
1471 #if defined(ENABLE_EXTERNAL_AUTH) | 1511 #if defined(ENABLE_EXTERNAL_AUTH) |
1472 const webrtc::RtpExtension* send_time_extension = | 1512 const webrtc::RtpExtension* send_time_extension = |
1473 FindHeaderExtension(extensions, webrtc::RtpExtension::kAbsSendTimeUri); | 1513 webrtc::RtpExtension::FindHeaderExtensionByUri( |
| 1514 extensions, webrtc::RtpExtension::kAbsSendTimeUri); |
1474 int rtp_abs_sendtime_extn_id = | 1515 int rtp_abs_sendtime_extn_id = |
1475 send_time_extension ? send_time_extension->id : -1; | 1516 send_time_extension ? send_time_extension->id : -1; |
1476 invoker_.AsyncInvoke<void>( | 1517 invoker_.AsyncInvoke<void>( |
1477 RTC_FROM_HERE, network_thread_, | 1518 RTC_FROM_HERE, network_thread_, |
1478 Bind(&BaseChannel::CacheRtpAbsSendTimeHeaderExtension_n, this, | 1519 Bind(&BaseChannel::CacheRtpAbsSendTimeHeaderExtension_n, this, |
1479 rtp_abs_sendtime_extn_id)); | 1520 rtp_abs_sendtime_extn_id)); |
1480 #endif | 1521 #endif |
1481 } | 1522 } |
1482 | 1523 |
1483 void BaseChannel::CacheRtpAbsSendTimeHeaderExtension_n( | 1524 void BaseChannel::CacheRtpAbsSendTimeHeaderExtension_n( |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1797 LOG(LS_INFO) << "Setting local voice description"; | 1838 LOG(LS_INFO) << "Setting local voice description"; |
1798 | 1839 |
1799 const AudioContentDescription* audio = | 1840 const AudioContentDescription* audio = |
1800 static_cast<const AudioContentDescription*>(content); | 1841 static_cast<const AudioContentDescription*>(content); |
1801 RTC_DCHECK(audio != NULL); | 1842 RTC_DCHECK(audio != NULL); |
1802 if (!audio) { | 1843 if (!audio) { |
1803 SafeSetError("Can't find audio content in local description.", error_desc); | 1844 SafeSetError("Can't find audio content in local description.", error_desc); |
1804 return false; | 1845 return false; |
1805 } | 1846 } |
1806 | 1847 |
1807 if (!SetRtpTransportParameters(content, action, CS_LOCAL, error_desc)) { | 1848 RtpHeaderExtensions rtp_header_extensions = |
| 1849 GetFilteredRtpHeaderExtensions(audio->rtp_header_extensions()); |
| 1850 |
| 1851 if (!SetRtpTransportParameters(content, action, CS_LOCAL, |
| 1852 rtp_header_extensions, error_desc)) { |
1808 return false; | 1853 return false; |
1809 } | 1854 } |
1810 | 1855 |
1811 AudioRecvParameters recv_params = last_recv_params_; | 1856 AudioRecvParameters recv_params = last_recv_params_; |
1812 RtpParametersFromMediaDescription(audio, &recv_params); | 1857 RtpParametersFromMediaDescription(audio, rtp_header_extensions, &recv_params); |
1813 if (!media_channel()->SetRecvParameters(recv_params)) { | 1858 if (!media_channel()->SetRecvParameters(recv_params)) { |
1814 SafeSetError("Failed to set local audio description recv parameters.", | 1859 SafeSetError("Failed to set local audio description recv parameters.", |
1815 error_desc); | 1860 error_desc); |
1816 return false; | 1861 return false; |
1817 } | 1862 } |
1818 for (const AudioCodec& codec : audio->codecs()) { | 1863 for (const AudioCodec& codec : audio->codecs()) { |
1819 bundle_filter()->AddPayloadType(codec.id); | 1864 bundle_filter()->AddPayloadType(codec.id); |
1820 } | 1865 } |
1821 last_recv_params_ = recv_params; | 1866 last_recv_params_ = recv_params; |
1822 | 1867 |
(...skipping 19 matching lines...) Expand all Loading... |
1842 LOG(LS_INFO) << "Setting remote voice description"; | 1887 LOG(LS_INFO) << "Setting remote voice description"; |
1843 | 1888 |
1844 const AudioContentDescription* audio = | 1889 const AudioContentDescription* audio = |
1845 static_cast<const AudioContentDescription*>(content); | 1890 static_cast<const AudioContentDescription*>(content); |
1846 RTC_DCHECK(audio != NULL); | 1891 RTC_DCHECK(audio != NULL); |
1847 if (!audio) { | 1892 if (!audio) { |
1848 SafeSetError("Can't find audio content in remote description.", error_desc); | 1893 SafeSetError("Can't find audio content in remote description.", error_desc); |
1849 return false; | 1894 return false; |
1850 } | 1895 } |
1851 | 1896 |
1852 if (!SetRtpTransportParameters(content, action, CS_REMOTE, error_desc)) { | 1897 RtpHeaderExtensions rtp_header_extensions = |
| 1898 GetFilteredRtpHeaderExtensions(audio->rtp_header_extensions()); |
| 1899 |
| 1900 if (!SetRtpTransportParameters(content, action, CS_REMOTE, |
| 1901 rtp_header_extensions, error_desc)) { |
1853 return false; | 1902 return false; |
1854 } | 1903 } |
1855 | 1904 |
1856 AudioSendParameters send_params = last_send_params_; | 1905 AudioSendParameters send_params = last_send_params_; |
1857 RtpSendParametersFromMediaDescription(audio, &send_params); | 1906 RtpSendParametersFromMediaDescription(audio, rtp_header_extensions, |
| 1907 &send_params); |
1858 if (audio->agc_minus_10db()) { | 1908 if (audio->agc_minus_10db()) { |
1859 send_params.options.adjust_agc_delta = rtc::Optional<int>(kAgcMinus10db); | 1909 send_params.options.adjust_agc_delta = rtc::Optional<int>(kAgcMinus10db); |
1860 } | 1910 } |
1861 | 1911 |
1862 bool parameters_applied = media_channel()->SetSendParameters(send_params); | 1912 bool parameters_applied = media_channel()->SetSendParameters(send_params); |
1863 if (!parameters_applied) { | 1913 if (!parameters_applied) { |
1864 SafeSetError("Failed to set remote audio description send parameters.", | 1914 SafeSetError("Failed to set remote audio description send parameters.", |
1865 error_desc); | 1915 error_desc); |
1866 return false; | 1916 return false; |
1867 } | 1917 } |
1868 last_send_params_ = send_params; | 1918 last_send_params_ = send_params; |
1869 | 1919 |
1870 // TODO(pthatcher): Move remote streams into AudioRecvParameters, | 1920 // TODO(pthatcher): Move remote streams into AudioRecvParameters, |
1871 // and only give it to the media channel once we have a local | 1921 // and only give it to the media channel once we have a local |
1872 // description too (without a local description, we won't be able to | 1922 // description too (without a local description, we won't be able to |
1873 // recv them anyway). | 1923 // recv them anyway). |
1874 if (!UpdateRemoteStreams_w(audio->streams(), action, error_desc)) { | 1924 if (!UpdateRemoteStreams_w(audio->streams(), action, error_desc)) { |
1875 SafeSetError("Failed to set remote audio description streams.", error_desc); | 1925 SafeSetError("Failed to set remote audio description streams.", error_desc); |
1876 return false; | 1926 return false; |
1877 } | 1927 } |
1878 | 1928 |
1879 if (audio->rtp_header_extensions_set()) { | 1929 if (audio->rtp_header_extensions_set()) { |
1880 MaybeCacheRtpAbsSendTimeHeaderExtension_w(audio->rtp_header_extensions()); | 1930 MaybeCacheRtpAbsSendTimeHeaderExtension_w(rtp_header_extensions); |
1881 } | 1931 } |
1882 | 1932 |
1883 set_remote_content_direction(content->direction()); | 1933 set_remote_content_direction(content->direction()); |
1884 UpdateMediaSendRecvState_w(); | 1934 UpdateMediaSendRecvState_w(); |
1885 return true; | 1935 return true; |
1886 } | 1936 } |
1887 | 1937 |
1888 void VoiceChannel::HandleEarlyMediaTimeout() { | 1938 void VoiceChannel::HandleEarlyMediaTimeout() { |
1889 // This occurs on the main thread, not the worker thread. | 1939 // This occurs on the main thread, not the worker thread. |
1890 if (!received_media_) { | 1940 if (!received_media_) { |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2075 LOG(LS_INFO) << "Setting local video description"; | 2125 LOG(LS_INFO) << "Setting local video description"; |
2076 | 2126 |
2077 const VideoContentDescription* video = | 2127 const VideoContentDescription* video = |
2078 static_cast<const VideoContentDescription*>(content); | 2128 static_cast<const VideoContentDescription*>(content); |
2079 RTC_DCHECK(video != NULL); | 2129 RTC_DCHECK(video != NULL); |
2080 if (!video) { | 2130 if (!video) { |
2081 SafeSetError("Can't find video content in local description.", error_desc); | 2131 SafeSetError("Can't find video content in local description.", error_desc); |
2082 return false; | 2132 return false; |
2083 } | 2133 } |
2084 | 2134 |
2085 if (!SetRtpTransportParameters(content, action, CS_LOCAL, error_desc)) { | 2135 RtpHeaderExtensions rtp_header_extensions = |
| 2136 GetFilteredRtpHeaderExtensions(video->rtp_header_extensions()); |
| 2137 |
| 2138 if (!SetRtpTransportParameters(content, action, CS_LOCAL, |
| 2139 rtp_header_extensions, error_desc)) { |
2086 return false; | 2140 return false; |
2087 } | 2141 } |
2088 | 2142 |
2089 VideoRecvParameters recv_params = last_recv_params_; | 2143 VideoRecvParameters recv_params = last_recv_params_; |
2090 RtpParametersFromMediaDescription(video, &recv_params); | 2144 RtpParametersFromMediaDescription(video, rtp_header_extensions, &recv_params); |
2091 if (!media_channel()->SetRecvParameters(recv_params)) { | 2145 if (!media_channel()->SetRecvParameters(recv_params)) { |
2092 SafeSetError("Failed to set local video description recv parameters.", | 2146 SafeSetError("Failed to set local video description recv parameters.", |
2093 error_desc); | 2147 error_desc); |
2094 return false; | 2148 return false; |
2095 } | 2149 } |
2096 for (const VideoCodec& codec : video->codecs()) { | 2150 for (const VideoCodec& codec : video->codecs()) { |
2097 bundle_filter()->AddPayloadType(codec.id); | 2151 bundle_filter()->AddPayloadType(codec.id); |
2098 } | 2152 } |
2099 last_recv_params_ = recv_params; | 2153 last_recv_params_ = recv_params; |
2100 | 2154 |
(...skipping 19 matching lines...) Expand all Loading... |
2120 LOG(LS_INFO) << "Setting remote video description"; | 2174 LOG(LS_INFO) << "Setting remote video description"; |
2121 | 2175 |
2122 const VideoContentDescription* video = | 2176 const VideoContentDescription* video = |
2123 static_cast<const VideoContentDescription*>(content); | 2177 static_cast<const VideoContentDescription*>(content); |
2124 RTC_DCHECK(video != NULL); | 2178 RTC_DCHECK(video != NULL); |
2125 if (!video) { | 2179 if (!video) { |
2126 SafeSetError("Can't find video content in remote description.", error_desc); | 2180 SafeSetError("Can't find video content in remote description.", error_desc); |
2127 return false; | 2181 return false; |
2128 } | 2182 } |
2129 | 2183 |
2130 if (!SetRtpTransportParameters(content, action, CS_REMOTE, error_desc)) { | 2184 RtpHeaderExtensions rtp_header_extensions = |
| 2185 GetFilteredRtpHeaderExtensions(video->rtp_header_extensions()); |
| 2186 |
| 2187 if (!SetRtpTransportParameters(content, action, CS_REMOTE, |
| 2188 rtp_header_extensions, error_desc)) { |
2131 return false; | 2189 return false; |
2132 } | 2190 } |
2133 | 2191 |
2134 VideoSendParameters send_params = last_send_params_; | 2192 VideoSendParameters send_params = last_send_params_; |
2135 RtpSendParametersFromMediaDescription(video, &send_params); | 2193 RtpSendParametersFromMediaDescription(video, rtp_header_extensions, |
| 2194 &send_params); |
2136 if (video->conference_mode()) { | 2195 if (video->conference_mode()) { |
2137 send_params.conference_mode = true; | 2196 send_params.conference_mode = true; |
2138 } | 2197 } |
2139 | 2198 |
2140 bool parameters_applied = media_channel()->SetSendParameters(send_params); | 2199 bool parameters_applied = media_channel()->SetSendParameters(send_params); |
2141 | 2200 |
2142 if (!parameters_applied) { | 2201 if (!parameters_applied) { |
2143 SafeSetError("Failed to set remote video description send parameters.", | 2202 SafeSetError("Failed to set remote video description send parameters.", |
2144 error_desc); | 2203 error_desc); |
2145 return false; | 2204 return false; |
2146 } | 2205 } |
2147 last_send_params_ = send_params; | 2206 last_send_params_ = send_params; |
2148 | 2207 |
2149 // TODO(pthatcher): Move remote streams into VideoRecvParameters, | 2208 // TODO(pthatcher): Move remote streams into VideoRecvParameters, |
2150 // and only give it to the media channel once we have a local | 2209 // and only give it to the media channel once we have a local |
2151 // description too (without a local description, we won't be able to | 2210 // description too (without a local description, we won't be able to |
2152 // recv them anyway). | 2211 // recv them anyway). |
2153 if (!UpdateRemoteStreams_w(video->streams(), action, error_desc)) { | 2212 if (!UpdateRemoteStreams_w(video->streams(), action, error_desc)) { |
2154 SafeSetError("Failed to set remote video description streams.", error_desc); | 2213 SafeSetError("Failed to set remote video description streams.", error_desc); |
2155 return false; | 2214 return false; |
2156 } | 2215 } |
2157 | 2216 |
2158 if (video->rtp_header_extensions_set()) { | 2217 if (video->rtp_header_extensions_set()) { |
2159 MaybeCacheRtpAbsSendTimeHeaderExtension_w(video->rtp_header_extensions()); | 2218 MaybeCacheRtpAbsSendTimeHeaderExtension_w(rtp_header_extensions); |
2160 } | 2219 } |
2161 | 2220 |
2162 set_remote_content_direction(content->direction()); | 2221 set_remote_content_direction(content->direction()); |
2163 UpdateMediaSendRecvState_w(); | 2222 UpdateMediaSendRecvState_w(); |
2164 return true; | 2223 return true; |
2165 } | 2224 } |
2166 | 2225 |
2167 void VideoChannel::OnMessage(rtc::Message *pmsg) { | 2226 void VideoChannel::OnMessage(rtc::Message *pmsg) { |
2168 switch (pmsg->message_id) { | 2227 switch (pmsg->message_id) { |
2169 case MSG_CHANNEL_ERROR: { | 2228 case MSG_CHANNEL_ERROR: { |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2275 RTC_DCHECK(data != NULL); | 2334 RTC_DCHECK(data != NULL); |
2276 if (!data) { | 2335 if (!data) { |
2277 SafeSetError("Can't find data content in local description.", error_desc); | 2336 SafeSetError("Can't find data content in local description.", error_desc); |
2278 return false; | 2337 return false; |
2279 } | 2338 } |
2280 | 2339 |
2281 if (!CheckDataChannelTypeFromContent(data, error_desc)) { | 2340 if (!CheckDataChannelTypeFromContent(data, error_desc)) { |
2282 return false; | 2341 return false; |
2283 } | 2342 } |
2284 | 2343 |
2285 if (!SetRtpTransportParameters(content, action, CS_LOCAL, error_desc)) { | 2344 RtpHeaderExtensions rtp_header_extensions = |
| 2345 GetFilteredRtpHeaderExtensions(data->rtp_header_extensions()); |
| 2346 |
| 2347 if (!SetRtpTransportParameters(content, action, CS_LOCAL, |
| 2348 rtp_header_extensions, error_desc)) { |
2286 return false; | 2349 return false; |
2287 } | 2350 } |
2288 | 2351 |
2289 DataRecvParameters recv_params = last_recv_params_; | 2352 DataRecvParameters recv_params = last_recv_params_; |
2290 RtpParametersFromMediaDescription(data, &recv_params); | 2353 RtpParametersFromMediaDescription(data, rtp_header_extensions, &recv_params); |
2291 if (!media_channel()->SetRecvParameters(recv_params)) { | 2354 if (!media_channel()->SetRecvParameters(recv_params)) { |
2292 SafeSetError("Failed to set remote data description recv parameters.", | 2355 SafeSetError("Failed to set remote data description recv parameters.", |
2293 error_desc); | 2356 error_desc); |
2294 return false; | 2357 return false; |
2295 } | 2358 } |
2296 for (const DataCodec& codec : data->codecs()) { | 2359 for (const DataCodec& codec : data->codecs()) { |
2297 bundle_filter()->AddPayloadType(codec.id); | 2360 bundle_filter()->AddPayloadType(codec.id); |
2298 } | 2361 } |
2299 last_recv_params_ = recv_params; | 2362 last_recv_params_ = recv_params; |
2300 | 2363 |
(...skipping 28 matching lines...) Expand all Loading... |
2329 // If the remote data doesn't have codecs and isn't an update, it | 2392 // If the remote data doesn't have codecs and isn't an update, it |
2330 // must be empty, so ignore it. | 2393 // must be empty, so ignore it. |
2331 if (!data->has_codecs() && action != CA_UPDATE) { | 2394 if (!data->has_codecs() && action != CA_UPDATE) { |
2332 return true; | 2395 return true; |
2333 } | 2396 } |
2334 | 2397 |
2335 if (!CheckDataChannelTypeFromContent(data, error_desc)) { | 2398 if (!CheckDataChannelTypeFromContent(data, error_desc)) { |
2336 return false; | 2399 return false; |
2337 } | 2400 } |
2338 | 2401 |
| 2402 RtpHeaderExtensions rtp_header_extensions = |
| 2403 GetFilteredRtpHeaderExtensions(data->rtp_header_extensions()); |
| 2404 |
2339 LOG(LS_INFO) << "Setting remote data description"; | 2405 LOG(LS_INFO) << "Setting remote data description"; |
2340 if (!SetRtpTransportParameters(content, action, CS_REMOTE, error_desc)) { | 2406 if (!SetRtpTransportParameters(content, action, CS_REMOTE, |
| 2407 rtp_header_extensions, error_desc)) { |
2341 return false; | 2408 return false; |
2342 } | 2409 } |
2343 | 2410 |
2344 DataSendParameters send_params = last_send_params_; | 2411 DataSendParameters send_params = last_send_params_; |
2345 RtpSendParametersFromMediaDescription<DataCodec>(data, &send_params); | 2412 RtpSendParametersFromMediaDescription<DataCodec>(data, rtp_header_extensions, |
| 2413 &send_params); |
2346 if (!media_channel()->SetSendParameters(send_params)) { | 2414 if (!media_channel()->SetSendParameters(send_params)) { |
2347 SafeSetError("Failed to set remote data description send parameters.", | 2415 SafeSetError("Failed to set remote data description send parameters.", |
2348 error_desc); | 2416 error_desc); |
2349 return false; | 2417 return false; |
2350 } | 2418 } |
2351 last_send_params_ = send_params; | 2419 last_send_params_ = send_params; |
2352 | 2420 |
2353 // TODO(pthatcher): Move remote streams into DataRecvParameters, | 2421 // TODO(pthatcher): Move remote streams into DataRecvParameters, |
2354 // and only give it to the media channel once we have a local | 2422 // and only give it to the media channel once we have a local |
2355 // description too (without a local description, we won't be able to | 2423 // description too (without a local description, we won't be able to |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2465 signaling_thread()->Post(RTC_FROM_HERE, this, MSG_READYTOSENDDATA, | 2533 signaling_thread()->Post(RTC_FROM_HERE, this, MSG_READYTOSENDDATA, |
2466 new DataChannelReadyToSendMessageData(writable)); | 2534 new DataChannelReadyToSendMessageData(writable)); |
2467 } | 2535 } |
2468 | 2536 |
2469 void RtpDataChannel::GetSrtpCryptoSuites_n( | 2537 void RtpDataChannel::GetSrtpCryptoSuites_n( |
2470 std::vector<int>* crypto_suites) const { | 2538 std::vector<int>* crypto_suites) const { |
2471 GetSupportedDataCryptoSuites(crypto_options(), crypto_suites); | 2539 GetSupportedDataCryptoSuites(crypto_options(), crypto_suites); |
2472 } | 2540 } |
2473 | 2541 |
2474 } // namespace cricket | 2542 } // namespace cricket |
OLD | NEW |