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

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

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