Commit 327cec46 authored by Simon Morlat's avatar Simon Morlat

restore oRTP tests, they were broken due to crappy code written in configure.ac

improve fmtp_get_value() parser, so that it uses last occurence of parameter and doesn't get confused by parameter substring matches.
parent 8cac6a39
......@@ -309,7 +309,7 @@ CFLAGS="$CFLAGS $ORTP_DEFS"
echo "$ORTPDEPS_CFLAGS" > ortp.defs
AC_ARG_ENABLE(tests_enabled,
AC_ARG_ENABLE(tests,
[AS_HELP_STRING([--disable-tests], [Disable compilation of tests])],
[case "${enableval}" in
yes) tests_enabled=true ;;
......@@ -318,7 +318,7 @@ AC_ARG_ENABLE(tests_enabled,
esac],
[tests_enabled=false]
)
AM_CONDITIONAL(ENABLE_TESTS, test x$tests_enabled = xyes)
AM_CONDITIONAL(ENABLE_TESTS, test x$tests_enabled = xtrue)
case "$target_os" in
*linux*)
......
......@@ -139,9 +139,39 @@ void payload_type_destroy(PayloadType *pt)
ortp_free(pt);
}
static const char *find_param_occurence_of(const char *fmtp, const char *param){
const char *pos=fmtp;
do{
pos=strstr(pos,param);
if (pos){
/*check that the occurence found is not a subword of a parameter name*/
if (pos==fmtp) break;
if (pos[-1]==';' || pos[-1]==' '){
break;
}
pos+=strlen(param);
}
}while(pos!=NULL);
return pos;
}
static const char *find_last_param_occurence_of(const char *fmtp, const char *param){
const char *pos=fmtp;
const char *lastpos=NULL;
do{
pos=find_param_occurence_of(pos,param);
if (pos) {
lastpos=pos;
pos+=strlen(param);
}
}while(pos!=NULL);
return lastpos;
}
/**
* Parses a fmtp string such as "profile=0;level=10", finds the value matching
* parameter param_name, and writes it into result.
* If a parameter name is found multiple times, only the value of the last occurence is returned.
* Despite fmtp strings are not used anywhere within oRTP, this function can
* be useful for people using RTP streams described from SDP.
* @param fmtp the fmtp line (format parameters)
......@@ -151,7 +181,7 @@ void payload_type_destroy(PayloadType *pt)
* @return TRUE if the parameter was found, else FALSE.
**/
bool_t fmtp_get_value(const char *fmtp, const char *param_name, char *result, size_t result_len){
const char *pos=strstr(fmtp,param_name);
const char *pos=find_last_param_occurence_of(fmtp,param_name);
memset(result, '\0', result_len);
if (pos){
const char *equal=strchr(pos,'=');
......
......@@ -2,7 +2,7 @@ SUBDIRS=win_receiver win_sender
if ENABLE_TESTS
noinst_PROGRAMS=rtpsend rtprecv mrtpsend mrtprecv test_timer rtpmemtest tevrtpsend tevrtprecv tevmrtprecv rtpsend_stupid
noinst_PROGRAMS=rtpsend rtprecv mrtpsend mrtprecv test_timer rtpmemtest tevrtpsend tevrtprecv tevmrtprecv rtpsend_stupid fmtp_parse
rtpsend_SOURCES=rtpsend.c
......@@ -24,6 +24,8 @@ tevmrtprecv_SOURCES=tevmrtprecv.c
rtpsend_stupid_SOURCES=rtpsend_stupid.c
fmtp_parse_SOURCES=fmtpparse.c
endif
AM_CPPFLAGS=-I$(top_srcdir)/include/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment