common: Rename all flags to distinguish between types

I've already created one bug by not being able to distinguish between
different flags. uvgRTP has four types of flags: enable, context, rtp
and socket. I'm planning on adding one more flag type which makes this
a good point to rename all flags.
This commit is contained in:
Joni Räsänen 2022-08-23 09:47:07 +03:00
parent 4e12422d22
commit f9a89f7408
39 changed files with 302 additions and 295 deletions

View File

@ -40,8 +40,9 @@ namespace uvgrtp {
class media_stream {
public:
/// \cond DO_NOT_DOCUMENT
media_stream(std::string cname, std::string addr, int src_port, int dst_port, rtp_format_t fmt, int flags);
media_stream(std::string cname, std::string remote_addr, std::string local_addr, int src_port, int dst_port, rtp_format_t fmt, int flags);
media_stream(std::string cname, std::string addr, int src_port, int dst_port, rtp_format_t fmt, int rce_flags);
media_stream(std::string cname, std::string remote_addr, std::string local_addr, int src_port, int dst_port,
rtp_format_t fmt, int rce_flags);
~media_stream();
/* Initialize traditional RTP session
@ -98,7 +99,7 @@ namespace uvgrtp {
*
* \param data Pointer to data the that should be sent
* \param data_len Length of data
* \param flags Optional flags, see ::RTP_FLAGS for more details
* \param rtp_flags Optional flags, see ::RTP_FLAGS for more details
*
* \return RTP error code
*
@ -108,7 +109,7 @@ namespace uvgrtp {
* \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_frame(uint8_t *data, size_t data_len, int flags);
rtp_error_t push_frame(uint8_t *data, size_t data_len, int rtp_flags);
/**
* \brief Send data to remote participant with a custom timestamp
@ -122,7 +123,7 @@ namespace uvgrtp {
*
* \param data Smart pointer to data the that should be sent
* \param data_len Length of data
* \param flags Optional flags, see ::RTP_FLAGS for more details
* \param rtp_flags Optional flags, see ::RTP_FLAGS for more details
*
* \return RTP error code
*
@ -132,7 +133,7 @@ namespace uvgrtp {
* \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_frame(std::unique_ptr<uint8_t[]> data, size_t data_len, int flags);
rtp_error_t push_frame(std::unique_ptr<uint8_t[]> data, size_t data_len, int rtp_flags);
/**
* \brief Send data to remote participant with a custom timestamp
@ -153,7 +154,7 @@ namespace uvgrtp {
* \param data Pointer to data the that should be sent
* \param data_len Length of data
* \param ts 32-bit timestamp value for the data
* \param flags Optional flags, see ::RTP_FLAGS for more details
* \param rtp_flags Optional flags, see ::RTP_FLAGS for more details
*
* \return RTP error code
*
@ -163,7 +164,7 @@ namespace uvgrtp {
* \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_frame(uint8_t *data, size_t data_len, uint32_t ts, int flags);
rtp_error_t push_frame(uint8_t *data, size_t data_len, uint32_t ts, int rtp_flags);
/**
* \brief Send data to remote participant with a custom timestamp
@ -184,7 +185,7 @@ namespace uvgrtp {
* \param data Smart pointer to data the that should be sent
* \param data_len Length of data
* \param ts 32-bit timestamp value for the data
* \param flags Optional flags, see ::RTP_FLAGS for more details
* \param rtp_flags Optional flags, see ::RTP_FLAGS for more details
*
* \return RTP error code
*
@ -194,7 +195,7 @@ namespace uvgrtp {
* \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_frame(std::unique_ptr<uint8_t[]> data, size_t data_len, uint32_t ts, int flags);
rtp_error_t push_frame(std::unique_ptr<uint8_t[]> data, size_t data_len, uint32_t ts, int rtp_flags);
/**
* \brief Poll a frame indefinitely from the media stream object
@ -272,7 +273,7 @@ namespace uvgrtp {
* \retval RTP_INVALID_VALUE If the provided configuration flag is not supported
* \retval RTP_GENERIC_ERROR If setsockopt(2) failed
*/
rtp_error_t configure_ctx(int flag, ssize_t value);
rtp_error_t configure_ctx(int rcc_flag, ssize_t value);
/// \cond DO_NOT_DOCUMENT
/* Setter and getter for media-specific config that can be used f.ex with Opus */
@ -312,7 +313,7 @@ namespace uvgrtp {
/* free all allocated resources */
rtp_error_t free_resources(rtp_error_t ret);
rtp_error_t init_srtp_with_zrtp(int flags, int type, std::shared_ptr<uvgrtp::base_srtp> srtp,
rtp_error_t init_srtp_with_zrtp(int rce_flags, int type, std::shared_ptr<uvgrtp::base_srtp> srtp,
std::shared_ptr<uvgrtp::zrtp> zrtp);
rtp_error_t start_components();
@ -333,7 +334,7 @@ namespace uvgrtp {
int src_port_;
int dst_port_;
rtp_format_t fmt_;
int flags_;
int rce_flags_;
/* Media context config */
rtp_ctx_conf_t ctx_config_;

View File

@ -91,8 +91,8 @@ namespace uvgrtp {
class rtcp {
public:
/// \cond DO_NOT_DOCUMENT
rtcp(std::shared_ptr<uvgrtp::rtp> rtp, std::string cname, int flags);
rtcp(std::shared_ptr<uvgrtp::rtp> rtp, std::string cname, std::shared_ptr<uvgrtp::srtcp> srtcp, int flags);
rtcp(std::shared_ptr<uvgrtp::rtp> rtp, std::string cname, int rce_flags);
rtcp(std::shared_ptr<uvgrtp::rtp> rtp, std::string cname, std::shared_ptr<uvgrtp::srtcp> srtcp, int rce_flags);
~rtcp();
/* start the RTCP runner thread
@ -296,7 +296,7 @@ namespace uvgrtp {
rtp_error_t update_sender_stats(size_t pkt_size);
/* Update RTCP-related receiver statistics */
static rtp_error_t recv_packet_handler(void *arg, int flags, frame::rtp_frame **out);
static rtp_error_t recv_packet_handler(void *arg, int rce_flags, frame::rtp_frame **out);
/* Update RTCP-related sender statistics */
static rtp_error_t send_packet_handler_vec(void *arg, uvgrtp::buf_vec& buffers);
@ -394,7 +394,7 @@ namespace uvgrtp {
std::shared_ptr<uvgrtp::srtcp> srtcp_;
/* RTP context flags */
int flags_;
int rce_flags_;
/* are we a sender (and possible a receiver) or just a receiver */
int our_role_;

View File

@ -38,12 +38,12 @@ namespace uvgrtp {
* for uvgrtp::media_stream for more details.
*
* User can enable and disable functionality of uvgRTP by OR'ing RCE_* flags
* together and passing them using the flags parameter
* together and passing them using the rce_flags parameter
*
* \param src_port Local port that uvgRTP listens to for incoming RTP packets
* \param dst_port Remote port where uvgRTP sends RTP packets
* \param fmt Format of the media stream. see ::RTP_FORMAT for more details
* \param flags RTP context enable flags, see ::RTP_CTX_ENABLE_FLAGS for more details
* \param rce_flags RTP context enable flags, see ::RTP_CTX_ENABLE_FLAGS for more details
*
* \return RTP media stream object
*
@ -56,7 +56,7 @@ namespace uvgrtp {
* \retval nullptr If RCE_SRTP is given but RCE_SRTP_KMNGMNT_* flag is not given
* \retval nullptr If memory allocation failed
*/
uvgrtp::media_stream *create_stream(int src_port, int dst_port, rtp_format_t fmt, int flags);
uvgrtp::media_stream *create_stream(int src_port, int dst_port, rtp_format_t fmt, int rce_flags);
/**
* \brief Destroy a media stream

View File

@ -61,7 +61,7 @@ namespace uvgrtp {
class socket {
public:
socket(int flags);
socket(int rce_flags);
~socket();
/* Create socket using "family", "type" and "protocol"
@ -84,7 +84,7 @@ namespace uvgrtp {
* Return RTP_GENERIC_ERROR if setsockopt failed */
rtp_error_t setsockopt(int level, int optname, const void *optval, socklen_t optlen);
/* Same as send(2), send message to remote using "flags"
/* Same as send(2), send message to remote with send_flags
* This function uses the internal addr_ object as remote address so it MUST be set
*
* It is possible to combine multiple buffers and send them as one RTP frame by calling
@ -94,20 +94,20 @@ namespace uvgrtp {
*
* Return RTP_OK on success and write the amount of bytes sent to "bytes_sent"
* Return RTP_SEND_ERROR on error and set "bytes_sent" to -1 */
rtp_error_t sendto(uint8_t *buf, size_t buf_len, int flags);
rtp_error_t sendto(uint8_t *buf, size_t buf_len, int flags, int *bytes_sent);
rtp_error_t sendto(buf_vec& buffers, int flags);
rtp_error_t sendto(buf_vec& buffers, int flags, int *bytes_sent);
rtp_error_t sendto(pkt_vec& buffers, int flags);
rtp_error_t sendto(pkt_vec& buffers, int flags, int *bytes_sent);
rtp_error_t sendto(uint8_t *buf, size_t buf_len, int send_flags);
rtp_error_t sendto(uint8_t *buf, size_t buf_len, int send_flags, int *bytes_sent);
rtp_error_t sendto(buf_vec& buffers, int send_flags);
rtp_error_t sendto(buf_vec& buffers, int send_flags, int *bytes_sent);
rtp_error_t sendto(pkt_vec& buffers, int send_flags);
rtp_error_t sendto(pkt_vec& buffers, int send_flags, int *bytes_sent);
/* Same as sendto() but the remote address given as parameter */
rtp_error_t sendto(sockaddr_in& addr, uint8_t *buf, size_t buf_len, int flags);
rtp_error_t sendto(sockaddr_in& addr, uint8_t *buf, size_t buf_len, int flags, int *bytes_sent);
rtp_error_t sendto(sockaddr_in& addr, buf_vec& buffers, int flags);
rtp_error_t sendto(sockaddr_in& addr, buf_vec& buffers, int flags, int *bytes_sent);
rtp_error_t sendto(sockaddr_in& addr, pkt_vec& buffers, int flags);
rtp_error_t sendto(sockaddr_in& addr, pkt_vec& buffers, int flags, int *bytes_sent);
rtp_error_t sendto(sockaddr_in& addr, uint8_t *buf, size_t buf_len, int send_flags);
rtp_error_t sendto(sockaddr_in& addr, uint8_t *buf, size_t buf_len, int send_flags, int *bytes_sent);
rtp_error_t sendto(sockaddr_in& addr, buf_vec& buffers, int send_flags);
rtp_error_t sendto(sockaddr_in& addr, buf_vec& buffers, int send_flags, int *bytes_sent);
rtp_error_t sendto(sockaddr_in& addr, pkt_vec& buffers, int send_flags);
rtp_error_t sendto(sockaddr_in& addr, pkt_vec& buffers, int send_flags, int *bytes_sent);
/* Same as recv(2), receives a message from socket (remote address not known)
*
@ -116,8 +116,8 @@ namespace uvgrtp {
* Return RTP_OK on success and write the amount of bytes received to "bytes_read"
* Return RTP_INTERRUPTED if the call was interrupted due to timeout and set "bytes_sent" to 0
* Return RTP_GENERIC_ERROR on error and set "bytes_sent" to -1 */
rtp_error_t recv(uint8_t *buf, size_t buf_len, int flags);
rtp_error_t recv(uint8_t *buf, size_t buf_len, int flags, int *bytes_read);
rtp_error_t recv(uint8_t *buf, size_t buf_len, int recv_flags);
rtp_error_t recv(uint8_t *buf, size_t buf_len, int recv_flags, int *bytes_read);
/* Same as recvfrom(2), receives a message from remote
*
@ -127,10 +127,10 @@ namespace uvgrtp {
* Return RTP_OK on success and write the amount of bytes sent to "bytes_sent"
* Return RTP_INTERRUPTED if the call was interrupted due to timeout and set "bytes_sent" to 0
* Return RTP_GENERIC_ERROR on error and set "bytes_sent" to -1 */
rtp_error_t recvfrom(uint8_t *buf, size_t buf_len, int flags, sockaddr_in *sender, int *bytes_read);
rtp_error_t recvfrom(uint8_t *buf, size_t buf_len, int flags, sockaddr_in *sender);
rtp_error_t recvfrom(uint8_t *buf, size_t buf_len, int flags, int *bytes_read);
rtp_error_t recvfrom(uint8_t *buf, size_t buf_len, int flags);
rtp_error_t recvfrom(uint8_t *buf, size_t buf_len, int recv_flags, sockaddr_in *sender, int *bytes_read);
rtp_error_t recvfrom(uint8_t *buf, size_t buf_len, int recv_flags, sockaddr_in *sender);
rtp_error_t recvfrom(uint8_t *buf, size_t buf_len, int recv_flags, int *bytes_read);
rtp_error_t recvfrom(uint8_t *buf, size_t buf_len, int recv_flags);
/* Create sockaddr_in object using the provided information
* NOTE: "family" must be AF_INET */
@ -161,17 +161,17 @@ namespace uvgrtp {
private:
/* helper function for sending UPD packets, see documentation for sendto() above */
rtp_error_t __sendto(sockaddr_in& addr, uint8_t *buf, size_t buf_len, int flags, int *bytes_sent);
rtp_error_t __recv(uint8_t *buf, size_t buf_len, int flags, int *bytes_read);
rtp_error_t __recvfrom(uint8_t *buf, size_t buf_len, int flags, sockaddr_in *sender, int *bytes_read);
rtp_error_t __sendto(sockaddr_in& addr, uint8_t *buf, size_t buf_len, int send_flags, int *bytes_sent);
rtp_error_t __recv(uint8_t *buf, size_t buf_len, int recv_flags, int *bytes_read);
rtp_error_t __recvfrom(uint8_t *buf, size_t buf_len, int recv_flags, sockaddr_in *sender, int *bytes_read);
/* __sendtov() does the same as __sendto but it combines multiple buffers into one frame and sends them */
rtp_error_t __sendtov(sockaddr_in& addr, buf_vec& buffers, int flags, int *bytes_sent);
rtp_error_t __sendtov(sockaddr_in& addr, uvgrtp::pkt_vec& buffers, int flags, int *bytes_sent);
rtp_error_t __sendtov(sockaddr_in& addr, buf_vec& buffers, int send_flags, int *bytes_sent);
rtp_error_t __sendtov(sockaddr_in& addr, uvgrtp::pkt_vec& buffers, int send_flags, int *bytes_sent);
socket_t socket_;
sockaddr_in addr_;
int flags_;
int rce_flags_;
/* __sendto() calls these handlers in order before sending the packet */
std::vector<socket_packet_handler> buf_handlers_;

View File

@ -305,7 +305,7 @@ enum RTP_CTX_CONFIGURATION_FLAGS {
/* see src/util.hh for more information */
typedef struct rtp_ctx_conf {
int flags = 0;
int rce_flags = 0;
ssize_t ctx_values[RCC_LAST];
} rtp_ctx_conf_t;

View File

@ -10,7 +10,7 @@ void uvgrtp_create_ctx(void** uvgrtp_context);
void uvgrtp_create_session(void* uvgrtp_context, void** uvgrtp_session, char* remote_address);
void uvgrtp_create_stream(void* uvgrtp_session, void** uvgrtp_stream, uint16_t local_port, uint16_t remote_port, int flags);
void uvgrtp_create_stream(void* uvgrtp_session, void** uvgrtp_stream, uint16_t local_port, uint16_t remote_port, int rce_flags);
void uvgrtp_destroy_ctx(void* uvgrtp_context);
@ -18,7 +18,7 @@ void uvgrtp_destroy_session(void* uvgrtp_context, void* uvgrtp_session);
void uvgrtp_destroy_stream(void* uvgrtp_session, void* uvgrtp_stream);
void uvgrtp_push_frame(void* uvgrtp_stream, uint8_t* data, size_t data_len, int flags);
void uvgrtp_push_frame(void* uvgrtp_stream, uint8_t* data, size_t data_len, int rtp_flags);
#ifdef __cplusplus
}

View File

@ -16,8 +16,8 @@
#include <sys/socket.h>
#endif
uvgrtp::formats::h264::h264(std::shared_ptr<uvgrtp::socket> socket, std::shared_ptr<uvgrtp::rtp> rtp, int flags) :
h26x(socket, rtp, flags)
uvgrtp::formats::h264::h264(std::shared_ptr<uvgrtp::socket> socket, std::shared_ptr<uvgrtp::rtp> rtp, int rce_flags) :
h26x(socket, rtp, rce_flags)
{
}
@ -188,9 +188,9 @@ uvgrtp::frame::rtp_frame* uvgrtp::formats::h264::allocate_rtp_frame_with_startco
return complete;
}
void uvgrtp::formats::h264::prepend_start_code(int flags, uvgrtp::frame::rtp_frame** out)
void uvgrtp::formats::h264::prepend_start_code(int rce_flags, uvgrtp::frame::rtp_frame** out)
{
if (flags & RCE_H26X_PREPEND_SC) {
if (rce_flags & RCE_H26X_PREPEND_SC) {
uint8_t* pl = new uint8_t[(*out)->payload_len + 3];
pl[0] = 0;

View File

@ -41,7 +41,7 @@ namespace uvgrtp {
class h264 : public h26x {
public:
h264(std::shared_ptr<uvgrtp::socket> socket, std::shared_ptr<uvgrtp::rtp> rtp, int flags);
h264(std::shared_ptr<uvgrtp::socket> socket, std::shared_ptr<uvgrtp::rtp> rtp, int rce_flags);
~h264();
protected:
@ -72,7 +72,7 @@ namespace uvgrtp {
virtual uvgrtp::frame::rtp_frame* allocate_rtp_frame_with_startcode(bool add_start_code,
uvgrtp::frame::rtp_header& header, size_t payload_size_without_startcode, size_t& fptr);
virtual void prepend_start_code(int flags, uvgrtp::frame::rtp_frame** out);
virtual void prepend_start_code(int rce_flags, uvgrtp::frame::rtp_frame** out);
private:
h264_aggregation_packet aggr_pkt_info_;

View File

@ -21,8 +21,8 @@
uvgrtp::formats::h265::h265(std::shared_ptr<uvgrtp::socket> socket,
std::shared_ptr<uvgrtp::rtp> rtp, int flags) :
h26x(socket, rtp, flags)
std::shared_ptr<uvgrtp::rtp> rtp, int rce_flags) :
h26x(socket, rtp, rce_flags)
{}
uvgrtp::formats::h265::~h265()

View File

@ -42,7 +42,7 @@ namespace uvgrtp {
class h265 : public h26x {
public:
h265(std::shared_ptr<uvgrtp::socket> socket, std::shared_ptr<uvgrtp::rtp> rtp, int flags);
h265(std::shared_ptr<uvgrtp::socket> socket, std::shared_ptr<uvgrtp::rtp> rtp, int rce_flags);
~h265();
protected:

View File

@ -21,8 +21,8 @@
uvgrtp::formats::h266::h266(std::shared_ptr<uvgrtp::socket> socket, std::shared_ptr<uvgrtp::rtp> rtp, int flags) :
h26x(socket, rtp, flags)
uvgrtp::formats::h266::h266(std::shared_ptr<uvgrtp::socket> socket, std::shared_ptr<uvgrtp::rtp> rtp, int rce_flags) :
h26x(socket, rtp, rce_flags)
{}
uvgrtp::formats::h266::~h266()

View File

@ -41,7 +41,7 @@ namespace uvgrtp {
class h266 : public h26x {
public:
h266(std::shared_ptr<uvgrtp::socket> socket, std::shared_ptr<uvgrtp::rtp> rtp, int flags);
h266(std::shared_ptr<uvgrtp::socket> socket, std::shared_ptr<uvgrtp::rtp> rtp, int rce_flags);
~h266();
protected:

View File

@ -82,8 +82,8 @@ static inline unsigned __find_h26x_start(uint32_t value,bool& additional_byte)
return 0;
}
uvgrtp::formats::h26x::h26x(std::shared_ptr<uvgrtp::socket> socket, std::shared_ptr<uvgrtp::rtp> rtp, int flags) :
media(socket, rtp, flags),
uvgrtp::formats::h26x::h26x(std::shared_ptr<uvgrtp::socket> socket, std::shared_ptr<uvgrtp::rtp> rtp, int rce_flags) :
media(socket, rtp, rce_flags),
queued_(),
frames_(),
fragments_(UINT16_MAX + 1, nullptr),
@ -276,7 +276,7 @@ rtp_error_t uvgrtp::formats::h26x::frame_getter(uvgrtp::frame::rtp_frame** frame
return RTP_NOT_FOUND;
}
rtp_error_t uvgrtp::formats::h26x::push_media_frame(uint8_t* data, size_t data_len, int flags)
rtp_error_t uvgrtp::formats::h26x::push_media_frame(uint8_t* data, size_t data_len, int rtp_flags)
{
rtp_error_t ret = RTP_OK;
@ -294,7 +294,7 @@ rtp_error_t uvgrtp::formats::h26x::push_media_frame(uint8_t* data, size_t data_l
std::vector<nal_info> nals;
bool should_aggregate = false;
if (flags & RTP_NO_H26X_SCL) {
if (rtp_flags & RTP_NO_H26X_SCL) {
nal_info nal;
nal.offset = 0;
nal.prefix_len = 0;
@ -478,9 +478,9 @@ uvgrtp::frame::rtp_frame* uvgrtp::formats::h26x::allocate_rtp_frame_with_startco
return complete;
}
void uvgrtp::formats::h26x::prepend_start_code(int flags, uvgrtp::frame::rtp_frame** out)
void uvgrtp::formats::h26x::prepend_start_code(int rce_flags, uvgrtp::frame::rtp_frame** out)
{
if (flags & RCE_H26X_PREPEND_SC) {
if (rce_flags & RCE_H26X_PREPEND_SC) {
uint8_t* pl = new uint8_t[(*out)->payload_len + 4];
pl[0] = 0;
@ -533,7 +533,7 @@ uint32_t uvgrtp::formats::h26x::drop_frame(uint32_t ts)
}
rtp_error_t uvgrtp::formats::h26x::handle_aggregation_packet(uvgrtp::frame::rtp_frame** out,
uint8_t payload_header_size, int flags)
uint8_t payload_header_size, int rce_flags)
{
uvgrtp::buf_vec nalus;
@ -557,8 +557,10 @@ rtp_error_t uvgrtp::formats::h26x::handle_aggregation_packet(uvgrtp::frame::rtp_
for (size_t i = 0; i < nalus.size(); ++i) {
size_t fptr = 0;
bool prepend_startcode = rce_flags & RCE_H26X_PREPEND_SC;
uvgrtp::frame::rtp_frame* retframe =
allocate_rtp_frame_with_startcode(flags, (*out)->header, nalus[i].first, fptr);
allocate_rtp_frame_with_startcode(prepend_startcode, (*out)->header, nalus[i].first, fptr);
std::memcpy(
retframe->payload + fptr,
@ -572,7 +574,7 @@ rtp_error_t uvgrtp::formats::h26x::handle_aggregation_packet(uvgrtp::frame::rtp_
return RTP_MULTIPLE_PKTS_READY;
}
rtp_error_t uvgrtp::formats::h26x::packet_handler(int flags, uvgrtp::frame::rtp_frame** out)
rtp_error_t uvgrtp::formats::h26x::packet_handler(int rce_flags, uvgrtp::frame::rtp_frame** out)
{
uvgrtp::frame::rtp_frame* frame = *out;
@ -596,7 +598,7 @@ rtp_error_t uvgrtp::formats::h26x::packet_handler(int flags, uvgrtp::frame::rtp_
if (frag_type == uvgrtp::formats::FRAG_TYPE::FT_AGGR) {
// handle aggregate packets (packets with multiple NAL units in them)
return handle_aggregation_packet(out, get_payload_header_size(), flags);
return handle_aggregation_packet(out, get_payload_header_size(), rce_flags);
}
else if (frag_type == uvgrtp::formats::FRAG_TYPE::FT_NOT_FRAG) { // Single NAL unit
@ -604,7 +606,7 @@ rtp_error_t uvgrtp::formats::h26x::packet_handler(int flags, uvgrtp::frame::rtp_
completed_ts_[frame->header.timestamp] = std::chrono::high_resolution_clock::now();
// nothing special needs to be done, just possibly add start codes back
prepend_start_code(flags, out);
prepend_start_code(rce_flags, out);
return RTP_PKT_READY;
}
else if (frag_type == uvgrtp::formats::FRAG_TYPE::FT_INVALID) {
@ -681,7 +683,7 @@ rtp_error_t uvgrtp::formats::h26x::packet_handler(int flags, uvgrtp::frame::rtp_
// have we received every fragment and can the frame can be reconstructed?
if (received == frames_[fragment_ts].received_packet_seqs.size()) {
bool enable_reference_discarding = (flags & RCE_H26X_DEPENDENCY_ENFORCEMENT);
bool enable_reference_discarding = (rce_flags & RCE_H26X_DEPENDENCY_ENFORCEMENT);
// here we discard inter frames if their references were not received correctly
if (discard_until_key_frame_ && enable_reference_discarding) {
if (nal_type == uvgrtp::formats::NAL_TYPE::NT_INTER) {
@ -699,7 +701,7 @@ rtp_error_t uvgrtp::formats::h26x::packet_handler(int flags, uvgrtp::frame::rtp_
}
}
return reconstruction(out, flags, fragment_ts, sizeof_fu_headers);
return reconstruction(out, rce_flags, fragment_ts, sizeof_fu_headers);
}
}
@ -865,7 +867,7 @@ void uvgrtp::formats::h26x::scl(uint8_t* data, size_t data_len, size_t packet_si
}
rtp_error_t uvgrtp::formats::h26x::reconstruction(uvgrtp::frame::rtp_frame** out,
int flags, uint32_t frame_timestamp, const uint8_t sizeof_fu_headers)
int rce_flags, uint32_t frame_timestamp, const uint8_t sizeof_fu_headers)
{
uvgrtp::frame::rtp_frame* frame = *out;
@ -876,7 +878,7 @@ rtp_error_t uvgrtp::formats::h26x::reconstruction(uvgrtp::frame::rtp_frame** out
size_t fptr = 0;
// allocating the frame with start code ready saves a copy operation for the frame
uvgrtp::frame::rtp_frame* complete = allocate_rtp_frame_with_startcode((flags & RCE_H26X_PREPEND_SC),
uvgrtp::frame::rtp_frame* complete = allocate_rtp_frame_with_startcode((rce_flags & RCE_H26X_PREPEND_SC),
frame->header, get_nal_header_size() + frames_[frame_timestamp].total_size, fptr);
// construct the NAL header from fragment header of current fragment

View File

@ -66,7 +66,7 @@ namespace uvgrtp {
class h26x : public media {
public:
h26x(std::shared_ptr<uvgrtp::socket> socket, std::shared_ptr<uvgrtp::rtp> rtp, int flags);
h26x(std::shared_ptr<uvgrtp::socket> socket, std::shared_ptr<uvgrtp::rtp> rtp, int rce_flags);
virtual ~h26x();
/* Find H26x start code from "data"
@ -81,7 +81,7 @@ namespace uvgrtp {
*
* Return RTP_OK on success
* Return RTP_INVALID_VALUE if one of the parameters is invalid */
rtp_error_t push_media_frame(uint8_t *data, size_t data_len, int flags);
rtp_error_t push_media_frame(uint8_t *data, size_t data_len, int rtp_flags);
/* If the packet handler must return more than one frame, it can install a frame getter
* that is called by the auxiliary handler caller if packet_handler() returns RTP_MULTIPLE_PKTS_READY
@ -108,7 +108,7 @@ namespace uvgrtp {
* Return RTP_PKT_NOT_HANDLED if the packet is not handled by this handler
* Return RTP_PKT_MODIFIED if the packet was modified but should be forwarded to other handlers
* Return RTP_GENERIC_ERROR if the packet was corrupted in some way */
rtp_error_t packet_handler(int flags, frame::rtp_frame** frame);
rtp_error_t packet_handler(int rce_flags, frame::rtp_frame** frame);
protected:
@ -131,7 +131,7 @@ namespace uvgrtp {
void initialize_fu_headers(uint8_t nal_type, uint8_t fu_headers[]);
rtp_error_t handle_aggregation_packet(uvgrtp::frame::rtp_frame** out, uint8_t nal_header_size, int flags);
rtp_error_t handle_aggregation_packet(uvgrtp::frame::rtp_frame** out, uint8_t nal_header_size, int rce_flags);
/* Gets the format specific nal type from data*/
virtual uint8_t get_nal_type(uint8_t* data) const = 0;
@ -148,7 +148,7 @@ namespace uvgrtp {
virtual uvgrtp::frame::rtp_frame* allocate_rtp_frame_with_startcode(bool add_start_code,
uvgrtp::frame::rtp_header& header, size_t payload_size_without_startcode, size_t& fptr);
virtual void prepend_start_code(int flags, uvgrtp::frame::rtp_frame** out);
virtual void prepend_start_code(int rce_flags, uvgrtp::frame::rtp_frame** out);
private:
@ -166,7 +166,7 @@ namespace uvgrtp {
void garbage_collect_lost_frames(size_t timout);
rtp_error_t reconstruction(uvgrtp::frame::rtp_frame** out,
int flags, uint32_t frame_timestamp, const uint8_t sizeof_fu_headers);
int rce_flags, uint32_t frame_timestamp, const uint8_t sizeof_fu_headers);
std::deque<uvgrtp::frame::rtp_frame*> queued_;
std::unordered_map<uint32_t, h26x_info_t> frames_;

View File

@ -13,8 +13,8 @@
#define INVALID_SEQ 0xffffffff
uvgrtp::formats::media::media(std::shared_ptr<uvgrtp::socket> socket, std::shared_ptr<uvgrtp::rtp> rtp_ctx, int flags):
socket_(socket), rtp_ctx_(rtp_ctx), flags_(flags), fqueue_(new uvgrtp::frame_queue(socket, rtp_ctx, flags)), minfo_()
uvgrtp::formats::media::media(std::shared_ptr<uvgrtp::socket> socket, std::shared_ptr<uvgrtp::rtp> rtp_ctx, int rce_flags):
socket_(socket), rtp_ctx_(rtp_ctx), rce_flags_(rce_flags), fqueue_(new uvgrtp::frame_queue(socket, rtp_ctx, rce_flags)), minfo_()
{}
uvgrtp::formats::media::~media()
@ -22,25 +22,25 @@ uvgrtp::formats::media::~media()
fqueue_ = nullptr;
}
rtp_error_t uvgrtp::formats::media::push_frame(uint8_t *data, size_t data_len, int flags)
rtp_error_t uvgrtp::formats::media::push_frame(uint8_t *data, size_t data_len, int rtp_flags)
{
if (!data || !data_len)
return RTP_INVALID_VALUE;
return push_media_frame(data, data_len, flags);
return push_media_frame(data, data_len, rtp_flags);
}
rtp_error_t uvgrtp::formats::media::push_frame(std::unique_ptr<uint8_t[]> data, size_t data_len, int flags)
rtp_error_t uvgrtp::formats::media::push_frame(std::unique_ptr<uint8_t[]> data, size_t data_len, int rtp_flags)
{
if (!data || !data_len)
return RTP_INVALID_VALUE;
return push_media_frame(data.get(), data_len, flags);
return push_media_frame(data.get(), data_len, rtp_flags);
}
rtp_error_t uvgrtp::formats::media::push_media_frame(uint8_t *data, size_t data_len, int flags)
rtp_error_t uvgrtp::formats::media::push_media_frame(uint8_t *data, size_t data_len, int rtp_flags)
{
(void)flags;
(void)rtp_flags;
rtp_error_t ret;
@ -49,7 +49,7 @@ rtp_error_t uvgrtp::formats::media::push_media_frame(uint8_t *data, size_t data_
return ret;
}
if (!(flags_ & RCE_FRAGMENT_GENERIC) || data_len <= rtp_ctx_->get_payload_size()) {
if (!(rce_flags_ & RCE_FRAGMENT_GENERIC) || data_len <= rtp_ctx_->get_payload_size()) {
if (data_len > rtp_ctx_->get_payload_size()) {
UVG_LOG_WARN("Packet is larger (%zu bytes) than maximum payload size (%zu bytes)",
data_len, rtp_ctx_->get_payload_size());
@ -94,7 +94,7 @@ uvgrtp::formats::media_frame_info_t *uvgrtp::formats::media::get_media_frame_inf
return &minfo_;
}
rtp_error_t uvgrtp::formats::media::packet_handler(void *arg, int flags, uvgrtp::frame::rtp_frame **out)
rtp_error_t uvgrtp::formats::media::packet_handler(void *arg, int rce_flags, uvgrtp::frame::rtp_frame **out)
{
auto minfo = (uvgrtp::formats::media_frame_info_t *)arg;
auto frame = *out;
@ -104,7 +104,7 @@ rtp_error_t uvgrtp::formats::media::packet_handler(void *arg, int flags, uvgrtp:
/* If fragmentation of generic frame has not been enabled, we can just return the frame
* in "out" because RTP packet handler has done all the necessasry stuff for small RTP packets */
if (!(flags & RCE_FRAGMENT_GENERIC))
if (!(rce_flags & RCE_FRAGMENT_GENERIC))
return RTP_PKT_READY;
if (minfo->frames.find(ts) != minfo->frames.end()) {

View File

@ -36,7 +36,7 @@ namespace uvgrtp {
class media {
public:
media(std::shared_ptr<uvgrtp::socket> socket, std::shared_ptr<uvgrtp::rtp> rtp_ctx, int flags);
media(std::shared_ptr<uvgrtp::socket> socket, std::shared_ptr<uvgrtp::rtp> rtp_ctx, int rce_flags);
virtual ~media();
/* These two functions are called by media_stream which is self is called by the application.
@ -44,10 +44,10 @@ namespace uvgrtp {
* implement if they require more processing than what the default implementation offers
*
* Return RTP_OK on success */
rtp_error_t push_frame(uint8_t *data, size_t data_len, int flags);
rtp_error_t push_frame(std::unique_ptr<uint8_t[]> data, size_t data_len, int flags);
rtp_error_t push_frame(uint8_t *data, size_t data_len, int rtp_flags);
rtp_error_t push_frame(std::unique_ptr<uint8_t[]> data, size_t data_len, int rtp_flags);
/* Media-specific packet handler. The default handler, depending on what "flags_" contains,
/* Media-specific packet handler. The default handler, depending on what "rce_flags_" contains,
* may only return the received RTP packet or it may merge multiple packets together before
* returning a complete frame to the user.
*
@ -57,7 +57,7 @@ namespace uvgrtp {
* Return RTP_PKT_NOT_HANDLED if the packet is not handled by this handler
* Return RTP_PKT_MODIFIED if the packet was modified but should be forwarded to other handlers
* Return RTP_GENERIC_ERROR if the packet was corrupted in some way */
static rtp_error_t packet_handler(void *arg, int flags, frame::rtp_frame **frame);
static rtp_error_t packet_handler(void *arg, int rce_flags, frame::rtp_frame **frame);
/* Return pointer to the internal frame info structure which is relayed to packet handler */
media_frame_info_t *get_media_frame_info();
@ -65,11 +65,11 @@ namespace uvgrtp {
void set_fps(int enumarator, int denominator);
protected:
virtual rtp_error_t push_media_frame(uint8_t *data, size_t data_len, int flags);
virtual rtp_error_t push_media_frame(uint8_t *data, size_t data_len, int rtp_flags);
std::shared_ptr<uvgrtp::socket> socket_;
std::shared_ptr<uvgrtp::rtp> rtp_ctx_;
int flags_;
int rce_flags_;
std::unique_ptr<uvgrtp::frame_queue> fqueue_;
private:

View File

@ -22,13 +22,13 @@
#endif
uvgrtp::frame_queue::frame_queue(std::shared_ptr<uvgrtp::socket> socket, std::shared_ptr<uvgrtp::rtp> rtp, int flags):
uvgrtp::frame_queue::frame_queue(std::shared_ptr<uvgrtp::socket> socket, std::shared_ptr<uvgrtp::rtp> rtp, int rce_flags):
active_(nullptr),
max_mcount_(MAX_MSG_COUNT),
max_ccount_(MAX_CHUNK_COUNT* max_mcount_),
rtp_(rtp),
socket_(socket),
flags_(flags),
rce_flags_(rce_flags),
frame_interval_(),
fps_sync_point_(),
frames_since_sync_(0)
@ -86,7 +86,7 @@ rtp_error_t uvgrtp::frame_queue::init_transaction()
active_->data_smart = nullptr;
active_->dealloc_hook = dealloc_hook_;
if (flags_ & RCE_SRTP_AUTHENTICATE_RTP)
if (rce_flags_ & RCE_SRTP_AUTHENTICATE_RTP)
active_->rtp_auth_tags = new uint8_t[10 * max_mcount_];
else
active_->rtp_auth_tags = nullptr;
@ -208,7 +208,7 @@ rtp_error_t uvgrtp::frame_queue::enqueue_message(uint8_t *message, size_t messag
/* If SRTP with proper encryption has been enabled but
* RCE_SRTP_INPLACE_ENCRYPTION has **not** been enabled, make a copy of the memory block*/
if ((flags_ & (RCE_SRTP | RCE_SRTP_INPLACE_ENCRYPTION | RCE_SRTP_NULL_CIPHER)) == RCE_SRTP)
if ((rce_flags_ & (RCE_SRTP | RCE_SRTP_INPLACE_ENCRYPTION | RCE_SRTP_NULL_CIPHER)) == RCE_SRTP)
message = (uint8_t *)memdup(message, message_len);
tmp.push_back({ message_len, message });
@ -243,7 +243,7 @@ rtp_error_t uvgrtp::frame_queue::enqueue_message(buf_vec& buffers)
/* If SRTP with proper encryption is used and there are more than one buffer,
* frame queue must be a copy of the input and ... */
if ((flags_ & RCE_SRTP) && !(flags_ & RCE_SRTP_NULL_CIPHER) && buffers.size() > 1) {
if ((rce_flags_ & RCE_SRTP) && !(rce_flags_ & RCE_SRTP_NULL_CIPHER) && buffers.size() > 1) {
size_t total = 0;
@ -376,7 +376,7 @@ void uvgrtp::frame_queue::install_dealloc_hook(void (*dealloc_hook)(void *))
void uvgrtp::frame_queue::enqueue_finalize(uvgrtp::buf_vec& tmp)
{
if (flags_ & RCE_SRTP_AUTHENTICATE_RTP) {
if (rce_flags_ & RCE_SRTP_AUTHENTICATE_RTP) {
tmp.push_back({
UVG_AUTH_TAG_LENGTH,
(uint8_t*)&active_->rtp_auth_tags[10 * active_->rtpauth_ptr++]

View File

@ -77,7 +77,7 @@ namespace uvgrtp {
class frame_queue {
public:
frame_queue(std::shared_ptr<uvgrtp::socket> socket, std::shared_ptr<uvgrtp::rtp> rtp, int flags);
frame_queue(std::shared_ptr<uvgrtp::socket> socket, std::shared_ptr<uvgrtp::rtp> rtp, int rce_flags);
~frame_queue();
rtp_error_t init_transaction();
@ -176,8 +176,7 @@ namespace uvgrtp {
std::shared_ptr<uvgrtp::rtp> rtp_;
std::shared_ptr<uvgrtp::socket> socket_;
/* RTP context flags */
int flags_;
int rce_flags_;
bool fps = false;
std::chrono::nanoseconds frame_interval_;

View File

@ -21,7 +21,7 @@
#include <errno.h>
uvgrtp::media_stream::media_stream(std::string cname, std::string addr,
int src_port, int dst_port, rtp_format_t fmt, int flags):
int src_port, int dst_port, rtp_format_t fmt, int rce_flags):
srtp_(nullptr),
srtcp_(nullptr),
socket_(nullptr),
@ -41,20 +41,20 @@ uvgrtp::media_stream::media_stream(std::string cname, std::string addr,
fmt_ = fmt;
addr_ = addr;
laddr_ = "";
flags_ = flags;
rce_flags_ = rce_flags;
src_port_ = src_port;
dst_port_ = dst_port;
key_ = uvgrtp::random::generate_32();
ctx_config_.flags = flags;
ctx_config_.rce_flags = rce_flags;
}
uvgrtp::media_stream::media_stream(std::string cname,
std::string remote_addr, std::string local_addr,
int src_port, int dst_port,
rtp_format_t fmt, int flags
rtp_format_t fmt, int rce_flags
):
media_stream(cname, remote_addr, src_port, dst_port, fmt, flags)
media_stream(cname, remote_addr, src_port, dst_port, fmt, rce_flags)
{
laddr_ = local_addr;
}
@ -70,12 +70,12 @@ uvgrtp::media_stream::~media_stream()
// and media stream is destroyed. Note that this is the only way to stop pull
// frame without waiting
if ((ctx_config_.flags & RCE_RTCP) && rtcp_)
if ((ctx_config_.rce_flags & RCE_RTCP) && rtcp_)
{
rtcp_->stop();
}
if ((ctx_config_.flags & RCE_HOLEPUNCH_KEEPALIVE) && holepuncher_)
if ((ctx_config_.rce_flags & RCE_HOLEPUNCH_KEEPALIVE) && holepuncher_)
{
holepuncher_->stop();
}
@ -87,7 +87,7 @@ rtp_error_t uvgrtp::media_stream::init_connection()
{
rtp_error_t ret = RTP_OK;
socket_ = std::shared_ptr<uvgrtp::socket> (new uvgrtp::socket(ctx_config_.flags));
socket_ = std::shared_ptr<uvgrtp::socket> (new uvgrtp::socket(ctx_config_.rce_flags));
if ((ret = socket_->init(AF_INET, SOCK_DGRAM, 0)) != RTP_OK)
return ret;
@ -134,7 +134,7 @@ rtp_error_t uvgrtp::media_stream::create_media(rtp_format_t fmt)
switch (fmt_) {
case RTP_FORMAT_H264:
{
uvgrtp::formats::h264* format_264 = new uvgrtp::formats::h264(socket_, rtp_, ctx_config_.flags);
uvgrtp::formats::h264* format_264 = new uvgrtp::formats::h264(socket_, rtp_, ctx_config_.rce_flags);
reception_flow_->install_aux_handler_cpp(
rtp_handler_key_,
@ -147,7 +147,7 @@ rtp_error_t uvgrtp::media_stream::create_media(rtp_format_t fmt)
}
case RTP_FORMAT_H265:
{
uvgrtp::formats::h265* format_265 = new uvgrtp::formats::h265(socket_, rtp_, ctx_config_.flags);
uvgrtp::formats::h265* format_265 = new uvgrtp::formats::h265(socket_, rtp_, ctx_config_.rce_flags);
reception_flow_->install_aux_handler_cpp(
rtp_handler_key_,
@ -160,7 +160,7 @@ rtp_error_t uvgrtp::media_stream::create_media(rtp_format_t fmt)
}
case RTP_FORMAT_H266:
{
uvgrtp::formats::h266* format_266 = new uvgrtp::formats::h266(socket_, rtp_, ctx_config_.flags);
uvgrtp::formats::h266* format_266 = new uvgrtp::formats::h266(socket_, rtp_, ctx_config_.rce_flags);
reception_flow_->install_aux_handler_cpp(
rtp_handler_key_,
@ -173,7 +173,7 @@ rtp_error_t uvgrtp::media_stream::create_media(rtp_format_t fmt)
}
case RTP_FORMAT_OPUS:
case RTP_FORMAT_GENERIC:
media_ = std::unique_ptr<uvgrtp::formats::media> (new uvgrtp::formats::media(socket_, rtp_, ctx_config_.flags));
media_ = std::unique_ptr<uvgrtp::formats::media> (new uvgrtp::formats::media(socket_, rtp_, ctx_config_.rce_flags));
reception_flow_->install_aux_handler(
rtp_handler_key_,
@ -238,7 +238,7 @@ rtp_error_t uvgrtp::media_stream::init()
reception_flow_ = std::unique_ptr<uvgrtp::reception_flow> (new uvgrtp::reception_flow());
rtp_ = std::shared_ptr<uvgrtp::rtp> (new uvgrtp::rtp(fmt_));
rtcp_ = std::shared_ptr<uvgrtp::rtcp> (new uvgrtp::rtcp(rtp_, cname_, ctx_config_.flags));
rtcp_ = std::shared_ptr<uvgrtp::rtcp> (new uvgrtp::rtcp(rtp_, cname_, ctx_config_.rce_flags));
socket_->install_handler(rtcp_.get(), rtcp_->send_packet_handler_vec);
@ -266,15 +266,15 @@ rtp_error_t uvgrtp::media_stream::init(std::shared_ptr<uvgrtp::zrtp> zrtp)
return free_resources(ret);
}
srtp_ = std::shared_ptr<uvgrtp::srtp>(new uvgrtp::srtp(ctx_config_.flags));
if ((ret = init_srtp_with_zrtp(ctx_config_.flags, SRTP, srtp_, zrtp)) != RTP_OK)
srtp_ = std::shared_ptr<uvgrtp::srtp>(new uvgrtp::srtp(ctx_config_.rce_flags));
if ((ret = init_srtp_with_zrtp(ctx_config_.rce_flags, SRTP, srtp_, zrtp)) != RTP_OK)
return free_resources(ret);
srtcp_ = std::shared_ptr<uvgrtp::srtcp> (new uvgrtp::srtcp());
if ((ret = init_srtp_with_zrtp(ctx_config_.flags, SRTCP, srtcp_, zrtp)) != RTP_OK)
if ((ret = init_srtp_with_zrtp(ctx_config_.rce_flags, SRTCP, srtcp_, zrtp)) != RTP_OK)
return free_resources(ret);
rtcp_ = std::shared_ptr<uvgrtp::rtcp> (new uvgrtp::rtcp(rtp_, cname_, srtcp_, ctx_config_.flags));
rtcp_ = std::shared_ptr<uvgrtp::rtcp> (new uvgrtp::rtcp(rtp_, cname_, srtcp_, ctx_config_.rce_flags));
socket_->install_handler(rtcp_.get(), rtcp_->send_packet_handler_vec);
socket_->install_handler(srtp_.get(), srtp_->send_packet_handler);
@ -293,7 +293,7 @@ rtp_error_t uvgrtp::media_stream::add_srtp_ctx(uint8_t *key, uint8_t *salt)
if (!key || !salt)
return RTP_INVALID_VALUE;
unsigned srtp_flags = RCE_SRTP | RCE_SRTP_KMNGMNT_USER;
unsigned int srtp_rce_flags = RCE_SRTP | RCE_SRTP_KMNGMNT_USER;
rtp_error_t ret = RTP_OK;
if (init_connection() != RTP_OK) {
@ -301,29 +301,29 @@ rtp_error_t uvgrtp::media_stream::add_srtp_ctx(uint8_t *key, uint8_t *salt)
return free_resources(RTP_GENERIC_ERROR);
}
if ((flags_ & srtp_flags) != srtp_flags)
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_));
srtp_ = std::shared_ptr<uvgrtp::srtp> (new uvgrtp::srtp(ctx_config_.flags));
srtp_ = std::shared_ptr<uvgrtp::srtp> (new uvgrtp::srtp(ctx_config_.rce_flags));
// why are they local and remote key/salt the same?
if ((ret = srtp_->init(SRTP, ctx_config_.flags, key, key, salt, salt)) != RTP_OK) {
if ((ret = srtp_->init(SRTP, ctx_config_.rce_flags, key, key, salt, salt)) != RTP_OK) {
UVG_LOG_WARN("Failed to initialize SRTP for media stream!");
return free_resources(ret);
}
srtcp_ = std::shared_ptr<uvgrtp::srtcp> (new uvgrtp::srtcp());
if ((ret = srtcp_->init(SRTCP, ctx_config_.flags, key, key, salt, salt)) != RTP_OK) {
if ((ret = srtcp_->init(SRTCP, ctx_config_.rce_flags, key, key, salt, salt)) != RTP_OK) {
UVG_LOG_WARN("Failed to initialize SRTCP for media stream!");
return free_resources(ret);
}
rtcp_ = std::shared_ptr<uvgrtp::rtcp> (new uvgrtp::rtcp(rtp_, cname_, srtcp_, ctx_config_.flags));
rtcp_ = std::shared_ptr<uvgrtp::rtcp> (new uvgrtp::rtcp(rtp_, cname_, srtcp_, ctx_config_.rce_flags));
socket_->install_handler(rtcp_.get(), rtcp_->send_packet_handler_vec);
socket_->install_handler(srtp_.get(), srtp_->send_packet_handler);
@ -341,51 +341,51 @@ rtp_error_t uvgrtp::media_stream::start_components()
if (create_media(fmt_) != RTP_OK)
return free_resources(RTP_MEMORY_ERROR);
if (ctx_config_.flags & RCE_HOLEPUNCH_KEEPALIVE) {
if (ctx_config_.rce_flags & RCE_HOLEPUNCH_KEEPALIVE) {
holepuncher_ = std::unique_ptr<uvgrtp::holepuncher> (new uvgrtp::holepuncher(socket_));
holepuncher_->start();
}
if (ctx_config_.flags & RCE_RTCP) {
if (ctx_config_.rce_flags & RCE_RTCP) {
rtcp_->add_participant(addr_, src_port_ + 1, dst_port_ + 1, rtp_->get_clock_rate());
rtcp_->set_session_bandwidth(get_default_bandwidth_kbps(fmt_));
rtcp_->start();
}
if (ctx_config_.flags & RCE_SRTP_AUTHENTICATE_RTP)
if (ctx_config_.rce_flags & RCE_SRTP_AUTHENTICATE_RTP)
rtp_->set_payload_size(MAX_PAYLOAD - UVG_AUTH_TAG_LENGTH);
initialized_ = true;
return reception_flow_->start(socket_, ctx_config_.flags);
return reception_flow_->start(socket_, ctx_config_.rce_flags);
}
rtp_error_t uvgrtp::media_stream::push_frame(uint8_t *data, size_t data_len, int flags)
rtp_error_t uvgrtp::media_stream::push_frame(uint8_t *data, size_t data_len, int rtp_flags)
{
if (!initialized_) {
UVG_LOG_ERROR("RTP context has not been initialized fully, cannot continue!");
return RTP_NOT_INITIALIZED;
}
if (ctx_config_.flags & RCE_HOLEPUNCH_KEEPALIVE && holepuncher_)
if (ctx_config_.rce_flags & RCE_HOLEPUNCH_KEEPALIVE && holepuncher_)
holepuncher_->notify();
return media_->push_frame(data, data_len, flags);
return media_->push_frame(data, data_len, rtp_flags);
}
rtp_error_t uvgrtp::media_stream::push_frame(std::unique_ptr<uint8_t[]> data, size_t data_len, int flags)
rtp_error_t uvgrtp::media_stream::push_frame(std::unique_ptr<uint8_t[]> data, size_t data_len, int rtp_flags)
{
if (!initialized_) {
UVG_LOG_ERROR("RTP context has not been initialized fully, cannot continue!");
return RTP_NOT_INITIALIZED;
}
if (ctx_config_.flags & RCE_HOLEPUNCH_KEEPALIVE && holepuncher_)
if (ctx_config_.rce_flags & RCE_HOLEPUNCH_KEEPALIVE && holepuncher_)
holepuncher_->notify();
return media_->push_frame(std::move(data), data_len, flags);
return media_->push_frame(std::move(data), data_len, rtp_flags);
}
rtp_error_t uvgrtp::media_stream::push_frame(uint8_t *data, size_t data_len, uint32_t ts, int flags)
rtp_error_t uvgrtp::media_stream::push_frame(uint8_t *data, size_t data_len, uint32_t ts, int rtp_flags)
{
rtp_error_t ret = RTP_GENERIC_ERROR;
@ -394,17 +394,17 @@ rtp_error_t uvgrtp::media_stream::push_frame(uint8_t *data, size_t data_len, uin
return RTP_NOT_INITIALIZED;
}
if (ctx_config_.flags & RCE_HOLEPUNCH_KEEPALIVE)
if (ctx_config_.rce_flags & RCE_HOLEPUNCH_KEEPALIVE)
holepuncher_->notify();
rtp_->set_timestamp(ts);
ret = media_->push_frame(data, data_len, flags);
ret = media_->push_frame(data, data_len, rtp_flags);
rtp_->set_timestamp(INVALID_TS);
return ret;
}
rtp_error_t uvgrtp::media_stream::push_frame(std::unique_ptr<uint8_t[]> data, size_t data_len, uint32_t ts, int flags)
rtp_error_t uvgrtp::media_stream::push_frame(std::unique_ptr<uint8_t[]> data, size_t data_len, uint32_t ts, int rtp_flags)
{
rtp_error_t ret = RTP_GENERIC_ERROR;
@ -413,11 +413,11 @@ rtp_error_t uvgrtp::media_stream::push_frame(std::unique_ptr<uint8_t[]> data, si
return RTP_NOT_INITIALIZED;
}
if (ctx_config_.flags & RCE_HOLEPUNCH_KEEPALIVE)
if (ctx_config_.rce_flags & RCE_HOLEPUNCH_KEEPALIVE)
holepuncher_->notify();
rtp_->set_timestamp(ts);
ret = media_->push_frame(std::move(data), data_len, flags);
ret = media_->push_frame(std::move(data), data_len, rtp_flags);
rtp_->set_timestamp(INVALID_TS);
return ret;
@ -502,7 +502,7 @@ void *uvgrtp::media_stream::get_media_config()
return media_config_;
}
rtp_error_t uvgrtp::media_stream::configure_ctx(int flag, ssize_t value)
rtp_error_t uvgrtp::media_stream::configure_ctx(int rcc_flag, ssize_t value)
{
if (!initialized_) {
UVG_LOG_ERROR("RTP context has not been initialized fully, cannot continue!");
@ -511,7 +511,7 @@ rtp_error_t uvgrtp::media_stream::configure_ctx(int flag, ssize_t value)
rtp_error_t ret = RTP_OK;
switch (flag) {
switch (rcc_flag) {
case RCC_UDP_SND_BUF_SIZE: {
if (value <= 0)
return RTP_INVALID_VALUE;
@ -554,7 +554,7 @@ rtp_error_t uvgrtp::media_stream::configure_ctx(int flag, ssize_t value)
ssize_t hdr = ETH_HDR_SIZE + IPV4_HDR_SIZE + UDP_HDR_SIZE + RTP_HDR_SIZE;
ssize_t max_size = 0xffff - IPV4_HDR_SIZE - UDP_HDR_SIZE;
if (ctx_config_.flags & RCE_SRTP_AUTHENTICATE_RTP)
if (ctx_config_.rce_flags & RCE_SRTP_AUTHENTICATE_RTP)
hdr += UVG_AUTH_TAG_LENGTH;
if (value <= hdr)
@ -615,10 +615,10 @@ uint32_t uvgrtp::media_stream::get_ssrc() const
return rtp_->get_ssrc();
}
rtp_error_t uvgrtp::media_stream::init_srtp_with_zrtp(int flags, int type, std::shared_ptr<uvgrtp::base_srtp> srtp,
rtp_error_t uvgrtp::media_stream::init_srtp_with_zrtp(int rce_flags, int type, std::shared_ptr<uvgrtp::base_srtp> srtp,
std::shared_ptr<uvgrtp::zrtp> zrtp)
{
size_t key_size = srtp->get_key_size(flags);
size_t key_size = srtp->get_key_size(rce_flags);
uint8_t* local_key = new uint8_t[key_size];
uint8_t* remote_key = new uint8_t[key_size];
@ -634,7 +634,7 @@ rtp_error_t uvgrtp::media_stream::init_srtp_with_zrtp(int flags, int type, std::
if (ret == RTP_OK)
{
ret = srtp->init(type, flags, local_key, remote_key,
ret = srtp->init(type, rce_flags, local_key, remote_key,
local_salt, remote_salt);
}
else

View File

@ -81,13 +81,13 @@ void uvgrtp::reception_flow::set_buffer_size(const ssize_t& value)
create_ring_buffer();
}
rtp_error_t uvgrtp::reception_flow::start(std::shared_ptr<uvgrtp::socket> socket, int flags)
rtp_error_t uvgrtp::reception_flow::start(std::shared_ptr<uvgrtp::socket> socket, int rce_flags)
{
should_stop_ = false;
UVG_LOG_DEBUG("Creating receiving threads and setting priorities");
processor_ = std::unique_ptr<std::thread>(new std::thread(&uvgrtp::reception_flow::process_packet, this, flags));
receiver_ = std::unique_ptr<std::thread>(new std::thread(&uvgrtp::reception_flow::receiver, this, socket, flags));
processor_ = std::unique_ptr<std::thread>(new std::thread(&uvgrtp::reception_flow::process_packet, this, rce_flags));
receiver_ = std::unique_ptr<std::thread>(new std::thread(&uvgrtp::reception_flow::receiver, this, socket, rce_flags));
// set receiver thread priority to maximum
#ifndef WIN32
@ -243,12 +243,12 @@ void uvgrtp::reception_flow::return_frame(uvgrtp::frame::rtp_frame *frame)
}
}
void uvgrtp::reception_flow::call_aux_handlers(uint32_t key, int flags, uvgrtp::frame::rtp_frame **frame)
void uvgrtp::reception_flow::call_aux_handlers(uint32_t key, int rce_flags, uvgrtp::frame::rtp_frame **frame)
{
rtp_error_t ret;
for (auto& aux : packet_handlers_[key].auxiliary) {
switch ((ret = (*aux.handler)(aux.arg, flags, frame))) {
switch ((ret = (*aux.handler)(aux.arg, rce_flags, frame))) {
/* packet was handled successfully */
case RTP_OK:
break;
@ -282,7 +282,7 @@ void uvgrtp::reception_flow::call_aux_handlers(uint32_t key, int flags, uvgrtp::
}
for (auto& aux : packet_handlers_[key].auxiliary_cpp) {
switch ((ret = aux.handler(flags, frame))) {
switch ((ret = aux.handler(rce_flags, frame))) {
case RTP_OK: /* packet was handled successfully */
{
@ -328,7 +328,7 @@ void uvgrtp::reception_flow::call_aux_handlers(uint32_t key, int flags, uvgrtp::
}
}
void uvgrtp::reception_flow::receiver(std::shared_ptr<uvgrtp::socket> socket, int flags)
void uvgrtp::reception_flow::receiver(std::shared_ptr<uvgrtp::socket> socket, int rce_flags)
{
int read_packets = 0;
@ -413,7 +413,7 @@ void uvgrtp::reception_flow::receiver(std::shared_ptr<uvgrtp::socket> socket, in
UVG_LOG_DEBUG("Total read packets from buffer: %li", read_packets);
}
void uvgrtp::reception_flow::process_packet(int flags)
void uvgrtp::reception_flow::process_packet(int rce_flags)
{
std::unique_lock<std::mutex> lk(wait_mtx_);
@ -446,7 +446,7 @@ void uvgrtp::reception_flow::process_packet(int flags)
// Here we don't lock ring mutex because the chaging is only done above.
// NOTE: If there is a need for multiple processing threads, the read should be guarded
switch ((ret = (*handler.second.primary)(ring_buffer_[ring_read_index_].read,
ring_buffer_[ring_read_index_].data, flags, &frame))) {
ring_buffer_[ring_read_index_].data, rce_flags, &frame))) {
case RTP_OK:
{
// packet was handled successfully
@ -461,7 +461,7 @@ void uvgrtp::reception_flow::process_packet(int flags)
}
case RTP_PKT_MODIFIED:
{
this->call_aux_handlers(handler.first, flags, &frame);
this->call_aux_handlers(handler.first, rce_flags, &frame);
break;
}
case RTP_GENERIC_ERROR:

View File

@ -126,7 +126,7 @@ namespace uvgrtp {
*
* Return RTP_OK on success
* Return RTP_MEMORY_ERROR if allocation of a thread object fails */
rtp_error_t start(std::shared_ptr<uvgrtp::socket> socket, int flags);
rtp_error_t start(std::shared_ptr<uvgrtp::socket> socket, int rce_flags);
/* Stop the RTP reception flow and wait until the receive loop is exited
* to make sure that destroying the object is safe.
@ -149,16 +149,16 @@ namespace uvgrtp {
private:
/* RTP packet receiver thread */
void receiver(std::shared_ptr<uvgrtp::socket> socket, int flags);
void receiver(std::shared_ptr<uvgrtp::socket> socket, int rce_flags);
/* RTP packet dispatcher thread */
void process_packet(int flags);
void process_packet(int rce_flags);
/* Return a processed RTP frame to user either through frame queue or receive hook */
void return_frame(uvgrtp::frame::rtp_frame *frame);
/* Call auxiliary handlers of a primary handler */
void call_aux_handlers(uint32_t key, int flags, uvgrtp::frame::rtp_frame **frame);
void call_aux_handlers(uint32_t key, int rce_flags, uvgrtp::frame::rtp_frame **frame);
inline void increase_buffer_size(ssize_t next_write_index);

View File

@ -34,8 +34,8 @@ constexpr int ESTIMATED_MAX_RECEPTION_TIME_MS = 10;
const uint32_t MAX_SUPPORTED_PARTICIPANTS = 31;
uvgrtp::rtcp::rtcp(std::shared_ptr<uvgrtp::rtp> rtp, std::string cname, int flags):
flags_(flags), our_role_(RECEIVER),
uvgrtp::rtcp::rtcp(std::shared_ptr<uvgrtp::rtp> rtp, std::string cname, int rce_flags):
rce_flags_(rce_flags), our_role_(RECEIVER),
tp_(0), tc_(0), tn_(0), pmembers_(0),
members_(0), senders_(0), rtcp_bandwidth_(0),
we_sent_(false), avg_rtcp_pkt_pize_(0), rtcp_pkt_count_(0),
@ -87,8 +87,8 @@ uvgrtp::rtcp::rtcp(std::shared_ptr<uvgrtp::rtp> rtp, std::string cname, int flag
}
uvgrtp::rtcp::rtcp(std::shared_ptr<uvgrtp::rtp> rtp, std::string cname,
std::shared_ptr<uvgrtp::srtcp> srtcp, int flags):
rtcp(rtp, cname, flags)
std::shared_ptr<uvgrtp::srtcp> srtcp, int rce_flags):
rtcp(rtp, cname, rce_flags)
{
srtcp_ = srtcp;
}
@ -966,9 +966,9 @@ void uvgrtp::rtcp::update_session_statistics(const uvgrtp::frame::rtp_frame *fra
* have been received.
* - it keeps track of participants' SSRCs and if a collision
* is detected, the RTP context is updated */
rtp_error_t uvgrtp::rtcp::recv_packet_handler(void *arg, int flags, frame::rtp_frame **out)
rtp_error_t uvgrtp::rtcp::recv_packet_handler(void *arg, int rce_flags, frame::rtp_frame **out)
{
(void)flags;
(void)rce_flags;
// The validity of the header has been checked by previous handlers
@ -1054,7 +1054,7 @@ rtp_error_t uvgrtp::rtcp::handle_incoming_packet(uint8_t *buffer, size_t size)
if (size > RTCP_HEADER_SIZE + SSRC_CSRC_SIZE)
{
sender_ssrc = ntohl(*(uint32_t*)& buffer[read_ptr + RTCP_HEADER_SIZE]);
if (srtcp_ && (ret = srtcp_->handle_rtcp_decryption(flags_, sender_ssrc,
if (srtcp_ && (ret = srtcp_->handle_rtcp_decryption(rce_flags_, sender_ssrc,
buffer + RTCP_HEADER_SIZE + SSRC_CSRC_SIZE, size)) != RTP_OK)
{
UVG_LOG_ERROR("Failed at decryption");
@ -1479,7 +1479,7 @@ rtp_error_t uvgrtp::rtcp::send_rtcp_packet_to_participants(uint8_t* frame, size_
rtp_error_t ret = RTP_OK;
if (encrypt && srtcp_ &&
(ret = srtcp_->handle_rtcp_encryption(flags_, rtcp_pkt_sent_count_, ssrc_, frame, frame_size)) != RTP_OK)
(ret = srtcp_->handle_rtcp_encryption(rce_flags_, rtcp_pkt_sent_count_, ssrc_, frame, frame_size)) != RTP_OK)
{
UVG_LOG_DEBUG("Encryption failed. Not sending packet");
delete[] frame;
@ -1530,12 +1530,12 @@ size_t uvgrtp::rtcp::size_of_compound_packet(uint16_t reports,
if (sr_packet)
{
compound_packet_size = get_sr_packet_size(flags_, reports);
compound_packet_size = get_sr_packet_size(rce_flags_, reports);
UVG_LOG_DEBUG("Sending SR. Compound packet size: %li", compound_packet_size);
}
else if (rr_packet)
{
compound_packet_size = get_rr_packet_size(flags_, reports);
compound_packet_size = get_rr_packet_size(rce_flags_, reports);
UVG_LOG_DEBUG("Sending RR. Compound packet size: %li", compound_packet_size);
}
else
@ -1607,7 +1607,7 @@ rtp_error_t uvgrtp::rtcp::generate_report()
if (sr_packet)
{
// sender reports have sender information in addition compared to receiver reports
size_t sender_report_size = get_sr_packet_size(flags_, reports);
size_t sender_report_size = get_sr_packet_size(rce_flags_, reports);
/* TODO: The clock would be better to start with first sent RTP packet.
* In reality it should be provided by user which I think is implemented? */
@ -1633,7 +1633,7 @@ rtp_error_t uvgrtp::rtcp::generate_report()
our_stats.sent_rtp_packet = false;
} else if (rr_packet) { // RECEIVER
size_t receiver_report_size = get_rr_packet_size(flags_, reports);
size_t receiver_report_size = get_rr_packet_size(rce_flags_, reports);
if (!construct_rtcp_header(frame, write_ptr, receiver_report_size, reports, uvgrtp::frame::RTCP_FT_RR) ||
!construct_ssrc(frame, write_ptr, ssrc_))

View File

@ -5,18 +5,18 @@
#include "debug.hh"
size_t uvgrtp::get_sr_packet_size(int flags, uint16_t reports)
size_t uvgrtp::get_sr_packet_size(int rce_flags, uint16_t reports)
{
/* Sender report is otherwise identical with receiver report,
* but it also includes sender info */
return get_rr_packet_size(flags, reports) + SENDER_INFO_SIZE;
return get_rr_packet_size(rce_flags, reports) + SENDER_INFO_SIZE;
}
size_t uvgrtp::get_rr_packet_size(int flags, uint16_t reports)
size_t uvgrtp::get_rr_packet_size(int rce_flags, uint16_t reports)
{
size_t size = (size_t)RTCP_HEADER_SIZE + SSRC_CSRC_SIZE
+ (size_t)REPORT_BLOCK_SIZE * reports;
if (flags & RCE_SRTP)
if (rce_flags & RCE_SRTP)
{
size += UVG_SRTCP_INDEX_LENGTH + UVG_AUTH_TAG_LENGTH;
}

View File

@ -13,8 +13,8 @@ namespace uvgrtp
const uint16_t REPORT_BLOCK_SIZE = 24;
const uint16_t APP_NAME_SIZE = 4;
size_t get_sr_packet_size(int flags, uint16_t reports);
size_t get_rr_packet_size(int flags, uint16_t reports);
size_t get_sr_packet_size(int rce_flags, uint16_t reports);
size_t get_rr_packet_size(int rce_flags, uint16_t reports);
size_t get_sdes_packet_size(const std::vector<uvgrtp::frame::rtcp_sdes_item>& items);
size_t get_app_packet_size(size_t payload_len);
size_t get_bye_packet_size(const std::vector<uint32_t>& ssrcs);

View File

@ -161,9 +161,9 @@ size_t uvgrtp::rtp::get_pkt_max_delay() const
return delay_;
}
rtp_error_t uvgrtp::rtp::packet_handler(ssize_t size, void *packet, int flags, uvgrtp::frame::rtp_frame **out)
rtp_error_t uvgrtp::rtp::packet_handler(ssize_t size, void *packet, int rce_flags, uvgrtp::frame::rtp_frame **out)
{
(void)flags;
(void)rce_flags;
/* not an RTP frame */
if (size < 12)

View File

@ -38,7 +38,7 @@ namespace uvgrtp {
void update_sequence(uint8_t *buffer);
/* Validates the RTP header pointed to by "packet" */
static rtp_error_t packet_handler(ssize_t size, void *packet, int flags, frame::rtp_frame **out);
static rtp_error_t packet_handler(ssize_t size, void *packet, int rce_flags, frame::rtp_frame **out);
private:

View File

@ -31,26 +31,26 @@ uvgrtp::session::~session()
streams_.clear();
}
uvgrtp::media_stream *uvgrtp::session::create_stream(int r_port, int s_port, rtp_format_t fmt, int flags)
uvgrtp::media_stream *uvgrtp::session::create_stream(int r_port, int s_port, rtp_format_t fmt, int rce_flags)
{
std::lock_guard<std::mutex> m(session_mtx_);
uvgrtp::media_stream *stream = nullptr;
if (flags & RCE_SYSTEM_CALL_DISPATCHER) {
if (rce_flags & RCE_SYSTEM_CALL_DISPATCHER) {
UVG_LOG_ERROR("SCD is no longer supported!");
rtp_errno = RTP_NOT_SUPPORTED;
return nullptr;
}
if (laddr_ == "") {
stream = new uvgrtp::media_stream(cname_, addr_, r_port, s_port, fmt, flags);
stream = new uvgrtp::media_stream(cname_, addr_, r_port, s_port, fmt, rce_flags);
}
else {
stream = new uvgrtp::media_stream(cname_, addr_, laddr_, r_port, s_port, fmt, flags);
stream = new uvgrtp::media_stream(cname_, addr_, laddr_, r_port, s_port, fmt, rce_flags);
}
if (flags & RCE_SRTP) {
if (rce_flags & RCE_SRTP) {
if (!uvgrtp::crypto::enabled()) {
UVG_LOG_ERROR("Recompile uvgRTP with -D__RTP_CRYPTO__");
delete stream;
@ -58,12 +58,12 @@ uvgrtp::media_stream *uvgrtp::session::create_stream(int r_port, int s_port, rtp
return nullptr;
}
if (flags & RCE_SRTP_REPLAY_PROTECTION)
flags |= RCE_SRTP_AUTHENTICATE_RTP;
if (rce_flags & RCE_SRTP_REPLAY_PROTECTION)
rce_flags |= RCE_SRTP_AUTHENTICATE_RTP;
if (flags & RCE_SRTP_KMNGMNT_ZRTP) {
if (rce_flags & RCE_SRTP_KMNGMNT_ZRTP) {
if (flags & (RCE_SRTP_KEYSIZE_192 | RCE_SRTP_KEYSIZE_256)) {
if (rce_flags & (RCE_SRTP_KEYSIZE_192 | RCE_SRTP_KEYSIZE_256)) {
UVG_LOG_ERROR("Only 128-bit keys are supported with ZRTP");
return nullptr;
}
@ -76,7 +76,7 @@ uvgrtp::media_stream *uvgrtp::session::create_stream(int r_port, int s_port, rtp
UVG_LOG_ERROR("Failed to initialize media stream %s:%d/%d", addr_.c_str(), r_port, s_port);
return nullptr;
}
} else if (flags & RCE_SRTP_KMNGMNT_USER) {
} else if (rce_flags & RCE_SRTP_KMNGMNT_USER) {
UVG_LOG_DEBUG("SRTP with user-managed keys enabled, postpone initialization");
} else {
UVG_LOG_ERROR("SRTP key management scheme not specified!");

View File

@ -28,9 +28,9 @@ using namespace mingw;
#define WSABUF_SIZE 256
uvgrtp::socket::socket(int flags):
uvgrtp::socket::socket(int rce_flags):
socket_(-1),
flags_(flags)
rce_flags_(rce_flags)
{}
uvgrtp::socket::~socket()
@ -153,12 +153,12 @@ rtp_error_t uvgrtp::socket::install_handler(void *arg, packet_handler_vec handle
return RTP_OK;
}
rtp_error_t uvgrtp::socket::__sendto(sockaddr_in& addr, uint8_t *buf, size_t buf_len, int flags, int *bytes_sent)
rtp_error_t uvgrtp::socket::__sendto(sockaddr_in& addr, uint8_t *buf, size_t buf_len, int send_flags, int *bytes_sent)
{
int nsend = 0;
#ifndef _WIN32
if ((nsend = ::sendto(socket_, buf, buf_len, flags, (const struct sockaddr *)&addr, sizeof(addr_))) == -1) {
if ((nsend = ::sendto(socket_, buf, buf_len, send_flags, (const struct sockaddr *)&addr, sizeof(addr_))) == -1) {
UVG_LOG_ERROR("Failed to send data: %s", strerror(errno));
if (bytes_sent)
@ -172,7 +172,7 @@ rtp_error_t uvgrtp::socket::__sendto(sockaddr_in& addr, uint8_t *buf, size_t buf
data_buf.buf = (char *)buf;
data_buf.len = (ULONG)buf_len;
if (WSASendTo(socket_, &data_buf, 1, &sent_bytes, flags, (const struct sockaddr *)&addr, sizeof(addr_), nullptr, nullptr) == -1) {
if (WSASendTo(socket_, &data_buf, 1, &sent_bytes, send_flags, (const struct sockaddr *)&addr, sizeof(addr_), nullptr, nullptr) == -1) {
win_get_last_error();
if (bytes_sent)
@ -192,30 +192,30 @@ rtp_error_t uvgrtp::socket::__sendto(sockaddr_in& addr, uint8_t *buf, size_t buf
return RTP_OK;
}
rtp_error_t uvgrtp::socket::sendto(uint8_t *buf, size_t buf_len, int flags)
rtp_error_t uvgrtp::socket::sendto(uint8_t *buf, size_t buf_len, int send_flags)
{
return __sendto(addr_, buf, buf_len, flags, nullptr);
return __sendto(addr_, buf, buf_len, send_flags, nullptr);
}
rtp_error_t uvgrtp::socket::sendto(uint8_t *buf, size_t buf_len, int flags, int *bytes_sent)
rtp_error_t uvgrtp::socket::sendto(uint8_t *buf, size_t buf_len, int send_flags, int *bytes_sent)
{
return __sendto(addr_, buf, buf_len, flags, bytes_sent);
return __sendto(addr_, buf, buf_len, send_flags, bytes_sent);
}
rtp_error_t uvgrtp::socket::sendto(sockaddr_in& addr, uint8_t *buf, size_t buf_len, int flags, int *bytes_sent)
rtp_error_t uvgrtp::socket::sendto(sockaddr_in& addr, uint8_t *buf, size_t buf_len, int send_flags, int *bytes_sent)
{
return __sendto(addr, buf, buf_len, flags, bytes_sent);
return __sendto(addr, buf, buf_len, send_flags, bytes_sent);
}
rtp_error_t uvgrtp::socket::sendto(sockaddr_in& addr, uint8_t *buf, size_t buf_len, int flags)
rtp_error_t uvgrtp::socket::sendto(sockaddr_in& addr, uint8_t *buf, size_t buf_len, int send_flags)
{
return __sendto(addr, buf, buf_len, flags, nullptr);
return __sendto(addr, buf, buf_len, send_flags, nullptr);
}
rtp_error_t uvgrtp::socket::__sendtov(
sockaddr_in& addr,
uvgrtp::buf_vec& buffers,
int flags, int *bytes_sent
int send_flags, int *bytes_sent
)
{
#ifndef _WIN32
@ -235,7 +235,7 @@ rtp_error_t uvgrtp::socket::__sendtov(
header_.msg_hdr.msg_control = 0;
header_.msg_hdr.msg_controllen = 0;
if (sendmmsg(socket_, &header_, 1, flags) < 0) {
if (sendmmsg(socket_, &header_, 1, send_flags) < 0) {
UVG_LOG_ERROR("Failed to send RTP frame: %s!", strerror(errno));
set_bytes(bytes_sent, -1);
return RTP_SEND_ERROR;
@ -256,7 +256,7 @@ rtp_error_t uvgrtp::socket::__sendtov(
buffers_[i].buf = (char *)buffers.at(i).second;
}
if (WSASendTo(socket_, buffers_, (DWORD)buffers.size(), &sent_bytes, flags,
if (WSASendTo(socket_, buffers_, (DWORD)buffers.size(), &sent_bytes, send_flags,
(SOCKADDR *)&addr, sizeof(addr_), nullptr, nullptr) == -1) {
win_get_last_error();
@ -275,7 +275,7 @@ rtp_error_t uvgrtp::socket::__sendtov(
return RTP_OK;
}
rtp_error_t uvgrtp::socket::sendto(buf_vec& buffers, int flags)
rtp_error_t uvgrtp::socket::sendto(buf_vec& buffers, int send_flags)
{
rtp_error_t ret = RTP_OK;
@ -286,10 +286,10 @@ rtp_error_t uvgrtp::socket::sendto(buf_vec& buffers, int flags)
}
}
return __sendtov(addr_, buffers, flags, nullptr);
return __sendtov(addr_, buffers, send_flags, nullptr);
}
rtp_error_t uvgrtp::socket::sendto(buf_vec& buffers, int flags, int *bytes_sent)
rtp_error_t uvgrtp::socket::sendto(buf_vec& buffers, int send_flags, int *bytes_sent)
{
rtp_error_t ret = RTP_OK;
@ -300,10 +300,10 @@ rtp_error_t uvgrtp::socket::sendto(buf_vec& buffers, int flags, int *bytes_sent)
}
}
return __sendtov(addr_, buffers, flags, bytes_sent);
return __sendtov(addr_, buffers, send_flags, bytes_sent);
}
rtp_error_t uvgrtp::socket::sendto(sockaddr_in& addr, buf_vec& buffers, int flags)
rtp_error_t uvgrtp::socket::sendto(sockaddr_in& addr, buf_vec& buffers, int send_flags)
{
rtp_error_t ret = RTP_OK;
@ -314,13 +314,13 @@ rtp_error_t uvgrtp::socket::sendto(sockaddr_in& addr, buf_vec& buffers, int flag
}
}
return __sendtov(addr, buffers, flags, nullptr);
return __sendtov(addr, buffers, send_flags, nullptr);
}
rtp_error_t uvgrtp::socket::sendto(
sockaddr_in& addr,
buf_vec& buffers,
int flags, int *bytes_sent
int send_flags, int *bytes_sent
)
{
rtp_error_t ret = RTP_OK;
@ -332,13 +332,13 @@ rtp_error_t uvgrtp::socket::sendto(
}
}
return __sendtov(addr, buffers, flags, bytes_sent);
return __sendtov(addr, buffers, send_flags, bytes_sent);
}
rtp_error_t uvgrtp::socket::__sendtov(
sockaddr_in& addr,
uvgrtp::pkt_vec& buffers,
int flags, int *bytes_sent
int send_flags, int *bytes_sent
)
{
#ifndef _WIN32
@ -361,11 +361,11 @@ rtp_error_t uvgrtp::socket::__sendtov(
}
}
ssize_t npkts = (flags_ & RCE_NO_SYSTEM_CALL_CLUSTERING) ? 1 : 1024;
ssize_t npkts = (rce_flags_ & RCE_NO_SYSTEM_CALL_CLUSTERING) ? 1 : 1024;
ssize_t bptr = buffers.size();
while (bptr > npkts) {
if (sendmmsg(socket_, hptr, npkts, flags) < 0) {
if (sendmmsg(socket_, hptr, npkts, send_flags) < 0) {
log_platform_error("sendmmsg(2) failed");
return RTP_SEND_ERROR;
}
@ -374,7 +374,7 @@ rtp_error_t uvgrtp::socket::__sendtov(
hptr += npkts;
}
if (sendmmsg(socket_, hptr, bptr, flags) < 0) {
if (sendmmsg(socket_, hptr, bptr, send_flags) < 0) {
log_platform_error("sendmmsg(2) failed");
return RTP_SEND_ERROR;
}
@ -406,7 +406,7 @@ send_:
wsa_bufs,
(DWORD)buffer.size(),
&sent_bytes,
flags,
send_flags,
(SOCKADDR *)&addr,
sizeof(addr_),
nullptr,
@ -441,7 +441,7 @@ send_:
return RTP_OK;
}
rtp_error_t uvgrtp::socket::sendto(pkt_vec& buffers, int flags)
rtp_error_t uvgrtp::socket::sendto(pkt_vec& buffers, int send_flags)
{
rtp_error_t ret = RTP_OK;
@ -454,10 +454,10 @@ rtp_error_t uvgrtp::socket::sendto(pkt_vec& buffers, int flags)
}
}
return __sendtov(addr_, buffers, flags, nullptr);
return __sendtov(addr_, buffers, send_flags, nullptr);
}
rtp_error_t uvgrtp::socket::sendto(pkt_vec& buffers, int flags, int *bytes_sent)
rtp_error_t uvgrtp::socket::sendto(pkt_vec& buffers, int send_flags, int *bytes_sent)
{
rtp_error_t ret = RTP_OK;
@ -470,10 +470,10 @@ rtp_error_t uvgrtp::socket::sendto(pkt_vec& buffers, int flags, int *bytes_sent)
}
}
return __sendtov(addr_, buffers, flags, bytes_sent);
return __sendtov(addr_, buffers, send_flags, bytes_sent);
}
rtp_error_t uvgrtp::socket::sendto(sockaddr_in& addr, pkt_vec& buffers, int flags)
rtp_error_t uvgrtp::socket::sendto(sockaddr_in& addr, pkt_vec& buffers, int send_flags)
{
rtp_error_t ret = RTP_OK;
@ -486,10 +486,10 @@ rtp_error_t uvgrtp::socket::sendto(sockaddr_in& addr, pkt_vec& buffers, int flag
}
}
return __sendtov(addr, buffers, flags, nullptr);
return __sendtov(addr, buffers, send_flags, nullptr);
}
rtp_error_t uvgrtp::socket::sendto(sockaddr_in& addr, pkt_vec& buffers, int flags, int *bytes_sent)
rtp_error_t uvgrtp::socket::sendto(sockaddr_in& addr, pkt_vec& buffers, int send_flags, int *bytes_sent)
{
rtp_error_t ret = RTP_OK;
@ -502,10 +502,10 @@ rtp_error_t uvgrtp::socket::sendto(sockaddr_in& addr, pkt_vec& buffers, int flag
}
}
return __sendtov(addr, buffers, flags, bytes_sent);
return __sendtov(addr, buffers, send_flags, bytes_sent);
}
rtp_error_t uvgrtp::socket::__recv(uint8_t *buf, size_t buf_len, int flags, int *bytes_read)
rtp_error_t uvgrtp::socket::__recv(uint8_t *buf, size_t buf_len, int recv_flags, int *bytes_read)
{
if (!buf || !buf_len) {
set_bytes(bytes_read, -1);
@ -513,7 +513,7 @@ rtp_error_t uvgrtp::socket::__recv(uint8_t *buf, size_t buf_len, int flags, int
}
#ifndef _WIN32
int32_t ret = ::recv(socket_, buf, buf_len, flags);
int32_t ret = ::recv(socket_, buf, buf_len, recv_flags);
if (ret == -1) {
if (errno == EAGAIN || errno == EINTR) {
@ -532,9 +532,10 @@ rtp_error_t uvgrtp::socket::__recv(uint8_t *buf, size_t buf_len, int flags, int
WSABUF DataBuf;
DataBuf.len = (u_long)buf_len;
DataBuf.buf = (char *)buf;
DWORD bytes_received, flags_ = 0;
DWORD bytes_received = 0;
DWORD d_recv_flags = 0;
int rc = ::WSARecv(socket_, &DataBuf, 1, &bytes_received, &flags_, NULL, NULL);
int rc = ::WSARecv(socket_, &DataBuf, 1, &bytes_received, &d_recv_flags, NULL, NULL);
if (rc == SOCKET_ERROR) {
int err = WSAGetLastError();
if (err == WSA_IO_PENDING || err == WSAEWOULDBLOCK) {
@ -557,17 +558,17 @@ rtp_error_t uvgrtp::socket::__recv(uint8_t *buf, size_t buf_len, int flags, int
return RTP_OK;
}
rtp_error_t uvgrtp::socket::recv(uint8_t *buf, size_t buf_len, int flags)
rtp_error_t uvgrtp::socket::recv(uint8_t *buf, size_t buf_len, int recv_flags)
{
return uvgrtp::socket::__recv(buf, buf_len, flags, nullptr);
return uvgrtp::socket::__recv(buf, buf_len, recv_flags, nullptr);
}
rtp_error_t uvgrtp::socket::recv(uint8_t *buf, size_t buf_len, int flags, int *bytes_read)
rtp_error_t uvgrtp::socket::recv(uint8_t *buf, size_t buf_len, int recv_flags, int *bytes_read)
{
return uvgrtp::socket::__recv(buf, buf_len, flags, bytes_read);
return uvgrtp::socket::__recv(buf, buf_len, recv_flags, bytes_read);
}
rtp_error_t uvgrtp::socket::__recvfrom(uint8_t *buf, size_t buf_len, int flags, sockaddr_in *sender, int *bytes_read)
rtp_error_t uvgrtp::socket::__recvfrom(uint8_t *buf, size_t buf_len, int recv_flags, sockaddr_in *sender, int *bytes_read)
{
socklen_t *len_ptr = nullptr;
socklen_t len = sizeof(sockaddr_in);
@ -576,7 +577,7 @@ rtp_error_t uvgrtp::socket::__recvfrom(uint8_t *buf, size_t buf_len, int flags,
len_ptr = &len;
#ifndef _WIN32
int32_t ret = ::recvfrom(socket_, buf, buf_len, flags, (struct sockaddr *)sender, len_ptr);
int32_t ret = ::recvfrom(socket_, buf, buf_len, recv_flags, (struct sockaddr *)sender, len_ptr);
if (ret == -1) {
if (errno == EAGAIN || errno == EWOULDBLOCK) {
@ -594,9 +595,10 @@ rtp_error_t uvgrtp::socket::__recvfrom(uint8_t *buf, size_t buf_len, int flags,
WSABUF DataBuf;
DataBuf.len = (u_long)buf_len;
DataBuf.buf = (char *)buf;
DWORD bytes_received, flags_ = 0;
DWORD bytes_received = 0;
DWORD d_recv_flags = 0;
int rc = ::WSARecvFrom(socket_, &DataBuf, 1, &bytes_received, &flags_, (SOCKADDR *)sender, (int *)len_ptr, NULL, NULL);
int rc = ::WSARecvFrom(socket_, &DataBuf, 1, &bytes_received, &d_recv_flags, (SOCKADDR *)sender, (int *)len_ptr, NULL, NULL);
if (WSAGetLastError() == WSAEWOULDBLOCK)
return RTP_INTERRUPTED;
@ -618,24 +620,24 @@ rtp_error_t uvgrtp::socket::__recvfrom(uint8_t *buf, size_t buf_len, int flags,
return RTP_OK;
}
rtp_error_t uvgrtp::socket::recvfrom(uint8_t *buf, size_t buf_len, int flags, sockaddr_in *sender, int *bytes_read)
rtp_error_t uvgrtp::socket::recvfrom(uint8_t *buf, size_t buf_len, int recv_flags, sockaddr_in *sender, int *bytes_read)
{
return __recvfrom(buf, buf_len, flags, sender, bytes_read);
return __recvfrom(buf, buf_len, recv_flags, sender, bytes_read);
}
rtp_error_t uvgrtp::socket::recvfrom(uint8_t *buf, size_t buf_len, int flags, int *bytes_read)
rtp_error_t uvgrtp::socket::recvfrom(uint8_t *buf, size_t buf_len, int recv_flags, int *bytes_read)
{
return __recvfrom(buf, buf_len, flags, nullptr, bytes_read);
return __recvfrom(buf, buf_len, recv_flags, nullptr, bytes_read);
}
rtp_error_t uvgrtp::socket::recvfrom(uint8_t *buf, size_t buf_len, int flags, sockaddr_in *sender)
rtp_error_t uvgrtp::socket::recvfrom(uint8_t *buf, size_t buf_len, int recv_flags, sockaddr_in *sender)
{
return __recvfrom(buf, buf_len, flags, sender, nullptr);
return __recvfrom(buf, buf_len, recv_flags, sender, nullptr);
}
rtp_error_t uvgrtp::socket::recvfrom(uint8_t *buf, size_t buf_len, int flags)
rtp_error_t uvgrtp::socket::recvfrom(uint8_t *buf, size_t buf_len, int recv_flags)
{
return __recvfrom(buf, buf_len, flags, nullptr, nullptr);
return __recvfrom(buf, buf_len, recv_flags, nullptr, nullptr);
}
sockaddr_in& uvgrtp::socket::get_out_address()

View File

@ -76,7 +76,7 @@ rtp_error_t uvgrtp::base_srtp::create_iv(uint8_t *out, uint32_t ssrc, uint64_t i
bool uvgrtp::base_srtp::is_replayed_packet(uint8_t *digest)
{
if (!(remote_srtp_ctx_->flags & RCE_SRTP_REPLAY_PROTECTION))
if (!(remote_srtp_ctx_->rce_flags & RCE_SRTP_REPLAY_PROTECTION))
return false;
uint64_t truncated;
@ -91,36 +91,36 @@ bool uvgrtp::base_srtp::is_replayed_packet(uint8_t *digest)
return false;
}
rtp_error_t uvgrtp::base_srtp::init(int type, int flags, uint8_t* local_key, uint8_t* remote_key,
rtp_error_t uvgrtp::base_srtp::init(int type, int rce_flags, uint8_t* local_key, uint8_t* remote_key,
uint8_t* local_salt, uint8_t* remote_salt)
{
if (!local_key || !remote_key || !local_salt || !remote_salt)
return RTP_INVALID_VALUE;
use_null_cipher_ = (flags & RCE_SRTP_NULL_CIPHER);
use_null_cipher_ = (rce_flags & RCE_SRTP_NULL_CIPHER);
init_srtp_context(local_srtp_ctx_, type, flags, local_key, local_salt);
init_srtp_context(remote_srtp_ctx_, type, flags, remote_key, remote_salt);
init_srtp_context(local_srtp_ctx_, type, rce_flags, local_key, local_salt);
init_srtp_context(remote_srtp_ctx_, type, rce_flags, remote_key, remote_salt);
return RTP_OK;
}
size_t uvgrtp::base_srtp::get_key_size(int flags) const
size_t uvgrtp::base_srtp::get_key_size(int rce_flags) const
{
size_t key_size = AES128_KEY_SIZE;
if (!(flags & RCE_SRTP_KMNGMNT_ZRTP))
if (!(rce_flags & RCE_SRTP_KMNGMNT_ZRTP))
{
if (flags & RCE_SRTP_KEYSIZE_192)
if (rce_flags & RCE_SRTP_KEYSIZE_192)
key_size = AES192_KEY_SIZE;
else if (flags & RCE_SRTP_KEYSIZE_256)
else if (rce_flags & RCE_SRTP_KEYSIZE_256)
key_size = AES256_KEY_SIZE;
}
return key_size;
}
rtp_error_t uvgrtp::base_srtp::init_srtp_context(std::shared_ptr<uvgrtp::srtp_ctx_t> context, int type, int flags,
rtp_error_t uvgrtp::base_srtp::init_srtp_context(std::shared_ptr<uvgrtp::srtp_ctx_t> context, int type, int rce_flags,
uint8_t* key, uint8_t* salt)
{
context->roc = 0;
@ -128,7 +128,7 @@ rtp_error_t uvgrtp::base_srtp::init_srtp_context(std::shared_ptr<uvgrtp::srtp_ct
context->type = type;
context->hmac = HMAC_SHA1;
size_t key_size = get_key_size(flags);
size_t key_size = get_key_size(rce_flags);
switch (key_size) {
case AES128_KEY_SIZE:
@ -154,7 +154,7 @@ rtp_error_t uvgrtp::base_srtp::init_srtp_context(std::shared_ptr<uvgrtp::srtp_ct
context->s_l = 0;
context->replay = nullptr;
context->flags = flags;
context->rce_flags = rce_flags;
int label_enc = 0;
int label_auth = 0;

View File

@ -92,7 +92,7 @@ namespace uvgrtp {
uint16_t s_l = 0; /* highest received sequence number */
uint8_t *replay = nullptr; /* list of recently received and authenticated SRTP packets */
int flags = 0; /* context configuration flags */
int rce_flags = 0; /* context configuration flags */
} srtp_ctx_t;
class base_srtp {
@ -108,7 +108,7 @@ namespace uvgrtp {
* Return RTP_OK if SRTP setup was successful
* Return RTP_INVALID_VALUE if "key" or "salt" is nullptr
* Return RTP_MEMORY allocation failed */
rtp_error_t init(int type, int flags, uint8_t *local_key, uint8_t *remote_key,
rtp_error_t init(int type, int rce_flags, uint8_t *local_key, uint8_t *remote_key,
uint8_t *local_salt, uint8_t *remote_salt);
/* Has RTP packet encryption been disabled? */
@ -122,7 +122,7 @@ namespace uvgrtp {
* Returns false if replay protection has not been enabled */
bool is_replayed_packet(uint8_t *digest);
size_t get_key_size(int flags) const;
size_t get_key_size(int rce_flags) const;
protected:
@ -142,7 +142,7 @@ namespace uvgrtp {
private:
rtp_error_t init_srtp_context(std::shared_ptr<srtp_ctx_t> context, int type, int flags,
rtp_error_t init_srtp_context(std::shared_ptr<srtp_ctx_t> context, int type, int rce_flags,
uint8_t* key, uint8_t* salt);
rtp_error_t derive_key(int label, size_t key_size, uint8_t *key, uint8_t *salt, uint8_t *out, size_t len);

View File

@ -16,14 +16,14 @@ uvgrtp::srtcp::~srtcp()
{
}
rtp_error_t uvgrtp::srtcp::handle_rtcp_encryption(int flags, uint64_t packet_number,
rtp_error_t uvgrtp::srtcp::handle_rtcp_encryption(int rce_flags, uint64_t packet_number,
uint32_t ssrc, uint8_t* frame, size_t frame_size)
{
auto ret = RTP_OK;
/* Encrypt the packet if NULL cipher has not been enabled,
* calculate authentication tag for the packet and add SRTCP index at the end */
if (flags & RCE_SRTP) {
if (rce_flags & RCE_SRTP) {
if (!(RCE_SRTP & RCE_SRTP_NULL_CIPHER)) {
ret = encrypt(ssrc, packet_number, &frame[8],
frame_size - 8 - UVG_SRTCP_INDEX_LENGTH - UVG_AUTH_TAG_LENGTH);
@ -42,19 +42,19 @@ rtp_error_t uvgrtp::srtcp::handle_rtcp_encryption(int flags, uint64_t packet_num
return ret;
}
rtp_error_t uvgrtp::srtcp::handle_rtcp_decryption(int flags, uint32_t ssrc,
rtp_error_t uvgrtp::srtcp::handle_rtcp_decryption(int rce_flags, uint32_t ssrc,
uint8_t* packet, size_t packet_size)
{
auto ret = RTP_OK;
auto srtpi = (*(uint32_t*)&packet[packet_size - UVG_SRTCP_INDEX_LENGTH - UVG_AUTH_TAG_LENGTH]);
if (flags & RCE_SRTP) {
if (rce_flags & RCE_SRTP) {
if ((ret = verify_auth_tag(packet, packet_size)) != RTP_OK) {
UVG_LOG_ERROR("Failed to verify RTCP authentication tag!");
return RTP_AUTH_TAG_MISMATCH;
}
if (((srtpi >> 31) & 0x1) && !(flags & RCE_SRTP_NULL_CIPHER)) {
if (((srtpi >> 31) & 0x1) && !(rce_flags & RCE_SRTP_NULL_CIPHER)) {
if (decrypt(ssrc, srtpi & 0x7fffffff, packet, packet_size) != RTP_OK) {
UVG_LOG_ERROR("Failed to decrypt RTCP Sender Report");
return ret;

View File

@ -12,7 +12,7 @@ namespace uvgrtp {
*
* Report RTP_OK on succes
* Return RTP_INVALID_VALUE if IV creation fails */
rtp_error_t handle_rtcp_encryption(int flags, uint64_t packet_number,
rtp_error_t handle_rtcp_encryption(int rce_flags, uint64_t packet_number,
uint32_t ssrc, uint8_t* frame, size_t frame_size);
/* Decrypt and verify the authenticity of the RTCP packet
@ -21,7 +21,7 @@ namespace uvgrtp {
* Return RTP_INVALID_VALUE if IV creation fails
* Return RTP_AUTH_TAG_MISMATCH if authentication tag is incorrect
* Return RTP_MEMORY_ERROR if memory allocation fails */
rtp_error_t handle_rtcp_decryption(int flags, uint32_t ssrc,
rtp_error_t handle_rtcp_decryption(int rce_flags, uint32_t ssrc,
uint8_t* packet, size_t packet_size);
private:

View File

@ -12,8 +12,8 @@
#define MAX_OFF 10000
uvgrtp::srtp::srtp(int flags):base_srtp(),
authenticate_rtp_(flags & RCE_SRTP_AUTHENTICATE_RTP)
uvgrtp::srtp::srtp(int rce_flags):base_srtp(),
authenticate_rtp_(rce_flags& RCE_SRTP_AUTHENTICATE_RTP)
{}
uvgrtp::srtp::~srtp()
@ -45,9 +45,9 @@ rtp_error_t uvgrtp::srtp::encrypt(uint32_t ssrc, uint16_t seq, uint8_t *buffer,
return RTP_OK;
}
rtp_error_t uvgrtp::srtp::recv_packet_handler(void *arg, int flags, frame::rtp_frame **out)
rtp_error_t uvgrtp::srtp::recv_packet_handler(void *arg, int rce_flags, frame::rtp_frame **out)
{
(void)flags;
(void)rce_flags;
auto srtp = (uvgrtp::srtp *)arg;
auto remote_ctx = srtp->get_remote_ctx();

View File

@ -10,11 +10,11 @@ namespace uvgrtp {
class srtp : public base_srtp {
public:
srtp(int flags);
srtp(int rce_flags);
~srtp();
/* Decrypt the payload of an RTP packet and verify authentication tag (if enabled) */
static rtp_error_t recv_packet_handler(void *arg, int flags, frame::rtp_frame **out);
static rtp_error_t recv_packet_handler(void *arg, int rce_flags, frame::rtp_frame **out);
/* Encrypt the payload of an RTP packet and add authentication tag (if enabled) */
static rtp_error_t send_packet_handler(void *arg, buf_vec& buffers);

View File

@ -43,11 +43,12 @@ uvgrtp_destroy_session(void* uvgrtp_context, void* uvgrtp_session)
}
void
uvgrtp_create_stream(void* uvgrtp_session, void** uvgrtp_stream, uint16_t local_port, uint16_t remote_port, int flags)
uvgrtp_create_stream(void* uvgrtp_session, void** uvgrtp_stream, uint16_t local_port, uint16_t remote_port,
int rce_flags)
{
rtp_format_t fmt = RTP_FORMAT_H265;
uvgrtp::session* uvg_sess_ptr = (uvgrtp::session*)uvgrtp_session;
uvgrtp::media_stream *stream = uvg_sess_ptr->create_stream(local_port, remote_port, fmt, flags);
uvgrtp::media_stream *stream = uvg_sess_ptr->create_stream(local_port, remote_port, fmt, rce_flags);
*uvgrtp_stream = stream;
}
@ -60,8 +61,8 @@ uvgrtp_destroy_stream(void* uvgrtp_session, void* uvgrtp_stream)
}
void
uvgrtp_push_frame(void* uvgrtp_stream, uint8_t* data, size_t data_len, int flags)
uvgrtp_push_frame(void* uvgrtp_stream, uint8_t* data, size_t data_len, int rtp_flags)
{
uvgrtp::media_stream* uvg_stream_ptr = (uvgrtp::media_stream*)uvgrtp_stream;
uvg_stream_ptr->push_frame(data, data_len, flags);
uvg_stream_ptr->push_frame(data, data_len, rtp_flags);
}

View File

@ -794,9 +794,11 @@ rtp_error_t uvgrtp::zrtp::get_srtp_keys(
return RTP_OK;
}
rtp_error_t uvgrtp::zrtp::packet_handler(ssize_t size, void *packet, int flags, frame::rtp_frame **out)
rtp_error_t uvgrtp::zrtp::packet_handler(ssize_t size, void *packet, int rce_flags, frame::rtp_frame **out)
{
(void)size, (void)flags, (void)out;
(void)size; // TODO: Check this
(void)rce_flags;
(void)out;
auto msg = (uvgrtp::zrtp_msg::zrtp_msg *)packet;

View File

@ -68,7 +68,7 @@ namespace uvgrtp {
* Return RTP_OK on success
* Return RTP_PKT_NOT_HANDLED if "buffer" does not contain a ZRTP message
* Return RTP_GENERIC_ERROR if "buffer" contains an invalid ZRTP message */
static rtp_error_t packet_handler(ssize_t size, void *packet, int flags, frame::rtp_frame **out);
static rtp_error_t packet_handler(ssize_t size, void *packet, int rce_flags, frame::rtp_frame **out);
private:
/* Initialize ZRTP session between us and remote using Diffie-Hellman Mode

View File

@ -42,7 +42,7 @@ uvgrtp::zrtp_msg::receiver::~receiver()
delete[] mem_;
}
int uvgrtp::zrtp_msg::receiver::recv_msg(std::shared_ptr<uvgrtp::socket> socket, int timeout, int flags)
int uvgrtp::zrtp_msg::receiver::recv_msg(std::shared_ptr<uvgrtp::socket> socket, int timeout, int recv_flags)
{
rtp_error_t ret = RTP_GENERIC_ERROR;
int nread = 0;
@ -70,7 +70,7 @@ int uvgrtp::zrtp_msg::receiver::recv_msg(std::shared_ptr<uvgrtp::socket> socket,
if (socket->setsockopt(SOL_SOCKET, SO_RCVTIMEO, (const char *)&tv, sizeof(tv)) != RTP_OK)
return RTP_GENERIC_ERROR;
if ((ret = socket->recv(mem_, len_, flags, &nread)) != RTP_OK) {
if ((ret = socket->recv(mem_, len_, recv_flags, &nread)) != RTP_OK) {
if (ret == RTP_INTERRUPTED)
return ret;

View File

@ -27,7 +27,7 @@ namespace uvgrtp {
* Return -EPROTONOSUPPORT if message contains incompatible version number
* Return -ENOPNOTSUPP if message type is not supported
* Return -errno for any other error */
int recv_msg(std::shared_ptr<uvgrtp::socket> socket, int timeout, int flags);
int recv_msg(std::shared_ptr<uvgrtp::socket> socket, int timeout, int recv_flags);
/* TODO: */
ssize_t get_msg(void *ptr, size_t len);