summaryrefslogtreecommitdiff
path: root/toxav/codec.c
diff options
context:
space:
mode:
Diffstat (limited to 'toxav/codec.c')
-rw-r--r--toxav/codec.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/toxav/codec.c b/toxav/codec.c
index b0f2ed31..4ae5a10b 100644
--- a/toxav/codec.c
+++ b/toxav/codec.c
@@ -337,12 +337,14 @@ void cs_do(CSession *cs)
337 pthread_mutex_unlock(cs->queue_mutex); 337 pthread_mutex_unlock(cs->queue_mutex);
338 338
339 if (success == 2) { 339 if (success == 2) {
340 LOGGER_DEBUG("OPUS correction");
340 rc = opus_decode(cs->audio_decoder, NULL, 0, tmp, 341 rc = opus_decode(cs->audio_decoder, NULL, 0, tmp,
341 cs->last_packet_sampling_rate * cs->last_packet_frame_duration / 1000, 1); 342 (cs->last_packet_sampling_rate * cs->last_packet_frame_duration / 1000) *
343 cs->last_packet_channel_count, 1);
342 } else { 344 } else {
343 /* Get values from packet and decode. 345 /* Get values from packet and decode.
344 * It also checks for validity of an opus packet 346 * It also checks for validity of an opus packet
345 */ 347 */
346 rc = convert_bw_to_sampling_rate(opus_packet_get_bandwidth(msg->data)); 348 rc = convert_bw_to_sampling_rate(opus_packet_get_bandwidth(msg->data));
347 if (rc != -1) { 349 if (rc != -1) {
348 cs->last_packet_sampling_rate = rc; 350 cs->last_packet_sampling_rate = rc;
@@ -351,6 +353,9 @@ void cs_do(CSession *cs)
351 cs->last_packet_frame_duration = 353 cs->last_packet_frame_duration =
352 ( opus_packet_get_samples_per_frame(msg->data, cs->last_packet_sampling_rate) * 1000 ) 354 ( opus_packet_get_samples_per_frame(msg->data, cs->last_packet_sampling_rate) * 1000 )
353 / cs->last_packet_sampling_rate; 355 / cs->last_packet_sampling_rate;
356
357 /* TODO FIXME WARNING calculate properly according to propper channel count */
358 cs->last_packet_frame_duration /= cs->last_packet_channel_count;
354 } else { 359 } else {
355 LOGGER_WARNING("Failed to load packet values!"); 360 LOGGER_WARNING("Failed to load packet values!");
356 rtp_free_msg(NULL, msg); 361 rtp_free_msg(NULL, msg);
@@ -433,7 +438,7 @@ CSession *cs_new(uint32_t peer_video_frame_piece_size)
433 */ 438 */
434 439
435 int status; 440 int status;
436 cs->audio_decoder = opus_decoder_create(48000, 2, &status ); /* NOTE: Must be mono */ 441 cs->audio_decoder = opus_decoder_create(48000, 1, &status ); /* NOTE: Must be mono */
437 442
438 if ( status != OPUS_OK ) { 443 if ( status != OPUS_OK ) {
439 LOGGER_ERROR("Error while starting audio decoder: %s", opus_strerror(status)); 444 LOGGER_ERROR("Error while starting audio decoder: %s", opus_strerror(status));
@@ -472,6 +477,10 @@ CSession *cs_new(uint32_t peer_video_frame_piece_size)
472 vpx_codec_destroy(cs->v_decoder); 477 vpx_codec_destroy(cs->v_decoder);
473 goto AUDIO_DECODER_CLEANUP; 478 goto AUDIO_DECODER_CLEANUP;
474 } 479 }
480
481 if ( !(cs->split_video_frame = calloc(VIDEOFRAME_PIECE_SIZE + VIDEOFRAME_HEADER_SIZE, 1)) )
482 goto FAILURE;
483
475 /*++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ 484 /*++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
476 485
477 /* Initialize encoders with default values */ 486 /* Initialize encoders with default values */