/* * Copyright 2017 The WebRTC project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree.
*/
// This subclass of the RtpTransport is used for SRTP which is reponsible for // protecting/unprotecting the packets. It provides interfaces to set the crypto // parameters for the SrtpSession underneath. class SrtpTransport : public RtpTransport { public:
SrtpTransport(bool rtcp_mux_enabled, const FieldTrialsView& field_trials);
virtual ~SrtpTransport() = default;
bool SendRtpPacket(rtc::CopyOnWriteBuffer* packet, const rtc::PacketOptions& options, int flags) override;
bool SendRtcpPacket(rtc::CopyOnWriteBuffer* packet, const rtc::PacketOptions& options, int flags) override;
// The transport becomes active if the send_session_ and recv_session_ are // created. bool IsSrtpActive() const override;
bool IsWritable(bool rtcp) const override;
// Create new send/recv sessions and set the negotiated crypto keys for RTP // packet encryption. The keys can either come from SDES negotiation or DTLS // handshake. bool SetRtpParams(int send_crypto_suite, const rtc::ZeroOnFreeBuffer<uint8_t>& send_key, const std::vector<int>& send_extension_ids, int recv_crypto_suite, const rtc::ZeroOnFreeBuffer<uint8_t>& recv_key, const std::vector<int>& recv_extension_ids);
// Create new send/recv sessions and set the negotiated crypto keys for RTCP // packet encryption. The keys can either come from SDES negotiation or DTLS // handshake. bool SetRtcpParams(int send_crypto_suite, const rtc::ZeroOnFreeBuffer<uint8_t>& send_key, const std::vector<int>& send_extension_ids, int recv_crypto_suite, const rtc::ZeroOnFreeBuffer<uint8_t>& recv_key, const std::vector<int>& recv_extension_ids);
void ResetParams();
// 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 crypto 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;
// Cache RTP Absoulute SendTime extension header ID. This is only used when // external authentication is enabled. void CacheRtpAbsSendTimeHeaderExtension(int rtp_abs_sendtime_extn_id) {
rtp_abs_sendtime_extn_id_ = rtp_abs_sendtime_extn_id;
}
// In addition to unregistering the sink, the SRTP transport // disassociates all SSRCs of the sink from libSRTP. bool UnregisterRtpDemuxerSink(RtpPacketSinkInterface* sink) override;
protected: // If the writable state changed, fire the SignalWritableState. void MaybeUpdateWritableState();
// Override the RtpTransport::OnWritableState. void OnWritableState(rtc::PacketTransportInternal* packet_transport) override;
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);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.