diff options
author | mannol <eniz_vukovic@hotmail.com> | 2013-10-13 16:16:47 +0200 |
---|---|---|
committer | BtbN <btbn@btbn.de> | 2013-10-13 16:16:47 +0200 |
commit | da727875ac954b13ecb16521d255499511bb7424 (patch) | |
tree | 551904f3738612e9c15d98f320c323aa325a5cf8 /toxrtp/toxrtp_helper.h | |
parent | 1b971de651278429eea312f3240e1c5b8fbc67a4 (diff) |
tox A/V: RTP/MSI implementation
Diffstat (limited to 'toxrtp/toxrtp_helper.h')
-rw-r--r-- | toxrtp/toxrtp_helper.h | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/toxrtp/toxrtp_helper.h b/toxrtp/toxrtp_helper.h new file mode 100644 index 00000000..c9bcfcca --- /dev/null +++ b/toxrtp/toxrtp_helper.h | |||
@@ -0,0 +1,77 @@ | |||
1 | /* rtp_helper.h | ||
2 | * | ||
3 | * Has some standard functions. !Red! | ||
4 | * | ||
5 | * | ||
6 | * Copyright (C) 2013 Tox project All Rights Reserved. | ||
7 | * | ||
8 | * This file is part of Tox. | ||
9 | * | ||
10 | * Tox is free software: you can redistribute it and/or modify | ||
11 | * it under the terms of the GNU General Public License as published by | ||
12 | * the Free Software Foundation, either version 3 of the License, or | ||
13 | * (at your option) any later version. | ||
14 | * | ||
15 | * Tox is distributed in the hope that it will be useful, | ||
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
18 | * GNU General Public License for more details. | ||
19 | * | ||
20 | * You should have received a copy of the GNU General Public License | ||
21 | * along with Tox. If not, see <http://www.gnu.org/licenses/>. | ||
22 | * | ||
23 | */ | ||
24 | |||
25 | #ifndef _RTP__HELPER_H_ | ||
26 | #define _RTP__HELPER_H_ | ||
27 | |||
28 | #include <time.h> | ||
29 | #include <inttypes.h> | ||
30 | |||
31 | /* Current time, unix format */ | ||
32 | /*#define _time ((uint32_t)time(NULL))*/ | ||
33 | |||
34 | #define SUCCESS 0 | ||
35 | #define FAILURE -1 | ||
36 | |||
37 | #define _USE_ERRORS | ||
38 | |||
39 | #define RUN_IN_THREAD(_func, _thread_id, _arg_ptr) \ | ||
40 | if ( pthread_create ( &_thread_id, NULL, _func, _arg_ptr ) ) { \ | ||
41 | pthread_detach ( _thread_id ); \ | ||
42 | } | ||
43 | |||
44 | /* Core adaptation helper */ | ||
45 | int t_setipport ( const char* _ip, unsigned short _port, void* _cont ); | ||
46 | uint32_t t_random ( uint32_t _max ); | ||
47 | |||
48 | /* It's a bit faster than the memcpy it self and more optimized for using | ||
49 | * a uint8_t since memcpy has optimizations when copying "words" i.e. long type. | ||
50 | * Otherwise it just copies char's while we need only uint8_t | ||
51 | */ | ||
52 | void t_memcpy ( uint8_t* _dest, const uint8_t* _source, size_t _size ); | ||
53 | |||
54 | |||
55 | /* This is our memset. It's also a bit faster than the memset for it | ||
56 | * does not cast _dest to char* and uses faster loop algorithm. | ||
57 | */ | ||
58 | uint8_t* t_memset ( uint8_t* _dest, uint8_t _valu, size_t _size ); | ||
59 | |||
60 | /* Get null terminated len */ | ||
61 | size_t t_memlen ( const uint8_t* _valu ); | ||
62 | |||
63 | /* finds location of substring */ | ||
64 | size_t t_strfind ( const uint8_t* _str, const uint8_t* _substr ); | ||
65 | |||
66 | /* string alloc and copy ( ! must be null terminated ) */ | ||
67 | uint8_t* t_strallcpy ( const uint8_t* _source ); | ||
68 | |||
69 | /* Get current time in milliseconds */ | ||
70 | uint64_t t_time(); | ||
71 | |||
72 | |||
73 | #endif /* _RTP__HELPER_H_ */ | ||
74 | |||
75 | |||
76 | |||
77 | |||