mirror of
				https://gitea.osmocom.org/cellular-infrastructure/osmo-mgw.git
				synced 2025-11-04 05:53:26 +00:00 
			
		
		
		
	Compare commits
	
		
			1 Commits
		
	
	
		
			1.11.1
			...
			pmaier/amr
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					63ce8ce2e9 | 
@@ -191,6 +191,7 @@ struct mgcp_trunk_config {
 | 
				
			|||||||
	int force_constant_ssrc; /* 0: don't, 1: once */
 | 
						int force_constant_ssrc; /* 0: don't, 1: once */
 | 
				
			||||||
	int force_aligned_timing;
 | 
						int force_aligned_timing;
 | 
				
			||||||
	bool rfc5993_hr_convert;
 | 
						bool rfc5993_hr_convert;
 | 
				
			||||||
 | 
						bool amr_oa_bwe_convert;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* spec handling */
 | 
						/* spec handling */
 | 
				
			||||||
	int force_realloc;
 | 
						int force_realloc;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -129,6 +129,7 @@ struct mgcp_rtp_end {
 | 
				
			|||||||
	/* should we perform align_rtp_timestamp_offset() (1) or not (0) */
 | 
						/* should we perform align_rtp_timestamp_offset() (1) or not (0) */
 | 
				
			||||||
	int force_aligned_timing;
 | 
						int force_aligned_timing;
 | 
				
			||||||
	bool rfc5993_hr_convert;
 | 
						bool rfc5993_hr_convert;
 | 
				
			||||||
 | 
						bool amr_oa_bwe_convert;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* Each end has a separate socket for RTP and RTCP */
 | 
						/* Each end has a separate socket for RTP and RTCP */
 | 
				
			||||||
	struct osmo_fd rtp;
 | 
						struct osmo_fd rtp;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -34,6 +34,7 @@
 | 
				
			|||||||
#include <osmocom/core/socket.h>
 | 
					#include <osmocom/core/socket.h>
 | 
				
			||||||
#include <osmocom/core/byteswap.h>
 | 
					#include <osmocom/core/byteswap.h>
 | 
				
			||||||
#include <osmocom/netif/rtp.h>
 | 
					#include <osmocom/netif/rtp.h>
 | 
				
			||||||
 | 
					#include <osmocom/netif/amr.h>
 | 
				
			||||||
#include <osmocom/mgcp/mgcp.h>
 | 
					#include <osmocom/mgcp/mgcp.h>
 | 
				
			||||||
#include <osmocom/mgcp/mgcp_common.h>
 | 
					#include <osmocom/mgcp/mgcp_common.h>
 | 
				
			||||||
#include <osmocom/mgcp/mgcp_internal.h>
 | 
					#include <osmocom/mgcp/mgcp_internal.h>
 | 
				
			||||||
@@ -686,6 +687,41 @@ static void rfc5993_hr_convert(struct mgcp_endpoint *endp, char *data, int *len)
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* For AMR RTP two framing modes are defined RFC3267. There is a bandwith
 | 
				
			||||||
 | 
					 * efficient encoding scheme where all fields are packed together one after
 | 
				
			||||||
 | 
					 * another and an octet aligned mode where all fields are aligned to octet
 | 
				
			||||||
 | 
					 * boundaries. This function is used to convert between the two modes */
 | 
				
			||||||
 | 
					static void amr_oa_bwe_convert(struct mgcp_endpoint *endp, char *data, int *len)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						/* NOTE: *data has an overall length of RTP_BUF_SIZE, so there is
 | 
				
			||||||
 | 
						 * plenty of space available to store the slightly larger, converted
 | 
				
			||||||
 | 
						 * data */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						struct rtp_hdr *rtp_hdr;
 | 
				
			||||||
 | 
						unsigned int payload_len;
 | 
				
			||||||
 | 
						int rc;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						OSMO_ASSERT(*len >= sizeof(struct rtp_hdr));
 | 
				
			||||||
 | 
						rtp_hdr = (struct rtp_hdr *)data;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						payload_len = *len - sizeof(struct rtp_hdr);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (osmo_amr_is_oa(rtp_hdr->data, payload_len))
 | 
				
			||||||
 | 
							rc = osmo_amr_oa_to_bwe(rtp_hdr->data, payload_len);
 | 
				
			||||||
 | 
						else
 | 
				
			||||||
 | 
							rc = osmo_amr_bwe_to_oa(rtp_hdr->data, payload_len,
 | 
				
			||||||
 | 
										RTP_BUF_SIZE);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (rc < 0) {
 | 
				
			||||||
 | 
							LOGP(DRTP, LOGL_ERROR,
 | 
				
			||||||
 | 
							     "endpoint:0x%x AMR RTP packet conversion failed\n",
 | 
				
			||||||
 | 
							     ENDPOINT_NUMBER(endp));
 | 
				
			||||||
 | 
							return;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						*len = rc + sizeof(struct rtp_hdr);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Forward data to a debug tap. This is debug function that is intended for
 | 
					/* Forward data to a debug tap. This is debug function that is intended for
 | 
				
			||||||
 * debugging the voice traffic with tools like gstreamer */
 | 
					 * debugging the voice traffic with tools like gstreamer */
 | 
				
			||||||
static void forward_data(int fd, struct mgcp_rtp_tap *tap, const char *buf,
 | 
					static void forward_data(int fd, struct mgcp_rtp_tap *tap, const char *buf,
 | 
				
			||||||
@@ -799,6 +835,11 @@ int mgcp_send(struct mgcp_endpoint *endp, int is_rtp, struct sockaddr_in *addr,
 | 
				
			|||||||
				      "GSM-HR-08") == 0)
 | 
									      "GSM-HR-08") == 0)
 | 
				
			||||||
				rfc5993_hr_convert(endp, buf, &buflen);
 | 
									rfc5993_hr_convert(endp, buf, &buflen);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								else if (rtp_end->amr_oa_bwe_convert
 | 
				
			||||||
 | 
								    && strcmp(conn_src->end.codec->subtype_name,
 | 
				
			||||||
 | 
									      "AMR") == 0)
 | 
				
			||||||
 | 
									amr_oa_bwe_convert(endp, buf, &buflen);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			LOGP(DRTP, LOGL_DEBUG,
 | 
								LOGP(DRTP, LOGL_DEBUG,
 | 
				
			||||||
			     "endpoint:0x%x process/send to %s %s "
 | 
								     "endpoint:0x%x process/send to %s %s "
 | 
				
			||||||
			     "rtp_port:%u rtcp_port:%u\n",
 | 
								     "rtp_port:%u rtcp_port:%u\n",
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -653,6 +653,7 @@ void mgcp_rtp_end_config(struct mgcp_endpoint *endp, int expect_ssrc_change,
 | 
				
			|||||||
	rtp->force_aligned_timing = tcfg->force_aligned_timing;
 | 
						rtp->force_aligned_timing = tcfg->force_aligned_timing;
 | 
				
			||||||
	rtp->force_constant_ssrc = patch_ssrc ? 1 : 0;
 | 
						rtp->force_constant_ssrc = patch_ssrc ? 1 : 0;
 | 
				
			||||||
	rtp->rfc5993_hr_convert = tcfg->rfc5993_hr_convert;
 | 
						rtp->rfc5993_hr_convert = tcfg->rfc5993_hr_convert;
 | 
				
			||||||
 | 
						rtp->amr_oa_bwe_convert = tcfg->amr_oa_bwe_convert;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	LOGP(DLMGCP, LOGL_DEBUG,
 | 
						LOGP(DLMGCP, LOGL_DEBUG,
 | 
				
			||||||
	     "Configuring RTP endpoint: local port %d%s%s\n",
 | 
						     "Configuring RTP endpoint: local port %d%s%s\n",
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -38,6 +38,7 @@
 | 
				
			|||||||
#define RTP_PATCH_STR "Modify RTP packet header in both directions\n"
 | 
					#define RTP_PATCH_STR "Modify RTP packet header in both directions\n"
 | 
				
			||||||
#define RTP_KEEPALIVE_STR "Send dummy UDP packet to net RTP destination\n"
 | 
					#define RTP_KEEPALIVE_STR "Send dummy UDP packet to net RTP destination\n"
 | 
				
			||||||
#define RTP_TS101318_RFC5993_CONV_STR "Convert GSM-HR from TS101318 to RFC5993 and vice versa\n"
 | 
					#define RTP_TS101318_RFC5993_CONV_STR "Convert GSM-HR from TS101318 to RFC5993 and vice versa\n"
 | 
				
			||||||
 | 
					#define RTP_AMR_OA_BWE_CONV_STR "Convert AMR from octet-aligned to bandwith-efficient mode and vice versa\n"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static struct mgcp_config *g_cfg = NULL;
 | 
					static struct mgcp_config *g_cfg = NULL;
 | 
				
			||||||
@@ -744,6 +745,22 @@ DEFUN(cfg_mgcp_no_patch_rtp_rfc5993hr,
 | 
				
			|||||||
	return CMD_SUCCESS;
 | 
						return CMD_SUCCESS;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					DEFUN(cfg_mgcp_patch_rtp_amr_oa_bwe,
 | 
				
			||||||
 | 
					      cfg_mgcp_patch_rtp_amr_oa_bwe_cmd,
 | 
				
			||||||
 | 
					      "rtp-patch amr-oa-bwe", RTP_PATCH_STR RTP_AMR_OA_BWE_CONV_STR)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						g_cfg->trunk.amr_oa_bwe_convert = true;
 | 
				
			||||||
 | 
						return CMD_SUCCESS;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					DEFUN(cfg_mgcp_no_patch_rtp_amr_oa_bwe,
 | 
				
			||||||
 | 
					      cfg_mgcp_no_patch_rtp_amr_oa_bwe_cmd,
 | 
				
			||||||
 | 
					      "no rtp-patch amr-oa-bwe", NO_STR RTP_PATCH_STR RTP_AMR_OA_BWE_CONV_STR)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						g_cfg->trunk.amr_oa_bwe_convert = false;
 | 
				
			||||||
 | 
						return CMD_SUCCESS;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
DEFUN(cfg_mgcp_no_patch_rtp,
 | 
					DEFUN(cfg_mgcp_no_patch_rtp,
 | 
				
			||||||
      cfg_mgcp_no_patch_rtp_cmd, "no rtp-patch", NO_STR RTP_PATCH_STR)
 | 
					      cfg_mgcp_no_patch_rtp_cmd, "no rtp-patch", NO_STR RTP_PATCH_STR)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@@ -1040,6 +1057,24 @@ DEFUN(cfg_trunk_no_patch_rtp_rfc5993hr,
 | 
				
			|||||||
	return CMD_SUCCESS;
 | 
						return CMD_SUCCESS;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					DEFUN(cfg_trunk_patch_rtp_amr_oa_bwe,
 | 
				
			||||||
 | 
					      cfg_trunk_patch_rtp_amr_oa_bwe_cmd,
 | 
				
			||||||
 | 
					      "rtp-patch amr-oa-bwe", RTP_PATCH_STR RTP_AMR_OA_BWE_CONV_STR)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						struct mgcp_trunk_config *trunk = vty->index;
 | 
				
			||||||
 | 
						trunk->amr_oa_bwe_convert = true;
 | 
				
			||||||
 | 
						return CMD_SUCCESS;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					DEFUN(cfg_trunk_no_patch_rtp_amr_oa_bwe,
 | 
				
			||||||
 | 
					      cfg_trunk_no_patch_rtp_amr_oa_bwe_cmd,
 | 
				
			||||||
 | 
					      "no rtp-patch amr-oa-bwe", NO_STR RTP_PATCH_STR RTP_AMR_OA_BWE_CONV_STR)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						struct mgcp_trunk_config *trunk = vty->index;
 | 
				
			||||||
 | 
						trunk->amr_oa_bwe_convert = false;
 | 
				
			||||||
 | 
						return CMD_SUCCESS;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
DEFUN(cfg_trunk_no_patch_rtp,
 | 
					DEFUN(cfg_trunk_no_patch_rtp,
 | 
				
			||||||
      cfg_trunk_no_patch_rtp_cmd, "no rtp-patch", NO_STR RTP_PATCH_STR)
 | 
					      cfg_trunk_no_patch_rtp_cmd, "no rtp-patch", NO_STR RTP_PATCH_STR)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@@ -1448,6 +1483,8 @@ int mgcp_vty_init(void)
 | 
				
			|||||||
	install_element(MGCP_NODE, &cfg_mgcp_no_patch_rtp_cmd);
 | 
						install_element(MGCP_NODE, &cfg_mgcp_no_patch_rtp_cmd);
 | 
				
			||||||
	install_element(MGCP_NODE, &cfg_mgcp_patch_rtp_rfc5993hr_cmd);
 | 
						install_element(MGCP_NODE, &cfg_mgcp_patch_rtp_rfc5993hr_cmd);
 | 
				
			||||||
	install_element(MGCP_NODE, &cfg_mgcp_no_patch_rtp_rfc5993hr_cmd);
 | 
						install_element(MGCP_NODE, &cfg_mgcp_no_patch_rtp_rfc5993hr_cmd);
 | 
				
			||||||
 | 
						install_element(MGCP_NODE, &cfg_mgcp_patch_rtp_amr_oa_bwe_cmd);
 | 
				
			||||||
 | 
						install_element(MGCP_NODE, &cfg_mgcp_no_patch_rtp_amr_oa_bwe_cmd);
 | 
				
			||||||
	install_element(MGCP_NODE, &cfg_mgcp_sdp_fmtp_extra_cmd);
 | 
						install_element(MGCP_NODE, &cfg_mgcp_sdp_fmtp_extra_cmd);
 | 
				
			||||||
	install_element(MGCP_NODE, &cfg_mgcp_sdp_payload_send_ptime_cmd);
 | 
						install_element(MGCP_NODE, &cfg_mgcp_sdp_payload_send_ptime_cmd);
 | 
				
			||||||
	install_element(MGCP_NODE, &cfg_mgcp_no_sdp_payload_send_ptime_cmd);
 | 
						install_element(MGCP_NODE, &cfg_mgcp_no_sdp_payload_send_ptime_cmd);
 | 
				
			||||||
@@ -1481,6 +1518,8 @@ int mgcp_vty_init(void)
 | 
				
			|||||||
	install_element(TRUNK_NODE, &cfg_trunk_patch_rtp_ts_cmd);
 | 
						install_element(TRUNK_NODE, &cfg_trunk_patch_rtp_ts_cmd);
 | 
				
			||||||
	install_element(TRUNK_NODE, &cfg_trunk_patch_rtp_rfc5993hr_cmd);
 | 
						install_element(TRUNK_NODE, &cfg_trunk_patch_rtp_rfc5993hr_cmd);
 | 
				
			||||||
	install_element(TRUNK_NODE, &cfg_trunk_no_patch_rtp_rfc5993hr_cmd);
 | 
						install_element(TRUNK_NODE, &cfg_trunk_no_patch_rtp_rfc5993hr_cmd);
 | 
				
			||||||
 | 
						install_element(TRUNK_NODE, &cfg_trunk_patch_rtp_amr_oa_bwe_cmd);
 | 
				
			||||||
 | 
						install_element(TRUNK_NODE, &cfg_trunk_no_patch_rtp_amr_oa_bwe_cmd);
 | 
				
			||||||
	install_element(TRUNK_NODE, &cfg_trunk_no_patch_rtp_ts_cmd);
 | 
						install_element(TRUNK_NODE, &cfg_trunk_no_patch_rtp_ts_cmd);
 | 
				
			||||||
	install_element(TRUNK_NODE, &cfg_trunk_no_patch_rtp_cmd);
 | 
						install_element(TRUNK_NODE, &cfg_trunk_no_patch_rtp_cmd);
 | 
				
			||||||
	install_element(TRUNK_NODE, &cfg_trunk_sdp_fmtp_extra_cmd);
 | 
						install_element(TRUNK_NODE, &cfg_trunk_sdp_fmtp_extra_cmd);
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user