Skip to content
Snippets Groups Projects
Commit 5f78b14b authored by Guillaume Roguez's avatar Guillaume Roguez Committed by Adrien Béraud
Browse files

tweak jitter-buffers values

Increase jitter-buffers size/delay in TLS and RTP channels.
Gives better results on high-latency connections (i.e. with TURN enabled).

Note: also refactor RTP constants coding to be more easier to tweak.

Change-Id: Ia4cb78306465e2385a52728629942b4d07330f13
parent 07b523bf
Branches
Tags
No related merge requests found
......@@ -39,9 +39,15 @@
#include <iostream>
#include <unistd.h>
#include <thread> // hardware_concurrency
#include <chrono>
namespace ring {
// maximum number of packets the jitter buffer can queue
const unsigned jitterBufferMaxSize_ {5000};
// maximum time a packet can be queued
const constexpr auto jitterBufferMaxDelay_ = std::chrono::milliseconds(1500);
MediaDecoder::MediaDecoder() :
inputCtx_(avformat_alloc_context()),
startTime_(AV_NOPTS_VALUE)
......@@ -88,7 +94,8 @@ int MediaDecoder::openInput(const DeviceParams& params)
// Set jitter buffer options
av_dict_set(&options_, "reorder_queue_size",ring::to_string(jitterBufferMaxSize_).c_str(), 0);
av_dict_set(&options_, "max_delay",ring::to_string(jitterBufferMaxDelay_).c_str(), 0);
auto us = std::chrono::duration_cast<std::chrono::microseconds>(jitterBufferMaxDelay_).count();
av_dict_set(&options_, "max_delay",ring::to_string(us).c_str(), 0);
if(!params.pixel_format.empty()){
av_dict_set(&options_, "pixel_format", params.pixel_format.c_str(), 0);
......
......@@ -118,12 +118,6 @@ class MediaDecoder {
void extract(const std::map<std::string, std::string>& map, const std::string& key);
int correctPixFmt(int input_pix_fmt);
// Jitter buffer options: they are default values set in libav
// maximum of packet jitter buffer can queue
const unsigned jitterBufferMaxSize_ {1500};
// maximum time a packet can be queued (in us)
const unsigned jitterBufferMaxDelay_ {1000000};
#ifdef RING_ACCEL
bool enableAccel_ = true;
std::unique_ptr<video::HardwareAccel> accel_;
......
......@@ -58,7 +58,7 @@ static constexpr uint8_t HEARTBEAT_RETRIES = 1; // Number of tries at each heart
static constexpr auto HEARTBEAT_RETRANS_TIMEOUT = std::chrono::milliseconds(700); // gnutls heartbeat retransmission timeout for each ping (in milliseconds)
static constexpr auto HEARTBEAT_TOTAL_TIMEOUT = HEARTBEAT_RETRANS_TIMEOUT * HEARTBEAT_RETRIES; // gnutls heartbeat time limit for heartbeat procedure (in milliseconds)
static constexpr int MISS_ORDERING_LIMIT = 32; // maximal accepted distance of out-of-order packet (note: must be a signed type)
static constexpr auto RX_OOO_TIMEOUT = std::chrono::milliseconds(500);
static constexpr auto RX_OOO_TIMEOUT = std::chrono::milliseconds(1500);
// mtus array to test, do not add mtu over the interface MTU, this will result in false result due to packet fragmentation.
// also do not set over 16000 this will result in a gnutls error (unexpected packet size)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment