adjustment
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@10876 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
61647d0f3e
commit
e9d7a4a4a0
|
@ -1165,6 +1165,12 @@ SWITCH_DECLARE(void) switch_core_session_unset_read_codec(_In_ switch_core_sessi
|
||||||
SWITCH_DECLARE(void) switch_core_session_unset_write_codec(_In_ switch_core_session_t *session);
|
SWITCH_DECLARE(void) switch_core_session_unset_write_codec(_In_ switch_core_session_t *session);
|
||||||
|
|
||||||
|
|
||||||
|
SWITCH_DECLARE(void) switch_core_session_lock_codec_write(_In_ switch_core_session_t *session);
|
||||||
|
SWITCH_DECLARE(void) switch_core_session_unlock_codec_write(_In_ switch_core_session_t *session);
|
||||||
|
SWITCH_DECLARE(void) switch_core_session_lock_codec_read(_In_ switch_core_session_t *session);
|
||||||
|
SWITCH_DECLARE(void) switch_core_session_unlock_codec_read(_In_ switch_core_session_t *session);
|
||||||
|
|
||||||
|
|
||||||
SWITCH_DECLARE(switch_status_t) switch_core_session_get_read_impl(switch_core_session_t *session, switch_codec_implementation_t *impp);
|
SWITCH_DECLARE(switch_status_t) switch_core_session_get_read_impl(switch_core_session_t *session, switch_codec_implementation_t *impp);
|
||||||
SWITCH_DECLARE(switch_status_t) switch_core_session_get_write_impl(switch_core_session_t *session, switch_codec_implementation_t *impp);
|
SWITCH_DECLARE(switch_status_t) switch_core_session_get_write_impl(switch_core_session_t *session, switch_codec_implementation_t *impp);
|
||||||
SWITCH_DECLARE(switch_status_t) switch_core_session_get_video_read_impl(switch_core_session_t *session, switch_codec_implementation_t *impp);
|
SWITCH_DECLARE(switch_status_t) switch_core_session_get_video_read_impl(switch_core_session_t *session, switch_codec_implementation_t *impp);
|
||||||
|
|
|
@ -56,7 +56,7 @@ SWITCH_DECLARE(int) switch_isspace(int c);
|
||||||
SWITCH_DECLARE(int) switch_isupper(int c);
|
SWITCH_DECLARE(int) switch_isupper(int c);
|
||||||
SWITCH_DECLARE(int) switch_isxdigit(int c);
|
SWITCH_DECLARE(int) switch_isxdigit(int c);
|
||||||
|
|
||||||
|
#define switch_goto_status(_status, _label) status = _status; goto _label
|
||||||
#define switch_samples_per_packet(rate, interval) ((uint32_t)((float)rate / (1000.0f / (float)interval)))
|
#define switch_samples_per_packet(rate, interval) ((uint32_t)((float)rate / (1000.0f / (float)interval)))
|
||||||
#define SWITCH_SMAX 32767
|
#define SWITCH_SMAX 32767
|
||||||
#define SWITCH_SMIN -32768
|
#define SWITCH_SMIN -32768
|
||||||
|
|
|
@ -738,14 +738,20 @@ static switch_status_t sofia_read_frame(switch_core_session_t *session, switch_f
|
||||||
tech_pvt->codec_ms = codec_ms;
|
tech_pvt->codec_ms = codec_ms;
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
|
||||||
"Changing codec ptime to %d. I bet you have a linksys/sipura =D\n", tech_pvt->codec_ms);
|
"Changing codec ptime to %d. I bet you have a linksys/sipura =D\n", tech_pvt->codec_ms);
|
||||||
|
|
||||||
|
switch_core_session_lock_codec_write(session);
|
||||||
|
switch_core_session_lock_codec_read(session);
|
||||||
|
|
||||||
switch_core_codec_destroy(&tech_pvt->read_codec);
|
switch_core_codec_destroy(&tech_pvt->read_codec);
|
||||||
switch_core_codec_destroy(&tech_pvt->write_codec);
|
switch_core_codec_destroy(&tech_pvt->write_codec);
|
||||||
|
|
||||||
if (sofia_glue_tech_set_codec(tech_pvt, 2) != SWITCH_STATUS_SUCCESS) {
|
if (sofia_glue_tech_set_codec(tech_pvt, 2) != SWITCH_STATUS_SUCCESS) {
|
||||||
*frame = NULL;
|
*frame = NULL;
|
||||||
|
switch_core_session_unlock_codec_write(session);
|
||||||
|
switch_core_session_unlock_codec_read(session);
|
||||||
return SWITCH_STATUS_GENERR;
|
return SWITCH_STATUS_GENERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ((val = switch_channel_get_variable(tech_pvt->channel, "rtp_timeout_sec"))) {
|
if ((val = switch_channel_get_variable(tech_pvt->channel, "rtp_timeout_sec"))) {
|
||||||
int v = atoi(val);
|
int v = atoi(val);
|
||||||
if (v >= 0) {
|
if (v >= 0) {
|
||||||
|
@ -784,6 +790,10 @@ static switch_status_t sofia_read_frame(switch_core_session_t *session, switch_f
|
||||||
}
|
}
|
||||||
|
|
||||||
tech_pvt->check_frames = MAX_CODEC_CHECK_FRAMES;
|
tech_pvt->check_frames = MAX_CODEC_CHECK_FRAMES;
|
||||||
|
|
||||||
|
switch_core_session_unlock_codec_write(session);
|
||||||
|
switch_core_session_unlock_codec_read(session);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1532,27 +1532,32 @@ switch_status_t sofia_glue_tech_set_video_codec(private_object_t *tech_pvt, int
|
||||||
switch_status_t sofia_glue_tech_set_codec(private_object_t *tech_pvt, int force)
|
switch_status_t sofia_glue_tech_set_codec(private_object_t *tech_pvt, int force)
|
||||||
{
|
{
|
||||||
int ms;
|
int ms;
|
||||||
|
switch_status_t status = SWITCH_STATUS_SUCCESS;
|
||||||
|
int resetting = 0;
|
||||||
|
|
||||||
if (!tech_pvt->iananame) {
|
if (!tech_pvt->iananame) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No audio codec available\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No audio codec available\n");
|
||||||
return SWITCH_STATUS_FALSE;
|
switch_goto_status(SWITCH_STATUS_FALSE, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tech_pvt->read_codec.implementation) {
|
if (tech_pvt->read_codec.implementation) {
|
||||||
if (!force) {
|
if (!force) {
|
||||||
return SWITCH_STATUS_SUCCESS;
|
switch_goto_status(SWITCH_STATUS_SUCCESS, end);
|
||||||
}
|
}
|
||||||
if (strcasecmp(tech_pvt->read_codec.implementation->iananame, tech_pvt->iananame) ||
|
if (strcasecmp(tech_pvt->read_codec.implementation->iananame, tech_pvt->iananame) ||
|
||||||
tech_pvt->read_codec.implementation->samples_per_second != tech_pvt->rm_rate) {
|
tech_pvt->read_codec.implementation->samples_per_second != tech_pvt->rm_rate) {
|
||||||
|
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Changing Codec from %s to %s\n",
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Changing Codec from %s to %s\n",
|
||||||
tech_pvt->read_codec.implementation->iananame, tech_pvt->rm_encoding);
|
tech_pvt->read_codec.implementation->iananame, tech_pvt->rm_encoding);
|
||||||
|
switch_core_session_lock_codec_write(tech_pvt->session);
|
||||||
|
switch_core_session_lock_codec_read(tech_pvt->session);
|
||||||
|
resetting = 1;
|
||||||
switch_core_codec_destroy(&tech_pvt->read_codec);
|
switch_core_codec_destroy(&tech_pvt->read_codec);
|
||||||
switch_core_codec_destroy(&tech_pvt->write_codec);
|
switch_core_codec_destroy(&tech_pvt->write_codec);
|
||||||
switch_core_session_reset(tech_pvt->session, SWITCH_TRUE);
|
switch_core_session_reset(tech_pvt->session, SWITCH_TRUE);
|
||||||
} else {
|
} else {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Already using %s\n", tech_pvt->read_codec.implementation->iananame);
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Already using %s\n", tech_pvt->read_codec.implementation->iananame);
|
||||||
return SWITCH_STATUS_SUCCESS;
|
switch_goto_status(SWITCH_STATUS_SUCCESS, end);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1565,7 +1570,7 @@ switch_status_t sofia_glue_tech_set_codec(private_object_t *tech_pvt, int force)
|
||||||
SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE | tech_pvt->profile->codec_flags,
|
SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE | tech_pvt->profile->codec_flags,
|
||||||
NULL, switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) {
|
NULL, switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n");
|
||||||
return SWITCH_STATUS_FALSE;
|
switch_goto_status(SWITCH_STATUS_FALSE, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (switch_core_codec_init(&tech_pvt->write_codec,
|
if (switch_core_codec_init(&tech_pvt->write_codec,
|
||||||
|
@ -1577,7 +1582,7 @@ switch_status_t sofia_glue_tech_set_codec(private_object_t *tech_pvt, int force)
|
||||||
SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE | tech_pvt->profile->codec_flags,
|
SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE | tech_pvt->profile->codec_flags,
|
||||||
NULL, switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) {
|
NULL, switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n");
|
||||||
return SWITCH_STATUS_FALSE;
|
switch_goto_status(SWITCH_STATUS_FALSE, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (switch_rtp_ready(tech_pvt->rtp_session)) {
|
if (switch_rtp_ready(tech_pvt->rtp_session)) {
|
||||||
|
@ -1590,7 +1595,7 @@ switch_status_t sofia_glue_tech_set_codec(private_object_t *tech_pvt, int force)
|
||||||
|
|
||||||
if (!tech_pvt->read_codec.implementation) {
|
if (!tech_pvt->read_codec.implementation) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n");
|
||||||
return SWITCH_STATUS_FALSE;
|
switch_goto_status(SWITCH_STATUS_FALSE, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Set Codec %s %s/%ld %d ms %d samples\n",
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Set Codec %s %s/%ld %d ms %d samples\n",
|
||||||
|
@ -1612,7 +1617,13 @@ switch_status_t sofia_glue_tech_set_codec(private_object_t *tech_pvt, int force)
|
||||||
switch_rtp_set_default_payload(tech_pvt->rtp_session, tech_pvt->pt);
|
switch_rtp_set_default_payload(tech_pvt->rtp_session, tech_pvt->pt);
|
||||||
}
|
}
|
||||||
|
|
||||||
return SWITCH_STATUS_SUCCESS;
|
end:
|
||||||
|
if (resetting) {
|
||||||
|
switch_core_session_unlock_codec_write(tech_pvt->session);
|
||||||
|
switch_core_session_unlock_codec_read(tech_pvt->session);
|
||||||
|
}
|
||||||
|
|
||||||
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -58,6 +58,26 @@ SWITCH_DECLARE(void) switch_core_session_unset_read_codec(switch_core_session_t
|
||||||
switch_mutex_unlock(session->codec_read_mutex);
|
switch_mutex_unlock(session->codec_read_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SWITCH_DECLARE(void) switch_core_session_lock_codec_write(switch_core_session_t *session)
|
||||||
|
{
|
||||||
|
switch_mutex_lock(session->codec_write_mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
SWITCH_DECLARE(void) switch_core_session_unlock_codec_write(switch_core_session_t *session)
|
||||||
|
{
|
||||||
|
switch_mutex_unlock(session->codec_write_mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
SWITCH_DECLARE(void) switch_core_session_lock_codec_read(switch_core_session_t *session)
|
||||||
|
{
|
||||||
|
switch_mutex_lock(session->codec_read_mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
SWITCH_DECLARE(void) switch_core_session_unlock_codec_read(switch_core_session_t *session)
|
||||||
|
{
|
||||||
|
switch_mutex_unlock(session->codec_read_mutex);
|
||||||
|
}
|
||||||
|
|
||||||
SWITCH_DECLARE(void) switch_core_session_unset_write_codec(switch_core_session_t *session)
|
SWITCH_DECLARE(void) switch_core_session_unset_write_codec(switch_core_session_t *session)
|
||||||
{
|
{
|
||||||
switch_mutex_t *mutex = NULL;
|
switch_mutex_t *mutex = NULL;
|
||||||
|
@ -550,6 +570,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_codec_destroy(switch_codec_t *codec)
|
||||||
{
|
{
|
||||||
switch_mutex_t *mutex;
|
switch_mutex_t *mutex;
|
||||||
switch_memory_pool_t *pool;
|
switch_memory_pool_t *pool;
|
||||||
|
int free_pool = 0;
|
||||||
|
|
||||||
switch_assert(codec != NULL);
|
switch_assert(codec != NULL);
|
||||||
|
|
||||||
|
@ -558,6 +579,10 @@ SWITCH_DECLARE(switch_status_t) switch_core_codec_destroy(switch_codec_t *codec)
|
||||||
return SWITCH_STATUS_NOT_INITALIZED;
|
return SWITCH_STATUS_NOT_INITALIZED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (switch_test_flag(codec, SWITCH_CODEC_FLAG_FREE_POOL)) {
|
||||||
|
free_pool = 1;
|
||||||
|
}
|
||||||
|
|
||||||
pool = codec->memory_pool;
|
pool = codec->memory_pool;
|
||||||
mutex = codec->mutex;
|
mutex = codec->mutex;
|
||||||
|
|
||||||
|
@ -571,7 +596,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_codec_destroy(switch_codec_t *codec)
|
||||||
|
|
||||||
if (mutex) switch_mutex_unlock(mutex);
|
if (mutex) switch_mutex_unlock(mutex);
|
||||||
|
|
||||||
if (switch_test_flag(codec, SWITCH_CODEC_FLAG_FREE_POOL)) {
|
if (free_pool) {
|
||||||
switch_core_destroy_memory_pool(&pool);
|
switch_core_destroy_memory_pool(&pool);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -643,7 +643,11 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_write_frame(switch_core_sess
|
||||||
do_resample = TRUE;
|
do_resample = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (need_codec) {
|
if (!need_codec) {
|
||||||
|
do_write = TRUE;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
if (!switch_test_flag(session, SSF_WARN_TRANSCODE)) {
|
if (!switch_test_flag(session, SSF_WARN_TRANSCODE)) {
|
||||||
switch_core_session_message_t msg = { 0 };
|
switch_core_session_message_t msg = { 0 };
|
||||||
|
|
||||||
|
@ -996,9 +1000,6 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_write_frame(switch_core_sess
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
do_write = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
done:
|
done:
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue