Index: webrtc/pc/srtptransport.h |
diff --git a/webrtc/pc/srtptransport.h b/webrtc/pc/srtptransport.h |
index be746d50c81aa4dbc4fcf322d2eacc0092d6b559..39cd254cbd5146f146a600f93044d5796ec65b5d 100644 |
--- a/webrtc/pc/srtptransport.h |
+++ b/webrtc/pc/srtptransport.h |
@@ -17,6 +17,7 @@ |
#include "webrtc/pc/rtptransportinternal.h" |
#include "webrtc/pc/srtpfilter.h" |
+#include "webrtc/pc/srtpsession.h" |
#include "webrtc/rtc_base/checks.h" |
namespace webrtc { |
@@ -65,6 +66,8 @@ class SrtpTransport : public RtpTransportInternal { |
return rtp_transport_->IsWritable(rtcp); |
} |
+ bool IsActive() const; |
Taylor Brandstetter
2017/08/23 22:13:30
Some comments for this method and the other new me
Zhi Huang
2017/08/24 23:38:07
Done.
|
+ |
bool SendPacket(bool rtcp, |
rtc::CopyOnWriteBuffer* packet, |
const rtc::PacketOptions& options, |
@@ -89,7 +92,55 @@ class SrtpTransport : public RtpTransportInternal { |
// TODO(zstein): Remove this when we remove RtpTransportAdapter. |
RtpTransportAdapter* GetInternal() override { return nullptr; } |
+ bool SetRtpParams(int send_cs, |
+ const uint8_t* send_key, |
+ int send_key_len, |
+ int recv_cs, |
+ const uint8_t* recv_key, |
+ int recv_key_len); |
+ |
+ bool SetRtcpParams(int send_cs, |
+ const uint8_t* send_key, |
+ int send_key_len, |
+ int recv_cs, |
+ const uint8_t* recv_key, |
+ int recv_key_len); |
+ |
+ bool UpdateRtpParams(int send_cs, |
+ const uint8_t* send_key, |
+ int send_key_len, |
+ int recv_cs, |
+ const uint8_t* recv_key, |
+ int recv_key_len); |
+ |
+ void ResetParams(); |
+ |
+ void SetEncryptedHeaderExtensionIds(cricket::ContentSource source, |
+ const std::vector<int>& extension_ids); |
+ |
+ // If external auth is enabled, SRTP will write a dummy auth tag that then |
+ // later must get replaced before the packet is sent out. Only supported for |
+ // non-GCM cipher suites and can be checked through "IsExternalAuthActive" |
+ // if it is actually used. This method is only valid before the RTP params |
+ // have been set. |
+ void EnableExternalAuth(); |
+ bool IsExternalAuthEnabled() const; |
+ |
+ // A SrtpTransport supports external creation of the auth tag if a non-GCM |
+ // cipher is used. This method is only valid after the RTP params have |
+ // been set. |
+ bool IsExternalAuthActive() const; |
+ |
+ // Returns srtp overhead for rtp packets. |
+ bool GetSrtpOverhead(int* srtp_overhead) const; |
+ |
+ void CacheRtpAbsSendTimeHeaderExtension(int rtp_abs_sendtime_extn_id) { |
+ rtp_abs_sendtime_extn_id_ = rtp_abs_sendtime_extn_id; |
+ } |
+ |
private: |
+ void CreateSrtpSessions(); |
+ |
void ConnectToRtpTransport(); |
void OnPacketReceived(bool rtcp, |
@@ -98,9 +149,38 @@ class SrtpTransport : public RtpTransportInternal { |
void OnReadyToSend(bool ready) { SignalReadyToSend(ready); } |
- const std::string content_name_; |
+ bool ProtectRtp(void* data, int in_len, int max_len, int* out_len); |
+ |
+ // Overloaded version, outputs packet index. |
+ bool ProtectRtp(void* data, |
+ int in_len, |
+ int max_len, |
+ int* out_len, |
+ int64_t* index); |
+ bool ProtectRtcp(void* data, int in_len, int max_len, int* out_len); |
+ |
+ // Decrypts/verifies an invidiual RTP/RTCP packet. |
+ // If an HMAC is used, this will decrease the packet size. |
+ bool UnprotectRtp(void* data, int in_len, int* out_len); |
+ bool UnprotectRtcp(void* data, int in_len, int* out_len); |
+ |
+ // Returns rtp auth params from srtp context. |
+ bool GetRtpAuthParams(uint8_t** key, int* key_len, int* tag_len); |
+ |
+ const std::string content_name_; |
std::unique_ptr<RtpTransportInternal> rtp_transport_; |
+ |
+ std::unique_ptr<cricket::SrtpSession> send_session_; |
+ std::unique_ptr<cricket::SrtpSession> recv_session_; |
+ std::unique_ptr<cricket::SrtpSession> send_rtcp_session_; |
+ std::unique_ptr<cricket::SrtpSession> recv_rtcp_session_; |
+ |
+ std::vector<int> send_encrypted_header_extension_ids_; |
+ std::vector<int> recv_encrypted_header_extension_ids_; |
+ bool external_auth_enabled_ = false; |
+ |
+ int rtp_abs_sendtime_extn_id_ = -1; |
}; |
} // namespace webrtc |