1
/* $Id: stream_common.c 3664 2011-07-19 03:42:28Z nanang $ */
3
* Copyright (C) 2011 Teluu Inc. (http://www.teluu.com)
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
#include <pjmedia/stream_common.h>
22
#define THIS_FILE "stream_common.c"
25
* Parse fmtp for specified format/payload type.
27
PJ_DEF(pj_status_t) pjmedia_stream_info_parse_fmtp( pj_pool_t *pool,
28
const pjmedia_sdp_media *m,
30
pjmedia_codec_fmtp *fmtp)
32
const pjmedia_sdp_attr *attr;
33
pjmedia_sdp_fmtp sdp_fmtp;
34
char *p, *p_end, fmt_buf[8];
40
pj_bzero(fmtp, sizeof(pjmedia_codec_fmtp));
42
/* Get "fmtp" attribute for the format */
43
pj_ansi_sprintf(fmt_buf, "%d", pt);
44
fmt = pj_str(fmt_buf);
45
attr = pjmedia_sdp_media_find_attr2(m, "fmtp", &fmt);
49
/* Parse "fmtp" attribute */
50
status = pjmedia_sdp_attr_get_fmtp(attr, &sdp_fmtp);
51
if (status != PJ_SUCCESS)
55
p = sdp_fmtp.fmt_param.ptr;
56
p_end = p + sdp_fmtp.fmt_param.slen;
60
char *token, *start, *end;
62
if (fmtp->cnt >= PJMEDIA_CODEC_MAX_FMTP_CNT) {
64
"Warning: fmtp parameter count exceeds "
65
"PJMEDIA_CODEC_MAX_FMTP_CNT"));
69
/* Skip whitespaces */
70
while (p < p_end && (*p == ' ' || *p == '\t')) ++p;
76
while (p < p_end && *p != ';' && *p != '=') ++p;
80
while (end >= start && (*end == ' ' || *end == '\t' ||
81
*end == '\r' || *end == '\n' ))
84
/* Forward a char after trimming */
90
token = (char*)pj_pool_alloc(pool, end - start);
91
pj_ansi_strncpy(token, start, end - start);
97
pj_strset(&fmtp->param[fmtp->cnt].name, token, end - start);
100
pj_strset(&fmtp->param[fmtp->cnt++].val, token, end - start);
101
} else if (*p != '=') {