From 9dbec4b99e47b9ce071facec1ea1b6d30c2ca7b6 Mon Sep 17 00:00:00 2001 From: ejurgensen Date: Tue, 19 Dec 2023 22:46:25 +0100 Subject: [PATCH] [misc] Move endianess utils from rtp_common.h to misc.h So that transcode.c can also use them. --- src/misc.h | 12 ++++++++++++ src/outputs/cast.c | 11 ++--------- src/outputs/rtp_common.h | 12 ------------ 3 files changed, 14 insertions(+), 21 deletions(-) diff --git a/src/misc.h b/src/misc.h index 520fe896..e3d1b7d9 100644 --- a/src/misc.h +++ b/src/misc.h @@ -59,6 +59,18 @@ net_is_http_or_https(const char *url); /* ----------------------- Conversion/hashing/sanitizers -------------------- */ +#ifdef HAVE_ENDIAN_H +# include +#elif defined(HAVE_SYS_ENDIAN_H) +# include +#elif defined(HAVE_LIBKERN_OSBYTEORDER_H) +#include +#define htobe16(x) OSSwapHostToBigInt16(x) +#define be16toh(x) OSSwapBigToHostInt16(x) +#define htobe32(x) OSSwapHostToBigInt32(x) +#define be32toh(x) OSSwapBigToHostInt32(x) +#endif + // Samples to bytes, bytes to samples #define STOB(s, bits, c) ((s) * (c) * (bits) / 8) #define BTOS(b, bits, c) ((b) / ((c) * (bits) / 8)) diff --git a/src/outputs/cast.c b/src/outputs/cast.c index 7963d0be..d051b1d0 100644 --- a/src/outputs/cast.c +++ b/src/outputs/cast.c @@ -32,15 +32,7 @@ #include #include #include -#ifdef HAVE_ENDIAN_H -# include -#elif defined(HAVE_SYS_ENDIAN_H) -# include -#elif defined(HAVE_LIBKERN_OSBYTEORDER_H) -#include -#define htobe32(x) OSSwapHostToBigInt32(x) -#define be32toh(x) OSSwapBigToHostInt32(x) -#endif + #include #include #include @@ -55,6 +47,7 @@ #include "outputs.h" #include "db.h" #include "artwork.h" +#include "misc.h" #ifdef HAVE_PROTOBUF_OLD #include "cast_channel.v0.pb-c.h" diff --git a/src/outputs/rtp_common.h b/src/outputs/rtp_common.h index d6ced5c7..0900157c 100644 --- a/src/outputs/rtp_common.h +++ b/src/outputs/rtp_common.h @@ -5,18 +5,6 @@ #include #include -#ifdef HAVE_ENDIAN_H -# include -#elif defined(HAVE_SYS_ENDIAN_H) -# include -#elif defined(HAVE_LIBKERN_OSBYTEORDER_H) -#include -#define htobe16(x) OSSwapHostToBigInt16(x) -#define be16toh(x) OSSwapBigToHostInt16(x) -#define htobe32(x) OSSwapHostToBigInt32(x) -#define be32toh(x) OSSwapBigToHostInt32(x) -#endif - struct rtcp_timestamp { uint32_t pos;