[PATCH 2/9] Use 'defines' for length and duration of RTP payload

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/OpenBSC@lists.osmocom.org/.

Andreas Eversberg jolly at eversberg.eu
Wed Jan 22 09:05:51 UTC 2014


---
 openbsc/include/openbsc/rtp_proxy.h |  4 ++++
 openbsc/src/libtrau/rtp_proxy.c     | 20 +++++++++++++-------
 2 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/openbsc/include/openbsc/rtp_proxy.h b/openbsc/include/openbsc/rtp_proxy.h
index 26cac0d..52ffefd 100644
--- a/openbsc/include/openbsc/rtp_proxy.h
+++ b/openbsc/include/openbsc/rtp_proxy.h
@@ -33,6 +33,10 @@
 #define RTP_PT_GSM_HALF 96
 #define RTP_PT_GSM_EFR 97
 #define RTP_PT_AMR 98
+#define RTP_LEN_GSM_FULL 33
+#define RTP_LEN_GSM_HALF 15
+#define RTP_LEN_GSM_EFR 31
+#define RTP_GSM_DURATION 160
 
 enum rtp_rx_action {
 	RTP_NONE,
diff --git a/openbsc/src/libtrau/rtp_proxy.c b/openbsc/src/libtrau/rtp_proxy.c
index 4278fc6..94a5b2f 100644
--- a/openbsc/src/libtrau/rtp_proxy.c
+++ b/openbsc/src/libtrau/rtp_proxy.c
@@ -167,15 +167,21 @@ static int rtp_decode(struct msgb *msg, uint32_t callref, struct msgb **data)
 	switch (rtph->payload_type) {
 	case RTP_PT_GSM_FULL:
 		msg_type = GSM_TCHF_FRAME;
-		if (payload_len != 33) {
+		if (payload_len != RTP_LEN_GSM_FULL) {
 			DEBUGPC(DLMUX, "received RTP full rate frame with "
-				"payload length != 32 (len = %d)\n",
-				payload_len);
+				"payload length != %d (len = %d)\n",
+				RTP_LEN_GSM_FULL, payload_len);
 			return -EINVAL;
 		}
 		break;
 	case RTP_PT_GSM_EFR:
 		msg_type = GSM_TCHF_FRAME_EFR;
+		if (payload_len != RTP_LEN_GSM_EFR) {
+			DEBUGPC(DLMUX, "received RTP extended full rate frame "
+				"with payload length != %d (len = %d)\n",
+				RTP_LEN_GSM_EFR, payload_len);
+			return -EINVAL;
+		}
 		break;
 	default:
 		DEBUGPC(DLMUX, "received RTP frame with unknown payload "
@@ -236,13 +242,13 @@ int rtp_send_frame(struct rtp_socket *rs, struct gsm_data_frame *frame)
 	switch (frame->msg_type) {
 	case GSM_TCHF_FRAME:
 		payload_type = RTP_PT_GSM_FULL;
-		payload_len = 33;
-		duration = 160;
+		payload_len = RTP_LEN_GSM_FULL;
+		duration = RTP_GSM_DURATION;
 		break;
 	case GSM_TCHF_FRAME_EFR:
 		payload_type = RTP_PT_GSM_EFR;
-		payload_len = 31;
-		duration = 160;
+		payload_len = RTP_LEN_GSM_EFR;
+		duration = RTP_GSM_DURATION;
 		break;
 	default:
 		DEBUGPC(DLMUX, "unsupported message type %d\n",
-- 
1.8.1.5





More information about the OpenBSC mailing list