Bug 1091242 - Part 5.2: Functionality changes to sipcc sdp code. r=ehugg r=pkerr

This commit is contained in:
Byron Campen [:bwc] 2014-11-14 17:37:40 -08:00
parent 3a9bea5a98
commit fd079c31ac
21 changed files with 1211 additions and 1494 deletions

View File

@ -150,6 +150,7 @@ typedef enum {
SDP_UNRECOGNIZED_TOKEN,
SDP_NULL_BUF_PTR,
SDP_POTENTIAL_SDP_OVERFLOW,
SDP_EMPTY_TOKEN,
SDP_MAX_RC
} sdp_result_e;
@ -249,6 +250,11 @@ typedef enum {
SDP_ATTR_CONNECTION,
SDP_ATTR_EXTMAP, /* RFC 5285 */
SDP_ATTR_IDENTITY,
SDP_ATTR_MSID,
SDP_ATTR_MSID_SEMANTIC,
SDP_ATTR_BUNDLE_ONLY,
SDP_ATTR_END_OF_CANDIDATES,
SDP_ATTR_ICE_OPTIONS,
SDP_MAX_ATTR_TYPES,
SDP_ATTR_INVALID
} sdp_attr_e;

View File

@ -57,40 +57,4 @@ static_assert(SDP_MAX_RTCP_FB_NACK +
"rtcp-fb Bitmap is larger than 32 bits");
#endif
static int32_t
sdp_rtcp_fb_nack_to_bitmap(sdp_rtcp_fb_nack_type_e type)
{
int bitnumber = type;
if (type < 0 || type >= SDP_MAX_RTCP_FB_NACK) {
return 0;
}
return (1 << bitnumber);
}
static int32_t
sdp_rtcp_fb_ack_to_bitmap(sdp_rtcp_fb_ack_type_e type)
{
int bitnumber = type + SDP_MAX_RTCP_FB_NACK;
if (type < 0 || type >= SDP_MAX_RTCP_FB_ACK) {
return 0;
}
return (1 << bitnumber);
}
static int32_t
sdp_rtcp_fb_ccm_to_bitmap(sdp_rtcp_fb_ccm_type_e type)
{
int bitnumber = type + SDP_MAX_RTCP_FB_NACK + SDP_MAX_RTCP_FB_ACK;
if (type < 0 || type >= SDP_MAX_RTCP_FB_CCM) {
return 0;
}
return (1 << bitnumber);
}
#endif

View File

@ -1,157 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef _CPR_ANDROID_TYPES_H_
#define _CPR_ANDROID_TYPES_H_
#include "sys/types.h"
#include "stddef.h"
#include "inttypes.h"
/**
* @typedef boolean
*
* Define boolean as an unsigned byte
*
* @note There are differences within TNP header files
* @li curses.h: bool => char
* @li types.h: boolean_t => enum
* @li dki_lock.h: bool_t => int
*/
typedef uint8_t boolean;
/*
* Define size_t
* defined in numerous header files
*/
/* DONE (sys/types.h => unsigned int) */
/*
* Define ssize_t
*/
/* DONE (sys/types.h => int) */
/*
* Define MIN/MAX
* defined in param.h
*
* The GNU versions of the MAX and MIN macros do two things better than
* the old versions:
* 1. they are more optimal as they only evaluate a & b once by creating a
* a variable of each type on the local stack.
* 2. they fix potential errors due to side-effects where a and b were
* evaluated twice, i.e. MIN(i++,j++)
*
* @note b could be cast to a's type, to help with usage where the code
* compares signed and unsigned types.
*/
#ifndef MIN
#ifdef __GNUC__
#define MIN(a,b) ({ typeof(a) _a = (a); typeof(b) _b = (b); _a < _b ? _a : _b; })
#else
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#endif
#endif
#ifndef MAX
#ifdef __GNUC__
#define MAX(a,b) ({ typeof(a) _a = (a); typeof(b) _b = (b); _a > _b ? _a : _b; })
#else
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#endif
#endif
/*
* Define NULL
* defined in numerous header files
*/
/* DONE (stddef.h) */
/**
* @def NUL
*
* Define NUL for string termination
*/
#ifndef NUL
#define NUL '\0'
#endif
/**
* @def RESTRICT
*
* If suppoprting the ISO/IEC 9899:1999 standard,
* use the '__restrict' keyword
*/
#if defined(_POSIX_C_SOURCE) && defined(__GNUC__)
#define RESTRICT __restrict
#else
#define RESTRICT
#endif
/**
* @def CONST
*
* Define CONST as @c const, if supported
*/
#define CONST const
/**
* @def INLINE
*
* Define the appropriate setting for inlining functions
*/
#ifdef __STRICT_ANSI__
#define INLINE
#else
#define INLINE __inline__
#endif
/**
* __BEGIN_DECLS and __END_DECLS
*
* Define macros for compilation by C++ compiler
*/
#ifndef __BEGIN_DECLS
#ifdef __cplusplus
#define __BEGIN_DECLS extern "C" {
#else
#define __BEGIN_DECLS
#endif
#endif
#ifndef __END_DECLS
#ifdef __cplusplus
#define __END_DECLS }
#else
#define __END_DECLS
#endif
#endif
/**
* Define TRUE/FALSE
* defined in several header files
*/
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
/*
* Define offsetof
*/
/* DONE (stddef.h) */
/**
* @def FIELDOFFSET(struct name, field name)
*
* Macro to generate offset from a given field in a structure
*/
#define FIELDOFFSET(struct_name, field_name) (size_t)(&(((struct_name *)0)->field_name))
#endif

View File

@ -53,45 +53,6 @@ typedef uint8_t boolean;
#endif
#endif
/**
* @def NUL
*
* Define NUL for string termination
*/
#ifndef NUL
#define NUL '\0'
#endif
/**
* @def RESTRICT
*
* If suppoprting the ISO/IEC 9899:1999 standard,
* use the '__restrict' keyword
*/
#if defined(_POSIX_C_SOURCE) && defined(__GNUC__)
#define RESTRICT __restrict
#else
#define RESTRICT
#endif
/**
* @def CONST
*
* Define CONST as @c const, if supported
*/
#define CONST const
/**
* @def INLINE
*
* Define the appropriate setting for inlining functions
*/
#ifdef __STRICT_ANSI__
#define INLINE
#else
#define INLINE __inline__
#endif
/**
* __BEGIN_DECLS and __END_DECLS
*
@ -125,12 +86,4 @@ typedef uint8_t boolean;
#define FALSE 0
#endif
/**
* @def FIELDOFFSET(struct name, field name)
*
* Macro to generate offset from a given field in a structure
*/
#define FIELDOFFSET(struct_name, field_name) (long)(&(((struct_name *)0)->field_name))
#endif

View File

@ -63,50 +63,6 @@ typedef uint8_t boolean;
#endif
/*
* Define NULL
* defined in numerous header files
*/
/* DONE (stddef.h) */
/**
* @def NUL
*
* Define NUL for string termination
*/
#ifndef NUL
#define NUL '\0'
#endif
/**
* @def RESTRICT
*
* If suppoprting the ISO/IEC 9899:1999 standard,
* use the '__restrict' keyword
*/
#if defined(_POSIX_C_SOURCE) && defined(__GNUC__)
#define RESTRICT __restrict
#else
#define RESTRICT
#endif
/**
* @def CONST
*
* Define CONST as @c const, if supported
*/
#define CONST const
/**
* @def INLINE
*
* Define the appropriate setting for inlining functions
*/
#ifdef __STRICT_ANSI__
#define INLINE
#else
#define INLINE __inline__
#endif
/**
* __BEGIN_DECLS and __END_DECLS
@ -128,7 +84,6 @@ typedef uint8_t boolean;
#define __END_DECLS
#endif
#endif
/**
* Define TRUE/FALSE
* defined in several header files
@ -146,12 +101,4 @@ typedef uint8_t boolean;
*/
/* DONE (stddef.h) */
/**
* @def FIELDOFFSET(struct name, field name)
*
* Macro to generate offset from a given field in a structure
*/
#define FIELDOFFSET(struct_name, field_name) (size_t)(&(((struct_name *)0)->field_name))
#endif

View File

@ -6,10 +6,18 @@
#include "mozilla/Assertions.h"
#include "cpr_types.h"
#include "cpr_stdlib.h"
#include "cpr_string.h"
#include "cpr_strings.h"
/* From cpr_stdlib.h */
#include "mozilla/mozalloc.h"
#define cpr_malloc(a) moz_xmalloc(a)
#define cpr_calloc(a, b) moz_xcalloc(a, b)
#define cpr_realloc(a, b) moz_xrealloc(a, b)
#define cpr_free(a) moz_free(a)
/**
* sstrncpy
*
@ -222,3 +230,43 @@ void flex_string_sprintf(flex_string *fs, const char *format, ...) {
va_end(ap);
}
/* From cpr_linux_string.c */
/**
* cpr_strdup
*
* @brief The CPR wrapper for strdup
* The cpr_strdup shall return a pointer to a new string, which is a duplicate
* of the string pointed to by "str" argument. A null pointer is returned if the
* new string cannot be created.
*
* @param[in] str - The string that needs to be duplicated
*
* @return The duplicated string or NULL in case of no memory
*
*/
char *
cpr_strdup (const char *str)
{
char *dup;
size_t len;
if (!str) {
return (char *) NULL;
}
len = strlen(str);
if (len == 0) {
return (char *) NULL;
}
len++;
dup = cpr_malloc(len * sizeof(char));
if (!dup) {
return (char *) NULL;
}
(void) memcpy(dup, str, len);
return dup;
}

View File

@ -12,15 +12,6 @@
__BEGIN_DECLS
#if defined SIP_OS_LINUX
#include "../linux/cpr_linux_string.h"
#elif defined SIP_OS_WINDOWS
#include "../win32/cpr_win_string.h"
#define cpr_strdup _strdup
#elif defined SIP_OS_OSX
#include "../darwin/cpr_darwin_string.h"
#endif
/**
* sstrncpy
*
@ -65,6 +56,7 @@ sstrncpy(char *dst, const char *src, unsigned long max);
char *
sstrncat(char *s1, const char *s2, unsigned long max);
/*
* flex_string
*/
@ -120,6 +112,24 @@ void flex_string_vsprintf(flex_string *fs, const char *format, va_list original_
*/
void flex_string_sprintf(flex_string *fs, const char *format, ...);
/* From cpr_linux_string.h */
/* cpr_strdup
*
* @brief The CPR wrapper for strdup
* The cpr_strdup shall return a pointer to a new string, which is a duplicate
* of the string pointed to by "str" argument. A null pointer is returned if the
* new string cannot be created.
*
* @param[in] str - The string that needs to be duplicated
*
* @return The duplicated string or NULL in case of no memory
*
*/
char *
cpr_strdup(const char *str);
__END_DECLS
#endif

View File

@ -9,55 +9,21 @@
__BEGIN_DECLS
#if defined SIP_OS_LINUX
#include "../linux/cpr_linux_strings.h"
#elif defined SIP_OS_WINDOWS
#include "../win32/cpr_win_strings.h"
#elif defined SIP_OS_OSX
#include "../darwin/cpr_darwin_strings.h"
#endif
#ifdef CPR_USE_OS_STRCASECMP
/* Use standard library types, but use the OS's name for the functions */
#ifndef cpr_strcasecmp
#include <string.h>
#ifdef _MSC_VER
#define cpr_strcasecmp _stricmp
#define cpr_strncasecmp _strnicmp
#define snprintf _snprintf
#else // _MSC_VER
#define cpr_strcasecmp strcasecmp
#endif
#ifndef cpr_strncasecmp
#define cpr_strncasecmp strncasecmp
#endif
#else
/* Prototypes */
/**
* cpr_strcasecmp
*
* @brief The CPR wrapper for strcasecmp
*
* The cpr_strcasecmp performs case insensitive string comparison of the "s1"
* and the "s2" strings.
*
* @param[in] s1 - The first string
* @param[in] s2 - The second string
*
* @return integer <,=,> 0 depending on whether s1 is <,=,> s2
*/
int cpr_strcasecmp(const char *s1, const char *s2);
/**
* cpr_strncasecmp
*
* @brief The CPR wrapper for strncasecmp
*
* The cpr_strncasecmp performs case insensitive string comparison for specific
* length "len".
*
* @param[in] s1 - The first string
* @param[in] s2 - The second string
* @param[in] len - The length to be compared
*
* @return integer <,=,> 0 depending on whether s1 is <,=,> s2
*/
int cpr_strncasecmp(const char *s1, const char *s2, size_t len);
#endif
#endif // _MSC_VER
__END_DECLS

View File

@ -6,11 +6,11 @@
#define _CPR_TYPES_H_
#if defined SIP_OS_LINUX
#include "../linux/cpr_linux_types.h"
#include "cpr_linux_types.h"
#elif defined SIP_OS_WINDOWS
#include "../win32/cpr_win_types.h"
#include "cpr_win_types.h"
#elif defined SIP_OS_OSX
#include "../darwin/cpr_darwin_types.h"
#include "cpr_darwin_types.h"
#endif
__BEGIN_DECLS

View File

@ -100,32 +100,6 @@ typedef int pid_t;
*/
/* DONE defined in windef.h */
/*
* Define NUL
*/
#ifndef NUL
#define NUL '\0'
#endif
/*
* Define RESTRICT
*
* If supporting the ISO/IEC 9899:1999 standard,
* use the 'restrict' keyword
*/
#if defined(_POSIX_C_SOURCE)
#define RESTRICT restrict
#else
#define RESTRICT
#endif
/*
* Define CONST
*/
#ifndef CONST
#define CONST const
#endif
/*
* Define __BEGIN_DECLS and __END_DECLS
*/
@ -137,16 +111,5 @@ typedef int pid_t;
#define __END_DECLS
#endif
/* Not sure what this is, but we need it */
#define MSG_ECHO_EVENT 0xF001
#endif // _CPR_WIN_TYPES_H_
/*
* Define alternate punctuation token spellings
* Added 'equals' which is not part of the standard iso646.h
*/
#ifndef __cplusplus
#include "iso646.h"
#endif
#define equals ==
#endif

View File

@ -2,10 +2,9 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef _SDP_H_
#define _SDP_H_
#ifndef _SIPCC_SDP_H_
#define _SIPCC_SDP_H_
#include "cc_constants.h"
#include "sdp_os_defs.h"
#include "ccsdp.h"
@ -24,6 +23,10 @@
#define AES_CM_128_HMAC_SHA1_80 "AES_CM_128_HMAC_SHA1_80"
#define F8_128_HMAC_SHA1_80 "F8_128_HMAC_SHA1_80"
/* Pulled in from rtp_defs.h. */
#define GET_DYN_PAYLOAD_TYPE_VALUE(a) ((a & 0XFF00) ? ((a & 0XFF00) >> 8) : a)
#define SET_PAYLOAD_TYPE_WITH_DYNAMIC(a,b) ((a << 8) | b)
/*
* SDP_SRTP_MAX_KEY_SIZE_BYTES
* Maximum size for a SRTP Master Key in bytes.
@ -179,6 +182,11 @@ typedef enum {
SDP_TRANSPORT_TCP,
SDP_TRANSPORT_RTPSAVPF,
SDP_TRANSPORT_DTLSSCTP,
SDP_TRANSPORT_RTPAVPF,
SDP_TRANSPORT_UDPTLSRTPSAVP,
SDP_TRANSPORT_UDPTLSRTPSAVPF,
SDP_TRANSPORT_TCPTLSRTPSAVP,
SDP_TRANSPORT_TCPTLSRTPSAVPF,
SDP_MAX_TRANSPORT_TYPES,
SDP_TRANSPORT_UNSUPPORTED,
SDP_TRANSPORT_INVALID
@ -454,6 +462,7 @@ typedef enum {
SDP_GROUP_ATTR_FID,
SDP_GROUP_ATTR_LS,
SDP_GROUP_ATTR_ANAT,
SDP_GROUP_ATTR_BUNDLE,
SDP_MAX_GROUP_ATTR_VAL,
SDP_GROUP_ATTR_UNSUPPORTED
} sdp_group_attr_e;
@ -542,7 +551,7 @@ typedef enum sdp_srtp_crypto_suite_t_ {
#define SDP_INVALID_PACKETIZATION_MODE_VALUE 255
#define SDP_MAX_LEVEL_ASYMMETRY_ALLOWED_VALUE 1 /* max level asymmetry allowed value for H.264 */
#define SDP_DEFAULT_LEVEL_ASYMMETRY_ALLOWED_VALUE 1 /* default level asymmetry allowed value for H.264 */
#define SDP_DEFAULT_LEVEL_ASYMMETRY_ALLOWED_VALUE 0 /* default level asymmetry allowed value for H.264 */
#define SDP_INVALID_LEVEL_ASYMMETRY_ALLOWED_VALUE 2 /* invalid value for level-asymmetry-allowed param for H.264 */
@ -718,6 +727,12 @@ typedef struct sdp_sctpmap {
char protocol[SDP_MAX_STRING_LEN+1];
} sdp_sctpmap_t;
#define SDP_MAX_MSID_LEN 64
typedef struct sdp_msid {
char identifier[SDP_MAX_MSID_LEN+1];
char appdata[SDP_MAX_MSID_LEN+1];
} sdp_msid_t;
/* a=qos|secure|X-pc-qos|X-qos info */
typedef struct sdp_qos {
@ -823,7 +838,7 @@ typedef struct sdp_stream_data {
char x_confid[SDP_MAX_STRING_LEN+1];
sdp_group_attr_e group_attr; /* FID or LS */
u16 num_group_id;
u16 group_id_arr[SDP_MAX_GROUP_STREAM_ID];
char * group_ids[SDP_MAX_GROUP_STREAM_ID];
} sdp_stream_data_t;
/*
@ -899,6 +914,7 @@ typedef struct sdp_media_profiles {
typedef struct sdp_extmap {
u16 id;
sdp_direction_e media_direction;
tinybool media_direction_specified;
char uri[SDP_MAX_STRING_LEN+1];
char extension_attributes[SDP_MAX_STRING_LEN+1];
} sdp_extmap_t;
@ -955,6 +971,7 @@ typedef struct sdp_mca {
sdp_attr_e media_direction; /* Either INACTIVE, SENDONLY,
RECVONLY, or SENDRECV */
u32 mid;
u32 line_number;
struct sdp_attr *media_attrs_p;
struct sdp_mca *next_p;
} sdp_mca_t;
@ -963,6 +980,7 @@ typedef struct sdp_mca {
/* generic a= line info */
typedef struct sdp_attr {
sdp_attr_e type;
u32 line_number;
union {
tinybool boolean_val;
u32 u32_val;
@ -970,6 +988,7 @@ typedef struct sdp_attr {
char ice_attr[SDP_MAX_STRING_LEN+1];
sdp_fmtp_t fmtp;
sdp_sctpmap_t sctpmap;
sdp_msid_t msid;
sdp_qos_t qos;
sdp_curr_t curr;
sdp_des_t des;
@ -1002,6 +1021,10 @@ typedef struct sdp_srtp_crypto_suite_list_ {
unsigned char salt_size_bytes;
} sdp_srtp_crypto_suite_list;
typedef void (*sdp_parse_error_handler)(void *context,
uint32_t line,
const char *message);
/* Application configuration options */
typedef struct sdp_conf_options {
u32 magic_num;
@ -1023,6 +1046,8 @@ typedef struct sdp_conf_options {
u32 num_invalid_param;
u32 num_no_resource;
struct sdp_conf_options *next_p;
sdp_parse_error_handler error_handler;
void *error_handler_context;
} sdp_conf_options_t;
@ -1030,7 +1055,6 @@ typedef struct sdp_conf_options {
/* Elements here that can only be one of are included directly. Elements */
/* that can be more than one are pointers. */
typedef struct {
char peerconnection[PC_HANDLE_SIZE];
u32 magic_num;
sdp_conf_options_t *conf_p;
tinybool debug_flag[SDP_MAX_DEBUG_TYPES];
@ -1061,6 +1085,9 @@ typedef struct {
/* Info to help building X-cpar/cpar attrs. */
sdp_attr_e last_cap_type;
/* Facilitates reporting line number for SDP errors */
u32 parse_line;
/* MCA - Media, connection, and attributes */
sdp_mca_t *mca_p;
ushort mca_count;
@ -1088,7 +1115,8 @@ typedef struct {
/* Prototypes */
/* sdp_config.c */
extern void *sdp_init_config(void);
extern sdp_conf_options_t *sdp_init_config(void);
extern void sdp_free_config(sdp_conf_options_t *config_p);
extern void sdp_appl_debug(void *config_p, sdp_debug_e debug_type,
tinybool debug_flag);
extern void sdp_require_version(void *config_p, tinybool version_required);
@ -1106,15 +1134,18 @@ extern void sdp_transport_supported(void *config_p, sdp_transport_e transport,
tinybool transport_supported);
extern void sdp_allow_choose(void *config_p, sdp_choose_param_e param,
tinybool choose_allowed);
extern void sdp_config_set_error_handler(void *config_p,
sdp_parse_error_handler handler,
void *context);
/* sdp_main.c */
extern sdp_t *sdp_init_description(const char *peerconnection, void *config_p);
extern sdp_t *sdp_init_description(sdp_conf_options_t *config_p);
extern void sdp_debug(sdp_t *sdp_ptr, sdp_debug_e debug_type, tinybool debug_flag);
extern void sdp_set_string_debug(sdp_t *sdp_ptr, const char *debug_str);
extern sdp_result_e sdp_parse(sdp_t *sdp_ptr, char **bufp, u16 len);
extern sdp_result_e sdp_parse(sdp_t *sdp_ptr, const char *buf, size_t len);
extern sdp_result_e sdp_build(sdp_t *sdp_ptr, flex_string *fs);
extern sdp_result_e sdp_free_description(sdp_t *sdp_ptr);
extern void sdp_parse_error(const char *peerconnection, const char *format, ...);
extern void sdp_parse_error(sdp_t *sdp, const char *format, ...);
extern const char *sdp_get_result_name(sdp_result_e rc);
@ -1181,6 +1212,7 @@ extern sdp_result_e sdp_set_mcast_addr_fields(void *sdp_ptr, u16 level,
extern tinybool sdp_media_line_valid(void *sdp_ptr, u16 level);
extern u16 sdp_get_num_media_lines(void *sdp_ptr);
extern sdp_media_e sdp_get_media_type(void *sdp_ptr, u16 level);
extern u32 sdp_get_media_line_number(void *sdp_ptr, u16 level);
extern sdp_port_format_e sdp_get_media_port_format(void *sdp_ptr, u16 level);
extern int32 sdp_get_media_portnum(void *sdp_ptr, u16 level);
extern int32 sdp_get_media_portcount(void *sdp_ptr, u16 level);
@ -1195,6 +1227,9 @@ extern sdp_transport_e sdp_get_media_profile(void *sdp_ptr, u16 level,
extern u16 sdp_get_media_num_payload_types(void *sdp_ptr, u16 level);
extern u16 sdp_get_media_profile_num_payload_types(void *sdp_ptr, u16 level,
u16 profile_num);
extern rtp_ptype sdp_get_known_payload_type(void *sdp_ptr,
u16 level,
u16 payload_type_raw);
extern u32 sdp_get_media_payload_type(void *sdp_ptr, u16 level,
u16 payload_num, sdp_payload_ind_e *indicator);
extern u32 sdp_get_media_profile_payload_type(void *sdp_ptr, u16 level,
@ -1225,6 +1260,9 @@ extern sdp_result_e sdp_add_media_profile_payload_type(void *sdp_ptr,
sdp_payload_ind_e indicator);
/* sdp_attr_access.c */
extern sdp_attr_t *sdp_find_attr (sdp_t *sdp_p, u16 level, u8 cap_num,
sdp_attr_e attr_type, u16 inst_num);
extern int sdp_find_fmtp_inst(sdp_t *sdp_ptr, u16 level, u16 payload_num);
extern sdp_result_e sdp_add_new_attr(void *sdp_ptr, u16 level, u8 cap_num,
sdp_attr_e attr_type, u16 *inst_num);
@ -1245,6 +1283,8 @@ extern sdp_result_e sdp_delete_attr(void *sdp_ptr, u16 level, u8 cap_num,
extern sdp_result_e sdp_delete_all_attrs(void *sdp_ptr, u16 level, u8 cap_num);
extern tinybool sdp_attr_valid(void *sdp_ptr, sdp_attr_e attr_type,
u16 level, u8 cap_num, u16 inst_num);
extern u32 sdp_attr_line_number(void *sdp_ptr, sdp_attr_e attr_type,
u16 level, u8 cap_num, u16 inst_num);
extern const char *sdp_attr_get_simple_string(void *sdp_ptr,
sdp_attr_e attr_type, u16 level, u8 cap_num, u16 inst_num);
extern sdp_result_e sdp_attr_set_simple_string(void *sdp_ptr,
@ -1333,6 +1373,8 @@ extern sdp_result_e sdp_attr_set_subnet_addr(void *sdp_ptr, u16 level,
extern sdp_result_e sdp_attr_set_subnet_prefix(void *sdp_ptr, u16 level,
u8 cap_num, u16 inst_num,
int32 prefix);
extern rtp_ptype sdp_attr_get_rtpmap_known_codec(void *sdp_ptr, u16 level,
u8 cap_num, u16 inst_num);
extern tinybool sdp_attr_rtpmap_payload_valid(void *sdp_ptr, u16 level,
u8 cap_num, u16 *inst_num, u16 payload_type);
extern u16 sdp_attr_get_rtpmap_payload_type(void *sdp_ptr, u16 level,
@ -1674,6 +1716,11 @@ extern sdp_result_e sdp_attr_set_sctpmap_streams (void *sdp_ptr, u16 level,
extern sdp_result_e sdp_attr_get_sctpmap_streams (void *sdp_ptr, u16 level,
u8 cap_num, u16 inst_num, u32* val);
extern const char *sdp_attr_get_msid_identifier(sdp_t *sdp_p, u16 level,
u8 cap_num, u16 inst_num);
extern const char *sdp_attr_get_msid_appdata(sdp_t *sdp_p, u16 level,
u8 cap_num, u16 inst_num);
/* H.264 codec specific params */
extern const char *sdp_attr_get_fmtp_profile_id(void *sdp_ptr, u16 level,
@ -1848,6 +1895,7 @@ extern sdp_result_e sdp_copy_all_bw_lines(void *src_sdp_ptr, void *dst_sdp_ptr,
u16 src_level, u16 dst_level);
extern sdp_bw_modifier_e sdp_get_bw_modifier(void *sdp_ptr, u16 level,
u16 inst_num);
extern const char *sdp_get_bw_modifier_name(sdp_bw_modifier_e bw_modifier);
extern int32 sdp_get_bw_value(void *sdp_ptr, u16 level, u16 inst_num);
extern int32 sdp_get_num_bw_lines (void *sdp_ptr, u16 level);
@ -1892,10 +1940,10 @@ extern sdp_result_e sdp_set_group_num_id(void *sdp_ptr, u16 level,
u8 cap_num, u16 inst_num,
u16 group_num_id);
extern int32 sdp_get_group_id(void *sdp_ptr, u16 level,
extern const char* sdp_get_group_id(void *sdp_ptr, u16 level,
u8 cap_num, u16 inst_num, u16 id_num);
extern sdp_result_e sdp_set_group_id (void *sdp_ptr, u16 level,
u8 cap_num, u16 inst_num, u16 group_id);
u8 cap_num, u16 inst_num, char* group_id);
extern int32 sdp_get_mid_value(void *sdp_ptr, u16 level);

View File

@ -5,12 +5,30 @@
#include "sdp_os_defs.h"
#include "sdp.h"
#include "sdp_private.h"
#include "ccsip_sdp.h"
#include "rtp_defs.h"
#include "CSFLog.h"
static const char* logTag = "sdp_access";
/* Pulled in from ccsip_sdp.h */
/* Possible encoding names of static payload types*/
#define SIPSDP_ATTR_ENCNAME_PCMU "PCMU"
#define SIPSDP_ATTR_ENCNAME_PCMA "PCMA"
#define SIPSDP_ATTR_ENCNAME_G729 "G729"
#define SIPSDP_ATTR_ENCNAME_G723 "G723"
#define SIPSDP_ATTR_ENCNAME_G726 "G726-32"
#define SIPSDP_ATTR_ENCNAME_G728 "G728"
#define SIPSDP_ATTR_ENCNAME_GSM "GSM"
#define SIPSDP_ATTR_ENCNAME_CN "CN"
#define SIPSDP_ATTR_ENCNAME_G722 "G722"
#define SIPSDP_ATTR_ENCNAME_ILBC "iLBC"
#define SIPSDP_ATTR_ENCNAME_H263v2 "H263-1998"
#define SIPSDP_ATTR_ENCNAME_H264 "H264"
#define SIPSDP_ATTR_ENCNAME_VP8 "VP8"
#define SIPSDP_ATTR_ENCNAME_L16_256K "L16"
#define SIPSDP_ATTR_ENCNAME_ISAC "ISAC"
#define SIPSDP_ATTR_ENCNAME_OPUS "opus"
/* Function: sdp_find_media_level
* Description: Find and return a pointer to the specified media level,
* if it exists.
@ -1275,6 +1293,31 @@ sdp_media_e sdp_get_media_type (void *sdp_ptr, u16 level)
return (mca_p->media);
}
/* Function: sdp_get_media_line_number
* Description: Returns the line number in the SDP the media
* section starts on. Only set if SDP has been parsed
* (rather than built).
* Parameters: sdp_ptr The SDP handle returned by sdp_init_description.
* level The level to of the m= media line. Will be 1-n.
* Returns: Line number (0 if not found or if locally built)
*/
u32 sdp_get_media_line_number (void *sdp_ptr, u16 level)
{
sdp_t *sdp_p = (sdp_t *)sdp_ptr;
sdp_mca_t *mca_p;
if (sdp_verify_sdp_ptr(sdp_p) == FALSE) {
return 0;
}
mca_p = sdp_find_media_level(sdp_p, level);
if (mca_p == NULL) {
return 0;
}
return (mca_p->line_number);
}
/* Function: sdp_get_media_port_format
* Description: Returns the port format type associated with the m=
* media token line. If port format type has not been
@ -1329,7 +1372,7 @@ int32 sdp_get_media_portnum (void *sdp_ptr, u16 level)
(mca_p->port_format != SDP_PORT_NUM_VPI_VCI_CID)) {
if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
CSFLogError(logTag, "%s Port num not valid for media line %u",
sdp_p->debug_str, level);
sdp_p->debug_str, (unsigned)level);
}
sdp_p->conf_p->num_invalid_param++;
return (SDP_INVALID_VALUE);
@ -1364,7 +1407,7 @@ int32 sdp_get_media_portcount (void *sdp_ptr, u16 level)
if (mca_p->port_format != SDP_PORT_NUM_COUNT) {
if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
CSFLogError(logTag, "%s Port count not valid for media line %u",
sdp_p->debug_str, level);
sdp_p->debug_str, (unsigned)level);
}
sdp_p->conf_p->num_invalid_param++;
return (SDP_INVALID_VALUE);
@ -1401,7 +1444,7 @@ int32 sdp_get_media_vpi (void *sdp_ptr, u16 level)
(mca_p->port_format != SDP_PORT_NUM_VPI_VCI_CID)) {
if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
CSFLogError(logTag, "%s VPI not valid for media line %u",
sdp_p->debug_str, level);
sdp_p->debug_str, (unsigned)level);
}
sdp_p->conf_p->num_invalid_param++;
return (SDP_INVALID_VALUE);
@ -1438,7 +1481,7 @@ u32 sdp_get_media_vci (void *sdp_ptr, u16 level)
(mca_p->port_format != SDP_PORT_NUM_VPI_VCI_CID)) {
if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
CSFLogError(logTag, "%s VCI not valid for media line %u",
sdp_p->debug_str, level);
sdp_p->debug_str, (unsigned)level);
}
sdp_p->conf_p->num_invalid_param++;
return (0);
@ -1474,7 +1517,7 @@ int32 sdp_get_media_vcci (void *sdp_ptr, u16 level)
(mca_p->port_format != SDP_PORT_VCCI_CID)) {
if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
CSFLogError(logTag, "%s VCCI not valid for media line %u",
sdp_p->debug_str, level);
sdp_p->debug_str, (unsigned)level);
}
sdp_p->conf_p->num_invalid_param++;
return (SDP_INVALID_VALUE);
@ -1510,7 +1553,7 @@ int32 sdp_get_media_cid (void *sdp_ptr, u16 level)
(mca_p->port_format != SDP_PORT_NUM_VPI_VCI_CID)) {
if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
CSFLogError(logTag, "%s CID not valid for media line %u",
sdp_p->debug_str, level);
sdp_p->debug_str, (unsigned)level);
}
sdp_p->conf_p->num_invalid_param++;
return (SDP_INVALID_VALUE);
@ -1675,6 +1718,93 @@ u16 sdp_get_media_profile_num_payload_types (void *sdp_ptr, u16 level,
}
}
rtp_ptype sdp_get_known_payload_type(void *sdp_ptr,
u16 level,
u16 payload_type_raw) {
sdp_t *sdp_p = (sdp_t *)sdp_ptr;
sdp_attr_t *attr_p;
sdp_transport_map_t *rtpmap;
uint16_t pack_mode = 0; /*default 0, if remote did not provide any */
const char *encname = NULL;
uint16_t num_a_lines = 0;
int i;
if (sdp_verify_sdp_ptr(sdp_p) == FALSE) {
return (RTP_NONE);
}
/*
* Get number of RTPMAP attributes for the media line
*/
(void) sdp_attr_num_instances(sdp_p, level, 0, SDP_ATTR_RTPMAP,
&num_a_lines);
/*
* Loop through media line RTPMAP attributes.
*/
for (i = 0; i < num_a_lines; i++) {
attr_p = sdp_find_attr(sdp_p, level, 0, SDP_ATTR_RTPMAP, (i + 1));
if (attr_p == NULL) {
if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
CSFLogError(logTag, "%s rtpmap attribute, level %u instance %u "
"not found.",
sdp_p->debug_str,
(unsigned)level,
(unsigned)(i + 1));
}
sdp_p->conf_p->num_invalid_param++;
return (RTP_NONE);
}
rtpmap = &(attr_p->attr.transport_map);
if (rtpmap->payload_num == payload_type_raw) {
encname = rtpmap->encname;
if (encname) {
if (cpr_strcasecmp(encname, SIPSDP_ATTR_ENCNAME_ILBC) == 0) {
return (RTP_ILBC);
}
if (cpr_strcasecmp(encname, SIPSDP_ATTR_ENCNAME_L16_256K) == 0) {
return (RTP_L16);
}
if (cpr_strcasecmp(encname, SIPSDP_ATTR_ENCNAME_ISAC) == 0) {
return (RTP_ISAC);
}
if (cpr_strcasecmp(encname, SIPSDP_ATTR_ENCNAME_OPUS) == 0) {
return (RTP_OPUS);
}
if (cpr_strcasecmp(encname, SIPSDP_ATTR_ENCNAME_PCMU) == 0) {
return (RTP_PCMU);
}
if (cpr_strcasecmp(encname, SIPSDP_ATTR_ENCNAME_PCMA) == 0) {
return (RTP_PCMA);
}
if (cpr_strcasecmp(encname, SIPSDP_ATTR_ENCNAME_G722) == 0) {
return (RTP_G722);
}
if (cpr_strcasecmp(encname, SIPSDP_ATTR_ENCNAME_H264) == 0) {
int fmtp_inst = sdp_find_fmtp_inst(sdp_p, level, rtpmap->payload_num);
if (fmtp_inst < 0) {
return (RTP_H264_P0);
} else {
sdp_attr_get_fmtp_pack_mode(sdp_p, level, 0, (uint16_t) fmtp_inst, &pack_mode);
if (pack_mode == SDP_DEFAULT_PACKETIZATION_MODE_VALUE) {
return (RTP_H264_P0);
} else {
return (RTP_H264_P1);
}
}
}
if (cpr_strcasecmp(encname, SIPSDP_ATTR_ENCNAME_VP8) == 0) {
return (RTP_VP8);
}
}
}
}
return (RTP_NONE);
}
/* Function: sdp_get_media_payload_type
* Description: Returns the payload type of the specified payload for the m=
* media token line. If the media line or payload number is
@ -1693,12 +1823,7 @@ u32 sdp_get_media_payload_type (void *sdp_ptr, u16 level, u16 payload_num,
{
sdp_t *sdp_p = (sdp_t *)sdp_ptr;
sdp_mca_t *mca_p;
uint16_t num_a_lines = 0;
int i;
uint16_t ptype;
uint16_t pack_mode = 0; /*default 0, if remote did not provide any */
const char *encname = NULL;
rtp_ptype ptype;
if (sdp_verify_sdp_ptr(sdp_p) == FALSE) {
return (0);
}
@ -1715,54 +1840,14 @@ u32 sdp_get_media_payload_type (void *sdp_ptr, u16 level, u16 payload_num,
*indicator = mca_p->payload_indicator[payload_num-1];
if ((mca_p->payload_type[payload_num-1] >= SDP_MIN_DYNAMIC_PAYLOAD) &&
(mca_p->payload_type[payload_num-1] <= SDP_MAX_DYNAMIC_PAYLOAD)) {
/*
* Get number of RTPMAP attributes for the AUDIO line
*/
(void) sdp_attr_num_instances(sdp_p, level, 0, SDP_ATTR_RTPMAP,
&num_a_lines);
/*
* Loop through AUDIO media line RTPMAP attributes.
* NET dynamic payload type will be returned.
*/
for (i = 0; i < num_a_lines; i++) {
ptype = sdp_attr_get_rtpmap_payload_type(sdp_p, level, 0,
(uint16_t) (i + 1));
if (ptype == mca_p->payload_type[payload_num-1] ) {
encname = sdp_attr_get_rtpmap_encname(sdp_p, level, 0,
(uint16_t) (i + 1));
if (encname) {
if (cpr_strcasecmp(encname, SIPSDP_ATTR_ENCNAME_ILBC) == 0) {
return (SET_PAYLOAD_TYPE_WITH_DYNAMIC(ptype, RTP_ILBC));
}
if (cpr_strcasecmp(encname, SIPSDP_ATTR_ENCNAME_L16_256K) == 0) {
return (SET_PAYLOAD_TYPE_WITH_DYNAMIC(ptype, RTP_L16));
}
if (cpr_strcasecmp(encname, SIPSDP_ATTR_ENCNAME_ISAC) == 0) {
return (SET_PAYLOAD_TYPE_WITH_DYNAMIC(ptype, RTP_ISAC));
}
if (cpr_strcasecmp(encname, SIPSDP_ATTR_ENCNAME_OPUS) == 0) {
return (SET_PAYLOAD_TYPE_WITH_DYNAMIC(ptype, RTP_OPUS));
}
if (cpr_strcasecmp(encname, SIPSDP_ATTR_ENCNAME_H264) == 0) {
int fmtp_inst = sdp_find_fmtp_inst(sdp_p, level,
ptype = sdp_get_known_payload_type(sdp_ptr,
level,
mca_p->payload_type[payload_num-1]);
if (fmtp_inst < 0) {
return (SET_PAYLOAD_TYPE_WITH_DYNAMIC(ptype, RTP_H264_P0));
} else {
sdp_attr_get_fmtp_pack_mode(sdp_p, level, 0, (uint16_t) fmtp_inst, &pack_mode);
if (pack_mode == SDP_DEFAULT_PACKETIZATION_MODE_VALUE) {
return (SET_PAYLOAD_TYPE_WITH_DYNAMIC(ptype, RTP_H264_P0));
} else {
return (SET_PAYLOAD_TYPE_WITH_DYNAMIC(ptype, RTP_H264_P1));
}
}
}
if (cpr_strcasecmp(encname, SIPSDP_ATTR_ENCNAME_VP8) == 0) {
return (SET_PAYLOAD_TYPE_WITH_DYNAMIC(ptype, RTP_VP8));
}
}
}
if (ptype != RTP_NONE) {
return (SET_PAYLOAD_TYPE_WITH_DYNAMIC(
mca_p->payload_type[payload_num-1], ptype));
}
}
return (mca_p->payload_type[payload_num-1]);
}
@ -1832,14 +1917,14 @@ sdp_result_e sdp_insert_media_line (void *sdp_ptr, u16 level)
if ((level < 1) || (level > (sdp_p->mca_count+1))) {
if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
CSFLogError(logTag, "%s Invalid media line (%u) to insert, max is "
"(%u).", sdp_p->debug_str, level, sdp_p->mca_count);
"(%u).", sdp_p->debug_str, (unsigned)level, (unsigned)sdp_p->mca_count);
}
sdp_p->conf_p->num_invalid_param++;
return (SDP_INVALID_PARAMETER);
}
/* Allocate resource for new media stream. */
new_mca_p = sdp_alloc_mca();
new_mca_p = sdp_alloc_mca(0);
if (new_mca_p == NULL) {
sdp_p->conf_p->num_no_resource++;
return (SDP_NO_RESOURCE);
@ -2264,7 +2349,7 @@ sdp_result_e sdp_add_media_profile (void *sdp_ptr, u16 level,
if (mca_p->media_profiles_p->num_profiles >= SDP_MAX_PROFILES) {
if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
CSFLogError(logTag, "%s Max number of media profiles already specified"
" for media level %u", sdp_p->debug_str, level);
" for media level %u", sdp_p->debug_str, (unsigned)level);
}
sdp_p->conf_p->num_invalid_param++;
return (SDP_INVALID_PARAMETER);
@ -2307,7 +2392,7 @@ sdp_result_e sdp_add_media_payload_type (void *sdp_ptr, u16 level,
if (mca_p->num_payloads == SDP_MAX_PAYLOAD_TYPES) {
if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
CSFLogError(logTag, "%s Max number of payload types already defined "
"for media line %u", sdp_p->debug_str, level);
"for media line %u", sdp_p->debug_str, (unsigned)level);
}
sdp_p->conf_p->num_invalid_param++;
return (SDP_INVALID_PARAMETER);
@ -2352,7 +2437,7 @@ sdp_result_e sdp_add_media_profile_payload_type (void *sdp_ptr, u16 level,
(prof_num > mca_p->media_profiles_p->num_profiles)) {
if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
CSFLogError(logTag, "%s Invalid profile number (%u) for set profile "
" payload type", sdp_p->debug_str, level);
" payload type", sdp_p->debug_str, (unsigned)level);
}
sdp_p->conf_p->num_invalid_param++;
return (SDP_INVALID_PARAMETER);
@ -2363,7 +2448,7 @@ sdp_result_e sdp_add_media_profile_payload_type (void *sdp_ptr, u16 level,
if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
CSFLogError(logTag, "%s Max number of profile payload types already "
"defined profile %u on media line %u",
sdp_p->debug_str, prof_num, level);
sdp_p->debug_str, (unsigned)prof_num, (unsigned)level);
}
sdp_p->conf_p->num_invalid_param++;
return (SDP_INVALID_PARAMETER);
@ -2464,7 +2549,7 @@ sdp_result_e sdp_copy_all_bw_lines (void *src_sdp_ptr, void *dst_sdp_ptr,
if (mca_p == NULL) {
if (src_sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
CSFLogError(logTag, "%s Invalid src media level (%u) for copy all "
"attrs ", src_sdp_p->debug_str, src_level);
"attrs ", src_sdp_p->debug_str, (unsigned)src_level);
}
return (SDP_INVALID_PARAMETER);
}
@ -2479,7 +2564,7 @@ sdp_result_e sdp_copy_all_bw_lines (void *src_sdp_ptr, void *dst_sdp_ptr,
if (mca_p == NULL) {
if (src_sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
CSFLogError(logTag, "%s Invalid dst media level (%u) for copy all "
"attrs ", src_sdp_p->debug_str, dst_level);
"attrs ", src_sdp_p->debug_str, (unsigned)dst_level);
}
return (SDP_INVALID_PARAMETER);
}
@ -2759,8 +2844,8 @@ sdp_result_e sdp_delete_bw_line (void *sdp_ptr, u16 level, u16 inst_num)
if (bw_data_p == NULL) {
if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
CSFLogError(logTag, "%s bw line instance %d not found.",
sdp_p->debug_str, inst_num);
CSFLogError(logTag, "%s bw line instance %u not found.",
sdp_p->debug_str, (unsigned)inst_num);
}
sdp_p->conf_p->num_invalid_param++;
return (SDP_INVALID_PARAMETER);
@ -2817,7 +2902,7 @@ sdp_result_e sdp_set_bw (void *sdp_ptr, u16 level, u16 inst_num,
if (bw_data_p == NULL) {
if (sdp_p->debug_flag[SDP_DEBUG_ERRORS]) {
CSFLogError(logTag, "%s The %u instance of a b= line was not found at level %u.",
sdp_p->debug_str, inst_num, level);
sdp_p->debug_str, (unsigned)inst_num, (unsigned)level);
}
sdp_p->conf_p->num_invalid_param++;
return (SDP_INVALID_PARAMETER);

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -5,6 +5,7 @@
#include "sdp_os_defs.h"
#include "sdp.h"
#include "sdp_private.h"
#include "CSFLog.h"
static const char* logTag = "sdp_config";
@ -41,7 +42,7 @@ tinybool sdp_verify_conf_ptr (sdp_conf_options_t *conf_p)
* Parameters: None.
* Returns: A handle for the configuration as a void ptr.
*/
void *sdp_init_config ()
sdp_conf_options_t *sdp_init_config ()
{
int i;
sdp_conf_options_t *conf_p;
@ -101,12 +102,22 @@ void *sdp_init_config ()
conf_p->num_invalid_param = 0;
conf_p->num_no_resource = 0;
/* Parse error handler stuff */
conf_p->error_handler = NULL;
conf_p->error_handler_context = NULL;
CSFLogInfo(logTag, "SDP: Initialized config pointer: %p (magic=0x%X)",
conf_p, conf_p ? conf_p->magic_num : 0);
return (conf_p);
}
void sdp_free_config(sdp_conf_options_t* config_p) {
if (config_p) {
SDP_FREE(config_p);
}
}
/* Function: void sdp_appl_debug(void *config_p, sdp_debug_e debug_type,
* tinybool my_bool);
* Description: Define the default type of debug for the application.
@ -304,3 +315,13 @@ void sdp_allow_choose (void *config_p, sdp_choose_param_e param, tinybool choose
conf_p->allow_choose[param] = choose_allowed;
}
}
void sdp_config_set_error_handler(void *config_p,
sdp_parse_error_handler handler,
void *context)
{
sdp_conf_options_t *conf_p = (sdp_conf_options_t *)config_p;
conf_p->error_handler = handler;
conf_p->error_handler_context = context;
}

View File

@ -5,7 +5,7 @@
#include "sdp_os_defs.h"
#include "sdp.h"
#include "sdp_private.h"
#include "vcm.h"
#include "CSFLog.h"
static const char* logTag = "sdp_main";
@ -137,7 +137,7 @@ const sdp_attrarray_t sdp_attr[SDP_MAX_ATTR_TYPES] =
{"group", sizeof("group"),
sdp_parse_attr_group, sdp_build_attr_group },
{"mid", sizeof("mid"),
sdp_parse_attr_simple_u32, sdp_build_attr_simple_u32 },
sdp_parse_attr_simple_string, sdp_build_attr_simple_string },
{"source-filter", sizeof("source-filter"),
sdp_parse_attr_source_filter, sdp_build_source_filter},
{"rtcp-unicast", sizeof("rtcp-unicast"),
@ -167,9 +167,9 @@ const sdp_attrarray_t sdp_attr[SDP_MAX_ATTR_TYPES] =
{"ice-lite", sizeof("ice-lite"),
sdp_parse_attr_simple_flag, sdp_build_attr_simple_flag},
{"rtcp-mux", sizeof("rtcp-mux"),
sdp_parse_attr_rtcp_mux_attr, sdp_build_attr_rtcp_mux_attr},
sdp_parse_attr_simple_flag, sdp_build_attr_simple_flag},
{"fingerprint", sizeof("fingerprint"),
sdp_parse_attr_fingerprint_attr, sdp_build_attr_simple_string},
sdp_parse_attr_complete_line, sdp_build_attr_simple_string},
{"maxptime", sizeof("maxptime"),
sdp_parse_attr_simple_u32, sdp_build_attr_simple_u32},
{"rtcp-fb", sizeof("rtcp-fb"),
@ -182,7 +182,18 @@ const sdp_attrarray_t sdp_attr[SDP_MAX_ATTR_TYPES] =
sdp_parse_attr_extmap, sdp_build_attr_extmap},
{"identity", sizeof("identity"),
sdp_parse_attr_simple_string, sdp_build_attr_simple_string},
{"msid", sizeof("msid"),
sdp_parse_attr_msid, sdp_build_attr_msid},
{"msid-semantic", sizeof("msid-semantic"),
sdp_parse_attr_simple_string, sdp_build_attr_simple_string},
{"bundle-only", sizeof("bundle-only"),
sdp_parse_attr_simple_flag, sdp_build_attr_simple_flag},
{"end-of-candidates", sizeof("end-of-candidates"),
sdp_parse_attr_simple_flag, sdp_build_attr_simple_flag},
{"ice-options", sizeof("ice-options"),
sdp_parse_attr_complete_line, sdp_build_attr_simple_string},
};
/* Note: These *must* be in the same order as the enum types. */
const sdp_namearray_t sdp_media[SDP_MAX_MEDIA_TYPES] =
{
@ -240,7 +251,12 @@ const sdp_namearray_t sdp_transport[SDP_MAX_TRANSPORT_TYPES] =
{"RTP/SAVP", sizeof("RTP/SAVP")},
{"tcp", sizeof("tcp")},
{"RTP/SAVPF", sizeof("RTP/SAVPF")},
{"DTLS/SCTP", sizeof("DTLS/SCTP")}
{"DTLS/SCTP", sizeof("DTLS/SCTP")},
{"RTP/AVPF", sizeof("RTP/AVPF")},
{"UDP/TLS/RTP/SAVP", sizeof("UDP/TLS/RTP/SAVP")},
{"UDP/TLS/RTP/SAVPF", sizeof("UDP/TLS/RTP/SAVPF")},
{"TCP/TLS/RTP/SAVP", sizeof("TCP/TLS/RTP/SAVP")},
{"TCP/TLS/RTP/SAVPF", sizeof("TCP/TLS/RTP/SAVPF")},
};
/* Note: These *must* be in the same order as the enum type. */
@ -427,7 +443,8 @@ const sdp_namearray_t sdp_group_attr_val[SDP_MAX_GROUP_ATTR_VAL] =
{
{"FID", sizeof("FID")},
{"LS", sizeof("LS")},
{"ANAT", sizeof("ANAT")}
{"ANAT", sizeof("ANAT")},
{"BUNDLE", sizeof("BUNDLE")}
};
const sdp_namearray_t sdp_srtp_context_crypto_suite[SDP_SRTP_MAX_NUM_CRYPTO_SUITES] =
@ -535,7 +552,8 @@ const char* sdp_result_name[SDP_MAX_RC] =
"SDP_NO_RESOURCE",
"SDP_UNRECOGNIZED_TOKEN",
"SDP_NULL_BUF_PTR",
"SDP_POTENTIAL_SDP_OVERFLOW"};
"SDP_POTENTIAL_SDP_OVERFLOW",
"SDP_EMPTY_TOKEN"};
const char *sdp_get_result_name ( sdp_result_e rc )
{
@ -775,7 +793,7 @@ const char *sdp_get_rtcp_unicast_mode_name (sdp_rtcp_unicast_mode_e type)
* Parameters: sdp_p The SDP structure handle.
* Returns: TRUE or FALSE.
*/
inline tinybool sdp_verify_sdp_ptr (sdp_t *sdp_p)
tinybool sdp_verify_sdp_ptr (sdp_t *sdp_p)
{
if ((sdp_p != NULL) && (sdp_p->magic_num == SDP_MAGIC_NUM)) {
return (TRUE);
@ -795,11 +813,10 @@ inline tinybool sdp_verify_sdp_ptr (sdp_t *sdp_p)
* Parameters: config_p The config handle returned by sdp_init_config
* Returns: A handle for a new SDP structure as a void ptr.
*/
sdp_t *sdp_init_description (const char *peerconnection, void *config_p)
sdp_t *sdp_init_description (sdp_conf_options_t *conf_p)
{
int i;
sdp_t *sdp_p;
sdp_conf_options_t *conf_p = (sdp_conf_options_t *)config_p;
if (sdp_verify_conf_ptr(conf_p) == FALSE) {
return (NULL);
@ -810,8 +827,6 @@ sdp_t *sdp_init_description (const char *peerconnection, void *config_p)
return (NULL);
}
sstrncpy(sdp_p->peerconnection, peerconnection, sizeof(sdp_p->peerconnection));
/* Initialize magic number. */
sdp_p->magic_num = SDP_MAGIC_NUM;
@ -914,7 +929,7 @@ sdp_result_e sdp_validate_sdp (sdp_t *sdp_p)
num_media_levels = sdp_get_num_media_lines((void *)sdp_p);
for (i=1; i <= num_media_levels; i++) {
if (sdp_connection_valid((void *)sdp_p, (unsigned short)i) == FALSE) {
sdp_parse_error(sdp_p->peerconnection,
sdp_parse_error(sdp_p,
"%s c= connection line not specified for "
"every media level, validation failed.",
sdp_p->debug_str);
@ -926,7 +941,7 @@ sdp_result_e sdp_validate_sdp (sdp_t *sdp_p)
/* Validate required lines were specified */
if ((sdp_owner_valid((void *)sdp_p) == FALSE) &&
(sdp_p->conf_p->owner_reqd == TRUE)) {
sdp_parse_error(sdp_p->peerconnection,
sdp_parse_error(sdp_p,
"%s o= owner line not specified, validation failed.",
sdp_p->debug_str);
return (SDP_FAILURE);
@ -934,7 +949,7 @@ sdp_result_e sdp_validate_sdp (sdp_t *sdp_p)
if ((sdp_session_name_valid((void *)sdp_p) == FALSE) &&
(sdp_p->conf_p->session_name_reqd == TRUE)) {
sdp_parse_error(sdp_p->peerconnection,
sdp_parse_error(sdp_p,
"%s s= session name line not specified, validation failed.",
sdp_p->debug_str);
return (SDP_FAILURE);
@ -942,7 +957,7 @@ sdp_result_e sdp_validate_sdp (sdp_t *sdp_p)
if ((sdp_timespec_valid((void *)sdp_p) == FALSE) &&
(sdp_p->conf_p->timespec_reqd == TRUE)) {
sdp_parse_error(sdp_p->peerconnection,
sdp_parse_error(sdp_p,
"%s t= timespec line not specified, validation failed.",
sdp_p->debug_str);
return (SDP_FAILURE);
@ -961,12 +976,12 @@ sdp_result_e sdp_validate_sdp (sdp_t *sdp_p)
* if not, what type of error was encountered. The
* information from the parse is stored in the sdp_p structure.
*/
sdp_result_e sdp_parse (sdp_t *sdp_p, char **bufp, u16 len)
sdp_result_e sdp_parse (sdp_t *sdp_p, const char *buf, size_t len)
{
u8 i;
u16 cur_level = SDP_SESSION_LEVEL;
char *ptr;
char *next_ptr = NULL;
const char *ptr;
const char *next_ptr = NULL;
char *line_end;
sdp_token_e last_token = SDP_TOKEN_V;
sdp_result_e result = SDP_SUCCESS;
@ -974,6 +989,7 @@ sdp_result_e sdp_parse (sdp_t *sdp_p, char **bufp, u16 len)
tinybool end_found = FALSE;
tinybool first_line = TRUE;
tinybool unrec_token = FALSE;
const char **bufp = &buf;
if (sdp_verify_sdp_ptr(sdp_p) == FALSE) {
return (SDP_INVALID_SDP_PTR);
@ -995,6 +1011,8 @@ sdp_result_e sdp_parse (sdp_t *sdp_p, char **bufp, u16 len)
sdp_p->cap_valid = FALSE;
sdp_p->last_cap_inst = 0;
sdp_p->parse_line = 0;
/* We want to try to find the end of the SDP description, even if
* we find a parsing error.
*/
@ -1003,6 +1021,7 @@ sdp_result_e sdp_parse (sdp_t *sdp_p, char **bufp, u16 len)
* we don't parse it.
*/
ptr = next_ptr;
sdp_p->parse_line++;
line_end = sdp_findchar(ptr, "\n");
if ((line_end >= (*bufp + len)) ||
(*line_end == '\0')) {
@ -1010,10 +1029,11 @@ sdp_result_e sdp_parse (sdp_t *sdp_p, char **bufp, u16 len)
* is still accept as valid. So encountering this is not treated as
* an error.
*/
sdp_parse_error(sdp_p->peerconnection,
sdp_parse_error(sdp_p,
"%s End of line beyond end of buffer.",
sdp_p->debug_str);
CSFLogError(logTag, "SDP: Invalid SDP, no \\n (len %u): %*s", len, len, *bufp);
CSFLogError(logTag, "SDP: Invalid SDP, no \\n (len %u): %*s",
(unsigned)len, (int)len, *bufp);
end_found = TRUE;
break;
}
@ -1040,7 +1060,7 @@ sdp_result_e sdp_parse (sdp_t *sdp_p, char **bufp, u16 len)
unrec_token = TRUE;
}
if (first_line == TRUE) {
sdp_parse_error(sdp_p->peerconnection,
sdp_parse_error(sdp_p,
"%s Attempt to parse text not recognized as "
"SDP text, parse fails.", sdp_p->debug_str);
/* If we haven't already printed out the line we
@ -1083,7 +1103,7 @@ sdp_result_e sdp_parse (sdp_t *sdp_p, char **bufp, u16 len)
(i != SDP_TOKEN_B) && (i != SDP_TOKEN_K) &&
(i != SDP_TOKEN_A) && (i != SDP_TOKEN_M)) {
sdp_p->conf_p->num_invalid_token_order++;
sdp_parse_error(sdp_p->peerconnection,
sdp_parse_error(sdp_p,
"%s Warning: Invalid token %s found at media level",
sdp_p->debug_str, sdp_token[i].name);
continue;
@ -1094,7 +1114,7 @@ sdp_result_e sdp_parse (sdp_t *sdp_p, char **bufp, u16 len)
if (first_line == TRUE) {
if (i != SDP_TOKEN_V) {
if (sdp_p->conf_p->version_reqd == TRUE) {
sdp_parse_error(sdp_p->peerconnection,
sdp_parse_error(sdp_p,
"%s First line not v=, parse fails",
sdp_p->debug_str);
sdp_p->conf_p->num_invalid_token_order++;
@ -1110,7 +1130,7 @@ sdp_result_e sdp_parse (sdp_t *sdp_p, char **bufp, u16 len)
} else {
if (i < last_token) {
sdp_p->conf_p->num_invalid_token_order++;
sdp_parse_error(sdp_p->peerconnection,
sdp_parse_error(sdp_p,
"%s Warning: Invalid token ordering detected, "
"token %s found after token %s", sdp_p->debug_str,
sdp_token[i].name, sdp_token[last_token].name);
@ -1242,9 +1262,7 @@ sdp_result_e sdp_free_description (sdp_t *sdp_p)
}
/* Free the config structure */
if (sdp_p->conf_p) {
SDP_FREE(sdp_p->conf_p);
}
sdp_free_config(sdp_p->conf_p);
/* Free any timespec structures - should be only one since
* this is all we currently support.
@ -1311,7 +1329,7 @@ sdp_result_e sdp_free_description (sdp_t *sdp_p)
* sdp_parse_error
* Send SDP parsing errors to log and up to peerconnection
*/
void sdp_parse_error(const char *peerconnection, const char *format, ...) {
void sdp_parse_error(sdp_t* sdp, const char *format, ...) {
flex_string fs;
va_list ap;
@ -1321,8 +1339,14 @@ void sdp_parse_error(const char *peerconnection, const char *format, ...) {
flex_string_vsprintf(&fs, format, ap);
va_end(ap);
CSFLogError("SDP Parse", "SDP Parse Error %s, pc %s", fs.buffer, peerconnection);
vcmOnSdpParseError(peerconnection, fs.buffer);
CSFLogError("SDP Parse", "SDP Parse Error %s, line %u", fs.buffer,
sdp->parse_line);
if (sdp->conf_p->error_handler) {
sdp->conf_p->error_handler(sdp->conf_p->error_handler_context,
sdp->parse_line,
fs.buffer);
}
flex_string_free(&fs);
}

View File

@ -5,17 +5,17 @@
#ifndef _SDP_OS_DEFS_H_
#define _SDP_OS_DEFS_H_
#include <stdlib.h>
#include "cpr_types.h"
#include "cpr_stdio.h"
#include "cpr_stdlib.h"
#include "cpr_string.h"
#include "phone_debug.h"
#define SDP_PRINT(format, ...) CSFLogError("sdp" , format , ## __VA_ARGS__ )
#define SDP_MALLOC(x) cpr_calloc(1, (x))
#define SDP_FREE cpr_free
/* Use operating system malloc */
#define SDP_MALLOC(x) calloc(1, (x))
#define SDP_FREE free
typedef uint8_t tinybool;
typedef uint8_t u8;

View File

@ -2,8 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef _SDP_PRIVATE_H_
#define _SDP_PRIVATE_H_
#ifndef _SIPCC_SDP_PRIVATE_H_
#define _SIPCC_SDP_PRIVATE_H_
#include "sdp.h"
@ -49,6 +49,9 @@ extern sdp_mca_t *sdp_find_media_level(sdp_t *sdp_p, u16 level);
extern sdp_bw_data_t* sdp_find_bw_line (void *sdp_ptr, u16 level, u16 inst_num);
/* sdp_attr.c */
extern sdp_result_e
sdp_build_attr_fmtp_params (sdp_t *sdp_p, sdp_fmtp_t *attr_p, flex_string *fs);
extern sdp_result_e sdp_parse_attribute(sdp_t *sdp_p, u16 level,
const char *ptr);
extern sdp_result_e sdp_parse_attr_simple_string(sdp_t *sdp_p,
@ -73,6 +76,10 @@ extern sdp_result_e sdp_parse_attr_sctpmap(sdp_t *sdp_p, sdp_attr_t *attr_p,
const char *ptr);
extern sdp_result_e sdp_build_attr_sctpmap(sdp_t *sdp_p, sdp_attr_t *attr_p,
flex_string *fs);
extern sdp_result_e sdp_parse_attr_msid(sdp_t *sdp_p, sdp_attr_t *attr_p,
const char *ptr);
extern sdp_result_e sdp_build_attr_msid(sdp_t *sdp_p, sdp_attr_t *attr_p,
flex_string *fs);
extern sdp_result_e sdp_parse_attr_direction(sdp_t *sdp_p, sdp_attr_t *attr_p,
const char *ptr);
extern sdp_result_e sdp_build_attr_direction(sdp_t *sdp_p, sdp_attr_t *attr_p,
@ -217,11 +224,7 @@ extern sdp_result_e sdp_build_attr_simple_flag (
extern sdp_result_e sdp_parse_attr_simple_flag (
sdp_t *sdp_p, sdp_attr_t *attr_p, const char *ptr);
extern sdp_result_e sdp_build_attr_rtcp_mux_attr (
sdp_t *sdp_p, sdp_attr_t *attr_p, flex_string *fs);
extern sdp_result_e sdp_parse_attr_rtcp_mux_attr (
sdp_t *sdp_p, sdp_attr_t *attr_p, const char *ptr);
extern sdp_result_e sdp_parse_attr_fingerprint_attr (
extern sdp_result_e sdp_parse_attr_complete_line (
sdp_t *sdp_p, sdp_attr_t *attr_p, const char *ptr);
/* sdp_attr_access.c */
@ -256,7 +259,6 @@ extern const char *sdp_get_silencesupp_pref_name(sdp_silencesupp_pref_e pref);
extern const char *sdp_get_silencesupp_siduse_name(sdp_silencesupp_siduse_e
siduse);
extern const char *sdp_get_bw_modifier_name(sdp_bw_modifier_e bw_modifier);
extern const char *sdp_get_group_attr_name(sdp_group_attr_e group_attr);
extern const char *sdp_get_src_filter_mode_name(sdp_src_filter_mode_e type);
extern const char *sdp_get_rtcp_unicast_mode_name(sdp_rtcp_unicast_mode_e type);
@ -323,7 +325,7 @@ sdp_build_attr_sdescriptions(sdp_t *sdp_p, sdp_attr_t *attr_p,
/* sdp_utils.c */
extern sdp_mca_t *sdp_alloc_mca(void);
extern sdp_mca_t *sdp_alloc_mca(u32 line);
extern tinybool sdp_validate_maxprate(const char *string_parm);
extern char *sdp_findchar(const char *ptr, char *char_list);
extern const char *sdp_getnextstrtok(const char *str, char *tokenstr, unsigned tokenstr_len,

View File

@ -6,6 +6,7 @@
#include "sdp.h"
#include "sdp_private.h"
#include "CSFLog.h"
/******************************************************************/
/* Required Platform Routines */

View File

@ -7,9 +7,7 @@
#include "sdp_os_defs.h"
#include "sdp.h"
#include "sdp_private.h"
#include "configmgr.h"
#include "prot_configmgr.h"
#include "ccapi.h"
#include "CSFLog.h"
#include "prprf.h"
@ -24,16 +22,16 @@ sdp_result_e sdp_parse_version (sdp_t *sdp_p, u16 level, const char *ptr)
sdp_p->version = (u16)sdp_getnextnumtok(ptr, &ptr, " \t", &result);
if ((result != SDP_SUCCESS) || (sdp_p->version != SDP_CURRENT_VERSION)) {
sdp_parse_error(sdp_p->peerconnection,
"%s Invalid version (%lu) found, parse failed.",
sdp_p->debug_str, sdp_p->version);
sdp_parse_error(sdp_p,
"%s Invalid version (%u) found, parse failed.",
sdp_p->debug_str, (unsigned)sdp_p->version);
sdp_p->conf_p->num_invalid_param++;
return (SDP_INVALID_PARAMETER);
}
if (sdp_p->debug_flag[SDP_DEBUG_TRACE]) {
SDP_PRINT("%s Parse version line successful, version %u",
sdp_p->debug_str, (u16)sdp_p->version);
sdp_p->debug_str, (unsigned)sdp_p->version);
}
return (SDP_SUCCESS);
}
@ -52,7 +50,7 @@ sdp_result_e sdp_build_version (sdp_t *sdp_p, u16 level, flex_string *fs)
}
}
flex_string_sprintf(fs, "v=%u\r\n", (u16)sdp_p->version);
flex_string_sprintf(fs, "v=%u\r\n", (unsigned)sdp_p->version);
if (sdp_p->debug_flag[SDP_DEBUG_TRACE]) {
SDP_PRINT("%s Built v= version line", sdp_p->debug_str);
@ -82,7 +80,6 @@ static sdp_result_e sdp_verify_unsigned(const char *ptr, uint64_t max_value)
sdp_result_e sdp_parse_owner (sdp_t *sdp_p, u16 level, const char *ptr)
{
int i;
char *tmpptr;
sdp_result_e result;
char tmp[SDP_MAX_STRING_LEN];
/* The spec says this:
@ -93,11 +90,13 @@ sdp_result_e sdp_parse_owner (sdp_t *sdp_p, u16 level, const char *ptr)
(2**62)-1, to avoid rollovers.
*/
const uint64_t max_value_sessid = ((((uint64_t) 1) << 63) - 1);
const uint64_t max_value_version = ((((uint64_t) 1) << 62) - 2);
/* Do not check that this is 2^62 - 1; that's just the limit on
* the initial version, not every version number. */
const uint64_t max_value_version = ((((uint64_t) 1) << 63) - 1);
if (sdp_p->owner_name[0] != '\0') {
sdp_p->conf_p->num_invalid_token_order++;
sdp_parse_error(sdp_p->peerconnection,
sdp_parse_error(sdp_p,
"%s Warning: More than one o= line specified.",
sdp_p->debug_str);
}
@ -105,7 +104,7 @@ sdp_result_e sdp_parse_owner (sdp_t *sdp_p, u16 level, const char *ptr)
/* Find the owner name. */
ptr = sdp_getnextstrtok(ptr, sdp_p->owner_name, sizeof(sdp_p->owner_name), " \t", &result);
if (result != SDP_SUCCESS) {
sdp_parse_error(sdp_p->peerconnection,
sdp_parse_error(sdp_p,
"%s No owner name specified for o=.",
sdp_p->debug_str);
sdp_p->conf_p->num_invalid_param++;
@ -123,7 +122,7 @@ sdp_result_e sdp_parse_owner (sdp_t *sdp_p, u16 level, const char *ptr)
result = sdp_verify_unsigned(sdp_p->owner_sessid, max_value_sessid);
}
if (result != SDP_SUCCESS) {
sdp_parse_error(sdp_p->peerconnection,
sdp_parse_error(sdp_p,
"%s Invalid owner session id specified for o=.",
sdp_p->debug_str);
sdp_p->conf_p->num_invalid_param++;
@ -139,7 +138,7 @@ sdp_result_e sdp_parse_owner (sdp_t *sdp_p, u16 level, const char *ptr)
result = sdp_verify_unsigned(sdp_p->owner_version, max_value_version);
}
if (result != SDP_SUCCESS) {
sdp_parse_error(sdp_p->peerconnection,
sdp_parse_error(sdp_p,
"%s Invalid owner version specified for o=.",
sdp_p->debug_str);
sdp_p->conf_p->num_invalid_param++;
@ -149,7 +148,7 @@ sdp_result_e sdp_parse_owner (sdp_t *sdp_p, u16 level, const char *ptr)
/* Find the owner network type. */
ptr = sdp_getnextstrtok(ptr, tmp, sizeof(tmp), " \t", &result);
if (result != SDP_SUCCESS) {
sdp_parse_error(sdp_p->peerconnection,
sdp_parse_error(sdp_p,
"%s No owner network type specified for o=.",
sdp_p->debug_str);
sdp_p->conf_p->num_invalid_param++;
@ -165,7 +164,7 @@ sdp_result_e sdp_parse_owner (sdp_t *sdp_p, u16 level, const char *ptr)
}
}
if (sdp_p->owner_network_type == SDP_NT_UNSUPPORTED) {
sdp_parse_error(sdp_p->peerconnection,
sdp_parse_error(sdp_p,
"%s Owner network type unsupported (%s)",
sdp_p->debug_str, tmp);
sdp_p->conf_p->num_invalid_param++;
@ -175,7 +174,7 @@ sdp_result_e sdp_parse_owner (sdp_t *sdp_p, u16 level, const char *ptr)
/* Find the owner address type. */
ptr = sdp_getnextstrtok(ptr, tmp, sizeof(tmp), " \t", &result);
if (result != SDP_SUCCESS) {
sdp_parse_error(sdp_p->peerconnection,
sdp_parse_error(sdp_p,
"%s No owner address type specified for o=.",
sdp_p->debug_str);
sdp_p->conf_p->num_invalid_param++;
@ -192,7 +191,7 @@ sdp_result_e sdp_parse_owner (sdp_t *sdp_p, u16 level, const char *ptr)
}
if ((sdp_p->owner_addr_type == SDP_AT_UNSUPPORTED) &&
(sdp_p->owner_network_type != SDP_NT_ATM)) {
sdp_parse_error(sdp_p->peerconnection,
sdp_parse_error(sdp_p,
"%s Owner address type unsupported (%s)",
sdp_p->debug_str, tmp);
sdp_p->conf_p->num_invalid_param++;
@ -202,7 +201,7 @@ sdp_result_e sdp_parse_owner (sdp_t *sdp_p, u16 level, const char *ptr)
/* Find the owner address. */
ptr = sdp_getnextstrtok(ptr, sdp_p->owner_addr, sizeof(sdp_p->owner_addr), " \t", &result);
if (result != SDP_SUCCESS) {
sdp_parse_error(sdp_p->peerconnection,
sdp_parse_error(sdp_p,
"%s No owner address specified.", sdp_p->debug_str);
sdp_p->conf_p->num_invalid_param++;
return (SDP_INVALID_PARAMETER);
@ -267,14 +266,14 @@ sdp_result_e sdp_parse_sessname (sdp_t *sdp_p, u16 level, const char *ptr)
if (sdp_p->sessname[0] != '\0') {
sdp_p->conf_p->num_invalid_token_order++;
sdp_parse_error(sdp_p->peerconnection,
sdp_parse_error(sdp_p,
"%s Warning: More than one s= line specified.",
sdp_p->debug_str);
}
endptr = sdp_findchar(ptr, "\r\n");
if (ptr == endptr) {
sdp_parse_error(sdp_p->peerconnection,
sdp_parse_error(sdp_p,
"%s Warning: No session name specified.",
sdp_p->debug_str);
}
@ -322,7 +321,7 @@ sdp_result_e sdp_parse_sessinfo (sdp_t *sdp_p, u16 level, const char *ptr)
if (level == SDP_SESSION_LEVEL) {
if (sdp_p->sessinfo_found == TRUE) {
sdp_p->conf_p->num_invalid_token_order++;
sdp_parse_error(sdp_p->peerconnection,
sdp_parse_error(sdp_p,
"%s Warning: More than one i= line specified.",
sdp_p->debug_str);
}
@ -334,16 +333,16 @@ sdp_result_e sdp_parse_sessinfo (sdp_t *sdp_p, u16 level, const char *ptr)
}
if (mca_p->sessinfo_found == TRUE) {
sdp_p->conf_p->num_invalid_token_order++;
sdp_parse_error(sdp_p->peerconnection,
sdp_parse_error(sdp_p,
"%s Warning: More than one i= line specified"
" for media line %d.", sdp_p->debug_str, level);
" for media line %u.", sdp_p->debug_str, (unsigned)level);
}
mca_p->sessinfo_found = TRUE;
}
endptr = sdp_findchar(ptr, "\n");
if (ptr == endptr) {
sdp_parse_error(sdp_p->peerconnection,
sdp_parse_error(sdp_p,
"%s Warning: No session info specified.",
sdp_p->debug_str);
}
@ -366,7 +365,7 @@ sdp_result_e sdp_parse_uri (sdp_t *sdp_p, u16 level, const char *ptr)
if (sdp_p->uri_found == TRUE) {
sdp_p->conf_p->num_invalid_token_order++;
sdp_parse_error(sdp_p->peerconnection,
sdp_parse_error(sdp_p,
"%s Warning: More than one u= line specified.",
sdp_p->debug_str);
}
@ -374,7 +373,7 @@ sdp_result_e sdp_parse_uri (sdp_t *sdp_p, u16 level, const char *ptr)
endptr = sdp_findchar(ptr, "\n");
if (ptr == endptr) {
sdp_parse_error(sdp_p->peerconnection,
sdp_parse_error(sdp_p,
"%s Warning: No URI info specified.", sdp_p->debug_str);
}
@ -396,7 +395,7 @@ sdp_result_e sdp_parse_email (sdp_t *sdp_p, u16 level, const char *ptr)
endptr = sdp_findchar(ptr, "\n");
if (ptr == endptr) {
sdp_parse_error(sdp_p->peerconnection,
sdp_parse_error(sdp_p,
"%s Warning: No email info specified.", sdp_p->debug_str);
}
@ -418,7 +417,7 @@ sdp_result_e sdp_parse_phonenum (sdp_t *sdp_p, u16 level, const char *ptr)
endptr = sdp_findchar(ptr, "\n");
if (ptr == endptr) {
sdp_parse_error(sdp_p->peerconnection,
sdp_parse_error(sdp_p,
"%s Warning: No phone number info specified.",
sdp_p->debug_str);
}
@ -464,7 +463,7 @@ sdp_result_e sdp_parse_connection (sdp_t *sdp_p, u16 level, const char *ptr)
*/
if (conn_p->nettype != SDP_NT_INVALID) {
sdp_p->conf_p->num_invalid_token_order++;
sdp_parse_error(sdp_p->peerconnection,
sdp_parse_error(sdp_p,
"%s c= line specified twice at same level, "
"parse failed.", sdp_p->debug_str);
return (SDP_INVALID_TOKEN_ORDERING);
@ -473,7 +472,7 @@ sdp_result_e sdp_parse_connection (sdp_t *sdp_p, u16 level, const char *ptr)
/* Find the connection network type. */
ptr = sdp_getnextstrtok(ptr, tmp, sizeof(tmp), " \t", &result);
if (result != SDP_SUCCESS) {
sdp_parse_error(sdp_p->peerconnection,
sdp_parse_error(sdp_p,
"%s No connection network type specified for c=.",
sdp_p->debug_str);
sdp_p->conf_p->num_invalid_param++;
@ -489,7 +488,7 @@ sdp_result_e sdp_parse_connection (sdp_t *sdp_p, u16 level, const char *ptr)
}
}
if (conn_p->nettype == SDP_NT_UNSUPPORTED) {
sdp_parse_error(sdp_p->peerconnection,
sdp_parse_error(sdp_p,
"%s Warning: Connection network type unsupported "
"(%s) for c=.", sdp_p->debug_str, tmp);
}
@ -505,7 +504,7 @@ sdp_result_e sdp_parse_connection (sdp_t *sdp_p, u16 level, const char *ptr)
}
return (SDP_SUCCESS);
} else {
sdp_parse_error(sdp_p->peerconnection,
sdp_parse_error(sdp_p,
"%s No connection address type specified for "
"c=.", sdp_p->debug_str);
sdp_p->conf_p->num_invalid_param++;
@ -522,7 +521,7 @@ sdp_result_e sdp_parse_connection (sdp_t *sdp_p, u16 level, const char *ptr)
}
}
if (conn_p->addrtype == SDP_AT_UNSUPPORTED) {
sdp_parse_error(sdp_p->peerconnection,
sdp_parse_error(sdp_p,
"%s Warning: Connection address type unsupported "
"(%s) for c=.", sdp_p->debug_str, tmp);
}
@ -530,7 +529,7 @@ sdp_result_e sdp_parse_connection (sdp_t *sdp_p, u16 level, const char *ptr)
/* Find the connection address. */
ptr = sdp_getnextstrtok(ptr, conn_p->conn_addr, sizeof(conn_p->conn_addr), " \t", &result);
if (result != SDP_SUCCESS) {
sdp_parse_error(sdp_p->peerconnection,
sdp_parse_error(sdp_p,
"%s No connection address specified for c=.",
sdp_p->debug_str);
sdp_p->conf_p->num_invalid_param++;
@ -545,11 +544,12 @@ sdp_result_e sdp_parse_connection (sdp_t *sdp_p, u16 level, const char *ptr)
/* multicast addr check */
sstrncpy (mcast_str, conn_p->conn_addr, MCAST_STRING_LEN);
if (conn_p->addrtype == SDP_AT_IP4) {
errno = 0;
strtoul_result = strtoul(mcast_str, &strtoul_end, 10);
if (errno || mcast_str == strtoul_end || strtoul_result > 255) {
sdp_parse_error(sdp_p->peerconnection,
sdp_parse_error(sdp_p,
"%s Error parsing address %s for mcast.",
sdp_p->debug_str, mcast_str);
sdp_p->conf_p->num_invalid_param++;
@ -564,17 +564,20 @@ sdp_result_e sdp_parse_connection (sdp_t *sdp_p, u16 level, const char *ptr)
sdp_p->debug_str, mcast_bits);
conn_p->is_multicast = TRUE;
}
}
if (conn_p->addrtype != SDP_AT_EPN) {
slash_ptr = sdp_findchar(conn_p->conn_addr, "/");
if (slash_ptr[0] != '\0') {
if (conn_p->is_multicast) {
SDP_PRINT("%s A multicast address with slash %s",
/* this used to rely on the above busted multicast check */
SDP_PRINT("%s An address with slash %s",
sdp_p->debug_str, conn_p->conn_addr);
conn_p->conn_addr[slash_ptr - conn_p->conn_addr] = '\0';
slash_ptr++;
slash_ptr = sdp_getnextstrtok(slash_ptr, tmp, sizeof(tmp), "/", &result);
slash_ptr = sdp_getnextstrtok(slash_ptr, tmp, sizeof(tmp),
"/", &result);
if (result != SDP_SUCCESS) {
sdp_parse_error(sdp_p->peerconnection,
sdp_parse_error(sdp_p,
"%s No ttl value specified for this multicast addr with a slash",
sdp_p->debug_str);
sdp_p->conf_p->num_invalid_param++;
@ -585,7 +588,7 @@ sdp_result_e sdp_parse_connection (sdp_t *sdp_p, u16 level, const char *ptr)
strtoul_result = strtoul(tmp, &strtoul_end, 10);
if (errno || tmp == strtoul_end || conn_p->ttl > SDP_MAX_TTL_VALUE) {
sdp_parse_error(sdp_p->peerconnection,
sdp_parse_error(sdp_p,
"%s Invalid TTL: Value must be in the range 0-255 ",
sdp_p->debug_str);
sdp_p->conf_p->num_invalid_param++;
@ -609,7 +612,7 @@ sdp_result_e sdp_parse_connection (sdp_t *sdp_p, u16 level, const char *ptr)
strtoul_result = strtoul(slash_ptr, &strtoul_end, 10);
if (errno || slash_ptr == strtoul_end || strtoul_result == 0) {
sdp_parse_error(sdp_p->peerconnection,
sdp_parse_error(sdp_p,
"%s Invalid Num of addresses: Value must be > 0 ",
sdp_p->debug_str);
sdp_p->conf_p->num_invalid_param++;
@ -618,30 +621,24 @@ sdp_result_e sdp_parse_connection (sdp_t *sdp_p, u16 level, const char *ptr)
conn_p->num_of_addresses = (int) strtoul_result;
}
} else {
sdp_p->conf_p->num_invalid_param++;
SDP_PRINT("%s Only multicast addresses allowed with slashes",
sdp_p->debug_str);
return (SDP_INVALID_PARAMETER);
}
}
}
/* See if the address is the choose param and if it's allowed. */
if ((sdp_p->conf_p->allow_choose[SDP_CHOOSE_CONN_ADDR] == FALSE) &&
(strcmp(conn_p->conn_addr, "$") == 0)) {
sdp_parse_error(sdp_p->peerconnection,
sdp_parse_error(sdp_p,
"%s Warning: Choose parameter for connection "
"address specified but not allowed.", sdp_p->debug_str);
}
if (sdp_p->debug_flag[SDP_DEBUG_TRACE]) {
SDP_PRINT("%s Parse connection: network %s, address type %s, "
"address %s ttl= %d num of addresses = %d",
"address %s ttl= %u num of addresses = %u",
sdp_p->debug_str,
sdp_get_network_name(conn_p->nettype),
sdp_get_address_name(conn_p->addrtype),
conn_p->conn_addr, conn_p->ttl, conn_p->num_of_addresses);
conn_p->conn_addr, (unsigned)conn_p->ttl, (unsigned)conn_p->num_of_addresses);
}
return (SDP_SUCCESS);
}
@ -678,16 +675,18 @@ sdp_result_e sdp_build_connection (sdp_t *sdp_p, u16 level, flex_string *fs)
if (conn_p->is_multicast) {
if (conn_p->num_of_addresses > 1) {
flex_string_sprintf(fs, "c=%s %s %s/%d/%d\r\n",
flex_string_sprintf(fs, "c=%s %s %s/%u/%u\r\n",
sdp_get_network_name(conn_p->nettype),
sdp_get_address_name(conn_p->addrtype),
conn_p->conn_addr, conn_p->ttl,
conn_p->num_of_addresses);
conn_p->conn_addr,
(unsigned)conn_p->ttl,
(unsigned)conn_p->num_of_addresses);
} else {
flex_string_sprintf(fs, "c=%s %s %s/%d\r\n",
flex_string_sprintf(fs, "c=%s %s %s/%u\r\n",
sdp_get_network_name(conn_p->nettype),
sdp_get_address_name(conn_p->addrtype),
conn_p->conn_addr, conn_p->ttl);
conn_p->conn_addr,
(unsigned)conn_p->ttl);
}
} else {
@ -744,7 +743,7 @@ sdp_result_e sdp_parse_bandwidth (sdp_t *sdp_p, u16 level, const char *ptr)
/* Find the bw type (AS, CT or TIAS) */
ptr = sdp_getnextstrtok(ptr, tmp, sizeof(tmp), ":", &result);
if (result != SDP_SUCCESS) {
sdp_parse_error(sdp_p->peerconnection,
sdp_parse_error(sdp_p,
"%s No bandwidth type specified for b= ",
sdp_p->debug_str);
sdp_p->conf_p->num_invalid_param++;
@ -759,7 +758,7 @@ sdp_result_e sdp_parse_bandwidth (sdp_t *sdp_p, u16 level, const char *ptr)
}
if (bw_modifier == SDP_BW_MODIFIER_UNSUPPORTED) {
sdp_parse_error(sdp_p->peerconnection,
sdp_parse_error(sdp_p,
"%s Error: BW Modifier type unsupported (%s).",
sdp_p->debug_str, tmp);
sdp_p->conf_p->num_invalid_param++;
@ -774,7 +773,7 @@ sdp_result_e sdp_parse_bandwidth (sdp_t *sdp_p, u16 level, const char *ptr)
ptr++;
bw_val = sdp_getnextnumtok(ptr, &ptr, " \t", &result);
if ((result != SDP_SUCCESS)) {
sdp_parse_error(sdp_p->peerconnection,
sdp_parse_error(sdp_p,
"%s Error: No BW Value specified ",
sdp_p->debug_str);
sdp_p->conf_p->num_invalid_param++;
@ -882,7 +881,7 @@ sdp_result_e sdp_parse_timespec (sdp_t *sdp_p, u16 level, const char *ptr)
(const char **)&tmpptr, " \t", &result);
}
if (result != SDP_SUCCESS) {
sdp_parse_error(sdp_p->peerconnection,
sdp_parse_error(sdp_p,
"%s Invalid timespec start time specified.",
sdp_p->debug_str);
sdp_p->conf_p->num_invalid_param++;
@ -899,7 +898,7 @@ sdp_result_e sdp_parse_timespec (sdp_t *sdp_p, u16 level, const char *ptr)
(const char **)&tmpptr, " \t", &result);
}
if (result != SDP_SUCCESS) {
sdp_parse_error(sdp_p->peerconnection,
sdp_parse_error(sdp_p,
"%s Invalid timespec stop time specified.",
sdp_p->debug_str);
sdp_p->conf_p->num_invalid_param++;
@ -956,7 +955,7 @@ sdp_result_e sdp_parse_repeat_time (sdp_t *sdp_p, u16 level, const char *ptr)
endptr = sdp_findchar(ptr, "\n");
if (ptr == endptr) {
sdp_parse_error(sdp_p->peerconnection,
sdp_parse_error(sdp_p,
"%s Warning: No repeat time parameters "
"specified.", sdp_p->debug_str);
}
@ -979,7 +978,7 @@ sdp_result_e sdp_parse_timezone_adj (sdp_t *sdp_p, u16 level, const char *ptr)
endptr = sdp_findchar(ptr, "\n");
if (ptr == endptr) {
sdp_parse_error(sdp_p->peerconnection,
sdp_parse_error(sdp_p,
"%s Warning: No timezone parameters specified.",
sdp_p->debug_str);
}
@ -1018,7 +1017,7 @@ sdp_result_e sdp_parse_encryption (sdp_t *sdp_p, u16 level, const char *ptr)
/* Find the encryption type. */
ptr = sdp_getnextstrtok(ptr, tmp, sizeof(tmp), ":", &result);
if (result != SDP_SUCCESS) {
sdp_parse_error(sdp_p->peerconnection,
sdp_parse_error(sdp_p,
"%s No encryption type specified for k=.",
sdp_p->debug_str);
sdp_p->conf_p->num_invalid_param++;
@ -1033,7 +1032,7 @@ sdp_result_e sdp_parse_encryption (sdp_t *sdp_p, u16 level, const char *ptr)
}
}
if (encrypt_p->encrypt_type == SDP_ENCRYPT_UNSUPPORTED) {
sdp_parse_error(sdp_p->peerconnection,
sdp_parse_error(sdp_p,
"%s Warning: Encryption type unsupported (%s).",
sdp_p->debug_str, tmp);
}
@ -1051,7 +1050,7 @@ sdp_result_e sdp_parse_encryption (sdp_t *sdp_p, u16 level, const char *ptr)
((encrypt_p->encrypt_type == SDP_ENCRYPT_CLEAR) ||
(encrypt_p->encrypt_type == SDP_ENCRYPT_BASE64) ||
(encrypt_p->encrypt_type == SDP_ENCRYPT_URI))) {
sdp_parse_error(sdp_p->peerconnection,
sdp_parse_error(sdp_p,
"%s Warning: No encryption key specified "
"as required.", sdp_p->debug_str);
sdp_p->conf_p->num_invalid_param++;
@ -1121,7 +1120,7 @@ sdp_result_e sdp_parse_media (sdp_t *sdp_p, u16 level, const char *ptr)
int32 sctp_port;
/* Allocate resource for new media stream. */
mca_p = sdp_alloc_mca();
mca_p = sdp_alloc_mca(sdp_p->parse_line);
if (mca_p == NULL) {
sdp_p->conf_p->num_no_resource++;
return (SDP_NO_RESOURCE);
@ -1130,7 +1129,7 @@ sdp_result_e sdp_parse_media (sdp_t *sdp_p, u16 level, const char *ptr)
/* Find the media type. */
ptr = sdp_getnextstrtok(ptr, tmp, sizeof(tmp), " \t", &result);
if (result != SDP_SUCCESS) {
sdp_parse_error(sdp_p->peerconnection,
sdp_parse_error(sdp_p,
"%s No media type specified, parse failed.",
sdp_p->debug_str);
SDP_FREE(mca_p);
@ -1145,7 +1144,7 @@ sdp_result_e sdp_parse_media (sdp_t *sdp_p, u16 level, const char *ptr)
}
}
if (mca_p->media == SDP_MEDIA_UNSUPPORTED) {
sdp_parse_error(sdp_p->peerconnection,
sdp_parse_error(sdp_p,
"%s Warning: Media type unsupported (%s).",
sdp_p->debug_str, tmp);
}
@ -1156,7 +1155,7 @@ sdp_result_e sdp_parse_media (sdp_t *sdp_p, u16 level, const char *ptr)
*/
ptr = sdp_getnextstrtok(ptr, port, sizeof(port), " \t", &result);
if (result != SDP_SUCCESS) {
sdp_parse_error(sdp_p->peerconnection,
sdp_parse_error(sdp_p,
"%s No port specified in m= media line, "
"parse failed.", sdp_p->debug_str);
SDP_FREE(mca_p);
@ -1180,7 +1179,7 @@ sdp_result_e sdp_parse_media (sdp_t *sdp_p, u16 level, const char *ptr)
/* Find the transport protocol type. */
ptr = sdp_getnextstrtok(ptr, tmp, sizeof(tmp), " \t", &result);
if (result != SDP_SUCCESS) {
sdp_parse_error(sdp_p->peerconnection,
sdp_parse_error(sdp_p,
"%s No transport protocol type specified, "
"parse failed.", sdp_p->debug_str);
SDP_FREE(mca_p);
@ -1212,7 +1211,7 @@ sdp_result_e sdp_parse_media (sdp_t *sdp_p, u16 level, const char *ptr)
* just store the first num as the port.
*/
mca_p->port = num[0];
sdp_parse_error(sdp_p->peerconnection,
sdp_parse_error(sdp_p,
"%s Warning: Transport protocol type unsupported "
"(%s).", sdp_p->debug_str, tmp);
}
@ -1226,6 +1225,10 @@ sdp_result_e sdp_parse_media (sdp_t *sdp_p, u16 level, const char *ptr)
if ((mca_p->transport == SDP_TRANSPORT_RTPAVP) ||
(mca_p->transport == SDP_TRANSPORT_RTPSAVP) ||
(mca_p->transport == SDP_TRANSPORT_RTPSAVPF) ||
(mca_p->transport == SDP_TRANSPORT_UDPTLSRTPSAVP) ||
(mca_p->transport == SDP_TRANSPORT_UDPTLSRTPSAVPF) ||
(mca_p->transport == SDP_TRANSPORT_TCPTLSRTPSAVP) ||
(mca_p->transport == SDP_TRANSPORT_TCPTLSRTPSAVPF) ||
(mca_p->transport == SDP_TRANSPORT_UDP) ||
(mca_p->transport == SDP_TRANSPORT_TCP) ||
(mca_p->transport == SDP_TRANSPORT_UDPTL) ||
@ -1265,6 +1268,10 @@ sdp_result_e sdp_parse_media (sdp_t *sdp_p, u16 level, const char *ptr)
if ((mca_p->transport == SDP_TRANSPORT_RTPAVP) ||
(mca_p->transport == SDP_TRANSPORT_RTPSAVP) ||
(mca_p->transport == SDP_TRANSPORT_RTPSAVPF) ||
(mca_p->transport == SDP_TRANSPORT_UDPTLSRTPSAVP) ||
(mca_p->transport == SDP_TRANSPORT_UDPTLSRTPSAVPF) ||
(mca_p->transport == SDP_TRANSPORT_TCPTLSRTPSAVP) ||
(mca_p->transport == SDP_TRANSPORT_TCPTLSRTPSAVPF) ||
(mca_p->transport == SDP_TRANSPORT_UDP) ||
(mca_p->transport == SDP_TRANSPORT_LOCAL)) {
/* Port format is <port>/<num of ports>. Make sure choose
@ -1357,7 +1364,7 @@ sdp_result_e sdp_parse_media (sdp_t *sdp_p, u16 level, const char *ptr)
break;
}
if (valid_param == FALSE) {
sdp_parse_error(sdp_p->peerconnection,
sdp_parse_error(sdp_p,
"%s Invalid port format (%s) specified for transport "
"protocol (%s), parse failed.", sdp_p->debug_str,
port, sdp_get_transport_name(mca_p->transport));
@ -1382,7 +1389,7 @@ sdp_result_e sdp_parse_media (sdp_t *sdp_p, u16 level, const char *ptr)
} else if (mca_p->transport == SDP_TRANSPORT_DTLSSCTP) {
ptr = sdp_getnextstrtok(ptr, port, sizeof(port), " \t", &result);
if (result != SDP_SUCCESS) {
sdp_parse_error(sdp_p->peerconnection,
sdp_parse_error(sdp_p,
"%s No sctp port specified in m= media line, "
"parse failed.", sdp_p->debug_str);
SDP_FREE(mca_p);
@ -1397,6 +1404,11 @@ sdp_result_e sdp_parse_media (sdp_t *sdp_p, u16 level, const char *ptr)
sctp_port = sdp_getnextnumtok(port_ptr, (const char **)&port_ptr,
"/ \t", &result);
if (result != SDP_SUCCESS) {
sdp_parse_error(sdp_p,
"%s No sctp port specified in m= media line, "
"parse failed.", sdp_p->debug_str);
SDP_FREE(mca_p);
sdp_p->conf_p->num_invalid_param++;
return (SDP_INVALID_PARAMETER);
}
mca_p->sctpport = sctp_port;
@ -1460,12 +1472,12 @@ sdp_result_e sdp_parse_media (sdp_t *sdp_p, u16 level, const char *ptr)
for (i=0; i < mca_p->media_profiles_p->num_profiles; i++) {
SDP_PRINT("Profile %s, Num payloads %u ",
sdp_get_transport_name(mca_p->media_profiles_p->profile[i]),
mca_p->media_profiles_p->num_payloads[i]);
(unsigned)mca_p->media_profiles_p->num_payloads[i]);
}
} else {
SDP_PRINT("Transport %s, Num payloads %u",
sdp_get_transport_name(mca_p->transport),
mca_p->num_payloads);
(unsigned)mca_p->num_payloads);
}
}
return (SDP_SUCCESS);
@ -1506,19 +1518,19 @@ sdp_result_e sdp_build_media (sdp_t *sdp_p, u16 level, flex_string *fs)
if (mca_p->port == SDP_CHOOSE_PARAM) {
flex_string_sprintf(fs, "$ ");
} else {
flex_string_sprintf(fs, "%u ", (u16)mca_p->port);
flex_string_sprintf(fs, "%u ", (unsigned)mca_p->port);
}
} else if (mca_p->port_format == SDP_PORT_NUM_COUNT) {
flex_string_sprintf(fs, "%u/%u ", (u16)mca_p->port,
(u16)mca_p->num_ports);
flex_string_sprintf(fs, "%u/%u ", (unsigned)mca_p->port,
(unsigned)mca_p->num_ports);
} else if (mca_p->port_format == SDP_PORT_VPI_VCI) {
flex_string_sprintf(fs, "%u/%u ",
(u16)mca_p->vpi, (u16)mca_p->vci);
(unsigned)mca_p->vpi, (unsigned)mca_p->vci);
} else if (mca_p->port_format == SDP_PORT_VCCI) {
flex_string_sprintf(fs, "%u ", (u16)mca_p->vcci);
flex_string_sprintf(fs, "%u ", (unsigned)mca_p->vcci);
} else if (mca_p->port_format == SDP_PORT_NUM_VPI_VCI) {
flex_string_sprintf(fs, "%u/%u/%u ", (u16)mca_p->port,
(u16)mca_p->vpi, (u16)mca_p->vci);
flex_string_sprintf(fs, "%u/%u/%u ", (unsigned)mca_p->port,
(unsigned)mca_p->vpi, (unsigned)mca_p->vci);
} else if (mca_p->port_format == SDP_PORT_VCCI_CID) {
if ((mca_p->vcci == SDP_CHOOSE_PARAM) &&
(mca_p->cid == SDP_CHOOSE_PARAM)) {
@ -1532,11 +1544,11 @@ sdp_result_e sdp_build_media (sdp_t *sdp_p, u16 level, flex_string *fs)
return (SDP_INVALID_PARAMETER);
} else {
flex_string_sprintf(fs, "%u/%u ",
(u16)mca_p->vcci, (u16)mca_p->cid);
(unsigned)mca_p->vcci, (unsigned)mca_p->cid);
}
} else if (mca_p->port_format == SDP_PORT_NUM_VPI_VCI_CID) {
flex_string_sprintf(fs, "%u/%u/%u/%u ", (u16)mca_p->port,
(u16)mca_p->vpi, (u16)mca_p->vci, (u16)mca_p->cid);
flex_string_sprintf(fs, "%u/%u/%u/%u ", (unsigned)mca_p->port,
(unsigned)mca_p->vpi, (unsigned)mca_p->vci, (unsigned)mca_p->cid);
}
/* If the media line has AAL2 profiles, build them differently. */
@ -1550,7 +1562,7 @@ sdp_result_e sdp_build_media (sdp_t *sdp_p, u16 level, flex_string *fs)
for (j=0; j < profile_p->num_payloads[i]; j++) {
flex_string_sprintf(fs, " %u",
profile_p->payload_type[i][j]);
(unsigned)profile_p->payload_type[i][j]);
}
flex_string_sprintf(fs, " ");
}
@ -1573,12 +1585,12 @@ sdp_result_e sdp_build_media (sdp_t *sdp_p, u16 level, flex_string *fs)
flex_string_sprintf(fs, " %s",
sdp_get_payload_name((sdp_payload_e)mca_p->payload_type[i]));
} else {
flex_string_sprintf(fs, " %u", mca_p->payload_type[i]);
flex_string_sprintf(fs, " %u", (unsigned)mca_p->payload_type[i]);
}
}
} else {
/* Add port to SDP if transport is DTLS/SCTP */
flex_string_sprintf(fs, " %u", (u32)mca_p->sctpport);
flex_string_sprintf(fs, " %u", (unsigned)mca_p->sctpport);
}
flex_string_sprintf(fs, "\r\n");
@ -1620,7 +1632,7 @@ void sdp_parse_payload_types (sdp_t *sdp_p, sdp_mca_t *mca_p, const char *ptr)
if (result == SDP_SUCCESS) {
if ((mca_p->media == SDP_MEDIA_IMAGE) &&
(mca_p->transport == SDP_TRANSPORT_UDPTL)) {
sdp_parse_error(sdp_p->peerconnection,
sdp_parse_error(sdp_p,
"%s Warning: Numeric payload type not "
"valid for media %s with transport %s.",
sdp_p->debug_str,
@ -1666,7 +1678,7 @@ void sdp_parse_payload_types (sdp_t *sdp_p, sdp_mca_t *mca_p, const char *ptr)
mca_p->num_payloads++;
num_payloads++;
} else {
sdp_parse_error(sdp_p->peerconnection,
sdp_parse_error(sdp_p,
"%s Warning: Payload type %s not valid for "
"media %s with transport %s.",
sdp_p->debug_str,
@ -1676,13 +1688,13 @@ void sdp_parse_payload_types (sdp_t *sdp_p, sdp_mca_t *mca_p, const char *ptr)
}
} else {
/* Payload type wasn't recognized. */
sdp_parse_error(sdp_p->peerconnection,
sdp_parse_error(sdp_p,
"%s Warning: Payload type "
"unsupported (%s).", sdp_p->debug_str, tmp);
}
}
if (mca_p->num_payloads == 0) {
sdp_parse_error(sdp_p->peerconnection,
sdp_parse_error(sdp_p,
"%s Warning: No payload types specified.",
sdp_p->debug_str);
}
@ -1764,7 +1776,7 @@ sdp_result_e sdp_parse_multiple_profile_payload_types (sdp_t *sdp_p,
/* This token must be a payload type. Make sure there aren't
* too many payload types. */
if (payload >= SDP_MAX_PAYLOAD_TYPES) {
sdp_parse_error(sdp_p->peerconnection,
sdp_parse_error(sdp_p,
"%s Warning: Too many payload types "
"found, truncating.", sdp_p->debug_str);
continue;
@ -1785,14 +1797,14 @@ sdp_result_e sdp_parse_multiple_profile_payload_types (sdp_t *sdp_p,
/* No string payload types are currently valid for the AAL2
* transport types. This support can be added when needed. */
sdp_parse_error(sdp_p->peerconnection,
sdp_parse_error(sdp_p,
"%s Warning: Unsupported payload type "
"found (%s).", sdp_p->debug_str, tmp);
}
for (i=0; i < profile_p->num_profiles; i++) {
/* Make sure we have payloads for each profile type. */
if (profile_p->num_payloads[i] == 0) {
sdp_parse_error(sdp_p->peerconnection,
sdp_parse_error(sdp_p,
"%s Warning: No payload types specified "
"for AAL2 profile %s.", sdp_p->debug_str,
sdp_get_transport_name(profile_p->profile[i]));

View File

@ -4,16 +4,18 @@
#include <errno.h>
#include <limits.h>
#include <ctype.h>
#include "sdp_os_defs.h"
#include "sdp.h"
#include "sdp_private.h"
#include "CSFLog.h"
#define MKI_BUF_LEN 4
static const char* logTag = "sdp_utils";
sdp_mca_t *sdp_alloc_mca () {
sdp_mca_t *sdp_alloc_mca (u32 line) {
sdp_mca_t *mca_p;
/* Allocate resource for new media stream. */
@ -44,6 +46,7 @@ sdp_mca_t *sdp_alloc_mca () {
mca_p->mid = 0;
mca_p->bw.bw_data_count = 0;
mca_p->bw.bw_data_list = NULL;
mca_p->line_number = line;
return (mca_p);
}
@ -83,7 +86,7 @@ static sdp_result_e next_token(const char **string_of_tokens, char *token, unsig
/* Make sure there's really a token present. */
if ((*str == '\0') || (*str == '\n') || (*str == '\r')) {
return SDP_FAILURE;
return SDP_EMPTY_TOKEN;
}
/* Now locate end of token */