summaryrefslogtreecommitdiff
path: root/toxav
diff options
context:
space:
mode:
Diffstat (limited to 'toxav')
-rw-r--r--toxav/msi.c20
-rw-r--r--toxav/rtp.c22
-rw-r--r--toxav/toxav.c8
3 files changed, 25 insertions, 25 deletions
diff --git a/toxav/msi.c b/toxav/msi.c
index 9695029a..ee7a95f3 100644
--- a/toxav/msi.c
+++ b/toxav/msi.c
@@ -1002,18 +1002,18 @@ int send_error ( MSISession *session, MSICall *call, MSICallError errid, uint32_
1002 */ 1002 */
1003void add_peer( MSICall *call, int peer_id ) 1003void add_peer( MSICall *call, int peer_id )
1004{ 1004{
1005 uint32_t* peers = !call->peers ? peers = calloc(sizeof(uint32_t), 1) : 1005 uint32_t *peers = !call->peers ? peers = calloc(sizeof(uint32_t), 1) :
1006 realloc( call->peers, sizeof(uint32_t) * call->peer_count); 1006 realloc( call->peers, sizeof(uint32_t) * call->peer_count);
1007 1007
1008 if (!peers) { 1008 if (!peers) {
1009 LOGGER_WARNING("Allocation failed! Program might misbehave!"); 1009 LOGGER_WARNING("Allocation failed! Program might misbehave!");
1010 return; 1010 return;
1011 } 1011 }
1012 1012
1013 call->peer_count ++; 1013 call->peer_count ++;
1014 call->peers = peers; 1014 call->peers = peers;
1015 call->peers[call->peer_count - 1] = peer_id; 1015 call->peers[call->peer_count - 1] = peer_id;
1016 1016
1017 LOGGER_DEBUG("Added peer: %d", peer_id); 1017 LOGGER_DEBUG("Added peer: %d", peer_id);
1018} 1018}
1019 1019
@@ -1038,12 +1038,12 @@ MSICall *init_call ( MSISession *session, int peers, int ringing_timeout )
1038 1038
1039 for (; _call_idx < session->max_calls; _call_idx ++) { 1039 for (; _call_idx < session->max_calls; _call_idx ++) {
1040 if ( !session->calls[_call_idx] ) { 1040 if ( !session->calls[_call_idx] ) {
1041 1041
1042 if (!(session->calls[_call_idx] = calloc ( sizeof ( MSICall ), 1 ))) { 1042 if (!(session->calls[_call_idx] = calloc ( sizeof ( MSICall ), 1 ))) {
1043 LOGGER_WARNING("Allocation failed! Program might misbehave!"); 1043 LOGGER_WARNING("Allocation failed! Program might misbehave!");
1044 return NULL; 1044 return NULL;
1045 } 1045 }
1046 1046
1047 break; 1047 break;
1048 } 1048 }
1049 } 1049 }
@@ -1455,7 +1455,7 @@ int handle_recv_error ( MSISession *session, MSICall *call, MSIMessage *msg )
1455 * 1455 *
1456 * 1456 *
1457 */ 1457 */
1458void msi_handle_packet ( Messenger *messenger, int source, uint8_t *data, uint16_t length, void *object ) 1458void msi_handle_packet ( Messenger *messenger, int source, const uint8_t *data, uint16_t length, void *object )
1459{ 1459{
1460 LOGGER_DEBUG("Got msi message"); 1460 LOGGER_DEBUG("Got msi message");
1461 /* Unused */ 1461 /* Unused */
@@ -1610,7 +1610,7 @@ MSISession *msi_init_session ( Messenger *messenger, int32_t max_calls )
1610 free(_retu); 1610 free(_retu);
1611 return NULL; 1611 return NULL;
1612 } 1612 }
1613 1613
1614 _retu->max_calls = max_calls; 1614 _retu->max_calls = max_calls;
1615 1615
1616 _retu->frequ = 10000; /* default value? */ 1616 _retu->frequ = 10000; /* default value? */
@@ -1663,8 +1663,6 @@ int msi_terminate_session ( MSISession *session )
1663 timer_terminate_session(session->timer_handler); 1663 timer_terminate_session(session->timer_handler);
1664 1664
1665 pthread_mutex_destroy(&session->mutex); 1665 pthread_mutex_destroy(&session->mutex);
1666
1667// timer_terminate_session();
1668 1666
1669 LOGGER_DEBUG("Terminated session: %p", session); 1667 LOGGER_DEBUG("Terminated session: %p", session);
1670 free ( session ); 1668 free ( session );
diff --git a/toxav/rtp.c b/toxav/rtp.c
index ca37bf47..9ba3b6a3 100644
--- a/toxav/rtp.c
+++ b/toxav/rtp.c
@@ -105,16 +105,16 @@ RTPHeader *extract_header ( const uint8_t *payload, int length )
105 } 105 }
106 106
107 RTPHeader *_retu = calloc(1, sizeof (RTPHeader)); 107 RTPHeader *_retu = calloc(1, sizeof (RTPHeader));
108 108
109 if ( !_retu ) { 109 if ( !_retu ) {
110 LOGGER_WARNING("Alloc failed! Program might misbehave!"); 110 LOGGER_WARNING("Alloc failed! Program might misbehave!");
111 return NULL; 111 return NULL;
112 } 112 }
113 113
114 bytes_to_U16(&_retu->sequnum, payload); 114 bytes_to_U16(&_retu->sequnum, payload);
115 115
116 const uint8_t *_it = payload + 2; 116 const uint8_t *_it = payload + 2;
117 117
118 _retu->flags = *_it; 118 _retu->flags = *_it;
119 ++_it; 119 ++_it;
120 120
@@ -178,7 +178,7 @@ RTPExtHeader *extract_ext_header ( const uint8_t *payload, uint16_t length )
178 const uint8_t *_it = payload; 178 const uint8_t *_it = payload;
179 179
180 RTPExtHeader *_retu = calloc(1, sizeof (RTPExtHeader)); 180 RTPExtHeader *_retu = calloc(1, sizeof (RTPExtHeader));
181 181
182 if ( !_retu ) { 182 if ( !_retu ) {
183 LOGGER_WARNING("Alloc failed! Program might misbehave!"); 183 LOGGER_WARNING("Alloc failed! Program might misbehave!");
184 return NULL; 184 return NULL;
@@ -290,7 +290,7 @@ uint8_t *add_ext_header ( RTPExtHeader *header, uint8_t *payload )
290RTPHeader *build_header ( RTPSession *session ) 290RTPHeader *build_header ( RTPSession *session )
291{ 291{
292 RTPHeader *_retu = calloc ( 1, sizeof (RTPHeader) ); 292 RTPHeader *_retu = calloc ( 1, sizeof (RTPHeader) );
293 293
294 if ( !_retu ) { 294 if ( !_retu ) {
295 LOGGER_WARNING("Alloc failed! Program might misbehave!"); 295 LOGGER_WARNING("Alloc failed! Program might misbehave!");
296 return NULL; 296 return NULL;
@@ -386,7 +386,7 @@ RTPMessage *msg_parse ( const uint8_t *data, int length )
386 * @retval -1 Error occurred. 386 * @retval -1 Error occurred.
387 * @retval 0 Success. 387 * @retval 0 Success.
388 */ 388 */
389int rtp_handle_packet ( void *object, uint8_t *data, uint32_t length ) 389int rtp_handle_packet ( void *object, const uint8_t *data, uint32_t length )
390{ 390{
391 RTPSession *_session = object; 391 RTPSession *_session = object;
392 RTPMessage *_msg; 392 RTPMessage *_msg;
@@ -451,7 +451,7 @@ RTPMessage *rtp_new_message ( RTPSession *session, const uint8_t *data, uint32_t
451 451
452 uint8_t *_from_pos; 452 uint8_t *_from_pos;
453 RTPMessage *_retu = calloc(1, sizeof (RTPMessage)); 453 RTPMessage *_retu = calloc(1, sizeof (RTPMessage));
454 454
455 if ( !_retu ) { 455 if ( !_retu ) {
456 LOGGER_WARNING("Alloc failed! Program might misbehave!"); 456 LOGGER_WARNING("Alloc failed! Program might misbehave!");
457 return NULL; 457 return NULL;
@@ -465,7 +465,7 @@ RTPMessage *rtp_new_message ( RTPSession *session, const uint8_t *data, uint32_t
465 uint32_t _total_length = length + _retu->header->length + 1; 465 uint32_t _total_length = length + _retu->header->length + 1;
466 466
467 _retu->data[0] = session->prefix; 467 _retu->data[0] = session->prefix;
468 468
469 if ( _retu->ext_header ) { 469 if ( _retu->ext_header ) {
470 _total_length += ( 4 /* Minimum ext header len */ + _retu->ext_header->length * size_32 ); 470 _total_length += ( 4 /* Minimum ext header len */ + _retu->ext_header->length * size_32 );
471 471
@@ -617,10 +617,10 @@ int rtp_send_msg ( RTPSession *session, Messenger *messenger, const uint8_t *dat
617 } 617 }
618 618
619 619
620 /* Set sequ number */ 620 /* Set sequ number */
621 session->sequnum = session->sequnum >= MAX_SEQU_NUM ? 0 : session->sequnum + 1; 621 session->sequnum = session->sequnum >= MAX_SEQU_NUM ? 0 : session->sequnum + 1;
622 rtp_free_msg ( session, msg ); 622 rtp_free_msg ( session, msg );
623 623
624 return 0; 624 return 0;
625} 625}
626 626
@@ -665,7 +665,7 @@ void rtp_free_msg ( RTPSession *session, RTPMessage *msg )
665RTPSession *rtp_init_session ( int payload_type, Messenger *messenger, int friend_num ) 665RTPSession *rtp_init_session ( int payload_type, Messenger *messenger, int friend_num )
666{ 666{
667 RTPSession *_retu = calloc(1, sizeof(RTPSession)); 667 RTPSession *_retu = calloc(1, sizeof(RTPSession));
668 668
669 if ( !_retu ) { 669 if ( !_retu ) {
670 LOGGER_WARNING("Alloc failed! Program might misbehave!"); 670 LOGGER_WARNING("Alloc failed! Program might misbehave!");
671 return NULL; 671 return NULL;
diff --git a/toxav/toxav.c b/toxav/toxav.c
index 02c5a970..743d7fcf 100644
--- a/toxav/toxav.c
+++ b/toxav/toxav.c
@@ -447,7 +447,7 @@ inline__ int toxav_send_rtp_payload ( ToxAv *av, int32_t call_index, ToxAvCallTy
447 /* number of pieces - 1*/ 447 /* number of pieces - 1*/
448 uint8_t numparts = (length - 1) / VIDEOFRAME_PIECE_SIZE; 448 uint8_t numparts = (length - 1) / VIDEOFRAME_PIECE_SIZE;
449 449
450 uint8_t load[3 + VIDEOFRAME_PIECE_SIZE]; 450 uint8_t load[2 + VIDEOFRAME_PIECE_SIZE];
451 load[0] = av->calls[call_index].frame_outid++; 451 load[0] = av->calls[call_index].frame_outid++;
452 load[1] = 0; 452 load[1] = 0;
453 453
@@ -569,11 +569,11 @@ inline__ int toxav_recv_video ( ToxAv *av, int32_t call_index, vpx_image_t **out
569 call->frame_limit = 0; 569 call->frame_limit = 0;
570 570
571 if (rc != VPX_CODEC_OK) { 571 if (rc != VPX_CODEC_OK) {
572 LOGGER_ERROR("Error decoding video: %s\n", vpx_codec_err_to_string(rc)); 572 LOGGER_ERROR("Error decoding video: %u %s\n", i, vpx_codec_err_to_string(rc));
573 return ErrorInternal;
574 } 573 }
575 } else { 574 } else {
576 /* old packet, dont read */ 575 /* old packet, dont read */
576 LOGGER_DEBUG("Old packet: %u\n", i);
577 continue; 577 continue;
578 } 578 }
579 579
@@ -583,12 +583,14 @@ inline__ int toxav_recv_video ( ToxAv *av, int32_t call_index, vpx_image_t **out
583 continue; 583 continue;
584 } 584 }
585 585
586 LOGGER_DEBUG("Video Packet: %u %u\n", packet[0], packet[1]);
586 memcpy(call->frame_buf + packet[1] * VIDEOFRAME_PIECE_SIZE, packet + VIDEOFRAME_HEADER_SIZE, 587 memcpy(call->frame_buf + packet[1] * VIDEOFRAME_PIECE_SIZE, packet + VIDEOFRAME_HEADER_SIZE,
587 recved_size - VIDEOFRAME_HEADER_SIZE); 588 recved_size - VIDEOFRAME_HEADER_SIZE);
588 uint32_t limit = packet[1] * VIDEOFRAME_PIECE_SIZE + recved_size - VIDEOFRAME_HEADER_SIZE; 589 uint32_t limit = packet[1] * VIDEOFRAME_PIECE_SIZE + recved_size - VIDEOFRAME_HEADER_SIZE;
589 590
590 if (limit > call->frame_limit) { 591 if (limit > call->frame_limit) {
591 call->frame_limit = limit; 592 call->frame_limit = limit;
593 LOGGER_DEBUG("Limit: %u\n", call->frame_limit);
592 } 594 }
593 } 595 }
594 596