git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@6499 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale
2007-12-04 18:52:13 +00:00
parent 58c43fc8ab
commit db9c908f4e
2 changed files with 67 additions and 18 deletions

View File

@@ -37,8 +37,11 @@
SWITCH_DECLARE(switch_status_t) switch_core_session_set_read_codec(switch_core_session_t *session, switch_codec_t *codec)
{
switch_event_t *event;
switch_channel_t *channel;
char tmp[30];
assert(session != NULL);
channel = switch_core_session_get_channel(session);
if (switch_event_create(&event, SWITCH_EVENT_CODEC) == SWITCH_STATUS_SUCCESS) {
switch_channel_event_set_data(session->channel, event);
@@ -50,6 +53,10 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_set_read_codec(switch_core_s
switch_event_fire(&event);
}
switch_channel_set_variable(channel, "read_codec", codec->implementation->iananame);
snprintf(tmp, sizeof(tmp), "%d", codec->implementation->actual_samples_per_second);
switch_channel_set_variable(channel, "read_rate", tmp);
session->read_codec = codec;
session->raw_read_frame.codec = session->read_codec;
session->raw_write_frame.codec = session->read_codec;
@@ -67,7 +74,12 @@ SWITCH_DECLARE(switch_codec_t *) switch_core_session_get_read_codec(switch_core_
SWITCH_DECLARE(switch_status_t) switch_core_session_set_write_codec(switch_core_session_t *session, switch_codec_t *codec)
{
switch_event_t *event;
switch_channel_t *channel;
char tmp[30];
assert(session != NULL);
channel = switch_core_session_get_channel(session);
if (switch_event_create(&event, SWITCH_EVENT_CODEC) == SWITCH_STATUS_SUCCESS) {
switch_channel_event_set_data(session->channel, event);
@@ -79,6 +91,10 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_set_write_codec(switch_core_
switch_event_fire(&event);
}
switch_channel_set_variable(channel, "write_codec", codec->implementation->iananame);
snprintf(tmp, sizeof(tmp), "%d", codec->implementation->actual_samples_per_second);
switch_channel_set_variable(channel, "write_rate", tmp);
session->write_codec = codec;
return SWITCH_STATUS_SUCCESS;
}