mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-05-30 10:30:06 +00:00
updated
git-svn-id: http://svn.freeswitch.org/svn/local/src/freeswitch@18 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
b2ced66851
commit
f5497f6f2e
@ -41,6 +41,7 @@ extern "C" {
|
|||||||
#include <apr_general.h>
|
#include <apr_general.h>
|
||||||
#include <apr_thread_proc.h>
|
#include <apr_thread_proc.h>
|
||||||
#include <apr_thread_mutex.h>
|
#include <apr_thread_mutex.h>
|
||||||
|
#include <apr_thread_cond.h>
|
||||||
#include <apr_thread_rwlock.h>
|
#include <apr_thread_rwlock.h>
|
||||||
#include <apr_file_io.h>
|
#include <apr_file_io.h>
|
||||||
#include <apr_poll.h>
|
#include <apr_poll.h>
|
||||||
@ -49,7 +50,6 @@ extern "C" {
|
|||||||
#include <apr_strings.h>
|
#include <apr_strings.h>
|
||||||
#include <apr_network_io.h>
|
#include <apr_network_io.h>
|
||||||
#include <apr_poll.h>
|
#include <apr_poll.h>
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
//#include <time.h>
|
//#include <time.h>
|
||||||
|
@ -116,6 +116,7 @@ SWITCH_DECLARE(switch_status) switch_core_codec_destroy(switch_codec *codec);
|
|||||||
SWITCH_DECLARE(switch_status) switch_core_session_set_read_codec(switch_core_session *session, switch_codec *codec);
|
SWITCH_DECLARE(switch_status) switch_core_session_set_read_codec(switch_core_session *session, switch_codec *codec);
|
||||||
SWITCH_DECLARE(switch_status) switch_core_session_set_write_codec(switch_core_session *session, switch_codec *codec);
|
SWITCH_DECLARE(switch_status) switch_core_session_set_write_codec(switch_core_session *session, switch_codec *codec);
|
||||||
SWITCH_DECLARE(switch_memory_pool *) switch_core_session_get_pool(switch_core_session *session);
|
SWITCH_DECLARE(switch_memory_pool *) switch_core_session_get_pool(switch_core_session *session);
|
||||||
|
SWITCH_DECLARE(void) pbx_core_session_signal_state_change(switch_core_session *session);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@ -199,7 +199,7 @@ struct switch_codec {
|
|||||||
struct switch_codec_implementation {
|
struct switch_codec_implementation {
|
||||||
int samples_per_second;
|
int samples_per_second;
|
||||||
int bits_per_second;
|
int bits_per_second;
|
||||||
int nanoseconds_per_frame;
|
int microseconds_per_frame;
|
||||||
int samples_per_frame;
|
int samples_per_frame;
|
||||||
int bytes_per_frame;
|
int bytes_per_frame;
|
||||||
int encoded_bytes_per_frame;
|
int encoded_bytes_per_frame;
|
||||||
|
@ -178,6 +178,7 @@ typedef apr_socket_t switch_socket_t;
|
|||||||
typedef apr_pollfd_t switch_pollfd_t;
|
typedef apr_pollfd_t switch_pollfd_t;
|
||||||
typedef apr_pollset_t switch_pollset_t;
|
typedef apr_pollset_t switch_pollset_t;
|
||||||
typedef apr_file_t switch_file_t;
|
typedef apr_file_t switch_file_t;
|
||||||
|
typedef apr_thread_cond_t switch_thread_cond_t;
|
||||||
|
|
||||||
#define SWITCH_UNSPEC APR_UNSPEC
|
#define SWITCH_UNSPEC APR_UNSPEC
|
||||||
#define SWITCH_POLLIN APR_POLLIN
|
#define SWITCH_POLLIN APR_POLLIN
|
||||||
@ -189,6 +190,14 @@ typedef apr_file_t switch_file_t;
|
|||||||
#define SWITCH_READ APR_READ
|
#define SWITCH_READ APR_READ
|
||||||
#define SWITCH_FPROT_UREAD APR_FPROT_UREAD
|
#define SWITCH_FPROT_UREAD APR_FPROT_UREAD
|
||||||
#define SWITCH_FPROT_GREAD APR_FPROT_GREAD
|
#define SWITCH_FPROT_GREAD APR_FPROT_GREAD
|
||||||
|
|
||||||
|
#define switch_thread_cond_create apr_thread_cond_create
|
||||||
|
#define switch_thread_cond_wait apr_thread_cond_wait
|
||||||
|
#define switch_thread_cond_timedwait apr_thread_cond_timedwait
|
||||||
|
#define switch_thread_cond_signal apr_thread_cond_signal
|
||||||
|
#define switch_thread_cond_broadcast apr_thread_cond_broadcast
|
||||||
|
#define switch_thread_cond_destroy apr_thread_cond_destroy
|
||||||
|
|
||||||
#define switch_poll_setup apr_poll_setup
|
#define switch_poll_setup apr_poll_setup
|
||||||
#define switch_pollset_create apr_pollset_create
|
#define switch_pollset_create apr_pollset_create
|
||||||
#define switch_pollset_add apr_pollset_add
|
#define switch_pollset_add apr_pollset_add
|
||||||
@ -243,21 +252,21 @@ typedef apr_file_t switch_file_t;
|
|||||||
#define switch_file_read apr_file_read
|
#define switch_file_read apr_file_read
|
||||||
#define switch_file_write apr_file_write
|
#define switch_file_write apr_file_write
|
||||||
|
|
||||||
#define SWITCH_FOPEN_READ APR_FOPEN_READ
|
#define SWITCH_FOPEN_READ APR_FOPEN_READ
|
||||||
#define SWITCH_FOPEN_WRITE APR_FOPEN_WRITE
|
#define SWITCH_FOPEN_WRITE APR_FOPEN_WRITE
|
||||||
#define SWITCH_FOPEN_CREATE APR_FOPEN_CREATE
|
#define SWITCH_FOPEN_CREATE APR_FOPEN_CREATE
|
||||||
#define SWITCH_FOPEN_APPEND APR_FOPEN_APPEND
|
#define SWITCH_FOPEN_APPEND APR_FOPEN_APPEND
|
||||||
#define SWITCH_FOPEN_TRUNCATE APR_FOPEN_TRUNCATE
|
#define SWITCH_FOPEN_TRUNCATE APR_FOPEN_TRUNCATE
|
||||||
#define SWITCH_FOPEN_BINARY APR_FOPEN_BINARY
|
#define SWITCH_FOPEN_BINARY APR_FOPEN_BINARY
|
||||||
#define SWITCH_FOPEN_EXCL APR_FOPEN_EXCL
|
#define SWITCH_FOPEN_EXCL APR_FOPEN_EXCL
|
||||||
#define SWITCH_FOPEN_BUFFERED APR_FOPEN_BUFFERED
|
#define SWITCH_FOPEN_BUFFERED APR_FOPEN_BUFFERED
|
||||||
#define SWITCH_FOPEN_DELONCLOSE APR_FOPEN_DELONCLOSE
|
#define SWITCH_FOPEN_DELONCLOSE APR_FOPEN_DELONCLOSE
|
||||||
#define SWITCH_FOPEN_XTHREAD APR_FOPEN_XTHREAD
|
#define SWITCH_FOPEN_XTHREAD APR_FOPEN_XTHREAD
|
||||||
#define SWITCH_FOPEN_SHARELOCK APR_FOPEN_SHARELOCK
|
#define SWITCH_FOPEN_SHARELOCK APR_FOPEN_SHARELOCK
|
||||||
#define SWITCH_FOPEN_NOCLEANUP APR_FOPEN_NOCLEANUP
|
#define SWITCH_FOPEN_NOCLEANUP APR_FOPEN_NOCLEANUP
|
||||||
#define SWITCH_FOPEN_SENDFILE_ENABLED APR_FOPEN_SENDFILE_ENABLED
|
#define SWITCH_FOPEN_SENDFILE_ENABLED APR_FOPEN_SENDFILE_ENABLED
|
||||||
#define SWITCH_FOPEN_LARGEFILE APR_FOPEN_LARGEFILE
|
#define SWITCH_FOPEN_LARGEFILE APR_FOPEN_LARGEFILE
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define SWITCH_FPROT_USETID APR_FPROT_USETID
|
#define SWITCH_FPROT_USETID APR_FPROT_USETID
|
||||||
|
@ -76,7 +76,7 @@ static void *audio_bridge_thread(switch_thread *thread, void *obj)
|
|||||||
data->running = -1;
|
data->running = -1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Bad Frame.... %d Bubye!\n", read_frame->datalen);
|
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Bad Frame....Bubye!\n");
|
||||||
data->running = -1;
|
data->running = -1;
|
||||||
}
|
}
|
||||||
switch_yield(100);
|
switch_yield(100);
|
||||||
|
@ -111,7 +111,7 @@ struct private_object {
|
|||||||
int local_sdp_audio_port;
|
int local_sdp_audio_port;
|
||||||
char call_id[50];
|
char call_id[50];
|
||||||
int ssrc;
|
int ssrc;
|
||||||
//switch_mutex_t *rtp_lock;
|
switch_mutex_t *rtp_lock;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -373,7 +373,7 @@ static switch_status exosip_outgoing_channel(switch_core_session *session, switc
|
|||||||
memset(tech_pvt, 0, sizeof(*tech_pvt));
|
memset(tech_pvt, 0, sizeof(*tech_pvt));
|
||||||
channel = switch_core_session_get_channel(*new_session);
|
channel = switch_core_session_get_channel(*new_session);
|
||||||
switch_core_session_set_private(*new_session, tech_pvt);
|
switch_core_session_set_private(*new_session, tech_pvt);
|
||||||
//switch_mutex_init(&tech_pvt->rtp_lock, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(*new_session));
|
switch_mutex_init(&tech_pvt->rtp_lock, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(*new_session));
|
||||||
tech_pvt->session = *new_session;
|
tech_pvt->session = *new_session;
|
||||||
} else {
|
} else {
|
||||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Hey where is my memory pool?\n");
|
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Hey where is my memory pool?\n");
|
||||||
@ -418,7 +418,7 @@ static void deactivate_rtp(struct private_object *tech_pvt)
|
|||||||
{
|
{
|
||||||
int loops = 0;
|
int loops = 0;
|
||||||
if (tech_pvt->rtp_session) {
|
if (tech_pvt->rtp_session) {
|
||||||
//switch_mutex_lock(tech_pvt->rtp_lock);
|
switch_mutex_lock(tech_pvt->rtp_lock);
|
||||||
|
|
||||||
while(loops < 10 && (switch_test_flag(tech_pvt, TFLAG_READING) || switch_test_flag(tech_pvt, TFLAG_WRITING))) {
|
while(loops < 10 && (switch_test_flag(tech_pvt, TFLAG_READING) || switch_test_flag(tech_pvt, TFLAG_WRITING))) {
|
||||||
switch_yield(10000);
|
switch_yield(10000);
|
||||||
@ -427,7 +427,7 @@ static void deactivate_rtp(struct private_object *tech_pvt)
|
|||||||
|
|
||||||
ccrtp4c_destroy(&tech_pvt->rtp_session);
|
ccrtp4c_destroy(&tech_pvt->rtp_session);
|
||||||
tech_pvt->rtp_session = NULL;
|
tech_pvt->rtp_session = NULL;
|
||||||
//switch_mutex_unlock(tech_pvt->rtp_lock);
|
switch_mutex_unlock(tech_pvt->rtp_lock);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -443,10 +443,10 @@ static void activate_rtp(struct private_object *tech_pvt)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
//switch_mutex_lock(tech_pvt->rtp_lock);
|
switch_mutex_lock(tech_pvt->rtp_lock);
|
||||||
if (switch_test_flag(tech_pvt, TFLAG_USING_CODEC)) {
|
if (switch_test_flag(tech_pvt, TFLAG_USING_CODEC)) {
|
||||||
bw = tech_pvt->read_codec.implementation->bits_per_second;
|
bw = tech_pvt->read_codec.implementation->bits_per_second;
|
||||||
ms = tech_pvt->read_codec.implementation->nanoseconds_per_frame;
|
ms = tech_pvt->read_codec.implementation->microseconds_per_frame;
|
||||||
} else {
|
} else {
|
||||||
switch_channel_get_raw_mode(channel, NULL, NULL, NULL, &ms, &bw);
|
switch_channel_get_raw_mode(channel, NULL, NULL, NULL, &ms, &bw);
|
||||||
bw *= 8;
|
bw *= 8;
|
||||||
@ -470,8 +470,8 @@ static void activate_rtp(struct private_object *tech_pvt)
|
|||||||
tech_pvt->remote_sdp_audio_ip,
|
tech_pvt->remote_sdp_audio_ip,
|
||||||
tech_pvt->remote_sdp_audio_port,
|
tech_pvt->remote_sdp_audio_port,
|
||||||
tech_pvt->read_codec.codec_interface->ianacode,
|
tech_pvt->read_codec.codec_interface->ianacode,
|
||||||
ms,
|
ms ,
|
||||||
ms * 15);
|
ms * 20);
|
||||||
|
|
||||||
if (tech_pvt->rtp_session) {
|
if (tech_pvt->rtp_session) {
|
||||||
tech_pvt->ssrc = ccrtp4c_get_ssrc(tech_pvt->rtp_session);
|
tech_pvt->ssrc = ccrtp4c_get_ssrc(tech_pvt->rtp_session);
|
||||||
@ -481,7 +481,7 @@ static void activate_rtp(struct private_object *tech_pvt)
|
|||||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Oh oh?\n");
|
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Oh oh?\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
//switch_mutex_unlock(tech_pvt->rtp_lock);
|
switch_mutex_unlock(tech_pvt->rtp_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
static switch_status exosip_answer_channel(switch_core_session *session)
|
static switch_status exosip_answer_channel(switch_core_session *session)
|
||||||
@ -521,6 +521,8 @@ static switch_status exosip_read_frame(switch_core_session *session, switch_fram
|
|||||||
struct private_object *tech_pvt = NULL;
|
struct private_object *tech_pvt = NULL;
|
||||||
size_t bytes = 0, samples = 0, frames=0, ms=0;
|
size_t bytes = 0, samples = 0, frames=0, ms=0;
|
||||||
switch_channel *channel = NULL;
|
switch_channel *channel = NULL;
|
||||||
|
switch_time_t reference, now;
|
||||||
|
int mult = 2;
|
||||||
|
|
||||||
channel = switch_core_session_get_channel(session);
|
channel = switch_core_session_get_channel(session);
|
||||||
assert(channel != NULL);
|
assert(channel != NULL);
|
||||||
@ -534,6 +536,7 @@ static switch_status exosip_read_frame(switch_core_session *session, switch_fram
|
|||||||
if (switch_test_flag(tech_pvt, TFLAG_USING_CODEC)) {
|
if (switch_test_flag(tech_pvt, TFLAG_USING_CODEC)) {
|
||||||
bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_frame;
|
bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_frame;
|
||||||
samples = tech_pvt->read_codec.implementation->samples_per_frame;
|
samples = tech_pvt->read_codec.implementation->samples_per_frame;
|
||||||
|
ms = tech_pvt->read_codec.implementation->microseconds_per_frame;
|
||||||
} else {
|
} else {
|
||||||
assert(0);
|
assert(0);
|
||||||
}
|
}
|
||||||
@ -546,6 +549,8 @@ static switch_status exosip_read_frame(switch_core_session *session, switch_fram
|
|||||||
assert(tech_pvt->rtp_session != NULL);
|
assert(tech_pvt->rtp_session != NULL);
|
||||||
tech_pvt->read_frame.datalen = 0;
|
tech_pvt->read_frame.datalen = 0;
|
||||||
|
|
||||||
|
reference = switch_time_now();
|
||||||
|
reference += (ms * mult);
|
||||||
while(!switch_test_flag(tech_pvt, TFLAG_BYE) && switch_test_flag(tech_pvt, TFLAG_IO) && tech_pvt->read_frame.datalen == 0) {
|
while(!switch_test_flag(tech_pvt, TFLAG_BYE) && switch_test_flag(tech_pvt, TFLAG_IO) && tech_pvt->read_frame.datalen == 0) {
|
||||||
if ((tech_pvt->read_frame.datalen =
|
if ((tech_pvt->read_frame.datalen =
|
||||||
ccrtp4c_read(tech_pvt->rtp_session,
|
ccrtp4c_read(tech_pvt->rtp_session,
|
||||||
@ -555,10 +560,21 @@ static switch_status exosip_read_frame(switch_core_session *session, switch_fram
|
|||||||
bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_frame;
|
bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_frame;
|
||||||
frames = (tech_pvt->read_frame.datalen / bytes);
|
frames = (tech_pvt->read_frame.datalen / bytes);
|
||||||
samples = frames * tech_pvt->read_codec.implementation->samples_per_frame;
|
samples = frames * tech_pvt->read_codec.implementation->samples_per_frame;
|
||||||
ms = frames * tech_pvt->read_codec.implementation->nanoseconds_per_frame / 1000;
|
ms = frames * tech_pvt->read_codec.implementation->microseconds_per_frame;
|
||||||
tech_pvt->timestamp_recv += samples;
|
tech_pvt->timestamp_recv += samples;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
now = switch_time_now();
|
||||||
|
if (now >= reference) {
|
||||||
|
printf("TO\n");
|
||||||
|
//memset(tech_pvt->read_buf, 0, bytes *2);
|
||||||
|
//tech_pvt->timestamp_recv += (samples * mult);
|
||||||
|
//reference += (ms * mult);
|
||||||
|
//tech_pvt->read_frame.datalen = bytes *2;
|
||||||
|
//break;
|
||||||
|
}
|
||||||
|
|
||||||
switch_yield(100);
|
switch_yield(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -601,6 +617,7 @@ static switch_status exosip_write_frame(switch_core_session *session, switch_fra
|
|||||||
|
|
||||||
if (!switch_test_flag(tech_pvt, TFLAG_RTP)) {
|
if (!switch_test_flag(tech_pvt, TFLAG_RTP)) {
|
||||||
activate_rtp(tech_pvt);
|
activate_rtp(tech_pvt);
|
||||||
|
//return SWITCH_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!switch_test_flag(tech_pvt, TFLAG_IO)) {
|
if (!switch_test_flag(tech_pvt, TFLAG_IO)) {
|
||||||
@ -619,7 +636,7 @@ static switch_status exosip_write_frame(switch_core_session *session, switch_fra
|
|||||||
bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_frame;
|
bytes = tech_pvt->read_codec.implementation->encoded_bytes_per_frame;
|
||||||
frames = (frame->datalen / bytes);
|
frames = (frame->datalen / bytes);
|
||||||
samples = frames * tech_pvt->read_codec.implementation->samples_per_frame;
|
samples = frames * tech_pvt->read_codec.implementation->samples_per_frame;
|
||||||
ms = frames * tech_pvt->read_codec.implementation->nanoseconds_per_frame / 1000;
|
ms = frames * tech_pvt->read_codec.implementation->microseconds_per_frame / 1000;
|
||||||
} else {
|
} else {
|
||||||
assert(0);
|
assert(0);
|
||||||
}
|
}
|
||||||
@ -777,7 +794,7 @@ static switch_status exosip_create_call(eXosip_event_t *event)
|
|||||||
channel = switch_core_session_get_channel(session);
|
channel = switch_core_session_get_channel(session);
|
||||||
switch_core_session_set_private(session, tech_pvt);
|
switch_core_session_set_private(session, tech_pvt);
|
||||||
tech_pvt->session = session;
|
tech_pvt->session = session;
|
||||||
//switch_mutex_init(&tech_pvt->rtp_lock, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session));
|
switch_mutex_init(&tech_pvt->rtp_lock, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session));
|
||||||
} else {
|
} else {
|
||||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Hey where is my memory pool?\n");
|
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Hey where is my memory pool?\n");
|
||||||
switch_core_session_destroy(&session);
|
switch_core_session_destroy(&session);
|
||||||
@ -898,7 +915,7 @@ static switch_status exosip_create_call(eXosip_event_t *event)
|
|||||||
} else {
|
} else {
|
||||||
int ms;
|
int ms;
|
||||||
switch_set_flag(tech_pvt, TFLAG_USING_CODEC);
|
switch_set_flag(tech_pvt, TFLAG_USING_CODEC);
|
||||||
ms = tech_pvt->write_codec.implementation->nanoseconds_per_frame / 1000;
|
ms = tech_pvt->write_codec.implementation->microseconds_per_frame / 1000;
|
||||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Activate Inbound Codec %s/%d %d ms\n", dname, rate, ms);
|
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Activate Inbound Codec %s/%d %d ms\n", dname, rate, ms);
|
||||||
tech_pvt->read_frame.codec = &tech_pvt->read_codec;
|
tech_pvt->read_frame.codec = &tech_pvt->read_codec;
|
||||||
switch_core_session_set_read_codec(session, &tech_pvt->read_codec);
|
switch_core_session_set_read_codec(session, &tech_pvt->read_codec);
|
||||||
@ -1043,7 +1060,7 @@ static void handle_answer(eXosip_event_t *event)
|
|||||||
} else {
|
} else {
|
||||||
int ms;
|
int ms;
|
||||||
switch_set_flag(tech_pvt, TFLAG_USING_CODEC);
|
switch_set_flag(tech_pvt, TFLAG_USING_CODEC);
|
||||||
ms = tech_pvt->write_codec.implementation->nanoseconds_per_frame / 1000;
|
ms = tech_pvt->write_codec.implementation->microseconds_per_frame / 1000;
|
||||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Activate Outbound Codec %s/%d %d ms\n", dname, rate, ms);
|
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Activate Outbound Codec %s/%d %d ms\n", dname, rate, ms);
|
||||||
tech_pvt->read_frame.codec = &tech_pvt->read_codec;
|
tech_pvt->read_frame.codec = &tech_pvt->read_codec;
|
||||||
switch_core_session_set_read_codec(tech_pvt->session, &tech_pvt->read_codec);
|
switch_core_session_set_read_codec(tech_pvt->session, &tech_pvt->read_codec);
|
||||||
|
@ -189,7 +189,7 @@ static switch_status switch_g711a_destroy(switch_codec *codec)
|
|||||||
static const switch_codec_implementation g711u_8k_60ms_implementation = {
|
static const switch_codec_implementation g711u_8k_60ms_implementation = {
|
||||||
/*.samples_per_second*/ 8000,
|
/*.samples_per_second*/ 8000,
|
||||||
/*.bits_per_second*/ 19200,
|
/*.bits_per_second*/ 19200,
|
||||||
/*.nanoseconds_per_frame*/ 60000,
|
/*.microseconds_per_frame*/ 60000,
|
||||||
/*.samples_per_frame*/ 480,
|
/*.samples_per_frame*/ 480,
|
||||||
/*.bytes_per_frame*/ 960,
|
/*.bytes_per_frame*/ 960,
|
||||||
/*.encoded_bytes_per_frame*/ 480,
|
/*.encoded_bytes_per_frame*/ 480,
|
||||||
@ -205,7 +205,7 @@ static const switch_codec_implementation g711u_8k_60ms_implementation = {
|
|||||||
static const switch_codec_implementation g711u_8k_30ms_implementation = {
|
static const switch_codec_implementation g711u_8k_30ms_implementation = {
|
||||||
/*.samples_per_second*/ 8000,
|
/*.samples_per_second*/ 8000,
|
||||||
/*.bits_per_second*/ 96000,
|
/*.bits_per_second*/ 96000,
|
||||||
/*.nanoseconds_per_frame*/ 30000,
|
/*.microseconds_per_frame*/ 30000,
|
||||||
/*.samples_per_frame*/ 240,
|
/*.samples_per_frame*/ 240,
|
||||||
/*.bytes_per_frame*/ 480,
|
/*.bytes_per_frame*/ 480,
|
||||||
/*.encoded_bytes_per_frame*/ 240,
|
/*.encoded_bytes_per_frame*/ 240,
|
||||||
@ -222,7 +222,7 @@ static const switch_codec_implementation g711u_8k_30ms_implementation = {
|
|||||||
static const switch_codec_implementation g711u_8k_implementation = {
|
static const switch_codec_implementation g711u_8k_implementation = {
|
||||||
/*.samples_per_second*/ 8000,
|
/*.samples_per_second*/ 8000,
|
||||||
/*.bits_per_second*/ 64000,
|
/*.bits_per_second*/ 64000,
|
||||||
/*.nanoseconds_per_frame*/ 20000,
|
/*.microseconds_per_frame*/ 20000,
|
||||||
/*.samples_per_frame*/ 160,
|
/*.samples_per_frame*/ 160,
|
||||||
/*.bytes_per_frame*/ 320,
|
/*.bytes_per_frame*/ 320,
|
||||||
/*.encoded_bytes_per_frame*/ 160,
|
/*.encoded_bytes_per_frame*/ 160,
|
||||||
@ -240,7 +240,7 @@ static const switch_codec_implementation g711u_8k_implementation = {
|
|||||||
static const switch_codec_implementation g711a_8k_implementation = {
|
static const switch_codec_implementation g711a_8k_implementation = {
|
||||||
/*.samples_per_second*/ 8000,
|
/*.samples_per_second*/ 8000,
|
||||||
/*.bits_per_second*/ 64000,
|
/*.bits_per_second*/ 64000,
|
||||||
/*.nanoseconds_per_frame*/ 20000,
|
/*.microseconds_per_frame*/ 20000,
|
||||||
/*.samples_per_frame*/ 160,
|
/*.samples_per_frame*/ 160,
|
||||||
/*.bytes_per_frame*/ 320,
|
/*.bytes_per_frame*/ 320,
|
||||||
/*.encoded_bytes_per_frame*/ 160,
|
/*.encoded_bytes_per_frame*/ 160,
|
||||||
|
@ -124,7 +124,7 @@ void playback_function(switch_core_session *session, char *data)
|
|||||||
|
|
||||||
switch_core_codec_destroy(&codec);
|
switch_core_codec_destroy(&codec);
|
||||||
|
|
||||||
switch_channel_set_state(channel, CS_HANGUP);
|
switch_channel_hangup(channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const switch_application_interface playback_application_interface = {
|
static const switch_application_interface playback_application_interface = {
|
||||||
|
@ -90,7 +90,7 @@ static const switch_codec_implementation raw_32k_implementation = {
|
|||||||
/*.samples_per_frame = */ 640,
|
/*.samples_per_frame = */ 640,
|
||||||
/*.bytes_per_frame = */ 1280,
|
/*.bytes_per_frame = */ 1280,
|
||||||
/*.encoded_bytes_per_frame = */ 1280,
|
/*.encoded_bytes_per_frame = */ 1280,
|
||||||
/*.nanoseconds_per_frame = */ 20000,
|
/*.microseconds_per_frame = */ 20000,
|
||||||
/*.number_of_channels = */ 1,
|
/*.number_of_channels = */ 1,
|
||||||
/*.pref_frames_per_packet = */ 1,
|
/*.pref_frames_per_packet = */ 1,
|
||||||
/*.max_frames_per_packet = */ 1,
|
/*.max_frames_per_packet = */ 1,
|
||||||
@ -103,7 +103,7 @@ static const switch_codec_implementation raw_32k_implementation = {
|
|||||||
static const switch_codec_implementation raw_16k_implementation = {
|
static const switch_codec_implementation raw_16k_implementation = {
|
||||||
/*.samples_per_second = */ 16000,
|
/*.samples_per_second = */ 16000,
|
||||||
/*.bits_per_second = */ 256000,
|
/*.bits_per_second = */ 256000,
|
||||||
/*.nanoseconds_per_frame = */ 20000,
|
/*.microseconds_per_frame = */ 20000,
|
||||||
/*.samples_per_frame = */ 320,
|
/*.samples_per_frame = */ 320,
|
||||||
/*.bytes_per_frame = */ 640,
|
/*.bytes_per_frame = */ 640,
|
||||||
/*.encoded_bytes_per_frame = */ 640,
|
/*.encoded_bytes_per_frame = */ 640,
|
||||||
@ -120,7 +120,7 @@ static const switch_codec_implementation raw_16k_implementation = {
|
|||||||
static const switch_codec_implementation raw_8k_implementation = {
|
static const switch_codec_implementation raw_8k_implementation = {
|
||||||
/*.samples_per_second = */ 8000,
|
/*.samples_per_second = */ 8000,
|
||||||
/*.bits_per_second = */ 128000,
|
/*.bits_per_second = */ 128000,
|
||||||
/*.nanoseconds_per_frame = */ 20000,
|
/*.microseconds_per_frame = */ 20000,
|
||||||
/*.samples_per_frame = */ 160,
|
/*.samples_per_frame = */ 160,
|
||||||
/*.bytes_per_frame = */ 320,
|
/*.bytes_per_frame = */ 320,
|
||||||
/*.encoded_bytes_per_frame = */ 320,
|
/*.encoded_bytes_per_frame = */ 320,
|
||||||
@ -138,7 +138,7 @@ static const switch_codec_implementation raw_8k_implementation = {
|
|||||||
static const switch_codec_implementation raw_8k_30ms_implementation = {
|
static const switch_codec_implementation raw_8k_30ms_implementation = {
|
||||||
/*.samples_per_second*/ 8000,
|
/*.samples_per_second*/ 8000,
|
||||||
/*.bits_per_second*/ 128000,
|
/*.bits_per_second*/ 128000,
|
||||||
/*.nanoseconds_per_frame*/ 30000,
|
/*.microseconds_per_frame*/ 30000,
|
||||||
/*.samples_per_frame*/ 240,
|
/*.samples_per_frame*/ 240,
|
||||||
/*.bytes_per_frame*/ 480,
|
/*.bytes_per_frame*/ 480,
|
||||||
/*.encoded_bytes_per_frame*/ 480,
|
/*.encoded_bytes_per_frame*/ 480,
|
||||||
|
@ -347,8 +347,10 @@ SWITCH_DECLARE(switch_channel_state) switch_channel_set_state(switch_channel *ch
|
|||||||
if (ok) {
|
if (ok) {
|
||||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "%s State Change %s -> %s\n", channel->name, state_names[last_state], state_names[state]);
|
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "%s State Change %s -> %s\n", channel->name, state_names[last_state], state_names[state]);
|
||||||
channel->state = state;
|
channel->state = state;
|
||||||
|
pbx_core_session_signal_state_change(channel->session);
|
||||||
} else {
|
} else {
|
||||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "%s Invalid State Change %s -> %s\n", channel->name, state_names[last_state], state_names[state]);
|
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "%s Invalid State Change %s -> %s\n", channel->name, state_names[last_state], state_names[state]);
|
||||||
|
//we won't tolerate an invalid state change so we can make sure we are as robust as a nice cup of dark coffee!
|
||||||
assert(0);
|
assert(0);
|
||||||
}
|
}
|
||||||
return channel->state;
|
return channel->state;
|
||||||
@ -410,8 +412,8 @@ SWITCH_DECLARE(switch_status) switch_channel_hangup(switch_channel *channel)
|
|||||||
assert(channel != NULL);
|
assert(channel != NULL);
|
||||||
if (channel->state < CS_HANGUP) {
|
if (channel->state < CS_HANGUP) {
|
||||||
channel->state = CS_HANGUP;
|
channel->state = CS_HANGUP;
|
||||||
|
pbx_core_session_signal_state_change(channel->session);
|
||||||
}
|
}
|
||||||
|
|
||||||
return channel->state;
|
return channel->state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,6 +66,9 @@ struct switch_core_session {
|
|||||||
unsigned char *raw_read_buf[3200];
|
unsigned char *raw_read_buf[3200];
|
||||||
unsigned char *enc_read_buf[3200];
|
unsigned char *enc_read_buf[3200];
|
||||||
|
|
||||||
|
switch_mutex_t *mutex;
|
||||||
|
switch_thread_cond_t *cond;
|
||||||
|
|
||||||
void *private;
|
void *private;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -168,7 +171,7 @@ SWITCH_DECLARE(switch_status) switch_core_codec_init(switch_codec *codec, char *
|
|||||||
}
|
}
|
||||||
|
|
||||||
for(iptr = codec_interface->implementations; iptr; iptr = iptr->next) {
|
for(iptr = codec_interface->implementations; iptr; iptr = iptr->next) {
|
||||||
if ((!rate || rate == iptr->samples_per_second) && (!ms || ms == (iptr->nanoseconds_per_frame / 1000))) {
|
if ((!rate || rate == iptr->samples_per_second) && (!ms || ms == (iptr->microseconds_per_frame / 1000))) {
|
||||||
implementation = iptr;
|
implementation = iptr;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -339,9 +342,12 @@ SWITCH_DECLARE(void) switch_core_thread_session_end(switch_core_thread_session *
|
|||||||
|
|
||||||
switch_core_session_kill_channel(session, SWITCH_SIG_KILL);
|
switch_core_session_kill_channel(session, SWITCH_SIG_KILL);
|
||||||
|
|
||||||
thread_session->running = -1;
|
if (thread_session->running > 0) {
|
||||||
while(thread_session->running) {
|
thread_session->running = -1;
|
||||||
switch_yield(100);
|
|
||||||
|
while(thread_session->running) {
|
||||||
|
switch_yield(1000);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1074,6 +1080,11 @@ static void switch_core_standard_on_transmit(switch_core_session *session)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
SWITCH_DECLARE(void) pbx_core_session_signal_state_change(switch_core_session *session)
|
||||||
|
{
|
||||||
|
switch_thread_cond_signal(session->cond);
|
||||||
|
}
|
||||||
|
|
||||||
SWITCH_DECLARE(void) switch_core_session_run(switch_core_session *session)
|
SWITCH_DECLARE(void) switch_core_session_run(switch_core_session *session)
|
||||||
{
|
{
|
||||||
switch_channel_state state = CS_NEW, laststate = CS_HANGUP;
|
switch_channel_state state = CS_NEW, laststate = CS_HANGUP;
|
||||||
@ -1105,6 +1116,8 @@ SWITCH_DECLARE(void) switch_core_session_run(switch_core_session *session)
|
|||||||
driver_event_handlers = endpoint_interface->event_handlers;
|
driver_event_handlers = endpoint_interface->event_handlers;
|
||||||
assert(driver_event_handlers != NULL);
|
assert(driver_event_handlers != NULL);
|
||||||
|
|
||||||
|
switch_mutex_lock(session->mutex);
|
||||||
|
|
||||||
while ((state = switch_channel_get_state(session->channel)) != CS_DONE) {
|
while ((state = switch_channel_get_state(session->channel)) != CS_DONE) {
|
||||||
if (state != laststate) {
|
if (state != laststate) {
|
||||||
switch ( state ) {
|
switch ( state ) {
|
||||||
@ -1190,10 +1203,11 @@ SWITCH_DECLARE(void) switch_core_session_run(switch_core_session *session)
|
|||||||
}
|
}
|
||||||
laststate = state;
|
laststate = state;
|
||||||
}
|
}
|
||||||
//I should fall asleep here if possible!!!
|
|
||||||
switch_yield(1000);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (state < CS_DONE) {
|
||||||
|
switch_thread_cond_wait(session->cond, session->mutex);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SWITCH_DECLARE(void) switch_core_session_destroy(switch_core_session **session)
|
SWITCH_DECLARE(void) switch_core_session_destroy(switch_core_session **session)
|
||||||
@ -1373,6 +1387,9 @@ SWITCH_DECLARE(switch_core_session *) switch_core_session_request(const switch_e
|
|||||||
session->enc_write_frame.data = session->enc_write_buf;
|
session->enc_write_frame.data = session->enc_write_buf;
|
||||||
session->enc_read_frame.data = session->enc_read_buf;
|
session->enc_read_frame.data = session->enc_read_buf;
|
||||||
|
|
||||||
|
switch_mutex_init(&session->mutex, SWITCH_MUTEX_NESTED ,session->pool);
|
||||||
|
switch_thread_cond_create(&session->cond, session->pool);
|
||||||
|
|
||||||
return session;
|
return session;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -244,7 +244,7 @@ SWITCH_DECLARE(switch_status) switch_loadable_module_init()
|
|||||||
ptr->iananame,
|
ptr->iananame,
|
||||||
ptr->interface_name,
|
ptr->interface_name,
|
||||||
impl->samples_per_second,
|
impl->samples_per_second,
|
||||||
impl->nanoseconds_per_frame / 1000);
|
impl->microseconds_per_frame / 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch_core_hash_insert(loadable_modules.codec_hash,
|
switch_core_hash_insert(loadable_modules.codec_hash,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user