Remove the SetEncryptedHeaderExtensionIds methods.
The existing methods SetEncrypedHeaderExtensionIds in SrtpTransport and SrtpSession
are removed because those methods could be confusing. When these methods are called
the head extension IDs are not actually updated and the user need to call SetRtpParams
again to make that happen. The existing setter just caches the new IDs.
To make it less confusing, the SetEncryptedHeaderExtensionIds is removed and the new
extension IDs will be set immediately when setting the crypto params.
For SDES, the crypto params and the header extension IDs will be set at the same time.
For DTLS, the new header extensions are cached in BaseChannel and will be set when
the DTLS handshake is completed.
Another major change is that when doing DTLS-SRTP, the encrypted header extension
IDs will be updated only when they are changed.
Bug: webrtc:7013
Change-Id: Ib70d4797456ae5ecb61b3dfff15c7e3e7ede89bd
Reviewed-on: https://webrtc-review.googlesource.com/15860
Commit-Queue: Zhi Huang <zhihuang@webrtc.org>
Reviewed-by: Peter Thatcher <pthatcher@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#20639}
diff --git a/pc/srtptransport.cc b/pc/srtptransport.cc
index b71276c..1343fd0 100644
--- a/pc/srtptransport.cc
+++ b/pc/srtptransport.cc
@@ -173,9 +173,11 @@
bool SrtpTransport::SetRtpParams(int send_cs,
const uint8_t* send_key,
int send_key_len,
+ const std::vector<int>& send_extension_ids,
int recv_cs,
const uint8_t* recv_key,
- int recv_key_len) {
+ int recv_key_len,
+ const std::vector<int>& recv_extension_ids) {
// If parameters are being set for the first time, we should create new SRTP
// sessions and call "SetSend/SetRecv". Otherwise we should call
// "UpdateSend"/"UpdateRecv" on the existing sessions, which will internally
@@ -186,21 +188,20 @@
CreateSrtpSessions();
new_sessions = true;
}
- send_session_->SetEncryptedHeaderExtensionIds(
- send_encrypted_header_extension_ids_);
bool ret = new_sessions
- ? send_session_->SetSend(send_cs, send_key, send_key_len)
- : send_session_->UpdateSend(send_cs, send_key, send_key_len);
+ ? send_session_->SetSend(send_cs, send_key, send_key_len,
+ send_extension_ids)
+ : send_session_->UpdateSend(send_cs, send_key, send_key_len,
+ send_extension_ids);
if (!ret) {
ResetParams();
return false;
}
- recv_session_->SetEncryptedHeaderExtensionIds(
- recv_encrypted_header_extension_ids_);
- ret = new_sessions
- ? recv_session_->SetRecv(recv_cs, recv_key, recv_key_len)
- : recv_session_->UpdateRecv(recv_cs, recv_key, recv_key_len);
+ ret = new_sessions ? recv_session_->SetRecv(recv_cs, recv_key, recv_key_len,
+ recv_extension_ids)
+ : recv_session_->UpdateRecv(
+ recv_cs, recv_key, recv_key_len, recv_extension_ids);
if (!ret) {
ResetParams();
return false;
@@ -216,9 +217,11 @@
bool SrtpTransport::SetRtcpParams(int send_cs,
const uint8_t* send_key,
int send_key_len,
+ const std::vector<int>& send_extension_ids,
int recv_cs,
const uint8_t* recv_key,
- int recv_key_len) {
+ int recv_key_len,
+ const std::vector<int>& recv_extension_ids) {
// This can only be called once, but can be safely called after
// SetRtpParams
if (send_rtcp_session_ || recv_rtcp_session_) {
@@ -227,12 +230,14 @@
}
send_rtcp_session_.reset(new cricket::SrtpSession());
- if (!send_rtcp_session_->SetSend(send_cs, send_key, send_key_len)) {
+ if (!send_rtcp_session_->SetSend(send_cs, send_key, send_key_len,
+ send_extension_ids)) {
return false;
}
recv_rtcp_session_.reset(new cricket::SrtpSession());
- if (!recv_rtcp_session_->SetRecv(recv_cs, recv_key, recv_key_len)) {
+ if (!recv_rtcp_session_->SetRecv(recv_cs, recv_key, recv_key_len,
+ recv_extension_ids)) {
return false;
}
@@ -255,16 +260,6 @@
RTC_LOG(LS_INFO) << "The params in SRTP transport are reset.";
}
-void SrtpTransport::SetEncryptedHeaderExtensionIds(
- cricket::ContentSource source,
- const std::vector<int>& extension_ids) {
- if (source == cricket::CS_LOCAL) {
- recv_encrypted_header_extension_ids_ = extension_ids;
- } else {
- send_encrypted_header_extension_ids_ = extension_ids;
- }
-}
-
void SrtpTransport::CreateSrtpSessions() {
send_session_.reset(new cricket::SrtpSession());
recv_session_.reset(new cricket::SrtpSession());