OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2009 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2009 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 |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 bool ProtectRtcp(void* data, int in_len, int max_len, int* out_len); | 113 bool ProtectRtcp(void* data, int in_len, int max_len, int* out_len); |
114 // Decrypts/verifies an invidiual RTP/RTCP packet. | 114 // Decrypts/verifies an invidiual RTP/RTCP packet. |
115 // If an HMAC is used, this will decrease the packet size. | 115 // If an HMAC is used, this will decrease the packet size. |
116 bool UnprotectRtp(void* data, int in_len, int* out_len); | 116 bool UnprotectRtp(void* data, int in_len, int* out_len); |
117 bool UnprotectRtcp(void* data, int in_len, int* out_len); | 117 bool UnprotectRtcp(void* data, int in_len, int* out_len); |
118 | 118 |
119 // Returns rtp auth params from srtp context. | 119 // Returns rtp auth params from srtp context. |
120 bool GetRtpAuthParams(uint8_t** key, int* key_len, int* tag_len); | 120 bool GetRtpAuthParams(uint8_t** key, int* key_len, int* tag_len); |
121 | 121 |
122 // Update the silent threshold (in ms) for signaling errors. | 122 // Update the silent threshold (in ms) for signaling errors. |
123 void set_signal_silent_time(uint32_t signal_silent_time_in_ms); | 123 void set_signal_silent_time(int signal_silent_time_in_ms); |
124 | 124 |
125 bool ResetParams(); | 125 bool ResetParams(); |
126 | 126 |
127 sigslot::repeater3<uint32_t, Mode, Error> SignalSrtpError; | 127 sigslot::repeater3<uint32_t, Mode, Error> SignalSrtpError; |
128 | 128 |
129 protected: | 129 protected: |
130 bool ExpectOffer(ContentSource source); | 130 bool ExpectOffer(ContentSource source); |
131 bool StoreParams(const std::vector<CryptoParams>& params, | 131 bool StoreParams(const std::vector<CryptoParams>& params, |
132 ContentSource source); | 132 ContentSource source); |
133 bool ExpectAnswer(ContentSource source); | 133 bool ExpectAnswer(ContentSource source); |
(...skipping 25 matching lines...) Expand all Loading... |
159 // SRTP filter is active but the sent answer is only provisional. | 159 // SRTP filter is active but the sent answer is only provisional. |
160 // When the final answer is set, the state transitions to ST_ACTIVE or | 160 // When the final answer is set, the state transitions to ST_ACTIVE or |
161 // ST_INIT. | 161 // ST_INIT. |
162 ST_SENTPRANSWER, | 162 ST_SENTPRANSWER, |
163 // SRTP filter is active but the received answer is only provisional. | 163 // SRTP filter is active but the received answer is only provisional. |
164 // When the final answer is set, the state transitions to ST_ACTIVE or | 164 // When the final answer is set, the state transitions to ST_ACTIVE or |
165 // ST_INIT. | 165 // ST_INIT. |
166 ST_RECEIVEDPRANSWER | 166 ST_RECEIVEDPRANSWER |
167 }; | 167 }; |
168 State state_; | 168 State state_; |
169 uint32_t signal_silent_time_in_ms_; | 169 int signal_silent_time_in_ms_; |
170 std::vector<CryptoParams> offer_params_; | 170 std::vector<CryptoParams> offer_params_; |
171 std::unique_ptr<SrtpSession> send_session_; | 171 std::unique_ptr<SrtpSession> send_session_; |
172 std::unique_ptr<SrtpSession> recv_session_; | 172 std::unique_ptr<SrtpSession> recv_session_; |
173 std::unique_ptr<SrtpSession> send_rtcp_session_; | 173 std::unique_ptr<SrtpSession> send_rtcp_session_; |
174 std::unique_ptr<SrtpSession> recv_rtcp_session_; | 174 std::unique_ptr<SrtpSession> recv_rtcp_session_; |
175 CryptoParams applied_send_params_; | 175 CryptoParams applied_send_params_; |
176 CryptoParams applied_recv_params_; | 176 CryptoParams applied_recv_params_; |
177 }; | 177 }; |
178 | 178 |
179 // Class that wraps a libSRTP session. | 179 // Class that wraps a libSRTP session. |
(...skipping 21 matching lines...) Expand all Loading... |
201 bool ProtectRtcp(void* data, int in_len, int max_len, int* out_len); | 201 bool ProtectRtcp(void* data, int in_len, int max_len, int* out_len); |
202 // Decrypts/verifies an invidiual RTP/RTCP packet. | 202 // Decrypts/verifies an invidiual RTP/RTCP packet. |
203 // If an HMAC is used, this will decrease the packet size. | 203 // If an HMAC is used, this will decrease the packet size. |
204 bool UnprotectRtp(void* data, int in_len, int* out_len); | 204 bool UnprotectRtp(void* data, int in_len, int* out_len); |
205 bool UnprotectRtcp(void* data, int in_len, int* out_len); | 205 bool UnprotectRtcp(void* data, int in_len, int* out_len); |
206 | 206 |
207 // Helper method to get authentication params. | 207 // Helper method to get authentication params. |
208 bool GetRtpAuthParams(uint8_t** key, int* key_len, int* tag_len); | 208 bool GetRtpAuthParams(uint8_t** key, int* key_len, int* tag_len); |
209 | 209 |
210 // Update the silent threshold (in ms) for signaling errors. | 210 // Update the silent threshold (in ms) for signaling errors. |
211 void set_signal_silent_time(uint32_t signal_silent_time_in_ms); | 211 void set_signal_silent_time(int signal_silent_time_in_ms); |
212 | 212 |
213 // Calls srtp_shutdown if it's initialized. | 213 // Calls srtp_shutdown if it's initialized. |
214 static void Terminate(); | 214 static void Terminate(); |
215 | 215 |
216 sigslot::repeater3<uint32_t, SrtpFilter::Mode, SrtpFilter::Error> | 216 sigslot::repeater3<uint32_t, SrtpFilter::Mode, SrtpFilter::Error> |
217 SignalSrtpError; | 217 SignalSrtpError; |
218 | 218 |
219 private: | 219 private: |
220 bool SetKey(int type, int cs, const uint8_t* key, int len); | 220 bool SetKey(int type, int cs, const uint8_t* key, int len); |
221 // Returns send stream current packet index from srtp db. | 221 // Returns send stream current packet index from srtp db. |
(...skipping 23 matching lines...) Expand all Loading... |
245 // Report RTP protection results to the handler. | 245 // Report RTP protection results to the handler. |
246 void AddProtectRtpResult(uint32_t ssrc, int result); | 246 void AddProtectRtpResult(uint32_t ssrc, int result); |
247 // Report RTP unprotection results to the handler. | 247 // Report RTP unprotection results to the handler. |
248 void AddUnprotectRtpResult(uint32_t ssrc, int result); | 248 void AddUnprotectRtpResult(uint32_t ssrc, int result); |
249 // Report RTCP protection results to the handler. | 249 // Report RTCP protection results to the handler. |
250 void AddProtectRtcpResult(int result); | 250 void AddProtectRtcpResult(int result); |
251 // Report RTCP unprotection results to the handler. | 251 // Report RTCP unprotection results to the handler. |
252 void AddUnprotectRtcpResult(int result); | 252 void AddUnprotectRtcpResult(int result); |
253 | 253 |
254 // Get silent time (in ms) for SRTP statistics handler. | 254 // Get silent time (in ms) for SRTP statistics handler. |
255 uint32_t signal_silent_time() const { return signal_silent_time_; } | 255 int signal_silent_time() const { return signal_silent_time_; } |
256 // Set silent time (in ms) for SRTP statistics handler. | 256 // Set silent time (in ms) for SRTP statistics handler. |
257 void set_signal_silent_time(uint32_t signal_silent_time) { | 257 void set_signal_silent_time(int signal_silent_time) { |
258 signal_silent_time_ = signal_silent_time; | 258 signal_silent_time_ = signal_silent_time; |
259 } | 259 } |
260 | 260 |
261 // Sigslot for reporting errors. | 261 // Sigslot for reporting errors. |
262 sigslot::signal3<uint32_t, SrtpFilter::Mode, SrtpFilter::Error> | 262 sigslot::signal3<uint32_t, SrtpFilter::Mode, SrtpFilter::Error> |
263 SignalSrtpError; | 263 SignalSrtpError; |
264 | 264 |
265 private: | 265 private: |
266 // For each different ssrc and error, we collect statistics separately. | 266 // For each different ssrc and error, we collect statistics separately. |
267 struct FailureKey { | 267 struct FailureKey { |
(...skipping 21 matching lines...) Expand all Loading... |
289 // other improvements, it will be easier. | 289 // other improvements, it will be easier. |
290 struct FailureStat { | 290 struct FailureStat { |
291 FailureStat() | 291 FailureStat() |
292 : last_signal_time(0) { | 292 : last_signal_time(0) { |
293 } | 293 } |
294 explicit FailureStat(uint32_t in_last_signal_time) | 294 explicit FailureStat(uint32_t in_last_signal_time) |
295 : last_signal_time(in_last_signal_time) {} | 295 : last_signal_time(in_last_signal_time) {} |
296 void Reset() { | 296 void Reset() { |
297 last_signal_time = 0; | 297 last_signal_time = 0; |
298 } | 298 } |
299 uint32_t last_signal_time; | 299 int64_t last_signal_time; |
300 }; | 300 }; |
301 | 301 |
302 // Inspect SRTP result and signal error if needed. | 302 // Inspect SRTP result and signal error if needed. |
303 void HandleSrtpResult(const FailureKey& key); | 303 void HandleSrtpResult(const FailureKey& key); |
304 | 304 |
305 std::map<FailureKey, FailureStat> failures_; | 305 std::map<FailureKey, FailureStat> failures_; |
306 // Threshold in ms to silent the signaling errors. | 306 // Threshold in ms to silent the signaling errors. |
307 uint32_t signal_silent_time_; | 307 int signal_silent_time_; |
308 | 308 |
309 RTC_DISALLOW_COPY_AND_ASSIGN(SrtpStat); | 309 RTC_DISALLOW_COPY_AND_ASSIGN(SrtpStat); |
310 }; | 310 }; |
311 | 311 |
312 } // namespace cricket | 312 } // namespace cricket |
313 | 313 |
314 #endif // WEBRTC_PC_SRTPFILTER_H_ | 314 #endif // WEBRTC_PC_SRTPFILTER_H_ |
OLD | NEW |