diff options
author | mannol <eniz_vukovic@hotmail.com> | 2015-03-22 23:50:43 +0100 |
---|---|---|
committer | mannol <eniz_vukovic@hotmail.com> | 2015-03-22 23:50:43 +0100 |
commit | 62af82705a805648a4dba54a7f516681e5163923 (patch) | |
tree | f417e3489ed834de9df60cb7b4bbec625482638c /toxav/toxav.c | |
parent | a4fae8ffd49e298cd87e13be2496faf77e492bd9 (diff) |
Some progress
Diffstat (limited to 'toxav/toxav.c')
-rw-r--r-- | toxav/toxav.c | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/toxav/toxav.c b/toxav/toxav.c index 78243ae6..7cf8cec4 100644 --- a/toxav/toxav.c +++ b/toxav/toxav.c | |||
@@ -215,13 +215,6 @@ void toxav_iteration(ToxAV* av) | |||
215 | for (; i; i = i->next) { | 215 | for (; i; i = i->next) { |
216 | if (i->active) { | 216 | if (i->active) { |
217 | pthread_mutex_lock(i->mutex_decoding); | 217 | pthread_mutex_lock(i->mutex_decoding); |
218 | |||
219 | /* TODO make AV synchronisation */ | ||
220 | if (av->racb.first) | ||
221 | av->racb.first(av, i->friend_id, av->racb.second); | ||
222 | if (av->rvcb.first) | ||
223 | av->rvcb.first(av, i->friend_id, av->rvcb.second); | ||
224 | |||
225 | pthread_mutex_unlock(av->mutex); | 218 | pthread_mutex_unlock(av->mutex); |
226 | cs_do(i->cs); | 219 | cs_do(i->cs); |
227 | rc = MIN(i->cs->last_packet_frame_duration, rc); | 220 | rc = MIN(i->cs->last_packet_frame_duration, rc); |
@@ -304,6 +297,11 @@ bool toxav_answer(ToxAV* av, uint32_t friend_number, uint32_t audio_bit_rate, ui | |||
304 | goto END; | 297 | goto END; |
305 | } | 298 | } |
306 | 299 | ||
300 | if (!call_prepare_transmission(call)) { | ||
301 | rc = TOXAV_ERR_ANSWER_MALLOC; | ||
302 | goto END; | ||
303 | } | ||
304 | |||
307 | call->s_audio_b = audio_bit_rate; | 305 | call->s_audio_b = audio_bit_rate; |
308 | call->s_video_b = video_bit_rate; | 306 | call->s_video_b = video_bit_rate; |
309 | 307 | ||
@@ -645,7 +643,7 @@ bool toxav_send_audio_frame(ToxAV* av, uint32_t friend_number, const int16_t* pc | |||
645 | goto END; | 643 | goto END; |
646 | } | 644 | } |
647 | 645 | ||
648 | if ( channels != 1 || channels != 2 ) { | 646 | if ( channels != 1 && channels != 2 ) { |
649 | pthread_mutex_unlock(call->mutex_audio_sending); | 647 | pthread_mutex_unlock(call->mutex_audio_sending); |
650 | rc = TOXAV_ERR_SEND_FRAME_INVALID; | 648 | rc = TOXAV_ERR_SEND_FRAME_INVALID; |
651 | goto END; | 649 | goto END; |
@@ -666,8 +664,12 @@ bool toxav_send_audio_frame(ToxAV* av, uint32_t friend_number, const int16_t* pc | |||
666 | goto END; | 664 | goto END; |
667 | } | 665 | } |
668 | 666 | ||
669 | vrc = rtp_send_msg(call->rtps[audio_index], dest, vrc); | 667 | if (rtp_send_msg(call->rtps[audio_index], dest, vrc) != 0) { |
670 | /* TODO check for error? */ | 668 | LOGGER_WARNING("Failed to send audio packet"); |
669 | rc = TOXAV_ERR_SEND_FRAME_RTP_FAILED; | ||
670 | } | ||
671 | |||
672 | LOGGER_DEBUG("Sent packet of size: %d (o %d)", vrc, sample_count); | ||
671 | } | 673 | } |
672 | 674 | ||
673 | pthread_mutex_unlock(call->mutex_audio_sending); | 675 | pthread_mutex_unlock(call->mutex_audio_sending); |
@@ -965,7 +967,10 @@ bool call_prepare_transmission(ToxAVCall* call) | |||
965 | goto FAILURE; | 967 | goto FAILURE; |
966 | } | 968 | } |
967 | 969 | ||
968 | rtp_start_receiving(call->rtps[audio_index]); | 970 | if (rtp_start_receiving(call->rtps[audio_index]) != 0) { |
971 | LOGGER_WARNING("Failed to enable audio receiving!"); | ||
972 | goto FAILURE; | ||
973 | } | ||
969 | } | 974 | } |
970 | 975 | ||
971 | { /* Prepare video */ | 976 | { /* Prepare video */ |
@@ -984,13 +989,15 @@ bool call_prepare_transmission(ToxAVCall* call) | |||
984 | goto FAILURE; | 989 | goto FAILURE; |
985 | } | 990 | } |
986 | 991 | ||
987 | |||
988 | if (cs_enable_video_receiving(call->cs) != 0) { | 992 | if (cs_enable_video_receiving(call->cs) != 0) { |
989 | LOGGER_WARNING("Failed to enable video receiving!"); | 993 | LOGGER_WARNING("Failed to enable video receiving!"); |
990 | goto FAILURE; | 994 | goto FAILURE; |
991 | } | 995 | } |
992 | 996 | ||
993 | rtp_start_receiving(call->rtps[audio_index]); | 997 | if (rtp_start_receiving(call->rtps[video_index]) != 0) { |
998 | LOGGER_WARNING("Failed to enable audio receiving!"); | ||
999 | goto FAILURE; | ||
1000 | } | ||
994 | } | 1001 | } |
995 | 1002 | ||
996 | call->active = 1; | 1003 | call->active = 1; |