Reorganized defines and added mtu option to C API

This commit is contained in:
Paul-Louis Ageneau
2021-03-02 12:13:58 +01:00
parent 83453635a8
commit 32c4427b96
10 changed files with 78 additions and 60 deletions

View File

@@ -19,14 +19,14 @@
#ifndef RTC_COMMON_H
#define RTC_COMMON_H
#ifndef RTC_ENABLE_MEDIA
#define RTC_ENABLE_MEDIA 1
#endif
#ifndef RTC_ENABLE_WEBSOCKET
#define RTC_ENABLE_WEBSOCKET 1
#endif
#ifndef RTC_ENABLE_MEDIA
#define RTC_ENABLE_MEDIA 1
#endif
#ifdef _WIN32
#define RTC_CPP_EXPORT __declspec(dllexport)
#ifndef _WIN32_WINNT
@@ -39,6 +39,8 @@
#define RTC_CPP_EXPORT
#endif
#include "rtc.h" // for C API defines
#include "log.hpp"
#include "utils.hpp"

View File

@@ -62,11 +62,9 @@ private:
/// Nal unit
struct RTC_CPP_EXPORT NalUnit : binary {
NalUnit(const NalUnit &unit) = default;
NalUnit(size_t size, bool includingHeader = true)
: binary(size + (includingHeader ? 0 : 1)) {}
NalUnit(size_t size, bool includingHeader = true) : binary(size + (includingHeader ? 0 : 1)) {}
template <typename Iterator>
NalUnit(Iterator begin_, Iterator end_) : binary(begin_, end_) {}
template <typename Iterator> NalUnit(Iterator begin_, Iterator end_) : binary(begin_, end_) {}
NalUnit(binary &&data) : binary(std::move(data)) {}
@@ -101,9 +99,10 @@ struct RTC_CPP_EXPORT NalUnitFragmentA : NalUnit {
enum class FragmentType { Start, Middle, End };
NalUnitFragmentA(FragmentType type, bool forbiddenBit, uint8_t nri, uint8_t unitType,
binary data);
binary data);
static std::vector<std::shared_ptr<NalUnitFragmentA>> fragmentsFrom(std::shared_ptr<NalUnit> nalu, uint16_t maximumFragmentSize);
static std::vector<std::shared_ptr<NalUnitFragmentA>>
fragmentsFrom(std::shared_ptr<NalUnit> nalu, uint16_t maximumFragmentSize);
uint8_t unitType() { return fragmentHeader()->unitType(); }
@@ -144,7 +143,8 @@ protected:
class RTC_CPP_EXPORT NalUnits : public std::vector<std::shared_ptr<NalUnit>> {
public:
static const uint16_t defaultMaximumFragmentSize;
static const uint16_t defaultMaximumFragmentSize =
uint16_t(RTC_DEFAULT_MTU - 12 - 8 - 40); // SRTP/UDP/IPv6
std::vector<std::shared_ptr<binary>> generateFragments(uint16_t maximumFragmentSize);
};

View File

@@ -27,7 +27,6 @@
#include "init.hpp"
#include "message.hpp"
#include "reliability.hpp"
#include "rtc.hpp"
#include "track.hpp"
#include <chrono>

View File

@@ -39,8 +39,14 @@ extern "C" {
#define RTC_ENABLE_WEBSOCKET 1
#endif
#ifndef RTC_ENABLE_MEDIA
#define RTC_ENABLE_MEDIA 1
#endif
#define RTC_DEFAULT_MTU 1280 // IPv6 minimum guaranteed MTU
#if RTC_ENABLE_MEDIA
#define RTC_DEFAULT_MAXIMUM_FRAGMENT_SIZE ((uint16_t)(1280 - 12 - 8 - 40)) // SRTP/UDP/IPv6
#define RTC_DEFAULT_MAXIMUM_FRAGMENT_SIZE ((uint16_t)(RTC_DEFAULT_MTU - 12 - 8 - 40)) // SRTP/UDP/IPv6
#define RTC_DEFAULT_MAXIMUM_PACKET_COUNT_FOR_NACK_CACHE ((unsigned)512)
#endif
@@ -116,13 +122,14 @@ typedef struct {
bool enableIceTcp;
uint16_t portRangeBegin;
uint16_t portRangeEnd;
int mtu; // <= 0 means automatic
} rtcConfiguration;
typedef struct {
bool unordered;
bool unreliable;
unsigned int maxPacketLifeTime; // ignored if reliable
unsigned int maxRetransmits; // ignored if reliable
int maxPacketLifeTime; // ignored if reliable
int maxRetransmits; // ignored if reliable
} rtcReliability;
typedef struct {

View File

@@ -16,15 +16,25 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
// C API
#include "rtc.h"
// C++ API
#include "common.hpp"
#include "init.hpp" // for rtc::Cleanup()
#include "log.hpp"
//
#include "datachannel.hpp"
#include "track.hpp"
#include "peerconnection.hpp"
#if RTC_ENABLE_WEBSOCKET
// WebSocket
#include "websocket.hpp"
#endif // RTC_ENABLE_WEBSOCKET
#if RTC_ENABLE_MEDIA
// Media handling
@@ -39,5 +49,3 @@
#endif // RTC_ENABLE_MEDIA
// C API
#include "rtc.h"