multiplex: Install packets handlers also when using ZRTP

This commit is contained in:
Heikki Tampio 2023-06-15 14:13:09 +03:00
parent 088651de14
commit a10fe59259
3 changed files with 22 additions and 10 deletions

View File

@ -78,10 +78,7 @@ uvgrtp::media_stream::~media_stream()
rtcp_->stop();
}
// Clear this media stream from the reception_flow
if (reception_flow_ && zrtp_handler_key_ != 0) {
reception_flow_->clear_stream_from_flow(remote_ssrc_, zrtp_handler_key_);
}
if ( reception_flow_ && (reception_flow_->clear_stream_from_flow(remote_ssrc_, rtp_handler_key_)) == 1) {
if ( reception_flow_ && (reception_flow_->clear_stream_from_flow(remote_ssrc_)) == 1) {
reception_flow_->stop();
if (sfp_) {
sfp_->clear_port(src_port_, socket_);
@ -394,9 +391,27 @@ rtp_error_t uvgrtp::media_stream::init(std::shared_ptr<uvgrtp::zrtp> zrtp)
socket_->install_handler(rtcp_.get(), rtcp_->send_packet_handler_vec);
socket_->install_handler(srtp_.get(), srtp_->send_packet_handler);
reception_flow_->new_install_handler(
1, remote_ssrc_,
std::bind(&uvgrtp::rtp::new_packet_handler, rtp_, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3,
std::placeholders::_4, std::placeholders::_5),
nullptr);
if (rce_flags_ & RCE_RTCP) {
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());
}
if (rce_flags_ & RCE_RTCP_MUX) {
rtcp_->set_socket(socket_);
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,
std::placeholders::_4, std::placeholders::_5), nullptr);
}
return start_components();
}
@ -417,8 +432,6 @@ rtp_error_t uvgrtp::media_stream::add_srtp_ctx(uint8_t *key, uint8_t *salt)
if ((rce_flags_ & srtp_rce_flags) != srtp_rce_flags)
return free_resources(RTP_NOT_SUPPORTED);
//reception_flow_ = std::unique_ptr<uvgrtp::reception_flow> (new uvgrtp::reception_flow());
rtp_ = std::shared_ptr<uvgrtp::rtp> (new uvgrtp::rtp(fmt_, ssrc_, ipv6_));
srtp_ = std::shared_ptr<uvgrtp::srtp> (new uvgrtp::srtp(rce_flags_));

View File

@ -688,7 +688,7 @@ void uvgrtp::reception_flow::increase_buffer_size(ssize_t next_write_index)
}
}
int uvgrtp::reception_flow::clear_stream_from_flow(std::shared_ptr<std::atomic<std::uint32_t>> remote_ssrc, uint32_t handler_key)
int uvgrtp::reception_flow::clear_stream_from_flow(std::shared_ptr<std::atomic<std::uint32_t>> remote_ssrc)
{
// Clear all the data structures
if (hooks_.find(remote_ssrc) != hooks_.end()) {

View File

@ -119,7 +119,6 @@ namespace uvgrtp {
rtp_error_t new_remove_handlers(std::shared_ptr<std::atomic<std::uint32_t>> remote_ssrc);
/* Install receive hook in reception flow
*
* Return RTP_OK on success
* Return RTP_INVALID_VALUE if "hook" is nullptr */
rtp_error_t install_receive_hook(void *arg, void (*hook)(void *, uvgrtp::frame::rtp_frame *), std::shared_ptr<std::atomic<std::uint32_t>> remote_ssrc);
@ -150,13 +149,13 @@ namespace uvgrtp {
uvgrtp::frame::rtp_frame* pull_frame(std::shared_ptr<std::atomic<std::uint32_t>> remote_ssrc);
uvgrtp::frame::rtp_frame* pull_frame(ssize_t timeout_ms, std::shared_ptr<std::atomic<std::uint32_t>> remote_ssrc);
/* Clear the packet handlers associated with this handler key from the reception_flow
/* Clear the packet handlers associated with this REMOTE SSRC
* Also clear the hooks associated with this remote_ssrc
*
* Return 1 if the hooks and handlers were cleared and there is no hooks or handlers left in
* this reception_flow -> the flow can be safely deleted if wanted
* Return 0 if the hooks and handlers were removed but there is still others left in this reception_flow */
int clear_stream_from_flow(std::shared_ptr<std::atomic<std::uint32_t>> remote_ssrc, uint32_t handler_key);
int clear_stream_from_flow(std::shared_ptr<std::atomic<std::uint32_t>> remote_ssrc);
/// \cond DO_NOT_DOCUMENT
void set_buffer_size(const ssize_t& value);