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

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

Issue 2761143002: Support encrypted RTP extensions (RFC 6904) (Closed)
Patch Set: More 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 because UpdateRtpParams is only used
1104 selected_crypto_suite, &(*recv_key)[0], 1099 // to update the set of encrypted RTP header extension IDs.
1105 static_cast<int>(recv_key->size())); 1100 ret = true;
1101 } else {
1102 ret = srtp_filter_.UpdateRtpParams(
1103 selected_crypto_suite,
1104 &(*send_key)[0], static_cast<int>(send_key->size()),
1105 selected_crypto_suite,
1106 &(*recv_key)[0], static_cast<int>(recv_key->size()));
1107 }
1106 } 1108 }
1107 1109
1108 if (!ret) { 1110 if (!ret) {
1109 LOG(LS_WARNING) << "DTLS-SRTP key installation failed"; 1111 LOG(LS_WARNING) << "DTLS-SRTP key installation failed";
1110 } else { 1112 } else {
1111 dtls_keyed_ = true; 1113 dtls_keyed_ = true;
1112 UpdateTransportOverhead(); 1114 UpdateTransportOverhead();
1113 } 1115 }
1114 return ret; 1116 return ret;
1115 } 1117 }
(...skipping 27 matching lines...) Expand all
1143 1145
1144 LOG(LS_INFO) << "Channel not writable (" << content_name_ << ")"; 1146 LOG(LS_INFO) << "Channel not writable (" << content_name_ << ")";
1145 writable_ = false; 1147 writable_ = false;
1146 UpdateMediaSendRecvState(); 1148 UpdateMediaSendRecvState();
1147 } 1149 }
1148 1150
1149 bool BaseChannel::SetRtpTransportParameters( 1151 bool BaseChannel::SetRtpTransportParameters(
1150 const MediaContentDescription* content, 1152 const MediaContentDescription* content,
1151 ContentAction action, 1153 ContentAction action,
1152 ContentSource src, 1154 ContentSource src,
1155 const RtpHeaderExtensions& extensions,
1153 std::string* error_desc) { 1156 std::string* error_desc) {
1154 if (action == CA_UPDATE) { 1157 if (action == CA_UPDATE) {
1155 // These parameters never get changed by a CA_UDPATE. 1158 // These parameters never get changed by a CA_UDPATE.
1156 return true; 1159 return true;
1157 } 1160 }
1158 1161
1162 std::vector<int> encrypted_extension_ids;
1163 for (const webrtc::RtpExtension& extension : extensions) {
1164 if (extension.encrypt) {
1165 LOG(LS_INFO) << "Using " << (src == CS_LOCAL ? "local" : "remote")
1166 << " encrypted extension: " << extension.ToString();
1167 encrypted_extension_ids.push_back(extension.id);
1168 }
1169 }
1170
1159 // Cache srtp_required_ for belt and suspenders check on SendPacket 1171 // Cache srtp_required_ for belt and suspenders check on SendPacket
1160 return network_thread_->Invoke<bool>( 1172 return network_thread_->Invoke<bool>(
1161 RTC_FROM_HERE, Bind(&BaseChannel::SetRtpTransportParameters_n, this, 1173 RTC_FROM_HERE, Bind(&BaseChannel::SetRtpTransportParameters_n, this,
1162 content, action, src, error_desc)); 1174 content, action, src, encrypted_extension_ids,
1175 error_desc));
1163 } 1176 }
1164 1177
1165 bool BaseChannel::SetRtpTransportParameters_n( 1178 bool BaseChannel::SetRtpTransportParameters_n(
1166 const MediaContentDescription* content, 1179 const MediaContentDescription* content,
1167 ContentAction action, 1180 ContentAction action,
1168 ContentSource src, 1181 ContentSource src,
1182 const std::vector<int>& encrypted_extension_ids,
1169 std::string* error_desc) { 1183 std::string* error_desc) {
1170 RTC_DCHECK(network_thread_->IsCurrent()); 1184 RTC_DCHECK(network_thread_->IsCurrent());
1171 1185
1172 if (!SetSrtp_n(content->cryptos(), action, src, error_desc)) { 1186 if (!SetSrtp_n(content->cryptos(), action, src, encrypted_extension_ids,
1187 error_desc)) {
1173 return false; 1188 return false;
1174 } 1189 }
1175 1190
1176 if (!SetRtcpMux_n(content->rtcp_mux(), action, src, error_desc)) { 1191 if (!SetRtcpMux_n(content->rtcp_mux(), action, src, error_desc)) {
1177 return false; 1192 return false;
1178 } 1193 }
1179 1194
1180 return true; 1195 return true;
1181 } 1196 }
1182 1197
1183 // |dtls| will be set to true if DTLS is active for transport and crypto is 1198 // |dtls| will be set to true if DTLS is active for transport and crypto is
1184 // empty. 1199 // empty.
1185 bool BaseChannel::CheckSrtpConfig_n(const std::vector<CryptoParams>& cryptos, 1200 bool BaseChannel::CheckSrtpConfig_n(const std::vector<CryptoParams>& cryptos,
1186 bool* dtls, 1201 bool* dtls,
1187 std::string* error_desc) { 1202 std::string* error_desc) {
1188 *dtls = rtp_dtls_transport_ && rtp_dtls_transport_->IsDtlsActive(); 1203 *dtls = rtp_dtls_transport_ && rtp_dtls_transport_->IsDtlsActive();
1189 if (*dtls && !cryptos.empty()) { 1204 if (*dtls && !cryptos.empty()) {
1190 SafeSetError("Cryptos must be empty when DTLS is active.", error_desc); 1205 SafeSetError("Cryptos must be empty when DTLS is active.", error_desc);
1191 return false; 1206 return false;
1192 } 1207 }
1193 return true; 1208 return true;
1194 } 1209 }
1195 1210
1196 bool BaseChannel::SetSrtp_n(const std::vector<CryptoParams>& cryptos, 1211 bool BaseChannel::SetSrtp_n(const std::vector<CryptoParams>& cryptos,
1197 ContentAction action, 1212 ContentAction action,
1198 ContentSource src, 1213 ContentSource src,
1214 const std::vector<int>& encrypted_extension_ids,
1199 std::string* error_desc) { 1215 std::string* error_desc) {
1200 TRACE_EVENT0("webrtc", "BaseChannel::SetSrtp_w"); 1216 TRACE_EVENT0("webrtc", "BaseChannel::SetSrtp_w");
1201 if (action == CA_UPDATE) { 1217 if (action == CA_UPDATE) {
1202 // no crypto params. 1218 // no crypto params.
1203 return true; 1219 return true;
1204 } 1220 }
1205 bool ret = false; 1221 bool ret = false;
1206 bool dtls = false; 1222 bool dtls = false;
1207 ret = CheckSrtpConfig_n(cryptos, &dtls, error_desc); 1223 ret = CheckSrtpConfig_n(cryptos, &dtls, error_desc);
1208 if (!ret) { 1224 if (!ret) {
1209 return false; 1225 return false;
1210 } 1226 }
1227 srtp_filter_.SetEncryptedHeaderExtensionIds(src, encrypted_extension_ids);
1211 switch (action) { 1228 switch (action) {
1212 case CA_OFFER: 1229 case CA_OFFER:
1213 // If DTLS is already active on the channel, we could be renegotiating 1230 // If DTLS is already active on the channel, we could be renegotiating
1214 // here. We don't update the srtp filter. 1231 // here. We don't update the srtp filter.
1215 if (!dtls) { 1232 if (!dtls) {
1216 ret = srtp_filter_.SetOffer(cryptos, src); 1233 ret = srtp_filter_.SetOffer(cryptos, src);
1217 } 1234 }
1218 break; 1235 break;
1219 case CA_PRANSWER: 1236 case CA_PRANSWER:
1220 // If we're doing DTLS-SRTP, we don't want to update the filter 1237 // If we're doing DTLS-SRTP, we don't want to update the filter
1221 // with an answer, because we already have SRTP parameters. 1238 // with an answer, because we already have SRTP parameters.
1222 if (!dtls) { 1239 if (!dtls) {
1223 ret = srtp_filter_.SetProvisionalAnswer(cryptos, src); 1240 ret = srtp_filter_.SetProvisionalAnswer(cryptos, src);
1224 } 1241 }
1225 break; 1242 break;
1226 case CA_ANSWER: 1243 case CA_ANSWER:
1227 // If we're doing DTLS-SRTP, we don't want to update the filter 1244 // If we're doing DTLS-SRTP, we don't want to update the filter
1228 // with an answer, because we already have SRTP parameters. 1245 // with an answer, because we already have SRTP parameters.
1229 if (!dtls) { 1246 if (!dtls) {
1230 ret = srtp_filter_.SetAnswer(cryptos, src); 1247 ret = srtp_filter_.SetAnswer(cryptos, src);
1231 } 1248 }
1232 break; 1249 break;
1233 default: 1250 default:
1234 break; 1251 break;
1235 } 1252 }
1253 // Only update SRTP filter if using DTLS. SDES is handled internally
1254 // by the SRTP filter.
1255 // TODO(jbauch): Only update if encrypted extension ids have changed.
1256 if (ret && dtls_keyed_) {
1257 bool rtcp = false;
1258 ret = SetupDtlsSrtp_n(rtcp);
1259 }
1236 if (!ret) { 1260 if (!ret) {
1237 SafeSetError("Failed to setup SRTP filter.", error_desc); 1261 SafeSetError("Failed to setup SRTP filter.", error_desc);
1238 return false; 1262 return false;
1239 } 1263 }
1240 return true; 1264 return true;
1241 } 1265 }
1242 1266
1243 bool BaseChannel::SetRtcpMux_n(bool enable, 1267 bool BaseChannel::SetRtcpMux_n(bool enable,
1244 ContentAction action, 1268 ContentAction action,
1245 ContentSource src, 1269 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(); 1480 desc << "Failed to add remote stream ssrc: " << it->first_ssrc();
1457 SafeSetError(desc.str(), error_desc); 1481 SafeSetError(desc.str(), error_desc);
1458 ret = false; 1482 ret = false;
1459 } 1483 }
1460 } 1484 }
1461 } 1485 }
1462 remote_streams_ = streams; 1486 remote_streams_ = streams;
1463 return ret; 1487 return ret;
1464 } 1488 }
1465 1489
1490 RtpHeaderExtensions BaseChannel::GetFilteredRtpHeaderExtensions(
1491 const RtpHeaderExtensions& extensions) {
1492 if (!crypto_options_.enable_encrypted_rtp_header_extensions) {
1493 return extensions;
1494 }
1495
1496 return webrtc::RtpExtension::FilterDuplicateNonEncrypted(extensions);
1497 }
1498
1466 void BaseChannel::MaybeCacheRtpAbsSendTimeHeaderExtension_w( 1499 void BaseChannel::MaybeCacheRtpAbsSendTimeHeaderExtension_w(
1467 const std::vector<webrtc::RtpExtension>& extensions) { 1500 const std::vector<webrtc::RtpExtension>& extensions) {
1468 // Absolute Send Time extension id is used only with external auth, 1501 // 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 1502 // so do not bother searching for it and making asyncronious call to set
1470 // something that is not used. 1503 // something that is not used.
1471 #if defined(ENABLE_EXTERNAL_AUTH) 1504 #if defined(ENABLE_EXTERNAL_AUTH)
1472 const webrtc::RtpExtension* send_time_extension = 1505 const webrtc::RtpExtension* send_time_extension =
1473 FindHeaderExtension(extensions, webrtc::RtpExtension::kAbsSendTimeUri); 1506 webrtc::RtpExtension::FindHeaderExtensionByUri(
1507 extensions, webrtc::RtpExtension::kAbsSendTimeUri);
1474 int rtp_abs_sendtime_extn_id = 1508 int rtp_abs_sendtime_extn_id =
1475 send_time_extension ? send_time_extension->id : -1; 1509 send_time_extension ? send_time_extension->id : -1;
1476 invoker_.AsyncInvoke<void>( 1510 invoker_.AsyncInvoke<void>(
1477 RTC_FROM_HERE, network_thread_, 1511 RTC_FROM_HERE, network_thread_,
1478 Bind(&BaseChannel::CacheRtpAbsSendTimeHeaderExtension_n, this, 1512 Bind(&BaseChannel::CacheRtpAbsSendTimeHeaderExtension_n, this,
1479 rtp_abs_sendtime_extn_id)); 1513 rtp_abs_sendtime_extn_id));
1480 #endif 1514 #endif
1481 } 1515 }
1482 1516
1483 void BaseChannel::CacheRtpAbsSendTimeHeaderExtension_n( 1517 void BaseChannel::CacheRtpAbsSendTimeHeaderExtension_n(
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
1797 LOG(LS_INFO) << "Setting local voice description"; 1831 LOG(LS_INFO) << "Setting local voice description";
1798 1832
1799 const AudioContentDescription* audio = 1833 const AudioContentDescription* audio =
1800 static_cast<const AudioContentDescription*>(content); 1834 static_cast<const AudioContentDescription*>(content);
1801 RTC_DCHECK(audio != NULL); 1835 RTC_DCHECK(audio != NULL);
1802 if (!audio) { 1836 if (!audio) {
1803 SafeSetError("Can't find audio content in local description.", error_desc); 1837 SafeSetError("Can't find audio content in local description.", error_desc);
1804 return false; 1838 return false;
1805 } 1839 }
1806 1840
1807 if (!SetRtpTransportParameters(content, action, CS_LOCAL, error_desc)) { 1841 RtpHeaderExtensions rtp_header_extensions =
1842 GetFilteredRtpHeaderExtensions(audio->rtp_header_extensions());
1843
1844 if (!SetRtpTransportParameters(content, action, CS_LOCAL,
1845 rtp_header_extensions, error_desc)) {
1808 return false; 1846 return false;
1809 } 1847 }
1810 1848
1811 AudioRecvParameters recv_params = last_recv_params_; 1849 AudioRecvParameters recv_params = last_recv_params_;
1812 RtpParametersFromMediaDescription(audio, &recv_params); 1850 RtpParametersFromMediaDescription(audio, rtp_header_extensions, &recv_params);
1813 if (!media_channel()->SetRecvParameters(recv_params)) { 1851 if (!media_channel()->SetRecvParameters(recv_params)) {
1814 SafeSetError("Failed to set local audio description recv parameters.", 1852 SafeSetError("Failed to set local audio description recv parameters.",
1815 error_desc); 1853 error_desc);
1816 return false; 1854 return false;
1817 } 1855 }
1818 for (const AudioCodec& codec : audio->codecs()) { 1856 for (const AudioCodec& codec : audio->codecs()) {
1819 bundle_filter()->AddPayloadType(codec.id); 1857 bundle_filter()->AddPayloadType(codec.id);
1820 } 1858 }
1821 last_recv_params_ = recv_params; 1859 last_recv_params_ = recv_params;
1822 1860
(...skipping 19 matching lines...) Expand all
1842 LOG(LS_INFO) << "Setting remote voice description"; 1880 LOG(LS_INFO) << "Setting remote voice description";
1843 1881
1844 const AudioContentDescription* audio = 1882 const AudioContentDescription* audio =
1845 static_cast<const AudioContentDescription*>(content); 1883 static_cast<const AudioContentDescription*>(content);
1846 RTC_DCHECK(audio != NULL); 1884 RTC_DCHECK(audio != NULL);
1847 if (!audio) { 1885 if (!audio) {
1848 SafeSetError("Can't find audio content in remote description.", error_desc); 1886 SafeSetError("Can't find audio content in remote description.", error_desc);
1849 return false; 1887 return false;
1850 } 1888 }
1851 1889
1852 if (!SetRtpTransportParameters(content, action, CS_REMOTE, error_desc)) { 1890 RtpHeaderExtensions rtp_header_extensions =
1891 GetFilteredRtpHeaderExtensions(audio->rtp_header_extensions());
1892
1893 if (!SetRtpTransportParameters(content, action, CS_REMOTE,
1894 rtp_header_extensions, error_desc)) {
1853 return false; 1895 return false;
1854 } 1896 }
1855 1897
1856 AudioSendParameters send_params = last_send_params_; 1898 AudioSendParameters send_params = last_send_params_;
1857 RtpSendParametersFromMediaDescription(audio, &send_params); 1899 RtpSendParametersFromMediaDescription(audio, rtp_header_extensions,
1900 &send_params);
1858 if (audio->agc_minus_10db()) { 1901 if (audio->agc_minus_10db()) {
1859 send_params.options.adjust_agc_delta = rtc::Optional<int>(kAgcMinus10db); 1902 send_params.options.adjust_agc_delta = rtc::Optional<int>(kAgcMinus10db);
1860 } 1903 }
1861 1904
1862 bool parameters_applied = media_channel()->SetSendParameters(send_params); 1905 bool parameters_applied = media_channel()->SetSendParameters(send_params);
1863 if (!parameters_applied) { 1906 if (!parameters_applied) {
1864 SafeSetError("Failed to set remote audio description send parameters.", 1907 SafeSetError("Failed to set remote audio description send parameters.",
1865 error_desc); 1908 error_desc);
1866 return false; 1909 return false;
1867 } 1910 }
1868 last_send_params_ = send_params; 1911 last_send_params_ = send_params;
1869 1912
1870 // TODO(pthatcher): Move remote streams into AudioRecvParameters, 1913 // TODO(pthatcher): Move remote streams into AudioRecvParameters,
1871 // and only give it to the media channel once we have a local 1914 // 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 1915 // description too (without a local description, we won't be able to
1873 // recv them anyway). 1916 // recv them anyway).
1874 if (!UpdateRemoteStreams_w(audio->streams(), action, error_desc)) { 1917 if (!UpdateRemoteStreams_w(audio->streams(), action, error_desc)) {
1875 SafeSetError("Failed to set remote audio description streams.", error_desc); 1918 SafeSetError("Failed to set remote audio description streams.", error_desc);
1876 return false; 1919 return false;
1877 } 1920 }
1878 1921
1879 if (audio->rtp_header_extensions_set()) { 1922 if (audio->rtp_header_extensions_set()) {
1880 MaybeCacheRtpAbsSendTimeHeaderExtension_w(audio->rtp_header_extensions()); 1923 MaybeCacheRtpAbsSendTimeHeaderExtension_w(rtp_header_extensions);
1881 } 1924 }
1882 1925
1883 set_remote_content_direction(content->direction()); 1926 set_remote_content_direction(content->direction());
1884 UpdateMediaSendRecvState_w(); 1927 UpdateMediaSendRecvState_w();
1885 return true; 1928 return true;
1886 } 1929 }
1887 1930
1888 void VoiceChannel::HandleEarlyMediaTimeout() { 1931 void VoiceChannel::HandleEarlyMediaTimeout() {
1889 // This occurs on the main thread, not the worker thread. 1932 // This occurs on the main thread, not the worker thread.
1890 if (!received_media_) { 1933 if (!received_media_) {
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
2075 LOG(LS_INFO) << "Setting local video description"; 2118 LOG(LS_INFO) << "Setting local video description";
2076 2119
2077 const VideoContentDescription* video = 2120 const VideoContentDescription* video =
2078 static_cast<const VideoContentDescription*>(content); 2121 static_cast<const VideoContentDescription*>(content);
2079 RTC_DCHECK(video != NULL); 2122 RTC_DCHECK(video != NULL);
2080 if (!video) { 2123 if (!video) {
2081 SafeSetError("Can't find video content in local description.", error_desc); 2124 SafeSetError("Can't find video content in local description.", error_desc);
2082 return false; 2125 return false;
2083 } 2126 }
2084 2127
2085 if (!SetRtpTransportParameters(content, action, CS_LOCAL, error_desc)) { 2128 RtpHeaderExtensions rtp_header_extensions =
2129 GetFilteredRtpHeaderExtensions(video->rtp_header_extensions());
2130
2131 if (!SetRtpTransportParameters(content, action, CS_LOCAL,
2132 rtp_header_extensions, error_desc)) {
2086 return false; 2133 return false;
2087 } 2134 }
2088 2135
2089 VideoRecvParameters recv_params = last_recv_params_; 2136 VideoRecvParameters recv_params = last_recv_params_;
2090 RtpParametersFromMediaDescription(video, &recv_params); 2137 RtpParametersFromMediaDescription(video, rtp_header_extensions, &recv_params);
2091 if (!media_channel()->SetRecvParameters(recv_params)) { 2138 if (!media_channel()->SetRecvParameters(recv_params)) {
2092 SafeSetError("Failed to set local video description recv parameters.", 2139 SafeSetError("Failed to set local video description recv parameters.",
2093 error_desc); 2140 error_desc);
2094 return false; 2141 return false;
2095 } 2142 }
2096 for (const VideoCodec& codec : video->codecs()) { 2143 for (const VideoCodec& codec : video->codecs()) {
2097 bundle_filter()->AddPayloadType(codec.id); 2144 bundle_filter()->AddPayloadType(codec.id);
2098 } 2145 }
2099 last_recv_params_ = recv_params; 2146 last_recv_params_ = recv_params;
2100 2147
(...skipping 19 matching lines...) Expand all
2120 LOG(LS_INFO) << "Setting remote video description"; 2167 LOG(LS_INFO) << "Setting remote video description";
2121 2168
2122 const VideoContentDescription* video = 2169 const VideoContentDescription* video =
2123 static_cast<const VideoContentDescription*>(content); 2170 static_cast<const VideoContentDescription*>(content);
2124 RTC_DCHECK(video != NULL); 2171 RTC_DCHECK(video != NULL);
2125 if (!video) { 2172 if (!video) {
2126 SafeSetError("Can't find video content in remote description.", error_desc); 2173 SafeSetError("Can't find video content in remote description.", error_desc);
2127 return false; 2174 return false;
2128 } 2175 }
2129 2176
2130 if (!SetRtpTransportParameters(content, action, CS_REMOTE, error_desc)) { 2177 RtpHeaderExtensions rtp_header_extensions =
2178 GetFilteredRtpHeaderExtensions(video->rtp_header_extensions());
2179
2180 if (!SetRtpTransportParameters(content, action, CS_REMOTE,
2181 rtp_header_extensions, error_desc)) {
2131 return false; 2182 return false;
2132 } 2183 }
2133 2184
2134 VideoSendParameters send_params = last_send_params_; 2185 VideoSendParameters send_params = last_send_params_;
2135 RtpSendParametersFromMediaDescription(video, &send_params); 2186 RtpSendParametersFromMediaDescription(video, rtp_header_extensions,
2187 &send_params);
2136 if (video->conference_mode()) { 2188 if (video->conference_mode()) {
2137 send_params.conference_mode = true; 2189 send_params.conference_mode = true;
2138 } 2190 }
2139 2191
2140 bool parameters_applied = media_channel()->SetSendParameters(send_params); 2192 bool parameters_applied = media_channel()->SetSendParameters(send_params);
2141 2193
2142 if (!parameters_applied) { 2194 if (!parameters_applied) {
2143 SafeSetError("Failed to set remote video description send parameters.", 2195 SafeSetError("Failed to set remote video description send parameters.",
2144 error_desc); 2196 error_desc);
2145 return false; 2197 return false;
2146 } 2198 }
2147 last_send_params_ = send_params; 2199 last_send_params_ = send_params;
2148 2200
2149 // TODO(pthatcher): Move remote streams into VideoRecvParameters, 2201 // TODO(pthatcher): Move remote streams into VideoRecvParameters,
2150 // and only give it to the media channel once we have a local 2202 // 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 2203 // description too (without a local description, we won't be able to
2152 // recv them anyway). 2204 // recv them anyway).
2153 if (!UpdateRemoteStreams_w(video->streams(), action, error_desc)) { 2205 if (!UpdateRemoteStreams_w(video->streams(), action, error_desc)) {
2154 SafeSetError("Failed to set remote video description streams.", error_desc); 2206 SafeSetError("Failed to set remote video description streams.", error_desc);
2155 return false; 2207 return false;
2156 } 2208 }
2157 2209
2158 if (video->rtp_header_extensions_set()) { 2210 if (video->rtp_header_extensions_set()) {
2159 MaybeCacheRtpAbsSendTimeHeaderExtension_w(video->rtp_header_extensions()); 2211 MaybeCacheRtpAbsSendTimeHeaderExtension_w(rtp_header_extensions);
2160 } 2212 }
2161 2213
2162 set_remote_content_direction(content->direction()); 2214 set_remote_content_direction(content->direction());
2163 UpdateMediaSendRecvState_w(); 2215 UpdateMediaSendRecvState_w();
2164 return true; 2216 return true;
2165 } 2217 }
2166 2218
2167 void VideoChannel::OnMessage(rtc::Message *pmsg) { 2219 void VideoChannel::OnMessage(rtc::Message *pmsg) {
2168 switch (pmsg->message_id) { 2220 switch (pmsg->message_id) {
2169 case MSG_CHANNEL_ERROR: { 2221 case MSG_CHANNEL_ERROR: {
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
2275 RTC_DCHECK(data != NULL); 2327 RTC_DCHECK(data != NULL);
2276 if (!data) { 2328 if (!data) {
2277 SafeSetError("Can't find data content in local description.", error_desc); 2329 SafeSetError("Can't find data content in local description.", error_desc);
2278 return false; 2330 return false;
2279 } 2331 }
2280 2332
2281 if (!CheckDataChannelTypeFromContent(data, error_desc)) { 2333 if (!CheckDataChannelTypeFromContent(data, error_desc)) {
2282 return false; 2334 return false;
2283 } 2335 }
2284 2336
2285 if (!SetRtpTransportParameters(content, action, CS_LOCAL, error_desc)) { 2337 RtpHeaderExtensions rtp_header_extensions =
2338 GetFilteredRtpHeaderExtensions(data->rtp_header_extensions());
2339
2340 if (!SetRtpTransportParameters(content, action, CS_LOCAL,
2341 rtp_header_extensions, error_desc)) {
2286 return false; 2342 return false;
2287 } 2343 }
2288 2344
2289 DataRecvParameters recv_params = last_recv_params_; 2345 DataRecvParameters recv_params = last_recv_params_;
2290 RtpParametersFromMediaDescription(data, &recv_params); 2346 RtpParametersFromMediaDescription(data, rtp_header_extensions, &recv_params);
2291 if (!media_channel()->SetRecvParameters(recv_params)) { 2347 if (!media_channel()->SetRecvParameters(recv_params)) {
2292 SafeSetError("Failed to set remote data description recv parameters.", 2348 SafeSetError("Failed to set remote data description recv parameters.",
2293 error_desc); 2349 error_desc);
2294 return false; 2350 return false;
2295 } 2351 }
2296 for (const DataCodec& codec : data->codecs()) { 2352 for (const DataCodec& codec : data->codecs()) {
2297 bundle_filter()->AddPayloadType(codec.id); 2353 bundle_filter()->AddPayloadType(codec.id);
2298 } 2354 }
2299 last_recv_params_ = recv_params; 2355 last_recv_params_ = recv_params;
2300 2356
(...skipping 28 matching lines...) Expand all
2329 // If the remote data doesn't have codecs and isn't an update, it 2385 // If the remote data doesn't have codecs and isn't an update, it
2330 // must be empty, so ignore it. 2386 // must be empty, so ignore it.
2331 if (!data->has_codecs() && action != CA_UPDATE) { 2387 if (!data->has_codecs() && action != CA_UPDATE) {
2332 return true; 2388 return true;
2333 } 2389 }
2334 2390
2335 if (!CheckDataChannelTypeFromContent(data, error_desc)) { 2391 if (!CheckDataChannelTypeFromContent(data, error_desc)) {
2336 return false; 2392 return false;
2337 } 2393 }
2338 2394
2395 RtpHeaderExtensions rtp_header_extensions =
2396 GetFilteredRtpHeaderExtensions(data->rtp_header_extensions());
2397
2339 LOG(LS_INFO) << "Setting remote data description"; 2398 LOG(LS_INFO) << "Setting remote data description";
2340 if (!SetRtpTransportParameters(content, action, CS_REMOTE, error_desc)) { 2399 if (!SetRtpTransportParameters(content, action, CS_REMOTE,
2400 rtp_header_extensions, error_desc)) {
2341 return false; 2401 return false;
2342 } 2402 }
2343 2403
2344 DataSendParameters send_params = last_send_params_; 2404 DataSendParameters send_params = last_send_params_;
2345 RtpSendParametersFromMediaDescription<DataCodec>(data, &send_params); 2405 RtpSendParametersFromMediaDescription<DataCodec>(data, rtp_header_extensions,
2406 &send_params);
2346 if (!media_channel()->SetSendParameters(send_params)) { 2407 if (!media_channel()->SetSendParameters(send_params)) {
2347 SafeSetError("Failed to set remote data description send parameters.", 2408 SafeSetError("Failed to set remote data description send parameters.",
2348 error_desc); 2409 error_desc);
2349 return false; 2410 return false;
2350 } 2411 }
2351 last_send_params_ = send_params; 2412 last_send_params_ = send_params;
2352 2413
2353 // TODO(pthatcher): Move remote streams into DataRecvParameters, 2414 // TODO(pthatcher): Move remote streams into DataRecvParameters,
2354 // and only give it to the media channel once we have a local 2415 // 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 2416 // 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, 2526 signaling_thread()->Post(RTC_FROM_HERE, this, MSG_READYTOSENDDATA,
2466 new DataChannelReadyToSendMessageData(writable)); 2527 new DataChannelReadyToSendMessageData(writable));
2467 } 2528 }
2468 2529
2469 void RtpDataChannel::GetSrtpCryptoSuites_n( 2530 void RtpDataChannel::GetSrtpCryptoSuites_n(
2470 std::vector<int>* crypto_suites) const { 2531 std::vector<int>* crypto_suites) const {
2471 GetSupportedDataCryptoSuites(crypto_options(), crypto_suites); 2532 GetSupportedDataCryptoSuites(crypto_options(), crypto_suites);
2472 } 2533 }
2473 2534
2474 } // namespace cricket 2535 } // namespace cricket
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698