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

Unified Diff: webrtc/pc/channel.cc

Issue 2761143002: Support encrypted RTP extensions (RFC 6904) (Closed)
Patch Set: Various changes based on feedback from Peter and Taylor. Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: webrtc/pc/channel.cc
diff --git a/webrtc/pc/channel.cc b/webrtc/pc/channel.cc
index ecc1c9a633c6d4a935a146f048483256ccdc5d49..09a4d8360a927c6189620d53dfae5f4150058fec 100644
--- a/webrtc/pc/channel.cc
+++ b/webrtc/pc/channel.cc
@@ -43,20 +43,6 @@ struct SendPacketMessageData : public rtc::MessageData {
rtc::PacketOptions options;
};
-#if defined(ENABLE_EXTERNAL_AUTH)
-// Returns the named header extension if found among all extensions,
-// nullptr otherwise.
-const webrtc::RtpExtension* FindHeaderExtension(
- const std::vector<webrtc::RtpExtension>& extensions,
- const std::string& uri) {
- for (const auto& extension : extensions) {
- if (extension.uri == uri)
- return &extension;
- }
- return nullptr;
-}
-#endif
-
} // namespace
enum {
@@ -1150,26 +1136,39 @@ bool BaseChannel::SetRtpTransportParameters(
const MediaContentDescription* content,
ContentAction action,
ContentSource src,
+ const RtpHeaderExtensions& extensions,
std::string* error_desc) {
if (action == CA_UPDATE) {
// These parameters never get changed by a CA_UDPATE.
return true;
}
+ RtpHeaderExtensions encrypted_extensions;
+ for (const webrtc::RtpExtension& extension : extensions) {
+ if (extension.encrypt) {
+ LOG(LS_INFO) << "Using " << src << " encrypted extension: "
Taylor Brandstetter 2017/03/23 20:10:56 nit: "src" will print as "0" or "1" (I believe), w
joachim 2017/03/30 22:43:49 Done.
+ << extension.ToString();
+ encrypted_extensions.push_back(extension);
+ }
+ }
+
// Cache srtp_required_ for belt and suspenders check on SendPacket
return network_thread_->Invoke<bool>(
RTC_FROM_HERE, Bind(&BaseChannel::SetRtpTransportParameters_n, this,
- content, action, src, error_desc));
+ content, action, src, encrypted_extensions,
+ error_desc));
}
bool BaseChannel::SetRtpTransportParameters_n(
const MediaContentDescription* content,
ContentAction action,
ContentSource src,
+ const RtpHeaderExtensions& encrypted_extensions,
std::string* error_desc) {
RTC_DCHECK(network_thread_->IsCurrent());
- if (!SetSrtp_n(content->cryptos(), action, src, error_desc)) {
+ if (!SetSrtp_n(content->cryptos(), action, src, encrypted_extensions,
+ error_desc)) {
return false;
}
@@ -1196,6 +1195,7 @@ bool BaseChannel::CheckSrtpConfig_n(const std::vector<CryptoParams>& cryptos,
bool BaseChannel::SetSrtp_n(const std::vector<CryptoParams>& cryptos,
ContentAction action,
ContentSource src,
+ const RtpHeaderExtensions& encrypted_extensions,
std::string* error_desc) {
TRACE_EVENT0("webrtc", "BaseChannel::SetSrtp_w");
if (action == CA_UPDATE) {
@@ -1208,6 +1208,7 @@ bool BaseChannel::SetSrtp_n(const std::vector<CryptoParams>& cryptos,
if (!ret) {
return false;
}
+ srtp_filter_.SetEncryptedHeaderExtensions(src, encrypted_extensions);
switch (action) {
case CA_OFFER:
// If DTLS is already active on the channel, we could be renegotiating
@@ -1470,7 +1471,8 @@ void BaseChannel::MaybeCacheRtpAbsSendTimeHeaderExtension_w(
// something that is not used.
#if defined(ENABLE_EXTERNAL_AUTH)
const webrtc::RtpExtension* send_time_extension =
- FindHeaderExtension(extensions, webrtc::RtpExtension::kAbsSendTimeUri);
+ webrtc::RtpExtension::FindHeaderExtensionByUri(
+ extensions, webrtc::RtpExtension::kAbsSendTimeUri);
int rtp_abs_sendtime_extn_id =
send_time_extension ? send_time_extension->id : -1;
invoker_.AsyncInvoke<void>(
@@ -1804,7 +1806,8 @@ bool VoiceChannel::SetLocalContent_w(const MediaContentDescription* content,
return false;
}
- if (!SetRtpTransportParameters(content, action, CS_LOCAL, error_desc)) {
+ if (!SetRtpTransportParameters(content, action, CS_LOCAL,
+ audio->rtp_header_extensions(), error_desc)) {
return false;
}
@@ -1849,7 +1852,8 @@ bool VoiceChannel::SetRemoteContent_w(const MediaContentDescription* content,
return false;
}
- if (!SetRtpTransportParameters(content, action, CS_REMOTE, error_desc)) {
+ if (!SetRtpTransportParameters(content, action, CS_REMOTE,
+ audio->rtp_header_extensions(), error_desc)) {
return false;
}
@@ -2082,7 +2086,8 @@ bool VideoChannel::SetLocalContent_w(const MediaContentDescription* content,
return false;
}
- if (!SetRtpTransportParameters(content, action, CS_LOCAL, error_desc)) {
+ if (!SetRtpTransportParameters(content, action, CS_LOCAL,
+ video->rtp_header_extensions(), error_desc)) {
return false;
}
@@ -2127,7 +2132,8 @@ bool VideoChannel::SetRemoteContent_w(const MediaContentDescription* content,
return false;
}
- if (!SetRtpTransportParameters(content, action, CS_REMOTE, error_desc)) {
+ if (!SetRtpTransportParameters(content, action, CS_REMOTE,
+ video->rtp_header_extensions(), error_desc)) {
return false;
}
@@ -2282,7 +2288,8 @@ bool RtpDataChannel::SetLocalContent_w(const MediaContentDescription* content,
return false;
}
- if (!SetRtpTransportParameters(content, action, CS_LOCAL, error_desc)) {
+ if (!SetRtpTransportParameters(content, action, CS_LOCAL,
+ data->rtp_header_extensions(), error_desc)) {
return false;
}
@@ -2337,7 +2344,8 @@ bool RtpDataChannel::SetRemoteContent_w(const MediaContentDescription* content,
}
LOG(LS_INFO) << "Setting remote data description";
- if (!SetRtpTransportParameters(content, action, CS_REMOTE, error_desc)) {
+ if (!SetRtpTransportParameters(content, action, CS_REMOTE,
+ data->rtp_header_extensions(), error_desc)) {
return false;
}

Powered by Google App Engine
This is Rietveld 408576698