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