mirror of
				https://gitea.osmocom.org/cellular-infrastructure/osmo-mgw.git
				synced 2025-11-03 21:43:32 +00:00 
			
		
		
		
	Compare commits
	
		
			2 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					ed7c4fcfc3 | ||
| 
						 | 
					3babd1a803 | 
@@ -17,3 +17,4 @@ int mgcp_codec_decide(struct mgcp_conn_rtp *conn);
 | 
			
		||||
int mgcp_codec_pt_translate(struct mgcp_conn_rtp *conn_src, struct mgcp_conn_rtp *conn_dst, int payload_type);
 | 
			
		||||
const struct mgcp_rtp_codec *mgcp_codec_pt_find_by_subtype_name(struct mgcp_conn_rtp *conn,
 | 
			
		||||
								const char *subtype_name, unsigned int match_nr);
 | 
			
		||||
bool mgcp_codec_amr_is_octet_aligned(const struct mgcp_rtp_codec *codec);
 | 
			
		||||
 
 | 
			
		||||
@@ -355,7 +355,7 @@ int mgcp_codec_decide(struct mgcp_conn_rtp *conn)
 | 
			
		||||
 *
 | 
			
		||||
 * https://tools.ietf.org/html/rfc4867
 | 
			
		||||
 */
 | 
			
		||||
static bool amr_is_octet_aligned(const struct mgcp_rtp_codec *codec)
 | 
			
		||||
bool mgcp_codec_amr_is_octet_aligned(const struct mgcp_rtp_codec *codec)
 | 
			
		||||
{
 | 
			
		||||
	if (!codec->param_present)
 | 
			
		||||
		return false;
 | 
			
		||||
@@ -378,10 +378,10 @@ static bool codecs_same(struct mgcp_rtp_codec *codec_a, struct mgcp_rtp_codec *c
 | 
			
		||||
		return false;
 | 
			
		||||
	if (strcmp(codec_a->subtype_name, codec_b->subtype_name))
 | 
			
		||||
		return false;
 | 
			
		||||
	if (!strcmp(codec_a->subtype_name, "AMR")) {
 | 
			
		||||
		if (amr_is_octet_aligned(codec_a) != amr_is_octet_aligned(codec_b))
 | 
			
		||||
			return false;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* Note: AMR allows to set the RTP payload format to octet-aligned or bandwith-efficient (octet-aligned=0)
 | 
			
		||||
	 * via SDP. This difference concerns payload format only, but not the actual codec. It is not a difference
 | 
			
		||||
	 * within the meaning of this function. */
 | 
			
		||||
 | 
			
		||||
	return true;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1896,16 +1896,13 @@ static const struct testcase_mgcp_codec_pt_translate test_mgcp_codec_pt_translat
 | 
			
		||||
		.codecs = {
 | 
			
		||||
			{
 | 
			
		||||
				{ 111, "AMR/8000", &amr_param_octet_aligned_true, },
 | 
			
		||||
				{ 112, "AMR/8000", &amr_param_octet_aligned_false, },
 | 
			
		||||
			},
 | 
			
		||||
			{
 | 
			
		||||
				{ 122, "AMR/8000", &amr_param_octet_aligned_false, },
 | 
			
		||||
				{ 121, "AMR/8000", &amr_param_octet_aligned_true, },
 | 
			
		||||
			},
 | 
			
		||||
		},
 | 
			
		||||
		.expect = {
 | 
			
		||||
			{ .payload_type_map = {111, 121}, },
 | 
			
		||||
			{ .payload_type_map = {112, 122} },
 | 
			
		||||
			{ .payload_type_map = {111, 122}, },
 | 
			
		||||
			{ .end = true },
 | 
			
		||||
		},
 | 
			
		||||
	},
 | 
			
		||||
@@ -1914,15 +1911,13 @@ static const struct testcase_mgcp_codec_pt_translate test_mgcp_codec_pt_translat
 | 
			
		||||
		.codecs = {
 | 
			
		||||
			{
 | 
			
		||||
				{ 111, "AMR/8000", &amr_param_octet_aligned_true, },
 | 
			
		||||
				{ 112, "AMR/8000", &amr_param_octet_aligned_false, },
 | 
			
		||||
			},
 | 
			
		||||
			{
 | 
			
		||||
				{ 122, "AMR/8000", &amr_param_octet_aligned_unset, },
 | 
			
		||||
			},
 | 
			
		||||
		},
 | 
			
		||||
		.expect = {
 | 
			
		||||
			{ .payload_type_map = {111, -EINVAL}, },
 | 
			
		||||
			{ .payload_type_map = {112, 122} },
 | 
			
		||||
			{ .payload_type_map = {111, 122}, },
 | 
			
		||||
			{ .end = true },
 | 
			
		||||
		},
 | 
			
		||||
	},
 | 
			
		||||
@@ -1931,15 +1926,13 @@ static const struct testcase_mgcp_codec_pt_translate test_mgcp_codec_pt_translat
 | 
			
		||||
		.codecs = {
 | 
			
		||||
			{
 | 
			
		||||
				{ 111, "AMR/8000", &amr_param_octet_aligned_true, },
 | 
			
		||||
				{ 112, "AMR/8000", &amr_param_octet_aligned_false, },
 | 
			
		||||
			},
 | 
			
		||||
			{
 | 
			
		||||
				{ 122, "AMR/8000", NULL, },
 | 
			
		||||
			},
 | 
			
		||||
		},
 | 
			
		||||
		.expect = {
 | 
			
		||||
			{ .payload_type_map = {111, -EINVAL}, },
 | 
			
		||||
			{ .payload_type_map = {112, 122} },
 | 
			
		||||
			{ .payload_type_map = {111, 122}, },
 | 
			
		||||
			{ .end = true },
 | 
			
		||||
		},
 | 
			
		||||
	},
 | 
			
		||||
 
 | 
			
		||||
@@ -1347,32 +1347,24 @@ Testing mgcp_codec_pt_translate()
 | 
			
		||||
 - mgcp_codec_pt_translate(conn0, conn1, 112) -> -22
 | 
			
		||||
 - mgcp_codec_pt_translate(conn0, conn1, 0) -> -22
 | 
			
		||||
 - mgcp_codec_pt_translate(conn0, conn1, 111) -> -22
 | 
			
		||||
#4: conn1 has no codecs
 | 
			
		||||
#4: conn1 has no codecs
 | 
			
		||||
 - add codecs on conn0:
 | 
			
		||||
    1:   0 PCMU/8000/1  -> rc=0
 | 
			
		||||
    2: 111 GSM-HR-08/8000/1  -> rc=0
 | 
			
		||||
 - add codecs on conn1:
 | 
			
		||||
    (none)
 | 
			
		||||
 - mgcp_codec_pt_translate(conn0, conn1, 112) -> -22
 | 
			
		||||
    0: 112 AMR/8000/1 octet-aligned=1  -> rc=0
 | 
			
		||||
    1:   0 PCMU/8000/1  -> rc=0
 | 
			
		||||
    2: 111 GSM-HR-08/8000/1  -> rc=0
 | 
			
		||||
 - add codecs on conn1:
 | 
			
		||||
    (none)
 | 
			
		||||
 - add codecs on conn0:
 | 
			
		||||
 - mgcp_codec_pt_translate(conn0, conn1, 112) -> -22
 | 
			
		||||
 - mgcp_codec_pt_translate(conn0, conn1, 0) -> -22
 | 
			
		||||
 - add codecs on conn1:
 | 
			
		||||
    0: 122 AMR/8000 octet-aligned=0  -> rc=0
 | 
			
		||||
    1: 121 AMR/8000 octet-aligned=1  -> rc=0
 | 
			
		||||
 - mgcp_codec_pt_translate(conn0, conn1, 111) -> -22
 | 
			
		||||
#5: test AMR with differing octet-aligned settings
 | 
			
		||||
 - add codecs on conn0:
 | 
			
		||||
    0: 111 AMR/8000 octet-aligned=1  -> rc=0
 | 
			
		||||
 - add codecs on conn1:
 | 
			
		||||
 - mgcp_codec_pt_translate(conn1, conn0, 122) -> 112
 | 
			
		||||
    0: 122 AMR/8000 octet-aligned=0  -> rc=0
 | 
			
		||||
 - mgcp_codec_pt_translate(conn0, conn1, 111) -> 122
 | 
			
		||||
    0: 111 AMR/8000 octet-aligned=1  -> rc=0
 | 
			
		||||
    1: 112 AMR/8000 octet-aligned=0  -> rc=0
 | 
			
		||||
 - add codecs on conn1:
 | 
			
		||||
 - mgcp_codec_pt_translate(conn1, conn0, 122) -> 111
 | 
			
		||||
#6: test AMR with missing octet-aligned settings (defaults to 0)
 | 
			
		||||
 - add codecs on conn0:
 | 
			
		||||
    0: 111 AMR/8000 octet-aligned=1  -> rc=0
 | 
			
		||||
 - add codecs on conn1:
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user