2019-03-30 09:51:30 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <cstdint>
|
2019-05-17 09:49:33 +00:00
|
|
|
#include <cstddef>
|
2019-06-14 08:34:10 +00:00
|
|
|
#include <cstdio>
|
2019-03-30 09:51:30 +00:00
|
|
|
|
2019-06-17 09:01:23 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
|
|
|
|
/* TODO: make sure this works on windows too! */
|
|
|
|
|
|
|
|
#define PACKED_STRUCT_WIN(name) \
|
|
|
|
__pragma(pack(push, 1)) \
|
|
|
|
struct name \
|
|
|
|
__pragma(pack(pop))
|
|
|
|
#else
|
|
|
|
#define PACKED_STRUCT(name) \
|
|
|
|
struct __attribute__((packed)) name
|
|
|
|
#endif
|
|
|
|
|
2019-05-17 08:08:40 +00:00
|
|
|
const int MAX_PACKET = 65536;
|
|
|
|
const int MAX_PAYLOAD = 1000;
|
2019-05-17 09:49:33 +00:00
|
|
|
|
2019-05-22 06:39:16 +00:00
|
|
|
typedef enum RTP_ERROR {
|
2019-06-17 09:03:35 +00:00
|
|
|
RTP_INTERRUPTED = 2,
|
2019-06-03 08:50:15 +00:00
|
|
|
RTP_NOT_READY = 1,
|
2019-05-17 06:25:49 +00:00
|
|
|
RTP_OK = 0,
|
|
|
|
RTP_GENERIC_ERROR = -1,
|
|
|
|
RTP_SOCKET_ERROR = -2,
|
|
|
|
RTP_BIND_ERROR = -3,
|
2019-05-17 09:49:33 +00:00
|
|
|
RTP_INVALID_VALUE = -4,
|
|
|
|
RTP_SEND_ERROR = -5,
|
2019-05-22 09:43:35 +00:00
|
|
|
RTP_MEMORY_ERROR = -6,
|
2019-05-22 06:39:16 +00:00
|
|
|
} rtp_error_t;
|
2019-03-30 09:51:30 +00:00
|
|
|
|
|
|
|
typedef enum RTP_FORMAT {
|
|
|
|
RTP_FORMAT_GENERIC = 0,
|
|
|
|
RTP_FORMAT_HEVC = 96,
|
|
|
|
RTP_FORMAT_OPUS = 97,
|
|
|
|
} rtp_format_t;
|
2019-06-03 08:53:27 +00:00
|
|
|
|
2019-06-17 06:59:32 +00:00
|
|
|
extern thread_local rtp_error_t rtp_errno;
|
2019-06-03 08:53:27 +00:00
|
|
|
|
|
|
|
static inline void hex_dump(uint8_t *buf, size_t len)
|
|
|
|
{
|
|
|
|
if (!buf)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (size_t i = 0; i < len; i += 10) {
|
|
|
|
fprintf(stderr, "\t");
|
|
|
|
for (size_t k = i; k < i + 10; ++k) {
|
|
|
|
fprintf(stderr, "0x%02x ", buf[k]);
|
|
|
|
}
|
|
|
|
fprintf(stderr, "\n");
|
|
|
|
}
|
|
|
|
}
|
2019-06-20 06:25:01 +00:00
|
|
|
|
|
|
|
static inline void set_bytes(int *ptr, int nbytes)
|
|
|
|
{
|
|
|
|
if (ptr)
|
|
|
|
*ptr = nbytes;
|
|
|
|
}
|