patch: add sdp format dynamic encode handler. add remote params to local format

This commit is contained in:
Alfred E. Heggestad 2012-05-08 19:33:18 +00:00
parent 06ca7d1c00
commit 3e377be209
4 changed files with 14 additions and 2 deletions

View file

@ -32,6 +32,8 @@ enum sdp_bandwidth {
struct sdp_format;
typedef int(sdp_fmtp_enc_h)(struct mbuf *mb, const struct sdp_format *fmt,
bool offer, void *data);
typedef bool(sdp_fmtp_cmp_h)(const char *params1, const char *params2,
void *data);
typedef bool(sdp_format_h)(struct sdp_format *fmt, void *arg);
@ -42,7 +44,9 @@ struct sdp_format {
struct le le;
char *id;
char *params;
char *rparams;
char *name;
sdp_fmtp_enc_h *ench;
sdp_fmtp_cmp_h *cmph;
void *data;
bool ref;
@ -122,7 +126,7 @@ int sdp_media_debug(struct re_printf *pf, const struct sdp_media *m);
/* format */
int sdp_format_add(struct sdp_format **fmtp, struct sdp_media *m,
bool prepend, const char *id, const char *name,
uint32_t srate, uint8_t ch,
uint32_t srate, uint8_t ch, sdp_fmtp_enc_h *ench,
sdp_fmtp_cmp_h *cmph, void *data, bool ref,
const char *params, ...);
int sdp_format_set_params(struct sdp_format *fmt, const char *params, ...);

View file

@ -26,6 +26,7 @@ static void destructor(void *arg)
mem_deref(fmt->id);
mem_deref(fmt->params);
mem_deref(fmt->rparams);
mem_deref(fmt->name);
}
@ -49,7 +50,7 @@ static void destructor(void *arg)
*/
int sdp_format_add(struct sdp_format **fmtp, struct sdp_media *m,
bool prepend, const char *id, const char *name,
uint32_t srate, uint8_t ch,
uint32_t srate, uint8_t ch, sdp_fmtp_enc_h *ench,
sdp_fmtp_cmp_h *cmph, void *data, bool ref,
const char *params, ...)
{
@ -98,6 +99,7 @@ int sdp_format_add(struct sdp_format **fmtp, struct sdp_media *m,
fmt->pt = atoi(fmt->id);
fmt->srate = srate;
fmt->ch = ch;
fmt->ench = ench;
fmt->cmph = cmph;
fmt->data = ref ? mem_ref(data) : data;
fmt->ref = ref;

View file

@ -223,6 +223,7 @@ void sdp_media_align_formats(struct sdp_media *m, bool offer)
lfmt = lle->data;
lfmt->rparams = mem_deref(lfmt->rparams);
lfmt->sup = false;
}
@ -243,6 +244,9 @@ void sdp_media_align_formats(struct sdp_media *m, bool offer)
continue;
}
mem_deref(lfmt->rparams);
lfmt->rparams = mem_ref(rfmt->params);
lfmt->sup = true;
rfmt->sup = true;

View file

@ -416,6 +416,8 @@ static int media_encode(const struct sdp_media *m, struct mbuf *mb, bool offer)
if (str_isset(fmt->params))
err |= mbuf_printf(mb, "a=fmtp:%s %s\r\n",
fmt->id, fmt->params);
if (fmt->ench)
err |= fmt->ench(mb, fmt, offer, fmt->data);
}
if (sa_isset(&m->laddr_rtcp, SA_ALL))