multiplex: Add RTCP common handler
This commit is contained in:
parent
2d3451c9df
commit
c145213756
|
@ -418,6 +418,7 @@ namespace uvgrtp {
|
|||
/* Update RTCP-related receiver statistics */
|
||||
static rtp_error_t recv_packet_handler(void *arg, int rce_flags, frame::rtp_frame **out);
|
||||
rtp_error_t new_recv_packet_handler(void* args, int rce_flags, uint8_t* read_ptr, size_t size, frame::rtp_frame** out);
|
||||
rtp_error_t new_recv_packet_handler_common(void* args, int rce_flags, uint8_t* read_ptr, size_t size, frame::rtp_frame** out);
|
||||
|
||||
/* Update RTCP-related sender statistics */
|
||||
static rtp_error_t send_packet_handler_vec(void *arg, uvgrtp::buf_vec& buffers);
|
||||
|
|
|
@ -337,6 +337,12 @@ rtp_error_t uvgrtp::media_stream::init()
|
|||
|
||||
if (rce_flags_ & RCE_RTCP_MUX) {
|
||||
rtcp_->set_socket(socket_);
|
||||
|
||||
reception_flow_->new_install_handler(
|
||||
6, remote_ssrc_,
|
||||
std::bind(&uvgrtp::rtcp::new_recv_packet_handler_common, rtcp_, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3,
|
||||
std::placeholders::_4, std::placeholders::_5), rtcp_.get());
|
||||
|
||||
reception_flow_->new_install_handler(
|
||||
2, remote_ssrc_,
|
||||
std::bind(&uvgrtp::rtcp::new_recv_packet_handler, rtcp_, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3,
|
||||
|
|
|
@ -351,6 +351,11 @@ rtp_error_t uvgrtp::reception_flow::new_install_handler(int type, std::shared_pt
|
|||
NEW_packet_handlers_[remote_ssrc].handler_media.args = args;
|
||||
break;
|
||||
}
|
||||
case 6: {
|
||||
NEW_packet_handlers_[remote_ssrc].handler_rtcp_common.handler = handler;
|
||||
NEW_packet_handlers_[remote_ssrc].handler_rtcp_common.args = args;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
UVG_LOG_ERROR("Invalid type, only types 1-5 are allowed");
|
||||
break;
|
||||
|
@ -617,7 +622,7 @@ void uvgrtp::reception_flow::process_packet(int rce_flags)
|
|||
/* -------------------- RTCP check -------------------- */
|
||||
if (rce_flags & RCE_RTCP_MUX) {
|
||||
uint8_t pt = (uint8_t)ptr[1];
|
||||
//UVG_LOG_DEBUG("Received frame with pt %u", pt);
|
||||
UVG_LOG_DEBUG("Received frame with pt %u", pt);
|
||||
if (pt >= 200 && pt <= 204) {
|
||||
retval = handlers->handler_rtcp.handler(nullptr, rce_flags, &ptr[0], size, &frame);
|
||||
break;
|
||||
|
@ -643,7 +648,10 @@ void uvgrtp::reception_flow::process_packet(int rce_flags)
|
|||
if (retval == RTP_PKT_MODIFIED) {
|
||||
retval = handlers->handler_rtp.handler(nullptr, rce_flags, &ptr[0], size, &frame);
|
||||
}
|
||||
|
||||
// RTCP common handler
|
||||
if (rce_flags & RCE_RTCP) {
|
||||
retval = handlers->handler_rtcp_common.handler(handlers->handler_rtcp_common.args, rce_flags, &ptr[0], size, &frame);
|
||||
}
|
||||
if (retval == RTP_PKT_MODIFIED) {
|
||||
retval = handlers->handler_media.handler(handlers->handler_media.args, rce_flags, &ptr[0], size, &frame);
|
||||
if (retval == RTP_PKT_READY) {
|
||||
|
|
|
@ -73,6 +73,7 @@ namespace uvgrtp {
|
|||
renamethis_handler handler_zrtp;
|
||||
renamethis_handler handler_srtp;
|
||||
renamethis_handler handler_media;
|
||||
renamethis_handler handler_rtcp_common;
|
||||
std::function<rtp_error_t(uvgrtp::frame::rtp_frame ** out)> getter;
|
||||
};
|
||||
|
||||
|
@ -139,6 +140,7 @@ namespace uvgrtp {
|
|||
3 zrtp
|
||||
4 srtp
|
||||
5 media
|
||||
6 rtcp common
|
||||
getter can be nullptr if there is no getter (for media handlers mostly)
|
||||
*/
|
||||
rtp_error_t new_install_handler(int type, std::shared_ptr<std::atomic<std::uint32_t>> remote_ssrc,
|
||||
|
|
|
@ -1033,10 +1033,14 @@ void uvgrtp::rtcp::update_session_statistics(const uvgrtp::frame::rtp_frame *fra
|
|||
|
||||
rtp_error_t uvgrtp::rtcp::new_recv_packet_handler(void* args, int rce_flags, uint8_t* read_ptr, size_t size, frame::rtp_frame** out)
|
||||
{
|
||||
//UVG_LOG_INFO("RTCP packet handled from %u", remote_ssrc_.get()->load());
|
||||
UVG_LOG_INFO("RTCP packet handled from %u", remote_ssrc_.get()->load());
|
||||
return handle_incoming_packet(read_ptr, size);
|
||||
}
|
||||
|
||||
rtp_error_t uvgrtp::rtcp::new_recv_packet_handler_common(void* args, int rce_flags, uint8_t* read_ptr, size_t size, frame::rtp_frame** out)
|
||||
{
|
||||
return recv_packet_handler(args, rce_flags, out);
|
||||
}
|
||||
|
||||
/* RTCP packet handler is responsible for doing two things:
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue