multiplex: Add ability to set RCC_SSRC and RCC_REMOTE_SSRC before stream is initialized
Also add body for add_zrtp_ctx() in media_stream
This commit is contained in:
parent
01d84f303a
commit
985a33d043
|
@ -94,6 +94,24 @@ namespace uvgrtp {
|
|||
* \retval RTP_NOT_SUPPORTED If user-managed SRTP was not specified in create_stream() */
|
||||
rtp_error_t add_srtp_ctx(uint8_t *key, uint8_t *salt);
|
||||
|
||||
/**
|
||||
*
|
||||
* \brief Add keying information for user-managed SRTP session
|
||||
*
|
||||
* \details For user-managed SRTP session (flag RCE_SRTP_KMNGMNT_USER),
|
||||
* the media stream is not started until SRTP key has been added and all calls
|
||||
* to push_frame() will fail.
|
||||
*
|
||||
* \param key SRTP master key, default is 128-bit long
|
||||
* \param salt 112-bit long salt
|
||||
*
|
||||
* \return RTP error code
|
||||
*
|
||||
* \retval RTP_OK On success
|
||||
* \retval RTP_INVALID_VALUE If key or salt is invalid
|
||||
* \retval RTP_NOT_SUPPORTED If user-managed SRTP was not specified in create_stream() */
|
||||
rtp_error_t add_zrtp_ctx();
|
||||
|
||||
/**
|
||||
* \brief Send data to remote participant with a custom timestamp
|
||||
*
|
||||
|
|
|
@ -376,11 +376,17 @@ rtp_error_t uvgrtp::media_stream::add_srtp_ctx(uint8_t *key, uint8_t *salt)
|
|||
UVG_LOG_ERROR("Failed to initialize the underlying socket");
|
||||
return free_resources(RTP_GENERIC_ERROR);
|
||||
}
|
||||
if (!new_socket_) {
|
||||
reception_flow_ = sfp_->get_reception_flow_ptr(socket_);
|
||||
}
|
||||
else {
|
||||
reception_flow_ = sfp_->install_reception_flow(socket_);
|
||||
}
|
||||
|
||||
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());
|
||||
//reception_flow_ = std::unique_ptr<uvgrtp::reception_flow> (new uvgrtp::reception_flow());
|
||||
|
||||
rtp_ = std::shared_ptr<uvgrtp::rtp> (new uvgrtp::rtp(fmt_, ssrc_, ipv6_));
|
||||
|
||||
|
@ -405,6 +411,7 @@ rtp_error_t uvgrtp::media_stream::add_srtp_ctx(uint8_t *key, uint8_t *salt)
|
|||
socket_->install_handler(srtp_.get(), srtp_->send_packet_handler);
|
||||
|
||||
rtp_handler_key_ = reception_flow_->install_handler(rtp_->packet_handler);
|
||||
reception_flow_->map_handler_key(rtp_handler_key_, remote_ssrc_);
|
||||
|
||||
reception_flow_->install_aux_handler(rtp_handler_key_, rtcp_.get(), rtcp_->recv_packet_handler, nullptr);
|
||||
reception_flow_->install_aux_handler(rtp_handler_key_, srtp_.get(), srtp_->recv_packet_handler, nullptr);
|
||||
|
@ -412,6 +419,22 @@ rtp_error_t uvgrtp::media_stream::add_srtp_ctx(uint8_t *key, uint8_t *salt)
|
|||
return start_components();
|
||||
}
|
||||
|
||||
rtp_error_t uvgrtp::media_stream::add_zrtp_ctx()
|
||||
{
|
||||
if (init_connection() != RTP_OK) {
|
||||
log_platform_error("Failed to initialize the underlying socket");
|
||||
return RTP_GENERIC_ERROR;
|
||||
}
|
||||
if (!new_socket_) {
|
||||
reception_flow_ = sfp_->get_reception_flow_ptr(socket_);
|
||||
}
|
||||
else {
|
||||
reception_flow_ = sfp_->install_reception_flow(socket_);
|
||||
}
|
||||
|
||||
return start_components();
|
||||
}
|
||||
|
||||
rtp_error_t uvgrtp::media_stream::start_components()
|
||||
{
|
||||
if (create_media(fmt_) != RTP_OK)
|
||||
|
@ -674,13 +697,28 @@ rtp_error_t uvgrtp::media_stream::install_receive_hook(void *arg, void (*hook)(v
|
|||
|
||||
rtp_error_t uvgrtp::media_stream::configure_ctx(int rcc_flag, ssize_t value)
|
||||
{
|
||||
rtp_error_t ret = RTP_OK;
|
||||
|
||||
if (rcc_flag == RCC_SSRC) {
|
||||
if (value <= 0 || value > (ssize_t)UINT32_MAX)
|
||||
return RTP_INVALID_VALUE;
|
||||
|
||||
*ssrc_ = (uint32_t)value;
|
||||
return ret;
|
||||
}
|
||||
else if (rcc_flag == RCC_REMOTE_SSRC) {
|
||||
if (value <= 0 || value > (ssize_t)UINT32_MAX)
|
||||
return RTP_INVALID_VALUE;
|
||||
|
||||
*remote_ssrc_ = (uint32_t)value;
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (!initialized_) {
|
||||
UVG_LOG_ERROR("RTP context has not been initialized fully, cannot continue!");
|
||||
return RTP_NOT_INITIALIZED;
|
||||
}
|
||||
|
||||
rtp_error_t ret = RTP_OK;
|
||||
|
||||
switch (rcc_flag) {
|
||||
case RCC_UDP_SND_BUF_SIZE: {
|
||||
if (value <= 0)
|
||||
|
|
Loading…
Reference in New Issue