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

This commit is contained in:
Anthony Minessale authored and Michael Jerris committed 2015-05-28 12:47:13 -05:00
1 parent 52d15f6398
commit 7c294f242f
49 files changed
+307 -157

No files matched your search

+3 -2
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);
@@ -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,
@@ -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);
@@ -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);
+2 -2
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) {
@@ -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)
{
@@ -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));
+2 -2
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) {
@@ -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);
+2 -2
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) {
+16 -14
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);
}
@@ -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);
+16 -12
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;
}