diff options
author | mannol <eniz_vukovic@hotmail.com> | 2015-04-09 02:43:13 +0200 |
---|---|---|
committer | mannol <eniz_vukovic@hotmail.com> | 2015-04-09 02:43:13 +0200 |
commit | 4fa31d14cf53dd54b182508df31b5524b1f24cb6 (patch) | |
tree | 13b41abf8698f87307be2e6e8f7b78ce033af659 /toxav/toxav.c | |
parent | 9c003c9dd215d5f6bb2c1a0fbdc2c0f7fd9def7c (diff) |
Make it possible to decode mono audio with stereo decoder
Diffstat (limited to 'toxav/toxav.c')
-rw-r--r-- | toxav/toxav.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/toxav/toxav.c b/toxav/toxav.c index 0f16fde2..12f8b561 100644 --- a/toxav/toxav.c +++ b/toxav/toxav.c | |||
@@ -223,7 +223,7 @@ void toxav_iterate(ToxAV* av) | |||
223 | if (i->last_self_capabilities & msi_CapRAudio) /* Receiving audio */ | 223 | if (i->last_self_capabilities & msi_CapRAudio) /* Receiving audio */ |
224 | rc = MIN(i->cs->last_packet_frame_duration, rc); | 224 | rc = MIN(i->cs->last_packet_frame_duration, rc); |
225 | if (i->last_self_capabilities & msi_CapRVideo) /* Receiving video */ | 225 | if (i->last_self_capabilities & msi_CapRVideo) /* Receiving video */ |
226 | rc = MIN(i->cs->lcfd, rc); | 226 | rc = MIN(i->cs->lcfd, rc); /* TODO handle on/off */ |
227 | 227 | ||
228 | uint32_t fid = i->friend_id; | 228 | uint32_t fid = i->friend_id; |
229 | 229 | ||
@@ -712,9 +712,11 @@ bool toxav_send_audio_frame(ToxAV* av, uint32_t friend_number, const int16_t* pc | |||
712 | goto END; | 712 | goto END; |
713 | } | 713 | } |
714 | 714 | ||
715 | LOGGER_DEBUG("Sending audio frame size: %d; channels: %d; srate: %d", sample_count, channels, sampling_rate); | 715 | uint8_t dest[sample_count * channels + sizeof(sampling_rate)]; /* This is more than enough always */ |
716 | uint8_t dest[sample_count * channels * sizeof(int16_t)]; | 716 | |
717 | int vrc = opus_encode(call->cs->audio_encoder, pcm, sample_count, dest, sizeof (dest)); | 717 | sampling_rate = htonl(sampling_rate); |
718 | memcpy(dest, &sampling_rate, sizeof(sampling_rate)); | ||
719 | int vrc = opus_encode(call->cs->audio_encoder, pcm, sample_count, dest + sizeof(sampling_rate), sizeof(dest) - sizeof(sampling_rate)); | ||
718 | 720 | ||
719 | if (vrc < 0) { | 721 | if (vrc < 0) { |
720 | LOGGER_WARNING("Failed to encode frame"); | 722 | LOGGER_WARNING("Failed to encode frame"); |
@@ -723,7 +725,10 @@ bool toxav_send_audio_frame(ToxAV* av, uint32_t friend_number, const int16_t* pc | |||
723 | goto END; | 725 | goto END; |
724 | } | 726 | } |
725 | 727 | ||
726 | if (rtp_send_msg(call->rtps[audio_index], dest, vrc) != 0) { | 728 | LOGGER_DEBUG("Sending encoded audio frame size: %d; channels: %d; srate: %d", vrc, channels, |
729 | ntohl(sampling_rate)); | ||
730 | |||
731 | if (rtp_send_msg(call->rtps[audio_index], dest, vrc + sizeof(sampling_rate)) != 0) { | ||
727 | LOGGER_WARNING("Failed to send audio packet"); | 732 | LOGGER_WARNING("Failed to send audio packet"); |
728 | rc = TOXAV_ERR_SEND_FRAME_RTP_FAILED; | 733 | rc = TOXAV_ERR_SEND_FRAME_RTP_FAILED; |
729 | } | 734 | } |