patch: add optional SDP media encode handler

This commit is contained in:
Alfred E. Heggestad 2012-07-13 14:43:37 +00:00
parent c09a7c73ae
commit 48d51ab9a9
4 changed files with 26 additions and 0 deletions

View file

@ -32,6 +32,7 @@ enum sdp_bandwidth {
struct sdp_format;
typedef int(sdp_media_enc_h)(struct mbuf *mb, bool offer, void *arg);
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,
@ -84,6 +85,8 @@ struct sdp_media;
int sdp_media_add(struct sdp_media **mp, struct sdp_session *sess,
const char *name, uint16_t port, const char *proto);
void sdp_media_set_encode_handler(struct sdp_media *m, sdp_media_enc_h *ench,
void *arg);
void sdp_media_set_disabled(struct sdp_media *m, bool disabled);
void sdp_media_set_lport(struct sdp_media *m, uint16_t port);
void sdp_media_set_laddr(struct sdp_media *m, const struct sa *laddr);

View file

@ -289,6 +289,24 @@ void sdp_media_align_formats(struct sdp_media *m, bool offer)
}
/**
* Set SDP Media line encode handler
*
* @param m SDP Media line
* @param ench Encode handler
* @param arg Encode handler argument
*/
void sdp_media_set_encode_handler(struct sdp_media *m, sdp_media_enc_h *ench,
void *arg)
{
if (!m)
return;
m->ench = ench;
m->arg = arg;
}
/**
* Set an SDP Media line to enabled/disabled
*

View file

@ -435,6 +435,9 @@ static int media_encode(const struct sdp_media *m, struct mbuf *mb, bool offer)
for (le = m->lattrl.head; le; le = le->next)
err |= mbuf_printf(mb, "%H", sdp_attr_print, le->data);
if (m->ench)
err |= m->ench(mb, offer, m->arg);
return err;
}

View file

@ -39,6 +39,8 @@ struct sdp_media {
int32_t rbwv[SDP_BANDWIDTH_MAX];
char *name;
char *proto;
sdp_media_enc_h *ench;
void *arg;
enum sdp_dir ldir;
enum sdp_dir rdir;
bool disabled;