common: Disable user packets for now

This commit is contained in:
Heikki Tampio 2023-08-02 13:46:45 +03:00
parent 6ec8880760
commit ecf65ba5b0
8 changed files with 20 additions and 77 deletions

View File

@ -290,44 +290,10 @@ namespace uvgrtp {
*/
rtp_error_t push_frame(std::unique_ptr<uint8_t[]> 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
*

View File

@ -371,18 +371,6 @@ namespace uvgrtp {
*/
rtp_error_t install_app_hook(std::function<void(std::unique_ptr<uvgrtp::frame::rtcp_app_packet>)> 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<void(std::unique_ptr<uvgrtp::frame::rtcp_fb_packet>)> 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<void(std::shared_ptr<uvgrtp::frame::rtcp_sender_report>)> sr_handler);

View File

@ -644,10 +644,10 @@ rtp_error_t uvgrtp::media_stream::push_frame(std::unique_ptr<uint8_t[]> 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()
{

View File

@ -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<uvgrtp::socket> 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;

View File

@ -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);

View File

@ -691,19 +691,6 @@ rtp_error_t uvgrtp::rtcp::install_app_hook(std::function<void(std::unique_ptr<uv
return RTP_OK;
}
rtp_error_t uvgrtp::rtcp::install_fb_hook(std::function<void(std::unique_ptr<uvgrtp::frame::rtcp_fb_packet>)> 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<std::mutex> prtcp_lock(participants_mutex_);

View File

@ -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);
}
}*/

View File

@ -111,12 +111,12 @@ inline void send_packets(std::unique_ptr<uint8_t[]> 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;