diff options
author | mannol <eniz_vukovic@hotmail.com> | 2014-01-25 01:32:33 +0100 |
---|---|---|
committer | mannol <eniz_vukovic@hotmail.com> | 2014-01-25 01:32:33 +0100 |
commit | 65d320e31daa4709bb48b7f2a52c269dde0927e9 (patch) | |
tree | 45081a96be413d850a837d6afcee19fcfbfe7aca /toxrtp/toxrtp.h | |
parent | 51d8c41390be853a13693476802a834daf8d156a (diff) |
Done with encryption and core adaptations.
Diffstat (limited to 'toxrtp/toxrtp.h')
-rw-r--r-- | toxrtp/toxrtp.h | 188 |
1 files changed, 0 insertions, 188 deletions
diff --git a/toxrtp/toxrtp.h b/toxrtp/toxrtp.h deleted file mode 100644 index 0aa89993..00000000 --- a/toxrtp/toxrtp.h +++ /dev/null | |||
@@ -1,188 +0,0 @@ | |||
1 | /* rtp_impl.h | ||
2 | * | ||
3 | * Rtp implementation includes rtp_session_s struct which is a session identifier. | ||
4 | * It contains session information and it's a must for every session. | ||
5 | * It's best if you don't touch any variable directly but use callbacks to do so. !Red! | ||
6 | * | ||
7 | * | ||
8 | * Copyright (C) 2013 Tox project All Rights Reserved. | ||
9 | * | ||
10 | * This file is part of Tox. | ||
11 | * | ||
12 | * Tox is free software: you can redistribute it and/or modify | ||
13 | * it under the terms of the GNU General Public License as published by | ||
14 | * the Free Software Foundation, either version 3 of the License, or | ||
15 | * (at your option) any later version. | ||
16 | * | ||
17 | * Tox is distributed in the hope that it will be useful, | ||
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
20 | * GNU General Public License for more details. | ||
21 | * | ||
22 | * You should have received a copy of the GNU General Public License | ||
23 | * along with Tox. If not, see <http://www.gnu.org/licenses/>. | ||
24 | * | ||
25 | */ | ||
26 | |||
27 | |||
28 | #ifndef _RTP__IMPL_H_ | ||
29 | #define _RTP__IMPL_H_ | ||
30 | |||
31 | #define RTP_VERSION 2 | ||
32 | #include <inttypes.h> | ||
33 | #include "tox.h" | ||
34 | #include <pthread.h> | ||
35 | /* Extension header flags */ | ||
36 | #define RTP_EXT_TYPE_RESOLUTION 0x01 | ||
37 | #define RTP_EXT_TYPE_FRAMERATE 0x02 | ||
38 | |||
39 | /* Some defines */ | ||
40 | |||
41 | #define RTP_PACKET 70 | ||
42 | |||
43 | /* Payload identifiers */ | ||
44 | |||
45 | /* Audio */ | ||
46 | #define _PAYLOAD_OPUS 96 | ||
47 | |||
48 | /* Video */ | ||
49 | #define _PAYLOAD_VP8 106 | ||
50 | |||
51 | /* End of Payload identifiers */ | ||
52 | |||
53 | /* End of defines */ | ||
54 | |||
55 | |||
56 | /* Our main session descriptor. | ||
57 | * It measures the session variables and controls | ||
58 | * the entire session. There are functions for manipulating | ||
59 | * the session so tend to use those instead of directly accessing | ||
60 | * session parameters. | ||
61 | */ | ||
62 | typedef struct rtp_session_s { | ||
63 | uint8_t _version; | ||
64 | uint8_t _padding; | ||
65 | uint8_t _extension; | ||
66 | uint8_t _cc; | ||
67 | uint8_t _marker; | ||
68 | uint8_t _payload_type; | ||
69 | uint16_t _sequence_number; /* Set when sending */ | ||
70 | uint16_t _last_sequence_number; /* Check when recving msg */ | ||
71 | uint32_t _initial_time; | ||
72 | uint32_t _time_elapsed; | ||
73 | uint32_t _current_timestamp; | ||
74 | uint32_t _ssrc; | ||
75 | uint32_t *_csrc; | ||
76 | |||
77 | |||
78 | /* If some additional data must be sent via message | ||
79 | * apply it here. Only by allocating this member you will be | ||
80 | * automatically placing it within a message. | ||
81 | */ | ||
82 | |||
83 | struct rtp_ext_header_s *_ext_header; | ||
84 | /* External header identifiers */ | ||
85 | int _exthdr_resolution; | ||
86 | int _exthdr_framerate; | ||
87 | |||
88 | int _max_users; /* -1 undefined */ | ||
89 | |||
90 | uint64_t _packets_sent; /* measure packets */ | ||
91 | uint64_t _packets_recv; | ||
92 | |||
93 | uint64_t _bytes_sent; | ||
94 | uint64_t _bytes_recv; | ||
95 | |||
96 | uint64_t _packet_loss; | ||
97 | |||
98 | const char *_last_error; | ||
99 | |||
100 | struct rtp_dest_list_s *_dest_list; | ||
101 | struct rtp_dest_list_s *_last_user; /* a tail for faster appending */ | ||
102 | |||
103 | struct rtp_msg_s *_oldest_msg; | ||
104 | struct rtp_msg_s *_last_msg; /* tail */ | ||
105 | |||
106 | uint16_t _prefix_length; | ||
107 | uint8_t *_prefix; | ||
108 | |||
109 | /* Specifies multiple session use. | ||
110 | * When using one session it uses default value ( -1 ) | ||
111 | * Otherwise it's set to 1 and rtp_register_msg () is required | ||
112 | */ | ||
113 | int _multi_session; | ||
114 | |||
115 | uint32_t _current_framerate; | ||
116 | |||
117 | pthread_mutex_t _mutex; | ||
118 | |||
119 | } rtp_session_t; | ||
120 | |||
121 | |||
122 | /* | ||
123 | * Now i don't believe we need to store this _from thing every time | ||
124 | * since we have csrc table but will leave it like this for a while | ||
125 | */ | ||
126 | |||
127 | |||
128 | void rtp_free_msg ( rtp_session_t *_session, struct rtp_msg_s *_msg ); | ||
129 | int rtp_release_session_recv ( rtp_session_t *_session ); | ||
130 | |||
131 | /* Functions handling receiving */ | ||
132 | struct rtp_msg_s *rtp_recv_msg ( rtp_session_t *_session ); | ||
133 | void rtp_store_msg ( rtp_session_t *_session, struct rtp_msg_s *_msg ); | ||
134 | |||
135 | /* | ||
136 | * rtp_msg_parse() stores headers separately from the payload data | ||
137 | * and so the _length variable is set accordingly | ||
138 | */ | ||
139 | struct rtp_msg_s *rtp_msg_parse ( rtp_session_t *_session, const uint8_t *_data, uint32_t _length ); | ||
140 | |||
141 | int rtp_check_late_message (rtp_session_t *_session, struct rtp_msg_s *_msg); | ||
142 | void rtp_register_msg ( rtp_session_t *_session, struct rtp_msg_s * ); | ||
143 | |||
144 | /* Functions handling sending */ | ||
145 | int rtp_send_msg ( rtp_session_t *_session, struct rtp_msg_s *_msg, void *_core_handler ); | ||
146 | |||
147 | /* | ||
148 | * rtp_msg_new() stores headers and payload data in one container ( _data ) | ||
149 | * and the _length is set accordingly. Returned message is used for sending only | ||
150 | * so there is not much use of the headers there | ||
151 | */ | ||
152 | struct rtp_msg_s *rtp_msg_new ( rtp_session_t *_session, const uint8_t *_data, uint32_t _length ); | ||
153 | |||
154 | |||
155 | /* Convenient functions for creating a header */ | ||
156 | struct rtp_header_s *rtp_build_header ( rtp_session_t *_session ); | ||
157 | |||
158 | /* Functions handling session control */ | ||
159 | |||
160 | /* Handling an rtp packet */ | ||
161 | /* int rtp_handlepacket(uint8_t * packet, uint32_t length, IP_Port source); */ | ||
162 | |||
163 | /* Session initiation and termination. | ||
164 | * Set _multi_session to -1 if not using multiple sessions | ||
165 | */ | ||
166 | rtp_session_t *rtp_init_session ( int _max_users, int _multi_session ); | ||
167 | int rtp_terminate_session ( rtp_session_t *_session ); | ||
168 | |||
169 | /* Adding receiver */ | ||
170 | int rtp_add_receiver ( rtp_session_t *_session, tox_IP_Port *_dest ); | ||
171 | |||
172 | /* Convenient functions for marking the resolution */ | ||
173 | int rtp_add_resolution_marking ( rtp_session_t *_session, uint16_t _width, uint16_t _height ); | ||
174 | int rtp_remove_resolution_marking ( rtp_session_t *_session ); | ||
175 | uint16_t rtp_get_resolution_marking_height ( struct rtp_ext_header_s *_header, uint32_t _position ); | ||
176 | uint16_t rtp_get_resolution_marking_width ( struct rtp_ext_header_s *_header, uint32_t _position ); | ||
177 | |||
178 | int rtp_add_framerate_marking ( rtp_session_t *_session, uint32_t _value ); | ||
179 | int rtp_remove_framerate_marking ( rtp_session_t *_session ); | ||
180 | uint32_t rtp_get_framerate_marking ( struct rtp_ext_header_s *_header ); | ||
181 | /* Convenient functions for marking the payload */ | ||
182 | void rtp_set_payload_type ( rtp_session_t *_session, uint8_t _payload_value ); | ||
183 | uint32_t rtp_get_payload_type ( rtp_session_t *_session ); | ||
184 | |||
185 | /* When using RTP in core be sure to set prefix when sending via rtp_send_msg */ | ||
186 | int rtp_set_prefix ( rtp_session_t *_session, uint8_t *_prefix, uint16_t _prefix_length ); | ||
187 | |||
188 | #endif /* _RTP__IMPL_H_ */ | ||