if (switch_core_codec_init(&tech_pvt->read_codec,
dname,
NULL,
+ NULL,
srate,
interval,
1,
if (switch_core_codec_init(&tech_pvt->write_codec,
dname,
NULL,
+ NULL,
srate,
interval,
1,
if (switch_core_codec_init(&tech_pvt->read_codec,
dname,
NULL,
+ NULL,
8000,
interval,
1,
if (switch_core_codec_init(&tech_pvt->write_codec,
dname,
NULL,
+ NULL,
8000,
interval,
1,
if (out_asis) {
- if (switch_core_codec_init_with_bitrate(&codec, format, fmtp, rate, ptime, channels, bitrate, SWITCH_CODEC_FLAG_ENCODE, NULL, pool) != SWITCH_STATUS_SUCCESS) {
+ if (switch_core_codec_init_with_bitrate(&codec, format, NULL, fmtp, rate, ptime, channels, bitrate, SWITCH_CODEC_FLAG_ENCODE, NULL, pool) != SWITCH_STATUS_SUCCESS) {
fprintf(stderr, "Couldn't initialize codec for %s@%dh@%di\n", format, rate, ptime);
goto end;
}
if ((p = strchr(input, '.'))) {
p++;
}
- if (!p || switch_core_codec_init_with_bitrate(&codec, p, fmtp, rate, ptime, channels, bitrate, SWITCH_CODEC_FLAG_ENCODE|SWITCH_CODEC_FLAG_DECODE, NULL, pool) != SWITCH_STATUS_SUCCESS) {
+ if (!p || switch_core_codec_init_with_bitrate(&codec, p, NULL, fmtp, rate, ptime, channels, bitrate, SWITCH_CODEC_FLAG_ENCODE|SWITCH_CODEC_FLAG_DECODE, NULL, pool) != SWITCH_STATUS_SUCCESS) {
fprintf(stderr, "Couldn't initialize codec for %s@%dh@%di\n", p, rate, ptime);
goto end;
}
- if (switch_core_codec_init_with_bitrate(&raw_codec, "L16", fmtp, rate, ptime, channels, bitrate, SWITCH_CODEC_FLAG_ENCODE|SWITCH_CODEC_FLAG_DECODE, NULL, pool) != SWITCH_STATUS_SUCCESS) {
+ if (switch_core_codec_init_with_bitrate(&raw_codec, "L16", NULL, fmtp, rate, ptime, channels, bitrate, SWITCH_CODEC_FLAG_ENCODE|SWITCH_CODEC_FLAG_DECODE, NULL, pool) != SWITCH_STATUS_SUCCESS) {
fprintf(stderr, "Couldn't initialize codec for %s@%dh@%di\n", "L16", rate, ptime);
goto end;
}
\param pool the memory pool to use
\return SWITCH_STATUS_SUCCESS if the handle is allocated
*/
-#define switch_core_codec_init(_codec, _codec_name, _fmtp, _rate, _ms, _channels, _flags, _codec_settings, _pool) \
- switch_core_codec_init_with_bitrate(_codec, _codec_name, _fmtp, _rate, _ms, _channels, 0, _flags, _codec_settings, _pool)
+#define switch_core_codec_init(_codec, _codec_name, _modname, _fmtp, _rate, _ms, _channels, _flags, _codec_settings, _pool) \
+ switch_core_codec_init_with_bitrate(_codec, _codec_name, _modname, _fmtp, _rate, _ms, _channels, 0, _flags, _codec_settings, _pool)
SWITCH_DECLARE(switch_status_t) switch_core_codec_init_with_bitrate(switch_codec_t *codec,
- const char *codec_name,
- const char *fmtp,
- uint32_t rate,
- int ms,
- int channels,
- uint32_t bitrate,
- uint32_t flags, const switch_codec_settings_t *codec_settings, switch_memory_pool_t *pool);
-
+ const char *codec_name,
+ const char *fmtp,
+ const char *modname,
+ uint32_t rate,
+ int ms,
+ int channels,
+ uint32_t bitrate,
+ uint32_t flags,
+ const switch_codec_settings_t *codec_settings,
+ switch_memory_pool_t *pool);
+
SWITCH_DECLARE(switch_status_t) switch_core_codec_copy(switch_codec_t *codec, switch_codec_t *new_codec,
const switch_codec_settings_t *codec_settings, switch_memory_pool_t *pool);
SWITCH_DECLARE(switch_status_t) switch_core_codec_parse_fmtp(const char *codec_name, const char *fmtp, uint32_t rate, switch_codec_fmtp_t *codec_fmtp);
SWITCH_DECLARE(payload_map_t *) switch_core_media_add_payload_map(switch_core_session_t *session,
switch_media_type_t type,
const char *name,
+ const char *modname,
const char *fmtp,
switch_sdp_type_t sdp_type,
uint32_t pt,
\param name the name of the codec
\return the desired codec interface
*/
-SWITCH_DECLARE(switch_codec_interface_t *) switch_loadable_module_get_codec_interface(const char *name);
+SWITCH_DECLARE(switch_codec_interface_t *) switch_loadable_module_get_codec_interface(const char *name, const char *modname);
-SWITCH_DECLARE(char *) switch_parse_codec_buf(char *buf, uint32_t *interval, uint32_t *rate, uint32_t *bit, uint32_t *channels);
+SWITCH_DECLARE(char *) switch_parse_codec_buf(char *buf, uint32_t *interval, uint32_t *rate, uint32_t *bit, uint32_t *channels, char **modname);
/*!
\brief Retrieve the dialplan interface by it's registered name
#define SWITCH_ADD_CODEC(codec_int, int_name) \
for (;;) { \
codec_int = (switch_codec_interface_t *)switch_loadable_module_create_interface(*module_interface, SWITCH_CODEC_INTERFACE); \
+ codec_int->modname = switch_core_strdup(pool, (*module_interface)->module_name); \
codec_int->interface_name = switch_core_strdup(pool, int_name); \
codec_int->codec_id = switch_core_codec_next_id(); \
break; \
impl->codec_id = codec_interface->codec_id;
impl->next = codec_interface->implementations;
impl->impl_id = switch_core_codec_next_id();
+ impl->modname = codec_interface->modname;
codec_interface->implementations = impl;
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Rejected codec name: %s rate: %u ptime: %d channels: %d\n",
impl->codec_id = codec_interface->codec_id;
impl->next = codec_interface->implementations;
impl->impl_id = switch_core_codec_next_id();
+ impl->modname = codec_interface->modname;
codec_interface->implementations = impl;
}
switch_core_codec_destroy_func_t destroy;
uint32_t codec_id;
uint32_t impl_id;
+ char *modname;
struct switch_codec_implementation *next;
};
switch_thread_rwlock_t *rwlock;
int refs;
switch_mutex_t *reflock;
+ char *modname;
switch_loadable_module_interface_t *parent;
struct switch_codec_interface *next;
};
char *rm_encoding;
char *iananame;
+ char *modname;
switch_payload_t pt;
unsigned long rm_rate;
unsigned long adv_rm_rate;
if (switch_core_codec_init(&codec,
"L16",
NULL,
+ NULL,
// read_impl.samples_per_second,
44100, // todo: not hard coded?
read_impl.microseconds_per_packet / 1000,
if (switch_core_codec_init(&codec,
"L16",
- NULL, (int) read_impl.samples_per_second, read_impl.microseconds_per_packet / 1000,
+ NULL, NULL, (int) read_impl.samples_per_second, read_impl.microseconds_per_packet / 1000,
1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL,
switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
return -1;
/* Setup a Signed Linear codec for reading audio. */
if (switch_core_codec_init(&member->read_codec,
"L16",
- NULL, read_impl.actual_samples_per_second, read_impl.microseconds_per_packet / 1000,
+ NULL, NULL, read_impl.actual_samples_per_second, read_impl.microseconds_per_packet / 1000,
read_impl.number_of_channels,
SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, member->pool) == SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(member->session), SWITCH_LOG_DEBUG,
if (switch_core_codec_init(&member->write_codec,
"L16",
NULL,
+ NULL,
conference->rate,
read_impl.microseconds_per_packet / 1000,
read_impl.number_of_channels,
if (switch_core_codec_init(&codec,
"L16",
NULL,
+ NULL,
read_rate,
20,
1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
if (switch_core_codec_init(&write_codec,
codec_name,
NULL,
+ NULL,
8000,
20,
1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
if (switch_core_codec_init(&codec,
"L16",
NULL,
+ NULL,
read_impl.samples_per_second,
read_impl.microseconds_per_packet / 1000,
1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
if (switch_core_codec_init(&codec,
"L16",
NULL,
+ NULL,
h.audio_rate,
h.audio_ptime,
1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
if (switch_core_codec_init(&vid_codec,
h.video_codec_name,
NULL,
+ NULL,
0,
0,
1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
MP4::Context ctx(reinterpret_cast<char*>(data), true);
if (switch_core_codec_init(&codec,
- "L16",
- NULL,
- read_impl.samples_per_second,
- read_impl.microseconds_per_packet / 1000,
- 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
- NULL, switch_core_session_get_pool(session)) == SWITCH_STATUS_SUCCESS)
+ "L16",
+ NULL,
+ NULL,
+ read_impl.samples_per_second,
+ read_impl.microseconds_per_packet / 1000,
+ 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
+ NULL, switch_core_session_get_pool(session)) == SWITCH_STATUS_SUCCESS)
{
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Audio Codec Activation Success\n");
} else {
}
if (switch_core_codec_init(&codec,
- vc.audioTrack().codecName,
- NULL,
- vc.audioTrack().clock,
- vc.audioTrack().packetLength,
- 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
- NULL, switch_core_session_get_pool(session)) == SWITCH_STATUS_SUCCESS) {
+ vc.audioTrack().codecName,
+ NULL,
+ NULL,
+ vc.audioTrack().clock,
+ vc.audioTrack().packetLength,
+ 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
+ NULL, switch_core_session_get_pool(session)) == SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Audio Codec Activation Success\n");
} else {
throw Exception("Audio Codec Activation Fail");
}
if (switch_core_codec_init(&vid_codec,
- vc.videoTrack().track.codecName,
- NULL,
- 0,
- 0,
- 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
- NULL, switch_core_session_get_pool(session)) == SWITCH_STATUS_SUCCESS) {
+ vc.videoTrack().track.codecName,
+ NULL,
+ NULL,
+ 0,
+ 0,
+ 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
+ NULL, switch_core_session_get_pool(session)) == SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Video Codec Activation Success\n");
} else
{
if (switch_core_codec_init(&codec,
"PCMU",
NULL,
+ NULL,
read_impl.samples_per_second,
read_impl.microseconds_per_packet / 1000,
read_impl.number_of_channels, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
if (switch_core_codec_init(&context->audio_codec,
get_audio_codec_name(context->audio_type),
NULL,
+ NULL,
handle->samplerate,
20,//ms
handle->channels, SWITCH_CODEC_FLAG_ENCODE,
if (switch_test_flag(handle, SWITCH_FILE_FLAG_VIDEO)) {
if (switch_core_codec_init(&context->video_codec,
- "H264",
- NULL,
- 90000,
- 0,//ms
- 1, SWITCH_CODEC_FLAG_ENCODE,
- NULL, handle->memory_pool) == SWITCH_STATUS_SUCCESS) {
+ "H264",
+ NULL,
+ NULL,
+ 90000,
+ 0,//ms
+ 1, SWITCH_CODEC_FLAG_ENCODE,
+ NULL, handle->memory_pool) == SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Video Codec H264 Activation Success\n");
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Video Codec H264 Activation Fail\n");
if (switch_core_codec_init(&speech_codec,
"L16",
NULL,
+ NULL,
(int) rate,
interval,
1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL,
switch_core_session_get_read_impl(session, &read_impl);
if (switch_core_codec_init(&write_codec,
- "L16",
- NULL,
- read_impl.actual_samples_per_second,
- read_impl.microseconds_per_packet / 1000,
- read_impl.number_of_channels,
- SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL,
- switch_core_session_get_pool(session)) == SWITCH_STATUS_SUCCESS) {
- write_frame.data = write_buf;
- write_frame.buflen = sizeof(write_buf);
- write_frame.datalen = read_impl.decoded_bytes_per_packet;
- write_frame.samples = write_frame.datalen / 2;
- write_frame.codec = &write_codec;
+ "L16",
+ NULL,
+ NULL,
+ read_impl.actual_samples_per_second,
+ read_impl.microseconds_per_packet / 1000,
+ read_impl.number_of_channels,
+ SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL,
+ switch_core_session_get_pool(session)) == SWITCH_STATUS_SUCCESS) {
+ write_frame.data = write_buf;
+ write_frame.buflen = sizeof(write_buf);
+ write_frame.datalen = read_impl.decoded_bytes_per_packet;
+ write_frame.samples = write_frame.datalen / 2;
+ write_frame.codec = &write_codec;
switch_core_session_set_read_codec(session, &write_codec);
} else {
return SWITCH_STATUS_FALSE;
*/
if (switch_core_codec_init(&read_codec,
"L16",
+ NULL,
NULL,
read_impl.samples_per_second,
read_impl.microseconds_per_packet / 1000,
if (switch_core_codec_init(&write_codec,
"L16",
+ NULL,
NULL,
read_impl.samples_per_second,
read_impl.microseconds_per_packet / 1000,
if (switch_core_codec_init(&read_codec,
"L16",
+ NULL,
NULL,
read_impl.samples_per_second,
read_impl.microseconds_per_packet / 1000,
if (switch_core_codec_init(&write_codec,
"L16",
+ NULL,
NULL,
read_impl.samples_per_second,
read_impl.microseconds_per_packet / 1000,
status = switch_core_codec_init(&tech_pvt->read_codec,
iananame,
+ NULL,
NULL,
rate, interval, 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, switch_core_session_get_pool(session));
status = switch_core_codec_init(&tech_pvt->write_codec,
iananame,
+ NULL,
NULL,
rate, interval, 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, switch_core_session_get_pool(session));
switch_core_codec_add_video_implementation(pool, codec_interface, 99, "H264", NULL,
switch_h264_init, switch_h264_encode, switch_h264_decode, switch_h264_control, switch_h264_destroy);
+
/* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS;
}
if (switch_core_codec_init(&tech_pvt->write_codec,
"L16",
NULL,
+ NULL,
sample_rate,
codec_ms,
1,
if (switch_core_codec_init(&globals.read_codec,
"L16",
- NULL, sample_rate, codec_ms, 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, NULL) != SWITCH_STATUS_SUCCESS) {
+ NULL, NULL, sample_rate, codec_ms, 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, NULL) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n");
return SWITCH_STATUS_FALSE;
} else {
if (switch_core_codec_init(&globals.write_codec,
"L16",
- NULL,
+ NULL, NULL,
sample_rate, codec_ms, 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, NULL) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n");
switch_core_codec_destroy(&globals.read_codec);
if (switch_core_codec_init(&tech_pvt->transports[LDL_TPORT_RTP].read_codec,
tech_pvt->transports[LDL_TPORT_RTP].codec_name,
NULL,
+ NULL,
tech_pvt->transports[LDL_TPORT_RTP].codec_rate,
ms,
1,
if (switch_core_codec_init(&tech_pvt->transports[LDL_TPORT_RTP].write_codec,
tech_pvt->transports[LDL_TPORT_RTP].codec_name,
NULL,
+ NULL,
tech_pvt->transports[LDL_TPORT_RTP].codec_rate,
ms,
1,
if (switch_core_codec_init(&tech_pvt->transports[LDL_TPORT_VIDEO_RTP].read_codec,
tech_pvt->transports[LDL_TPORT_VIDEO_RTP].codec_name,
NULL,
+ NULL,
tech_pvt->transports[LDL_TPORT_VIDEO_RTP].codec_rate,
ms,
1,
if (switch_core_codec_init(&tech_pvt->transports[LDL_TPORT_VIDEO_RTP].write_codec,
tech_pvt->transports[LDL_TPORT_VIDEO_RTP].codec_name,
NULL,
+ NULL,
tech_pvt->transports[LDL_TPORT_VIDEO_RTP].codec_rate,
ms,
1,
switch_core_session_t *session = NULL;
if (switch_core_codec_init
- (&tech_pvt->read_codec, "L16", NULL, sample_rate, codec_ms, 1,
+ (&tech_pvt->read_codec, "L16", NULL, NULL, sample_rate, codec_ms, 1,
SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, NULL) != SWITCH_STATUS_SUCCESS) {
ERRORA("Can't load codec?\n", GSMOPEN_P_LOG);
return SWITCH_STATUS_FALSE;
}
if (switch_core_codec_init
- (&tech_pvt->write_codec, "L16", NULL, sample_rate, codec_ms, 1,
+ (&tech_pvt->write_codec, "L16", NULL, NULL, sample_rate, codec_ms, 1,
SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, NULL) != SWITCH_STATUS_SUCCESS) {
ERRORA("Can't load codec?\n", GSMOPEN_P_LOG);
switch_core_codec_destroy(&tech_pvt->read_codec);
switch_core_session_t *session = NULL;
if (switch_core_codec_init
- (&tech_pvt->read_codec, "L16", NULL, sample_rate, codec_ms, 1,
+ (&tech_pvt->read_codec, "L16", NULL, NULL, sample_rate, codec_ms, 1,
SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, NULL) != SWITCH_STATUS_SUCCESS) {
ERRORA("Can't load codec?\n", GSMOPEN_P_LOG);
return SWITCH_STATUS_FALSE;
}
if (switch_core_codec_init
- (&tech_pvt->write_codec, "L16", NULL, sample_rate, codec_ms, 1,
+ (&tech_pvt->write_codec, "L16", NULL, NULL, sample_rate, codec_ms, 1,
SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, NULL) != SWITCH_STATUS_SUCCESS) {
ERRORA("Can't load codec?\n", GSMOPEN_P_LOG);
switch_core_codec_destroy(&tech_pvt->read_codec);
tech_pvt->read_frame.codec = &tech_pvt->read_codec; /* Set codec here - no need to set it every time a frame is read */
- if (switch_core_codec_init(codec, GetH245CodecName(m_capability), NULL, // FMTP
+ if (switch_core_codec_init(codec, GetH245CodecName(m_capability), NULL, NULL, // FMTP
8000, m_codec_ms, 1, // Channels
SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, // Settings
switch_core_session_get_pool(m_fsSession)) != SWITCH_STATUS_SUCCESS) {
- if (switch_core_codec_init(codec, GetH245CodecName(m_capability), NULL, // FMTP
+ if (switch_core_codec_init(codec, GetH245CodecName(m_capability), NULL, NULL, // FMTP
8000, 0, 1, // Channels
SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, // Settings
switch_core_session_get_pool(m_fsSession)) != SWITCH_STATUS_SUCCESS) {
switch_core_session_add_stream(session(), NULL);
- if (switch_core_codec_init(&_read_codec, "PCMA", NULL, 8000, Globals::switch_packet_duration, 1,
+ if (switch_core_codec_init(&_read_codec, "PCMA", NULL, NULL, 8000, Globals::switch_packet_duration, 1,
SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL,
(pool ? *pool : NULL)) != SWITCH_STATUS_SUCCESS)
{
return SWITCH_STATUS_FALSE;
}
- if (switch_core_codec_init(&_write_codec, "PCMA", NULL, 8000, Globals::switch_packet_duration, 1,
+ if (switch_core_codec_init(&_write_codec, "PCMA", NULL, NULL, 8000, Globals::switch_packet_duration, 1,
SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL,
(pool ? *pool : NULL)) != SWITCH_STATUS_SUCCESS)
{
interval = codec->implementation->microseconds_per_packet / 1000;
} else {
const char *var;
+ char *modname = NULL;
if ((var = switch_channel_get_variable(channel, "loopback_initial_codec"))) {
char *dup = switch_core_session_strdup(session, var);
uint32_t bit, channels;
- iananame = switch_parse_codec_buf(dup, &interval, &rate, &bit, &channels);
+ iananame = switch_parse_codec_buf(dup, &interval, &rate, &bit, &channels, &modname);
}
}
status = switch_core_codec_init(&tech_pvt->read_codec,
iananame,
NULL,
+ NULL,
rate, interval, 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, switch_core_session_get_pool(session));
if (status != SWITCH_STATUS_SUCCESS || !tech_pvt->read_codec.implementation || !switch_core_codec_ready(&tech_pvt->read_codec)) {
status = switch_core_codec_init(&tech_pvt->write_codec,
iananame,
NULL,
+ NULL,
rate, interval, 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, switch_core_session_get_pool(session));
}
// The following is performed on two different instances of this object.
- if (switch_core_codec_init(m_switchCodec, mediaFormat.GetEncodingName(), NULL, // FMTP
+ if (switch_core_codec_init(m_switchCodec, mediaFormat.GetEncodingName(), NULL, NULL, // FMTP
mediaFormat.GetClockRate(), ptime, 1, // Channels
SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, // Settings
switch_core_session_get_pool(fsSession)) != SWITCH_STATUS_SUCCESS) {
// Could not select a codecs using negotiated frames/packet, so try using default.
- if (switch_core_codec_init(m_switchCodec, mediaFormat.GetEncodingName(), NULL, // FMTP
+ if (switch_core_codec_init(m_switchCodec, mediaFormat.GetEncodingName(), NULL, NULL, // FMTP
mediaFormat.GetClockRate(), 0, 1, // Channels
SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, // Settings
switch_core_session_get_pool(fsSession)) != SWITCH_STATUS_SUCCESS) {
}
if (switch_core_codec_init(&endpoint->read_codec,
- "L16", NULL, sample_rate, codec_ms, 1,
- SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, NULL) != SWITCH_STATUS_SUCCESS) {
+ "L16", NULL, NULL, sample_rate, codec_ms, 1,
+ SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, NULL) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n");
goto error;
}
if (switch_core_codec_init(&endpoint->write_codec,
- "L16", NULL, sample_rate, codec_ms, 1,
- SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, NULL) != SWITCH_STATUS_SUCCESS) {
+ "L16", NULL, NULL, sample_rate, codec_ms, 1,
+ SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, NULL) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n");
goto error;
}
if (!switch_core_codec_ready(&globals.read_codec)) {
if (switch_core_codec_init(&globals.read_codec,
"L16",
+ NULL,
NULL, sample_rate, codec_ms, 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL,
NULL) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n");
if (switch_core_codec_init(&globals.write_codec,
"L16",
NULL,
+ NULL,
sample_rate, codec_ms, 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, NULL) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n");
switch_core_codec_destroy(&globals.read_codec);
tech_pvt->channel = switch_core_session_get_channel(session);
/* Initialize read & write codecs */
- if (switch_core_codec_init(&tech_pvt->read_codec, /* name */ "SPEEX",
+ if (switch_core_codec_init(&tech_pvt->read_codec, /* name */ "SPEEX", /* modname */ NULL,
/* fmtp */ NULL, /* rate */ 16000, /* ms */ 20, /* channels */ 1,
/* flags */ SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
/* codec settings */ NULL, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
return SWITCH_STATUS_FALSE;
}
- if (switch_core_codec_init(&tech_pvt->write_codec, /* name */ "SPEEX",
+ if (switch_core_codec_init(&tech_pvt->write_codec, /* name */ "SPEEX", /* modname */ NULL,
/* fmtp */ NULL, /* rate */ 16000, /* ms */ 20, /* channels */ 1,
/* flags */ SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
/* codec settings */ NULL, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
}
if (switch_core_codec_init(&tech_pvt->read_codec,
- tech_pvt->iananame,
- tech_pvt->rm_fmtp,
- tech_pvt->rm_rate,
- tech_pvt->codec_ms,
- 1,
- SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE | 0 /* TODO tech_pvt->profile->codec_flags */,
- NULL, switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) {
+ tech_pvt->iananame,
+ NULL,
+ tech_pvt->rm_fmtp,
+ tech_pvt->rm_rate,
+ tech_pvt->codec_ms,
+ 1,
+ SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE | 0 /* TODO tech_pvt->profile->codec_flags */,
+ NULL, switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_ERROR, "Can't load codec?\n");
switch_goto_status(SWITCH_STATUS_FALSE, end);
}
if (switch_core_codec_init(&tech_pvt->write_codec,
- tech_pvt->iananame,
- tech_pvt->rm_fmtp,
- tech_pvt->rm_rate,
- tech_pvt->codec_ms,
- 1,
- SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE | 0 /* TODO tech_pvt->profile->codec_flags */,
- NULL, switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) {
+ tech_pvt->iananame,
+ NULL,
+ tech_pvt->rm_fmtp,
+ tech_pvt->rm_rate,
+ tech_pvt->codec_ms,
+ 1,
+ SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE | 0 /* TODO tech_pvt->profile->codec_flags */,
+ NULL, switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_ERROR, "Can't load codec?\n");
switch_goto_status(SWITCH_STATUS_FALSE, end);
}
switch_core_session_t *session = NULL;
if (switch_core_codec_init
- (&tech_pvt->read_codec, "L16", NULL, sample_rate, codec_ms, 1,
+ (&tech_pvt->read_codec, "L16", NULL, NULL, sample_rate, codec_ms, 1,
SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, NULL) != SWITCH_STATUS_SUCCESS) {
ERRORA("skypopen_codec: Can't load codec?\n", SKYPOPEN_P_LOG);
return SWITCH_STATUS_FALSE;
}
if (switch_core_codec_init
- (&tech_pvt->write_codec, "L16", NULL, sample_rate, codec_ms, 1,
+ (&tech_pvt->write_codec, "L16", NULL, NULL, sample_rate, codec_ms, 1,
SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, NULL) != SWITCH_STATUS_SUCCESS) {
ERRORA("skypopen_codec: Can't load codec?\n", SKYPOPEN_P_LOG);
switch_core_codec_destroy(&tech_pvt->read_codec);
if (switch_core_codec_init(&tech_pvt->read_codec,
codec,
NULL,
+ NULL,
rate,
ptime,
1,
if (switch_core_codec_init(&tech_pvt->write_codec,
codec,
NULL,
+ NULL,
rate,
ptime,
1,
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "Switching codec updating \n");
if (switch_core_codec_init(&tech_pvt->read_codec,
- codec,
- NULL,
- rate,
- ptime,
- 1,
+ codec,
+ NULL,
+ NULL,
+ rate,
+ ptime,
+ 1,
/*SWITCH_CODEC_FLAG_ENCODE |*/ SWITCH_CODEC_FLAG_DECODE,
NULL, switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n");
goto fail;
} else {
if (switch_core_codec_init(&tech_pvt->write_codec,
- codec,
- NULL,
- rate,
- ptime,
- 1,
- SWITCH_CODEC_FLAG_ENCODE /*| SWITCH_CODEC_FLAG_DECODE*/,
- NULL, switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) {
+ codec,
+ NULL,
+ NULL,
+ rate,
+ ptime,
+ 1,
+ SWITCH_CODEC_FLAG_ENCODE /*| SWITCH_CODEC_FLAG_DECODE*/,
+ NULL, switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n");
goto fail;
}
if (switch_core_codec_init(&codec,
"L16",
NULL,
+ NULL,
force_sample_rate,
read_impl.microseconds_per_packet / 1000,
read_impl.number_of_channels, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
if (!switch_core_codec_ready(&source->read_codec)) {
if (switch_core_codec_init(&source->read_codec,
"L16",
- NULL, sample_rate, codec_ms, 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL,
+ NULL, NULL, sample_rate, codec_ms, 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL,
NULL) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n");
return SWITCH_STATUS_FALSE;
if (!switch_core_codec_ready(&source->write_codec)) {
if (switch_core_codec_init(&source->write_codec,
"L16",
- NULL,
+ NULL, NULL,
sample_rate, codec_ms, 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, NULL) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n");
switch_core_codec_destroy(&source->read_codec);
if (switch_core_codec_init(&codec,
"L16",
NULL,
+ NULL,
read_impl.actual_samples_per_second,
read_impl.microseconds_per_packet/1000,
read_impl.number_of_channels, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
if (switch_core_codec_init(&tech_pvt->read_codec,
"L16",
NULL,
+ NULL,
tech_pvt->read_impl.actual_samples_per_second,
tech_pvt->read_impl.microseconds_per_packet / 1000,
tech_pvt->read_impl.number_of_channels,
if (switch_core_codec_init(&tech_pvt->write_codec,
tech_pvt->read_impl.iananame,
+ tech_pvt->read_impl.modname,
NULL,
tech_pvt->read_impl.actual_samples_per_second,
tech_pvt->read_impl.microseconds_per_packet / 1000,
}
if (switch_core_codec_init(&tech_pvt->video_codec,
- codec_str,
- NULL,
- 90000,
- 0,
- 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
- NULL, switch_core_session_get_pool(tech_pvt->session)) == SWITCH_STATUS_SUCCESS) {
+ codec_str,
+ NULL,
+ NULL,
+ 90000,
+ 0,
+ 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
+ NULL, switch_core_session_get_pool(tech_pvt->session)) == SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(*new_session), SWITCH_LOG_DEBUG, "Video Codec Activation Success\n");
} else {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(*new_session), SWITCH_LOG_ERROR, "Video Codec Activation Fail\n");
if (switch_core_codec_init(&context->audio_codec,
AUDIO_CODEC,
+ NULL,
fmtp,
handle->samplerate,
20,//ms
if (switch_core_codec_init(&context->video_codec,
"VP8",
NULL,
+ NULL,
90000,
0,//ms
1, SWITCH_CODEC_FLAG_ENCODE,
if (switch_core_codec_init(&this->_speech->codec,
"L16",
NULL,
+ NULL,
rate,
interval,
1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL,
if (switch_core_codec_init(&tto->_codec,
"L16",
NULL,
+ NULL,
read_impl.actual_samples_per_second,
read_impl.microseconds_per_packet / 1000,
read_impl.number_of_channels, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, pool) == SWITCH_STATUS_SUCCESS) {
memset(codec_fmtp, 0, sizeof(*codec_fmtp));
- if ((codec_interface = switch_loadable_module_get_codec_interface(codec_name))) {
+ if ((codec_interface = switch_loadable_module_get_codec_interface(codec_name, NULL))) {
if (codec_interface->parse_fmtp) {
codec_fmtp->actual_samples_per_second = rate;
status = codec_interface->parse_fmtp(fmtp, codec_fmtp);
return switch_core_codec_init(new_codec,
codec->implementation->iananame,
+ codec->implementation->modname,
codec->fmtp_in,
codec->implementation->samples_per_second,
codec->implementation->microseconds_per_packet / 1000,
}
-SWITCH_DECLARE(switch_status_t) switch_core_codec_init_with_bitrate(switch_codec_t *codec, const char *codec_name, const char *fmtp,
+SWITCH_DECLARE(switch_status_t) switch_core_codec_init_with_bitrate(switch_codec_t *codec, const char *codec_name, const char *modname, const char *fmtp,
uint32_t rate, int ms, int channels, uint32_t bitrate, uint32_t flags,
const switch_codec_settings_t *codec_settings, switch_memory_pool_t *pool)
{
codec->session = switch_core_memory_pool_get_data(pool, "__session");
}
- if ((codec_interface = switch_loadable_module_get_codec_interface(codec_name)) == 0) {
+ if (strchr(codec_name, '.')) {
+ char *p = NULL;
+ codec_name = switch_core_strdup(pool, codec_name);
+ if ((p = strchr(codec_name, '.'))) {
+ *p++ = '\0';
+ modname = codec_name;
+ codec_name = p;
+ }
+ }
+
+ if ((codec_interface = switch_loadable_module_get_codec_interface(codec_name, modname)) == 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid codec %s!\n", codec_name);
return SWITCH_STATUS_GENERR;
}
SWITCH_DECLARE(payload_map_t *) switch_core_media_add_payload_map(switch_core_session_t *session,
switch_media_type_t type,
const char *name,
+ const char *modname,
const char *fmtp,
switch_sdp_type_t sdp_type,
uint32_t pt,
pmap->channels = channels;
}
+ if (modname) {
+ pmap->modname = switch_core_strdup(session->pool, modname);
+ }
+
if (!zstr(fmtp) && (zstr(pmap->rm_fmtp) || strcmp(pmap->rm_fmtp, fmtp))) {
pmap->rm_fmtp = switch_core_strdup(session->pool, fmtp);
}
if (!(preferred = switch_channel_get_variable(session->channel, "absolute_codec_string"))) {
preferred = switch_channel_get_variable(session->channel, "codec_string");
}
-
+
if (!preferred) {
if (switch_channel_direction(session->channel) == SWITCH_CALL_DIRECTION_OUTBOUND) {
preferred = smh->mparams->outbound_codec_string;
if (switch_core_codec_init(&v_engine->read_codec,
v_engine->cur_payload_map->rm_encoding,
+ v_engine->cur_payload_map->modname,
v_engine->cur_payload_map->rm_fmtp,
v_engine->cur_payload_map->rm_rate,
0,
} else {
if (switch_core_codec_init(&v_engine->write_codec,
v_engine->cur_payload_map->rm_encoding,
+ v_engine->cur_payload_map->modname,
v_engine->cur_payload_map->rm_fmtp,
v_engine->cur_payload_map->rm_rate,
0,
if (switch_core_codec_init_with_bitrate(&a_engine->read_codec,
a_engine->cur_payload_map->iananame,
+ a_engine->cur_payload_map->modname,
a_engine->cur_payload_map->rm_fmtp,
a_engine->cur_payload_map->rm_rate,
a_engine->cur_payload_map->codec_ms,
if (switch_core_codec_init_with_bitrate(&a_engine->write_codec,
a_engine->cur_payload_map->iananame,
+ a_engine->cur_payload_map->modname,
a_engine->cur_payload_map->rm_fmtp,
a_engine->cur_payload_map->rm_rate,
a_engine->cur_payload_map->codec_ms,
payload_map_t *pmap = switch_core_media_add_payload_map(session,
SWITCH_MEDIA_TYPE_AUDIO,
matches[j].map->rm_encoding,
+ matches[j].imp->modname,
matches[j].map->rm_fmtp,
sdp_type,
matches[j].map->rm_pt,
payload_map_t *pmap = switch_core_media_add_payload_map(session,
SWITCH_MEDIA_TYPE_VIDEO,
matches[j].map->rm_encoding,
+ matches[j].imp->modname,
matches[j].map->rm_fmtp,
sdp_type,
matches[j].map->rm_pt,
matches[j].imp->microseconds_per_packet / 1000,
matches[j].imp->number_of_channels,
SWITCH_TRUE);
+
if (j == 0) {
v_engine->cur_payload_map = pmap;
v_engine->cur_payload_map->current = 1;
switch_core_media_add_payload_map(session,
imp->codec_type == SWITCH_CODEC_TYPE_AUDIO ? SWITCH_MEDIA_TYPE_AUDIO : SWITCH_MEDIA_TYPE_VIDEO,
imp->iananame,
+ imp->modname,
NULL,
sdp_type,
smh->ianacodes[i],
SWITCH_MEDIA_TYPE_AUDIO,
"PROXY",
NULL,
+ NULL,
SDP_TYPE_RESPONSE,
0,
8000,
SWITCH_MEDIA_TYPE_AUDIO,
"PROXY-VID",
NULL,
+ NULL,
SDP_TYPE_RESPONSE,
0,
90000,
}
-static void add_audio_codec(sdp_rtpmap_t *map, int ptime, char *buf, switch_size_t buflen)
+static void add_audio_codec(sdp_rtpmap_t *map, const switch_codec_implementation_t *imp, int ptime, char *buf, switch_size_t buflen)
{
int codec_ms = ptime;
uint32_t map_bit_rate = 0, map_channels = 1;
switch_snprintf(bitstr, sizeof(bitstr), "@%dc", map_channels);
}
- switch_snprintf(buf + strlen(buf), buflen - strlen(buf), ",%s%s%s%s", map->rm_encoding, ratestr, ptstr, bitstr);
+ switch_snprintf(buf + strlen(buf), buflen - strlen(buf), ",%s.%s%s%s%s", imp->modname, map->rm_encoding, ratestr, ptstr, bitstr);
}
switch_core_media_add_payload_map(session,
m->m_type == sdp_media_audio ? SWITCH_MEDIA_TYPE_AUDIO : SWITCH_MEDIA_TYPE_VIDEO,
map->rm_encoding,
+ NULL,
map->rm_fmtp,
sdp_type,
map->rm_pt,
}
if (match) {
- add_audio_codec(map, ptime, buf, sizeof(buf));
+ add_audio_codec(map, imp, ptime, buf, sizeof(buf));
break;
}
}
if (match) {
- add_audio_codec(map, ptime, buf, sizeof(buf));
+ add_audio_codec(map, imp, ptime, buf, sizeof(buf));
break;
}
}
}
for (i = 0; i < num_codecs; i++) {
const switch_codec_implementation_t *imp = codecs[i];
- int channels;
if (imp->codec_type != SWITCH_CODEC_TYPE_VIDEO || imp->ianacode > 127 || already_did[imp->ianacode]) {
continue;
}
if (match) {
- channels = map->rm_params ? atoi(map->rm_params) : 1;
- if (ptime > 0) {
- switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), ",%s@%uh@%di@%dc", imp->iananame, (unsigned int) map->rm_rate,
- ptime, channels);
- } else {
- switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), ",%s@%uh@%dc", imp->iananame, (unsigned int) map->rm_rate, channels);
- }
+ switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), ",%s.%s", imp->modname, imp->iananame);
already_did[imp->ianacode] = 1;
break;
}
SWITCH_MEDIA_TYPE_AUDIO,
"PROXY",
NULL,
+ NULL,
SDP_TYPE_RESPONSE,
0,
8000,
SWITCH_MEDIA_TYPE_AUDIO,
"PROXY-VID",
NULL,
+ NULL,
SDP_TYPE_RESPONSE,
0,
90000,
if (switch_core_codec_init(&data->codec,
"L16",
NULL,
+ NULL,
read_impl.actual_samples_per_second,
interval,
read_impl.number_of_channels, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, NULL) == SWITCH_STATUS_SUCCESS) {
if (switch_core_codec_init(&codec,
"L16",
NULL,
+ NULL,
imp.samples_per_second,
imp.microseconds_per_packet / 1000,
imp.number_of_channels,
if (switch_core_codec_init(&codec,
"L16",
NULL,
+ NULL,
imp.actual_samples_per_second,
imp.microseconds_per_packet / 1000,
imp.number_of_channels,
if (switch_core_codec_init(&conninfo->read_codec,
"L16",
NULL,
+ NULL,
read_codec->implementation->actual_samples_per_second,
read_codec->implementation->microseconds_per_packet / 1000,
1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
if (switch_core_codec_init(&codec,
"L16",
NULL,
+ NULL,
imp.actual_samples_per_second,
imp.microseconds_per_packet / 1000,
imp.number_of_channels,
if (switch_core_codec_init(&codec,
"L16",
NULL,
+ NULL,
imp.samples_per_second,
imp.microseconds_per_packet / 1000,
imp.number_of_channels,
if (switch_core_codec_init(&codec,
"L16",
NULL,
+ NULL,
tread_impl.actual_samples_per_second,
tread_impl.microseconds_per_packet / 1000,
tread_impl.number_of_channels,
if (switch_core_codec_init(&silence_codec,
"L16",
NULL,
+ NULL,
read_impl.actual_samples_per_second,
read_impl.microseconds_per_packet / 1000,
1,
if (switch_core_codec_init(&write_codec,
"L16",
NULL,
+ NULL,
read_codec->implementation->actual_samples_per_second,
read_codec->implementation->microseconds_per_packet / 1000,
1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL,
if (switch_core_codec_init(write_codec,
"L16",
NULL,
+ NULL,
peer_read_impl.actual_samples_per_second,
peer_read_impl.microseconds_per_packet / 1000,
1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL,
if (switch_core_codec_init(&read_codecs[i],
"L16",
NULL,
+ NULL,
read_impl.actual_samples_per_second,
read_impl.microseconds_per_packet / 1000,
1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL,
if (switch_core_codec_init(&write_codec,
"L16",
NULL,
+ NULL,
read_impl.actual_samples_per_second,
read_impl.microseconds_per_packet / 1000,
read_impl.number_of_channels,
if (switch_core_codec_init(&codec,
codec_name,
NULL,
+ NULL,
read_impl.actual_samples_per_second,
read_impl.microseconds_per_packet / 1000,
read_impl.number_of_channels,
if (switch_core_codec_init(&write_codec,
"L16",
NULL,
+ NULL,
read_impl.actual_samples_per_second,
read_impl.microseconds_per_packet / 1000,
1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
if (switch_core_codec_init(&codec,
codec_name,
NULL,
+ NULL,
fh->samplerate,
interval, read_impl.number_of_channels,
SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, pool) == SWITCH_STATUS_SUCCESS) {
if (switch_core_codec_init(&raw_codec,
"L16",
NULL,
+ NULL,
read_impl.actual_samples_per_second,
read_impl.microseconds_per_packet / 1000,
1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
if (need_create) {
if (switch_core_codec_init(codec,
codec_name,
+ NULL,
NULL, (int) rate, interval, channels, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL,
pool) == SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Raw Codec Activated\n");
const char *interface_name;
struct switch_file_node_s *next;
} switch_file_node_t;
+
+typedef struct switch_codec_node_s {
+ const switch_codec_interface_t *ptr;
+ const char *interface_name;
+ struct switch_codec_node_s *next;
+} switch_codec_node_t;
struct switch_loadable_module {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Failed to load codec interface from %s due to no interface name.\n", key);
} else {
unsigned load_interface = 1;
+ switch_codec_node_t *node, *head;
+
for (impl = ptr->implementations; impl; impl = impl->next) {
if (!impl->iananame) {
load_interface = 0;
impl->iananame, impl->ianacode,
ptr->interface_name, impl->actual_samples_per_second, impl->microseconds_per_packet / 1000);
}
- if (!switch_core_hash_find(loadable_modules.codec_hash, impl->iananame)) {
- switch_core_hash_insert(loadable_modules.codec_hash, impl->iananame, (const void *) ptr);
+
+ node = switch_core_alloc(new_module->pool, sizeof(*node));
+ node->ptr = ptr;
+ node->interface_name = switch_core_strdup(new_module->pool, new_module->module_interface->module_name);
+ if ((head = switch_core_hash_find(loadable_modules.codec_hash, impl->iananame))) {
+ node->next = head;
}
+
+ switch_core_hash_insert(loadable_modules.codec_hash, impl->iananame, (const void *) node);
}
+
if (switch_event_create(&event, SWITCH_EVENT_MODULE_LOAD) == SWITCH_STATUS_SUCCESS) {
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "type", "codec");
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "name", ptr->interface_name);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "key", new_module->key);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "filename", new_module->filename);
+ switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "module", new_module->module_interface->module_name);
switch_event_fire(&event);
added++;
}
if (old_module->module_interface->codec_interface) {
const switch_codec_implementation_t *impl;
const switch_codec_interface_t *ptr;
+ switch_codec_node_t *node, *head, *last = NULL;
for (ptr = old_module->module_interface->codec_interface; ptr; ptr = ptr->next) {
if (ptr->interface_name) {
ptr->interface_name, impl->actual_samples_per_second, impl->microseconds_per_packet / 1000);
switch_core_session_hupall_matching_var("read_codec", impl->iananame, SWITCH_CAUSE_MANAGER_REQUEST);
switch_core_session_hupall_matching_var("write_codec", impl->iananame, SWITCH_CAUSE_MANAGER_REQUEST);
- if (switch_core_hash_find(loadable_modules.codec_hash, impl->iananame)) {
- switch_core_hash_delete(loadable_modules.codec_hash, impl->iananame);
+
+ if ((head = switch_core_hash_find(loadable_modules.codec_hash, impl->iananame))) {
+ for(node = head; node; node = node->next) {
+ if (!strcmp(node->interface_name, old_module->module_interface->module_name)) {
+ if (node == head) {
+ if ((node = node->next)) {
+ switch_core_hash_insert(loadable_modules.codec_hash, impl->iananame, (const void *) node);
+ } else {
+ switch_core_hash_delete(loadable_modules.codec_hash, impl->iananame);
+ }
+ } else {
+ if (last) {
+ last->next = node->next;
+ }
+ }
+ break;
+ }
+ last = node;
+ }
}
}
if (switch_event_create(&event, SWITCH_EVENT_MODULE_UNLOAD) == SWITCH_STATUS_SUCCESS) {
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "type", "codec");
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "name", ptr->interface_name);
+ switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "module", old_module->module_interface->module_name);
switch_event_fire(&event);
removed++;
}
return i;
}
-SWITCH_DECLARE(switch_codec_interface_t *) switch_loadable_module_get_codec_interface(const char *name)
+SWITCH_DECLARE(switch_codec_interface_t *) switch_loadable_module_get_codec_interface(const char *name, const char *modname)
{
- char altname[256] = "";
- switch_codec_interface_t *codec;
- switch_size_t x;
+ switch_codec_interface_t *codec = NULL;
+ switch_codec_node_t *node, *head;
switch_mutex_lock(loadable_modules.mutex);
- if (!(codec = switch_core_hash_find(loadable_modules.codec_hash, name))) {
- for (x = 0; x < strlen(name); x++) {
- altname[x] = (char) toupper((int) name[x]);
- }
- if (!(codec = switch_core_hash_find(loadable_modules.codec_hash, altname))) {
- for (x = 0; x < strlen(name); x++) {
- altname[x] = (char) tolower((int) name[x]);
+
+ if ((head = switch_core_hash_find(loadable_modules.codec_hash, name))) {
+ if (modname) {
+ for (node = head; node; node = node->next) {
+ if (!strcasecmp(node->interface_name, modname)) {
+ codec = (switch_codec_interface_t *) node->ptr;
+ break;
+ }
}
- codec = switch_core_hash_find(loadable_modules.codec_hash, altname);
+ } else {
+ codec = (switch_codec_interface_t *) head->ptr;
}
}
+
switch_mutex_unlock(loadable_modules.mutex);
if (codec) {
switch_codec_interface_t *codec_interface;
int i = 0;
const switch_codec_implementation_t *imp;
+ switch_codec_node_t *node, *head;
switch_mutex_lock(loadable_modules.mutex);
for (hi = switch_core_hash_first(loadable_modules.codec_hash); hi; hi = switch_core_hash_next(&hi)) {
switch_core_hash_this(hi, NULL, NULL, &val);
- codec_interface = (switch_codec_interface_t *) val;
+ head = (switch_codec_node_t *) val;
- /* Look for the default ptime of the codec because it's the safest choice */
- for (imp = codec_interface->implementations; imp; imp = imp->next) {
- uint32_t default_ptime = switch_default_ptime(imp->iananame, imp->ianacode);
+ for (node = head; node; node = node->next) {
+ codec_interface = (switch_codec_interface_t *) node->ptr;
- if (imp->microseconds_per_packet / 1000 == (int)default_ptime) {
- array[i++] = imp;
- goto found;
+ /* Look for the default ptime of the codec because it's the safest choice */
+ for (imp = codec_interface->implementations; imp; imp = imp->next) {
+ uint32_t default_ptime = switch_default_ptime(imp->iananame, imp->ianacode);
+
+ if (imp->microseconds_per_packet / 1000 == (int)default_ptime) {
+ array[i++] = imp;
+ goto found;
+ }
}
+ /* oh well we will use what we have */
+ array[i++] = codec_interface->implementations;
}
- /* oh well we will use what we have */
- array[i++] = codec_interface->implementations;
-
- found:
+ found:
+
if (i > arraylen) {
break;
}
+
}
switch_safe_free(hi);
}
-SWITCH_DECLARE(char *) switch_parse_codec_buf(char *buf, uint32_t *interval, uint32_t *rate, uint32_t *bit, uint32_t *channels)
+SWITCH_DECLARE(char *) switch_parse_codec_buf(char *buf, uint32_t *interval, uint32_t *rate, uint32_t *bit, uint32_t *channels, char **modname)
{
char *cur, *next = NULL, *name, *p;
cur = next;
}
+ if ((p = strchr(name, '.'))) {
+ *p++ = '\0';
+ *modname = name;
+ name = p;
+ }
+
return name;
}
switch_mutex_lock(loadable_modules.mutex);
for (x = 0; x < preflen; x++) {
- char *name, buf[256], jbuf[256];
+ char *name, buf[256], jbuf[256], *modname = NULL;
uint32_t interval = 0, rate = 0, bit = 0, channels = 1;
switch_copy_string(buf, prefs[x], sizeof(buf));
- name = switch_parse_codec_buf(buf, &interval, &rate, &bit, &channels);
+ name = switch_parse_codec_buf(buf, &interval, &rate, &bit, &channels, &modname);
for(j = 0; j < x; j++) {
- char *jname;
+ char *jname, *jmodname = NULL;
uint32_t jinterval = 0, jrate = 0, jbit = 0, jchannels = 1;
uint32_t ointerval = interval, orate = rate, ochannels = channels;
}
switch_copy_string(jbuf, prefs[j], sizeof(jbuf));
- jname = switch_parse_codec_buf(jbuf, &jinterval, &jrate, &jbit, &jchannels);
+ jname = switch_parse_codec_buf(jbuf, &jinterval, &jrate, &jbit, &jchannels, &jmodname);
if (jinterval == 0) {
jinterval = switch_default_ptime(jname, 0);
}
}
- if ((codec_interface = switch_loadable_module_get_codec_interface(name)) != 0) {
+ if ((codec_interface = switch_loadable_module_get_codec_interface(name, modname)) != 0) {
/* If no specific codec interval is requested opt for the default above all else because lots of stuff assumes it */
for (imp = codec_interface->implementations; imp; imp = imp->next) {
uint32_t default_ptime = switch_default_ptime(imp->iananame, imp->ianacode);
if (switch_core_codec_init(&rtp_session->vad_data.vad_codec,
codec->implementation->iananame,
+ codec->implementation->modname,
NULL,
codec->implementation->samples_per_second,
codec->implementation->microseconds_per_packet / 1000,