Implement RCC_MTU_SIZE

This commit is contained in:
Aaro Altonen 2021-02-13 04:33:03 +02:00
parent b1ccd7f788
commit 4d561a5b28
3 changed files with 35 additions and 7 deletions

View File

@ -31,9 +31,17 @@ typedef SSIZE_T ssize_t;
typedef int socket_t;
#endif
const int MAX_PACKET = 65536;
const int MAX_PAYLOAD = 1446;
const int PKT_MAX_DELAY = 100;
const int MAX_PACKET = 65536;
const int MAX_PAYLOAD = 1446;
const int PKT_MAX_DELAY = 100;
/* TODO: add ability for user to specify these? */
enum HEADER_SIZES {
ETH_HDR_SIZE = 14,
IPV4_HDR_SIZE = 20,
UDP_HDR_SIZE = 8,
RTP_HDR_SIZE = 12
};
typedef enum RTP_ERROR {
RTP_MULTIPLE_PKTS_READY = 6, /* multiple packets can be queried from the layer */
@ -221,6 +229,16 @@ enum RTP_CTX_CONFIGURATION_FLAGS {
* dynamic payload type for all packets of an RTP stream */
RCC_DYN_PAYLOAD_TYPE = 4,
/* Set a maximum value for the Ethernet frame size assumed by uvgRTP.
*
* Default is 1500, from this Ethernet, IPv4 and UDP, and RTP headers
* are removed from this, giving a payload size of 1446 bytes
*
* If application wishes to use small UDP datagrams for some reason,
* it can set MTU size to, for example, 500 bytes or if it wishes
* to use jumbo frames, it can set the MTU size to 9000 bytes */
RCC_MTU_SIZE = 5,
RCC_LAST
};

View File

@ -625,6 +625,19 @@ rtp_error_t uvg_rtp::media_stream::configure_ctx(int flag, ssize_t value)
}
break;
case RCC_MTU_SIZE: {
size_t hdr = ETH_HDR_SIZE + IPV4_HDR_SIZE + UDP_HDR_SIZE + RTP_HDR_SIZE;
if (ctx_config_.flags & RCE_SRTP_AUTHENTICATE_RTP)
hdr += AUTH_TAG_LENGTH;
if (value <= hdr)
return RTP_INVALID_VALUE;
rtp_->set_payload_size(value - hdr);
}
break;
default:
return RTP_INVALID_VALUE;
}

View File

@ -14,9 +14,6 @@
#include "rtcp.hh"
#include "util.hh"
#define UDP_HEADER_SIZE 8
#define IP_HEADER_SIZE 20
uvg_rtp::rtcp::rtcp(uvg_rtp::rtp *rtp, int flags):
rtp_(rtp), flags_(flags), our_role_(RECEIVER),
tp_(0), tc_(0), tn_(0), pmembers_(0),
@ -187,7 +184,7 @@ rtp_error_t uvg_rtp::rtcp::add_participant(uint32_t ssrc)
void uvg_rtp::rtcp::update_rtcp_bandwidth(size_t pkt_size)
{
rtcp_pkt_count_ += 1;
rtcp_byte_count_ += pkt_size + UDP_HEADER_SIZE + IP_HEADER_SIZE;
rtcp_byte_count_ += pkt_size + UDP_HDR_SIZE + IPV4_HDR_SIZE;
avg_rtcp_pkt_pize_ = rtcp_byte_count_ / rtcp_pkt_count_;
}