From c4de5397fb9923cfd8d2b7a3f13dd4ffcbd703da Mon Sep 17 00:00:00 2001 From: Aaro Altonen Date: Wed, 11 Sep 2019 11:34:12 +0300 Subject: [PATCH] Disable RTP probation zone by default It makes more sense to disable it by default, especially when it's not platform-independent and has negative side effects (larger memory footprint) --- README.md | 3 ++- src/frame.cc | 7 ++++++- src/frame.hh | 6 ++---- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 34f6167..e494825 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,8 @@ Windows Use `__RTP_SILENT__` to disable all prints -Use `__RTP_NO_PROBATION_ZONE__` to disable the probation zone allocation for RTP frames +Use `__RTP_USE_PROBATION_ZONE__` to enable the probation zone allocation for RTP frames +* See src/frame.hh for more details Use `NDEBUG` to disable `LOG_DEBUG` which is the most verbose level of logging diff --git a/src/frame.cc b/src/frame.cc index ed6f554..96d2476 100644 --- a/src/frame.cc +++ b/src/frame.cc @@ -18,7 +18,10 @@ kvz_rtp::frame::rtp_frame *kvz_rtp::frame::alloc_rtp_frame() std::memset(frame, 0, sizeof(kvz_rtp::frame::rtp_frame)); frame->payload = nullptr; + +#if defined(__linux__) && defined(__RTP_USE_PROBATION_ZONE__) frame->probation = nullptr; +#endif return frame; } @@ -30,7 +33,7 @@ kvz_rtp::frame::rtp_frame *kvz_rtp::frame::alloc_rtp_frame(size_t payload_len) if ((frame = kvz_rtp::frame::alloc_rtp_frame()) == nullptr) return nullptr; -#if defined(__linux__) && !defined(__RTP_NO_PROBATION_ZONE__) +#if defined(__linux__) && defined(__RTP_USE_PROBATION_ZONE__) frame->probation = new uint8_t[PROBATION_MAX_PKTS * MAX_PAYLOAD + payload_len]; frame->probation_len = PROBATION_MAX_PKTS * MAX_PAYLOAD; frame->probation_off = 0; @@ -56,8 +59,10 @@ rtp_error_t kvz_rtp::frame::dealloc_frame(kvz_rtp::frame::rtp_frame *frame) if (frame->ext) delete frame->ext; +#if defined(__linux__) && defined(__RTP_USE_PROBATION_ZONE__) if (frame->probation) delete[] frame->probation; +#endif else if (frame->payload) delete[] frame->payload; diff --git a/src/frame.hh b/src/frame.hh index 6564cc7..7102b15 100644 --- a/src/frame.hh +++ b/src/frame.hh @@ -62,7 +62,7 @@ namespace kvz_rtp { size_t padding_len; /* non-zero if frame is padded */ size_t payload_len; /* payload_len: total_len - header_len - padding length (if padded) */ -#if defined(__linux__) && !defined(__RTP_NO_PROBATION_ZONE__) +#if defined(__linux__) && defined(__RTP_USE_PROBATION_ZONE__) /* Probation zone is a small area of free-to-use memory for the frame receiver * when handling fragments. For example HEVC fragments that belong to future frames * but cannot be relocated there (start sequence missing) are copied to probation @@ -71,9 +71,7 @@ namespace kvz_rtp { * NOTE 1: Probation zone will increase the memory usage and will increase * the internal fragmentation as this memory is not usable for anything else * - * NOTE 2: This is a Linux-only optimization - * - * Use -D__RTP_NO_PROBATION_ZONE__ to disable the optimization */ + * NOTE 2: This is a Linux-only optimization */ size_t probation_len; size_t probation_off; uint8_t *probation;