summaryrefslogtreecommitdiff
path: root/modules/g7221/sdp.c
blob: 7bfc62c282593626585c4b4a7e2e638c51f31918 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/**
 * @file g7221/sdp.c G.722.1 SDP Functions
 *
 * Copyright (C) 2010 Creytiv.com
 */

#include <re.h>
#include <baresip.h>
#include "g7221.h"


static uint32_t g7221_bitrate(const char *fmtp)
{
	struct pl pl, bitrate;

	if (!fmtp)
		return 0;

	pl_set_str(&pl, fmtp);

	if (fmt_param_get(&pl, "bitrate", &bitrate))
		return pl_u32(&bitrate);

	return 0;
}


int g7221_fmtp_enc(struct mbuf *mb, const struct sdp_format *fmt,
		  bool offer, void *arg)
{
	const struct g7221_aucodec *g7221 = arg;
	(void)offer;

	if (!mb || !fmt || !g7221)
		return 0;

	return mbuf_printf(mb, "a=fmtp:%s bitrate=%u\r\n",
			   fmt->id, g7221->bitrate);
}


bool g7221_fmtp_cmp(const char *lfmtp, const char *rfmtp, void *arg)
{
	const struct g7221_aucodec *g7221 = arg;
	(void)lfmtp;

	if (!g7221)
		return false;

	if (g7221->bitrate != g7221_bitrate(rfmtp))
		return false;

	return true;
}