diff options
author | mannol <eniz_vukovic@hotmail.com> | 2015-04-17 19:19:58 +0200 |
---|---|---|
committer | mannol <eniz_vukovic@hotmail.com> | 2015-04-17 19:19:58 +0200 |
commit | d1fd3e36a6b58d4cd6b3e2a7ccbed7e1e5d2e2a3 (patch) | |
tree | 6ae0aacc5fba56fc356be615b6f459c95647d597 /toxav/rtp.c | |
parent | 969367b72aebaa2ecfc168cf2e86b20501298c20 (diff) | |
parent | f8087887feaf77577a345ae1be68776459613c03 (diff) |
Updated with upstream
Diffstat (limited to 'toxav/rtp.c')
-rw-r--r-- | toxav/rtp.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/toxav/rtp.c b/toxav/rtp.c index 665ebf86..e1e6dbac 100644 --- a/toxav/rtp.c +++ b/toxav/rtp.c | |||
@@ -25,6 +25,7 @@ | |||
25 | 25 | ||
26 | #include "../toxcore/logger.h" | 26 | #include "../toxcore/logger.h" |
27 | #include "../toxcore/util.h" | 27 | #include "../toxcore/util.h" |
28 | #include "../toxcore/Messenger.h" | ||
28 | 29 | ||
29 | #include "rtp.h" | 30 | #include "rtp.h" |
30 | #include <stdlib.h> | 31 | #include <stdlib.h> |
@@ -77,11 +78,9 @@ RTPMessage *msg_parse ( const uint8_t *data, int length ); | |||
77 | uint8_t *parse_header_out ( const RTPHeader* header, uint8_t* payload ); | 78 | uint8_t *parse_header_out ( const RTPHeader* header, uint8_t* payload ); |
78 | uint8_t *parse_ext_header_out ( const RTPExtHeader* header, uint8_t* payload ); | 79 | uint8_t *parse_ext_header_out ( const RTPExtHeader* header, uint8_t* payload ); |
79 | void build_header ( RTPSession* session, RTPHeader* header ); | 80 | void build_header ( RTPSession* session, RTPHeader* header ); |
80 | void send_rtcp_report ( RTCPSession* session, Messenger* m, int32_t friendnumber ); | 81 | void send_rtcp_report ( RTCPSession* session, Messenger* m, uint32_t friendnumber ); |
81 | int handle_rtp_packet ( Messenger *m, int32_t friendnumber, const uint8_t *data, uint32_t length, void *object ); | 82 | int handle_rtp_packet ( Messenger *m, uint32_t friendnumber, const uint8_t *data, uint16_t length, void *object ); |
82 | int handle_rtcp_packet ( Messenger *m, int32_t friendnumber, const uint8_t *data, uint32_t length, void *object ); | 83 | int handle_rtcp_packet ( Messenger *m, uint32_t friendnumber, const uint8_t *data, uint16_t length, void *object ); |
83 | |||
84 | |||
85 | 84 | ||
86 | 85 | ||
87 | RTPSession *rtp_new ( int payload_type, Messenger *messenger, int friend_num ) | 86 | RTPSession *rtp_new ( int payload_type, Messenger *messenger, int friend_num ) |
@@ -121,7 +120,7 @@ RTPSession *rtp_new ( int payload_type, Messenger *messenger, int friend_num ) | |||
121 | return NULL; | 120 | return NULL; |
122 | } | 121 | } |
123 | 122 | ||
124 | retu->rtcp_session->prefix = 222 + payload_type % 192; | 123 | retu->rtcp_session->prefix = payload_type + 2; |
125 | retu->rtcp_session->pl_stats = rb_new(4); | 124 | retu->rtcp_session->pl_stats = rb_new(4); |
126 | retu->rtcp_session->rtp_session = retu; | 125 | retu->rtcp_session->rtp_session = retu; |
127 | 126 | ||
@@ -201,15 +200,15 @@ int rtp_start_receiving(RTPSession* session) | |||
201 | if (session == NULL) | 200 | if (session == NULL) |
202 | return -1; | 201 | return -1; |
203 | 202 | ||
204 | if (custom_lossy_packet_registerhandler(session->m, session->dest, session->prefix, | 203 | if (m_callback_rtp_packet(session->m, session->dest, session->prefix, |
205 | handle_rtp_packet, session) == -1) { | 204 | handle_rtp_packet, session) == -1) { |
206 | LOGGER_WARNING("Failed to register rtp receive handler"); | 205 | LOGGER_WARNING("Failed to register rtp receive handler"); |
207 | return -1; | 206 | return -1; |
208 | } | 207 | } |
209 | if (custom_lossy_packet_registerhandler(session->m, session->dest, session->rtcp_session->prefix, | 208 | if (m_callback_rtp_packet(session->m, session->dest, session->rtcp_session->prefix, |
210 | handle_rtcp_packet, session->rtcp_session) == -1) { | 209 | handle_rtcp_packet, session->rtcp_session) == -1) { |
211 | LOGGER_WARNING("Failed to register rtcp receive handler"); | 210 | LOGGER_WARNING("Failed to register rtcp receive handler"); |
212 | custom_lossy_packet_registerhandler(session->m, session->dest, session->prefix, NULL, NULL); | 211 | m_callback_rtp_packet(session->m, session->dest, session->prefix, NULL, NULL); |
213 | return -1; | 212 | return -1; |
214 | } | 213 | } |
215 | 214 | ||
@@ -220,8 +219,8 @@ int rtp_stop_receiving(RTPSession* session) | |||
220 | if (session == NULL) | 219 | if (session == NULL) |
221 | return -1; | 220 | return -1; |
222 | 221 | ||
223 | custom_lossy_packet_registerhandler(session->m, session->dest, session->prefix, NULL, NULL); | 222 | m_callback_rtp_packet(session->m, session->dest, session->prefix, NULL, NULL); |
224 | custom_lossy_packet_registerhandler(session->m, session->dest, session->rtcp_session->prefix, NULL, NULL); /* RTCP */ | 223 | m_callback_rtp_packet(session->m, session->dest, session->rtcp_session->prefix, NULL, NULL); /* RTCP */ |
225 | 224 | ||
226 | return 0; | 225 | return 0; |
227 | } | 226 | } |
@@ -251,6 +250,7 @@ int rtp_send_msg ( RTPSession *session, const uint8_t *data, uint16_t length ) | |||
251 | 250 | ||
252 | memcpy ( it, data, length ); | 251 | memcpy ( it, data, length ); |
253 | 252 | ||
253 | |||
254 | if ( -1 == send_custom_lossy_packet(session->m, session->dest, parsed, parsed_len) ) { | 254 | if ( -1 == send_custom_lossy_packet(session->m, session->dest, parsed, parsed_len) ) { |
255 | LOGGER_WARNING("Failed to send full packet (len: %d)! std error: %s", length, strerror(errno)); | 255 | LOGGER_WARNING("Failed to send full packet (len: %d)! std error: %s", length, strerror(errno)); |
256 | return -1; | 256 | return -1; |
@@ -514,7 +514,7 @@ void build_header ( RTPSession *session, RTPHeader *header ) | |||
514 | 514 | ||
515 | header->length = 12 /* Minimum header len */ + ( session->cc * size_32 ); | 515 | header->length = 12 /* Minimum header len */ + ( session->cc * size_32 ); |
516 | } | 516 | } |
517 | void send_rtcp_report(RTCPSession* session, Messenger* m, int32_t friendnumber) | 517 | void send_rtcp_report(RTCPSession* session, Messenger* m, uint32_t friendnumber) |
518 | { | 518 | { |
519 | if (session->last_expected_packets == 0) | 519 | if (session->last_expected_packets == 0) |
520 | return; | 520 | return; |
@@ -538,7 +538,7 @@ void send_rtcp_report(RTCPSession* session, Messenger* m, int32_t friendnumber) | |||
538 | session->last_sent_report_ts = current_time_monotonic(); | 538 | session->last_sent_report_ts = current_time_monotonic(); |
539 | } | 539 | } |
540 | } | 540 | } |
541 | int handle_rtp_packet ( Messenger *m, int32_t friendnumber, const uint8_t *data, uint32_t length, void *object ) | 541 | int handle_rtp_packet ( Messenger* m, uint32_t friendnumber, const uint8_t* data, uint16_t length, void* object ) |
542 | { | 542 | { |
543 | RTPSession *session = object; | 543 | RTPSession *session = object; |
544 | RTPMessage *msg; | 544 | RTPMessage *msg; |
@@ -574,7 +574,7 @@ int handle_rtp_packet ( Messenger *m, int32_t friendnumber, const uint8_t *data, | |||
574 | queue_message(session, msg); | 574 | queue_message(session, msg); |
575 | return 0; | 575 | return 0; |
576 | } | 576 | } |
577 | int handle_rtcp_packet ( Messenger *m, int32_t friendnumber, const uint8_t *data, uint32_t length, void *object ) | 577 | int handle_rtcp_packet ( Messenger* m, uint32_t friendnumber, const uint8_t* data, uint16_t length, void* object ) |
578 | { | 578 | { |
579 | if (length < 9) | 579 | if (length < 9) |
580 | return -1; | 580 | return -1; |