Chromium Code Reviews| Index: webrtc/pc/dtlssrtptransport.h |
| diff --git a/webrtc/pc/dtlssrtptransport.h b/webrtc/pc/dtlssrtptransport.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..7a2b788c1f8d302488bd71c1b9d86b9f98694d51 |
| --- /dev/null |
| +++ b/webrtc/pc/dtlssrtptransport.h |
| @@ -0,0 +1,109 @@ |
| +/* |
| + * 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. |
| + */ |
| + |
| +#ifndef WEBRTC_PC_DTLSSRTPTRANSPORT_H_ |
| +#define WEBRTC_PC_DTLSSRTPTRANSPORT_H_ |
| + |
| +#include <memory> |
| +#include <string> |
| +#include <vector> |
| + |
| +#include "webrtc/p2p/base/dtlstransportinternal.h" |
| +#include "webrtc/pc/srtptransport.h" |
| + |
| +namespace webrtc { |
| + |
| +// This class exports the keying materials from underneath DtlsTransport and |
|
pthatcher
2017/09/12 00:24:44
"from underneath DtlsTransport" => "from the DtlsT
Zhi Huang
2017/09/27 00:46:32
Done.
|
| +// sets the crypto keys for the wrapped SrtpTransport. |
| +class DtlsSrtpTransport : public RtpTransportInternal { |
| + public: |
| + DtlsSrtpTransport(std::unique_ptr<webrtc::SrtpTransport> srtp_transport, |
| + const std::string& content_name); |
|
pthatcher
2017/09/12 00:24:44
Why is the content name needed?
Zhi Huang
2017/09/27 00:46:32
Removed.
|
| + |
| + bool SetupDtlsSrtp(bool rtcp); |
|
pthatcher
2017/09/12 00:24:44
Note: this is the kind of place removing support f
Zhi Huang
2017/09/27 00:46:33
Acknowledged.
|
| + |
| + // Set a P2P layer DtlsTransport for DtlsSrtpTransport. |
| + void SetDtlsTransport(bool rtcp, |
| + cricket::DtlsTransportInternal* dtls_transport); |
|
pthatcher
2017/09/12 00:24:44
The getters have two methods. I think the setters
Zhi Huang
2017/09/27 00:46:32
Done.
|
| + |
| + // Set the header extension ids that should be encrypted for the given source. |
| + // This method doesn't immediately update the SRTP session with the new IDs, |
| + // and you need to call SetupDtlsSrtp for that to happen. |
| + void SetEncryptedHeaderExtensionIds(cricket::ContentSource source, |
| + const std::vector<int>& extension_ids); |
|
pthatcher
2017/09/12 00:24:44
Instead of passing in a source, I think it would b
Zhi Huang
2017/09/27 00:46:32
Agreed. The BaseChannel should take care of the Co
|
| + |
| + cricket::DtlsTransportInternal* rtp_dtls_transport() { |
| + return rtp_dtls_transport_; |
| + } |
| + |
| + cricket::DtlsTransportInternal* rtcp_dtls_transport() { |
| + return rtcp_dtls_transport_; |
| + } |
| + |
| + // RtpTransportInternal overrides. |
| + void SetRtcpMuxEnabled(bool enable) override; |
| + |
| + rtc::PacketTransportInternal* rtp_packet_transport() const override; |
| + |
| + void SetRtpPacketTransport(rtc::PacketTransportInternal* rtp) override; |
| + |
| + PacketTransportInterface* GetRtpPacketTransport() const override; |
| + |
| + rtc::PacketTransportInternal* rtcp_packet_transport() const override; |
| + |
| + void SetRtcpPacketTransport(rtc::PacketTransportInternal* rtcp) override; |
| + |
| + PacketTransportInterface* GetRtcpPacketTransport() const override; |
| + |
| + bool IsWritable(bool rtcp) const override; |
| + |
| + bool SendRtpPacket(rtc::CopyOnWriteBuffer* packet, |
| + const rtc::PacketOptions& options, |
| + int flags) override; |
| + |
| + bool SendRtcpPacket(rtc::CopyOnWriteBuffer* packet, |
| + const rtc::PacketOptions& options, |
| + int flags) override; |
| + |
| + bool HandlesPayloadType(int payload_type) const override; |
| + |
| + void AddHandledPayloadType(int payload_type) override; |
| + |
| + bool IsActive() { return active_; } |
| + |
| + void ResetParams(); |
| + |
| + RTCError SetParameters(const RtpTransportParameters& parameters) override; |
| + |
| + RtpTransportParameters GetParameters() const override; |
| + |
| + // TODO(zhihuang): Remove this when we remove RtpTransportAdapter. |
| + RtpTransportAdapter* GetInternal() override { return nullptr; } |
| + |
| + private: |
| + void ConnectToSrtpTransport(); |
| + |
| + void OnPacketReceived(bool rtcp, |
| + rtc::CopyOnWriteBuffer* packet, |
| + const rtc::PacketTime& packet_time); |
| + |
| + void OnReadyToSend(bool ready); |
| + |
| + bool active_ = false; |
|
pthatcher
2017/09/12 00:24:44
Can you leave a comment explaining when it becomes
Zhi Huang
2017/09/27 00:46:32
Done.
|
| + std::unique_ptr<SrtpTransport> srtp_transport_; |
| + std::string content_name_; |
| + // Not owned by this class. |
|
pthatcher
2017/09/12 00:24:44
Who has the responsibility of tracking the lifetim
Zhi Huang
2017/09/27 00:46:32
The transport controller should own these.
|
| + cricket::DtlsTransportInternal* rtp_dtls_transport_ = nullptr; |
| + cricket::DtlsTransportInternal* rtcp_dtls_transport_ = nullptr; |
| +}; |
| + |
| +} // namespace webrtc |
| + |
| +#endif // WEBRTC_PC_DTLSSRTPTRANSPORT_H_ |