OLD | NEW |
---|---|
(Empty) | |
1 /* | |
2 * Copyright 2017 The WebRTC project authors. All Rights Reserved. | |
3 * | |
4 * Use of this source code is governed by a BSD-style license | |
5 * that can be found in the LICENSE file in the root of the source | |
6 * tree. An additional intellectual property rights grant can be found | |
7 * in the file PATENTS. All contributing project authors may | |
8 * be found in the AUTHORS file in the root of the source tree. | |
9 */ | |
10 | |
11 #ifndef PC_DTLSSRTPTRANSPORT_H_ | |
12 #define PC_DTLSSRTPTRANSPORT_H_ | |
13 | |
14 #include <memory> | |
15 #include <string> | |
16 #include <vector> | |
17 | |
18 #include "p2p/base/dtlstransportinternal.h" | |
19 #include "pc/srtptransport.h" | |
20 | |
21 namespace webrtc { | |
22 | |
23 // This class exports the keying materials from the DtlsTransport underneath and | |
24 // sets the crypto keys for the wrapped SrtpTransport. | |
25 class DtlsSrtpTransport : public RtpTransportInternal { | |
26 public: | |
27 explicit DtlsSrtpTransport( | |
28 std::unique_ptr<webrtc::SrtpTransport> srtp_transport); | |
29 | |
30 bool SetupDtlsSrtp(bool rtcp); | |
31 | |
32 // Set a P2P layer DtlsTransport for RTP DtlsSrtpTransport. | |
33 void SetRtpDtlsTransport(cricket::DtlsTransportInternal* dtls_transport) { | |
34 rtp_dtls_transport_ = dtls_transport; | |
35 } | |
36 | |
37 // Set a P2P layer DtlsTransport for RTCP DtlsSrtpTransport. | |
38 void SetRtcpDtlsTransport(cricket::DtlsTransportInternal* dtls_transport) { | |
39 rtcp_dtls_transport_ = dtls_transport; | |
40 } | |
41 // Set the header extension ids that should be encrypted. | |
42 // This method doesn't immediately update the SRTP session with the new IDs, | |
43 // and you need to call SetupDtlsSrtp for that to happen. | |
44 void SetSendEncryptedHeaderExtensionIds( | |
45 const std::vector<int>& send_extension_ids); | |
46 | |
47 void SetRecvEncryptedHeaderExtensionIds( | |
48 const std::vector<int>& recv_extension_ids); | |
49 | |
50 cricket::DtlsTransportInternal* rtp_dtls_transport() { | |
51 return rtp_dtls_transport_; | |
52 } | |
53 | |
54 cricket::DtlsTransportInternal* rtcp_dtls_transport() { | |
55 return rtcp_dtls_transport_; | |
56 } | |
57 | |
58 // RtpTransportInternal overrides. | |
59 void SetRtcpMuxEnabled(bool enable) override; | |
Taylor Brandstetter
2017/09/27 23:54:48
nit: I'd remove the newlines between all the overr
| |
60 | |
61 rtc::PacketTransportInternal* rtp_packet_transport() const override; | |
62 | |
63 void SetRtpPacketTransport(rtc::PacketTransportInternal* rtp) override; | |
64 | |
65 PacketTransportInterface* GetRtpPacketTransport() const override; | |
66 | |
67 rtc::PacketTransportInternal* rtcp_packet_transport() const override; | |
68 | |
69 void SetRtcpPacketTransport(rtc::PacketTransportInternal* rtcp) override; | |
70 | |
71 PacketTransportInterface* GetRtcpPacketTransport() const override; | |
72 | |
73 bool IsWritable(bool rtcp) const override; | |
74 | |
75 bool SendRtpPacket(rtc::CopyOnWriteBuffer* packet, | |
76 const rtc::PacketOptions& options, | |
77 int flags) override; | |
78 | |
79 bool SendRtcpPacket(rtc::CopyOnWriteBuffer* packet, | |
80 const rtc::PacketOptions& options, | |
81 int flags) override; | |
82 | |
83 bool HandlesPayloadType(int payload_type) const override; | |
84 | |
85 void AddHandledPayloadType(int payload_type) override; | |
86 | |
87 bool IsActive() { return active_; } | |
88 | |
89 void ResetParams(); | |
90 | |
91 RTCError SetParameters(const RtpTransportParameters& parameters) override; | |
92 | |
93 RtpTransportParameters GetParameters() const override; | |
94 | |
95 // TODO(zhihuang): Remove this when we remove RtpTransportAdapter. | |
96 RtpTransportAdapter* GetInternal() override { return nullptr; } | |
97 | |
98 private: | |
99 void ConnectToSrtpTransport(); | |
100 | |
101 void OnPacketReceived(bool rtcp, | |
102 rtc::CopyOnWriteBuffer* packet, | |
103 const rtc::PacketTime& packet_time); | |
104 | |
105 void OnReadyToSend(bool ready); | |
106 | |
107 // DtlsSrtpTransport become active after the DTLS-SRTP keys are installed. | |
108 bool active_ = false; | |
Taylor Brandstetter
2017/09/27 23:54:48
Is this ever different than srtp_transport_->IsAct
| |
109 std::unique_ptr<SrtpTransport> srtp_transport_; | |
110 // Owned by the TransportController. | |
111 cricket::DtlsTransportInternal* rtp_dtls_transport_ = nullptr; | |
112 cricket::DtlsTransportInternal* rtcp_dtls_transport_ = nullptr; | |
113 }; | |
114 | |
115 } // namespace webrtc | |
116 | |
117 #endif // PC_DTLSSRTPTRANSPORT_H_ | |
OLD | NEW |