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

Side by Side Diff: webrtc/pc/channel.cc

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

Powered by Google App Engine
This is Rietveld 408576698