summaryrefslogtreecommitdiff
path: root/modules/amr/sdp.c
blob: e4b0cdfd3b699a5387d60577d6af3508425683ee (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
55
56
/**
 * @file amr/sdp.c AMR SDP Functions
 *
 * Copyright (C) 2010 - 2015 Creytiv.com
 */

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


static bool amr_octet_align(const char *fmtp)
{
	struct pl pl, oa;

	if (!fmtp)
		return false;

	pl_set_str(&pl, fmtp);

	if (fmt_param_get(&pl, "octet-align", &oa))
		return 0 == pl_strcmp(&oa, "1");

	return false;
}


int amr_fmtp_enc(struct mbuf *mb, const struct sdp_format *fmt,
		 bool offer, void *arg)
{
	const struct aucodec *ac = arg;
	(void)offer;

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

	return mbuf_printf(mb, "a=fmtp:%s octet-align=1\r\n",
			   fmt->id);
}


bool amr_fmtp_cmp(const char *lfmtp, const char *rfmtp, void *arg)
{
	const struct aucodec *ac = arg;
	(void)lfmtp;

	if (!ac)
		return false;

	if (!amr_octet_align(rfmtp)) {
		info("amr: octet-align mode is required\n");
		return false;
	}

	return true;
}