mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-07-24 21:22:09 +00:00
Check in TDM and RTP controllable channels (incomplete)
This commit is contained in:
@@ -4,6 +4,7 @@ BASE=../../..
|
||||
FT_DIR=..
|
||||
VERBOSE=1
|
||||
FTLA=$(FT_DIR)/libfreetdm.la
|
||||
LOCAL_OBJS=tdm.o
|
||||
LOCAL_CFLAGS=-I$(FT_DIR)/src/include -I$(FT_DIR)/src/isdn/include $(FT_CFLAGS)
|
||||
LOCAL_LDFLAGS=-L$(FT_DIR) -lfreetdm
|
||||
include $(BASE)/build/modmake.rules
|
||||
|
||||
@@ -873,7 +873,7 @@ static switch_status_t channel_write_frame(switch_core_session_t *session, switc
|
||||
if (!tech_pvt->ftdmchan) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "no ftdmchan set in channel %s!\n", name);
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
span_id = ftdm_channel_get_span_id(tech_pvt->ftdmchan);
|
||||
chan_id = ftdm_channel_get_id(tech_pvt->ftdmchan);
|
||||
@@ -906,7 +906,7 @@ static switch_status_t channel_write_frame(switch_core_session_t *session, switc
|
||||
ftdm_channel_wait(tech_pvt->ftdmchan, &wflags, ftdm_channel_get_io_interval(tech_pvt->ftdmchan) * 10);
|
||||
|
||||
if (!(wflags & FTDM_WRITE)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Dropping frame! (write note ready) in channel %s device %d:%d!\n", name, span_id, chan_id);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Dropping frame! (write not ready) in channel %s device %d:%d!\n", name, span_id, chan_id);
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,413 @@
|
||||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Portions created by the Initial Developer are Copyright (C)
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Mathieu Rene <mrene@avgs.ca>
|
||||
*
|
||||
* tdm.c -- FreeTDM Controllable Channel Module
|
||||
*
|
||||
*/
|
||||
|
||||
#include <switch.h>
|
||||
#include "freetdm.h"
|
||||
|
||||
void ctdm_init(switch_loadable_module_interface_t *module_interface);
|
||||
|
||||
/* Parameters */
|
||||
|
||||
#define kSPAN_ID "span"
|
||||
#define kCHAN_ID "chan"
|
||||
|
||||
static struct {
|
||||
switch_memory_pool_t *pool;
|
||||
switch_endpoint_interface_t *endpoint_interface;
|
||||
} ctdm;
|
||||
|
||||
typedef struct {
|
||||
int span_id;
|
||||
int chan_id;
|
||||
ftdm_channel_t *ftdm_channel;
|
||||
switch_core_session_t *session;
|
||||
switch_codec_t read_codec, write_codec;
|
||||
switch_frame_t read_frame;
|
||||
} ctdm_private_t;
|
||||
|
||||
static switch_status_t channel_on_init(switch_core_session_t *session);
|
||||
static switch_status_t channel_on_destroy(switch_core_session_t *session);
|
||||
static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *session, switch_event_t *var_event,
|
||||
switch_caller_profile_t *outbound_profile,
|
||||
switch_core_session_t **new_session,
|
||||
switch_memory_pool_t **pool,
|
||||
switch_originate_flag_t flags, switch_call_cause_t *cancel_cause);
|
||||
static switch_status_t channel_read_frame(switch_core_session_t *session, switch_frame_t **frame, switch_io_flag_t flags, int stream_id);
|
||||
static switch_status_t channel_write_frame(switch_core_session_t *session, switch_frame_t *frame, switch_io_flag_t flags, int stream_id);
|
||||
static switch_status_t channel_receive_message(switch_core_session_t *session, switch_core_session_message_t *msg);
|
||||
static switch_status_t channel_send_dtmf(switch_core_session_t *session, const switch_dtmf_t *dtmf);
|
||||
|
||||
switch_state_handler_table_t ctdm_state_handlers = {
|
||||
.on_init = channel_on_init,
|
||||
.on_destroy = channel_on_destroy
|
||||
};
|
||||
|
||||
switch_io_routines_t ctdm_io_routines = {
|
||||
.send_dtmf = channel_send_dtmf,
|
||||
.outgoing_channel = channel_outgoing_channel,
|
||||
.read_frame = channel_read_frame,
|
||||
.write_frame = channel_write_frame,
|
||||
.receive_message = channel_receive_message
|
||||
};
|
||||
|
||||
void ctdm_init(switch_loadable_module_interface_t *module_interface)
|
||||
{
|
||||
switch_endpoint_interface_t *endpoint_interface;
|
||||
ctdm.pool = module_interface->pool;
|
||||
endpoint_interface = switch_loadable_module_create_interface(module_interface, SWITCH_ENDPOINT_INTERFACE);
|
||||
endpoint_interface->interface_name = "tdm";
|
||||
endpoint_interface->io_routines = &ctdm_io_routines;
|
||||
endpoint_interface->state_handler = &ctdm_state_handlers;
|
||||
ctdm.endpoint_interface = endpoint_interface;
|
||||
|
||||
}
|
||||
|
||||
static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *session, switch_event_t *var_event,
|
||||
switch_caller_profile_t *outbound_profile,
|
||||
switch_core_session_t **new_session,
|
||||
switch_memory_pool_t **pool,
|
||||
switch_originate_flag_t flags, switch_call_cause_t *cancel_cause)
|
||||
{
|
||||
const char *szspanid = switch_event_get_header(var_event, kSPAN_ID),
|
||||
*szchanid = switch_event_get_header(var_event, kCHAN_ID);
|
||||
int chan_id;
|
||||
int span_id;
|
||||
|
||||
ftdm_span_t *span;
|
||||
ftdm_channel_t *chan;
|
||||
switch_channel_t *channel;
|
||||
char name[128];
|
||||
const char *dname;
|
||||
ftdm_codec_t codec;
|
||||
uint32_t interval;
|
||||
|
||||
ctdm_private_t *tech_pvt;
|
||||
|
||||
if (zstr(szchanid) || zstr(szspanid)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Both "kSPAN_ID" and "kCHAN_ID" have to be set.\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
chan_id = atoi(szchanid);
|
||||
span_id = atoi(szspanid);
|
||||
|
||||
|
||||
if (!(*new_session = switch_core_session_request(ctdm.endpoint_interface, SWITCH_CALL_DIRECTION_OUTBOUND, 0, pool))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't request session.\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
channel = switch_core_session_get_channel(*new_session);
|
||||
|
||||
if (ftdm_channel_open(span_id, chan_id, &chan) != FTDM_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't open span or channel.\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
span = ftdm_channel_get_span(chan);
|
||||
|
||||
tech_pvt = switch_core_session_alloc(*new_session, sizeof *tech_pvt);
|
||||
tech_pvt->chan_id = chan_id;
|
||||
tech_pvt->span_id = span_id;
|
||||
tech_pvt->ftdm_channel = chan;
|
||||
tech_pvt->session = *new_session;
|
||||
switch_core_session_set_private(*new_session, tech_pvt);
|
||||
|
||||
snprintf(name, sizeof(name), "tdm/%d:%d", span_id, chan_id);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Connect outbound channel %s\n", name);
|
||||
switch_channel_set_name(channel, name);
|
||||
|
||||
switch_channel_set_state(channel, CS_INIT);
|
||||
|
||||
if (FTDM_SUCCESS != ftdm_channel_command(chan, FTDM_COMMAND_GET_CODEC, &codec)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to retrieve channel codec.\n");
|
||||
return SWITCH_STATUS_GENERR;
|
||||
}
|
||||
|
||||
if (FTDM_SUCCESS != ftdm_channel_command(chan, FTDM_COMMAND_GET_INTERVAL, &interval)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to retrieve channel interval.\n");
|
||||
return SWITCH_STATUS_GENERR;
|
||||
}
|
||||
|
||||
switch(codec) {
|
||||
case FTDM_CODEC_ULAW:
|
||||
{
|
||||
dname = "PCMU";
|
||||
}
|
||||
break;
|
||||
case FTDM_CODEC_ALAW:
|
||||
{
|
||||
dname = "PCMA";
|
||||
}
|
||||
break;
|
||||
case FTDM_CODEC_SLIN:
|
||||
{
|
||||
dname = "L16";
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid codec value retrieved from channel, codec value: %d\n", codec);
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (switch_core_codec_init(&tech_pvt->read_codec,
|
||||
dname,
|
||||
NULL,
|
||||
8000,
|
||||
interval,
|
||||
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,
|
||||
dname,
|
||||
NULL,
|
||||
8000,
|
||||
interval,
|
||||
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");
|
||||
switch_core_codec_destroy(&tech_pvt->read_codec);
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
||||
if (switch_core_session_set_read_codec(*new_session, &tech_pvt->read_codec) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't set read codec?\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (switch_core_session_set_write_codec(*new_session, &tech_pvt->write_codec) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't set write codec?\n");
|
||||
}
|
||||
|
||||
if (switch_core_session_thread_launch(*new_session) != SWITCH_STATUS_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't start session thread.\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
return SWITCH_CAUSE_SUCCESS;
|
||||
|
||||
fail:
|
||||
|
||||
if (tech_pvt) {
|
||||
if (tech_pvt->ftdm_channel) {
|
||||
ftdm_channel_close(&tech_pvt->ftdm_channel);
|
||||
}
|
||||
|
||||
if (tech_pvt->read_codec.implementation) {
|
||||
switch_core_codec_destroy(&tech_pvt->read_codec);
|
||||
}
|
||||
|
||||
if (tech_pvt->write_codec.implementation) {
|
||||
switch_core_codec_destroy(&tech_pvt->write_codec);
|
||||
}
|
||||
}
|
||||
|
||||
if (*new_session) {
|
||||
switch_core_session_destroy(new_session);
|
||||
}
|
||||
return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
|
||||
}
|
||||
|
||||
static switch_status_t channel_on_init(switch_core_session_t *session)
|
||||
{
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_status_t channel_on_destroy(switch_core_session_t *session)
|
||||
{
|
||||
ctdm_private_t *tech_pvt = switch_core_session_get_private(session);
|
||||
|
||||
if ((tech_pvt = switch_core_session_get_private(session))) {
|
||||
|
||||
if (tech_pvt->read_codec.implementation) {
|
||||
switch_core_codec_destroy(&tech_pvt->read_codec);
|
||||
}
|
||||
|
||||
if (tech_pvt->write_codec.implementation) {
|
||||
switch_core_codec_destroy(&tech_pvt->write_codec);
|
||||
}
|
||||
}
|
||||
|
||||
ftdm_channel_close(&tech_pvt->ftdm_channel);
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static switch_status_t channel_read_frame(switch_core_session_t *session, switch_frame_t **frame, switch_io_flag_t flags, int stream_id)
|
||||
{
|
||||
ftdm_wait_flag_t wflags = FTDM_READ;
|
||||
ftdm_status_t status;
|
||||
ctdm_private_t *tech_pvt;
|
||||
const char *name;
|
||||
switch_channel_t *channel;
|
||||
int chunk;
|
||||
uint32_t span_id, chan_id;
|
||||
ftdm_size_t len;
|
||||
char dtmf[128] = "";
|
||||
|
||||
channel = switch_core_session_get_channel(session);
|
||||
assert(channel != NULL);
|
||||
|
||||
tech_pvt = switch_core_session_get_private(session);
|
||||
assert(tech_pvt != NULL);
|
||||
|
||||
name = switch_channel_get_name(channel);
|
||||
|
||||
top:
|
||||
wflags = FTDM_READ;
|
||||
chunk = ftdm_channel_get_io_interval(tech_pvt->ftdm_channel) * 2;
|
||||
status = ftdm_channel_wait(tech_pvt->ftdm_channel, &wflags, chunk);
|
||||
|
||||
|
||||
span_id = ftdm_channel_get_span_id(tech_pvt->ftdm_channel);
|
||||
chan_id = ftdm_channel_get_id(tech_pvt->ftdm_channel);
|
||||
|
||||
if (status == FTDM_FAIL) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to read from channel %s device %d:%d!\n", name, span_id, chan_id);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (status == FTDM_TIMEOUT) {
|
||||
goto top;
|
||||
}
|
||||
|
||||
if (!(wflags & FTDM_READ)) {
|
||||
goto top;
|
||||
}
|
||||
|
||||
len = tech_pvt->read_frame.buflen;
|
||||
if (ftdm_channel_read(tech_pvt->ftdm_channel, tech_pvt->read_frame.data, &len) != FTDM_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Failed to read from channel %s device %d:%d!\n", name, span_id, chan_id);
|
||||
}
|
||||
|
||||
*frame = &tech_pvt->read_frame;
|
||||
tech_pvt->read_frame.datalen = (uint32_t)len;
|
||||
tech_pvt->read_frame.samples = tech_pvt->read_frame.datalen;
|
||||
|
||||
if (ftdm_channel_get_codec(tech_pvt->ftdm_channel) == FTDM_CODEC_SLIN) {
|
||||
tech_pvt->read_frame.samples /= 2;
|
||||
}
|
||||
|
||||
while (ftdm_channel_dequeue_dtmf(tech_pvt->ftdm_channel, dtmf, sizeof(dtmf))) {
|
||||
switch_dtmf_t _dtmf = { 0, switch_core_default_dtmf_duration(0) };
|
||||
char *p;
|
||||
for (p = dtmf; p && *p; p++) {
|
||||
if (is_dtmf(*p)) {
|
||||
_dtmf.digit = *p;
|
||||
ftdm_log(FTDM_LOG_DEBUG, "Queuing DTMF [%c] in channel %s device %d:%d\n", *p, name, span_id, chan_id);
|
||||
switch_channel_queue_dtmf(channel, &_dtmf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
|
||||
fail:
|
||||
return SWITCH_STATUS_GENERR;
|
||||
}
|
||||
|
||||
static switch_status_t channel_write_frame(switch_core_session_t *session, switch_frame_t *frame, switch_io_flag_t flags, int stream_id)
|
||||
{
|
||||
ftdm_wait_flag_t wflags = FTDM_WRITE;
|
||||
ctdm_private_t *tech_pvt;
|
||||
const char *name;
|
||||
switch_channel_t *channel;
|
||||
uint32_t span_id, chan_id;
|
||||
ftdm_size_t len;
|
||||
unsigned char data[SWITCH_RECOMMENDED_BUFFER_SIZE] = {0};
|
||||
|
||||
channel = switch_core_session_get_channel(session);
|
||||
assert(channel != NULL);
|
||||
|
||||
tech_pvt = switch_core_session_get_private(session);
|
||||
assert(tech_pvt != NULL);
|
||||
|
||||
span_id = ftdm_channel_get_span_id(tech_pvt->ftdm_channel);
|
||||
chan_id = ftdm_channel_get_id(tech_pvt->ftdm_channel);
|
||||
|
||||
name = switch_channel_get_name(channel);
|
||||
|
||||
if (switch_test_flag(frame, SFF_CNG)) {
|
||||
frame->data = data;
|
||||
frame->buflen = sizeof(data);
|
||||
if ((frame->datalen = tech_pvt->write_codec.implementation->encoded_bytes_per_packet) > frame->buflen) {
|
||||
goto fail;
|
||||
}
|
||||
memset(data, 255, frame->datalen);
|
||||
}
|
||||
|
||||
wflags = FTDM_WRITE;
|
||||
ftdm_channel_wait(tech_pvt->ftdm_channel, &wflags, ftdm_channel_get_io_interval(tech_pvt->ftdm_channel) * 10);
|
||||
|
||||
if (!(wflags & FTDM_WRITE)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Dropping frame! (write not ready) in channel %s device %d:%d!\n", name, span_id, chan_id);
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
len = frame->datalen;
|
||||
if (ftdm_channel_write(tech_pvt->ftdm_channel, frame->data, frame->buflen, &len) != FTDM_SUCCESS) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Failed to write to channel %s device %d:%d!\n", name, span_id, chan_id);
|
||||
}
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
|
||||
fail:
|
||||
return SWITCH_STATUS_GENERR;
|
||||
}
|
||||
|
||||
static switch_status_t channel_send_dtmf(switch_core_session_t *session, const switch_dtmf_t *dtmf)
|
||||
{
|
||||
ctdm_private_t *tech_pvt = NULL;
|
||||
char tmp[2] = "";
|
||||
|
||||
tech_pvt = switch_core_session_get_private(session);
|
||||
assert(tech_pvt != NULL);
|
||||
|
||||
tmp[0] = dtmf->digit;
|
||||
ftdm_channel_command(tech_pvt->ftdm_channel, FTDM_COMMAND_SEND_DTMF, tmp);
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_status_t channel_receive_message(switch_core_session_t *session, switch_core_session_message_t *msg)
|
||||
{
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -81,6 +81,7 @@ struct sdp_parser_s {
|
||||
unsigned pr_insane : 1;
|
||||
unsigned pr_c_missing : 1;
|
||||
unsigned pr_config : 1;
|
||||
unsigned pr_megaco : 1;
|
||||
};
|
||||
|
||||
#define is_posdigit(c) ((c) >= '1' && (c) <= '9')
|
||||
@@ -176,6 +177,7 @@ sdp_parse(su_home_t *home, char const msg[], issize_t msgsize, int flags)
|
||||
if (flags & sdp_f_config)
|
||||
p->pr_c_missing = 1, p->pr_config = 1;
|
||||
p->pr_mode_manual = (flags & sdp_f_mode_manual) != 0;
|
||||
p->pr_megaco = (flags & sdp_f_megaco) != 0;
|
||||
p->pr_session_mode = sdp_sendrecv;
|
||||
|
||||
parse_message(p);
|
||||
@@ -1502,8 +1504,18 @@ static void parse_payload(sdp_parser_t *p, char *r, sdp_rtpmap_t **result)
|
||||
{
|
||||
while (*r) {
|
||||
unsigned long value;
|
||||
if (((p->pr_config && r[0] == '*') || (p->pr_megaco && r[0] == MEGACO_CHOOSE_TOK)) && (r[1] == ' ' || r[1] == '\0')) {
|
||||
PARSE_ALLOC(p, sdp_rtpmap_t, rm);
|
||||
|
||||
if (parse_ul(p, &r, &value, 128) == 0) {
|
||||
*result = rm; result = &rm->rm_next;
|
||||
|
||||
rm->rm_predef = 1;
|
||||
rm->rm_any = 1;
|
||||
rm->rm_encoding = "*";
|
||||
rm->rm_rate = 0;
|
||||
|
||||
return;
|
||||
} else if (parse_ul(p, &r, &value, 128) == 0 && value < 128) {
|
||||
PARSE_ALLOC(p, sdp_rtpmap_t, rm);
|
||||
|
||||
assert(0 <= value && value < 128);
|
||||
@@ -1519,21 +1531,8 @@ static void parse_payload(sdp_parser_t *p, char *r, sdp_rtpmap_t **result)
|
||||
rm->rm_encoding = "";
|
||||
rm->rm_rate = 0;
|
||||
}
|
||||
}
|
||||
else if (p->pr_config && r[0] == '*' && (r[1] == ' ' || r[1] == '\0')) {
|
||||
PARSE_ALLOC(p, sdp_rtpmap_t, rm);
|
||||
|
||||
*result = rm; result = &rm->rm_next;
|
||||
|
||||
rm->rm_predef = 1;
|
||||
rm->rm_any = 1;
|
||||
rm->rm_encoding = "*";
|
||||
rm->rm_rate = 0;
|
||||
|
||||
return;
|
||||
}
|
||||
else {
|
||||
parsing_error(p, "m= invalid format for RTP/AVT");
|
||||
} else {
|
||||
parsing_error(p, "m= invalid format for RTP/AVP");
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -1797,6 +1796,13 @@ static int parse_ul(sdp_parser_t *p, char **r,
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (p->pr_megaco && *ul == MEGACO_CHOOSE_TOK) {
|
||||
*result = MEGACO_CHOOSE;
|
||||
(*r)++;
|
||||
*r += strspn(*r, SPACE TAB);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -1824,6 +1830,13 @@ static int parse_ull(sdp_parser_t *p, char **r,
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (p->pr_megaco && *s == MEGACO_CHOOSE_TOK) {
|
||||
*result = MEGACO_CHOOSE;
|
||||
(*r)++;
|
||||
*r += strspn(*r, SPACE TAB);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,10 @@
|
||||
|
||||
#ifndef SDP_H
|
||||
#define SDP_H
|
||||
|
||||
#define MEGACO_CHOOSE_TOK '$'
|
||||
#define MEGACO_CHOOSE (UINT16_MAX + 1)
|
||||
|
||||
/**@file sofia-sip/sdp.h Simple SDP (RFC 2327) Interface.
|
||||
*
|
||||
* @author Pekka Pessi <Pekka.Pessi@nokia.com>
|
||||
@@ -260,7 +264,7 @@ typedef enum {
|
||||
/** Media announcement.
|
||||
*
|
||||
* This structure describes one media type, e.g., audio. The description
|
||||
* contains the transport address (IP address and port) used for the group,
|
||||
* contains the transport address (IP address and port) used for the group,/Users/mrene/Downloads
|
||||
* the transport protocol used, the media formats or RTP payload types, and
|
||||
* optionally media-specific bandwidth specification, encryption key and
|
||||
* attributes.
|
||||
@@ -525,7 +529,9 @@ enum sdp_parse_flags_e {
|
||||
/** Do not generate or parse SDP mode */
|
||||
sdp_f_mode_manual = 512,
|
||||
/** Always generate media-level mode attributes */
|
||||
sdp_f_mode_always = 1024
|
||||
sdp_f_mode_always = 1024,
|
||||
/** Allow optional (choose) parameters */
|
||||
sdp_f_megaco = 2048
|
||||
};
|
||||
|
||||
/** SDP parser handle. */
|
||||
|
||||
Reference in New Issue
Block a user