From ecf65ba5b0a0d67ebfd71d023e1f9c62eb48274d Mon Sep 17 00:00:00 2001 From: Heikki Tampio Date: Wed, 2 Aug 2023 13:46:45 +0300 Subject: [PATCH] common: Disable user packets for now --- include/uvgrtp/media_stream.hh | 40 +++------------------------------- include/uvgrtp/rtcp.hh | 12 ---------- src/media_stream.cc | 6 ++--- src/reception_flow.cc | 13 ++++++----- src/reception_flow.hh | 5 +++-- src/rtcp.cc | 13 ----------- test/test_2_rtp.cpp | 4 ++-- test/test_common.hh | 4 ++-- 8 files changed, 20 insertions(+), 77 deletions(-) diff --git a/include/uvgrtp/media_stream.hh b/include/uvgrtp/media_stream.hh index 9721549..4e66dac 100644 --- a/include/uvgrtp/media_stream.hh +++ b/include/uvgrtp/media_stream.hh @@ -290,44 +290,10 @@ namespace uvgrtp { */ rtp_error_t push_frame(std::unique_ptr data, size_t data_len, uint32_t ts, uint64_t ntp_ts, int rtp_flags); - /** - * \brief Send a custom UDP packet to the specified address - * - * \details - * - * \param data Pointer to data the that should be sent - * \param len Length of data - * \param Remote_address IPv4 or IPv6 address of the remote participant - * \param port Port number of the remote participant - * - * \return RTP error code - * - * \retval RTP_OK On success - * \retval RTP_SEND_ERROR If uvgRTP failed to send the data to remote - * \retval RTP_GENERIC_ERROR If an unspecified error occurred - */ - rtp_error_t push_user_packet(uint8_t* data, uint32_t len); - - /** - * \brief Asynchronous way of getting user frames - * - * \details When a user hook is installed, uvgRTP will notify - * the application when user frames are received. - * - * The hook should not be used for frame processing as it will block the receiver from - * reading more frames. Instead, it should only be used as an interface between uvgRTP and - * the calling application where the frame hand-off happens. - * - * \param arg Optional argument that is passed to the hook when it is called, can be set to nullptr - * \param hook Function pointer to the receive hook that uvgRTP should call - * - * \return RTP error code - * - * \retval RTP_OK On success - * \retval RTP_INVALID_VALUE If hook is nullptr */ - rtp_error_t install_user_receive_hook(void* arg, void (*hook)(void*, uint8_t* data, uint32_t len)); + // Disabled for now + //rtp_error_t push_user_packet(uint8_t* data, uint32_t len); + //rtp_error_t install_user_receive_hook(void* arg, void (*hook)(void*, uint8_t* data, uint32_t len)); - /** * \brief Poll a frame indefinitely from the media stream object * diff --git a/include/uvgrtp/rtcp.hh b/include/uvgrtp/rtcp.hh index 58577b4..033fbd3 100644 --- a/include/uvgrtp/rtcp.hh +++ b/include/uvgrtp/rtcp.hh @@ -371,18 +371,6 @@ namespace uvgrtp { */ rtp_error_t install_app_hook(std::function)> app_handler); - /** - * \brief Install an RTCP FB packet hook - * - * \details This function is called when an RTCP FB (RFC 4585 section 6.1) packet is received - * - * \param app_handler C++ function pointer to the hook - * - * \retval RTP_OK on success - * \retval RTP_INVALID_VALUE If hook is nullptr - */ - rtp_error_t install_fb_hook(std::function)> fb_handler); - /// \cond DO_NOT_DOCUMENT // These have been replaced by functions with unique_ptr in them rtp_error_t install_sender_hook(std::function)> sr_handler); diff --git a/src/media_stream.cc b/src/media_stream.cc index 35ab3c4..095c746 100644 --- a/src/media_stream.cc +++ b/src/media_stream.cc @@ -644,10 +644,10 @@ rtp_error_t uvgrtp::media_stream::push_frame(std::unique_ptr data, si return ret; } - +/* Disabled for now rtp_error_t uvgrtp::media_stream::push_user_packet(uint8_t* data, uint32_t len) { - if (rce_flags_ && RCE_RECEIVE_ONLY) { + if (rce_flags_ & RCE_RECEIVE_ONLY) { UVG_LOG_WARN("Cannot send user packets from a RECEIVE_ONLY stream"); return RTP_SEND_ERROR; } @@ -675,7 +675,7 @@ rtp_error_t uvgrtp::media_stream::install_user_receive_hook(void* arg, void (*ho return reception_flow_->install_user_hook(arg, hook);; -} +}*/ uvgrtp::frame::rtp_frame *uvgrtp::media_stream::pull_frame() { diff --git a/src/reception_flow.cc b/src/reception_flow.cc index 22c047c..fb9bae1 100644 --- a/src/reception_flow.cc +++ b/src/reception_flow.cc @@ -388,6 +388,7 @@ void uvgrtp::reception_flow::return_frame(uvgrtp::frame::rtp_frame *frame) frames_mtx_.unlock(); } } +/* User packets disabled for now rtp_error_t uvgrtp::reception_flow::install_user_hook(void* arg, void (*hook)(void*, uint8_t* data, uint32_t len)) { if (!hook) @@ -413,7 +414,7 @@ void uvgrtp::reception_flow::return_user_pkt(uint8_t* pkt, uint32_t len) UVG_LOG_DEBUG("No user hook installed"); } } - +*/ void uvgrtp::reception_flow::receiver(std::shared_ptr socket) { int read_packets = 0; @@ -573,7 +574,7 @@ void uvgrtp::reception_flow::process_packet(int rce_flags) * 2. Version 0 and Magic Cookie is 0x5a525450 -> ZRTP packet * 3. Version is 2 -> RTP packet (or SRTP) * 4. Version is 3 -> Keep-Alive/Holepuncher - * 5. Otherwise -> User packet */ + * 5. Otherwise -> User packet, DISABLED */ if (rtcp_pkt && (rce_flags & RCE_RTCP_MUX)) { uint8_t pt = (uint8_t)ptr[1]; // Packet type if (pt >= 200 && pt <= 204) { @@ -637,18 +638,18 @@ void uvgrtp::reception_flow::process_packet(int rce_flags) else if (version == 0x3) { UVG_LOG_DEBUG("Holepuncher packet"); } - else { + /* DISABLED else { return_user_pkt(&ptr[0], (uint32_t)size); - } + }*/ } else { /* No SSRC match found -> Holepuncher or user packet */ if (version == 0x3) { UVG_LOG_DEBUG("Holepuncher packet"); } - else { + /* DISABLED else { return_user_pkt(&ptr[0], (uint32_t)size); - } + }*/ } // to make sure we don't process this packet again ring_buffer_[ring_read_index_].read = 0; diff --git a/src/reception_flow.hh b/src/reception_flow.hh index 65a239d..a38c8d2 100644 --- a/src/reception_flow.hh +++ b/src/reception_flow.hh @@ -78,6 +78,7 @@ namespace uvgrtp { * each reception_flow object will have just a single set of packet handlers * and all packets are given to these. * + * ---- NOTE: User packets disabled for now ---- * If there is no valid SSRC to be found in the received packet's header, the * packet is assumed to be a user packet, in which case it is handed over to * a user packet handler, provided that there is one installed. */ @@ -157,7 +158,7 @@ namespace uvgrtp { void set_poll_timeout_ms(int timeout_ms); int get_poll_timeout_ms(); - rtp_error_t install_user_hook(void* arg, void (*hook)(void*, uint8_t* data, uint32_t len)); + // DISABLED rtp_error_t install_user_hook(void* arg, void (*hook)(void*, uint8_t* data, uint32_t len)); /// \endcond private: @@ -170,7 +171,7 @@ namespace uvgrtp { /* Return a processed RTP frame to user either through frame queue or receive hook */ void return_frame(uvgrtp::frame::rtp_frame *frame); - void return_user_pkt(uint8_t* pkt, uint32_t len); + //void return_user_pkt(uint8_t* pkt, uint32_t len); inline void increase_buffer_size(ssize_t next_write_index); diff --git a/src/rtcp.cc b/src/rtcp.cc index 6d245f6..0437b4e 100644 --- a/src/rtcp.cc +++ b/src/rtcp.cc @@ -691,19 +691,6 @@ rtp_error_t uvgrtp::rtcp::install_app_hook(std::function)> fb_handler) -{ - if (!fb_handler) - { - return RTP_INVALID_VALUE; - } - fb_mutex_.lock(); - fb_hook_u_ = fb_handler; - fb_mutex_.unlock(); - - return RTP_OK; -} - uvgrtp::frame::rtcp_sender_report* uvgrtp::rtcp::get_sender_packet(uint32_t ssrc) { std::lock_guard prtcp_lock(participants_mutex_); diff --git a/test/test_2_rtp.cpp b/test/test_2_rtp.cpp index 406ae1e..c9cee1c 100644 --- a/test/test_2_rtp.cpp +++ b/test/test_2_rtp.cpp @@ -653,7 +653,7 @@ TEST(RTPTests, rtp_multiplex_poll) cleanup_sess(ctx, sender_sess); cleanup_sess(ctx, receiver_sess); } - +/* User packets disabled for now TEST(RTPTests, uvgrtp_user_frames) { // Tests sending and receiving custom UDP packets @@ -688,4 +688,4 @@ TEST(RTPTests, uvgrtp_user_frames) cleanup_ms(sess, sender); cleanup_ms(sess, receiver); cleanup_sess(ctx, sess); -} \ No newline at end of file +}*/ \ No newline at end of file diff --git a/test/test_common.hh b/test/test_common.hh index 503ae35..565ae98 100644 --- a/test/test_common.hh +++ b/test/test_common.hh @@ -111,12 +111,12 @@ inline void send_packets(std::unique_ptr test_packet, size_t size, const char* data = "ABCD"; sender->get_rtcp()->send_app_packet("Test", 1, 4, (uint8_t*)data); } - + /* User packets disabled for now if (i % 4 == 0 && user) { uint8_t data[5] = {20, 25, 30, 35, 40}; uint8_t* ptr = &data[0]; sender->push_user_packet(ptr, 5); - } + }*/ rtp_error_t ret = RTP_OK;