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

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

Issue 2761143002: Support encrypted RTP extensions (RFC 6904) (Closed)
Patch Set: Don't negotiate extension ids in SrtpFilter, more changes after feedback from Taylor. 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,
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,
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 (!srtp_filter_.IsActive()) {
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.
Taylor Brandstetter 2017/04/19 06:48:40 Can you add "because UpdateRtpParams is only used
joachim 2017/04/19 23:40:19 Done.
1104 selected_crypto_suite, &(*recv_key)[0], 1099 ret = true;
1105 static_cast<int>(recv_key->size())); 1100 } else {
1101 ret = srtp_filter_.UpdateRtpParams(
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 std::vector<int> encrypted_extension_ids;
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_extension_ids.push_back(extension.id);
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_extension_ids,
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 std::vector<int>& encrypted_extension_ids,
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_extension_ids,
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 std::vector<int>& encrypted_extension_ids,
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_.SetEncryptedHeaderExtensionIds(src, encrypted_extension_ids);
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 }
1218 break; 1234 break;
1219 case CA_PRANSWER: 1235 case CA_PRANSWER:
1220 // If we're doing DTLS-SRTP, we don't want to update the filter 1236 // If we're doing DTLS-SRTP, we don't want to update the filter
1221 // with an answer, because we already have SRTP parameters. 1237 // with an answer, because we already have SRTP parameters.
1222 if (!dtls) { 1238 if (!dtls) {
1223 ret = srtp_filter_.SetProvisionalAnswer(cryptos, src); 1239 ret = srtp_filter_.SetProvisionalAnswer(cryptos, src);
1224 } 1240 }
1225 break; 1241 break;
1226 case CA_ANSWER: 1242 case CA_ANSWER:
1227 // If we're doing DTLS-SRTP, we don't want to update the filter 1243 // If we're doing DTLS-SRTP, we don't want to update the filter
1228 // with an answer, because we already have SRTP parameters. 1244 // with an answer, because we already have SRTP parameters.
1229 if (!dtls) { 1245 if (!dtls) {
1230 ret = srtp_filter_.SetAnswer(cryptos, src); 1246 ret = srtp_filter_.SetAnswer(cryptos, src);
1231 } 1247 }
1232 break; 1248 break;
1233 default: 1249 default:
1234 break; 1250 break;
1235 } 1251 }
1252 // Only update SRTP filter if using DTLS. SDES is handled internally
1253 // by the SRTP filter.
1254 // TODO(jbauch): Only update if encrypted extension ids have changed.
1255 if (ret && dtls_keyed_) {
1256 bool rtcp = false;
1257 ret = SetupDtlsSrtp_n(rtcp);
1258 }
1236 if (!ret) { 1259 if (!ret) {
1237 SafeSetError("Failed to setup SRTP filter.", error_desc); 1260 SafeSetError("Failed to setup SRTP filter.", error_desc);
1238 return false; 1261 return false;
1239 } 1262 }
1240 return true; 1263 return true;
1241 } 1264 }
1242 1265
1243 bool BaseChannel::SetRtcpMux_n(bool enable, 1266 bool BaseChannel::SetRtcpMux_n(bool enable,
1244 ContentAction action, 1267 ContentAction action,
1245 ContentSource src, 1268 ContentSource src,
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
1456 desc << "Failed to add remote stream ssrc: " << it->first_ssrc(); 1479 desc << "Failed to add remote stream ssrc: " << it->first_ssrc();
1457 SafeSetError(desc.str(), error_desc); 1480 SafeSetError(desc.str(), error_desc);
1458 ret = false; 1481 ret = false;
1459 } 1482 }
1460 } 1483 }
1461 } 1484 }
1462 remote_streams_ = streams; 1485 remote_streams_ = streams;
1463 return ret; 1486 return ret;
1464 } 1487 }
1465 1488
1489 RtpHeaderExtensions BaseChannel::GetFilteredRtpHeaderExtensions(
1490 const RtpHeaderExtensions& extensions) {
1491 if (!crypto_options_.enable_encrypted_rtp_header_extensions) {
1492 return extensions;
Taylor Brandstetter 2017/04/20 06:37:28 I'm still slightly confused by this. If the remote
joachim 2017/04/24 22:07:48 You're right, added filtering code for when "enabl
1493 }
1494
1495 return webrtc::RtpExtension::FilterDuplicateNonEncrypted(extensions);
1496 }
1497
1466 void BaseChannel::MaybeCacheRtpAbsSendTimeHeaderExtension_w( 1498 void BaseChannel::MaybeCacheRtpAbsSendTimeHeaderExtension_w(
1467 const std::vector<webrtc::RtpExtension>& extensions) { 1499 const std::vector<webrtc::RtpExtension>& extensions) {
1468 // Absolute Send Time extension id is used only with external auth, 1500 // 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 1501 // so do not bother searching for it and making asyncronious call to set
1470 // something that is not used. 1502 // something that is not used.
1471 #if defined(ENABLE_EXTERNAL_AUTH) 1503 #if defined(ENABLE_EXTERNAL_AUTH)
1472 const webrtc::RtpExtension* send_time_extension = 1504 const webrtc::RtpExtension* send_time_extension =
1473 FindHeaderExtension(extensions, webrtc::RtpExtension::kAbsSendTimeUri); 1505 webrtc::RtpExtension::FindHeaderExtensionByUri(
1506 extensions, webrtc::RtpExtension::kAbsSendTimeUri);
1474 int rtp_abs_sendtime_extn_id = 1507 int rtp_abs_sendtime_extn_id =
1475 send_time_extension ? send_time_extension->id : -1; 1508 send_time_extension ? send_time_extension->id : -1;
1476 invoker_.AsyncInvoke<void>( 1509 invoker_.AsyncInvoke<void>(
1477 RTC_FROM_HERE, network_thread_, 1510 RTC_FROM_HERE, network_thread_,
1478 Bind(&BaseChannel::CacheRtpAbsSendTimeHeaderExtension_n, this, 1511 Bind(&BaseChannel::CacheRtpAbsSendTimeHeaderExtension_n, this,
1479 rtp_abs_sendtime_extn_id)); 1512 rtp_abs_sendtime_extn_id));
1480 #endif 1513 #endif
1481 } 1514 }
1482 1515
1483 void BaseChannel::CacheRtpAbsSendTimeHeaderExtension_n( 1516 void BaseChannel::CacheRtpAbsSendTimeHeaderExtension_n(
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
1797 LOG(LS_INFO) << "Setting local voice description"; 1830 LOG(LS_INFO) << "Setting local voice description";
1798 1831
1799 const AudioContentDescription* audio = 1832 const AudioContentDescription* audio =
1800 static_cast<const AudioContentDescription*>(content); 1833 static_cast<const AudioContentDescription*>(content);
1801 RTC_DCHECK(audio != NULL); 1834 RTC_DCHECK(audio != NULL);
1802 if (!audio) { 1835 if (!audio) {
1803 SafeSetError("Can't find audio content in local description.", error_desc); 1836 SafeSetError("Can't find audio content in local description.", error_desc);
1804 return false; 1837 return false;
1805 } 1838 }
1806 1839
1807 if (!SetRtpTransportParameters(content, action, CS_LOCAL, error_desc)) { 1840 RtpHeaderExtensions rtp_header_extensions =
1841 GetFilteredRtpHeaderExtensions(audio->rtp_header_extensions());
Taylor Brandstetter 2017/04/19 06:48:40 Is this necessary, since SetRtpTransportParameters
joachim 2017/04/19 23:40:19 Yes, the same (filtered) list is also passed to "R
1842
1843 if (!SetRtpTransportParameters(content, action, CS_LOCAL,
1844 rtp_header_extensions, error_desc)) {
1808 return false; 1845 return false;
1809 } 1846 }
1810 1847
1811 AudioRecvParameters recv_params = last_recv_params_; 1848 AudioRecvParameters recv_params = last_recv_params_;
1812 RtpParametersFromMediaDescription(audio, &recv_params); 1849 RtpParametersFromMediaDescription(audio, rtp_header_extensions, &recv_params);
1813 if (!media_channel()->SetRecvParameters(recv_params)) { 1850 if (!media_channel()->SetRecvParameters(recv_params)) {
1814 SafeSetError("Failed to set local audio description recv parameters.", 1851 SafeSetError("Failed to set local audio description recv parameters.",
1815 error_desc); 1852 error_desc);
1816 return false; 1853 return false;
1817 } 1854 }
1818 for (const AudioCodec& codec : audio->codecs()) { 1855 for (const AudioCodec& codec : audio->codecs()) {
1819 bundle_filter()->AddPayloadType(codec.id); 1856 bundle_filter()->AddPayloadType(codec.id);
1820 } 1857 }
1821 last_recv_params_ = recv_params; 1858 last_recv_params_ = recv_params;
1822 1859
(...skipping 19 matching lines...) Expand all
1842 LOG(LS_INFO) << "Setting remote voice description"; 1879 LOG(LS_INFO) << "Setting remote voice description";
1843 1880
1844 const AudioContentDescription* audio = 1881 const AudioContentDescription* audio =
1845 static_cast<const AudioContentDescription*>(content); 1882 static_cast<const AudioContentDescription*>(content);
1846 RTC_DCHECK(audio != NULL); 1883 RTC_DCHECK(audio != NULL);
1847 if (!audio) { 1884 if (!audio) {
1848 SafeSetError("Can't find audio content in remote description.", error_desc); 1885 SafeSetError("Can't find audio content in remote description.", error_desc);
1849 return false; 1886 return false;
1850 } 1887 }
1851 1888
1852 if (!SetRtpTransportParameters(content, action, CS_REMOTE, error_desc)) { 1889 RtpHeaderExtensions rtp_header_extensions =
1890 GetFilteredRtpHeaderExtensions(audio->rtp_header_extensions());
1891
1892 if (!SetRtpTransportParameters(content, action, CS_REMOTE,
1893 rtp_header_extensions, error_desc)) {
1853 return false; 1894 return false;
1854 } 1895 }
1855 1896
1856 AudioSendParameters send_params = last_send_params_; 1897 AudioSendParameters send_params = last_send_params_;
1857 RtpSendParametersFromMediaDescription(audio, &send_params); 1898 RtpSendParametersFromMediaDescription(audio, rtp_header_extensions,
1899 &send_params);
1858 if (audio->agc_minus_10db()) { 1900 if (audio->agc_minus_10db()) {
1859 send_params.options.adjust_agc_delta = rtc::Optional<int>(kAgcMinus10db); 1901 send_params.options.adjust_agc_delta = rtc::Optional<int>(kAgcMinus10db);
1860 } 1902 }
1861 1903
1862 bool parameters_applied = media_channel()->SetSendParameters(send_params); 1904 bool parameters_applied = media_channel()->SetSendParameters(send_params);
1863 if (!parameters_applied) { 1905 if (!parameters_applied) {
1864 SafeSetError("Failed to set remote audio description send parameters.", 1906 SafeSetError("Failed to set remote audio description send parameters.",
1865 error_desc); 1907 error_desc);
1866 return false; 1908 return false;
1867 } 1909 }
1868 last_send_params_ = send_params; 1910 last_send_params_ = send_params;
1869 1911
1870 // TODO(pthatcher): Move remote streams into AudioRecvParameters, 1912 // TODO(pthatcher): Move remote streams into AudioRecvParameters,
1871 // and only give it to the media channel once we have a local 1913 // 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 1914 // description too (without a local description, we won't be able to
1873 // recv them anyway). 1915 // recv them anyway).
1874 if (!UpdateRemoteStreams_w(audio->streams(), action, error_desc)) { 1916 if (!UpdateRemoteStreams_w(audio->streams(), action, error_desc)) {
1875 SafeSetError("Failed to set remote audio description streams.", error_desc); 1917 SafeSetError("Failed to set remote audio description streams.", error_desc);
1876 return false; 1918 return false;
1877 } 1919 }
1878 1920
1879 if (audio->rtp_header_extensions_set()) { 1921 if (audio->rtp_header_extensions_set()) {
1880 MaybeCacheRtpAbsSendTimeHeaderExtension_w(audio->rtp_header_extensions()); 1922 MaybeCacheRtpAbsSendTimeHeaderExtension_w(rtp_header_extensions);
1881 } 1923 }
1882 1924
1883 set_remote_content_direction(content->direction()); 1925 set_remote_content_direction(content->direction());
1884 UpdateMediaSendRecvState_w(); 1926 UpdateMediaSendRecvState_w();
1885 return true; 1927 return true;
1886 } 1928 }
1887 1929
1888 void VoiceChannel::HandleEarlyMediaTimeout() { 1930 void VoiceChannel::HandleEarlyMediaTimeout() {
1889 // This occurs on the main thread, not the worker thread. 1931 // This occurs on the main thread, not the worker thread.
1890 if (!received_media_) { 1932 if (!received_media_) {
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
2075 LOG(LS_INFO) << "Setting local video description"; 2117 LOG(LS_INFO) << "Setting local video description";
2076 2118
2077 const VideoContentDescription* video = 2119 const VideoContentDescription* video =
2078 static_cast<const VideoContentDescription*>(content); 2120 static_cast<const VideoContentDescription*>(content);
2079 RTC_DCHECK(video != NULL); 2121 RTC_DCHECK(video != NULL);
2080 if (!video) { 2122 if (!video) {
2081 SafeSetError("Can't find video content in local description.", error_desc); 2123 SafeSetError("Can't find video content in local description.", error_desc);
2082 return false; 2124 return false;
2083 } 2125 }
2084 2126
2085 if (!SetRtpTransportParameters(content, action, CS_LOCAL, error_desc)) { 2127 RtpHeaderExtensions rtp_header_extensions =
2128 GetFilteredRtpHeaderExtensions(video->rtp_header_extensions());
2129
2130 if (!SetRtpTransportParameters(content, action, CS_LOCAL,
2131 rtp_header_extensions, error_desc)) {
2086 return false; 2132 return false;
2087 } 2133 }
2088 2134
2089 VideoRecvParameters recv_params = last_recv_params_; 2135 VideoRecvParameters recv_params = last_recv_params_;
2090 RtpParametersFromMediaDescription(video, &recv_params); 2136 RtpParametersFromMediaDescription(video, rtp_header_extensions, &recv_params);
2091 if (!media_channel()->SetRecvParameters(recv_params)) { 2137 if (!media_channel()->SetRecvParameters(recv_params)) {
2092 SafeSetError("Failed to set local video description recv parameters.", 2138 SafeSetError("Failed to set local video description recv parameters.",
2093 error_desc); 2139 error_desc);
2094 return false; 2140 return false;
2095 } 2141 }
2096 for (const VideoCodec& codec : video->codecs()) { 2142 for (const VideoCodec& codec : video->codecs()) {
2097 bundle_filter()->AddPayloadType(codec.id); 2143 bundle_filter()->AddPayloadType(codec.id);
2098 } 2144 }
2099 last_recv_params_ = recv_params; 2145 last_recv_params_ = recv_params;
2100 2146
(...skipping 19 matching lines...) Expand all
2120 LOG(LS_INFO) << "Setting remote video description"; 2166 LOG(LS_INFO) << "Setting remote video description";
2121 2167
2122 const VideoContentDescription* video = 2168 const VideoContentDescription* video =
2123 static_cast<const VideoContentDescription*>(content); 2169 static_cast<const VideoContentDescription*>(content);
2124 RTC_DCHECK(video != NULL); 2170 RTC_DCHECK(video != NULL);
2125 if (!video) { 2171 if (!video) {
2126 SafeSetError("Can't find video content in remote description.", error_desc); 2172 SafeSetError("Can't find video content in remote description.", error_desc);
2127 return false; 2173 return false;
2128 } 2174 }
2129 2175
2130 if (!SetRtpTransportParameters(content, action, CS_REMOTE, error_desc)) { 2176 RtpHeaderExtensions rtp_header_extensions =
2177 GetFilteredRtpHeaderExtensions(video->rtp_header_extensions());
2178
2179 if (!SetRtpTransportParameters(content, action, CS_REMOTE,
2180 rtp_header_extensions, error_desc)) {
2131 return false; 2181 return false;
2132 } 2182 }
2133 2183
2134 VideoSendParameters send_params = last_send_params_; 2184 VideoSendParameters send_params = last_send_params_;
2135 RtpSendParametersFromMediaDescription(video, &send_params); 2185 RtpSendParametersFromMediaDescription(video, rtp_header_extensions,
2186 &send_params);
2136 if (video->conference_mode()) { 2187 if (video->conference_mode()) {
2137 send_params.conference_mode = true; 2188 send_params.conference_mode = true;
2138 } 2189 }
2139 2190
2140 bool parameters_applied = media_channel()->SetSendParameters(send_params); 2191 bool parameters_applied = media_channel()->SetSendParameters(send_params);
2141 2192
2142 if (!parameters_applied) { 2193 if (!parameters_applied) {
2143 SafeSetError("Failed to set remote video description send parameters.", 2194 SafeSetError("Failed to set remote video description send parameters.",
2144 error_desc); 2195 error_desc);
2145 return false; 2196 return false;
2146 } 2197 }
2147 last_send_params_ = send_params; 2198 last_send_params_ = send_params;
2148 2199
2149 // TODO(pthatcher): Move remote streams into VideoRecvParameters, 2200 // TODO(pthatcher): Move remote streams into VideoRecvParameters,
2150 // and only give it to the media channel once we have a local 2201 // 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 2202 // description too (without a local description, we won't be able to
2152 // recv them anyway). 2203 // recv them anyway).
2153 if (!UpdateRemoteStreams_w(video->streams(), action, error_desc)) { 2204 if (!UpdateRemoteStreams_w(video->streams(), action, error_desc)) {
2154 SafeSetError("Failed to set remote video description streams.", error_desc); 2205 SafeSetError("Failed to set remote video description streams.", error_desc);
2155 return false; 2206 return false;
2156 } 2207 }
2157 2208
2158 if (video->rtp_header_extensions_set()) { 2209 if (video->rtp_header_extensions_set()) {
2159 MaybeCacheRtpAbsSendTimeHeaderExtension_w(video->rtp_header_extensions()); 2210 MaybeCacheRtpAbsSendTimeHeaderExtension_w(rtp_header_extensions);
2160 } 2211 }
2161 2212
2162 set_remote_content_direction(content->direction()); 2213 set_remote_content_direction(content->direction());
2163 UpdateMediaSendRecvState_w(); 2214 UpdateMediaSendRecvState_w();
2164 return true; 2215 return true;
2165 } 2216 }
2166 2217
2167 void VideoChannel::OnMessage(rtc::Message *pmsg) { 2218 void VideoChannel::OnMessage(rtc::Message *pmsg) {
2168 switch (pmsg->message_id) { 2219 switch (pmsg->message_id) {
2169 case MSG_CHANNEL_ERROR: { 2220 case MSG_CHANNEL_ERROR: {
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
2275 RTC_DCHECK(data != NULL); 2326 RTC_DCHECK(data != NULL);
2276 if (!data) { 2327 if (!data) {
2277 SafeSetError("Can't find data content in local description.", error_desc); 2328 SafeSetError("Can't find data content in local description.", error_desc);
2278 return false; 2329 return false;
2279 } 2330 }
2280 2331
2281 if (!CheckDataChannelTypeFromContent(data, error_desc)) { 2332 if (!CheckDataChannelTypeFromContent(data, error_desc)) {
2282 return false; 2333 return false;
2283 } 2334 }
2284 2335
2285 if (!SetRtpTransportParameters(content, action, CS_LOCAL, error_desc)) { 2336 RtpHeaderExtensions rtp_header_extensions =
2337 GetFilteredRtpHeaderExtensions(data->rtp_header_extensions());
2338
2339 if (!SetRtpTransportParameters(content, action, CS_LOCAL,
2340 rtp_header_extensions, error_desc)) {
2286 return false; 2341 return false;
2287 } 2342 }
2288 2343
2289 DataRecvParameters recv_params = last_recv_params_; 2344 DataRecvParameters recv_params = last_recv_params_;
2290 RtpParametersFromMediaDescription(data, &recv_params); 2345 RtpParametersFromMediaDescription(data, rtp_header_extensions, &recv_params);
2291 if (!media_channel()->SetRecvParameters(recv_params)) { 2346 if (!media_channel()->SetRecvParameters(recv_params)) {
2292 SafeSetError("Failed to set remote data description recv parameters.", 2347 SafeSetError("Failed to set remote data description recv parameters.",
2293 error_desc); 2348 error_desc);
2294 return false; 2349 return false;
2295 } 2350 }
2296 for (const DataCodec& codec : data->codecs()) { 2351 for (const DataCodec& codec : data->codecs()) {
2297 bundle_filter()->AddPayloadType(codec.id); 2352 bundle_filter()->AddPayloadType(codec.id);
2298 } 2353 }
2299 last_recv_params_ = recv_params; 2354 last_recv_params_ = recv_params;
2300 2355
(...skipping 28 matching lines...) Expand all
2329 // If the remote data doesn't have codecs and isn't an update, it 2384 // If the remote data doesn't have codecs and isn't an update, it
2330 // must be empty, so ignore it. 2385 // must be empty, so ignore it.
2331 if (!data->has_codecs() && action != CA_UPDATE) { 2386 if (!data->has_codecs() && action != CA_UPDATE) {
2332 return true; 2387 return true;
2333 } 2388 }
2334 2389
2335 if (!CheckDataChannelTypeFromContent(data, error_desc)) { 2390 if (!CheckDataChannelTypeFromContent(data, error_desc)) {
2336 return false; 2391 return false;
2337 } 2392 }
2338 2393
2394 RtpHeaderExtensions rtp_header_extensions =
2395 GetFilteredRtpHeaderExtensions(data->rtp_header_extensions());
2396
2339 LOG(LS_INFO) << "Setting remote data description"; 2397 LOG(LS_INFO) << "Setting remote data description";
2340 if (!SetRtpTransportParameters(content, action, CS_REMOTE, error_desc)) { 2398 if (!SetRtpTransportParameters(content, action, CS_REMOTE,
2399 rtp_header_extensions, error_desc)) {
2341 return false; 2400 return false;
2342 } 2401 }
2343 2402
2344 DataSendParameters send_params = last_send_params_; 2403 DataSendParameters send_params = last_send_params_;
2345 RtpSendParametersFromMediaDescription<DataCodec>(data, &send_params); 2404 RtpSendParametersFromMediaDescription<DataCodec>(data, rtp_header_extensions,
2405 &send_params);
2346 if (!media_channel()->SetSendParameters(send_params)) { 2406 if (!media_channel()->SetSendParameters(send_params)) {
2347 SafeSetError("Failed to set remote data description send parameters.", 2407 SafeSetError("Failed to set remote data description send parameters.",
2348 error_desc); 2408 error_desc);
2349 return false; 2409 return false;
2350 } 2410 }
2351 last_send_params_ = send_params; 2411 last_send_params_ = send_params;
2352 2412
2353 // TODO(pthatcher): Move remote streams into DataRecvParameters, 2413 // TODO(pthatcher): Move remote streams into DataRecvParameters,
2354 // and only give it to the media channel once we have a local 2414 // 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 2415 // 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, 2525 signaling_thread()->Post(RTC_FROM_HERE, this, MSG_READYTOSENDDATA,
2466 new DataChannelReadyToSendMessageData(writable)); 2526 new DataChannelReadyToSendMessageData(writable));
2467 } 2527 }
2468 2528
2469 void RtpDataChannel::GetSrtpCryptoSuites_n( 2529 void RtpDataChannel::GetSrtpCryptoSuites_n(
2470 std::vector<int>* crypto_suites) const { 2530 std::vector<int>* crypto_suites) const {
2471 GetSupportedDataCryptoSuites(crypto_options(), crypto_suites); 2531 GetSupportedDataCryptoSuites(crypto_options(), crypto_suites);
2472 } 2532 }
2473 2533
2474 } // namespace cricket 2534 } // namespace cricket
OLDNEW
« webrtc/config.cc ('K') | « webrtc/pc/channel.h ('k') | webrtc/pc/channel_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698