From 983c99113d912ae4003a7fa18c0abd039c42e16d Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Sun, 22 Jun 2014 22:30:28 +0200 Subject: [PATCH] rtp: Share the rtp header between the proxy and the mgcp code --- openbsc/include/openbsc/Makefile.am | 2 +- openbsc/include/openbsc/rtp.h | 38 +++++++++++++++++++++++++++++ openbsc/src/libmgcp/mgcp_network.c | 37 +--------------------------- openbsc/src/libtrau/rtp_proxy.c | 23 +---------------- 4 files changed, 41 insertions(+), 59 deletions(-) create mode 100644 openbsc/include/openbsc/rtp.h diff --git a/openbsc/include/openbsc/Makefile.am b/openbsc/include/openbsc/Makefile.am index b739d0f46..23386f1f0 100644 --- a/openbsc/include/openbsc/Makefile.am +++ b/openbsc/include/openbsc/Makefile.am @@ -14,7 +14,7 @@ noinst_HEADERS = abis_nm.h abis_rsl.h db.h gsm_04_08.h gsm_data.h \ osmo_msc_data.h osmo_bsc_grace.h sms_queue.h abis_om2000.h \ bss.h gsm_data_shared.h control_cmd.h ipaccess.h mncc_int.h \ arfcn_range_encode.h nat_rewrite_trie.h bsc_nat_callstats.h \ - osmux.h mgcp_transcode.h + osmux.h mgcp_transcode.h rtp.h openbsc_HEADERS = gsm_04_08.h meas_rep.h bsc_api.h openbscdir = $(includedir)/openbsc diff --git a/openbsc/include/openbsc/rtp.h b/openbsc/include/openbsc/rtp.h new file mode 100644 index 000000000..451d0defa --- /dev/null +++ b/openbsc/include/openbsc/rtp.h @@ -0,0 +1,38 @@ +#pragma once + +/* attempt to determine byte order */ +#include +#include +#include + +#ifndef __BYTE_ORDER +# ifdef __APPLE__ +# define __BYTE_ORDER __DARWIN_BYTE_ORDER +# define __LITTLE_ENDIAN __DARWIN_LITTLE_ENDIAN +# define __BIG_ENDIAN __DARWIN_BIG_ENDIAN +# else +# error "__BYTE_ORDER should be defined by someone" +# endif +#endif + +/* according to rtp_proxy.c RFC 3550 */ +struct rtp_hdr { +#if __BYTE_ORDER == __LITTLE_ENDIAN + uint8_t csrc_count:4, + extension:1, + padding:1, + version:2; + uint8_t payload_type:7, + marker:1; +#elif __BYTE_ORDER == __BIG_ENDIAN + uint8_t version:2, + padding:1, + extension:1, + csrc_count:4; + uint8_t marker:1, + payload_type:7; +#endif + uint16_t sequence; + uint32_t timestamp; + uint32_t ssrc; +} __attribute__((packed)); diff --git a/openbsc/src/libmgcp/mgcp_network.c b/openbsc/src/libmgcp/mgcp_network.c index 219d3f990..6e79e60b4 100644 --- a/openbsc/src/libmgcp/mgcp_network.c +++ b/openbsc/src/libmgcp/mgcp_network.c @@ -34,47 +34,12 @@ #include #include +#include #include #warning "Make use of the rtp proxy code" -/* attempt to determine byte order */ -#include -#include -#include - -#ifndef __BYTE_ORDER -# ifdef __APPLE__ -# define __BYTE_ORDER __DARWIN_BYTE_ORDER -# define __LITTLE_ENDIAN __DARWIN_LITTLE_ENDIAN -# define __BIG_ENDIAN __DARWIN_BIG_ENDIAN -# else -# error "__BYTE_ORDER should be defined by someone" -# endif -#endif - -/* according to rtp_proxy.c RFC 3550 */ -struct rtp_hdr { -#if __BYTE_ORDER == __LITTLE_ENDIAN - uint8_t csrc_count:4, - extension:1, - padding:1, - version:2; - uint8_t payload_type:7, - marker:1; -#elif __BYTE_ORDER == __BIG_ENDIAN - uint8_t version:2, - padding:1, - extension:1, - csrc_count:4; - uint8_t marker:1, - payload_type:7; -#endif - uint16_t sequence; - uint32_t timestamp; - uint32_t ssrc; -} __attribute__((packed)); #define RTP_SEQ_MOD (1 << 16) #define RTP_MAX_DROPOUT 3000 diff --git a/openbsc/src/libtrau/rtp_proxy.c b/openbsc/src/libtrau/rtp_proxy.c index 15673234b..67c0c7005 100644 --- a/openbsc/src/libtrau/rtp_proxy.c +++ b/openbsc/src/libtrau/rtp_proxy.c @@ -36,6 +36,7 @@ #include #include #include +#include /* attempt to determine byte order */ #include @@ -76,28 +77,6 @@ struct rtcp_hdr { #define RTCP_IE_CNAME 1 -/* according to RFC 3550 */ -struct rtp_hdr { -#if __BYTE_ORDER == __LITTLE_ENDIAN - uint8_t csrc_count:4, - extension:1, - padding:1, - version:2; - uint8_t payload_type:7, - marker:1; -#elif __BYTE_ORDER == __BIG_ENDIAN - uint8_t version:2, - padding:1, - extension:1, - csrc_count:4; - uint8_t marker:1, - payload_type:7; -#endif - uint16_t sequence; - uint32_t timestamp; - uint32_t ssrc; -} __attribute__((packed)); - struct rtp_x_hdr { uint16_t by_profile; uint16_t length;