Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(351)

Side by Side Diff: pc/srtptransport.h

Issue 3018513002: Revert of Completed the functionalities of SrtpTransport. (Closed)
Patch Set: Created 3 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « pc/srtpfilter_unittest.cc ('k') | pc/srtptransport.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2017 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2017 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 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 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 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #ifndef PC_SRTPTRANSPORT_H_ 11 #ifndef PC_SRTPTRANSPORT_H_
12 #define PC_SRTPTRANSPORT_H_ 12 #define PC_SRTPTRANSPORT_H_
13 13
14 #include <memory> 14 #include <memory>
15 #include <string> 15 #include <string>
16 #include <utility> 16 #include <utility>
17 17
18 #include "pc/rtptransportinternal.h" 18 #include "pc/rtptransportinternal.h"
19 #include "pc/srtpfilter.h" 19 #include "pc/srtpfilter.h"
20 #include "pc/srtpsession.h"
21 #include "rtc_base/checks.h" 20 #include "rtc_base/checks.h"
22 21
23 namespace webrtc { 22 namespace webrtc {
24 23
25 // This class will eventually be a wrapper around RtpTransportInternal 24 // This class will eventually be a wrapper around RtpTransportInternal
26 // that protects and unprotects sent and received RTP packets. 25 // that protects and unprotects sent and received RTP packets. This
26 // functionality is currently implemented by SrtpFilter and BaseChannel, but
27 // will be moved here in the future.
27 class SrtpTransport : public RtpTransportInternal { 28 class SrtpTransport : public RtpTransportInternal {
28 public: 29 public:
29 SrtpTransport(bool rtcp_mux_enabled, const std::string& content_name); 30 SrtpTransport(bool rtcp_mux_enabled, const std::string& content_name);
30 31
32 // TODO(zstein): Consider taking an RtpTransport instead of an
33 // RtpTransportInternal.
31 SrtpTransport(std::unique_ptr<RtpTransportInternal> transport, 34 SrtpTransport(std::unique_ptr<RtpTransportInternal> transport,
32 const std::string& content_name); 35 const std::string& content_name);
33 36
34 void SetRtcpMuxEnabled(bool enable) override { 37 void SetRtcpMuxEnabled(bool enable) override {
35 rtp_transport_->SetRtcpMuxEnabled(enable); 38 rtp_transport_->SetRtcpMuxEnabled(enable);
36 } 39 }
37 40
38 rtc::PacketTransportInternal* rtp_packet_transport() const override { 41 rtc::PacketTransportInternal* rtp_packet_transport() const override {
39 return rtp_transport_->rtp_packet_transport(); 42 return rtp_transport_->rtp_packet_transport();
40 } 43 }
(...skipping 10 matching lines...) Expand all
51 return rtp_transport_->rtcp_packet_transport(); 54 return rtp_transport_->rtcp_packet_transport();
52 } 55 }
53 void SetRtcpPacketTransport(rtc::PacketTransportInternal* rtcp) override { 56 void SetRtcpPacketTransport(rtc::PacketTransportInternal* rtcp) override {
54 rtp_transport_->SetRtcpPacketTransport(rtcp); 57 rtp_transport_->SetRtcpPacketTransport(rtcp);
55 } 58 }
56 59
57 PacketTransportInterface* GetRtcpPacketTransport() const override { 60 PacketTransportInterface* GetRtcpPacketTransport() const override {
58 return rtp_transport_->GetRtcpPacketTransport(); 61 return rtp_transport_->GetRtcpPacketTransport();
59 } 62 }
60 63
61 bool SendRtpPacket(rtc::CopyOnWriteBuffer* packet,
62 const rtc::PacketOptions& options,
63 int flags) override;
64
65 bool SendRtcpPacket(rtc::CopyOnWriteBuffer* packet,
66 const rtc::PacketOptions& options,
67 int flags) override;
68
69 bool IsWritable(bool rtcp) const override { 64 bool IsWritable(bool rtcp) const override {
70 return rtp_transport_->IsWritable(rtcp); 65 return rtp_transport_->IsWritable(rtcp);
71 } 66 }
72 67
73 // The transport becomes active if the send_session_ and recv_session_ are 68 bool SendPacket(bool rtcp,
74 // created. 69 rtc::CopyOnWriteBuffer* packet,
75 bool IsActive() const; 70 const rtc::PacketOptions& options,
71 int flags) override;
76 72
77 bool HandlesPayloadType(int payload_type) const override { 73 bool HandlesPayloadType(int payload_type) const override {
78 return rtp_transport_->HandlesPayloadType(payload_type); 74 return rtp_transport_->HandlesPayloadType(payload_type);
79 } 75 }
80 76
81 void AddHandledPayloadType(int payload_type) override { 77 void AddHandledPayloadType(int payload_type) override {
82 rtp_transport_->AddHandledPayloadType(payload_type); 78 rtp_transport_->AddHandledPayloadType(payload_type);
83 } 79 }
84 80
85 RTCError SetParameters(const RtpTransportParameters& parameters) override { 81 RTCError SetParameters(const RtpTransportParameters& parameters) override {
86 return rtp_transport_->SetParameters(parameters); 82 return rtp_transport_->SetParameters(parameters);
87 } 83 }
88 84
89 RtpTransportParameters GetParameters() const override { 85 RtpTransportParameters GetParameters() const override {
90 return rtp_transport_->GetParameters(); 86 return rtp_transport_->GetParameters();
91 } 87 }
92 88
93 // TODO(zstein): Remove this when we remove RtpTransportAdapter. 89 // TODO(zstein): Remove this when we remove RtpTransportAdapter.
94 RtpTransportAdapter* GetInternal() override { return nullptr; } 90 RtpTransportAdapter* GetInternal() override { return nullptr; }
95 91
96 // Create new send/recv sessions and set the negotiated crypto keys for RTP
97 // packet encryption. The keys can either come from SDES negotiation or DTLS
98 // handshake.
99 bool SetRtpParams(int send_cs,
100 const uint8_t* send_key,
101 int send_key_len,
102 int recv_cs,
103 const uint8_t* recv_key,
104 int recv_key_len);
105
106 // Create new send/recv sessions and set the negotiated crypto keys for RTCP
107 // packet encryption. The keys can either come from SDES negotiation or DTLS
108 // handshake.
109 bool SetRtcpParams(int send_cs,
110 const uint8_t* send_key,
111 int send_key_len,
112 int recv_cs,
113 const uint8_t* recv_key,
114 int recv_key_len);
115
116 void ResetParams();
117
118 // Set the header extension ids that should be encrypted for the given source.
119 // This method doesn't immediately update the SRTP session with the new IDs,
120 // and you need to call SetRtpParams for that to happen.
121 void SetEncryptedHeaderExtensionIds(cricket::ContentSource source,
122 const std::vector<int>& extension_ids);
123
124 // If external auth is enabled, SRTP will write a dummy auth tag that then
125 // later must get replaced before the packet is sent out. Only supported for
126 // non-GCM cipher suites and can be checked through "IsExternalAuthActive"
127 // if it is actually used. This method is only valid before the RTP params
128 // have been set.
129 void EnableExternalAuth();
130 bool IsExternalAuthEnabled() const;
131
132 // A SrtpTransport supports external creation of the auth tag if a non-GCM
133 // cipher is used. This method is only valid after the RTP params have
134 // been set.
135 bool IsExternalAuthActive() const;
136
137 // Returns srtp overhead for rtp packets.
138 bool GetSrtpOverhead(int* srtp_overhead) const;
139
140 // Returns rtp auth params from srtp context.
141 bool GetRtpAuthParams(uint8_t** key, int* key_len, int* tag_len);
142
143 // Helper method to get RTP Absoulute SendTime extension header id if
144 // present in remote supported extensions list.
145 void CacheRtpAbsSendTimeHeaderExtension(int rtp_abs_sendtime_extn_id) {
146 rtp_abs_sendtime_extn_id_ = rtp_abs_sendtime_extn_id;
147 }
148
149 private: 92 private:
150 void CreateSrtpSessions();
151
152 void ConnectToRtpTransport(); 93 void ConnectToRtpTransport();
153 94
154 bool SendPacket(bool rtcp,
155 rtc::CopyOnWriteBuffer* packet,
156 const rtc::PacketOptions& options,
157 int flags);
158
159 void OnPacketReceived(bool rtcp, 95 void OnPacketReceived(bool rtcp,
160 rtc::CopyOnWriteBuffer* packet, 96 rtc::CopyOnWriteBuffer* packet,
161 const rtc::PacketTime& packet_time); 97 const rtc::PacketTime& packet_time);
162 98
163 void OnReadyToSend(bool ready) { SignalReadyToSend(ready); } 99 void OnReadyToSend(bool ready) { SignalReadyToSend(ready); }
164 100
165 bool ProtectRtp(void* data, int in_len, int max_len, int* out_len); 101 const std::string content_name_;
166 102
167 // Overloaded version, outputs packet index.
168 bool ProtectRtp(void* data,
169 int in_len,
170 int max_len,
171 int* out_len,
172 int64_t* index);
173 bool ProtectRtcp(void* data, int in_len, int max_len, int* out_len);
174
175 // Decrypts/verifies an invidiual RTP/RTCP packet.
176 // If an HMAC is used, this will decrease the packet size.
177 bool UnprotectRtp(void* data, int in_len, int* out_len);
178
179 bool UnprotectRtcp(void* data, int in_len, int* out_len);
180
181 const std::string content_name_;
182 std::unique_ptr<RtpTransportInternal> rtp_transport_; 103 std::unique_ptr<RtpTransportInternal> rtp_transport_;
183
184 std::unique_ptr<cricket::SrtpSession> send_session_;
185 std::unique_ptr<cricket::SrtpSession> recv_session_;
186 std::unique_ptr<cricket::SrtpSession> send_rtcp_session_;
187 std::unique_ptr<cricket::SrtpSession> recv_rtcp_session_;
188
189 std::vector<int> send_encrypted_header_extension_ids_;
190 std::vector<int> recv_encrypted_header_extension_ids_;
191 bool external_auth_enabled_ = false;
192
193 int rtp_abs_sendtime_extn_id_ = -1;
194 }; 104 };
195 105
196 } // namespace webrtc 106 } // namespace webrtc
197 107
198 #endif // PC_SRTPTRANSPORT_H_ 108 #endif // PC_SRTPTRANSPORT_H_
OLDNEW
« no previous file with comments | « pc/srtpfilter_unittest.cc ('k') | pc/srtptransport.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698