FS-7504: allow <modname>.<codecname> support so multiple modules can exist for the same codec

This commit is contained in:
Anthony Minessale 2015-03-19 14:26:47 -05:00 committed by Michael Jerris
parent 52d15f6398
commit 7c294f242f
49 changed files with 307 additions and 157 deletions

View File

@ -378,6 +378,7 @@ init_codecs:
if (switch_core_codec_init(&tech_pvt->read_codec,
dname,
NULL,
NULL,
srate,
interval,
1,
@ -389,6 +390,7 @@ init_codecs:
if (switch_core_codec_init(&tech_pvt->write_codec,
dname,
NULL,
NULL,
srate,
interval,
1,

View File

@ -435,6 +435,7 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
if (switch_core_codec_init(&tech_pvt->read_codec,
dname,
NULL,
NULL,
8000,
interval,
1,
@ -446,6 +447,7 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
if (switch_core_codec_init(&tech_pvt->write_codec,
dname,
NULL,
NULL,
8000,
interval,
1,

View File

@ -205,7 +205,7 @@ int main(int argc, char *argv[])
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;
}
@ -215,12 +215,12 @@ int main(int argc, char *argv[])
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;
}

View File

@ -1567,17 +1567,20 @@ SWITCH_DECLARE(switch_status_t) switch_core_timer_destroy(switch_timer_t *timer)
\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);

View File

@ -278,6 +278,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_get_payload_code(switch_core
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,

View File

@ -115,9 +115,9 @@ SWITCH_DECLARE(switch_endpoint_interface_t *) switch_loadable_module_get_endpoin
\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
@ -415,6 +415,7 @@ SWITCH_DECLARE(uint32_t) switch_core_codec_next_id(void);
#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; \
@ -523,6 +524,7 @@ static inline void switch_core_codec_add_implementation(switch_memory_pool_t *po
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",
@ -571,6 +573,7 @@ static inline void switch_core_codec_add_video_implementation(switch_memory_pool
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;
}

View File

@ -709,6 +709,7 @@ struct switch_codec_implementation {
switch_core_codec_destroy_func_t destroy;
uint32_t codec_id;
uint32_t impl_id;
char *modname;
struct switch_codec_implementation *next;
};
@ -724,6 +725,7 @@ struct switch_codec_interface {
switch_thread_rwlock_t *rwlock;
int refs;
switch_mutex_t *reflock;
char *modname;
switch_loadable_module_interface_t *parent;
struct switch_codec_interface *next;
};

View File

@ -2469,6 +2469,7 @@ typedef struct payload_map_s {
char *rm_encoding;
char *iananame;
char *modname;
switch_payload_t pt;
unsigned long rm_rate;
unsigned long adv_rm_rate;

View File

@ -1129,6 +1129,7 @@ SWITCH_STANDARD_APP(record_av_function)
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,

View File

@ -246,7 +246,7 @@ int vgo(int i, switch_core_session_t *session)
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;

View File

@ -11049,7 +11049,7 @@ static int setup_media(conference_member_t *member, conference_obj_t *conference
/* 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,
@ -11094,6 +11094,7 @@ static int setup_media(conference_member_t *member, conference_obj_t *conference
if (switch_core_codec_init(&member->write_codec,
"L16",
NULL,
NULL,
conference->rate,
read_impl.microseconds_per_packet / 1000,
read_impl.number_of_channels,

View File

@ -352,6 +352,7 @@ SWITCH_STANDARD_APP(bcast_function)
if (switch_core_codec_init(&codec,
"L16",
NULL,
NULL,
read_rate,
20,
1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
@ -366,6 +367,7 @@ SWITCH_STANDARD_APP(bcast_function)
if (switch_core_codec_init(&write_codec,
codec_name,
NULL,
NULL,
8000,
20,
1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,

View File

@ -147,6 +147,7 @@ SWITCH_STANDARD_APP(record_fsv_function)
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,
@ -339,6 +340,7 @@ SWITCH_STANDARD_APP(play_fsv_function)
if (switch_core_codec_init(&codec,
"L16",
NULL,
NULL,
h.audio_rate,
h.audio_ptime,
1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
@ -353,6 +355,7 @@ SWITCH_STANDARD_APP(play_fsv_function)
if (switch_core_codec_init(&vid_codec,
h.video_codec_name,
NULL,
NULL,
0,
0,
1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,

View File

@ -168,12 +168,13 @@ SWITCH_STANDARD_APP(record_mp4_function)
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 {
@ -440,24 +441,26 @@ SWITCH_STANDARD_APP(play_mp4_function)
}
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
{

View File

@ -369,6 +369,7 @@ SWITCH_STANDARD_APP(record_mp4_function)
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,
@ -669,6 +670,7 @@ static switch_status_t mp4_file_open(switch_file_handle_t *handle, const char *p
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,
@ -681,12 +683,13 @@ static switch_status_t mp4_file_open(switch_file_handle_t *handle, const char *p
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");

View File

@ -272,6 +272,7 @@ SWITCH_STANDARD_APP(rss_function)
if (switch_core_codec_init(&speech_codec,
"L16",
NULL,
NULL,
(int) rate,
interval,
1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL,

View File

@ -189,18 +189,19 @@ switch_status_t spandsp_tdd_send_session(switch_core_session_t *session, const c
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;

View File

@ -1440,6 +1440,7 @@ void mod_spandsp_fax_process_fax(switch_core_session_t *session, const char *dat
*/
if (switch_core_codec_init(&read_codec,
"L16",
NULL,
NULL,
read_impl.samples_per_second,
read_impl.microseconds_per_packet / 1000,
@ -1457,6 +1458,7 @@ void mod_spandsp_fax_process_fax(switch_core_session_t *session, const char *dat
if (switch_core_codec_init(&write_codec,
"L16",
NULL,
NULL,
read_impl.samples_per_second,
read_impl.microseconds_per_packet / 1000,
@ -1864,6 +1866,7 @@ static switch_status_t t38_gateway_on_consume_media(switch_core_session_t *sessi
if (switch_core_codec_init(&read_codec,
"L16",
NULL,
NULL,
read_impl.samples_per_second,
read_impl.microseconds_per_packet / 1000,
@ -1880,6 +1883,7 @@ static switch_status_t t38_gateway_on_consume_media(switch_core_session_t *sessi
if (switch_core_codec_init(&write_codec,
"L16",
NULL,
NULL,
read_impl.samples_per_second,
read_impl.microseconds_per_packet / 1000,

View File

@ -770,6 +770,7 @@ static switch_status_t tech_init(private_t *tech_pvt, switch_core_session_t *ses
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));
@ -779,6 +780,7 @@ static switch_status_t tech_init(private_t *tech_pvt, switch_core_session_t *ses
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));

View File

@ -756,6 +756,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_openh264_load)
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;
}

View File

@ -562,6 +562,7 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
if (switch_core_codec_init(&tech_pvt->write_codec,
"L16",
NULL,
NULL,
sample_rate,
codec_ms,
1,
@ -989,13 +990,13 @@ static switch_status_t engage_device(unsigned int sample_rate, int codec_ms)
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);

View File

@ -1167,6 +1167,7 @@ static int activate_audio_rtp(struct private_object *tech_pvt)
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,
@ -1188,6 +1189,7 @@ static int activate_audio_rtp(struct private_object *tech_pvt)
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,
@ -1366,6 +1368,7 @@ static int activate_video_rtp(struct private_object *tech_pvt)
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,
@ -1384,6 +1387,7 @@ static int activate_video_rtp(struct private_object *tech_pvt)
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,

View File

@ -217,14 +217,14 @@ static switch_status_t gsmopen_codec(private_t * tech_pvt, int sample_rate, int
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);

View File

@ -156,14 +156,14 @@ static switch_status_t gsmopen_codec(private_t *tech_pvt, int sample_rate, int c
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);

View File

@ -2071,12 +2071,12 @@ PBoolean FSH323_ExternalRTPChannel::Start()
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) {

View File

@ -713,7 +713,7 @@ switch_status_t Board::KhompPvt::justAlloc(bool is_answering, switch_memory_pool
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)
{
@ -722,7 +722,7 @@ switch_status_t Board::KhompPvt::justAlloc(bool is_answering, switch_memory_pool
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)
{

View File

@ -137,11 +137,12 @@ static switch_status_t tech_init(loopback_private_t *tech_pvt, switch_core_sessi
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);
}
}
@ -160,6 +161,7 @@ static switch_status_t tech_init(loopback_private_t *tech_pvt, switch_core_sessi
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)) {
@ -169,6 +171,7 @@ static switch_status_t tech_init(loopback_private_t *tech_pvt, switch_core_sessi
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));

View File

@ -1287,12 +1287,12 @@ PBoolean FSMediaStream::Open()
}
// 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) {

View File

@ -1217,15 +1217,15 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
}
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;
}
@ -2222,6 +2222,7 @@ static switch_status_t create_codecs(int restart)
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");
@ -2235,6 +2236,7 @@ static switch_status_t create_codecs(int restart)
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);

View File

@ -109,7 +109,7 @@ switch_status_t rtmp_tech_init(rtmp_private_t *tech_pvt, rtmp_session_t *rsessio
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) {
@ -118,7 +118,7 @@ switch_status_t rtmp_tech_init(rtmp_private_t *tech_pvt, rtmp_session_t *rsessio
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) {

View File

@ -574,25 +574,27 @@ switch_status_t skinny_tech_set_codec(private_t *tech_pvt, int force)
}
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);
}

View File

@ -212,14 +212,14 @@ static switch_status_t skypopen_codec(private_t *tech_pvt, int sample_rate, int
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);

View File

@ -229,6 +229,7 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
if (switch_core_codec_init(&tech_pvt->read_codec,
codec,
NULL,
NULL,
rate,
ptime,
1,
@ -240,6 +241,7 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
if (switch_core_codec_init(&tech_pvt->write_codec,
codec,
NULL,
NULL,
rate,
ptime,
1,
@ -479,24 +481,26 @@ static switch_status_t channel_receive_event(switch_core_session_t *session, swi
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;
}

View File

@ -550,6 +550,7 @@ SWITCH_STANDARD_APP(record_av_function)
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,

View File

@ -174,7 +174,7 @@ static switch_status_t engage_device(portaudio_stream_source_t *source, int rest
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;
@ -186,7 +186,7 @@ static switch_status_t engage_device(portaudio_stream_source_t *source, int rest
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);

View File

@ -1417,6 +1417,7 @@ SWITCH_STANDARD_APP(play_video_function)
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,
@ -2301,6 +2302,7 @@ static switch_call_cause_t vlc_outgoing_channel(switch_core_session_t *session,
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,
@ -2312,6 +2314,7 @@ static switch_call_cause_t vlc_outgoing_channel(switch_core_session_t *session,
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,
@ -2337,12 +2340,13 @@ static switch_call_cause_t vlc_outgoing_channel(switch_core_session_t *session,
}
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");

View File

@ -171,6 +171,7 @@ static switch_status_t webm_file_open(switch_file_handle_t *handle, const char *
if (switch_core_codec_init(&context->audio_codec,
AUDIO_CODEC,
NULL,
fmtp,
handle->samplerate,
20,//ms
@ -186,6 +187,7 @@ static switch_status_t webm_file_open(switch_file_handle_t *handle, const char *
if (switch_core_codec_init(&context->video_codec,
"VP8",
NULL,
NULL,
90000,
0,//ms
1, SWITCH_CODEC_FLAG_ENCODE,

View File

@ -972,6 +972,7 @@ switch_status_t FSSession::InitSpeechEngine(const char *engine, const char *voic
if (switch_core_codec_init(&this->_speech->codec,
"L16",
NULL,
NULL,
rate,
interval,
1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL,

View File

@ -137,6 +137,7 @@ void *FSTeleTone::Construct(const v8::FunctionCallbackInfo<Value>& info)
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) {

View File

@ -593,7 +593,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_codec_parse_fmtp(const char *codec_n
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);
@ -624,6 +624,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_codec_copy(switch_codec_t *codec, sw
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,
@ -634,7 +635,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_codec_copy(switch_codec_t *codec, sw
}
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)
{
@ -650,7 +651,17 @@ SWITCH_DECLARE(switch_status_t) switch_core_codec_init_with_bitrate(switch_codec
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;
}

View File

@ -656,6 +656,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_get_payload_code(switch_core
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,
@ -728,6 +729,10 @@ SWITCH_DECLARE(payload_map_t *) switch_core_media_add_payload_map(switch_core_se
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);
}
@ -780,7 +785,7 @@ SWITCH_DECLARE(const char *)switch_core_media_get_codec_string(switch_core_sessi
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;
@ -2491,6 +2496,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_set_video_codec(switch_core_se
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,
@ -2502,6 +2508,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_set_video_codec(switch_core_se
} 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,
@ -2628,6 +2635,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_set_codec(switch_core_session_
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,
@ -2645,6 +2653,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_set_codec(switch_core_session_
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,
@ -4030,6 +4039,7 @@ SWITCH_DECLARE(uint8_t) switch_core_media_negotiate_sdp(switch_core_session_t *s
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,
@ -4342,6 +4352,7 @@ SWITCH_DECLARE(uint8_t) switch_core_media_negotiate_sdp(switch_core_session_t *s
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,
@ -4349,6 +4360,7 @@ SWITCH_DECLARE(uint8_t) switch_core_media_negotiate_sdp(switch_core_session_t *s
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;
@ -6900,6 +6912,7 @@ SWITCH_DECLARE(void) switch_core_media_gen_local_sdp(switch_core_session_t *sess
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],
@ -7957,6 +7970,7 @@ SWITCH_DECLARE(void) switch_core_media_patch_sdp(switch_core_session_t *session)
SWITCH_MEDIA_TYPE_AUDIO,
"PROXY",
NULL,
NULL,
SDP_TYPE_RESPONSE,
0,
8000,
@ -8113,6 +8127,7 @@ SWITCH_DECLARE(void) switch_core_media_patch_sdp(switch_core_session_t *session)
SWITCH_MEDIA_TYPE_AUDIO,
"PROXY-VID",
NULL,
NULL,
SDP_TYPE_RESPONSE,
0,
90000,
@ -8949,7 +8964,7 @@ SWITCH_DECLARE(void) switch_core_media_set_sdp_codec_string(switch_core_session_
}
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;
@ -9004,7 +9019,7 @@ static void add_audio_codec(sdp_rtpmap_t *map, int ptime, char *buf, switch_size
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);
}
@ -9084,6 +9099,7 @@ static void switch_core_media_set_r_sdp_codec_string(switch_core_session_t *sess
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,
@ -9141,7 +9157,7 @@ static void switch_core_media_set_r_sdp_codec_string(switch_core_session_t *sess
}
if (match) {
add_audio_codec(map, ptime, buf, sizeof(buf));
add_audio_codec(map, imp, ptime, buf, sizeof(buf));
break;
}
@ -9171,7 +9187,7 @@ static void switch_core_media_set_r_sdp_codec_string(switch_core_session_t *sess
}
if (match) {
add_audio_codec(map, ptime, buf, sizeof(buf));
add_audio_codec(map, imp, ptime, buf, sizeof(buf));
break;
}
}
@ -9190,7 +9206,6 @@ static void switch_core_media_set_r_sdp_codec_string(switch_core_session_t *sess
}
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;
@ -9218,13 +9233,7 @@ static void switch_core_media_set_r_sdp_codec_string(switch_core_session_t *sess
}
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;
}
@ -9315,6 +9324,7 @@ SWITCH_DECLARE(void) switch_core_media_check_outgoing_proxy(switch_core_session_
SWITCH_MEDIA_TYPE_AUDIO,
"PROXY",
NULL,
NULL,
SDP_TYPE_RESPONSE,
0,
8000,
@ -9330,6 +9340,7 @@ SWITCH_DECLARE(void) switch_core_media_check_outgoing_proxy(switch_core_session_
SWITCH_MEDIA_TYPE_AUDIO,
"PROXY-VID",
NULL,
NULL,
SDP_TYPE_RESPONSE,
0,
90000,

View File

@ -97,6 +97,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_set_codec_slin(switch_core_s
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) {

View File

@ -62,6 +62,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_sound_test(switch_core_session_t *ses
if (switch_core_codec_init(&codec,
"L16",
NULL,
NULL,
imp.samples_per_second,
imp.microseconds_per_packet / 1000,
imp.number_of_channels,
@ -179,6 +180,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_sleep(switch_core_session_t *session,
if (switch_core_codec_init(&codec,
"L16",
NULL,
NULL,
imp.actual_samples_per_second,
imp.microseconds_per_packet / 1000,
imp.number_of_channels,
@ -436,6 +438,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_activate_unicast(switch_core_session_
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,
@ -953,6 +956,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_park(switch_core_session_t *session,
if (switch_core_codec_init(&codec,
"L16",
NULL,
NULL,
imp.actual_samples_per_second,
imp.microseconds_per_packet / 1000,
imp.number_of_channels,
@ -1297,6 +1301,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_collect_digits_count(switch_core_sess
if (switch_core_codec_init(&codec,
"L16",
NULL,
NULL,
imp.samples_per_second,
imp.microseconds_per_packet / 1000,
imp.number_of_channels,

View File

@ -1843,6 +1843,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_eavesdrop_session(switch_core_session
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,

View File

@ -312,6 +312,7 @@ static void *audio_bridge_thread(switch_thread_t *thread, void *obj)
if (switch_core_codec_init(&silence_codec,
"L16",
NULL,
NULL,
read_impl.actual_samples_per_second,
read_impl.microseconds_per_packet / 1000,
1,

View File

@ -922,6 +922,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_wait_for_answer(switch_core_session_t
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,
@ -1240,6 +1241,7 @@ static switch_status_t setup_ringback(originate_global_t *oglobals, originate_st
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,
@ -1776,6 +1778,7 @@ static void *SWITCH_THREAD_FUNC early_thread_run(switch_thread_t *thread, void *
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,

View File

@ -453,6 +453,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_record_file(switch_core_session_t *se
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,
@ -600,6 +601,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_record_file(switch_core_session_t *se
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,
@ -873,6 +875,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_gentones(switch_core_session_t *sessi
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,
@ -1336,6 +1339,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess
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) {
@ -1896,6 +1900,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_wait_for_silence(switch_core_session_
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,
@ -2605,6 +2610,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_speak_text(switch_core_session_t *ses
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");

View File

@ -46,6 +46,12 @@ typedef struct switch_file_node_s {
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 {
@ -176,6 +182,8 @@ static switch_status_t switch_loadable_module_process(char *key, switch_loadable
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;
@ -207,15 +215,23 @@ static switch_status_t switch_loadable_module_process(char *key, switch_loadable
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++;
}
@ -946,6 +962,7 @@ static switch_status_t switch_loadable_module_unprocess(switch_loadable_module_t
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) {
@ -964,13 +981,31 @@ static switch_status_t switch_loadable_module_unprocess(switch_loadable_module_t
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++;
}
@ -2106,24 +2141,26 @@ SWITCH_DECLARE(switch_file_interface_t *) switch_loadable_module_get_file_interf
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) {
@ -2259,29 +2296,35 @@ SWITCH_DECLARE(int) switch_loadable_module_get_codecs(const switch_codec_impleme
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);
@ -2293,7 +2336,7 @@ SWITCH_DECLARE(int) switch_loadable_module_get_codecs(const switch_codec_impleme
}
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;
@ -2327,6 +2370,12 @@ SWITCH_DECLARE(char *) switch_parse_codec_buf(char *buf, uint32_t *interval, uin
cur = next;
}
if ((p = strchr(name, '.'))) {
*p++ = '\0';
*modname = name;
name = p;
}
return name;
}
@ -2339,14 +2388,14 @@ SWITCH_DECLARE(int) switch_loadable_module_get_codecs_sorted(const switch_codec_
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;
@ -2363,7 +2412,7 @@ SWITCH_DECLARE(int) switch_loadable_module_get_codecs_sorted(const switch_codec_
}
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);
@ -2382,7 +2431,7 @@ SWITCH_DECLARE(int) switch_loadable_module_get_codecs_sorted(const switch_codec_
}
}
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);

View File

@ -7107,6 +7107,7 @@ SWITCH_DECLARE(switch_status_t) switch_rtp_enable_vad(switch_rtp_t *rtp_session,
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,