diff options
author | iphydf <iphydf@users.noreply.github.com> | 2018-01-25 02:14:18 +0000 |
---|---|---|
committer | iphydf <iphydf@users.noreply.github.com> | 2018-01-25 09:42:01 +0000 |
commit | cd8080f6d180677d03edff4878305c655c29bd69 (patch) | |
tree | 9d569b151ed3ba8f547d24bb663243f9611b2ed8 | |
parent | a640ed106a74347e08c10e62d7ec9eee9e90e43b (diff) |
Rename some rtp header struct members to be clearer.
These are the names used in the next PR, in RTPHeaderV3, so here we
rename the old struct members already.
-rw-r--r-- | toxav/rtp.c | 32 | ||||
-rw-r--r-- | toxav/rtp.h | 8 |
2 files changed, 20 insertions, 20 deletions
diff --git a/toxav/rtp.c b/toxav/rtp.c index dc0bdefa..1e07516c 100644 --- a/toxav/rtp.c +++ b/toxav/rtp.c | |||
@@ -123,7 +123,7 @@ int rtp_send_data(RTPSession *session, const uint8_t *data, uint16_t length, Log | |||
123 | 123 | ||
124 | struct RTPHeader *header = (struct RTPHeader *)(rdata + 1); | 124 | struct RTPHeader *header = (struct RTPHeader *)(rdata + 1); |
125 | 125 | ||
126 | header->ve = 2; | 126 | header->protocol_version = 2; |
127 | header->pe = 0; | 127 | header->pe = 0; |
128 | header->xe = 0; | 128 | header->xe = 0; |
129 | header->cc = 0; | 129 | header->cc = 0; |
@@ -135,8 +135,8 @@ int rtp_send_data(RTPSession *session, const uint8_t *data, uint16_t length, Log | |||
135 | header->timestamp = net_htonl(current_time_monotonic()); | 135 | header->timestamp = net_htonl(current_time_monotonic()); |
136 | header->ssrc = net_htonl(session->ssrc); | 136 | header->ssrc = net_htonl(session->ssrc); |
137 | 137 | ||
138 | header->cpart = 0; | 138 | header->offset_lower = 0; |
139 | header->tlen = net_htons(length); | 139 | header->data_length_lower = net_htons(length); |
140 | 140 | ||
141 | if (MAX_CRYPTO_DATA_SIZE > length + sizeof(struct RTPHeader) + 1) { | 141 | if (MAX_CRYPTO_DATA_SIZE > length + sizeof(struct RTPHeader) + 1) { |
142 | 142 | ||
@@ -170,7 +170,7 @@ int rtp_send_data(RTPSession *session, const uint8_t *data, uint16_t length, Log | |||
170 | } | 170 | } |
171 | 171 | ||
172 | sent += piece; | 172 | sent += piece; |
173 | header->cpart = net_htons(sent); | 173 | header->offset_lower = net_htons(sent); |
174 | } | 174 | } |
175 | 175 | ||
176 | /* Send remaining */ | 176 | /* Send remaining */ |
@@ -228,8 +228,8 @@ static struct RTPMessage *new_message(size_t allocate_len, const uint8_t *data, | |||
228 | msg->header.timestamp = net_ntohl(msg->header.timestamp); | 228 | msg->header.timestamp = net_ntohl(msg->header.timestamp); |
229 | msg->header.ssrc = net_ntohl(msg->header.ssrc); | 229 | msg->header.ssrc = net_ntohl(msg->header.ssrc); |
230 | 230 | ||
231 | msg->header.cpart = net_ntohs(msg->header.cpart); | 231 | msg->header.offset_lower = net_ntohs(msg->header.offset_lower); |
232 | msg->header.tlen = net_ntohs(msg->header.tlen); | 232 | msg->header.data_length_lower = net_ntohs(msg->header.data_length_lower); |
233 | 233 | ||
234 | return msg; | 234 | return msg; |
235 | } | 235 | } |
@@ -255,14 +255,14 @@ int handle_rtp_packet(Messenger *m, uint32_t friendnumber, const uint8_t *data, | |||
255 | return -1; | 255 | return -1; |
256 | } | 256 | } |
257 | 257 | ||
258 | if (net_ntohs(header->cpart) >= net_ntohs(header->tlen)) { | 258 | if (net_ntohs(header->offset_lower) >= net_ntohs(header->data_length_lower)) { |
259 | /* Never allow this case to happen */ | 259 | /* Never allow this case to happen */ |
260 | return -1; | 260 | return -1; |
261 | } | 261 | } |
262 | 262 | ||
263 | bwc_feed_avg(session->bwc, length); | 263 | bwc_feed_avg(session->bwc, length); |
264 | 264 | ||
265 | if (net_ntohs(header->tlen) == length - sizeof(struct RTPHeader)) { | 265 | if (net_ntohs(header->data_length_lower) == length - sizeof(struct RTPHeader)) { |
266 | /* The message is sent in single part */ | 266 | /* The message is sent in single part */ |
267 | 267 | ||
268 | /* Only allow messages which have arrived in order; | 268 | /* Only allow messages which have arrived in order; |
@@ -316,22 +316,22 @@ int handle_rtp_packet(Messenger *m, uint32_t friendnumber, const uint8_t *data, | |||
316 | /* First case */ | 316 | /* First case */ |
317 | 317 | ||
318 | /* Make sure we have enough allocated memory */ | 318 | /* Make sure we have enough allocated memory */ |
319 | if (session->mp->header.tlen - session->mp->len < length - sizeof(struct RTPHeader) || | 319 | if (session->mp->header.data_length_lower - session->mp->len < length - sizeof(struct RTPHeader) || |
320 | session->mp->header.tlen <= net_ntohs(header->cpart)) { | 320 | session->mp->header.data_length_lower <= net_ntohs(header->offset_lower)) { |
321 | /* There happened to be some corruption on the stream; | 321 | /* There happened to be some corruption on the stream; |
322 | * continue wihtout this part | 322 | * continue wihtout this part |
323 | */ | 323 | */ |
324 | return 0; | 324 | return 0; |
325 | } | 325 | } |
326 | 326 | ||
327 | memcpy(session->mp->data + net_ntohs(header->cpart), data + sizeof(struct RTPHeader), | 327 | memcpy(session->mp->data + net_ntohs(header->offset_lower), data + sizeof(struct RTPHeader), |
328 | length - sizeof(struct RTPHeader)); | 328 | length - sizeof(struct RTPHeader)); |
329 | 329 | ||
330 | session->mp->len += length - sizeof(struct RTPHeader); | 330 | session->mp->len += length - sizeof(struct RTPHeader); |
331 | 331 | ||
332 | bwc_add_recv(session->bwc, length); | 332 | bwc_add_recv(session->bwc, length); |
333 | 333 | ||
334 | if (session->mp->len == session->mp->header.tlen) { | 334 | if (session->mp->len == session->mp->header.data_length_lower) { |
335 | /* Received a full message; now push it for the further | 335 | /* Received a full message; now push it for the further |
336 | * processing. | 336 | * processing. |
337 | */ | 337 | */ |
@@ -355,10 +355,10 @@ int handle_rtp_packet(Messenger *m, uint32_t friendnumber, const uint8_t *data, | |||
355 | 355 | ||
356 | /* Measure missing parts of the old message */ | 356 | /* Measure missing parts of the old message */ |
357 | bwc_add_lost(session->bwc, | 357 | bwc_add_lost(session->bwc, |
358 | (session->mp->header.tlen - session->mp->len) + | 358 | (session->mp->header.data_length_lower - session->mp->len) + |
359 | 359 | ||
360 | /* Must account sizes of rtp headers too */ | 360 | /* Must account sizes of rtp headers too */ |
361 | ((session->mp->header.tlen - session->mp->len) / | 361 | ((session->mp->header.data_length_lower - session->mp->len) / |
362 | MAX_CRYPTO_DATA_SIZE) * sizeof(struct RTPHeader)); | 362 | MAX_CRYPTO_DATA_SIZE) * sizeof(struct RTPHeader)); |
363 | 363 | ||
364 | /* Push the previous message for processing */ | 364 | /* Push the previous message for processing */ |
@@ -394,8 +394,8 @@ NEW_MULTIPARTED: | |||
394 | /* Again, only store message if handler is present | 394 | /* Again, only store message if handler is present |
395 | */ | 395 | */ |
396 | if (session->mcb) { | 396 | if (session->mcb) { |
397 | session->mp = new_message(net_ntohs(header->tlen) + sizeof(struct RTPHeader), data, length); | 397 | session->mp = new_message(net_ntohs(header->data_length_lower) + sizeof(struct RTPHeader), data, length); |
398 | memmove(session->mp->data + net_ntohs(header->cpart), session->mp->data, session->mp->len); | 398 | memmove(session->mp->data + net_ntohs(header->offset_lower), session->mp->data, session->mp->len); |
399 | } | 399 | } |
400 | } | 400 | } |
401 | 401 | ||
diff --git a/toxav/rtp.h b/toxav/rtp.h index 2f5ea84f..85da8fe1 100644 --- a/toxav/rtp.h +++ b/toxav/rtp.h | |||
@@ -41,12 +41,12 @@ struct RTPHeader { | |||
41 | uint16_t cc: 4; /* Contributing sources count */ | 41 | uint16_t cc: 4; /* Contributing sources count */ |
42 | uint16_t xe: 1; /* Extra header */ | 42 | uint16_t xe: 1; /* Extra header */ |
43 | uint16_t pe: 1; /* Padding */ | 43 | uint16_t pe: 1; /* Padding */ |
44 | uint16_t ve: 2; /* Version */ | 44 | uint16_t protocol_version: 2; /* Version has only 2 bits! */ |
45 | 45 | ||
46 | uint16_t pt: 7; /* Payload type */ | 46 | uint16_t pt: 7; /* Payload type */ |
47 | uint16_t ma: 1; /* Marker */ | 47 | uint16_t ma: 1; /* Marker */ |
48 | #else | 48 | #else |
49 | uint16_t ve: 2; /* Version */ | 49 | uint16_t protocol_version: 2; /* Version has only 2 bits! */ |
50 | uint16_t pe: 1; /* Padding */ | 50 | uint16_t pe: 1; /* Padding */ |
51 | uint16_t xe: 1; /* Extra header */ | 51 | uint16_t xe: 1; /* Extra header */ |
52 | uint16_t cc: 4; /* Contributing sources count */ | 52 | uint16_t cc: 4; /* Contributing sources count */ |
@@ -61,8 +61,8 @@ struct RTPHeader { | |||
61 | uint32_t csrc[16]; | 61 | uint32_t csrc[16]; |
62 | 62 | ||
63 | /* Non-standard TOX-specific fields */ | 63 | /* Non-standard TOX-specific fields */ |
64 | uint16_t cpart;/* Data offset of the current part */ | 64 | uint16_t offset_lower;/* Data offset of the current part */ |
65 | uint16_t tlen; /* Total message length */ | 65 | uint16_t data_length_lower; /* Total message length */ |
66 | } __attribute__((packed)); | 66 | } __attribute__((packed)); |
67 | 67 | ||
68 | /* Check alignment */ | 68 | /* Check alignment */ |