Merge pull request #756 in FS/freeswitch from bugfix/FS-8953-whitespace-cleanup-src-switch_-.c to master
* commit 'e18c12b6092114df9f6e149e49fc563858367c21': FS-8953 [core] white space clean up.
This commit is contained in:
commit
a107910907
|
@ -631,9 +631,9 @@ struct apr_threadattr_t {
|
||||||
/* this needs to be revisited when apr for windows supports thread priority settings */
|
/* this needs to be revisited when apr for windows supports thread priority settings */
|
||||||
/* search for WIN32 in this file */
|
/* search for WIN32 in this file */
|
||||||
struct apr_threadattr_t {
|
struct apr_threadattr_t {
|
||||||
apr_pool_t *pool;
|
apr_pool_t *pool;
|
||||||
apr_int32_t detach;
|
apr_int32_t detach;
|
||||||
apr_size_t stacksize;
|
apr_size_t stacksize;
|
||||||
int priority;
|
int priority;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
@ -802,13 +802,13 @@ SWITCH_DECLARE(switch_status_t) switch_sockaddr_create(switch_sockaddr_t **sa, s
|
||||||
new_sa->pool = pool;
|
new_sa->pool = pool;
|
||||||
memset(new_sa, 0, sizeof(*new_sa));
|
memset(new_sa, 0, sizeof(*new_sa));
|
||||||
|
|
||||||
new_sa->family = family;
|
new_sa->family = family;
|
||||||
new_sa->sa.sin.sin_family = family;
|
new_sa->sa.sin.sin_family = family;
|
||||||
|
|
||||||
new_sa->salen = sizeof(struct sockaddr_in);
|
new_sa->salen = sizeof(struct sockaddr_in);
|
||||||
new_sa->addr_str_len = 16;
|
new_sa->addr_str_len = 16;
|
||||||
new_sa->ipaddr_ptr = &(new_sa->sa.sin.sin_addr);
|
new_sa->ipaddr_ptr = &(new_sa->sa.sin.sin_addr);
|
||||||
new_sa->ipaddr_len = sizeof(struct in_addr);
|
new_sa->ipaddr_len = sizeof(struct in_addr);
|
||||||
|
|
||||||
*sa = new_sa;
|
*sa = new_sa;
|
||||||
return SWITCH_STATUS_SUCCESS;
|
return SWITCH_STATUS_SUCCESS;
|
||||||
|
@ -1310,7 +1310,7 @@ SWITCH_DECLARE(int) switch_atomic_dec(volatile switch_atomic_t *mem)
|
||||||
|
|
||||||
SWITCH_DECLARE(char *) switch_strerror(switch_status_t statcode, char *buf, switch_size_t bufsize)
|
SWITCH_DECLARE(char *) switch_strerror(switch_status_t statcode, char *buf, switch_size_t bufsize)
|
||||||
{
|
{
|
||||||
return apr_strerror(statcode, buf, bufsize);
|
return apr_strerror(statcode, buf, bufsize);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* For Emacs:
|
/* For Emacs:
|
||||||
|
|
|
@ -239,16 +239,16 @@ struct switch_callstate_table {
|
||||||
switch_channel_callstate_t callstate;
|
switch_channel_callstate_t callstate;
|
||||||
};
|
};
|
||||||
static struct switch_callstate_table CALLSTATE_CHART[] = {
|
static struct switch_callstate_table CALLSTATE_CHART[] = {
|
||||||
{"DOWN", CCS_DOWN},
|
{"DOWN", CCS_DOWN},
|
||||||
{"DIALING", CCS_DIALING},
|
{"DIALING", CCS_DIALING},
|
||||||
{"RINGING", CCS_RINGING},
|
{"RINGING", CCS_RINGING},
|
||||||
{"EARLY", CCS_EARLY},
|
{"EARLY", CCS_EARLY},
|
||||||
{"ACTIVE", CCS_ACTIVE},
|
{"ACTIVE", CCS_ACTIVE},
|
||||||
{"HELD", CCS_HELD},
|
{"HELD", CCS_HELD},
|
||||||
{"RING_WAIT", CCS_RING_WAIT},
|
{"RING_WAIT", CCS_RING_WAIT},
|
||||||
{"HANGUP", CCS_HANGUP},
|
{"HANGUP", CCS_HANGUP},
|
||||||
{"UNHELD", CCS_UNHELD},
|
{"UNHELD", CCS_UNHELD},
|
||||||
{NULL, 0}
|
{NULL, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct switch_device_state_table {
|
struct switch_device_state_table {
|
||||||
|
@ -256,14 +256,14 @@ struct switch_device_state_table {
|
||||||
switch_device_state_t device_state;
|
switch_device_state_t device_state;
|
||||||
};
|
};
|
||||||
static struct switch_device_state_table DEVICE_STATE_CHART[] = {
|
static struct switch_device_state_table DEVICE_STATE_CHART[] = {
|
||||||
{"DOWN", SDS_DOWN},
|
{"DOWN", SDS_DOWN},
|
||||||
{"RINGING", SDS_RINGING},
|
{"RINGING", SDS_RINGING},
|
||||||
{"ACTIVE", SDS_ACTIVE},
|
{"ACTIVE", SDS_ACTIVE},
|
||||||
{"ACTIVE_MULTI", SDS_ACTIVE_MULTI},
|
{"ACTIVE_MULTI", SDS_ACTIVE_MULTI},
|
||||||
{"HELD", SDS_HELD},
|
{"HELD", SDS_HELD},
|
||||||
{"UNHELD", SDS_UNHELD},
|
{"UNHELD", SDS_UNHELD},
|
||||||
{"HANGUP", SDS_HANGUP},
|
{"HANGUP", SDS_HANGUP},
|
||||||
{NULL, 0}
|
{NULL, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -348,7 +348,7 @@ SWITCH_DECLARE(const char *) switch_core_get_hostname(void)
|
||||||
|
|
||||||
SWITCH_DECLARE(const char *) switch_core_get_switchname(void)
|
SWITCH_DECLARE(const char *) switch_core_get_switchname(void)
|
||||||
{
|
{
|
||||||
if (!zstr(runtime.switchname)) return runtime.switchname;
|
if (!zstr(runtime.switchname)) return runtime.switchname;
|
||||||
return runtime.hostname;
|
return runtime.hostname;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2312,7 +2312,7 @@ static void switch_load_core_config(const char *file)
|
||||||
#endif
|
#endif
|
||||||
} else if (!strcasecmp(var, "switchname") && !zstr(val)) {
|
} else if (!strcasecmp(var, "switchname") && !zstr(val)) {
|
||||||
runtime.switchname = switch_core_strdup(runtime.memory_pool, val);
|
runtime.switchname = switch_core_strdup(runtime.memory_pool, val);
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Set switchname to %s\n", runtime.switchname);
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Set switchname to %s\n", runtime.switchname);
|
||||||
} else if (!strcasecmp(var, "rtp-retain-crypto-keys")) {
|
} else if (!strcasecmp(var, "rtp-retain-crypto-keys")) {
|
||||||
if (switch_true(val)) {
|
if (switch_true(val)) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
|
||||||
|
|
|
@ -110,8 +110,7 @@ static const EVP_MD *get_evp_by_name(const char *name)
|
||||||
* Solaris 10 with the Sun Studio compilers doesn't have strsep in the
|
* Solaris 10 with the Sun Studio compilers doesn't have strsep in the
|
||||||
* C library either.
|
* C library either.
|
||||||
*/
|
*/
|
||||||
char
|
char *strsep(char **stringp, const char *delim)
|
||||||
*strsep(char **stringp, const char *delim)
|
|
||||||
{
|
{
|
||||||
char *res;
|
char *res;
|
||||||
|
|
||||||
|
|
|
@ -116,7 +116,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(switch_core_sessi
|
||||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "%s has no read codec.\n", switch_channel_get_name(session->channel));
|
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "%s has no read codec.\n", switch_channel_get_name(session->channel));
|
||||||
switch_channel_hangup(session->channel, SWITCH_CAUSE_INCOMPATIBLE_DESTINATION);
|
switch_channel_hangup(session->channel, SWITCH_CAUSE_INCOMPATIBLE_DESTINATION);
|
||||||
*frame = &runtime.dummy_cng_frame;
|
*frame = &runtime.dummy_cng_frame;
|
||||||
return SWITCH_STATUS_FALSE;
|
return SWITCH_STATUS_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch_mutex_lock(session->read_codec->mutex);
|
switch_mutex_lock(session->read_codec->mutex);
|
||||||
|
@ -928,8 +928,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_frame(switch_core_sessi
|
||||||
even_more_done:
|
even_more_done:
|
||||||
|
|
||||||
if (!*frame ||
|
if (!*frame ||
|
||||||
(!switch_test_flag(*frame, SFF_PROXY_PACKET) &&
|
(!switch_test_flag(*frame, SFF_PROXY_PACKET) &&
|
||||||
(!(*frame)->codec || !(*frame)->codec->implementation || !switch_core_codec_ready((*frame)->codec)))) {
|
(!(*frame)->codec || !(*frame)->codec->implementation || !switch_core_codec_ready((*frame)->codec)))) {
|
||||||
*frame = &runtime.dummy_cng_frame;
|
*frame = &runtime.dummy_cng_frame;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -186,8 +186,8 @@ struct switch_media_handle_s {
|
||||||
switch_mutex_t *read_mutex[2];
|
switch_mutex_t *read_mutex[2];
|
||||||
switch_mutex_t *write_mutex[2];
|
switch_mutex_t *write_mutex[2];
|
||||||
char *codec_order[SWITCH_MAX_CODECS];
|
char *codec_order[SWITCH_MAX_CODECS];
|
||||||
int codec_order_last;
|
int codec_order_last;
|
||||||
const switch_codec_implementation_t *codecs[SWITCH_MAX_CODECS];
|
const switch_codec_implementation_t *codecs[SWITCH_MAX_CODECS];
|
||||||
|
|
||||||
int payload_space;
|
int payload_space;
|
||||||
char *origin;
|
char *origin;
|
||||||
|
@ -3829,16 +3829,16 @@ SWITCH_DECLARE(uint8_t) switch_core_media_negotiate_sdp(switch_core_session_t *s
|
||||||
char tmp[32] = "";
|
char tmp[32] = "";
|
||||||
|
|
||||||
|
|
||||||
if (!switch_channel_test_flag(other_channel, CF_ANSWERED)) {
|
if (!switch_channel_test_flag(other_channel, CF_ANSWERED)) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session),
|
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session),
|
||||||
SWITCH_LOG_WARNING, "%s Error Passing T.38 to unanswered channel %s\n",
|
SWITCH_LOG_WARNING, "%s Error Passing T.38 to unanswered channel %s\n",
|
||||||
switch_channel_get_name(session->channel), switch_channel_get_name(other_channel));
|
switch_channel_get_name(session->channel), switch_channel_get_name(other_channel));
|
||||||
switch_core_session_rwunlock(other_session);
|
switch_core_session_rwunlock(other_session);
|
||||||
|
|
||||||
pass = 0;
|
pass = 0;
|
||||||
match = 0;
|
match = 0;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (switch_true(switch_channel_get_variable(session->channel, "t38_broken_boolean")) &&
|
if (switch_true(switch_channel_get_variable(session->channel, "t38_broken_boolean")) &&
|
||||||
|
|
|
@ -1073,7 +1073,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_bug_enumerate(switch_core_sess
|
||||||
stream->write_function(stream, "<media-bugs>\n");
|
stream->write_function(stream, "<media-bugs>\n");
|
||||||
|
|
||||||
if (session->bugs) {
|
if (session->bugs) {
|
||||||
switch_thread_rwlock_rdlock(session->bug_rwlock);
|
switch_thread_rwlock_rdlock(session->bug_rwlock);
|
||||||
for (bp = session->bugs; bp; bp = bp->next) {
|
for (bp = session->bugs; bp; bp = bp->next) {
|
||||||
int thread_locked = (bp->thread_id && bp->thread_id == switch_thread_self());
|
int thread_locked = (bp->thread_id && bp->thread_id == switch_thread_self());
|
||||||
stream->write_function(stream,
|
stream->write_function(stream,
|
||||||
|
|
|
@ -315,7 +315,7 @@ SWITCH_DECLARE(void) switch_core_session_hupall_endpoint(const switch_endpoint_i
|
||||||
void *val;
|
void *val;
|
||||||
switch_core_session_t *session;
|
switch_core_session_t *session;
|
||||||
switch_memory_pool_t *pool;
|
switch_memory_pool_t *pool;
|
||||||
struct str_node *head = NULL, *np;
|
struct str_node *head = NULL, *np;
|
||||||
|
|
||||||
switch_core_new_memory_pool(&pool);
|
switch_core_new_memory_pool(&pool);
|
||||||
|
|
||||||
|
@ -327,8 +327,8 @@ SWITCH_DECLARE(void) switch_core_session_hupall_endpoint(const switch_endpoint_i
|
||||||
if (switch_core_session_read_lock(session) == SWITCH_STATUS_SUCCESS) {
|
if (switch_core_session_read_lock(session) == SWITCH_STATUS_SUCCESS) {
|
||||||
if (session->endpoint_interface == endpoint_interface) {
|
if (session->endpoint_interface == endpoint_interface) {
|
||||||
np = switch_core_alloc(pool, sizeof(*np));
|
np = switch_core_alloc(pool, sizeof(*np));
|
||||||
np->str = switch_core_strdup(pool, session->uuid_str);
|
np->str = switch_core_strdup(pool, session->uuid_str);
|
||||||
np->next = head;
|
np->next = head;
|
||||||
head = np;
|
head = np;
|
||||||
}
|
}
|
||||||
switch_core_session_rwunlock(session);
|
switch_core_session_rwunlock(session);
|
||||||
|
|
|
@ -3524,12 +3524,12 @@ switch_status_t switch_core_sqldb_start(switch_memory_pool_t *pool, switch_bool_
|
||||||
//runtime.odbc_dsn = NULL;
|
//runtime.odbc_dsn = NULL;
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Database Error [%s]\n", err);
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Database Error [%s]\n", err);
|
||||||
//switch_cache_db_release_db_handle(&sql_manager.dbh);
|
//switch_cache_db_release_db_handle(&sql_manager.dbh);
|
||||||
if (switch_stristr("read-only", err)) {
|
if (switch_stristr("read-only", err)) {
|
||||||
switch_safe_free(err);
|
switch_safe_free(err);
|
||||||
} else {
|
} else {
|
||||||
switch_safe_free(err);
|
switch_safe_free(err);
|
||||||
goto top;
|
goto top;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -60,76 +60,76 @@ static void switch_core_standard_on_hangup(switch_core_session_t *session)
|
||||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s Standard HANGUP, cause: %s\n",
|
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s Standard HANGUP, cause: %s\n",
|
||||||
switch_channel_get_name(session->channel), switch_channel_cause2str(switch_channel_get_cause(session->channel)));
|
switch_channel_get_name(session->channel), switch_channel_cause2str(switch_channel_get_cause(session->channel)));
|
||||||
|
|
||||||
if (switch_true(switch_channel_get_variable(session->channel, "log_audio_stats_on_hangup"))) {
|
if (switch_true(switch_channel_get_variable(session->channel, "log_audio_stats_on_hangup"))) {
|
||||||
switch_rtp_stats_t *audio_stats = NULL;
|
switch_rtp_stats_t *audio_stats = NULL;
|
||||||
|
|
||||||
switch_core_media_set_stats(session);
|
switch_core_media_set_stats(session);
|
||||||
audio_stats = switch_core_media_get_stats(session, SWITCH_MEDIA_TYPE_AUDIO, switch_core_session_get_pool(session));
|
audio_stats = switch_core_media_get_stats(session, SWITCH_MEDIA_TYPE_AUDIO, switch_core_session_get_pool(session));
|
||||||
if (audio_stats) {
|
if (audio_stats) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session),
|
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session),
|
||||||
SWITCH_LOG_DEBUG,
|
SWITCH_LOG_DEBUG,
|
||||||
"%s Call statistics:\n"
|
"%s Call statistics:\n"
|
||||||
"in_raw_bytes: %d\n"
|
"in_raw_bytes: %d\n"
|
||||||
"in_media_bytes: %d\n"
|
"in_media_bytes: %d\n"
|
||||||
"in_packet_count: %d\n"
|
"in_packet_count: %d\n"
|
||||||
"in_media_packet_count: %d\n"
|
"in_media_packet_count: %d\n"
|
||||||
"in_skip_packet_count: %d\n"
|
"in_skip_packet_count: %d\n"
|
||||||
"in_jitter_packet_count: %d\n"
|
"in_jitter_packet_count: %d\n"
|
||||||
"in_dtmf_packet_count: %d\n"
|
"in_dtmf_packet_count: %d\n"
|
||||||
"in_cng_packet_count: %d\n"
|
"in_cng_packet_count: %d\n"
|
||||||
"in_flush_packet_count: %d\n"
|
"in_flush_packet_count: %d\n"
|
||||||
"in_largest_jb_size: %d\n\n"
|
"in_largest_jb_size: %d\n\n"
|
||||||
"in_jitter_min_variance: %lf\n"
|
"in_jitter_min_variance: %lf\n"
|
||||||
"in_jitter_max_variance: %lf\n"
|
"in_jitter_max_variance: %lf\n"
|
||||||
"in_jitter_loss_rate: %lf\n"
|
"in_jitter_loss_rate: %lf\n"
|
||||||
"in_jitter_burst_rate: %lf\n"
|
"in_jitter_burst_rate: %lf\n"
|
||||||
"in_mean_interval: %lf\n\n"
|
"in_mean_interval: %lf\n\n"
|
||||||
"in_flaw_total: %d\n"
|
"in_flaw_total: %d\n"
|
||||||
"in_quality_percentage: %lf\n"
|
"in_quality_percentage: %lf\n"
|
||||||
"in_mos: %lf\n\n"
|
"in_mos: %lf\n\n"
|
||||||
"out_raw_bytes: %d\n"
|
"out_raw_bytes: %d\n"
|
||||||
"out_media_bytes: %d\n"
|
"out_media_bytes: %d\n"
|
||||||
"out_packet_count: %d\n"
|
"out_packet_count: %d\n"
|
||||||
"out_media_packet_count: %d\n"
|
"out_media_packet_count: %d\n"
|
||||||
"out_skip_packet_count: %d\n"
|
"out_skip_packet_count: %d\n"
|
||||||
"out_dtmf_packet_count: %d\n"
|
"out_dtmf_packet_count: %d\n"
|
||||||
"out_cng_packet_count: %d\n\n"
|
"out_cng_packet_count: %d\n\n"
|
||||||
"rtcp_packet_count: %d\n"
|
"rtcp_packet_count: %d\n"
|
||||||
"rtcp_octet_count: %d\n",
|
"rtcp_octet_count: %d\n",
|
||||||
switch_channel_get_name(session->channel),
|
switch_channel_get_name(session->channel),
|
||||||
(int)audio_stats->inbound.raw_bytes,
|
(int)audio_stats->inbound.raw_bytes,
|
||||||
(int)audio_stats->inbound.media_bytes,
|
(int)audio_stats->inbound.media_bytes,
|
||||||
(int)audio_stats->inbound.packet_count,
|
(int)audio_stats->inbound.packet_count,
|
||||||
(int)audio_stats->inbound.media_packet_count,
|
(int)audio_stats->inbound.media_packet_count,
|
||||||
(int)audio_stats->inbound.skip_packet_count,
|
(int)audio_stats->inbound.skip_packet_count,
|
||||||
(int)audio_stats->inbound.jb_packet_count,
|
(int)audio_stats->inbound.jb_packet_count,
|
||||||
(int)audio_stats->inbound.dtmf_packet_count,
|
(int)audio_stats->inbound.dtmf_packet_count,
|
||||||
(int)audio_stats->inbound.cng_packet_count,
|
(int)audio_stats->inbound.cng_packet_count,
|
||||||
(int)audio_stats->inbound.flush_packet_count,
|
(int)audio_stats->inbound.flush_packet_count,
|
||||||
(int)audio_stats->inbound.largest_jb_size,
|
(int)audio_stats->inbound.largest_jb_size,
|
||||||
audio_stats->inbound.min_variance,
|
audio_stats->inbound.min_variance,
|
||||||
audio_stats->inbound.max_variance,
|
audio_stats->inbound.max_variance,
|
||||||
audio_stats->inbound.lossrate,
|
audio_stats->inbound.lossrate,
|
||||||
audio_stats->inbound.burstrate,
|
audio_stats->inbound.burstrate,
|
||||||
audio_stats->inbound.mean_interval,
|
audio_stats->inbound.mean_interval,
|
||||||
(int)audio_stats->inbound.flaws,
|
(int)audio_stats->inbound.flaws,
|
||||||
audio_stats->inbound.R,
|
audio_stats->inbound.R,
|
||||||
audio_stats->inbound.mos,
|
audio_stats->inbound.mos,
|
||||||
(int)audio_stats->outbound.raw_bytes,
|
(int)audio_stats->outbound.raw_bytes,
|
||||||
(int)audio_stats->outbound.media_bytes,
|
(int)audio_stats->outbound.media_bytes,
|
||||||
(int)audio_stats->outbound.packet_count,
|
(int)audio_stats->outbound.packet_count,
|
||||||
(int)audio_stats->outbound.media_packet_count,
|
(int)audio_stats->outbound.media_packet_count,
|
||||||
(int)audio_stats->outbound.skip_packet_count,
|
(int)audio_stats->outbound.skip_packet_count,
|
||||||
(int)audio_stats->outbound.dtmf_packet_count,
|
(int)audio_stats->outbound.dtmf_packet_count,
|
||||||
(int)audio_stats->outbound.cng_packet_count,
|
(int)audio_stats->outbound.cng_packet_count,
|
||||||
(int)audio_stats->rtcp.packet_count,
|
(int)audio_stats->rtcp.packet_count,
|
||||||
(int)audio_stats->rtcp.octet_count
|
(int)audio_stats->rtcp.octet_count
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "%s Missing call statistics!\n",
|
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "%s Missing call statistics!\n",
|
||||||
switch_channel_get_name(session->channel));
|
switch_channel_get_name(session->channel));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rec = switch_channel_test_flag(session->channel, CF_RECOVERING);
|
rec = switch_channel_test_flag(session->channel, CF_RECOVERING);
|
||||||
switch_channel_clear_flag(session->channel, CF_RECOVERING);
|
switch_channel_clear_flag(session->channel, CF_RECOVERING);
|
||||||
|
|
|
@ -129,10 +129,10 @@ struct fit_el {
|
||||||
|
|
||||||
|
|
||||||
static struct fit_el IMG_FIT_TABLE[] = {
|
static struct fit_el IMG_FIT_TABLE[] = {
|
||||||
{SWITCH_FIT_SIZE, "fit-size"},
|
{SWITCH_FIT_SIZE, "fit-size"},
|
||||||
{SWITCH_FIT_SCALE, "fit-scale"},
|
{SWITCH_FIT_SCALE, "fit-scale"},
|
||||||
{SWITCH_FIT_SIZE_AND_SCALE, "fit-size-and-scale"},
|
{SWITCH_FIT_SIZE_AND_SCALE, "fit-size-and-scale"},
|
||||||
{SWITCH_FIT_NONE, NULL}
|
{SWITCH_FIT_NONE, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -813,9 +813,9 @@ SWITCH_DECLARE(switch_status_t) switch_img_txt_handle_create(switch_img_txt_hand
|
||||||
new_handle->pool = pool;
|
new_handle->pool = pool;
|
||||||
new_handle->free_pool = free_pool;
|
new_handle->free_pool = free_pool;
|
||||||
|
|
||||||
if (zstr(font_family)) {
|
if (zstr(font_family)) {
|
||||||
font_family = switch_core_sprintf(new_handle->pool, "%s%s%s",SWITCH_GLOBAL_dirs.fonts_dir, SWITCH_PATH_SEPARATOR, "FreeMono.ttf");
|
font_family = switch_core_sprintf(new_handle->pool, "%s%s%s",SWITCH_GLOBAL_dirs.fonts_dir, SWITCH_PATH_SEPARATOR, "FreeMono.ttf");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!switch_is_file_path(font_family)) {
|
if (!switch_is_file_path(font_family)) {
|
||||||
new_handle->font_family = switch_core_sprintf(new_handle->pool, "%s%s%s",SWITCH_GLOBAL_dirs.fonts_dir, SWITCH_PATH_SEPARATOR, font_family);
|
new_handle->font_family = switch_core_sprintf(new_handle->pool, "%s%s%s",SWITCH_GLOBAL_dirs.fonts_dir, SWITCH_PATH_SEPARATOR, font_family);
|
||||||
|
@ -910,7 +910,7 @@ static void draw_bitmap(switch_img_txt_handle_t *handle, switch_image_t *img, FT
|
||||||
case FT_PIXEL_MODE_LCD_V:
|
case FT_PIXEL_MODE_LCD_V:
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "unsupported pixel mode %d\n", bitmap->pixel_mode);
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "unsupported pixel mode %d\n", bitmap->pixel_mode);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( i = x, p = 0; i < x_max; i++, p++ ) {
|
for ( i = x, p = 0; i < x_max; i++, p++ ) {
|
||||||
for ( j = y, q = 0; j < y_max; j++, q++ ) {
|
for ( j = y, q = 0; j < y_max; j++, q++ ) {
|
||||||
|
@ -1081,11 +1081,11 @@ SWITCH_DECLARE(switch_image_t *) switch_img_write_text_img(int w, int h, switch_
|
||||||
char *txt = "Value Optimized Out!";
|
char *txt = "Value Optimized Out!";
|
||||||
int argc = 0;
|
int argc = 0;
|
||||||
char *argv[6] = { 0 };
|
char *argv[6] = { 0 };
|
||||||
switch_rgb_color_t bgcolor = { 0 };
|
switch_rgb_color_t bgcolor = { 0 };
|
||||||
int pre_width = 0, width = 0, font_size = 0, height = 0;
|
int pre_width = 0, width = 0, font_size = 0, height = 0;
|
||||||
int len = 0;
|
int len = 0;
|
||||||
char *duptxt = strdup(text);
|
char *duptxt = strdup(text);
|
||||||
switch_img_txt_handle_t *txthandle = NULL;
|
switch_img_txt_handle_t *txthandle = NULL;
|
||||||
switch_image_t *txtimg = NULL;
|
switch_image_t *txtimg = NULL;
|
||||||
int x = 0, y = 0;
|
int x = 0, y = 0;
|
||||||
|
|
||||||
|
@ -1124,15 +1124,15 @@ SWITCH_DECLARE(switch_image_t *) switch_img_write_text_img(int w, int h, switch_
|
||||||
while (*txt == ' ') txt++;
|
while (*txt == ' ') txt++;
|
||||||
while (end_of(txt) == ' ') end_of(txt) = '\0';
|
while (end_of(txt) == ' ') end_of(txt) = '\0';
|
||||||
|
|
||||||
len = strlen(txt);
|
len = strlen(txt);
|
||||||
|
|
||||||
if (len < 5) len = 5;
|
if (len < 5) len = 5;
|
||||||
|
|
||||||
|
|
||||||
switch_img_txt_handle_create(&txthandle, font_face, fg, bg, font_size, 0, NULL);
|
switch_img_txt_handle_create(&txthandle, font_face, fg, bg, font_size, 0, NULL);
|
||||||
switch_color_set_rgb(&bgcolor, bg);
|
switch_color_set_rgb(&bgcolor, bg);
|
||||||
|
|
||||||
pre_width = switch_img_txt_handle_render(txthandle,
|
pre_width = switch_img_txt_handle_render(txthandle,
|
||||||
NULL,
|
NULL,
|
||||||
font_size / 2, font_size / 2,
|
font_size / 2, font_size / 2,
|
||||||
txt, NULL, fg, bg, 0, 0);
|
txt, NULL, fg, bg, 0, 0);
|
||||||
|
@ -1162,10 +1162,10 @@ SWITCH_DECLARE(switch_image_t *) switch_img_write_text_img(int w, int h, switch_
|
||||||
x = (txtimg->d_w / 2) - (pre_width / 2);
|
x = (txtimg->d_w / 2) - (pre_width / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch_img_txt_handle_render(txthandle,
|
switch_img_txt_handle_render(txthandle,
|
||||||
txtimg,
|
txtimg,
|
||||||
x, y,
|
x, y,
|
||||||
txt, NULL, fg, bg, 0, 0);
|
txt, NULL, fg, bg, 0, 0);
|
||||||
switch_img_txt_handle_destroy(&txthandle);
|
switch_img_txt_handle_destroy(&txthandle);
|
||||||
|
|
||||||
switch_safe_free(duptxt);
|
switch_safe_free(duptxt);
|
||||||
|
@ -1974,9 +1974,9 @@ static inline uint32_t switch_img_fmt2fourcc(switch_img_fmt_t fmt)
|
||||||
case SWITCH_IMG_FMT_I44416: fourcc = FOURCC_ANY ; break;
|
case SWITCH_IMG_FMT_I44416: fourcc = FOURCC_ANY ; break;
|
||||||
case SWITCH_IMG_FMT_I44016: fourcc = FOURCC_ANY ; break;
|
case SWITCH_IMG_FMT_I44016: fourcc = FOURCC_ANY ; break;
|
||||||
default: fourcc = FOURCC_ANY;
|
default: fourcc = FOURCC_ANY;
|
||||||
}
|
}
|
||||||
|
|
||||||
return fourcc;
|
return fourcc;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -2032,14 +2032,14 @@ SWITCH_DECLARE(switch_status_t) switch_img_from_raw(switch_image_t *dest, void *
|
||||||
|
|
||||||
/*
|
/*
|
||||||
int ConvertToI420(const uint8* src_frame, size_t src_size,
|
int ConvertToI420(const uint8* src_frame, size_t src_size,
|
||||||
uint8* dst_y, int dst_stride_y,
|
uint8* dst_y, int dst_stride_y,
|
||||||
uint8* dst_u, int dst_stride_u,
|
uint8* dst_u, int dst_stride_u,
|
||||||
uint8* dst_v, int dst_stride_v,
|
uint8* dst_v, int dst_stride_v,
|
||||||
int crop_x, int crop_y,
|
int crop_x, int crop_y,
|
||||||
int src_width, int src_height,
|
int src_width, int src_height,
|
||||||
int crop_width, int crop_height,
|
int crop_width, int crop_height,
|
||||||
enum RotationMode rotation,
|
enum RotationMode rotation,
|
||||||
uint32 format);
|
uint32 format);
|
||||||
|
|
||||||
src_size is only used when FOURCC_MJPG which we don't support so always 0
|
src_size is only used when FOURCC_MJPG which we don't support so always 0
|
||||||
*/
|
*/
|
||||||
|
@ -2085,10 +2085,10 @@ SWITCH_DECLARE(switch_status_t) switch_img_scale(switch_image_t *src, switch_ima
|
||||||
kFilterBox);
|
kFilterBox);
|
||||||
} else if (src->fmt == SWITCH_IMG_FMT_ARGB) {
|
} else if (src->fmt == SWITCH_IMG_FMT_ARGB) {
|
||||||
ret = ARGBScale(src->planes[SWITCH_PLANE_PACKED], src->d_w * 4,
|
ret = ARGBScale(src->planes[SWITCH_PLANE_PACKED], src->d_w * 4,
|
||||||
src->d_w, src->d_h,
|
src->d_w, src->d_h,
|
||||||
dest->planes[SWITCH_PLANE_PACKED], width * 4,
|
dest->planes[SWITCH_PLANE_PACKED], width * 4,
|
||||||
width, height,
|
width, height,
|
||||||
kFilterBox);
|
kFilterBox);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
|
|
|
@ -57,33 +57,33 @@ switch_create_hashtable(switch_hashtable_t **hp, unsigned int minsize,
|
||||||
unsigned int (*hashf) (void*),
|
unsigned int (*hashf) (void*),
|
||||||
int (*eqf) (void*,void*))
|
int (*eqf) (void*,void*))
|
||||||
{
|
{
|
||||||
switch_hashtable_t *h;
|
switch_hashtable_t *h;
|
||||||
unsigned int pindex, size = primes[0];
|
unsigned int pindex, size = primes[0];
|
||||||
|
|
||||||
/* Check requested hashtable isn't too large */
|
/* Check requested hashtable isn't too large */
|
||||||
if (minsize > (1u << 30)) {*hp = NULL; return SWITCH_STATUS_FALSE;}
|
if (minsize > (1u << 30)) {*hp = NULL; return SWITCH_STATUS_FALSE;}
|
||||||
/* Enforce size as prime */
|
/* Enforce size as prime */
|
||||||
for (pindex=0; pindex < prime_table_length; pindex++) {
|
for (pindex=0; pindex < prime_table_length; pindex++) {
|
||||||
if (primes[pindex] > minsize) {
|
if (primes[pindex] > minsize) {
|
||||||
size = primes[pindex];
|
size = primes[pindex];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
h = (switch_hashtable_t *) malloc(sizeof(switch_hashtable_t));
|
h = (switch_hashtable_t *) malloc(sizeof(switch_hashtable_t));
|
||||||
|
|
||||||
if (NULL == h) abort(); /*oom*/
|
if (NULL == h) abort(); /*oom*/
|
||||||
|
|
||||||
h->table = (struct entry **)malloc(sizeof(struct entry*) * size);
|
h->table = (struct entry **)malloc(sizeof(struct entry*) * size);
|
||||||
|
|
||||||
if (NULL == h->table) abort(); /*oom*/
|
if (NULL == h->table) abort(); /*oom*/
|
||||||
|
|
||||||
memset(h->table, 0, size * sizeof(struct entry *));
|
memset(h->table, 0, size * sizeof(struct entry *));
|
||||||
h->tablelength = size;
|
h->tablelength = size;
|
||||||
h->primeindex = pindex;
|
h->primeindex = pindex;
|
||||||
h->entrycount = 0;
|
h->entrycount = 0;
|
||||||
h->hashfn = hashf;
|
h->hashfn = hashf;
|
||||||
h->eqfn = eqf;
|
h->eqfn = eqf;
|
||||||
h->loadlimit = (unsigned int) ceil(size * max_load_factor);
|
h->loadlimit = (unsigned int) ceil(size * max_load_factor);
|
||||||
|
|
||||||
*hp = h;
|
*hp = h;
|
||||||
return SWITCH_STATUS_SUCCESS;
|
return SWITCH_STATUS_SUCCESS;
|
||||||
|
@ -93,17 +93,17 @@ switch_create_hashtable(switch_hashtable_t **hp, unsigned int minsize,
|
||||||
static int
|
static int
|
||||||
hashtable_expand(switch_hashtable_t *h)
|
hashtable_expand(switch_hashtable_t *h)
|
||||||
{
|
{
|
||||||
/* Double the size of the table to accomodate more entries */
|
/* Double the size of the table to accomodate more entries */
|
||||||
struct entry **newtable;
|
struct entry **newtable;
|
||||||
struct entry *e;
|
struct entry *e;
|
||||||
struct entry **pE;
|
struct entry **pE;
|
||||||
unsigned int newsize, i, index;
|
unsigned int newsize, i, index;
|
||||||
/* Check we're not hitting max capacity */
|
/* Check we're not hitting max capacity */
|
||||||
if (h->primeindex == (prime_table_length - 1)) return 0;
|
if (h->primeindex == (prime_table_length - 1)) return 0;
|
||||||
newsize = primes[++(h->primeindex)];
|
newsize = primes[++(h->primeindex)];
|
||||||
|
|
||||||
newtable = (struct entry **)malloc(sizeof(struct entry*) * newsize);
|
newtable = (struct entry **)malloc(sizeof(struct entry*) * newsize);
|
||||||
if (NULL != newtable)
|
if (NULL != newtable)
|
||||||
{
|
{
|
||||||
memset(newtable, 0, newsize * sizeof(struct entry *));
|
memset(newtable, 0, newsize * sizeof(struct entry *));
|
||||||
/* This algorithm is not 'stable'. ie. it reverses the list
|
/* This algorithm is not 'stable'. ie. it reverses the list
|
||||||
|
@ -119,8 +119,8 @@ hashtable_expand(switch_hashtable_t *h)
|
||||||
switch_safe_free(h->table);
|
switch_safe_free(h->table);
|
||||||
h->table = newtable;
|
h->table = newtable;
|
||||||
}
|
}
|
||||||
/* Plan B: realloc instead */
|
/* Plan B: realloc instead */
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
newtable = (struct entry **)
|
newtable = (struct entry **)
|
||||||
realloc(h->table, newsize * sizeof(struct entry *));
|
realloc(h->table, newsize * sizeof(struct entry *));
|
||||||
|
@ -141,30 +141,30 @@ hashtable_expand(switch_hashtable_t *h)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
h->tablelength = newsize;
|
h->tablelength = newsize;
|
||||||
h->loadlimit = (unsigned int) ceil(newsize * max_load_factor);
|
h->loadlimit = (unsigned int) ceil(newsize * max_load_factor);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
SWITCH_DECLARE(unsigned int)
|
SWITCH_DECLARE(unsigned int)
|
||||||
switch_hashtable_count(switch_hashtable_t *h)
|
switch_hashtable_count(switch_hashtable_t *h)
|
||||||
{
|
{
|
||||||
return h->entrycount;
|
return h->entrycount;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void * _switch_hashtable_remove(switch_hashtable_t *h, void *k, unsigned int hashvalue, unsigned int index) {
|
static void * _switch_hashtable_remove(switch_hashtable_t *h, void *k, unsigned int hashvalue, unsigned int index) {
|
||||||
/* TODO: consider compacting the table when the load factor drops enough,
|
/* TODO: consider compacting the table when the load factor drops enough,
|
||||||
* or provide a 'compact' method. */
|
* or provide a 'compact' method. */
|
||||||
|
|
||||||
struct entry *e;
|
struct entry *e;
|
||||||
struct entry **pE;
|
struct entry **pE;
|
||||||
void *v;
|
void *v;
|
||||||
|
|
||||||
|
|
||||||
pE = &(h->table[index]);
|
pE = &(h->table[index]);
|
||||||
e = *pE;
|
e = *pE;
|
||||||
while (NULL != e) {
|
while (NULL != e) {
|
||||||
/* Check hash value to short circuit heavier comparison */
|
/* Check hash value to short circuit heavier comparison */
|
||||||
if ((hashvalue == e->h) && (h->eqfn(k, e->k))) {
|
if ((hashvalue == e->h) && (h->eqfn(k, e->k))) {
|
||||||
*pE = e->next;
|
*pE = e->next;
|
||||||
|
@ -186,22 +186,22 @@ static void * _switch_hashtable_remove(switch_hashtable_t *h, void *k, unsigned
|
||||||
pE = &(e->next);
|
pE = &(e->next);
|
||||||
e = e->next;
|
e = e->next;
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
SWITCH_DECLARE(int)
|
SWITCH_DECLARE(int)
|
||||||
switch_hashtable_insert_destructor(switch_hashtable_t *h, void *k, void *v, hashtable_flag_t flags, hashtable_destructor_t destructor)
|
switch_hashtable_insert_destructor(switch_hashtable_t *h, void *k, void *v, hashtable_flag_t flags, hashtable_destructor_t destructor)
|
||||||
{
|
{
|
||||||
struct entry *e;
|
struct entry *e;
|
||||||
unsigned int hashvalue = hash(h, k);
|
unsigned int hashvalue = hash(h, k);
|
||||||
unsigned index = indexFor(h->tablelength, hashvalue);
|
unsigned index = indexFor(h->tablelength, hashvalue);
|
||||||
|
|
||||||
if (flags & HASHTABLE_DUP_CHECK) {
|
if (flags & HASHTABLE_DUP_CHECK) {
|
||||||
_switch_hashtable_remove(h, k, hashvalue, index);
|
_switch_hashtable_remove(h, k, hashvalue, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (++(h->entrycount) > h->loadlimit)
|
if (++(h->entrycount) > h->loadlimit)
|
||||||
{
|
{
|
||||||
/* Ignore the return value. If expand fails, we should
|
/* Ignore the return value. If expand fails, we should
|
||||||
* still try cramming just this value into the existing table
|
* still try cramming just this value into the existing table
|
||||||
|
@ -210,33 +210,33 @@ switch_hashtable_insert_destructor(switch_hashtable_t *h, void *k, void *v, hash
|
||||||
hashtable_expand(h);
|
hashtable_expand(h);
|
||||||
index = indexFor(h->tablelength, hashvalue);
|
index = indexFor(h->tablelength, hashvalue);
|
||||||
}
|
}
|
||||||
e = (struct entry *)malloc(sizeof(struct entry));
|
e = (struct entry *)malloc(sizeof(struct entry));
|
||||||
if (NULL == e) { --(h->entrycount); return 0; } /*oom*/
|
if (NULL == e) { --(h->entrycount); return 0; } /*oom*/
|
||||||
e->h = hashvalue;
|
e->h = hashvalue;
|
||||||
e->k = k;
|
e->k = k;
|
||||||
e->v = v;
|
e->v = v;
|
||||||
e->flags = flags;
|
e->flags = flags;
|
||||||
e->destructor = destructor;
|
e->destructor = destructor;
|
||||||
e->next = h->table[index];
|
e->next = h->table[index];
|
||||||
h->table[index] = e;
|
h->table[index] = e;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
SWITCH_DECLARE(void *) /* returns value associated with key */
|
SWITCH_DECLARE(void *) /* returns value associated with key */
|
||||||
switch_hashtable_search(switch_hashtable_t *h, void *k)
|
switch_hashtable_search(switch_hashtable_t *h, void *k)
|
||||||
{
|
{
|
||||||
struct entry *e;
|
struct entry *e;
|
||||||
unsigned int hashvalue, index;
|
unsigned int hashvalue, index;
|
||||||
hashvalue = hash(h,k);
|
hashvalue = hash(h,k);
|
||||||
index = indexFor(h->tablelength,hashvalue);
|
index = indexFor(h->tablelength,hashvalue);
|
||||||
e = h->table[index];
|
e = h->table[index];
|
||||||
while (NULL != e) {
|
while (NULL != e) {
|
||||||
/* Check hash value to short circuit heavier comparison */
|
/* Check hash value to short circuit heavier comparison */
|
||||||
if ((hashvalue == e->h) && (h->eqfn(k, e->k))) return e->v;
|
if ((hashvalue == e->h) && (h->eqfn(k, e->k))) return e->v;
|
||||||
e = e->next;
|
e = e->next;
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -252,9 +252,9 @@ switch_hashtable_remove(switch_hashtable_t *h, void *k)
|
||||||
SWITCH_DECLARE(void)
|
SWITCH_DECLARE(void)
|
||||||
switch_hashtable_destroy(switch_hashtable_t **h)
|
switch_hashtable_destroy(switch_hashtable_t **h)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
struct entry *e, *f;
|
struct entry *e, *f;
|
||||||
struct entry **table = (*h)->table;
|
struct entry **table = (*h)->table;
|
||||||
|
|
||||||
for (i = 0; i < (*h)->tablelength; i++) {
|
for (i = 0; i < (*h)->tablelength; i++) {
|
||||||
e = table[i];
|
e = table[i];
|
||||||
|
@ -275,7 +275,7 @@ switch_hashtable_destroy(switch_hashtable_t **h)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch_safe_free((*h)->table);
|
switch_safe_free((*h)->table);
|
||||||
free(*h);
|
free(*h);
|
||||||
*h = NULL;
|
*h = NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1848,8 +1848,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_3p_nomedia(const char *uuid, switch_m
|
||||||
}
|
}
|
||||||
|
|
||||||
if (switch_core_session_in_thread(session)) {
|
if (switch_core_session_in_thread(session)) {
|
||||||
switch_yield(100000);
|
switch_yield(100000);
|
||||||
} else {
|
} else {
|
||||||
switch_channel_wait_for_state(other_channel, channel, CS_HIBERNATE);
|
switch_channel_wait_for_state(other_channel, channel, CS_HIBERNATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1948,8 +1948,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_nomedia(const char *uuid, switch_medi
|
||||||
}
|
}
|
||||||
|
|
||||||
if (switch_core_session_in_thread(session)) {
|
if (switch_core_session_in_thread(session)) {
|
||||||
switch_yield(100000);
|
switch_yield(100000);
|
||||||
} else {
|
} else {
|
||||||
switch_channel_wait_for_state(other_channel, channel, CS_HIBERNATE);
|
switch_channel_wait_for_state(other_channel, channel, CS_HIBERNATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3820,9 +3820,9 @@ SWITCH_DECLARE(switch_bool_t) switch_ivr_uuid_force_exists(const char *uuid)
|
||||||
|
|
||||||
SWITCH_DECLARE(switch_status_t) switch_ivr_process_fh(switch_core_session_t *session, const char *cmd, switch_file_handle_t *fhp)
|
SWITCH_DECLARE(switch_status_t) switch_ivr_process_fh(switch_core_session_t *session, const char *cmd, switch_file_handle_t *fhp)
|
||||||
{
|
{
|
||||||
if (zstr(cmd)) {
|
if (zstr(cmd)) {
|
||||||
return SWITCH_STATUS_SUCCESS;
|
return SWITCH_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fhp) {
|
if (fhp) {
|
||||||
if (!switch_test_flag(fhp, SWITCH_FILE_OPEN)) {
|
if (!switch_test_flag(fhp, SWITCH_FILE_OPEN)) {
|
||||||
|
@ -3926,11 +3926,11 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_process_fh(switch_core_session_t *ses
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!strcmp(cmd, "true") || !strcmp(cmd, "undefined")) {
|
if (!strcmp(cmd, "true") || !strcmp(cmd, "undefined")) {
|
||||||
return SWITCH_STATUS_SUCCESS;
|
return SWITCH_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
return SWITCH_STATUS_FALSE;
|
return SWITCH_STATUS_FALSE;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5096,16 +5096,16 @@ static switch_bool_t video_write_overlay_callback(switch_media_bug_t *bug, void
|
||||||
switch_core_session_t *session = switch_core_media_bug_get_session(bug);
|
switch_core_session_t *session = switch_core_media_bug_get_session(bug);
|
||||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case SWITCH_ABC_TYPE_INIT:
|
case SWITCH_ABC_TYPE_INIT:
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SWITCH_ABC_TYPE_CLOSE:
|
case SWITCH_ABC_TYPE_CLOSE:
|
||||||
{
|
{
|
||||||
switch_img_free(&oht->img);
|
switch_img_free(&oht->img);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SWITCH_ABC_TYPE_WRITE_VIDEO_PING:
|
case SWITCH_ABC_TYPE_WRITE_VIDEO_PING:
|
||||||
if (switch_channel_test_flag(channel, CF_VIDEO_DECODED_READ)) {
|
if (switch_channel_test_flag(channel, CF_VIDEO_DECODED_READ)) {
|
||||||
switch_frame_t *frame = switch_core_media_bug_get_video_ping_frame(bug);
|
switch_frame_t *frame = switch_core_media_bug_get_video_ping_frame(bug);
|
||||||
|
@ -5121,12 +5121,12 @@ static switch_bool_t video_write_overlay_callback(switch_media_bug_t *bug, void
|
||||||
switch_img_free(&oimg);
|
switch_img_free(&oimg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return SWITCH_TRUE;
|
return SWITCH_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -5150,7 +5150,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_video_write_overlay_session(switch_co
|
||||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||||
switch_status_t status;
|
switch_status_t status;
|
||||||
switch_media_bug_flag_t bflags = SMBF_WRITE_VIDEO_PING;
|
switch_media_bug_flag_t bflags = SMBF_WRITE_VIDEO_PING;
|
||||||
switch_media_bug_t *bug;
|
switch_media_bug_t *bug;
|
||||||
overly_helper_t *oht;
|
overly_helper_t *oht;
|
||||||
switch_image_t *img;
|
switch_image_t *img;
|
||||||
|
|
||||||
|
|
|
@ -1026,7 +1026,7 @@ static switch_status_t uuid_bridge_on_soft_execute(switch_core_session_t *sessio
|
||||||
if (switch_ivr_wait_for_answer(session, other_session) != SWITCH_STATUS_SUCCESS) {
|
if (switch_ivr_wait_for_answer(session, other_session) != SWITCH_STATUS_SUCCESS) {
|
||||||
if (switch_true(switch_channel_get_variable(channel, "uuid_bridge_continue_on_cancel"))) {
|
if (switch_true(switch_channel_get_variable(channel, "uuid_bridge_continue_on_cancel"))) {
|
||||||
switch_channel_set_state(channel, CS_EXECUTE);
|
switch_channel_set_state(channel, CS_EXECUTE);
|
||||||
} else if (switch_true(switch_channel_get_variable(channel, "uuid_bridge_park_on_cancel"))) {
|
} else if (switch_true(switch_channel_get_variable(channel, "uuid_bridge_park_on_cancel"))) {
|
||||||
switch_ivr_park_session(session);
|
switch_ivr_park_session(session);
|
||||||
} else if (!switch_channel_test_flag(channel, CF_TRANSFER)) {
|
} else if (!switch_channel_test_flag(channel, CF_TRANSFER)) {
|
||||||
switch_channel_hangup(channel, SWITCH_CAUSE_ORIGINATOR_CANCEL);
|
switch_channel_hangup(channel, SWITCH_CAUSE_ORIGINATOR_CANCEL);
|
||||||
|
@ -1700,7 +1700,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_multi_threaded_bridge(switch_core_ses
|
||||||
switch_call_cause_t cause = switch_channel_get_cause(peer_channel);
|
switch_call_cause_t cause = switch_channel_get_cause(peer_channel);
|
||||||
const char *hup = switch_channel_get_variable(caller_channel, SWITCH_HANGUP_AFTER_BRIDGE_VARIABLE);
|
const char *hup = switch_channel_get_variable(caller_channel, SWITCH_HANGUP_AFTER_BRIDGE_VARIABLE);
|
||||||
int explicit = 0;
|
int explicit = 0;
|
||||||
int answered = 0;
|
int answered = 0;
|
||||||
int early = 0;
|
int early = 0;
|
||||||
|
|
||||||
if (cause == SWITCH_CAUSE_NONE) {
|
if (cause == SWITCH_CAUSE_NONE) {
|
||||||
|
|
|
@ -59,23 +59,23 @@ static void (*cJSON_free)(void *ptr) = glue_free;
|
||||||
|
|
||||||
static char* cJSON_strdup(const char* str)
|
static char* cJSON_strdup(const char* str)
|
||||||
{
|
{
|
||||||
size_t len;
|
size_t len;
|
||||||
char* copy;
|
char* copy;
|
||||||
const char *s = str ? str : "";
|
const char *s = str ? str : "";
|
||||||
|
|
||||||
len = strlen(s) + 1;
|
len = strlen(s) + 1;
|
||||||
if (!(copy = (char*)cJSON_malloc(len))) return 0;
|
if (!(copy = (char*)cJSON_malloc(len))) return 0;
|
||||||
memcpy(copy,s,len);
|
memcpy(copy,s,len);
|
||||||
return copy;
|
return copy;
|
||||||
}
|
}
|
||||||
|
|
||||||
SWITCH_DECLARE(void)cJSON_InitHooks(cJSON_Hooks* hooks)
|
SWITCH_DECLARE(void)cJSON_InitHooks(cJSON_Hooks* hooks)
|
||||||
{
|
{
|
||||||
if (!hooks) { /* Reset hooks */
|
if (!hooks) { /* Reset hooks */
|
||||||
cJSON_malloc = malloc;
|
cJSON_malloc = malloc;
|
||||||
cJSON_free = free;
|
cJSON_free = free;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
cJSON_malloc = (hooks->malloc_fn)?hooks->malloc_fn:malloc;
|
cJSON_malloc = (hooks->malloc_fn)?hooks->malloc_fn:malloc;
|
||||||
cJSON_free = (hooks->free_fn)?hooks->free_fn:free;
|
cJSON_free = (hooks->free_fn)?hooks->free_fn:free;
|
||||||
|
|
432
src/switch_pcm.c
432
src/switch_pcm.c
|
@ -470,23 +470,23 @@ SWITCH_MODULE_LOAD_FUNCTION(core_pcm_load)
|
||||||
switch_raw_decode, /* function to decode encoded data into raw data */
|
switch_raw_decode, /* function to decode encoded data into raw data */
|
||||||
switch_raw_destroy); /* deinitalize a codec handle using this implementation */
|
switch_raw_destroy); /* deinitalize a codec handle using this implementation */
|
||||||
|
|
||||||
switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */
|
switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */
|
||||||
100, /* the IANA code number */
|
100, /* the IANA code number */
|
||||||
"L16", /* the IANA code name */
|
"L16", /* the IANA code name */
|
||||||
NULL, /* default fmtp to send (can be overridden by the init function) */
|
NULL, /* default fmtp to send (can be overridden by the init function) */
|
||||||
12000, /* samples transferred per second */
|
12000, /* samples transferred per second */
|
||||||
12000, /* actual samples transferred per second */
|
12000, /* actual samples transferred per second */
|
||||||
192000 * 2, /* bits transferred per second */
|
192000 * 2, /* bits transferred per second */
|
||||||
ms_per_frame, /* number of microseconds per frame */
|
ms_per_frame, /* number of microseconds per frame */
|
||||||
samples_per_frame, /* number of samples per frame */
|
samples_per_frame, /* number of samples per frame */
|
||||||
bytes_per_frame * 2, /* number of bytes per frame decompressed */
|
bytes_per_frame * 2, /* number of bytes per frame decompressed */
|
||||||
bytes_per_frame * 2, /* number of bytes per frame compressed */
|
bytes_per_frame * 2, /* number of bytes per frame compressed */
|
||||||
2, /* number of channels represented */
|
2, /* number of channels represented */
|
||||||
1, /* number of frames per network packet */
|
1, /* number of frames per network packet */
|
||||||
switch_raw_init, /* function to initialize a codec handle using this implementation */
|
switch_raw_init, /* function to initialize a codec handle using this implementation */
|
||||||
switch_raw_encode, /* function to encode raw data into encoded data */
|
switch_raw_encode, /* function to encode raw data into encoded data */
|
||||||
switch_raw_decode, /* function to decode encoded data into raw data */
|
switch_raw_decode, /* function to decode encoded data into raw data */
|
||||||
switch_raw_destroy); /* deinitalize a codec handle using this implementation */
|
switch_raw_destroy); /* deinitalize a codec handle using this implementation */
|
||||||
|
|
||||||
samples_per_frame += 240;
|
samples_per_frame += 240;
|
||||||
bytes_per_frame += 480;
|
bytes_per_frame += 480;
|
||||||
|
@ -517,23 +517,23 @@ SWITCH_MODULE_LOAD_FUNCTION(core_pcm_load)
|
||||||
switch_raw_decode, /* function to decode encoded data into raw data */
|
switch_raw_decode, /* function to decode encoded data into raw data */
|
||||||
switch_raw_destroy); /* deinitalize a codec handle using this implementation */
|
switch_raw_destroy); /* deinitalize a codec handle using this implementation */
|
||||||
|
|
||||||
switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */
|
switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */
|
||||||
100, /* the IANA code number */
|
100, /* the IANA code number */
|
||||||
"L16", /* the IANA code name */
|
"L16", /* the IANA code name */
|
||||||
NULL, /* default fmtp to send (can be overridden by the init function) */
|
NULL, /* default fmtp to send (can be overridden by the init function) */
|
||||||
24000, /* samples transferred per second */
|
24000, /* samples transferred per second */
|
||||||
24000, /* actual samples transferred per second */
|
24000, /* actual samples transferred per second */
|
||||||
384000 * 2, /* bits transferred per second */
|
384000 * 2, /* bits transferred per second */
|
||||||
ms_per_frame, /* number of microseconds per frame */
|
ms_per_frame, /* number of microseconds per frame */
|
||||||
samples_per_frame, /* number of samples per frame */
|
samples_per_frame, /* number of samples per frame */
|
||||||
bytes_per_frame * 2, /* number of bytes per frame decompressed */
|
bytes_per_frame * 2, /* number of bytes per frame decompressed */
|
||||||
bytes_per_frame * 2, /* number of bytes per frame compressed */
|
bytes_per_frame * 2, /* number of bytes per frame compressed */
|
||||||
2, /* number of channels represented */
|
2, /* number of channels represented */
|
||||||
1, /* number of frames per network packet */
|
1, /* number of frames per network packet */
|
||||||
switch_raw_init, /* function to initialize a codec handle using this implementation */
|
switch_raw_init, /* function to initialize a codec handle using this implementation */
|
||||||
switch_raw_encode, /* function to encode raw data into encoded data */
|
switch_raw_encode, /* function to encode raw data into encoded data */
|
||||||
switch_raw_decode, /* function to decode encoded data into raw data */
|
switch_raw_decode, /* function to decode encoded data into raw data */
|
||||||
switch_raw_destroy); /* deinitalize a codec handle using this implementation */
|
switch_raw_destroy); /* deinitalize a codec handle using this implementation */
|
||||||
|
|
||||||
samples_per_frame += 480;
|
samples_per_frame += 480;
|
||||||
bytes_per_frame += 960;
|
bytes_per_frame += 960;
|
||||||
|
@ -614,23 +614,23 @@ SWITCH_MODULE_LOAD_FUNCTION(core_pcm_load)
|
||||||
switch_raw_decode, /* function to decode encoded data into raw data */
|
switch_raw_decode, /* function to decode encoded data into raw data */
|
||||||
switch_raw_destroy); /* deinitalize a codec handle using this implementation */
|
switch_raw_destroy); /* deinitalize a codec handle using this implementation */
|
||||||
|
|
||||||
switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */
|
switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */
|
||||||
100, /* the IANA code number */
|
100, /* the IANA code number */
|
||||||
"L16", /* the IANA code name */
|
"L16", /* the IANA code name */
|
||||||
NULL, /* default fmtp to send (can be overridden by the init function) */
|
NULL, /* default fmtp to send (can be overridden by the init function) */
|
||||||
8000, /* samples transferred per second */
|
8000, /* samples transferred per second */
|
||||||
8000, /* actual samples transferred per second */
|
8000, /* actual samples transferred per second */
|
||||||
128000 * 2, /* bits transferred per second */
|
128000 * 2, /* bits transferred per second */
|
||||||
ms_per_frame, /* number of microseconds per frame */
|
ms_per_frame, /* number of microseconds per frame */
|
||||||
samples_per_frame, /* number of samples per frame */
|
samples_per_frame, /* number of samples per frame */
|
||||||
bytes_per_frame * 2, /* number of bytes per frame decompressed */
|
bytes_per_frame * 2, /* number of bytes per frame decompressed */
|
||||||
bytes_per_frame * 2, /* number of bytes per frame compressed */
|
bytes_per_frame * 2, /* number of bytes per frame compressed */
|
||||||
2, /* number of channels represented */
|
2, /* number of channels represented */
|
||||||
1, /* number of frames per network packet */
|
1, /* number of frames per network packet */
|
||||||
switch_raw_init, /* function to initialize a codec handle using this implementation */
|
switch_raw_init, /* function to initialize a codec handle using this implementation */
|
||||||
switch_raw_encode, /* function to encode raw data into encoded data */
|
switch_raw_encode, /* function to encode raw data into encoded data */
|
||||||
switch_raw_decode, /* function to decode encoded data into raw data */
|
switch_raw_decode, /* function to decode encoded data into raw data */
|
||||||
switch_raw_destroy); /* deinitalize a codec handle using this implementation */
|
switch_raw_destroy); /* deinitalize a codec handle using this implementation */
|
||||||
|
|
||||||
samples_per_frame += 16;
|
samples_per_frame += 16;
|
||||||
bytes_per_frame += 32;
|
bytes_per_frame += 32;
|
||||||
|
@ -661,23 +661,23 @@ SWITCH_MODULE_LOAD_FUNCTION(core_pcm_load)
|
||||||
switch_raw_decode, /* function to decode encoded data into raw data */
|
switch_raw_decode, /* function to decode encoded data into raw data */
|
||||||
switch_raw_destroy); /* deinitalize a codec handle using this implementation */
|
switch_raw_destroy); /* deinitalize a codec handle using this implementation */
|
||||||
|
|
||||||
switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */
|
switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */
|
||||||
100, /* the IANA code number */
|
100, /* the IANA code number */
|
||||||
"L16", /* the IANA code name */
|
"L16", /* the IANA code name */
|
||||||
NULL, /* default fmtp to send (can be overridden by the init function) */
|
NULL, /* default fmtp to send (can be overridden by the init function) */
|
||||||
16000, /* samples transferred per second */
|
16000, /* samples transferred per second */
|
||||||
16000, /* actual samples transferred per second */
|
16000, /* actual samples transferred per second */
|
||||||
256000 * 2, /* bits transferred per second */
|
256000 * 2, /* bits transferred per second */
|
||||||
ms_per_frame, /* number of microseconds per frame */
|
ms_per_frame, /* number of microseconds per frame */
|
||||||
samples_per_frame, /* number of samples per frame */
|
samples_per_frame, /* number of samples per frame */
|
||||||
bytes_per_frame * 2, /* number of bytes per frame decompressed */
|
bytes_per_frame * 2, /* number of bytes per frame decompressed */
|
||||||
bytes_per_frame * 2, /* number of bytes per frame compressed */
|
bytes_per_frame * 2, /* number of bytes per frame compressed */
|
||||||
2, /* number of channels represented */
|
2, /* number of channels represented */
|
||||||
1, /* number of frames per network packet */
|
1, /* number of frames per network packet */
|
||||||
switch_raw_init, /* function to initialize a codec handle using this implementation */
|
switch_raw_init, /* function to initialize a codec handle using this implementation */
|
||||||
switch_raw_encode, /* function to encode raw data into encoded data */
|
switch_raw_encode, /* function to encode raw data into encoded data */
|
||||||
switch_raw_decode, /* function to decode encoded data into raw data */
|
switch_raw_decode, /* function to decode encoded data into raw data */
|
||||||
switch_raw_destroy); /* deinitalize a codec handle using this implementation */
|
switch_raw_destroy); /* deinitalize a codec handle using this implementation */
|
||||||
|
|
||||||
samples_per_frame += 32;
|
samples_per_frame += 32;
|
||||||
bytes_per_frame += 64;
|
bytes_per_frame += 64;
|
||||||
|
@ -709,23 +709,23 @@ SWITCH_MODULE_LOAD_FUNCTION(core_pcm_load)
|
||||||
switch_raw_decode, /* function to decode encoded data into raw data */
|
switch_raw_decode, /* function to decode encoded data into raw data */
|
||||||
switch_raw_destroy); /* deinitalize a codec handle using this implementation */
|
switch_raw_destroy); /* deinitalize a codec handle using this implementation */
|
||||||
|
|
||||||
switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */
|
switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */
|
||||||
100, /* the IANA code number */
|
100, /* the IANA code number */
|
||||||
"L16", /* the IANA code name */
|
"L16", /* the IANA code name */
|
||||||
NULL, /* default fmtp to send (can be overridden by the init function) */
|
NULL, /* default fmtp to send (can be overridden by the init function) */
|
||||||
32000, /* samples transferred per second */
|
32000, /* samples transferred per second */
|
||||||
32000, /* actual samples transferred per second */
|
32000, /* actual samples transferred per second */
|
||||||
512000 * 2, /* bits transferred per second */
|
512000 * 2, /* bits transferred per second */
|
||||||
ms_per_frame, /* number of microseconds per frame */
|
ms_per_frame, /* number of microseconds per frame */
|
||||||
samples_per_frame, /* number of samples per frame */
|
samples_per_frame, /* number of samples per frame */
|
||||||
bytes_per_frame * 2, /* number of bytes per frame decompressed */
|
bytes_per_frame * 2, /* number of bytes per frame decompressed */
|
||||||
bytes_per_frame * 2, /* number of bytes per frame compressed */
|
bytes_per_frame * 2, /* number of bytes per frame compressed */
|
||||||
2, /* number of channels represented */
|
2, /* number of channels represented */
|
||||||
1, /* number of frames per network packet */
|
1, /* number of frames per network packet */
|
||||||
switch_raw_init, /* function to initialize a codec handle using this implementation */
|
switch_raw_init, /* function to initialize a codec handle using this implementation */
|
||||||
switch_raw_encode, /* function to encode raw data into encoded data */
|
switch_raw_encode, /* function to encode raw data into encoded data */
|
||||||
switch_raw_decode, /* function to decode encoded data into raw data */
|
switch_raw_decode, /* function to decode encoded data into raw data */
|
||||||
switch_raw_destroy); /* deinitalize a codec handle using this implementation */
|
switch_raw_destroy); /* deinitalize a codec handle using this implementation */
|
||||||
|
|
||||||
samples_per_frame += 64;
|
samples_per_frame += 64;
|
||||||
bytes_per_frame += 128;
|
bytes_per_frame += 128;
|
||||||
|
@ -785,40 +785,40 @@ SWITCH_MODULE_LOAD_FUNCTION(core_pcm_load)
|
||||||
|
|
||||||
for (x = 0; x < 3; x++) {
|
for (x = 0; x < 3; x++) {
|
||||||
switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */
|
switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */
|
||||||
100, /* the IANA code number */
|
100, /* the IANA code number */
|
||||||
"L16", /* the IANA code name */
|
"L16", /* the IANA code name */
|
||||||
NULL, /* default fmtp to send (can be overridden by the init function) */
|
NULL, /* default fmtp to send (can be overridden by the init function) */
|
||||||
44100, /* samples transferred per second */
|
44100, /* samples transferred per second */
|
||||||
44100, /* actual samples transferred per second */
|
44100, /* actual samples transferred per second */
|
||||||
705600, /* bits transferred per second */
|
705600, /* bits transferred per second */
|
||||||
ms_per_frame, /* number of microseconds per frame */
|
ms_per_frame, /* number of microseconds per frame */
|
||||||
samples_per_frame, /* number of samples per frame */
|
samples_per_frame, /* number of samples per frame */
|
||||||
bytes_per_frame, /* number of bytes per frame decompressed */
|
bytes_per_frame, /* number of bytes per frame decompressed */
|
||||||
bytes_per_frame, /* number of bytes per frame compressed */
|
bytes_per_frame, /* number of bytes per frame compressed */
|
||||||
1, /* number of channels represented */
|
1, /* number of channels represented */
|
||||||
1, /* number of frames per network packet */
|
1, /* number of frames per network packet */
|
||||||
switch_raw_init, /* function to initialize a codec handle using this implementation */
|
switch_raw_init, /* function to initialize a codec handle using this implementation */
|
||||||
switch_raw_encode, /* function to encode raw data into encoded data */
|
switch_raw_encode, /* function to encode raw data into encoded data */
|
||||||
switch_raw_decode, /* function to decode encoded data into raw data */
|
switch_raw_decode, /* function to decode encoded data into raw data */
|
||||||
switch_raw_destroy); /* deinitalize a codec handle using this implementation */
|
switch_raw_destroy); /* deinitalize a codec handle using this implementation */
|
||||||
|
|
||||||
switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */
|
switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */
|
||||||
100, /* the IANA code number */
|
100, /* the IANA code number */
|
||||||
"L16", /* the IANA code name */
|
"L16", /* the IANA code name */
|
||||||
NULL, /* default fmtp to send (can be overridden by the init function) */
|
NULL, /* default fmtp to send (can be overridden by the init function) */
|
||||||
44100, /* samples transferred per second */
|
44100, /* samples transferred per second */
|
||||||
44100, /* actual samples transferred per second */
|
44100, /* actual samples transferred per second */
|
||||||
705600, /* bits transferred per second */
|
705600, /* bits transferred per second */
|
||||||
ms_per_frame, /* number of microseconds per frame */
|
ms_per_frame, /* number of microseconds per frame */
|
||||||
samples_per_frame, /* number of samples per frame */
|
samples_per_frame, /* number of samples per frame */
|
||||||
bytes_per_frame * 2, /* number of bytes per frame decompressed */
|
bytes_per_frame * 2, /* number of bytes per frame decompressed */
|
||||||
bytes_per_frame * 2, /* number of bytes per frame compressed */
|
bytes_per_frame * 2, /* number of bytes per frame compressed */
|
||||||
2, /* number of channels represented */
|
2, /* number of channels represented */
|
||||||
1, /* number of frames per network packet */
|
1, /* number of frames per network packet */
|
||||||
switch_raw_init, /* function to initialize a codec handle using this implementation */
|
switch_raw_init, /* function to initialize a codec handle using this implementation */
|
||||||
switch_raw_encode, /* function to encode raw data into encoded data */
|
switch_raw_encode, /* function to encode raw data into encoded data */
|
||||||
switch_raw_decode, /* function to decode encoded data into raw data */
|
switch_raw_decode, /* function to decode encoded data into raw data */
|
||||||
switch_raw_destroy); /* deinitalize a codec handle using this implementation */
|
switch_raw_destroy); /* deinitalize a codec handle using this implementation */
|
||||||
|
|
||||||
samples_per_frame += 441;
|
samples_per_frame += 441;
|
||||||
bytes_per_frame += 882;
|
bytes_per_frame += 882;
|
||||||
|
@ -829,113 +829,113 @@ SWITCH_MODULE_LOAD_FUNCTION(core_pcm_load)
|
||||||
|
|
||||||
|
|
||||||
switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */
|
switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */
|
||||||
100, /* the IANA code number */
|
100, /* the IANA code number */
|
||||||
"L16", /* the IANA code name */
|
"L16", /* the IANA code name */
|
||||||
NULL, /* default fmtp to send (can be overridden by the init function) */
|
NULL, /* default fmtp to send (can be overridden by the init function) */
|
||||||
22050, /* samples transferred per second */
|
22050, /* samples transferred per second */
|
||||||
22050, /* actual samples transferred per second */
|
22050, /* actual samples transferred per second */
|
||||||
352800, /* bits transferred per second */
|
352800, /* bits transferred per second */
|
||||||
20000, /* number of microseconds per frame */
|
20000, /* number of microseconds per frame */
|
||||||
441, /* number of samples per frame */
|
441, /* number of samples per frame */
|
||||||
882, /* number of bytes per frame decompressed */
|
882, /* number of bytes per frame decompressed */
|
||||||
882, /* number of bytes per frame compressed */
|
882, /* number of bytes per frame compressed */
|
||||||
1, /* number of channels represented */
|
1, /* number of channels represented */
|
||||||
1, /* number of frames per network packet */
|
1, /* number of frames per network packet */
|
||||||
switch_raw_init, /* function to initialize a codec handle using this implementation */
|
switch_raw_init, /* function to initialize a codec handle using this implementation */
|
||||||
switch_raw_encode, /* function to encode raw data into encoded data */
|
switch_raw_encode, /* function to encode raw data into encoded data */
|
||||||
switch_raw_decode, /* function to decode encoded data into raw data */
|
switch_raw_decode, /* function to decode encoded data into raw data */
|
||||||
switch_raw_destroy); /* deinitalize a codec handle using this implementation */
|
switch_raw_destroy); /* deinitalize a codec handle using this implementation */
|
||||||
|
|
||||||
switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */
|
switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */
|
||||||
100, /* the IANA code number */
|
100, /* the IANA code number */
|
||||||
"L16", /* the IANA code name */
|
"L16", /* the IANA code name */
|
||||||
NULL, /* default fmtp to send (can be overridden by the init function) */
|
NULL, /* default fmtp to send (can be overridden by the init function) */
|
||||||
22050, /* samples transferred per second */
|
22050, /* samples transferred per second */
|
||||||
22050, /* actual samples transferred per second */
|
22050, /* actual samples transferred per second */
|
||||||
352800 * 2, /* bits transferred per second */
|
352800 * 2, /* bits transferred per second */
|
||||||
20000, /* number of microseconds per frame */
|
20000, /* number of microseconds per frame */
|
||||||
441, /* number of samples per frame */
|
441, /* number of samples per frame */
|
||||||
882 * 2, /* number of bytes per frame decompressed */
|
882 * 2, /* number of bytes per frame decompressed */
|
||||||
882 * 2, /* number of bytes per frame compressed */
|
882 * 2, /* number of bytes per frame compressed */
|
||||||
2, /* number of channels represented */
|
2, /* number of channels represented */
|
||||||
1, /* number of frames per network packet */
|
1, /* number of frames per network packet */
|
||||||
switch_raw_init, /* function to initialize a codec handle using this implementation */
|
switch_raw_init, /* function to initialize a codec handle using this implementation */
|
||||||
switch_raw_encode, /* function to encode raw data into encoded data */
|
switch_raw_encode, /* function to encode raw data into encoded data */
|
||||||
switch_raw_decode, /* function to decode encoded data into raw data */
|
switch_raw_decode, /* function to decode encoded data into raw data */
|
||||||
switch_raw_destroy); /* deinitalize a codec handle using this implementation */
|
switch_raw_destroy); /* deinitalize a codec handle using this implementation */
|
||||||
|
|
||||||
switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */
|
switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */
|
||||||
100, /* the IANA code number */
|
100, /* the IANA code number */
|
||||||
"L16", /* the IANA code name */
|
"L16", /* the IANA code name */
|
||||||
NULL, /* default fmtp to send (can be overridden by the init function) */
|
NULL, /* default fmtp to send (can be overridden by the init function) */
|
||||||
11025, /* samples transferred per second */
|
11025, /* samples transferred per second */
|
||||||
11025, /* actual samples transferred per second */
|
11025, /* actual samples transferred per second */
|
||||||
176400, /* bits transferred per second */
|
176400, /* bits transferred per second */
|
||||||
40000, /* number of microseconds per frame */
|
40000, /* number of microseconds per frame */
|
||||||
441, /* number of samples per frame */
|
441, /* number of samples per frame */
|
||||||
882, /* number of bytes per frame decompressed */
|
882, /* number of bytes per frame decompressed */
|
||||||
882, /* number of bytes per frame compressed */
|
882, /* number of bytes per frame compressed */
|
||||||
1, /* number of channels represented */
|
1, /* number of channels represented */
|
||||||
1, /* number of frames per network packet */
|
1, /* number of frames per network packet */
|
||||||
switch_raw_init, /* function to initialize a codec handle using this implementation */
|
switch_raw_init, /* function to initialize a codec handle using this implementation */
|
||||||
switch_raw_encode, /* function to encode raw data into encoded data */
|
switch_raw_encode, /* function to encode raw data into encoded data */
|
||||||
switch_raw_decode, /* function to decode encoded data into raw data */
|
switch_raw_decode, /* function to decode encoded data into raw data */
|
||||||
switch_raw_destroy); /* deinitalize a codec handle using this implementation */
|
switch_raw_destroy); /* deinitalize a codec handle using this implementation */
|
||||||
|
|
||||||
switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */
|
switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */
|
||||||
100, /* the IANA code number */
|
100, /* the IANA code number */
|
||||||
"L16", /* the IANA code name */
|
"L16", /* the IANA code name */
|
||||||
NULL, /* default fmtp to send (can be overridden by the init function) */
|
NULL, /* default fmtp to send (can be overridden by the init function) */
|
||||||
11025, /* samples transferred per second */
|
11025, /* samples transferred per second */
|
||||||
11025, /* actual samples transferred per second */
|
11025, /* actual samples transferred per second */
|
||||||
176400 * 2, /* bits transferred per second */
|
176400 * 2, /* bits transferred per second */
|
||||||
40000, /* number of microseconds per frame */
|
40000, /* number of microseconds per frame */
|
||||||
441, /* number of samples per frame */
|
441, /* number of samples per frame */
|
||||||
882 * 2, /* number of bytes per frame decompressed */
|
882 * 2, /* number of bytes per frame decompressed */
|
||||||
882 * 2, /* number of bytes per frame compressed */
|
882 * 2, /* number of bytes per frame compressed */
|
||||||
2, /* number of channels represented */
|
2, /* number of channels represented */
|
||||||
1, /* number of frames per network packet */
|
1, /* number of frames per network packet */
|
||||||
switch_raw_init, /* function to initialize a codec handle using this implementation */
|
switch_raw_init, /* function to initialize a codec handle using this implementation */
|
||||||
switch_raw_encode, /* function to encode raw data into encoded data */
|
switch_raw_encode, /* function to encode raw data into encoded data */
|
||||||
switch_raw_decode, /* function to decode encoded data into raw data */
|
switch_raw_decode, /* function to decode encoded data into raw data */
|
||||||
switch_raw_destroy); /* deinitalize a codec handle using this implementation */
|
switch_raw_destroy); /* deinitalize a codec handle using this implementation */
|
||||||
|
|
||||||
|
|
||||||
switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */
|
switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */
|
||||||
100, /* the IANA code number */
|
100, /* the IANA code number */
|
||||||
"L16", /* the IANA code name */
|
"L16", /* the IANA code name */
|
||||||
NULL, /* default fmtp to send (can be overridden by the init function) */
|
NULL, /* default fmtp to send (can be overridden by the init function) */
|
||||||
11025, /* samples transferred per second */
|
11025, /* samples transferred per second */
|
||||||
11025, /* actual samples transferred per second */
|
11025, /* actual samples transferred per second */
|
||||||
176400, /* bits transferred per second */
|
176400, /* bits transferred per second */
|
||||||
32000, /* number of microseconds per frame */
|
32000, /* number of microseconds per frame */
|
||||||
256, /* number of samples per frame */
|
256, /* number of samples per frame */
|
||||||
512, /* number of bytes per frame decompressed */
|
512, /* number of bytes per frame decompressed */
|
||||||
512, /* number of bytes per frame compressed */
|
512, /* number of bytes per frame compressed */
|
||||||
1, /* number of channels represented */
|
1, /* number of channels represented */
|
||||||
1, /* number of frames per network packet */
|
1, /* number of frames per network packet */
|
||||||
switch_raw_init, /* function to initialize a codec handle using this implementation */
|
switch_raw_init, /* function to initialize a codec handle using this implementation */
|
||||||
switch_raw_encode, /* function to encode raw data into encoded data */
|
switch_raw_encode, /* function to encode raw data into encoded data */
|
||||||
switch_raw_decode, /* function to decode encoded data into raw data */
|
switch_raw_decode, /* function to decode encoded data into raw data */
|
||||||
switch_raw_destroy); /* deinitalize a codec handle using this implementation */
|
switch_raw_destroy); /* deinitalize a codec handle using this implementation */
|
||||||
|
|
||||||
switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */
|
switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO, /* enumeration defining the type of the codec */
|
||||||
100, /* the IANA code number */
|
100, /* the IANA code number */
|
||||||
"L16", /* the IANA code name */
|
"L16", /* the IANA code name */
|
||||||
NULL, /* default fmtp to send (can be overridden by the init function) */
|
NULL, /* default fmtp to send (can be overridden by the init function) */
|
||||||
11025, /* samples transferred per second */
|
11025, /* samples transferred per second */
|
||||||
11025, /* actual samples transferred per second */
|
11025, /* actual samples transferred per second */
|
||||||
176400 * 2, /* bits transferred per second */
|
176400 * 2, /* bits transferred per second */
|
||||||
32000, /* number of microseconds per frame */
|
32000, /* number of microseconds per frame */
|
||||||
256, /* number of samples per frame */
|
256, /* number of samples per frame */
|
||||||
512 * 2, /* number of bytes per frame decompressed */
|
512 * 2, /* number of bytes per frame decompressed */
|
||||||
512 * 2, /* number of bytes per frame compressed */
|
512 * 2, /* number of bytes per frame compressed */
|
||||||
2, /* number of channels represented */
|
2, /* number of channels represented */
|
||||||
1, /* number of frames per network packet */
|
1, /* number of frames per network packet */
|
||||||
switch_raw_init, /* function to initialize a codec handle using this implementation */
|
switch_raw_init, /* function to initialize a codec handle using this implementation */
|
||||||
switch_raw_encode, /* function to encode raw data into encoded data */
|
switch_raw_encode, /* function to encode raw data into encoded data */
|
||||||
switch_raw_decode, /* function to decode encoded data into raw data */
|
switch_raw_decode, /* function to decode encoded data into raw data */
|
||||||
switch_raw_destroy); /* deinitalize a codec handle using this implementation */
|
switch_raw_destroy); /* deinitalize a codec handle using this implementation */
|
||||||
|
|
||||||
/* indicate that the module should continue to be loaded */
|
/* indicate that the module should continue to be loaded */
|
||||||
|
|
||||||
|
|
|
@ -124,8 +124,8 @@ static int db_is_up(switch_pgsql_handle_t *handle)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Try a non-blocking read on the connection to gobble up any EOF from a closed connection and mark the connection BAD if it is closed. */
|
/* Try a non-blocking read on the connection to gobble up any EOF from a closed connection and mark the connection BAD if it is closed. */
|
||||||
PQconsumeInput(handle->con);
|
PQconsumeInput(handle->con);
|
||||||
|
|
||||||
if (PQstatus(handle->con) == CONNECTION_BAD) {
|
if (PQstatus(handle->con) == CONNECTION_BAD) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "PQstatus returned bad connection; reconnecting...\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "PQstatus returned bad connection; reconnecting...\n");
|
||||||
|
|
|
@ -52,8 +52,8 @@ struct profile_timer
|
||||||
/* last calculated percentage of idle time */
|
/* last calculated percentage of idle time */
|
||||||
double last_percentage_of_idle_time;
|
double last_percentage_of_idle_time;
|
||||||
double *percentage_of_idle_time_ring;
|
double *percentage_of_idle_time_ring;
|
||||||
unsigned int last_idle_time_index;
|
unsigned int last_idle_time_index;
|
||||||
unsigned int cpu_idle_smoothing_depth;
|
unsigned int cpu_idle_smoothing_depth;
|
||||||
|
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
/* the cpu feature gets disabled on errors */
|
/* the cpu feature gets disabled on errors */
|
||||||
|
@ -83,14 +83,14 @@ struct profile_timer
|
||||||
|
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
static int read_cpu_stats(switch_profile_timer_t *p,
|
static int read_cpu_stats(switch_profile_timer_t *p,
|
||||||
unsigned long long *user,
|
unsigned long long *user,
|
||||||
unsigned long long *nice,
|
unsigned long long *nice,
|
||||||
unsigned long long *system,
|
unsigned long long *system,
|
||||||
unsigned long long *idle,
|
unsigned long long *idle,
|
||||||
unsigned long long *iowait,
|
unsigned long long *iowait,
|
||||||
unsigned long long *irq,
|
unsigned long long *irq,
|
||||||
unsigned long long *softirq,
|
unsigned long long *softirq,
|
||||||
unsigned long long *steal)
|
unsigned long long *steal)
|
||||||
{
|
{
|
||||||
// the output of proc should not change that often from one kernel to other
|
// the output of proc should not change that often from one kernel to other
|
||||||
// see fs/proc/proc_misc.c or fs/proc/stat.c in the Linux kernel for more details
|
// see fs/proc/proc_misc.c or fs/proc/stat.c in the Linux kernel for more details
|
||||||
|
@ -307,15 +307,15 @@ SWITCH_DECLARE(switch_profile_timer_t *)switch_new_profile_timer(void)
|
||||||
switch_profile_timer_t *p = calloc(1, sizeof(switch_profile_timer_t));
|
switch_profile_timer_t *p = calloc(1, sizeof(switch_profile_timer_t));
|
||||||
|
|
||||||
if ( runtime.cpu_idle_smoothing_depth && runtime.cpu_idle_smoothing_depth > 0 ) {
|
if ( runtime.cpu_idle_smoothing_depth && runtime.cpu_idle_smoothing_depth > 0 ) {
|
||||||
p->cpu_idle_smoothing_depth = runtime.cpu_idle_smoothing_depth;
|
p->cpu_idle_smoothing_depth = runtime.cpu_idle_smoothing_depth;
|
||||||
} else {
|
} else {
|
||||||
p->cpu_idle_smoothing_depth = 30;
|
p->cpu_idle_smoothing_depth = 30;
|
||||||
}
|
}
|
||||||
|
|
||||||
p->percentage_of_idle_time_ring = calloc(1, sizeof(double) * p->cpu_idle_smoothing_depth);
|
p->percentage_of_idle_time_ring = calloc(1, sizeof(double) * p->cpu_idle_smoothing_depth);
|
||||||
|
|
||||||
for ( x = 0; x < p->cpu_idle_smoothing_depth; x++ ) {
|
for ( x = 0; x < p->cpu_idle_smoothing_depth; x++ ) {
|
||||||
p->percentage_of_idle_time_ring[x] = 100.0;
|
p->percentage_of_idle_time_ring[x] = 100.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return p;
|
return p;
|
||||||
|
|
|
@ -1727,10 +1727,10 @@ static void rtcp_generate_sender_info(switch_rtp_t *rtp_session, struct switch_r
|
||||||
|
|
||||||
switch_time_exp_gmt(&now_hr,now);
|
switch_time_exp_gmt(&now_hr,now);
|
||||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG10,"Sending an RTCP packet[%04d-%02d-%02d %02d:%02d:%02d.%d] lsr[%u] msw[%u] lsw[%u] stats_ssrc[%u]\n",
|
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG10,"Sending an RTCP packet[%04d-%02d-%02d %02d:%02d:%02d.%d] lsr[%u] msw[%u] lsw[%u] stats_ssrc[%u]\n",
|
||||||
1900 + now_hr.tm_year, now_hr.tm_mday, now_hr.tm_mon, now_hr.tm_hour, now_hr.tm_min, now_hr.tm_sec, now_hr.tm_usec,
|
1900 + now_hr.tm_year, now_hr.tm_mday, now_hr.tm_mon, now_hr.tm_hour, now_hr.tm_min, now_hr.tm_sec, now_hr.tm_usec,
|
||||||
(ntohl(sr->ntp_lsw)&0xffff0000)>>16 | (ntohl(sr->ntp_msw)&0x0000ffff)<<16,
|
(ntohl(sr->ntp_lsw)&0xffff0000)>>16 | (ntohl(sr->ntp_msw)&0x0000ffff)<<16,
|
||||||
ntohl(sr->ntp_msw),ntohl(sr->ntp_lsw), rtp_session->stats.rtcp.ssrc
|
ntohl(sr->ntp_msw),ntohl(sr->ntp_lsw), rtp_session->stats.rtcp.ssrc
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
//#define DEBUG_RTCP
|
//#define DEBUG_RTCP
|
||||||
|
@ -1769,11 +1769,11 @@ static void rtcp_generate_report_block(switch_rtp_t *rtp_session, struct switch_
|
||||||
|
|
||||||
#ifdef DEBUG_RTCP
|
#ifdef DEBUG_RTCP
|
||||||
if (rtp_session->flags[SWITCH_RTP_FLAG_VIDEO])
|
if (rtp_session->flags[SWITCH_RTP_FLAG_VIDEO])
|
||||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "rtcp_generate_sr: stats_ssrc[%u]\nreceived[%d]\nexpected[%d]\ncum[%d]\nlost[%d|%d/256]pkt\nlast_seq[%d]\ncyc[%d]\nlast_rpt_seq[%d]\ncyc[%d]\nssrc[%d]\n",
|
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "rtcp_generate_sr: stats_ssrc[%u]\nreceived[%d]\nexpected[%d]\ncum[%d]\nlost[%d|%d/256]pkt\nlast_seq[%d]\ncyc[%d]\nlast_rpt_seq[%d]\ncyc[%d]\nssrc[%d]\n",
|
||||||
rtp_session->remote_ssrc, stats->period_pkt_count, expected_pkt,
|
rtp_session->remote_ssrc, stats->period_pkt_count, expected_pkt,
|
||||||
stats->cum_lost, pkt_lost, rtcp_report_block->fraction, stats->high_ext_seq_recv&0x0000ffff,
|
stats->cum_lost, pkt_lost, rtcp_report_block->fraction, stats->high_ext_seq_recv&0x0000ffff,
|
||||||
stats->cycle, stats->last_rpt_ext_seq&0x0000ffff, stats->last_rpt_cycle, rtp_session->stats.rtcp.peer_ssrc
|
stats->cycle, stats->last_rpt_ext_seq&0x0000ffff, stats->last_rpt_cycle, rtp_session->stats.rtcp.peer_ssrc
|
||||||
);
|
);
|
||||||
#endif
|
#endif
|
||||||
rtcp_report_block->highest_sequence_number_received = htonl(stats->high_ext_seq_recv);
|
rtcp_report_block->highest_sequence_number_received = htonl(stats->high_ext_seq_recv);
|
||||||
|
|
||||||
|
@ -1851,7 +1851,7 @@ static int rtcp_stats(switch_rtp_t *rtp_session)
|
||||||
if (pkt_seq < max_seq) {
|
if (pkt_seq < max_seq) {
|
||||||
stats->cycle++;
|
stats->cycle++;
|
||||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "rtcp_stats:[cycle change] pkt_seq[%d] cycle[%d] max_seq[%d] stats_ssrc[%u] local_ts[%u]\n",
|
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "rtcp_stats:[cycle change] pkt_seq[%d] cycle[%d] max_seq[%d] stats_ssrc[%u] local_ts[%u]\n",
|
||||||
pkt_seq, stats->cycle, max_seq, stats->ssrc, rtp_session->timer.samplecount);
|
pkt_seq, stats->cycle, max_seq, stats->ssrc, rtp_session->timer.samplecount);
|
||||||
}
|
}
|
||||||
pkt_extended_seq = stats->cycle << 16 | pkt_seq; /* getting the extended packet extended sequence ID */
|
pkt_extended_seq = stats->cycle << 16 | pkt_seq; /* getting the extended packet extended sequence ID */
|
||||||
if (pkt_extended_seq > stats->high_ext_seq_recv) {
|
if (pkt_extended_seq > stats->high_ext_seq_recv) {
|
||||||
|
@ -1878,7 +1878,7 @@ static int rtcp_stats(switch_rtp_t *rtp_session)
|
||||||
stats->pkt_count++;
|
stats->pkt_count++;
|
||||||
#ifdef DEBUG_RTCP
|
#ifdef DEBUG_RTCP
|
||||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG10, "rtcp_stats: period_pkt_count[%d]last_seq[%d]cycle[%d]stats_ssrc[%u]local_ts[%u]\n",
|
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG10, "rtcp_stats: period_pkt_count[%d]last_seq[%d]cycle[%d]stats_ssrc[%u]local_ts[%u]\n",
|
||||||
stats->period_pkt_count, pkt_seq, stats->cycle, stats->ssrc, rtp_session->timer.samplecount);
|
stats->period_pkt_count, pkt_seq, stats->cycle, stats->ssrc, rtp_session->timer.samplecount);
|
||||||
#endif
|
#endif
|
||||||
/* Interarrival jitter calculation */
|
/* Interarrival jitter calculation */
|
||||||
pkt_tsdiff = abs((int)rtp_session->timer.samplecount - (int)ntohl(hdr->ts)); /* relative transit times for this packet */
|
pkt_tsdiff = abs((int)rtp_session->timer.samplecount - (int)ntohl(hdr->ts)); /* relative transit times for this packet */
|
||||||
|
@ -1893,7 +1893,7 @@ static int rtcp_stats(switch_rtp_t *rtp_session)
|
||||||
|
|
||||||
#ifdef DEBUG_RTCP
|
#ifdef DEBUG_RTCP
|
||||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG10, "rtcp_stats: pkt_ts[%d]local_ts[%d]diff[%d]pkt_spacing[%d]inter_jitter[%f]seq[%d]stats_ssrc[%d]",
|
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG10, "rtcp_stats: pkt_ts[%d]local_ts[%d]diff[%d]pkt_spacing[%d]inter_jitter[%f]seq[%d]stats_ssrc[%d]",
|
||||||
ntohl(hdr->ts), rtp_session->timer.samplecount, pkt_tsdiff, packet_spacing_diff, stats->inter_jitter, ntohs(hdr->seq), stats->ssrc);
|
ntohl(hdr->ts), rtp_session->timer.samplecount, pkt_tsdiff, packet_spacing_diff, stats->inter_jitter, ntohs(hdr->seq), stats->ssrc);
|
||||||
#endif
|
#endif
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -3917,10 +3917,10 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_create(switch_rtp_t **new_rtp_session
|
||||||
|
|
||||||
/* Burst and Packet Loss */
|
/* Burst and Packet Loss */
|
||||||
rtp_session->stats.inbound.lossrate = 0;
|
rtp_session->stats.inbound.lossrate = 0;
|
||||||
rtp_session->stats.inbound.burstrate = 0;
|
rtp_session->stats.inbound.burstrate = 0;
|
||||||
memset(rtp_session->stats.inbound.loss, 0, sizeof(rtp_session->stats.inbound.loss));
|
memset(rtp_session->stats.inbound.loss, 0, sizeof(rtp_session->stats.inbound.loss));
|
||||||
rtp_session->stats.inbound.last_loss = 0;
|
rtp_session->stats.inbound.last_loss = 0;
|
||||||
rtp_session->stats.inbound.last_processed_seq = -1;
|
rtp_session->stats.inbound.last_processed_seq = -1;
|
||||||
|
|
||||||
rtp_session->ready = 1;
|
rtp_session->ready = 1;
|
||||||
*new_rtp_session = rtp_session;
|
*new_rtp_session = rtp_session;
|
||||||
|
@ -4983,7 +4983,7 @@ static switch_size_t do_flush(switch_rtp_t *rtp_session, int force, switch_size_
|
||||||
if (rtp_session->vb) {
|
if (rtp_session->vb) {
|
||||||
//switch_jb_reset(rtp_session->vb);
|
//switch_jb_reset(rtp_session->vb);
|
||||||
bytes_out = bytes_in;
|
bytes_out = bytes_in;
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rtp_session->flags[SWITCH_RTP_FLAG_DEBUG_RTP_READ]) {
|
if (rtp_session->flags[SWITCH_RTP_FLAG_DEBUG_RTP_READ]) {
|
||||||
|
@ -6308,7 +6308,7 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_
|
||||||
switch_rtp_clear_flag(rtp_session, SWITCH_RTP_FLAG_BREAK);
|
switch_rtp_clear_flag(rtp_session, SWITCH_RTP_FLAG_BREAK);
|
||||||
bytes = 0;
|
bytes = 0;
|
||||||
reset_jitter_seq(rtp_session);
|
reset_jitter_seq(rtp_session);
|
||||||
return_cng_frame();
|
return_cng_frame();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,13 +4,13 @@
|
||||||
|
|
||||||
sdp_connection_t *sdp_media_connections(sdp_media_t const *m)
|
sdp_connection_t *sdp_media_connections(sdp_media_t const *m)
|
||||||
{
|
{
|
||||||
if (m) {
|
if (m) {
|
||||||
if (m->m_connections)
|
if (m->m_connections)
|
||||||
return m->m_connections;
|
return m->m_connections;
|
||||||
if (m->m_session)
|
if (m->m_session)
|
||||||
return m->m_session->sdp_connection;
|
return m->m_session->sdp_connection;
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#include <su_alloc.c>
|
#include <su_alloc.c>
|
||||||
|
|
|
@ -414,7 +414,7 @@ SWITCH_DECLARE(uint8_t) switch_stun_packet_attribute_get_xor_mapped_address(swit
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ip->port ^= ntohl(header->cookie) >> 16;
|
ip->port ^= ntohl(header->cookie) >> 16;
|
||||||
*port = ip->port;
|
*port = ip->port;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -585,9 +585,9 @@ SWITCH_DECLARE(uint8_t) switch_stun_packet_attribute_add_use_candidate(switch_st
|
||||||
SWITCH_DECLARE(uint8_t) switch_stun_packet_attribute_add_controlling(switch_stun_packet_t *packet)
|
SWITCH_DECLARE(uint8_t) switch_stun_packet_attribute_add_controlling(switch_stun_packet_t *packet)
|
||||||
{
|
{
|
||||||
switch_stun_packet_attribute_t *attribute;
|
switch_stun_packet_attribute_t *attribute;
|
||||||
char buf[8];
|
char buf[8];
|
||||||
|
|
||||||
switch_stun_random_string(buf, 8, NULL);
|
switch_stun_random_string(buf, 8, NULL);
|
||||||
|
|
||||||
attribute = (switch_stun_packet_attribute_t *) ((uint8_t *) & packet->first_attribute + ntohs(packet->header.length));
|
attribute = (switch_stun_packet_attribute_t *) ((uint8_t *) & packet->first_attribute + ntohs(packet->header.length));
|
||||||
attribute->type = htons(SWITCH_STUN_ATTR_CONTROLLING);
|
attribute->type = htons(SWITCH_STUN_ATTR_CONTROLLING);
|
||||||
|
@ -600,9 +600,9 @@ SWITCH_DECLARE(uint8_t) switch_stun_packet_attribute_add_controlling(switch_stun
|
||||||
SWITCH_DECLARE(uint8_t) switch_stun_packet_attribute_add_controlled(switch_stun_packet_t *packet)
|
SWITCH_DECLARE(uint8_t) switch_stun_packet_attribute_add_controlled(switch_stun_packet_t *packet)
|
||||||
{
|
{
|
||||||
switch_stun_packet_attribute_t *attribute;
|
switch_stun_packet_attribute_t *attribute;
|
||||||
char buf[8];
|
char buf[8];
|
||||||
|
|
||||||
switch_stun_random_string(buf, 8, NULL);
|
switch_stun_random_string(buf, 8, NULL);
|
||||||
|
|
||||||
attribute = (switch_stun_packet_attribute_t *) ((uint8_t *) & packet->first_attribute + ntohs(packet->header.length));
|
attribute = (switch_stun_packet_attribute_t *) ((uint8_t *) & packet->first_attribute + ntohs(packet->header.length));
|
||||||
attribute->type = htons(SWITCH_STUN_ATTR_CONTROLLED);
|
attribute->type = htons(SWITCH_STUN_ATTR_CONTROLLED);
|
||||||
|
|
|
@ -64,7 +64,7 @@ static const char trailingBytesForUTF8[256] = {
|
||||||
/* returns length of next utf-8 sequence */
|
/* returns length of next utf-8 sequence */
|
||||||
SWITCH_DECLARE(int) switch_u8_seqlen(char *s)
|
SWITCH_DECLARE(int) switch_u8_seqlen(char *s)
|
||||||
{
|
{
|
||||||
return trailingBytesForUTF8[(unsigned int)(unsigned char)s[0]] + 1;
|
return trailingBytesForUTF8[(unsigned int)(unsigned char)s[0]] + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* conversions without error checking
|
/* conversions without error checking
|
||||||
|
@ -76,38 +76,38 @@ SWITCH_DECLARE(int) switch_u8_seqlen(char *s)
|
||||||
dest will always be L'\0'-terminated, even if there isn't enough room
|
dest will always be L'\0'-terminated, even if there isn't enough room
|
||||||
for all the characters.
|
for all the characters.
|
||||||
if sz = srcsz+1 (i.e. 4*srcsz+4 bytes), there will always be enough space.
|
if sz = srcsz+1 (i.e. 4*srcsz+4 bytes), there will always be enough space.
|
||||||
*/
|
*/
|
||||||
SWITCH_DECLARE(int) switch_u8_toucs(uint32_t *dest, int sz, char *src, int srcsz)
|
SWITCH_DECLARE(int) switch_u8_toucs(uint32_t *dest, int sz, char *src, int srcsz)
|
||||||
{
|
{
|
||||||
uint32_t ch;
|
uint32_t ch;
|
||||||
char *src_end = src + srcsz;
|
char *src_end = src + srcsz;
|
||||||
int nb;
|
int nb;
|
||||||
int i=0;
|
int i=0;
|
||||||
|
|
||||||
while (i < sz-1) {
|
while (i < sz-1) {
|
||||||
nb = trailingBytesForUTF8[(unsigned char)*src];
|
nb = trailingBytesForUTF8[(unsigned char)*src];
|
||||||
if (srcsz == -1) {
|
if (srcsz == -1) {
|
||||||
if (*src == 0)
|
if (*src == 0)
|
||||||
goto done_toucs;
|
goto done_toucs;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (src + nb >= src_end)
|
if (src + nb >= src_end)
|
||||||
goto done_toucs;
|
goto done_toucs;
|
||||||
}
|
}
|
||||||
ch = 0;
|
ch = 0;
|
||||||
switch (nb) {
|
switch (nb) {
|
||||||
/* these fall through deliberately */
|
/* these fall through deliberately */
|
||||||
case 3: ch += (unsigned char)*src++; ch <<= 6;
|
case 3: ch += (unsigned char)*src++; ch <<= 6;
|
||||||
case 2: ch += (unsigned char)*src++; ch <<= 6;
|
case 2: ch += (unsigned char)*src++; ch <<= 6;
|
||||||
case 1: ch += (unsigned char)*src++; ch <<= 6;
|
case 1: ch += (unsigned char)*src++; ch <<= 6;
|
||||||
case 0: ch += (unsigned char)*src++;
|
case 0: ch += (unsigned char)*src++;
|
||||||
}
|
}
|
||||||
ch -= offsetsFromUTF8[nb];
|
ch -= offsetsFromUTF8[nb];
|
||||||
dest[i++] = ch;
|
dest[i++] = ch;
|
||||||
}
|
}
|
||||||
done_toucs:
|
done_toucs:
|
||||||
dest[i] = 0;
|
dest[i] = 0;
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* srcsz = number of source characters, or -1 if 0-terminated
|
/* srcsz = number of source characters, or -1 if 0-terminated
|
||||||
|
@ -121,346 +121,346 @@ SWITCH_DECLARE(int) switch_u8_toucs(uint32_t *dest, int sz, char *src, int srcsz
|
||||||
only NUL-terminates if all the characters fit, and there's space for
|
only NUL-terminates if all the characters fit, and there's space for
|
||||||
the NUL as well.
|
the NUL as well.
|
||||||
the destination string will never be bigger than the source string.
|
the destination string will never be bigger than the source string.
|
||||||
*/
|
*/
|
||||||
SWITCH_DECLARE(int) switch_u8_toutf8(char *dest, int sz, uint32_t *src, int srcsz)
|
SWITCH_DECLARE(int) switch_u8_toutf8(char *dest, int sz, uint32_t *src, int srcsz)
|
||||||
{
|
{
|
||||||
uint32_t ch;
|
uint32_t ch;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
char *dest_end = dest + sz;
|
char *dest_end = dest + sz;
|
||||||
|
|
||||||
while (srcsz<0 ? src[i]!=0 : i < srcsz) {
|
while (srcsz<0 ? src[i]!=0 : i < srcsz) {
|
||||||
ch = src[i];
|
ch = src[i];
|
||||||
if (ch < 0x80) {
|
if (ch < 0x80) {
|
||||||
if (dest >= dest_end)
|
if (dest >= dest_end)
|
||||||
return i;
|
return i;
|
||||||
*dest++ = (char)ch;
|
*dest++ = (char)ch;
|
||||||
}
|
}
|
||||||
else if (ch < 0x800) {
|
else if (ch < 0x800) {
|
||||||
if (dest >= dest_end-1)
|
if (dest >= dest_end-1)
|
||||||
return i;
|
return i;
|
||||||
*dest++ = (ch>>6) | 0xC0;
|
*dest++ = (ch>>6) | 0xC0;
|
||||||
*dest++ = (ch & 0x3F) | 0x80;
|
*dest++ = (ch & 0x3F) | 0x80;
|
||||||
}
|
}
|
||||||
else if (ch < 0x10000) {
|
else if (ch < 0x10000) {
|
||||||
if (dest >= dest_end-2)
|
if (dest >= dest_end-2)
|
||||||
return i;
|
return i;
|
||||||
*dest++ = (ch>>12) | 0xE0;
|
*dest++ = (ch>>12) | 0xE0;
|
||||||
*dest++ = ((ch>>6) & 0x3F) | 0x80;
|
*dest++ = ((ch>>6) & 0x3F) | 0x80;
|
||||||
*dest++ = (ch & 0x3F) | 0x80;
|
*dest++ = (ch & 0x3F) | 0x80;
|
||||||
}
|
}
|
||||||
else if (ch < 0x110000) {
|
else if (ch < 0x110000) {
|
||||||
if (dest >= dest_end-3)
|
if (dest >= dest_end-3)
|
||||||
return i;
|
return i;
|
||||||
*dest++ = (ch>>18) | 0xF0;
|
*dest++ = (ch>>18) | 0xF0;
|
||||||
*dest++ = ((ch>>12) & 0x3F) | 0x80;
|
*dest++ = ((ch>>12) & 0x3F) | 0x80;
|
||||||
*dest++ = ((ch>>6) & 0x3F) | 0x80;
|
*dest++ = ((ch>>6) & 0x3F) | 0x80;
|
||||||
*dest++ = (ch & 0x3F) | 0x80;
|
*dest++ = (ch & 0x3F) | 0x80;
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
if (dest < dest_end)
|
if (dest < dest_end)
|
||||||
*dest = '\0';
|
*dest = '\0';
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
SWITCH_DECLARE(int) switch_u8_wc_toutf8(char *dest, uint32_t ch)
|
SWITCH_DECLARE(int) switch_u8_wc_toutf8(char *dest, uint32_t ch)
|
||||||
{
|
{
|
||||||
if (ch < 0x80) {
|
if (ch < 0x80) {
|
||||||
dest[0] = (char)ch;
|
dest[0] = (char)ch;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (ch < 0x800) {
|
if (ch < 0x800) {
|
||||||
dest[0] = (ch>>6) | 0xC0;
|
dest[0] = (ch>>6) | 0xC0;
|
||||||
dest[1] = (ch & 0x3F) | 0x80;
|
dest[1] = (ch & 0x3F) | 0x80;
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
if (ch < 0x10000) {
|
if (ch < 0x10000) {
|
||||||
dest[0] = (ch>>12) | 0xE0;
|
dest[0] = (ch>>12) | 0xE0;
|
||||||
dest[1] = ((ch>>6) & 0x3F) | 0x80;
|
dest[1] = ((ch>>6) & 0x3F) | 0x80;
|
||||||
dest[2] = (ch & 0x3F) | 0x80;
|
dest[2] = (ch & 0x3F) | 0x80;
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
if (ch < 0x110000) {
|
if (ch < 0x110000) {
|
||||||
dest[0] = (ch>>18) | 0xF0;
|
dest[0] = (ch>>18) | 0xF0;
|
||||||
dest[1] = ((ch>>12) & 0x3F) | 0x80;
|
dest[1] = ((ch>>12) & 0x3F) | 0x80;
|
||||||
dest[2] = ((ch>>6) & 0x3F) | 0x80;
|
dest[2] = ((ch>>6) & 0x3F) | 0x80;
|
||||||
dest[3] = (ch & 0x3F) | 0x80;
|
dest[3] = (ch & 0x3F) | 0x80;
|
||||||
return 4;
|
return 4;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* charnum => byte offset */
|
/* charnum => byte offset */
|
||||||
SWITCH_DECLARE(int) switch_u8_offset(char *str, int charnum)
|
SWITCH_DECLARE(int) switch_u8_offset(char *str, int charnum)
|
||||||
{
|
{
|
||||||
int offs=0;
|
int offs=0;
|
||||||
|
|
||||||
while (charnum > 0 && str[offs]) {
|
while (charnum > 0 && str[offs]) {
|
||||||
(void)(isutf(str[++offs]) || isutf(str[++offs]) ||
|
(void)(isutf(str[++offs]) || isutf(str[++offs]) ||
|
||||||
isutf(str[++offs]) || ++offs);
|
isutf(str[++offs]) || ++offs);
|
||||||
charnum--;
|
charnum--;
|
||||||
}
|
}
|
||||||
return offs;
|
return offs;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* byte offset => charnum */
|
/* byte offset => charnum */
|
||||||
SWITCH_DECLARE(int) switch_u8_charnum(char *s, int offset)
|
SWITCH_DECLARE(int) switch_u8_charnum(char *s, int offset)
|
||||||
{
|
{
|
||||||
int charnum = 0, offs=0;
|
int charnum = 0, offs=0;
|
||||||
|
|
||||||
while (offs < offset && s[offs]) {
|
while (offs < offset && s[offs]) {
|
||||||
(void)(isutf(s[++offs]) || isutf(s[++offs]) ||
|
(void)(isutf(s[++offs]) || isutf(s[++offs]) ||
|
||||||
isutf(s[++offs]) || ++offs);
|
isutf(s[++offs]) || ++offs);
|
||||||
charnum++;
|
charnum++;
|
||||||
}
|
}
|
||||||
return charnum;
|
return charnum;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* number of characters */
|
/* number of characters */
|
||||||
SWITCH_DECLARE(int) switch_u8_strlen(char *s)
|
SWITCH_DECLARE(int) switch_u8_strlen(char *s)
|
||||||
{
|
{
|
||||||
int count = 0;
|
int count = 0;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
while (switch_u8_nextchar(s, &i) != 0)
|
while (switch_u8_nextchar(s, &i) != 0)
|
||||||
count++;
|
count++;
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* reads the next utf-8 sequence out of a string, updating an index */
|
/* reads the next utf-8 sequence out of a string, updating an index */
|
||||||
SWITCH_DECLARE(uint32_t) switch_u8_nextchar(char *s, int *i)
|
SWITCH_DECLARE(uint32_t) switch_u8_nextchar(char *s, int *i)
|
||||||
{
|
{
|
||||||
uint32_t ch = 0;
|
uint32_t ch = 0;
|
||||||
int sz = 0;
|
int sz = 0;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
ch <<= 6;
|
ch <<= 6;
|
||||||
ch += (unsigned char)s[(*i)++];
|
ch += (unsigned char)s[(*i)++];
|
||||||
sz++;
|
sz++;
|
||||||
} while (s[*i] && !isutf(s[*i]));
|
} while (s[*i] && !isutf(s[*i]));
|
||||||
ch -= offsetsFromUTF8[sz-1];
|
ch -= offsetsFromUTF8[sz-1];
|
||||||
|
|
||||||
return ch;
|
return ch;
|
||||||
}
|
}
|
||||||
|
|
||||||
SWITCH_DECLARE(void) switch_u8_inc(char *s, int *i)
|
SWITCH_DECLARE(void) switch_u8_inc(char *s, int *i)
|
||||||
{
|
{
|
||||||
(void)(isutf(s[++(*i)]) || isutf(s[++(*i)]) ||
|
(void)(isutf(s[++(*i)]) || isutf(s[++(*i)]) ||
|
||||||
isutf(s[++(*i)]) || ++(*i));
|
isutf(s[++(*i)]) || ++(*i));
|
||||||
}
|
}
|
||||||
|
|
||||||
SWITCH_DECLARE(void) switch_u8_dec(char *s, int *i)
|
SWITCH_DECLARE(void) switch_u8_dec(char *s, int *i)
|
||||||
{
|
{
|
||||||
(void)(isutf(s[--(*i)]) || isutf(s[--(*i)]) ||
|
(void)(isutf(s[--(*i)]) || isutf(s[--(*i)]) ||
|
||||||
isutf(s[--(*i)]) || --(*i));
|
isutf(s[--(*i)]) || --(*i));
|
||||||
}
|
}
|
||||||
|
|
||||||
SWITCH_DECLARE(int) octal_digit(char c)
|
SWITCH_DECLARE(int) octal_digit(char c)
|
||||||
{
|
{
|
||||||
return (c >= '0' && c <= '7');
|
return (c >= '0' && c <= '7');
|
||||||
}
|
}
|
||||||
|
|
||||||
SWITCH_DECLARE(int) hex_digit(char c)
|
SWITCH_DECLARE(int) hex_digit(char c)
|
||||||
{
|
{
|
||||||
return ((c >= '0' && c <= '9') ||
|
return ((c >= '0' && c <= '9') ||
|
||||||
(c >= 'A' && c <= 'F') ||
|
(c >= 'A' && c <= 'F') ||
|
||||||
(c >= 'a' && c <= 'f'));
|
(c >= 'a' && c <= 'f'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* assumes that src points to the character after a backslash
|
/* assumes that src points to the character after a backslash
|
||||||
returns number of input characters processed */
|
returns number of input characters processed */
|
||||||
SWITCH_DECLARE(int) switch_u8_read_escape_sequence(char *str, uint32_t *dest)
|
SWITCH_DECLARE(int) switch_u8_read_escape_sequence(char *str, uint32_t *dest)
|
||||||
{
|
{
|
||||||
uint32_t ch;
|
uint32_t ch;
|
||||||
char digs[9]="\0\0\0\0\0\0\0\0";
|
char digs[9]="\0\0\0\0\0\0\0\0";
|
||||||
int dno=0, i=1;
|
int dno=0, i=1;
|
||||||
|
|
||||||
ch = (uint32_t)str[0]; /* take literal character */
|
ch = (uint32_t)str[0]; /* take literal character */
|
||||||
if (str[0] == 'n')
|
if (str[0] == 'n')
|
||||||
ch = L'\n';
|
ch = L'\n';
|
||||||
else if (str[0] == 't')
|
else if (str[0] == 't')
|
||||||
ch = L'\t';
|
ch = L'\t';
|
||||||
else if (str[0] == 'r')
|
else if (str[0] == 'r')
|
||||||
ch = L'\r';
|
ch = L'\r';
|
||||||
else if (str[0] == 'b')
|
else if (str[0] == 'b')
|
||||||
ch = L'\b';
|
ch = L'\b';
|
||||||
else if (str[0] == 'f')
|
else if (str[0] == 'f')
|
||||||
ch = L'\f';
|
ch = L'\f';
|
||||||
else if (str[0] == 'v')
|
else if (str[0] == 'v')
|
||||||
ch = L'\v';
|
ch = L'\v';
|
||||||
else if (str[0] == 'a')
|
else if (str[0] == 'a')
|
||||||
ch = L'\a';
|
ch = L'\a';
|
||||||
else if (octal_digit(str[0])) {
|
else if (octal_digit(str[0])) {
|
||||||
i = 0;
|
i = 0;
|
||||||
do {
|
do {
|
||||||
digs[dno++] = str[i++];
|
digs[dno++] = str[i++];
|
||||||
} while (octal_digit(str[i]) && dno < 3);
|
} while (octal_digit(str[i]) && dno < 3);
|
||||||
ch = strtol(digs, NULL, 8);
|
ch = strtol(digs, NULL, 8);
|
||||||
}
|
}
|
||||||
else if (str[0] == 'x') {
|
else if (str[0] == 'x') {
|
||||||
while (hex_digit(str[i]) && dno < 2) {
|
while (hex_digit(str[i]) && dno < 2) {
|
||||||
digs[dno++] = str[i++];
|
digs[dno++] = str[i++];
|
||||||
}
|
}
|
||||||
if (dno > 0)
|
if (dno > 0)
|
||||||
ch = strtol(digs, NULL, 16);
|
ch = strtol(digs, NULL, 16);
|
||||||
}
|
}
|
||||||
else if (str[0] == 'u') {
|
else if (str[0] == 'u') {
|
||||||
while (hex_digit(str[i]) && dno < 4) {
|
while (hex_digit(str[i]) && dno < 4) {
|
||||||
digs[dno++] = str[i++];
|
digs[dno++] = str[i++];
|
||||||
}
|
}
|
||||||
if (dno > 0)
|
if (dno > 0)
|
||||||
ch = strtol(digs, NULL, 16);
|
ch = strtol(digs, NULL, 16);
|
||||||
}
|
}
|
||||||
else if (str[0] == 'U') {
|
else if (str[0] == 'U') {
|
||||||
while (hex_digit(str[i]) && dno < 8) {
|
while (hex_digit(str[i]) && dno < 8) {
|
||||||
digs[dno++] = str[i++];
|
digs[dno++] = str[i++];
|
||||||
}
|
}
|
||||||
if (dno > 0)
|
if (dno > 0)
|
||||||
ch = strtol(digs, NULL, 16);
|
ch = strtol(digs, NULL, 16);
|
||||||
}
|
}
|
||||||
*dest = ch;
|
*dest = ch;
|
||||||
|
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* convert a string with literal \uxxxx or \Uxxxxxxxx characters to UTF-8
|
/* convert a string with literal \uxxxx or \Uxxxxxxxx characters to UTF-8
|
||||||
example: u8_unescape(mybuf, 256, "hello\\u220e")
|
example: u8_unescape(mybuf, 256, "hello\\u220e")
|
||||||
note the double backslash is needed if called on a C string literal */
|
note the double backslash is needed if called on a C string literal */
|
||||||
SWITCH_DECLARE(int) switch_u8_unescape(char *buf, int sz, char *src)
|
SWITCH_DECLARE(int) switch_u8_unescape(char *buf, int sz, char *src)
|
||||||
{
|
{
|
||||||
int c=0, amt;
|
int c=0, amt;
|
||||||
uint32_t ch;
|
uint32_t ch;
|
||||||
char temp[4];
|
char temp[4];
|
||||||
|
|
||||||
while (*src && c < sz) {
|
while (*src && c < sz) {
|
||||||
if (*src == '\\') {
|
if (*src == '\\') {
|
||||||
src++;
|
src++;
|
||||||
amt = switch_u8_read_escape_sequence(src, &ch);
|
amt = switch_u8_read_escape_sequence(src, &ch);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ch = (uint32_t)*src;
|
ch = (uint32_t)*src;
|
||||||
amt = 1;
|
amt = 1;
|
||||||
}
|
}
|
||||||
src += amt;
|
src += amt;
|
||||||
amt = switch_u8_wc_toutf8(temp, ch);
|
amt = switch_u8_wc_toutf8(temp, ch);
|
||||||
if (amt > sz-c)
|
if (amt > sz-c)
|
||||||
break;
|
break;
|
||||||
memcpy(&buf[c], temp, amt);
|
memcpy(&buf[c], temp, amt);
|
||||||
c += amt;
|
c += amt;
|
||||||
}
|
}
|
||||||
if (c < sz)
|
if (c < sz)
|
||||||
buf[c] = '\0';
|
buf[c] = '\0';
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
SWITCH_DECLARE(int) switch_u8_escape_wchar(char *buf, int sz, uint32_t ch)
|
SWITCH_DECLARE(int) switch_u8_escape_wchar(char *buf, int sz, uint32_t ch)
|
||||||
{
|
{
|
||||||
if (ch == L'\n')
|
if (ch == L'\n')
|
||||||
return snprintf(buf, sz, "\\n");
|
return snprintf(buf, sz, "\\n");
|
||||||
else if (ch == L'\t')
|
else if (ch == L'\t')
|
||||||
return snprintf(buf, sz, "\\t");
|
return snprintf(buf, sz, "\\t");
|
||||||
else if (ch == L'\r')
|
else if (ch == L'\r')
|
||||||
return snprintf(buf, sz, "\\r");
|
return snprintf(buf, sz, "\\r");
|
||||||
else if (ch == L'\b')
|
else if (ch == L'\b')
|
||||||
return snprintf(buf, sz, "\\b");
|
return snprintf(buf, sz, "\\b");
|
||||||
else if (ch == L'\f')
|
else if (ch == L'\f')
|
||||||
return snprintf(buf, sz, "\\f");
|
return snprintf(buf, sz, "\\f");
|
||||||
else if (ch == L'\v')
|
else if (ch == L'\v')
|
||||||
return snprintf(buf, sz, "\\v");
|
return snprintf(buf, sz, "\\v");
|
||||||
else if (ch == L'\a')
|
else if (ch == L'\a')
|
||||||
return snprintf(buf, sz, "\\a");
|
return snprintf(buf, sz, "\\a");
|
||||||
else if (ch == L'\\')
|
else if (ch == L'\\')
|
||||||
return snprintf(buf, sz, "\\\\");
|
return snprintf(buf, sz, "\\\\");
|
||||||
else if (ch < 32 || ch == 0x7f)
|
else if (ch < 32 || ch == 0x7f)
|
||||||
return snprintf(buf, sz, "\\x%hhX", (unsigned char)ch);
|
return snprintf(buf, sz, "\\x%hhX", (unsigned char)ch);
|
||||||
else if (ch > 0xFFFF)
|
else if (ch > 0xFFFF)
|
||||||
return snprintf(buf, sz, "\\U%.8X", (uint32_t)ch);
|
return snprintf(buf, sz, "\\U%.8X", (uint32_t)ch);
|
||||||
else if (ch >= 0x80 && ch <= 0xFFFF)
|
else if (ch >= 0x80 && ch <= 0xFFFF)
|
||||||
return snprintf(buf, sz, "\\u%.4hX", (unsigned short)ch);
|
return snprintf(buf, sz, "\\u%.4hX", (unsigned short)ch);
|
||||||
|
|
||||||
return snprintf(buf, sz, "%c", (char)ch);
|
return snprintf(buf, sz, "%c", (char)ch);
|
||||||
}
|
}
|
||||||
|
|
||||||
SWITCH_DECLARE(int) switch_u8_escape(char *buf, int sz, char *src, int escape_quotes)
|
SWITCH_DECLARE(int) switch_u8_escape(char *buf, int sz, char *src, int escape_quotes)
|
||||||
{
|
{
|
||||||
int c=0, i=0, amt;
|
int c=0, i=0, amt;
|
||||||
|
|
||||||
while (src[i] && c < sz) {
|
while (src[i] && c < sz) {
|
||||||
if (escape_quotes && src[i] == '"') {
|
if (escape_quotes && src[i] == '"') {
|
||||||
amt = snprintf(buf, sz - c, "\\\"");
|
amt = snprintf(buf, sz - c, "\\\"");
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
amt = switch_u8_escape_wchar(buf, sz - c, switch_u8_nextchar(src, &i));
|
amt = switch_u8_escape_wchar(buf, sz - c, switch_u8_nextchar(src, &i));
|
||||||
}
|
}
|
||||||
c += amt;
|
c += amt;
|
||||||
buf += amt;
|
buf += amt;
|
||||||
}
|
}
|
||||||
if (c < sz)
|
if (c < sz)
|
||||||
*buf = '\0';
|
*buf = '\0';
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
SWITCH_DECLARE(char *) switch_u8_strchr(char *s, uint32_t ch, int *charn)
|
SWITCH_DECLARE(char *) switch_u8_strchr(char *s, uint32_t ch, int *charn)
|
||||||
{
|
{
|
||||||
int i = 0, lasti=0;
|
int i = 0, lasti=0;
|
||||||
uint32_t c;
|
uint32_t c;
|
||||||
|
|
||||||
*charn = 0;
|
*charn = 0;
|
||||||
while (s[i]) {
|
while (s[i]) {
|
||||||
c = switch_u8_nextchar(s, &i);
|
c = switch_u8_nextchar(s, &i);
|
||||||
if (c == ch) {
|
if (c == ch) {
|
||||||
return &s[lasti];
|
return &s[lasti];
|
||||||
}
|
}
|
||||||
lasti = i;
|
lasti = i;
|
||||||
(*charn)++;
|
(*charn)++;
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
SWITCH_DECLARE(char *) switch_u8_memchr(char *s, uint32_t ch, size_t sz, int *charn)
|
SWITCH_DECLARE(char *) switch_u8_memchr(char *s, uint32_t ch, size_t sz, int *charn)
|
||||||
{
|
{
|
||||||
int i = 0, lasti=0;
|
int i = 0, lasti=0;
|
||||||
uint32_t c;
|
uint32_t c;
|
||||||
int csz;
|
int csz;
|
||||||
|
|
||||||
*charn = 0;
|
*charn = 0;
|
||||||
while (i < sz) {
|
while (i < sz) {
|
||||||
c = csz = 0;
|
c = csz = 0;
|
||||||
do {
|
do {
|
||||||
c <<= 6;
|
c <<= 6;
|
||||||
c += (unsigned char)s[i++];
|
c += (unsigned char)s[i++];
|
||||||
csz++;
|
csz++;
|
||||||
} while (i < sz && !isutf(s[i]));
|
} while (i < sz && !isutf(s[i]));
|
||||||
c -= offsetsFromUTF8[csz-1];
|
c -= offsetsFromUTF8[csz-1];
|
||||||
|
|
||||||
if (c == ch) {
|
if (c == ch) {
|
||||||
return &s[lasti];
|
return &s[lasti];
|
||||||
}
|
}
|
||||||
lasti = i;
|
lasti = i;
|
||||||
(*charn)++;
|
(*charn)++;
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
SWITCH_DECLARE(int) switch_u8_is_locale_utf8(char *locale)
|
SWITCH_DECLARE(int) switch_u8_is_locale_utf8(char *locale)
|
||||||
{
|
{
|
||||||
/* this code based on libutf8 */
|
/* this code based on libutf8 */
|
||||||
const char* cp = locale;
|
const char* cp = locale;
|
||||||
|
|
||||||
for (; *cp != '\0' && *cp != '@' && *cp != '+' && *cp != ','; cp++) {
|
for (; *cp != '\0' && *cp != '@' && *cp != '+' && *cp != ','; cp++) {
|
||||||
if (*cp == '.') {
|
if (*cp == '.') {
|
||||||
const char* encoding = ++cp;
|
const char* encoding = ++cp;
|
||||||
for (; *cp != '\0' && *cp != '@' && *cp != '+' && *cp != ','; cp++)
|
for (; *cp != '\0' && *cp != '@' && *cp != '+' && *cp != ','; cp++)
|
||||||
;
|
;
|
||||||
if ((cp-encoding == 5 && !strncmp(encoding, "UTF-8", 5))
|
if ((cp-encoding == 5 && !strncmp(encoding, "UTF-8", 5))
|
||||||
|| (cp-encoding == 4 && !strncmp(encoding, "utf8", 4)))
|
|| (cp-encoding == 4 && !strncmp(encoding, "utf8", 4)))
|
||||||
return 1; /* it's UTF-8 */
|
return 1; /* it's UTF-8 */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1838,7 +1838,7 @@ SWITCH_DECLARE(switch_status_t) switch_find_local_ip(char *buf, int len, int *ma
|
||||||
#endif
|
#endif
|
||||||
SWITCH_DECLARE(switch_status_t) switch_find_interface_ip(char *buf, int len, int *mask, const char *ifname, int family)
|
SWITCH_DECLARE(switch_status_t) switch_find_interface_ip(char *buf, int len, int *mask, const char *ifname, int family)
|
||||||
{
|
{
|
||||||
switch_status_t status = SWITCH_STATUS_FALSE;
|
switch_status_t status = SWITCH_STATUS_FALSE;
|
||||||
|
|
||||||
#ifdef HAVE_GETIFADDRS
|
#ifdef HAVE_GETIFADDRS
|
||||||
|
|
||||||
|
|
|
@ -1041,15 +1041,15 @@ static switch_status_t switch_vpx_decode(switch_codec_t *codec, switch_frame_t *
|
||||||
is_keyframe = IS_VP8_KEY_FRAME((uint8_t *)frame->data);
|
is_keyframe = IS_VP8_KEY_FRAME((uint8_t *)frame->data);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (context->got_key_frame <= 0) {
|
if (context->got_key_frame <= 0) {
|
||||||
context->no_key_frame++;
|
context->no_key_frame++;
|
||||||
//switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "no keyframe, %d\n", context->no_key_frame);
|
//switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "no keyframe, %d\n", context->no_key_frame);
|
||||||
if (context->no_key_frame > 50) {
|
if (context->no_key_frame > 50) {
|
||||||
if ((is_keyframe = is_start)) {
|
if ((is_keyframe = is_start)) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "no keyframe, treating start as key.\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "no keyframe, treating start as key.\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (is_keyframe) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "got key %d\n", is_keyframe);
|
// if (is_keyframe) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "got key %d\n", is_keyframe);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue