mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-04-14 00:00:44 +00:00
fix esf for g722
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@7491 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
7561a30544
commit
480df2636d
@ -63,7 +63,7 @@ SWITCH_STANDARD_APP(bcast_function)
|
|||||||
switch_status_t status;
|
switch_status_t status;
|
||||||
switch_size_t bytes;
|
switch_size_t bytes;
|
||||||
ls_control_packet_t control_packet;
|
ls_control_packet_t control_packet;
|
||||||
switch_codec_t *read_codec;
|
switch_codec_t codec = { 0}, *read_codec, *orig_codec = NULL;
|
||||||
uint32_t flags = 0;
|
uint32_t flags = 0;
|
||||||
const char *err;
|
const char *err;
|
||||||
switch_rtp_t *rtp_session = NULL;
|
switch_rtp_t *rtp_session = NULL;
|
||||||
@ -139,15 +139,32 @@ SWITCH_STANDARD_APP(bcast_function)
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (read_frame->packet && read_frame->packetlen) {
|
if (read_frame->packet && read_frame->packetlen && read_codec->implementation->ianacode == 0) {
|
||||||
ready = SEND_TYPE_RAW;
|
ready = SEND_TYPE_RAW;
|
||||||
} else {
|
} else {
|
||||||
ready = SEND_TYPE_RTP;
|
ready = SEND_TYPE_RTP;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ready == SEND_TYPE_RTP) {
|
if (ready == SEND_TYPE_RTP) {
|
||||||
|
if (read_codec->implementation->ianacode != 0) {
|
||||||
|
if (switch_core_codec_init(&codec,
|
||||||
|
"PCMU",
|
||||||
|
NULL,
|
||||||
|
8000,
|
||||||
|
20,
|
||||||
|
1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
|
||||||
|
NULL, switch_core_session_get_pool(session)) == SWITCH_STATUS_SUCCESS) {
|
||||||
|
orig_codec = read_codec;
|
||||||
|
read_codec = &codec;
|
||||||
|
switch_core_session_set_read_codec(session, read_codec);
|
||||||
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Codec Activation Success\n");
|
||||||
|
} else {
|
||||||
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Codec Activation Fail\n");
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
switch_find_local_ip(guess_ip, sizeof(guess_ip), AF_INET);
|
switch_find_local_ip(guess_ip, sizeof(guess_ip), AF_INET);
|
||||||
if (!(rtp_port = switch_rtp_request_port(guess_ip))) {
|
if (!(rtp_port = switch_rtp_request_port(guess_ip))) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "RTP Port Error\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "RTP Port Error\n");
|
||||||
@ -187,9 +204,14 @@ SWITCH_STANDARD_APP(bcast_function)
|
|||||||
bytes = 16;
|
bytes = 16;
|
||||||
switch_socket_sendto(socket, control_packet_addr, 0, (void *)&control_packet, &bytes);
|
switch_socket_sendto(socket, control_packet_addr, 0, (void *)&control_packet, &bytes);
|
||||||
|
|
||||||
|
int fd;
|
||||||
|
fd = open("/tmp/wtf.ulaw", O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR);
|
||||||
|
|
||||||
for(;;) {
|
for(;;) {
|
||||||
|
if (write(fd, read_frame->data, read_frame->datalen));
|
||||||
|
|
||||||
status = switch_core_session_read_frame(session, &read_frame, -1, 0);
|
status = switch_core_session_read_frame(session, &read_frame, -1, 0);
|
||||||
|
|
||||||
if (!SWITCH_READ_ACCEPTABLE(status)) {
|
if (!SWITCH_READ_ACCEPTABLE(status)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -215,6 +237,11 @@ SWITCH_STANDARD_APP(bcast_function)
|
|||||||
|
|
||||||
fail:
|
fail:
|
||||||
|
|
||||||
|
if (orig_codec) {
|
||||||
|
switch_core_session_set_read_codec(session, orig_codec);
|
||||||
|
switch_core_codec_destroy(&codec);
|
||||||
|
}
|
||||||
|
|
||||||
if (rtp_session && ready == SEND_TYPE_RTP && switch_rtp_ready(rtp_session)) {
|
if (rtp_session && ready == SEND_TYPE_RTP && switch_rtp_ready(rtp_session)) {
|
||||||
switch_rtp_destroy(&rtp_session);
|
switch_rtp_destroy(&rtp_session);
|
||||||
}
|
}
|
||||||
|
@ -241,23 +241,6 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(switch_core_sessi
|
|||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if 0
|
|
||||||
if (session->read_resampler) {
|
|
||||||
short *data = read_frame->data;
|
|
||||||
switch_mutex_lock(session->resample_mutex);
|
|
||||||
|
|
||||||
session->read_resampler->from_len = switch_short_to_float(data, session->read_resampler->from, (int) read_frame->datalen / 2);
|
|
||||||
session->read_resampler->to_len =
|
|
||||||
switch_resample_process(session->read_resampler, session->read_resampler->from,
|
|
||||||
session->read_resampler->from_len, session->read_resampler->to, session->read_resampler->to_size, 0);
|
|
||||||
switch_float_to_short(session->read_resampler->to, data, read_frame->datalen);
|
|
||||||
read_frame->samples = session->read_resampler->to_len;
|
|
||||||
read_frame->datalen = session->read_resampler->to_len * 2;
|
|
||||||
read_frame->rate = session->read_resampler->to_rate;
|
|
||||||
switch_mutex_unlock(session->resample_mutex);
|
|
||||||
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (session->bugs) {
|
if (session->bugs) {
|
||||||
switch_media_bug_t *bp, *dp, *last = NULL;
|
switch_media_bug_t *bp, *dp, *last = NULL;
|
||||||
@ -311,6 +294,23 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(switch_core_sessi
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (session->read_codec) {
|
if (session->read_codec) {
|
||||||
|
|
||||||
|
if (session->read_resampler) {
|
||||||
|
short *data = read_frame->data;
|
||||||
|
switch_mutex_lock(session->resample_mutex);
|
||||||
|
|
||||||
|
session->read_resampler->from_len = switch_short_to_float(data, session->read_resampler->from, (int) read_frame->datalen / 2);
|
||||||
|
session->read_resampler->to_len =
|
||||||
|
switch_resample_process(session->read_resampler, session->read_resampler->from,
|
||||||
|
session->read_resampler->from_len, session->read_resampler->to, session->read_resampler->to_size, 0);
|
||||||
|
switch_float_to_short(session->read_resampler->to, data, read_frame->datalen);
|
||||||
|
read_frame->samples = session->read_resampler->to_len;
|
||||||
|
read_frame->datalen = session->read_resampler->to_len * 2;
|
||||||
|
read_frame->rate = session->read_resampler->to_rate;
|
||||||
|
switch_mutex_unlock(session->resample_mutex);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
if ((*frame)->datalen == session->read_codec->implementation->bytes_per_frame) {
|
if ((*frame)->datalen == session->read_codec->implementation->bytes_per_frame) {
|
||||||
perfect = TRUE;
|
perfect = TRUE;
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user