From 3e377be209384e77d94992dccb33277ae7016268 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Tue, 8 May 2012 19:33:18 +0000 Subject: [PATCH] patch: add sdp format dynamic encode handler. add remote params to local format --- include/re_sdp.h | 6 +++++- src/sdp/format.c | 4 +++- src/sdp/media.c | 4 ++++ src/sdp/msg.c | 2 ++ 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/include/re_sdp.h b/include/re_sdp.h index 129a429..123ba8b 100644 --- a/include/re_sdp.h +++ b/include/re_sdp.h @@ -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, ...); diff --git a/src/sdp/format.c b/src/sdp/format.c index aaa1988..6a8b67a 100644 --- a/src/sdp/format.c +++ b/src/sdp/format.c @@ -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; diff --git a/src/sdp/media.c b/src/sdp/media.c index f78e04f..c381b4c 100644 --- a/src/sdp/media.c +++ b/src/sdp/media.c @@ -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; diff --git a/src/sdp/msg.c b/src/sdp/msg.c index ffb11ee..8fe45c4 100644 --- a/src/sdp/msg.c +++ b/src/sdp/msg.c @@ -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))