Handle incoming RTCP reports as raw memory blocks

PACKED_STRUCT is quite an ugly hack if it must be cross-platform
so better to process the incoming (and soon outgoing) RTCP data
as raw memory and craft user-friendly RTCP packets from those
memory blocks which do not including strict padding or truncated fields.
This commit is contained in:
Aaro Altonen 2020-08-26 07:33:02 +03:00
parent 35174d142c
commit 47b17bb1d1
7 changed files with 24 additions and 18 deletions

View File

@ -98,11 +98,11 @@ namespace uvg_rtp {
* querying these reports is implemented
*
* Return RTP_OK on success and RTP_ERROR on error */
rtp_error_t handle_sender_report_packet(uvg_rtp::frame::rtcp_sender_frame *frame, size_t size);
rtp_error_t handle_receiver_report_packet(uvg_rtp::frame::rtcp_receiver_frame *frame, size_t size);
rtp_error_t handle_sdes_packet(uvg_rtp::frame::rtcp_sdes_frame *frame, size_t size);
rtp_error_t handle_bye_packet(uvg_rtp::frame::rtcp_bye_frame *frame, size_t size);
rtp_error_t handle_app_packet(uvg_rtp::frame::rtcp_app_frame *frame, size_t size);
rtp_error_t handle_sender_report_packet(uint8_t *frame, size_t size);
rtp_error_t handle_receiver_report_packet(uint8_t *frame, size_t size);
rtp_error_t handle_sdes_packet(uint8_t *frame, size_t size);
rtp_error_t handle_bye_packet(uint8_t *frame, size_t size);
rtp_error_t handle_app_packet(uint8_t *frame, size_t size);
/* Handle incoming RTCP packet (first make sure it's a valid RTCP packet)
* This function will call one of the above functions internally

View File

@ -479,23 +479,23 @@ rtp_error_t uvg_rtp::rtcp::handle_incoming_packet(uint8_t *buffer, size_t size)
switch (header->pkt_type) {
case uvg_rtp::frame::RTCP_FT_SR:
ret = handle_sender_report_packet((uvg_rtp::frame::rtcp_sender_frame *)buffer, size);
ret = handle_sender_report_packet(buffer, size);
break;
case uvg_rtp::frame::RTCP_FT_RR:
ret = handle_receiver_report_packet((uvg_rtp::frame::rtcp_receiver_frame *)buffer, size);
ret = handle_receiver_report_packet(buffer, size);
break;
case uvg_rtp::frame::RTCP_FT_SDES:
ret = handle_sdes_packet((uvg_rtp::frame::rtcp_sdes_frame *)buffer, size);
ret = handle_sdes_packet(buffer, size);
break;
case uvg_rtp::frame::RTCP_FT_BYE:
ret = handle_bye_packet((uvg_rtp::frame::rtcp_bye_frame *)buffer, size);
ret = handle_bye_packet(buffer, size);
break;
case uvg_rtp::frame::RTCP_FT_APP:
ret = handle_app_packet((uvg_rtp::frame::rtcp_app_frame *)buffer, size);
ret = handle_app_packet(buffer, size);
break;
default:

View File

@ -24,8 +24,9 @@ rtp_error_t uvg_rtp::rtcp::install_app_hook(void (*hook)(uvg_rtp::frame::rtcp_ap
return RTP_OK;
}
rtp_error_t uvg_rtp::rtcp::handle_app_packet(uvg_rtp::frame::rtcp_app_frame *frame, size_t size)
rtp_error_t uvg_rtp::rtcp::handle_app_packet(uint8_t *frame, size_t size)
{
#if 0
if (!frame)
return RTP_INVALID_VALUE;
@ -45,6 +46,7 @@ rtp_error_t uvg_rtp::rtcp::handle_app_packet(uvg_rtp::frame::rtcp_app_frame *fra
else
participants_[frame->ssrc]->app_frame = (uvg_rtp::frame::rtcp_app_frame *)cpy_frame;
#endif
return RTP_OK;
}

View File

@ -4,8 +4,9 @@
#include "rtcp.hh"
rtp_error_t uvg_rtp::rtcp::handle_bye_packet(uvg_rtp::frame::rtcp_bye_frame *frame, size_t size)
rtp_error_t uvg_rtp::rtcp::handle_bye_packet(uint8_t *frame, size_t size)
{
#if 0
(void)size;
if (!frame)
@ -23,6 +24,7 @@ rtp_error_t uvg_rtp::rtcp::handle_bye_packet(uvg_rtp::frame::rtcp_bye_frame *fra
delete participants_[ssrc];
participants_.erase(ssrc);
}
#endif
return RTP_OK;
}

View File

@ -24,11 +24,9 @@ rtp_error_t uvg_rtp::rtcp::install_receiver_hook(void (*hook)(uvg_rtp::frame::rt
return RTP_OK;
}
rtp_error_t uvg_rtp::rtcp::handle_receiver_report_packet(uvg_rtp::frame::rtcp_receiver_frame *frame, size_t size)
rtp_error_t uvg_rtp::rtcp::handle_receiver_report_packet(uint8_t *packet, size_t size)
{
(void)size;
if (!frame)
if (!packet || !size)
return RTP_INVALID_VALUE;
frame->header.length = ntohs(frame->header.length);

View File

@ -24,8 +24,9 @@ rtp_error_t uvg_rtp::rtcp::install_sdes_hook(void (*hook)(uvg_rtp::frame::rtcp_s
return RTP_OK;
}
rtp_error_t uvg_rtp::rtcp::handle_sdes_packet(uvg_rtp::frame::rtcp_sdes_frame *frame, size_t size)
rtp_error_t uvg_rtp::rtcp::handle_sdes_packet(uint8_t *frame, size_t size)
{
#if 0
if (!frame)
return RTP_INVALID_VALUE;
@ -48,6 +49,7 @@ rtp_error_t uvg_rtp::rtcp::handle_sdes_packet(uvg_rtp::frame::rtcp_sdes_frame *f
sdes_hook_((uvg_rtp::frame::rtcp_sdes_frame *)cpy_frame);
else
participants_[frame->sender_ssrc]->sdes_frame = (uvg_rtp::frame::rtcp_sdes_frame *)cpy_frame;
#endif
return RTP_OK;
}

View File

@ -24,8 +24,9 @@ rtp_error_t uvg_rtp::rtcp::install_sender_hook(void (*hook)(uvg_rtp::frame::rtcp
return RTP_OK;
}
rtp_error_t uvg_rtp::rtcp::handle_sender_report_packet(uvg_rtp::frame::rtcp_sender_frame *frame, size_t size)
rtp_error_t uvg_rtp::rtcp::handle_sender_report_packet(uint8_t *frame, size_t size)
{
#if 0
(void)size;
if (!frame)
@ -71,6 +72,7 @@ rtp_error_t uvg_rtp::rtcp::handle_sender_report_packet(uvg_rtp::frame::rtcp_send
else
participants_[frame->sender_ssrc]->s_frame = cpy_frame;
#endif
return RTP_OK;
}