media/webrtc/signaling/src/mediapipeline/SrtpFlow.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 2 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
michael@0 3 * You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 4
michael@0 5 // Original author: ekr@rtfm.com
michael@0 6
michael@0 7 #ifndef srtpflow_h__
michael@0 8 #define srtpflow_h__
michael@0 9
michael@0 10 #include "ssl.h"
michael@0 11 #include "sslproto.h"
michael@0 12 #include "mozilla/RefPtr.h"
michael@0 13 #include "nsISupportsImpl.h"
michael@0 14
michael@0 15 typedef struct srtp_policy_t srtp_policy_t;
michael@0 16 typedef struct srtp_ctx_t *srtp_t;
michael@0 17 typedef struct srtp_event_data_t srtp_event_data_t;
michael@0 18
michael@0 19 namespace mozilla {
michael@0 20
michael@0 21 #define SRTP_MASTER_KEY_LENGTH 16
michael@0 22 #define SRTP_MASTER_SALT_LENGTH 14
michael@0 23 #define SRTP_TOTAL_KEY_LENGTH (SRTP_MASTER_KEY_LENGTH + SRTP_MASTER_SALT_LENGTH)
michael@0 24
michael@0 25 // For some reason libsrtp increases packet size by > 12 for RTCP even though
michael@0 26 // the doc claims otherwise.
michael@0 27 #define SRTP_MAX_EXPANSION 20
michael@0 28
michael@0 29
michael@0 30 class SrtpFlow {
michael@0 31 public:
michael@0 32 ~SrtpFlow();
michael@0 33
michael@0 34
michael@0 35 static mozilla::RefPtr<SrtpFlow> Create(int cipher_suite,
michael@0 36 bool inbound,
michael@0 37 const void *key,
michael@0 38 size_t key_len);
michael@0 39
michael@0 40 nsresult ProtectRtp(void *in, int in_len,
michael@0 41 int max_len, int *out_len);
michael@0 42 nsresult UnprotectRtp(void *in, int in_len,
michael@0 43 int max_len, int *out_len);
michael@0 44 nsresult ProtectRtcp(void *in, int in_len,
michael@0 45 int max_len, int *out_len);
michael@0 46 nsresult UnprotectRtcp(void *in, int in_len,
michael@0 47 int max_len, int *out_len);
michael@0 48
michael@0 49 NS_INLINE_DECL_THREADSAFE_REFCOUNTING(SrtpFlow)
michael@0 50
michael@0 51 static void srtp_event_handler(srtp_event_data_t *data);
michael@0 52
michael@0 53
michael@0 54 private:
michael@0 55 SrtpFlow() : session_(nullptr) {}
michael@0 56
michael@0 57 nsresult CheckInputs(bool protect, void *in, int in_len,
michael@0 58 int max_len, int *out_len);
michael@0 59
michael@0 60 static nsresult Init();
michael@0 61 static bool initialized; // Was libsrtp initialized? Only happens once.
michael@0 62
michael@0 63 srtp_t session_;
michael@0 64 };
michael@0 65
michael@0 66 } // End of namespace
michael@0 67 #endif
michael@0 68

mercurial