[misc] Move endianess utils from rtp_common.h to misc.h

So that transcode.c can also use them.
This commit is contained in:
ejurgensen 2023-12-19 22:46:25 +01:00
parent 725419d4ac
commit 9dbec4b99e
3 changed files with 14 additions and 21 deletions

View File

@ -59,6 +59,18 @@ net_is_http_or_https(const char *url);
/* ----------------------- Conversion/hashing/sanitizers -------------------- */ /* ----------------------- Conversion/hashing/sanitizers -------------------- */
#ifdef HAVE_ENDIAN_H
# include <endian.h>
#elif defined(HAVE_SYS_ENDIAN_H)
# include <sys/endian.h>
#elif defined(HAVE_LIBKERN_OSBYTEORDER_H)
#include <libkern/OSByteOrder.h>
#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 // Samples to bytes, bytes to samples
#define STOB(s, bits, c) ((s) * (c) * (bits) / 8) #define STOB(s, bits, c) ((s) * (c) * (bits) / 8)
#define BTOS(b, bits, c) ((b) / ((c) * (bits) / 8)) #define BTOS(b, bits, c) ((b) / ((c) * (bits) / 8))

View File

@ -32,15 +32,7 @@
#include <ifaddrs.h> #include <ifaddrs.h>
#include <unistd.h> #include <unistd.h>
#include <fcntl.h> #include <fcntl.h>
#ifdef HAVE_ENDIAN_H
# include <endian.h>
#elif defined(HAVE_SYS_ENDIAN_H)
# include <sys/endian.h>
#elif defined(HAVE_LIBKERN_OSBYTEORDER_H)
#include <libkern/OSByteOrder.h>
#define htobe32(x) OSSwapHostToBigInt32(x)
#define be32toh(x) OSSwapBigToHostInt32(x)
#endif
#include <gnutls/gnutls.h> #include <gnutls/gnutls.h>
#include <event2/event.h> #include <event2/event.h>
#include <json.h> #include <json.h>
@ -55,6 +47,7 @@
#include "outputs.h" #include "outputs.h"
#include "db.h" #include "db.h"
#include "artwork.h" #include "artwork.h"
#include "misc.h"
#ifdef HAVE_PROTOBUF_OLD #ifdef HAVE_PROTOBUF_OLD
#include "cast_channel.v0.pb-c.h" #include "cast_channel.v0.pb-c.h"

View File

@ -5,18 +5,6 @@
#include <inttypes.h> #include <inttypes.h>
#include <stdbool.h> #include <stdbool.h>
#ifdef HAVE_ENDIAN_H
# include <endian.h>
#elif defined(HAVE_SYS_ENDIAN_H)
# include <sys/endian.h>
#elif defined(HAVE_LIBKERN_OSBYTEORDER_H)
#include <libkern/OSByteOrder.h>
#define htobe16(x) OSSwapHostToBigInt16(x)
#define be16toh(x) OSSwapBigToHostInt16(x)
#define htobe32(x) OSSwapHostToBigInt32(x)
#define be32toh(x) OSSwapBigToHostInt32(x)
#endif
struct rtcp_timestamp struct rtcp_timestamp
{ {
uint32_t pos; uint32_t pos;