From a611da8407a609a3a426c61e7fb10230a9320122 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Fri, 14 Aug 2015 09:24:11 +0200 Subject: mgcp: Move the SDP handling into a separate file/module The SDP file handling will get more complicated in terms of codec selection so let's remove it from the protocol handling before we start blowing it up in size. --- openbsc/include/openbsc/mgcp_internal.h | 61 +++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) (limited to 'openbsc/include') diff --git a/openbsc/include/openbsc/mgcp_internal.h b/openbsc/include/openbsc/mgcp_internal.h index 570d96395..763d83b0d 100644 --- a/openbsc/include/openbsc/mgcp_internal.h +++ b/openbsc/include/openbsc/mgcp_internal.h @@ -22,6 +22,8 @@ #pragma once +#include + #include #define CI_UNUSED 0 @@ -203,8 +205,51 @@ struct mgcp_endpoint { } osmux; }; +#define for_each_line(line, save) \ + for (line = strline_r(NULL, &save); line;\ + line = strline_r(NULL, &save)) + +static inline char *strline_r(char *str, char **saveptr) +{ + char *result; + + if (str) + *saveptr = str; + + result = *saveptr; + + if (*saveptr != NULL) { + *saveptr = strpbrk(*saveptr, "\r\n"); + + if (*saveptr != NULL) { + char *eos = *saveptr; + + if ((*saveptr)[0] == '\r' && (*saveptr)[1] == '\n') + (*saveptr)++; + (*saveptr)++; + if ((*saveptr)[0] == '\0') + *saveptr = NULL; + + *eos = '\0'; + } + } + + return result; +} + + + #define ENDPOINT_NUMBER(endp) abs((int)(endp - endp->tcfg->endpoints)) +/** + * Internal structure while parsing a request + */ +struct mgcp_parse_data { + struct mgcp_config *cfg; + struct mgcp_endpoint *endp; + char *trans; + char *save; + int found; }; int mgcp_send_dummy(struct mgcp_endpoint *endp); @@ -257,5 +302,21 @@ enum { MGCP_DEST_BTS, }; + #define MGCP_DUMMY_LOAD 0x23 + +/** + * SDP related information + */ +/* Assume audio frame length of 20ms */ +#define DEFAULT_RTP_AUDIO_FRAME_DUR_NUM 20 +#define DEFAULT_RTP_AUDIO_FRAME_DUR_DEN 1000 +#define DEFAULT_RTP_AUDIO_PACKET_DURATION_MS 20 +#define DEFAULT_RTP_AUDIO_DEFAULT_RATE 8000 +#define DEFAULT_RTP_AUDIO_DEFAULT_CHANNELS 1 + +#define PTYPE_UNDEFINED (-1) +int mgcp_parse_sdp_data(struct mgcp_rtp_end *rtp, struct mgcp_parse_data *p); +int mgcp_set_audio_info(void *ctx, struct mgcp_rtp_codec *codec, + int payload_type, const char *audio_name); -- cgit v1.2.3