common: Move internal definition out from public header

This commit is contained in:
Joni Räsänen 2022-09-19 09:34:02 +03:00
parent 72224ce909
commit 80433cfcc4
9 changed files with 36 additions and 25 deletions

View File

@ -80,6 +80,7 @@ source_group(include include/.*)
target_sources(${PROJECT_NAME} PRIVATE
src/crypto.hh
src/debug.hh
src/global.hh
src/random.hh
src/holepuncher.hh
src/hostname.hh

View File

@ -18,26 +18,6 @@ typedef SSIZE_T ssize_t;
#include <stdint.h>
namespace uvgrtp {
constexpr uint8_t IPV4_HDR_SIZE = 20;
constexpr uint8_t IPV6_HDR_SIZE = 40; // TODO: Ipv6 support
constexpr uint8_t UDP_HDR_SIZE = 8;
constexpr uint8_t RTP_HDR_SIZE = 12;
/* the default MTU size for ethernet, can be adjusted with rcc flags.
* The default is assumed to be 1500 minus 8 bytes reserved for additional protocol headers- */
constexpr uint16_t DEFAULT_MTU_SIZE = 1492;
constexpr uint16_t MAX_IPV4_PAYLOAD = DEFAULT_MTU_SIZE - IPV4_HDR_SIZE - UDP_HDR_SIZE;
constexpr uint16_t MAX_IPV6_PAYLOAD = DEFAULT_MTU_SIZE - IPV6_HDR_SIZE - UDP_HDR_SIZE;
// here we ignore ethernet frame header size since it is not included in MTU
constexpr uint16_t MAX_IPV4_MEDIA_PAYLOAD = MAX_IPV4_PAYLOAD - RTP_HDR_SIZE;
constexpr uint16_t MAX_IPV6_MEDIA_PAYLOAD = MAX_IPV6_PAYLOAD - RTP_HDR_SIZE;
constexpr int PKT_MAX_DELAY_MS = 500;
}
/// \endcond
/**

View File

@ -242,11 +242,11 @@ ssize_t uvgrtp::formats::h26x::find_h26x_start_code(
// current has 2 bytes of possible start code
//bool c2s = (((cur_ms >> 8) & 0xff) == 0x01);
// previous has 4 bytes of possible start code
// current has 4 bytes of possible start code
bool c4s = (cur_ms == 0x0100); // current starts with 0001
// previous has 6 bytes of start code
bool c6s = (cur_ms == 0x0000 && (cur_ls & 0xff) == 0x01); // current is 000001XX
// current has 6 bytes of start code
bool c6s = (cur_ms == 0x0000 && (cur_ls & 0xff) == 0x01); // current is 0000 01XX
#else
uint16_t cur_ls = (cur_value32 >> 0) & 0xffff;

24
src/global.hh Normal file
View File

@ -0,0 +1,24 @@
#pragma once
namespace uvgrtp {
constexpr uint8_t IPV4_HDR_SIZE = 20;
constexpr uint8_t IPV6_HDR_SIZE = 40; // TODO: Ipv6 support
constexpr uint8_t UDP_HDR_SIZE = 8;
constexpr uint8_t RTP_HDR_SIZE = 12;
/* the default MTU size for ethernet, can be adjusted with rcc flags.
* The default is assumed to be 1500 minus 8 bytes reserved for additional protocol headers- */
constexpr uint16_t DEFAULT_MTU_SIZE = 1492;
// here we ignore ethernet frame header size since it is not included in MTU
constexpr uint16_t MAX_IPV4_PAYLOAD = DEFAULT_MTU_SIZE - IPV4_HDR_SIZE - UDP_HDR_SIZE;
constexpr uint16_t MAX_IPV6_PAYLOAD = DEFAULT_MTU_SIZE - IPV6_HDR_SIZE - UDP_HDR_SIZE;
constexpr uint16_t MAX_IPV4_MEDIA_PAYLOAD = MAX_IPV4_PAYLOAD - RTP_HDR_SIZE;
constexpr uint16_t MAX_IPV6_MEDIA_PAYLOAD = MAX_IPV6_PAYLOAD - RTP_HDR_SIZE;
constexpr int PKT_MAX_DELAY_MS = 500;
}

View File

@ -16,6 +16,7 @@
#include "srtp/srtcp.hh"
#include "srtp/srtp.hh"
#include "formats/media.hh"
#include "global.hh"
#include <cstring>
#include <errno.h>

View File

@ -7,6 +7,8 @@
#include "debug.hh"
#include "random.hh"
#include "global.hh"
#include <chrono>
#ifndef _WIN32

View File

@ -11,6 +11,8 @@
#include "srtp/srtcp.hh"
#include "rtcp_packets.hh"
#include "global.hh"
#ifndef _WIN32
#include <sys/time.h>

View File

@ -6,6 +6,8 @@
#include "random.hh"
#include "memory.hh"
#include "global.hh"
#ifndef _WIN32
#include <arpa/inet.h>
#include <unistd.h>
@ -13,8 +15,6 @@
#include <chrono>
#define INVALID_TS UINT64_MAX
uvgrtp::rtp::rtp(rtp_format_t fmt):

View File

@ -5,6 +5,7 @@
#include "../debug.hh"
#include "../crypto.hh"
#include "base.hh"
#include "global.hh"
#include <cstring>
#include <iostream>