mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-03-05 18:13:27 +00:00
fix frame size for encoder
This commit is contained in:
parent
64c10e04c1
commit
1f5e5abbed
@ -72,7 +72,8 @@ static opus_codec_settings_t default_codec_settings = {
|
|||||||
struct opus_context {
|
struct opus_context {
|
||||||
OpusEncoder *encoder_object;
|
OpusEncoder *encoder_object;
|
||||||
OpusDecoder *decoder_object;
|
OpusDecoder *decoder_object;
|
||||||
int frame_size;
|
uint32_t enc_frame_size;
|
||||||
|
uint32_t dec_frame_size;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
@ -237,7 +238,8 @@ static switch_status_t switch_opus_init(switch_codec_t *codec, switch_codec_flag
|
|||||||
return SWITCH_STATUS_FALSE;
|
return SWITCH_STATUS_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
context->frame_size = codec->implementation->samples_per_packet;
|
context->enc_frame_size = codec->implementation->actual_samples_per_second * (codec->implementation->microseconds_per_packet / 1000) / 1000;
|
||||||
|
|
||||||
|
|
||||||
memset(&codec_fmtp, '\0', sizeof(struct switch_codec_fmtp));
|
memset(&codec_fmtp, '\0', sizeof(struct switch_codec_fmtp));
|
||||||
codec_fmtp.private_info = &opus_codec_settings;
|
codec_fmtp.private_info = &opus_codec_settings;
|
||||||
@ -378,10 +380,7 @@ static switch_status_t switch_opus_encode(switch_codec_t *codec,
|
|||||||
return SWITCH_STATUS_FALSE;
|
return SWITCH_STATUS_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (len > 2880) len = 2880;
|
bytes = opus_encode(context->encoder_object, (void *) decoded_data, context->enc_frame_size, (unsigned char *) encoded_data, len);
|
||||||
|
|
||||||
bytes = opus_encode(context->encoder_object, (void *) decoded_data,
|
|
||||||
decoded_data_len / 2 / codec->implementation->number_of_channels, (unsigned char *) encoded_data, len);
|
|
||||||
|
|
||||||
if (bytes > 0) {
|
if (bytes > 0) {
|
||||||
*encoded_data_len = (uint32_t) bytes;
|
*encoded_data_len = (uint32_t) bytes;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user