common: prepend logging macros with UVG_ to avoid collisions.
This commit is contained in:
parent
6620c5a01b
commit
2d378a3161
|
@ -63,30 +63,30 @@ static inline void uvgrtp_debug(const char *level, const char *function, const c
|
|||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
#define LOG_DEBUG(...) uvgrtp_debug(LOG_LEVEL_DEBUG, __func__, __VA_ARGS__)
|
||||
#define UVG_LOG_DEBUG(...) uvgrtp_debug(LOG_LEVEL_DEBUG, __func__, __VA_ARGS__)
|
||||
#else
|
||||
#define LOG_DEBUG(...) ;
|
||||
#define UVG_LOG_DEBUG(...) ;
|
||||
#endif
|
||||
|
||||
#ifdef __RTP_SILENT__
|
||||
#define LOG_ERROR(...) ;
|
||||
#define LOG_WARN(...) ;
|
||||
#define LOG_INFO(...) ;
|
||||
#undef LOG_DEBUG
|
||||
#define LOG_DEBUG(...) ;
|
||||
#define UVG_LOG_ERROR(...) ;
|
||||
#define UVG_LOG_WARN(...) ;
|
||||
#define UVG_LOG_INFO(...) ;
|
||||
#undef UVG_LOG_DEBUG
|
||||
#define UVG_LOG_DEBUG(...) ;
|
||||
#else
|
||||
#define LOG_ERROR(...) uvgrtp_debug(LOG_LEVEL_ERROR, __func__, __VA_ARGS__)
|
||||
#define LOG_WARN(...) uvgrtp_debug(LOG_LEVEL_WARN, __func__, __VA_ARGS__)
|
||||
#define LOG_INFO(...) uvgrtp_debug(LOG_LEVEL_INFO, __func__, __VA_ARGS__)
|
||||
#define UVG_LOG_ERROR(...) uvgrtp_debug(LOG_LEVEL_ERROR, __func__, __VA_ARGS__)
|
||||
#define UVG_LOG_WARN(...) uvgrtp_debug(LOG_LEVEL_WARN, __func__, __VA_ARGS__)
|
||||
#define UVG_LOG_INFO(...) uvgrtp_debug(LOG_LEVEL_INFO, __func__, __VA_ARGS__)
|
||||
#endif
|
||||
|
||||
static inline void log_platform_error(const char *aux)
|
||||
{
|
||||
#ifndef _WIN32
|
||||
if (aux) {
|
||||
LOG_ERROR("%s: %s %d\n", aux, strerror(errno), errno);
|
||||
UVG_LOG_ERROR("%s: %s %d\n", aux, strerror(errno), errno);
|
||||
} else {
|
||||
LOG_ERROR("%s %d\n", strerror(errno), errno);
|
||||
UVG_LOG_ERROR("%s %d\n", strerror(errno), errno);
|
||||
}
|
||||
#else
|
||||
wchar_t *s = NULL;
|
||||
|
@ -98,9 +98,9 @@ static inline void log_platform_error(const char *aux)
|
|||
);
|
||||
|
||||
if (aux) {
|
||||
LOG_ERROR("%s: %ls %d\n", aux, s, WSAGetLastError());
|
||||
UVG_LOG_ERROR("%s: %ls %d\n", aux, s, WSAGetLastError());
|
||||
} else {
|
||||
LOG_ERROR("%ls %d\n", s, WSAGetLastError());
|
||||
UVG_LOG_ERROR("%ls %d\n", s, WSAGetLastError());
|
||||
}
|
||||
LocalFree(s);
|
||||
#endif
|
||||
|
|
|
@ -18,7 +18,7 @@ static inline uint32_t ntp_diff_ms(uint64_t older, uint64_t newer)
|
|||
|
||||
if (r > UINT32_MAX)
|
||||
{
|
||||
LOG_ERROR("NTP difference is too large: %llu. Limiting value", r);
|
||||
UVG_LOG_ERROR("NTP difference is too large: %llu. Limiting value", r);
|
||||
r = UINT32_MAX;
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ thread_local rtp_error_t rtp_errno;
|
|||
|
||||
uvgrtp::context::context()
|
||||
{
|
||||
LOG_INFO("uvgRTP version: %s", uvgrtp::get_version().c_str());
|
||||
UVG_LOG_INFO("uvgRTP version: %s", uvgrtp::get_version().c_str());
|
||||
|
||||
cname_ = uvgrtp::context::generate_cname();
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ void uvgrtp::crypto::hmac::sha1::update(const uint8_t *data, size_t len)
|
|||
#else
|
||||
(void)data, (void)len;
|
||||
|
||||
LOG_ERROR("Recompile uvgRTP with -D__RTP_CRYPTO__");
|
||||
UVG_LOG_ERROR("Recompile uvgRTP with -D__RTP_CRYPTO__");
|
||||
exit(EXIT_FAILURE);
|
||||
#endif
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ void uvgrtp::crypto::hmac::sha1::final(uint8_t *digest)
|
|||
#else
|
||||
(void)digest;
|
||||
|
||||
LOG_ERROR("Recompile uvgRTP with -D__RTP_CRYPTO__");
|
||||
UVG_LOG_ERROR("Recompile uvgRTP with -D__RTP_CRYPTO__");
|
||||
exit(EXIT_FAILURE);
|
||||
#endif
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ void uvgrtp::crypto::hmac::sha1::final(uint8_t *digest, size_t size)
|
|||
#else
|
||||
(void)digest, (void)size;
|
||||
|
||||
LOG_ERROR("Recompile uvgRTP with -D__RTP_CRYPTO__");
|
||||
UVG_LOG_ERROR("Recompile uvgRTP with -D__RTP_CRYPTO__");
|
||||
exit(EXIT_FAILURE);
|
||||
#endif
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ void uvgrtp::crypto::hmac::sha256::update(const uint8_t *data, size_t len)
|
|||
#else
|
||||
(void)data, (void)len;
|
||||
|
||||
LOG_ERROR("Recompile uvgRTP with -D__RTP_CRYPTO__");
|
||||
UVG_LOG_ERROR("Recompile uvgRTP with -D__RTP_CRYPTO__");
|
||||
exit(EXIT_FAILURE);
|
||||
#endif
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ void uvgrtp::crypto::hmac::sha256::final(uint8_t *digest)
|
|||
#else
|
||||
(void)digest;
|
||||
|
||||
LOG_ERROR("Recompile uvgRTP with -D__RTP_CRYPTO__");
|
||||
UVG_LOG_ERROR("Recompile uvgRTP with -D__RTP_CRYPTO__");
|
||||
exit(EXIT_FAILURE);
|
||||
#endif
|
||||
}
|
||||
|
@ -120,7 +120,7 @@ void uvgrtp::crypto::sha256::update(const uint8_t *data, size_t len)
|
|||
#else
|
||||
(void)data, (void)len;
|
||||
|
||||
LOG_ERROR("Recompile uvgRTP with -D__RTP_CRYPTO__");
|
||||
UVG_LOG_ERROR("Recompile uvgRTP with -D__RTP_CRYPTO__");
|
||||
exit(EXIT_FAILURE);
|
||||
#endif
|
||||
}
|
||||
|
@ -132,7 +132,7 @@ void uvgrtp::crypto::sha256::final(uint8_t *digest)
|
|||
#else
|
||||
(void)digest;
|
||||
|
||||
LOG_ERROR("Recompile uvgRTP with -D__RTP_CRYPTO__");
|
||||
UVG_LOG_ERROR("Recompile uvgRTP with -D__RTP_CRYPTO__");
|
||||
exit(EXIT_FAILURE);
|
||||
#endif
|
||||
}
|
||||
|
@ -161,7 +161,7 @@ void uvgrtp::crypto::aes::ctr::encrypt(uint8_t *output, const uint8_t *input, si
|
|||
#else
|
||||
(void)output, (void)input, (void)len;
|
||||
|
||||
LOG_ERROR("Recompile uvgRTP with -D__RTP_CRYPTO__");
|
||||
UVG_LOG_ERROR("Recompile uvgRTP with -D__RTP_CRYPTO__");
|
||||
exit(EXIT_FAILURE);
|
||||
#endif
|
||||
}
|
||||
|
@ -173,7 +173,7 @@ void uvgrtp::crypto::aes::ctr::decrypt(uint8_t *output, const uint8_t *input, si
|
|||
#else
|
||||
(void)output, (void)input, (void)len;
|
||||
|
||||
LOG_ERROR("Recompile uvgRTP with -D__RTP_CRYPTO__");
|
||||
UVG_LOG_ERROR("Recompile uvgRTP with -D__RTP_CRYPTO__");
|
||||
exit(EXIT_FAILURE);
|
||||
#endif
|
||||
}
|
||||
|
@ -200,7 +200,7 @@ void uvgrtp::crypto::aes::cfb::encrypt(uint8_t *output, const uint8_t *input, si
|
|||
#else
|
||||
(void)output, (void)input, (void)len;
|
||||
|
||||
LOG_ERROR("Recompile uvgRTP with -D__RTP_CRYPTO__");
|
||||
UVG_LOG_ERROR("Recompile uvgRTP with -D__RTP_CRYPTO__");
|
||||
exit(EXIT_FAILURE);
|
||||
#endif
|
||||
}
|
||||
|
@ -212,7 +212,7 @@ void uvgrtp::crypto::aes::cfb::decrypt(uint8_t *output, const uint8_t *input, si
|
|||
#else
|
||||
(void)output, (void)input, (void)len;
|
||||
|
||||
LOG_ERROR("Recompile uvgRTP with -D__RTP_CRYPTO__");
|
||||
UVG_LOG_ERROR("Recompile uvgRTP with -D__RTP_CRYPTO__");
|
||||
exit(EXIT_FAILURE);
|
||||
#endif
|
||||
}
|
||||
|
@ -239,7 +239,7 @@ void uvgrtp::crypto::aes::ecb::encrypt(uint8_t *output, const uint8_t *input, si
|
|||
#else
|
||||
(void)output, (void)input, (void)len;
|
||||
|
||||
LOG_ERROR("Recompile uvgRTP with -D__RTP_CRYPTO__");
|
||||
UVG_LOG_ERROR("Recompile uvgRTP with -D__RTP_CRYPTO__");
|
||||
exit(EXIT_FAILURE);
|
||||
#endif
|
||||
}
|
||||
|
@ -251,7 +251,7 @@ void uvgrtp::crypto::aes::ecb::decrypt(uint8_t *output, const uint8_t *input, si
|
|||
#else
|
||||
(void)output, (void)input, (void)len;
|
||||
|
||||
LOG_ERROR("Recompile uvgRTP with -D__RTP_CRYPTO__");
|
||||
UVG_LOG_ERROR("Recompile uvgRTP with -D__RTP_CRYPTO__");
|
||||
exit(EXIT_FAILURE);
|
||||
#endif
|
||||
}
|
||||
|
@ -289,7 +289,7 @@ uvgrtp::crypto::dh::dh()
|
|||
|
||||
dh_.AccessGroupParameters().Initialize(p, g);
|
||||
#else
|
||||
LOG_ERROR("Recompile uvgRTP with -D__RTP_CRYPTO__");
|
||||
UVG_LOG_ERROR("Recompile uvgRTP with -D__RTP_CRYPTO__");
|
||||
exit(EXIT_FAILURE);
|
||||
#endif
|
||||
}
|
||||
|
@ -307,7 +307,7 @@ void uvgrtp::crypto::dh::generate_keys()
|
|||
sk_ = CryptoPP::Integer(t1, t1.size());
|
||||
pk_ = CryptoPP::Integer(t2, t2.size());
|
||||
#else
|
||||
LOG_ERROR("Recompile uvgRTP with -D__RTP_CRYPTO__");
|
||||
UVG_LOG_ERROR("Recompile uvgRTP with -D__RTP_CRYPTO__");
|
||||
exit(EXIT_FAILURE);
|
||||
#endif
|
||||
}
|
||||
|
@ -319,7 +319,7 @@ void uvgrtp::crypto::dh::get_pk(uint8_t *pk, size_t len)
|
|||
#else
|
||||
(void)pk, (void)len;
|
||||
|
||||
LOG_ERROR("Recompile uvgRTP with -D__RTP_CRYPTO__");
|
||||
UVG_LOG_ERROR("Recompile uvgRTP with -D__RTP_CRYPTO__");
|
||||
exit(EXIT_FAILURE);
|
||||
#endif
|
||||
}
|
||||
|
@ -331,7 +331,7 @@ void uvgrtp::crypto::dh::set_remote_pk(uint8_t *pk, size_t len)
|
|||
#else
|
||||
(void)pk, (void)len;
|
||||
|
||||
LOG_ERROR("Recompile uvgRTP with -D__RTP_CRYPTO__");
|
||||
UVG_LOG_ERROR("Recompile uvgRTP with -D__RTP_CRYPTO__");
|
||||
exit(EXIT_FAILURE);
|
||||
#endif
|
||||
}
|
||||
|
@ -365,7 +365,7 @@ void uvgrtp::crypto::dh::get_shared_secret(uint8_t *ss, size_t len)
|
|||
#else
|
||||
(void)ss, (void)len;
|
||||
|
||||
LOG_ERROR("Recompile uvgRTP with -D__RTP_CRYPTO__");
|
||||
UVG_LOG_ERROR("Recompile uvgRTP with -D__RTP_CRYPTO__");
|
||||
exit(EXIT_FAILURE);
|
||||
#endif
|
||||
}
|
||||
|
@ -396,7 +396,7 @@ void uvgrtp::crypto::b32::encode(const uint8_t *input, uint8_t *output, size_t l
|
|||
#else
|
||||
(void)input, (void)output, (void)len;
|
||||
|
||||
LOG_ERROR("Recompile uvgRTP with -D__RTP_CRYPTO__");
|
||||
UVG_LOG_ERROR("Recompile uvgRTP with -D__RTP_CRYPTO__");
|
||||
exit(EXIT_FAILURE);
|
||||
#endif
|
||||
}
|
||||
|
@ -411,7 +411,7 @@ void uvgrtp::crypto::random::generate_random(uint8_t *out, size_t len)
|
|||
#else
|
||||
(void)out, (void)len;
|
||||
|
||||
LOG_ERROR("Recompile uvgRTP with -D__RTP_CRYPTO__");
|
||||
UVG_LOG_ERROR("Recompile uvgRTP with -D__RTP_CRYPTO__");
|
||||
exit(EXIT_FAILURE);
|
||||
#endif
|
||||
}
|
||||
|
@ -428,7 +428,7 @@ void uvgrtp::crypto::crc32::get_crc32(const uint8_t *input, size_t len, uint32_t
|
|||
#else
|
||||
(void)input, (void)len, (void)output;
|
||||
|
||||
LOG_ERROR("Recompile uvgRTP with -D__RTP_CRYPTO__");
|
||||
UVG_LOG_ERROR("Recompile uvgRTP with -D__RTP_CRYPTO__");
|
||||
exit(EXIT_FAILURE);
|
||||
#endif
|
||||
}
|
||||
|
@ -446,7 +446,7 @@ uint32_t uvgrtp::crypto::crc32::calculate_crc32(const uint8_t *input, size_t len
|
|||
#else
|
||||
(void)input, (void)len;
|
||||
|
||||
LOG_ERROR("Recompile uvgRTP with -D__RTP_CRYPTO__");
|
||||
UVG_LOG_ERROR("Recompile uvgRTP with -D__RTP_CRYPTO__");
|
||||
exit(EXIT_FAILURE);
|
||||
#endif
|
||||
}
|
||||
|
@ -464,7 +464,7 @@ bool uvgrtp::crypto::crc32::verify_crc32(const uint8_t *input, size_t len, uint3
|
|||
#else
|
||||
(void)input, (void)len, (void)old_crc;
|
||||
|
||||
LOG_ERROR("Recompile uvgRTP with -D__RTP_CRYPTO__");
|
||||
UVG_LOG_ERROR("Recompile uvgRTP with -D__RTP_CRYPTO__");
|
||||
exit(EXIT_FAILURE);
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -131,12 +131,12 @@ rtp_error_t uvgrtp::formats::h264::finalize_aggregation_pkt()
|
|||
}
|
||||
else
|
||||
{
|
||||
LOG_ERROR("NAL unit is too large");
|
||||
UVG_LOG_ERROR("NAL unit is too large");
|
||||
}
|
||||
}
|
||||
|
||||
if ((ret = fqueue_->enqueue_message(aggr_pkt_info_.aggr_pkt)) != RTP_OK) {
|
||||
LOG_ERROR("Failed to enqueue NALUs of an aggregation packet!");
|
||||
UVG_LOG_ERROR("Failed to enqueue NALUs of an aggregation packet!");
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -203,4 +203,4 @@ void uvgrtp::formats::h264::prepend_start_code(int flags, uvgrtp::frame::rtp_fra
|
|||
(*out)->payload = pl;
|
||||
(*out)->payload_len += 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -145,12 +145,12 @@ rtp_error_t uvgrtp::formats::h265::finalize_aggregation_pkt()
|
|||
)
|
||||
);
|
||||
} else {
|
||||
LOG_ERROR("NALU too large");
|
||||
UVG_LOG_ERROR("NALU too large");
|
||||
}
|
||||
}
|
||||
|
||||
if ((ret = fqueue_->enqueue_message(aggr_pkt_info_.aggr_pkt)) != RTP_OK) {
|
||||
LOG_ERROR("Failed to enqueue buffers of an aggregation packet!");
|
||||
UVG_LOG_ERROR("Failed to enqueue buffers of an aggregation packet!");
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -182,4 +182,4 @@ rtp_error_t uvgrtp::formats::h265::fu_division(uint8_t* data, size_t data_len, s
|
|||
buffers->push_back(std::make_pair(payload_size, nullptr));
|
||||
|
||||
return divide_frame_to_fus(data, data_len, payload_size, *buffers, headers->fu_headers);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -280,7 +280,7 @@ rtp_error_t uvgrtp::formats::h26x::push_media_frame(uint8_t* data, size_t data_l
|
|||
return RTP_INVALID_VALUE;
|
||||
|
||||
if ((ret = fqueue_->init_transaction(data)) != RTP_OK) {
|
||||
LOG_ERROR("Invalid frame queue or failed to initialize transaction!");
|
||||
UVG_LOG_ERROR("Invalid frame queue or failed to initialize transaction!");
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -305,7 +305,7 @@ rtp_error_t uvgrtp::formats::h26x::push_media_frame(uint8_t* data, size_t data_l
|
|||
|
||||
if (nals.empty())
|
||||
{
|
||||
LOG_ERROR("Did not find any NAL units in frame. Cannot send.");
|
||||
UVG_LOG_ERROR("Did not find any NAL units in frame. Cannot send.");
|
||||
return RTP_INVALID_VALUE;
|
||||
}
|
||||
|
||||
|
@ -381,7 +381,7 @@ rtp_error_t uvgrtp::formats::h26x::single_nal_unit(uint8_t* data, size_t data_le
|
|||
// correct as is
|
||||
rtp_error_t ret = RTP_OK;
|
||||
if ((ret = fqueue_->enqueue_message(data, data_len)) != RTP_OK) {
|
||||
LOG_ERROR("Failed to enqueue single h26x NAL Unit packet!");
|
||||
UVG_LOG_ERROR("Failed to enqueue single h26x NAL Unit packet!");
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -392,7 +392,7 @@ rtp_error_t uvgrtp::formats::h26x::divide_frame_to_fus(uint8_t* data, size_t& da
|
|||
{
|
||||
if (data_left <= payload_size)
|
||||
{
|
||||
LOG_ERROR("Cannot use FU division for packets smaller than payload size");
|
||||
UVG_LOG_ERROR("Cannot use FU division for packets smaller than payload size");
|
||||
return RTP_GENERIC_ERROR;
|
||||
}
|
||||
|
||||
|
@ -417,7 +417,7 @@ rtp_error_t uvgrtp::formats::h26x::divide_frame_to_fus(uint8_t* data, size_t& da
|
|||
buffers.at(2).second = &data[data_pos];
|
||||
|
||||
if ((ret = fqueue_->enqueue_message(buffers)) != RTP_OK) {
|
||||
LOG_ERROR("Queueing the FU packet failed!");
|
||||
UVG_LOG_ERROR("Queueing the FU packet failed!");
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -435,7 +435,7 @@ rtp_error_t uvgrtp::formats::h26x::divide_frame_to_fus(uint8_t* data, size_t& da
|
|||
|
||||
// send the last fragment
|
||||
if ((ret = fqueue_->enqueue_message(buffers)) != RTP_OK) {
|
||||
LOG_ERROR("Failed to send the last fragment of an H26x frame!");
|
||||
UVG_LOG_ERROR("Failed to send the last fragment of an H26x frame!");
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -502,14 +502,14 @@ uint32_t uvgrtp::formats::h26x::drop_frame(uint32_t ts)
|
|||
uint32_t total_cleaned = 0;
|
||||
if (frames_.find(ts) == frames_.end())
|
||||
{
|
||||
LOG_ERROR("Tried to drop a non-existing frame");
|
||||
UVG_LOG_ERROR("Tried to drop a non-existing frame");
|
||||
return total_cleaned;
|
||||
}
|
||||
|
||||
uint16_t s_seq = frames_.at(ts).s_seq;
|
||||
uint16_t e_seq = frames_.at(ts).e_seq;
|
||||
|
||||
//LOG_INFO("Dropping frame. Ts: %lu, Seq: %u <-> %u, received/expected: %lli/%lli",
|
||||
//UVG_LOG_INFO("Dropping frame. Ts: %lu, Seq: %u <-> %u, received/expected: %lli/%lli",
|
||||
// ts, s_seq, e_seq, frames_[ts].received_packet_seqs.size(), calculate_expected_fus(ts));
|
||||
|
||||
for (auto& fragment_seq : frames_[ts].received_packet_seqs)
|
||||
|
@ -544,7 +544,7 @@ rtp_error_t uvgrtp::formats::h26x::handle_aggregation_packet(uvgrtp::frame::rtp_
|
|||
nalus.push_back(std::make_pair(packet_size, &frame->payload[i] + sizeof(uint16_t)));
|
||||
}
|
||||
else {
|
||||
LOG_ERROR("The received aggregation packet claims to be larger than packet!");
|
||||
UVG_LOG_ERROR("The received aggregation packet claims to be larger than packet!");
|
||||
return RTP_GENERIC_ERROR;
|
||||
}
|
||||
}
|
||||
|
@ -588,7 +588,7 @@ rtp_error_t uvgrtp::formats::h26x::packet_handler(int flags, uvgrtp::frame::rtp_
|
|||
}
|
||||
else if (frag_type == uvgrtp::formats::FRAG_TYPE::FT_INVALID) {
|
||||
// something is wrong
|
||||
LOG_WARN("invalid frame received!");
|
||||
UVG_LOG_WARN("invalid frame received!");
|
||||
(void)uvgrtp::frame::dealloc_frame(*out);
|
||||
*out = nullptr;
|
||||
return RTP_GENERIC_ERROR;
|
||||
|
@ -609,7 +609,7 @@ rtp_error_t uvgrtp::formats::h26x::packet_handler(int flags, uvgrtp::frame::rtp_
|
|||
|
||||
// Make sure we haven't discarded the frame corresponding to the fragment timestamp before
|
||||
if (dropped_.find(fragment_ts) != dropped_.end()) {
|
||||
LOG_DEBUG("Fragment belonging to a dropped frame was received! Timestamp: %lu",
|
||||
UVG_LOG_DEBUG("Fragment belonging to a dropped frame was received! Timestamp: %lu",
|
||||
fragment_ts);
|
||||
return RTP_GENERIC_ERROR;
|
||||
}
|
||||
|
@ -620,7 +620,7 @@ rtp_error_t uvgrtp::formats::h26x::packet_handler(int flags, uvgrtp::frame::rtp_
|
|||
frames_[fragment_ts].received_packet_seqs.end()) {
|
||||
|
||||
// we have already received this seq
|
||||
LOG_DEBUG("Detected duplicate fragment, dropping! Seq: %u", fragment_seq);
|
||||
UVG_LOG_DEBUG("Detected duplicate fragment, dropping! Seq: %u", fragment_seq);
|
||||
(void)uvgrtp::frame::dealloc_frame(frame); // free fragment memory
|
||||
*out = nullptr;
|
||||
return RTP_GENERIC_ERROR;
|
||||
|
@ -631,7 +631,7 @@ rtp_error_t uvgrtp::formats::h26x::packet_handler(int flags, uvgrtp::frame::rtp_
|
|||
|
||||
if (frames_[fragment_ts].nal_type != nal_type)
|
||||
{
|
||||
LOG_ERROR("The fragment has different NAL type fragments before!");
|
||||
UVG_LOG_ERROR("The fragment has different NAL type fragments before!");
|
||||
return RTP_GENERIC_ERROR;
|
||||
}
|
||||
|
||||
|
@ -641,7 +641,7 @@ rtp_error_t uvgrtp::formats::h26x::packet_handler(int flags, uvgrtp::frame::rtp_
|
|||
|
||||
if (fragments_[fragment_seq] != nullptr)
|
||||
{
|
||||
LOG_WARN("Found an existing fragment with same sequence number %u! Fragment ts: %lu, current ts: %lu",
|
||||
UVG_LOG_WARN("Found an existing fragment with same sequence number %u! Fragment ts: %lu, current ts: %lu",
|
||||
fragment_seq, fragments_[fragment_seq]->header.timestamp, fragment_ts);
|
||||
|
||||
free_fragment(fragment_seq);
|
||||
|
@ -671,7 +671,7 @@ rtp_error_t uvgrtp::formats::h26x::packet_handler(int flags, uvgrtp::frame::rtp_
|
|||
// 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) {
|
||||
LOG_WARN("Dropping h26x frame because of missing reference. Timestamp: %lu. Seq: %u - %u",
|
||||
UVG_LOG_WARN("Dropping h26x frame because of missing reference. Timestamp: %lu. Seq: %u - %u",
|
||||
fragment_ts, frames_[fragment_ts].s_seq, frames_[fragment_ts].e_seq);
|
||||
|
||||
drop_frame(fragment_ts);
|
||||
|
@ -680,7 +680,7 @@ rtp_error_t uvgrtp::formats::h26x::packet_handler(int flags, uvgrtp::frame::rtp_
|
|||
else if (nal_type == uvgrtp::formats::NAL_TYPE::NT_INTRA) {
|
||||
|
||||
// we don't have to discard anymore
|
||||
LOG_INFO("Found a key frame at ts %lu", fragment_ts);
|
||||
UVG_LOG_INFO("Found a key frame at ts %lu", fragment_ts);
|
||||
discard_until_key_frame_ = false;
|
||||
}
|
||||
}
|
||||
|
@ -703,7 +703,7 @@ void uvgrtp::formats::h26x::garbage_collect_lost_frames(size_t timout)
|
|||
// first find all frames that have been waiting for too long
|
||||
for (auto& gc_frame : frames_) {
|
||||
if (uvgrtp::clock::hrc::diff_now(gc_frame.second.sframe_time) > timout) {
|
||||
LOG_WARN("Found an old frame that has not been completed");
|
||||
UVG_LOG_WARN("Found an old frame that has not been completed");
|
||||
to_remove.push_back(gc_frame.first);
|
||||
}
|
||||
}
|
||||
|
@ -715,7 +715,7 @@ void uvgrtp::formats::h26x::garbage_collect_lost_frames(size_t timout)
|
|||
}
|
||||
|
||||
if (total_cleaned > 0) {
|
||||
LOG_INFO("Garbage collection cleaned %d bytes!", total_cleaned);
|
||||
UVG_LOG_INFO("Garbage collection cleaned %d bytes!", total_cleaned);
|
||||
}
|
||||
|
||||
last_garbage_collection_ = uvgrtp::clock::hrc::now();
|
||||
|
@ -757,7 +757,7 @@ void uvgrtp::formats::h26x::free_fragment(uint16_t sequence_number)
|
|||
{
|
||||
if (fragments_[sequence_number] == nullptr)
|
||||
{
|
||||
LOG_ERROR("Tried to free an already freed fragment with seq: %u", sequence_number);
|
||||
UVG_LOG_ERROR("Tried to free an already freed fragment with seq: %u", sequence_number);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -838,7 +838,7 @@ rtp_error_t uvgrtp::formats::h26x::reconstruction(uvgrtp::frame::rtp_frame** out
|
|||
{
|
||||
if (fragments_[i] == nullptr)
|
||||
{
|
||||
LOG_ERROR("Missing fragment in reconstruction. Seq range: %u - %u. Missing seq %u",
|
||||
UVG_LOG_ERROR("Missing fragment in reconstruction. Seq range: %u - %u. Missing seq %u",
|
||||
frames_.at(frame_timestamp).s_seq, frames_.at(frame_timestamp).e_seq, i);
|
||||
return RTP_GENERIC_ERROR;
|
||||
}
|
||||
|
|
|
@ -45,19 +45,19 @@ rtp_error_t uvgrtp::formats::media::push_media_frame(uint8_t *data, size_t data_
|
|||
rtp_error_t ret;
|
||||
|
||||
if ((ret = fqueue_->init_transaction(data)) != RTP_OK) {
|
||||
LOG_ERROR("Invalid frame queue or failed to initialize transaction!");
|
||||
UVG_LOG_ERROR("Invalid frame queue or failed to initialize transaction!");
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (!(flags_ & RCE_FRAGMENT_GENERIC) || data_len <= rtp_ctx_->get_payload_size()) {
|
||||
if (data_len > rtp_ctx_->get_payload_size()) {
|
||||
LOG_WARN("Packet is larger (%zu bytes) than maximum payload size (%zu bytes)",
|
||||
UVG_LOG_WARN("Packet is larger (%zu bytes) than maximum payload size (%zu bytes)",
|
||||
data_len, rtp_ctx_->get_payload_size());
|
||||
LOG_WARN("Consider using RCE_FRAGMENT_GENERIC!");
|
||||
UVG_LOG_WARN("Consider using RCE_FRAGMENT_GENERIC!");
|
||||
}
|
||||
|
||||
if ((ret = fqueue_->enqueue_message(data, data_len)) != RTP_OK) {
|
||||
LOG_ERROR("Failed to enqueue message: %d", ret);
|
||||
UVG_LOG_ERROR("Failed to enqueue message: %d", ret);
|
||||
(void)fqueue_->deinit_transaction();
|
||||
return ret;
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ rtp_error_t uvgrtp::formats::media::push_media_frame(uint8_t *data, size_t data_
|
|||
|
||||
while (data_left > (ssize_t)payload_size) {
|
||||
if ((ret = fqueue_->enqueue_message(data + data_pos, payload_size, set_marker)) != RTP_OK) {
|
||||
LOG_ERROR("Failed to enqueue packet when fragmenting generic frame");
|
||||
UVG_LOG_ERROR("Failed to enqueue packet when fragmenting generic frame");
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -82,7 +82,7 @@ rtp_error_t uvgrtp::formats::media::push_media_frame(uint8_t *data, size_t data_
|
|||
}
|
||||
|
||||
if ((ret = fqueue_->enqueue_message(data + data_pos, data_left, true)) != RTP_OK) {
|
||||
LOG_ERROR("Failed to enqueue packet when fragmenting generic frame");
|
||||
UVG_LOG_ERROR("Failed to enqueue packet when fragmenting generic frame");
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ rtp_error_t uvgrtp::frame::dealloc_frame(uvgrtp::frame::rtp_frame *frame)
|
|||
else if (frame->payload)
|
||||
delete[] frame->payload;
|
||||
|
||||
//LOG_DEBUG("Deallocating frame, type %u", frame->type);
|
||||
//UVG_LOG_DEBUG("Deallocating frame, type %u", frame->type);
|
||||
|
||||
delete frame;
|
||||
return RTP_OK;
|
||||
|
@ -81,7 +81,7 @@ uvgrtp::frame::zrtp_frame *uvgrtp::frame::alloc_zrtp_frame(size_t size)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
LOG_DEBUG("Allocate ZRTP frame, packet size %zu", size);
|
||||
UVG_LOG_DEBUG("Allocate ZRTP frame, packet size %zu", size);
|
||||
|
||||
uvgrtp::frame::zrtp_frame *frame = (uvgrtp::frame::zrtp_frame *)new uint8_t[size];
|
||||
|
||||
|
|
|
@ -100,7 +100,7 @@ rtp_error_t uvgrtp::frame_queue::init_transaction(uint8_t *data)
|
|||
return RTP_INVALID_VALUE;
|
||||
|
||||
if (init_transaction() != RTP_OK) {
|
||||
LOG_ERROR("Failed to initialize transaction");
|
||||
UVG_LOG_ERROR("Failed to initialize transaction");
|
||||
return RTP_GENERIC_ERROR;
|
||||
}
|
||||
|
||||
|
@ -116,7 +116,7 @@ rtp_error_t uvgrtp::frame_queue::init_transaction(std::unique_ptr<uint8_t[]> dat
|
|||
return RTP_INVALID_VALUE;
|
||||
|
||||
if (init_transaction() != RTP_OK) {
|
||||
LOG_ERROR("Failed to initialize transaction");
|
||||
UVG_LOG_ERROR("Failed to initialize transaction");
|
||||
return RTP_GENERIC_ERROR;
|
||||
}
|
||||
|
||||
|
@ -129,7 +129,7 @@ rtp_error_t uvgrtp::frame_queue::init_transaction(std::unique_ptr<uint8_t[]> dat
|
|||
rtp_error_t uvgrtp::frame_queue::deinit_transaction()
|
||||
{
|
||||
if (active_ == nullptr) {
|
||||
LOG_WARN("Trying to deinit transaction, no active transaction!");
|
||||
UVG_LOG_WARN("Trying to deinit transaction, no active transaction!");
|
||||
return RTP_INVALID_VALUE;
|
||||
}
|
||||
|
||||
|
@ -183,7 +183,7 @@ rtp_error_t uvgrtp::frame_queue::enqueue_message(uint8_t *message, size_t messag
|
|||
{
|
||||
if (message == nullptr || message_len == 0)
|
||||
{
|
||||
LOG_ERROR("Tried to enqueue invalid message");
|
||||
UVG_LOG_ERROR("Tried to enqueue invalid message");
|
||||
return RTP_INVALID_VALUE;
|
||||
}
|
||||
|
||||
|
@ -223,7 +223,7 @@ rtp_error_t uvgrtp::frame_queue::enqueue_message(buf_vec& buffers)
|
|||
{
|
||||
if (!buffers.size())
|
||||
{
|
||||
LOG_ERROR("Tried to enqueue an empty buffer");
|
||||
UVG_LOG_ERROR("Tried to enqueue an empty buffer");
|
||||
return RTP_INVALID_VALUE;
|
||||
}
|
||||
|
||||
|
@ -250,7 +250,7 @@ rtp_error_t uvgrtp::frame_queue::enqueue_message(buf_vec& buffers)
|
|||
|
||||
if (total > 1500)
|
||||
{
|
||||
LOG_DEBUG("Encryption needs to keep its FU division!");
|
||||
UVG_LOG_DEBUG("Encryption needs to keep its FU division!");
|
||||
}
|
||||
|
||||
uint8_t* mem = new uint8_t[total];
|
||||
|
@ -277,7 +277,7 @@ rtp_error_t uvgrtp::frame_queue::enqueue_message(buf_vec& buffers)
|
|||
rtp_error_t uvgrtp::frame_queue::flush_queue()
|
||||
{
|
||||
if (active_->packets.empty()) {
|
||||
LOG_ERROR("Cannot send an empty packet!");
|
||||
UVG_LOG_ERROR("Cannot send an empty packet!");
|
||||
(void)deinit_transaction();
|
||||
return RTP_INVALID_VALUE;
|
||||
}
|
||||
|
@ -287,12 +287,12 @@ rtp_error_t uvgrtp::frame_queue::flush_queue()
|
|||
((uint8_t *)&active_->rtp_headers[active_->rtphdr_ptr - 1])[1] |= (1 << 7);
|
||||
|
||||
if (socket_->sendto(active_->packets, 0) != RTP_OK) {
|
||||
LOG_ERROR("Failed to flush the message queue: %s", strerror(errno));
|
||||
UVG_LOG_ERROR("Failed to flush the message queue: %s", strerror(errno));
|
||||
(void)deinit_transaction();
|
||||
return RTP_SEND_ERROR;
|
||||
}
|
||||
|
||||
//LOG_DEBUG("full message took %zu chunks and %zu messages", active_->chunk_ptr, active_->hdr_ptr);
|
||||
//UVG_LOG_DEBUG("full message took %zu chunks and %zu messages", active_->chunk_ptr, active_->hdr_ptr);
|
||||
return deinit_transaction();
|
||||
}
|
||||
|
||||
|
@ -306,7 +306,7 @@ uvgrtp::buf_vec* uvgrtp::frame_queue::get_buffer_vector()
|
|||
{
|
||||
if (!active_)
|
||||
{
|
||||
LOG_ERROR("No active transaction");
|
||||
UVG_LOG_ERROR("No active transaction");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ std::string uvgrtp::hostname::get_hostname()
|
|||
char hostname[NAME_MAXLEN];
|
||||
|
||||
if (gethostname(hostname, NAME_MAXLEN) != 0) {
|
||||
LOG_ERROR("%s", strerror(errno));
|
||||
UVG_LOG_ERROR("%s", strerror(errno));
|
||||
return "";
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,7 @@ std::string uvgrtp::hostname::get_username()
|
|||
char username[NAME_MAXLEN];
|
||||
|
||||
if (getlogin_r(username, NAME_MAXLEN) != 0) {
|
||||
LOG_ERROR("%s", strerror(errno));
|
||||
UVG_LOG_ERROR("%s", strerror(errno));
|
||||
return "";
|
||||
}
|
||||
|
||||
|
|
|
@ -94,7 +94,7 @@ rtp_error_t uvgrtp::media_stream::init_connection()
|
|||
int enabled = 1;
|
||||
|
||||
if (::ioctlsocket(socket_->get_raw_socket(), FIONBIO, (u_long *)&enabled) < 0)
|
||||
LOG_ERROR("Failed to make the socket non-blocking!");
|
||||
UVG_LOG_ERROR("Failed to make the socket non-blocking!");
|
||||
#endif
|
||||
|
||||
if (laddr_ != "") {
|
||||
|
@ -181,7 +181,7 @@ rtp_error_t uvgrtp::media_stream::create_media(rtp_format_t fmt)
|
|||
return RTP_OK;
|
||||
|
||||
default:
|
||||
LOG_ERROR("Unknown payload format %u\n", fmt_);
|
||||
UVG_LOG_ERROR("Unknown payload format %u\n", fmt_);
|
||||
media_ = nullptr;
|
||||
return RTP_NOT_SUPPORTED;
|
||||
}
|
||||
|
@ -228,7 +228,7 @@ rtp_error_t uvgrtp::media_stream::free_resources(rtp_error_t ret)
|
|||
rtp_error_t uvgrtp::media_stream::init()
|
||||
{
|
||||
if (init_connection() != RTP_OK) {
|
||||
LOG_ERROR("Failed to initialize the underlying socket");
|
||||
UVG_LOG_ERROR("Failed to initialize the underlying socket");
|
||||
return free_resources(RTP_GENERIC_ERROR);
|
||||
}
|
||||
|
||||
|
@ -259,7 +259,7 @@ rtp_error_t uvgrtp::media_stream::init(std::shared_ptr<uvgrtp::zrtp> zrtp)
|
|||
rtp_ = std::shared_ptr<uvgrtp::rtp> (new uvgrtp::rtp(fmt_));
|
||||
|
||||
if ((ret = zrtp->init(rtp_->get_ssrc(), socket_, addr_out_)) != RTP_OK) {
|
||||
LOG_WARN("Failed to initialize ZRTP for media stream!");
|
||||
UVG_LOG_WARN("Failed to initialize ZRTP for media stream!");
|
||||
return free_resources(ret);
|
||||
}
|
||||
|
||||
|
@ -294,7 +294,7 @@ rtp_error_t uvgrtp::media_stream::add_srtp_ctx(uint8_t *key, uint8_t *salt)
|
|||
rtp_error_t ret = RTP_OK;
|
||||
|
||||
if (init_connection() != RTP_OK) {
|
||||
LOG_ERROR("Failed to initialize the underlying socket");
|
||||
UVG_LOG_ERROR("Failed to initialize the underlying socket");
|
||||
return free_resources(RTP_GENERIC_ERROR);
|
||||
}
|
||||
|
||||
|
@ -309,14 +309,14 @@ rtp_error_t uvgrtp::media_stream::add_srtp_ctx(uint8_t *key, uint8_t *salt)
|
|||
|
||||
// why are they local and remote key/salt the same?
|
||||
if ((ret = srtp_->init(SRTP, ctx_config_.flags, key, key, salt, salt)) != RTP_OK) {
|
||||
LOG_WARN("Failed to initialize SRTP for media stream!");
|
||||
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) {
|
||||
LOG_WARN("Failed to initialize SRTCP for media stream!");
|
||||
UVG_LOG_WARN("Failed to initialize SRTCP for media stream!");
|
||||
return free_resources(ret);
|
||||
}
|
||||
|
||||
|
@ -359,7 +359,7 @@ rtp_error_t uvgrtp::media_stream::start_components()
|
|||
rtp_error_t uvgrtp::media_stream::push_frame(uint8_t *data, size_t data_len, int flags)
|
||||
{
|
||||
if (!initialized_) {
|
||||
LOG_ERROR("RTP context has not been initialized fully, cannot continue!");
|
||||
UVG_LOG_ERROR("RTP context has not been initialized fully, cannot continue!");
|
||||
return RTP_NOT_INITIALIZED;
|
||||
}
|
||||
|
||||
|
@ -372,7 +372,7 @@ rtp_error_t uvgrtp::media_stream::push_frame(uint8_t *data, size_t data_len, int
|
|||
rtp_error_t uvgrtp::media_stream::push_frame(std::unique_ptr<uint8_t[]> data, size_t data_len, int flags)
|
||||
{
|
||||
if (!initialized_) {
|
||||
LOG_ERROR("RTP context has not been initialized fully, cannot continue!");
|
||||
UVG_LOG_ERROR("RTP context has not been initialized fully, cannot continue!");
|
||||
return RTP_NOT_INITIALIZED;
|
||||
}
|
||||
|
||||
|
@ -387,7 +387,7 @@ rtp_error_t uvgrtp::media_stream::push_frame(uint8_t *data, size_t data_len, uin
|
|||
rtp_error_t ret = RTP_GENERIC_ERROR;
|
||||
|
||||
if (!initialized_) {
|
||||
LOG_ERROR("RTP context has not been initialized fully, cannot continue!");
|
||||
UVG_LOG_ERROR("RTP context has not been initialized fully, cannot continue!");
|
||||
return RTP_NOT_INITIALIZED;
|
||||
}
|
||||
|
||||
|
@ -406,7 +406,7 @@ rtp_error_t uvgrtp::media_stream::push_frame(std::unique_ptr<uint8_t[]> data, si
|
|||
rtp_error_t ret = RTP_GENERIC_ERROR;
|
||||
|
||||
if (!initialized_) {
|
||||
LOG_ERROR("RTP context has not been initialized fully, cannot continue!");
|
||||
UVG_LOG_ERROR("RTP context has not been initialized fully, cannot continue!");
|
||||
return RTP_NOT_INITIALIZED;
|
||||
}
|
||||
|
||||
|
@ -423,7 +423,7 @@ rtp_error_t uvgrtp::media_stream::push_frame(std::unique_ptr<uint8_t[]> data, si
|
|||
uvgrtp::frame::rtp_frame *uvgrtp::media_stream::pull_frame()
|
||||
{
|
||||
if (!initialized_) {
|
||||
LOG_ERROR("RTP context has not been initialized fully, cannot continue!");
|
||||
UVG_LOG_ERROR("RTP context has not been initialized fully, cannot continue!");
|
||||
rtp_errno = RTP_NOT_INITIALIZED;
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -434,7 +434,7 @@ uvgrtp::frame::rtp_frame *uvgrtp::media_stream::pull_frame()
|
|||
uvgrtp::frame::rtp_frame *uvgrtp::media_stream::pull_frame(size_t timeout_ms)
|
||||
{
|
||||
if (!initialized_) {
|
||||
LOG_ERROR("RTP context has not been initialized fully, cannot continue!");
|
||||
UVG_LOG_ERROR("RTP context has not been initialized fully, cannot continue!");
|
||||
rtp_errno = RTP_NOT_INITIALIZED;
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -445,7 +445,7 @@ uvgrtp::frame::rtp_frame *uvgrtp::media_stream::pull_frame(size_t timeout_ms)
|
|||
rtp_error_t uvgrtp::media_stream::install_receive_hook(void *arg, void (*hook)(void *, uvgrtp::frame::rtp_frame *))
|
||||
{
|
||||
if (!initialized_) {
|
||||
LOG_ERROR("RTP context has not been initialized fully, cannot continue!");
|
||||
UVG_LOG_ERROR("RTP context has not been initialized fully, cannot continue!");
|
||||
return RTP_NOT_INITIALIZED;
|
||||
}
|
||||
|
||||
|
@ -460,7 +460,7 @@ rtp_error_t uvgrtp::media_stream::install_receive_hook(void *arg, void (*hook)(v
|
|||
rtp_error_t uvgrtp::media_stream::install_deallocation_hook(void (*hook)(void *))
|
||||
{
|
||||
if (!initialized_) {
|
||||
LOG_ERROR("RTP context has not been initialized fully, cannot continue!");
|
||||
UVG_LOG_ERROR("RTP context has not been initialized fully, cannot continue!");
|
||||
return RTP_NOT_INITIALIZED;
|
||||
}
|
||||
|
||||
|
@ -477,7 +477,7 @@ rtp_error_t uvgrtp::media_stream::install_notify_hook(void *arg, void (*hook)(vo
|
|||
(void)arg, (void)hook;
|
||||
|
||||
if (!initialized_) {
|
||||
LOG_ERROR("RTP context has not been initialized fully, cannot continue!");
|
||||
UVG_LOG_ERROR("RTP context has not been initialized fully, cannot continue!");
|
||||
return RTP_NOT_INITIALIZED;
|
||||
}
|
||||
|
||||
|
@ -502,7 +502,7 @@ void *uvgrtp::media_stream::get_media_config()
|
|||
rtp_error_t uvgrtp::media_stream::configure_ctx(int flag, ssize_t value)
|
||||
{
|
||||
if (!initialized_) {
|
||||
LOG_ERROR("RTP context has not been initialized fully, cannot continue!");
|
||||
UVG_LOG_ERROR("RTP context has not been initialized fully, cannot continue!");
|
||||
return RTP_NOT_INITIALIZED;
|
||||
}
|
||||
|
||||
|
@ -560,7 +560,7 @@ rtp_error_t uvgrtp::media_stream::configure_ctx(int flag, ssize_t value)
|
|||
|
||||
if (value > max_size) {
|
||||
unsigned int u_max_size = (unsigned int)max_size;
|
||||
LOG_ERROR("Payload size (%zd) is larger than maximum UDP datagram size (%u)",
|
||||
UVG_LOG_ERROR("Payload size (%zd) is larger than maximum UDP datagram size (%u)",
|
||||
value, u_max_size);
|
||||
return RTP_INVALID_VALUE;
|
||||
}
|
||||
|
@ -591,7 +591,7 @@ uvgrtp::rtcp *uvgrtp::media_stream::get_rtcp()
|
|||
uint32_t uvgrtp::media_stream::get_ssrc() const
|
||||
{
|
||||
if (!initialized_ || rtp_ == nullptr) {
|
||||
LOG_ERROR("RTP context has not been initialized, please call init before asking ssrc!");
|
||||
UVG_LOG_ERROR("RTP context has not been initialized, please call init before asking ssrc!");
|
||||
return RTP_NOT_INITIALIZED;
|
||||
}
|
||||
|
||||
|
@ -622,7 +622,7 @@ rtp_error_t uvgrtp::media_stream::init_srtp_with_zrtp(int flags, int type, std::
|
|||
}
|
||||
else
|
||||
{
|
||||
LOG_WARN("Failed to initialize SRTP for media stream!");
|
||||
UVG_LOG_WARN("Failed to initialize SRTP for media stream!");
|
||||
}
|
||||
|
||||
delete[] local_key;
|
||||
|
@ -649,10 +649,10 @@ int uvgrtp::media_stream::get_default_bandwidth_kbps(rtp_format_t fmt)
|
|||
bandwidth = 24;
|
||||
break;
|
||||
default:
|
||||
LOG_WARN("Unknown RTP format, setting session bandwidth to 64 kbps");
|
||||
UVG_LOG_WARN("Unknown RTP format, setting session bandwidth to 64 kbps");
|
||||
int bandwidth = 64;
|
||||
break;
|
||||
}
|
||||
|
||||
return bandwidth;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ rtp_error_t uvgrtp::poll::poll(std::vector<uvgrtp::socket>& sockets, uint8_t *bu
|
|||
return RTP_INVALID_VALUE;
|
||||
|
||||
if (sockets.size() >= MULTICAST_MAX_PEERS) {
|
||||
LOG_ERROR("Too many participants!");
|
||||
UVG_LOG_ERROR("Too many participants!");
|
||||
return RTP_INVALID_VALUE;
|
||||
}
|
||||
|
||||
|
@ -75,7 +75,7 @@ rtp_error_t uvgrtp::poll::poll(std::vector<uvgrtp::socket>& sockets, uint8_t *bu
|
|||
|
||||
if (ret == -1) {
|
||||
set_bytes(bytes_read, -1);
|
||||
LOG_ERROR("Poll failed: %s", strerror(errno));
|
||||
UVG_LOG_ERROR("Poll failed: %s", strerror(errno));
|
||||
return RTP_GENERIC_ERROR;
|
||||
}
|
||||
|
||||
|
@ -89,7 +89,7 @@ rtp_error_t uvgrtp::poll::poll(std::vector<uvgrtp::socket>& sockets, uint8_t *bu
|
|||
auto rtp_ret = sockets.at(i).recv(buf, buf_len, 0, bytes_read);
|
||||
|
||||
if (rtp_ret != RTP_OK) {
|
||||
LOG_ERROR("recv() for socket %d failed: %s", fds[i].fd, strerror(errno));
|
||||
UVG_LOG_ERROR("recv() for socket %d failed: %s", fds[i].fd, strerror(errno));
|
||||
set_bytes(bytes_read, -1);
|
||||
return RTP_GENERIC_ERROR;
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ int uvgrtp::random::generate(void *buf, size_t n)
|
|||
|
||||
if (n > UINT32_MAX)
|
||||
{
|
||||
LOG_WARN("Tried to generate too large random number");
|
||||
UVG_LOG_WARN("Tried to generate too large random number");
|
||||
n = UINT32_MAX;
|
||||
}
|
||||
|
||||
|
|
|
@ -85,7 +85,7 @@ rtp_error_t uvgrtp::reception_flow::start(std::shared_ptr<uvgrtp::socket> socket
|
|||
{
|
||||
should_stop_ = false;
|
||||
|
||||
LOG_DEBUG("Creating receiving threads and setting priorities");
|
||||
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));
|
||||
|
||||
|
@ -272,11 +272,11 @@ void uvgrtp::reception_flow::call_aux_handlers(uint32_t key, int flags, uvgrtp::
|
|||
|
||||
case RTP_GENERIC_ERROR:
|
||||
// too many prints with this in case of minor errors
|
||||
//LOG_DEBUG("Error in auxiliary handling of received packet!");
|
||||
//UVG_LOG_DEBUG("Error in auxiliary handling of received packet!");
|
||||
break;
|
||||
|
||||
default:
|
||||
LOG_ERROR("Unknown error code from packet handler: %d", ret);
|
||||
UVG_LOG_ERROR("Unknown error code from packet handler: %d", ret);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -315,13 +315,13 @@ void uvgrtp::reception_flow::call_aux_handlers(uint32_t key, int flags, uvgrtp::
|
|||
case RTP_GENERIC_ERROR:
|
||||
{
|
||||
// too many prints with this in case of minor errors
|
||||
//LOG_DEBUG("Error in auxiliary handling of received packet (cpp)!");
|
||||
//UVG_LOG_DEBUG("Error in auxiliary handling of received packet (cpp)!");
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
LOG_ERROR("Unknown error code from packet handler: %d", ret);
|
||||
UVG_LOG_ERROR("Unknown error code from packet handler: %d", ret);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -352,7 +352,7 @@ void uvgrtp::reception_flow::receiver(std::shared_ptr<uvgrtp::socket> socket, in
|
|||
#else
|
||||
if (poll(pfds, 1, timeout_ms) < 0) {
|
||||
#endif
|
||||
LOG_ERROR("poll(2) failed");
|
||||
UVG_LOG_ERROR("poll(2) failed");
|
||||
if (pfds)
|
||||
{
|
||||
delete pfds;
|
||||
|
@ -373,7 +373,7 @@ void uvgrtp::reception_flow::receiver(std::shared_ptr<uvgrtp::socket> socket, in
|
|||
// create new buffer spaces if the process/read hasn't freed any spots on the ring buffer
|
||||
if (next_write_index == ring_read_index_)
|
||||
{
|
||||
LOG_DEBUG("Reception buffer ran out, increasing the buffer size ...");
|
||||
UVG_LOG_DEBUG("Reception buffer ran out, increasing the buffer size ...");
|
||||
|
||||
// increase the buffer size by 25%
|
||||
int increase = ring_buffer_.size()/4;
|
||||
|
@ -401,11 +401,11 @@ void uvgrtp::reception_flow::receiver(std::shared_ptr<uvgrtp::socket> socket, in
|
|||
}
|
||||
else if (ring_buffer_[next_write_index].read == 0)
|
||||
{
|
||||
LOG_WARN("Failed to read anything from socket");
|
||||
UVG_LOG_WARN("Failed to read anything from socket");
|
||||
break;
|
||||
}
|
||||
else if (ret != RTP_OK) {
|
||||
LOG_ERROR("recvfrom(2) failed! Reception flow cannot continue %d!", ret);
|
||||
UVG_LOG_ERROR("recvfrom(2) failed! Reception flow cannot continue %d!", ret);
|
||||
should_stop_ = true;
|
||||
break;
|
||||
}
|
||||
|
@ -473,11 +473,11 @@ void uvgrtp::reception_flow::process_packet(int flags)
|
|||
break;
|
||||
|
||||
case RTP_GENERIC_ERROR:
|
||||
LOG_DEBUG("Error in handling of received packet!");
|
||||
UVG_LOG_DEBUG("Error in handling of received packet!");
|
||||
break;
|
||||
|
||||
default:
|
||||
LOG_ERROR("Unknown error code from packet handler: %d", ret);
|
||||
UVG_LOG_ERROR("Unknown error code from packet handler: %d", ret);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -490,4 +490,4 @@ void uvgrtp::reception_flow::process_packet(int flags)
|
|||
int uvgrtp::reception_flow::next_buffer_location(int current_location)
|
||||
{
|
||||
return (current_location + 1) % ring_buffer_.size();
|
||||
}
|
||||
}
|
||||
|
|
130
src/rtcp.cc
130
src/rtcp.cc
|
@ -70,7 +70,7 @@ uvgrtp::rtcp::rtcp(std::shared_ptr<uvgrtp::rtp> rtp, std::string cname, int flag
|
|||
|
||||
if (cname.length() > 255)
|
||||
{
|
||||
LOG_ERROR("Our CName is too long");
|
||||
UVG_LOG_ERROR("Our CName is too long");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -148,7 +148,7 @@ rtp_error_t uvgrtp::rtcp::start()
|
|||
{
|
||||
if (sockets_.empty())
|
||||
{
|
||||
LOG_ERROR("Cannot start RTCP Runner because no connections have been initialized");
|
||||
UVG_LOG_ERROR("Cannot start RTCP Runner because no connections have been initialized");
|
||||
return RTP_INVALID_VALUE;
|
||||
}
|
||||
active_ = true;
|
||||
|
@ -160,11 +160,11 @@ rtp_error_t uvgrtp::rtcp::start()
|
|||
|
||||
rtp_error_t uvgrtp::rtcp::stop()
|
||||
{
|
||||
LOG_DEBUG("Stopping RTCP");
|
||||
UVG_LOG_DEBUG("Stopping RTCP");
|
||||
// TODO: Make thread safe. I think this kind of works, but not in a flexible way
|
||||
if (!active_)
|
||||
{
|
||||
LOG_DEBUG("Removing all participants");
|
||||
UVG_LOG_DEBUG("Removing all participants");
|
||||
/* free all receiver statistic structs */
|
||||
for (auto& participant : participants_)
|
||||
{
|
||||
|
@ -185,7 +185,7 @@ rtp_error_t uvgrtp::rtcp::stop()
|
|||
|
||||
if (report_generator_ && report_generator_->joinable())
|
||||
{
|
||||
LOG_DEBUG("Waiting for RTCP loop to exit");
|
||||
UVG_LOG_DEBUG("Waiting for RTCP loop to exit");
|
||||
report_generator_->join();
|
||||
}
|
||||
|
||||
|
@ -207,11 +207,11 @@ rtp_error_t uvgrtp::rtcp::stop()
|
|||
|
||||
void uvgrtp::rtcp::rtcp_runner(rtcp* rtcp, int interval)
|
||||
{
|
||||
LOG_INFO("RTCP instance created! RTCP interval: %i ms", interval);
|
||||
UVG_LOG_INFO("RTCP instance created! RTCP interval: %i ms", interval);
|
||||
|
||||
// RFC 3550 says to wait half interval before sending first report
|
||||
int initial_sleep_ms = interval / 2;
|
||||
LOG_DEBUG("Sleeping for %i ms before sending first RTCP report", initial_sleep_ms);
|
||||
UVG_LOG_DEBUG("Sleeping for %i ms before sending first RTCP report", initial_sleep_ms);
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(initial_sleep_ms));
|
||||
|
||||
uint8_t buffer[MAX_PACKET];
|
||||
|
@ -230,11 +230,11 @@ void uvgrtp::rtcp::rtcp_runner(rtcp* rtcp, int interval)
|
|||
{
|
||||
++i;
|
||||
|
||||
LOG_DEBUG("Sending RTCP report number %i at time slot %i ms", i, next_sendslot);
|
||||
UVG_LOG_DEBUG("Sending RTCP report number %i at time slot %i ms", i, next_sendslot);
|
||||
|
||||
if ((ret = rtcp->generate_report()) != RTP_OK && ret != RTP_NOT_READY)
|
||||
{
|
||||
LOG_ERROR("Failed to send RTCP status report!");
|
||||
UVG_LOG_ERROR("Failed to send RTCP status report!");
|
||||
}
|
||||
} else if (diff_ms > ESTIMATED_MAX_RECEPTION_TIME_MS) { // try receiving if we have time
|
||||
// Receive RTCP reports until time to send report
|
||||
|
@ -257,7 +257,7 @@ void uvgrtp::rtcp::rtcp_runner(rtcp* rtcp, int interval)
|
|||
} else if (ret == RTP_INTERRUPTED) {
|
||||
/* do nothing */
|
||||
} else {
|
||||
LOG_ERROR("poll failed, %d", ret);
|
||||
UVG_LOG_ERROR("poll failed, %d", ret);
|
||||
break; // TODO the sockets should be manages so that this is not needed
|
||||
}
|
||||
} else { // sleep until it is time to send the report
|
||||
|
@ -265,7 +265,7 @@ void uvgrtp::rtcp::rtcp_runner(rtcp* rtcp, int interval)
|
|||
}
|
||||
}
|
||||
|
||||
LOG_DEBUG("Exited RTCP loop");
|
||||
UVG_LOG_DEBUG("Exited RTCP loop");
|
||||
}
|
||||
|
||||
rtp_error_t uvgrtp::rtcp::set_sdes_items(const std::vector<uvgrtp::frame::rtcp_sdes_item>& items)
|
||||
|
@ -279,13 +279,13 @@ rtp_error_t uvgrtp::rtcp::set_sdes_items(const std::vector<uvgrtp::frame::rtcp_s
|
|||
{
|
||||
if (items.at(i).type == 0)
|
||||
{
|
||||
LOG_WARN("Invalid item type 0 found at index %lu, removing item", i);
|
||||
UVG_LOG_WARN("Invalid item type 0 found at index %lu, removing item", i);
|
||||
to_ignore.insert(i);
|
||||
}
|
||||
else if (items.at(i).type == 1)
|
||||
{
|
||||
hasCname = true;
|
||||
LOG_DEBUG("Found CName in sdes items, not adding pregenerated");
|
||||
UVG_LOG_DEBUG("Found CName in sdes items, not adding pregenerated");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -312,7 +312,7 @@ rtp_error_t uvgrtp::rtcp::add_participant(std::string dst_addr, uint16_t dst_por
|
|||
{
|
||||
if (dst_addr == "" || !dst_port || !src_port)
|
||||
{
|
||||
LOG_ERROR("Invalid values given (%s, %d, %d), cannot create RTCP instance",
|
||||
UVG_LOG_ERROR("Invalid values given (%s, %d, %d), cannot create RTCP instance",
|
||||
dst_addr.c_str(), dst_port, src_port);
|
||||
return RTP_INVALID_VALUE;
|
||||
}
|
||||
|
@ -344,7 +344,7 @@ rtp_error_t uvgrtp::rtcp::add_participant(std::string dst_addr, uint16_t dst_por
|
|||
|
||||
if (::ioctlsocket(p->socket->get_raw_socket(), FIONBIO, (u_long *)&enabled) < 0)
|
||||
{
|
||||
LOG_ERROR("Failed to make the socket non-blocking!");
|
||||
UVG_LOG_ERROR("Failed to make the socket non-blocking!");
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -361,7 +361,7 @@ rtp_error_t uvgrtp::rtcp::add_participant(std::string dst_addr, uint16_t dst_por
|
|||
return ret;
|
||||
}
|
||||
|
||||
LOG_WARN("Binding to port %d (source port)", src_port);
|
||||
UVG_LOG_WARN("Binding to port %d (source port)", src_port);
|
||||
|
||||
if ((ret = p->socket->bind(AF_INET, INADDR_ANY, src_port)) != RTP_OK)
|
||||
{
|
||||
|
@ -382,7 +382,7 @@ rtp_error_t uvgrtp::rtcp::add_participant(uint32_t ssrc)
|
|||
{
|
||||
if (num_receivers_ == MAX_SUPPORTED_PARTICIPANTS)
|
||||
{
|
||||
LOG_ERROR("Maximum number of RTCP participants reached.");
|
||||
UVG_LOG_ERROR("Maximum number of RTCP participants reached.");
|
||||
// TODO: Support more participants by sending multiple messages at the same time
|
||||
return RTP_GENERIC_ERROR;
|
||||
}
|
||||
|
@ -763,7 +763,7 @@ void uvgrtp::rtcp::sender_update_stats(const uvgrtp::frame::rtp_frame *frame)
|
|||
|
||||
if (frame->payload_len > UINT32_MAX)
|
||||
{
|
||||
LOG_ERROR("Payload size larger than uint32 max which is not supported by RFC 3550");
|
||||
UVG_LOG_ERROR("Payload size larger than uint32 max which is not supported by RFC 3550");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -811,7 +811,7 @@ rtp_error_t uvgrtp::rtcp::update_sender_stats(size_t pkt_size)
|
|||
|
||||
if (our_stats.sent_bytes + pkt_size > UINT32_MAX)
|
||||
{
|
||||
LOG_ERROR("Sent bytes overflow");
|
||||
UVG_LOG_ERROR("Sent bytes overflow");
|
||||
}
|
||||
|
||||
our_stats.sent_pkts += 1;
|
||||
|
@ -839,7 +839,7 @@ rtp_error_t uvgrtp::rtcp::update_participant_seq(uint32_t ssrc, uint16_t seq)
|
|||
{
|
||||
if (participants_.find(ssrc) == participants_.end())
|
||||
{
|
||||
LOG_ERROR("Did not find participant SSRC when updating seq");
|
||||
UVG_LOG_ERROR("Did not find participant SSRC when updating seq");
|
||||
return RTP_GENERIC_ERROR;
|
||||
}
|
||||
|
||||
|
@ -884,7 +884,7 @@ rtp_error_t uvgrtp::rtcp::update_participant_seq(uint32_t ssrc, uint16_t seq)
|
|||
uvgrtp::rtcp::init_participant_seq(ssrc, seq);
|
||||
} else {
|
||||
p->stats.bad_seq = (seq + 1) & (RTP_SEQ_MOD - 1);
|
||||
LOG_ERROR("Invalid sequence number. Seq jump: %u -> %u", p->stats.max_seq, seq);
|
||||
UVG_LOG_ERROR("Invalid sequence number. Seq jump: %u -> %u", p->stats.max_seq, seq);
|
||||
return RTP_GENERIC_ERROR;
|
||||
}
|
||||
} else {
|
||||
|
@ -982,7 +982,7 @@ rtp_error_t uvgrtp::rtcp::recv_packet_handler(void *arg, int flags, frame::rtp_f
|
|||
{
|
||||
if ((rtcp->init_new_participant(frame)) != RTP_OK)
|
||||
{
|
||||
LOG_ERROR("Failed to initiate new participant");
|
||||
UVG_LOG_ERROR("Failed to initiate new participant");
|
||||
return RTP_GENERIC_ERROR;
|
||||
}
|
||||
} else if ((ret = rtcp->update_participant_seq(frame->header.ssrc, frame->header.seq)) != RTP_OK) {
|
||||
|
@ -990,7 +990,7 @@ rtp_error_t uvgrtp::rtcp::recv_packet_handler(void *arg, int flags, frame::rtp_f
|
|||
return RTP_OK;
|
||||
}
|
||||
else {
|
||||
LOG_ERROR("Failed to update participant with seq %u", frame->header.seq);
|
||||
UVG_LOG_ERROR("Failed to update participant with seq %u", frame->header.seq);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
@ -1033,7 +1033,7 @@ rtp_error_t uvgrtp::rtcp::handle_incoming_packet(uint8_t *buffer, size_t size)
|
|||
return RTP_INVALID_VALUE;
|
||||
}
|
||||
|
||||
LOG_DEBUG("Received an RTCP packet with size: %li", size);
|
||||
UVG_LOG_DEBUG("Received an RTCP packet with size: %li", size);
|
||||
|
||||
size_t read_ptr = 0;
|
||||
size_t remaining_size = size;
|
||||
|
@ -1053,7 +1053,7 @@ rtp_error_t uvgrtp::rtcp::handle_incoming_packet(uint8_t *buffer, size_t size)
|
|||
if (srtcp_ && (ret = srtcp_->handle_rtcp_decryption(flags_, sender_ssrc,
|
||||
buffer + RTCP_HEADER_SIZE + SSRC_CSRC_SIZE, size)) != RTP_OK)
|
||||
{
|
||||
LOG_ERROR("Failed at decryption");
|
||||
UVG_LOG_ERROR("Failed at decryption");
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
@ -1064,7 +1064,7 @@ rtp_error_t uvgrtp::rtcp::handle_incoming_packet(uint8_t *buffer, size_t size)
|
|||
++packets;
|
||||
if (remaining_size < RTCP_HEADER_SIZE)
|
||||
{
|
||||
LOG_ERROR("Didn't get enough data for an rtcp header. Packet # %i Got data: %lli",
|
||||
UVG_LOG_ERROR("Didn't get enough data for an rtcp header. Packet # %i Got data: %lli",
|
||||
packets, remaining_size);
|
||||
return RTP_INVALID_VALUE;
|
||||
}
|
||||
|
@ -1078,32 +1078,32 @@ rtp_error_t uvgrtp::rtcp::handle_incoming_packet(uint8_t *buffer, size_t size)
|
|||
* We have to substract the size of header, since it was added when reading the header. */
|
||||
size_t packet_end = read_ptr - RTCP_HEADER_SIZE + size_of_rtcp_packet;
|
||||
|
||||
LOG_DEBUG("Handling packet # %i with size %li and remaining packet amount %li",
|
||||
UVG_LOG_DEBUG("Handling packet # %i with size %li and remaining packet amount %li",
|
||||
packets, size_of_rtcp_packet, remaining_size);
|
||||
|
||||
if (header.version != 0x2)
|
||||
{
|
||||
LOG_ERROR("Packet # %i has invalid header version %u", packets, header.version);
|
||||
UVG_LOG_ERROR("Packet # %i has invalid header version %u", packets, header.version);
|
||||
return RTP_INVALID_VALUE;
|
||||
}
|
||||
|
||||
if (remaining_size < size_of_rtcp_packet)
|
||||
{
|
||||
LOG_ERROR("Received a partial RTCP packet, not supported!");
|
||||
UVG_LOG_ERROR("Received a partial RTCP packet, not supported!");
|
||||
return RTP_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
// TODO: I think we can?
|
||||
if (header.padding)
|
||||
{
|
||||
LOG_ERROR("Cannot handle padded packets!");
|
||||
UVG_LOG_ERROR("Cannot handle padded packets!");
|
||||
return RTP_INVALID_VALUE;
|
||||
}
|
||||
|
||||
if (header.pkt_type > uvgrtp::frame::RTCP_FT_APP ||
|
||||
header.pkt_type < uvgrtp::frame::RTCP_FT_SR)
|
||||
{
|
||||
LOG_ERROR("Invalid packet type (%u)!", header.pkt_type);
|
||||
UVG_LOG_ERROR("Invalid packet type (%u)!", header.pkt_type);
|
||||
return RTP_INVALID_VALUE;
|
||||
}
|
||||
|
||||
|
@ -1132,13 +1132,13 @@ rtp_error_t uvgrtp::rtcp::handle_incoming_packet(uint8_t *buffer, size_t size)
|
|||
break;
|
||||
|
||||
default:
|
||||
LOG_WARN("Unknown packet received, type %d", header.pkt_type);
|
||||
UVG_LOG_WARN("Unknown packet received, type %d", header.pkt_type);
|
||||
break;
|
||||
}
|
||||
|
||||
if (ret != RTP_OK)
|
||||
{
|
||||
LOG_WARN("Error parsing RTCP packet");
|
||||
UVG_LOG_WARN("Error parsing RTCP packet");
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -1148,11 +1148,11 @@ rtp_error_t uvgrtp::rtcp::handle_incoming_packet(uint8_t *buffer, size_t size)
|
|||
|
||||
if (packets > 1)
|
||||
{
|
||||
LOG_DEBUG("Received a compound RTCP frame with %i packets and size: %li", packets, size);
|
||||
UVG_LOG_DEBUG("Received a compound RTCP frame with %i packets and size: %li", packets, size);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_WARN("Received RTCP packet was not a compound packet!");
|
||||
UVG_LOG_WARN("Received RTCP packet was not a compound packet!");
|
||||
}
|
||||
|
||||
return RTP_OK;
|
||||
|
@ -1198,7 +1198,7 @@ void uvgrtp::rtcp::read_reports(const uint8_t* buffer, size_t& read_ptr, size_t
|
|||
read_ptr += REPORT_BLOCK_SIZE;
|
||||
}
|
||||
else {
|
||||
LOG_WARN("Received rtcp packet is smaller than the indicated number of reports!"
|
||||
UVG_LOG_WARN("Received rtcp packet is smaller than the indicated number of reports!"
|
||||
"Read: %i/%i, Read ptr: %i, Packet End:", i, count, read_ptr, packet_end);
|
||||
}
|
||||
}
|
||||
|
@ -1224,13 +1224,13 @@ rtp_error_t uvgrtp::rtcp::handle_receiver_report_packet(uint8_t* buffer, size_t&
|
|||
* Check if that's the case and if so, move the entry from initial_participants_ to participants_ */
|
||||
if (!is_participant(frame->ssrc))
|
||||
{
|
||||
LOG_INFO("Got an RR from a previously unknown participant SSRC %lu", frame->ssrc);
|
||||
UVG_LOG_INFO("Got an RR from a previously unknown participant SSRC %lu", frame->ssrc);
|
||||
add_participant(frame->ssrc);
|
||||
}
|
||||
|
||||
if (!frame->header.count)
|
||||
{
|
||||
LOG_ERROR("RR cannot have 0 report blocks!");
|
||||
UVG_LOG_ERROR("RR cannot have 0 report blocks!");
|
||||
return RTP_INVALID_VALUE;
|
||||
}
|
||||
|
||||
|
@ -1268,7 +1268,7 @@ rtp_error_t uvgrtp::rtcp::handle_sender_report_packet(uint8_t* buffer, size_t& r
|
|||
read_ssrc(buffer, read_ptr, frame->ssrc);
|
||||
if (!is_participant(frame->ssrc))
|
||||
{
|
||||
LOG_INFO("Got an SR from a previously unknown participant SSRC %lu", frame->ssrc);
|
||||
UVG_LOG_INFO("Got an SR from a previously unknown participant SSRC %lu", frame->ssrc);
|
||||
add_participant(frame->ssrc);
|
||||
}
|
||||
|
||||
|
@ -1317,7 +1317,7 @@ rtp_error_t uvgrtp::rtcp::handle_sdes_packet(uint8_t* packet, size_t& read_ptr,
|
|||
{
|
||||
if (!is_participant(sender_ssrc))
|
||||
{
|
||||
LOG_INFO("Got an SDES packet from a previously unknown participant SSRC %lu", sender_ssrc);
|
||||
UVG_LOG_INFO("Got an SDES packet from a previously unknown participant SSRC %lu", sender_ssrc);
|
||||
add_participant(sender_ssrc);
|
||||
}
|
||||
|
||||
|
@ -1402,11 +1402,11 @@ rtp_error_t uvgrtp::rtcp::handle_bye_packet(uint8_t* packet, size_t& read_ptr,
|
|||
|
||||
if (!is_participant(ssrc))
|
||||
{
|
||||
LOG_WARN("Participant %lu is not part of this group!", ssrc);
|
||||
UVG_LOG_WARN("Participant %lu is not part of this group!", ssrc);
|
||||
continue;
|
||||
}
|
||||
|
||||
LOG_DEBUG("Destroying participant with BYE");
|
||||
UVG_LOG_DEBUG("Destroying participant with BYE");
|
||||
participants_[ssrc]->socket = nullptr;
|
||||
delete participants_[ssrc];
|
||||
participants_.erase(ssrc);
|
||||
|
@ -1427,7 +1427,7 @@ rtp_error_t uvgrtp::rtcp::handle_app_packet(uint8_t* packet, size_t& read_ptr,
|
|||
/* Deallocate previous frame from the buffer if it exists, it's going to get overwritten */
|
||||
if (!is_participant(frame->ssrc))
|
||||
{
|
||||
LOG_WARN("Got an APP packet from an unknown participant");
|
||||
UVG_LOG_WARN("Got an APP packet from an unknown participant");
|
||||
add_participant(frame->ssrc);
|
||||
}
|
||||
|
||||
|
@ -1467,7 +1467,7 @@ rtp_error_t uvgrtp::rtcp::send_rtcp_packet_to_participants(uint8_t* frame, size_
|
|||
{
|
||||
if (!frame)
|
||||
{
|
||||
LOG_ERROR("No frame given for sending");
|
||||
UVG_LOG_ERROR("No frame given for sending");
|
||||
return RTP_GENERIC_ERROR;
|
||||
}
|
||||
|
||||
|
@ -1476,7 +1476,7 @@ rtp_error_t uvgrtp::rtcp::send_rtcp_packet_to_participants(uint8_t* frame, size_
|
|||
if (encrypt && srtcp_ &&
|
||||
(ret = srtcp_->handle_rtcp_encryption(flags_, rtcp_pkt_sent_count_, ssrc_, frame, frame_size)) != RTP_OK)
|
||||
{
|
||||
LOG_DEBUG("Encryption failed. Not sending packet");
|
||||
UVG_LOG_DEBUG("Encryption failed. Not sending packet");
|
||||
delete[] frame;
|
||||
return ret;
|
||||
}
|
||||
|
@ -1487,7 +1487,7 @@ rtp_error_t uvgrtp::rtcp::send_rtcp_packet_to_participants(uint8_t* frame, size_
|
|||
{
|
||||
if ((ret = p.second->socket->sendto(p.second->address, frame, frame_size, 0)) != RTP_OK)
|
||||
{
|
||||
LOG_ERROR("Sending rtcp packet with sendto() failed!");
|
||||
UVG_LOG_ERROR("Sending rtcp packet with sendto() failed!");
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1495,7 +1495,7 @@ rtp_error_t uvgrtp::rtcp::send_rtcp_packet_to_participants(uint8_t* frame, size_
|
|||
}
|
||||
else
|
||||
{
|
||||
LOG_ERROR("Tried to send RTCP packet when socket does not exist!");
|
||||
UVG_LOG_ERROR("Tried to send RTCP packet when socket does not exist!");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1526,35 +1526,35 @@ size_t uvgrtp::rtcp::size_of_compound_packet(uint16_t reports,
|
|||
if (sr_packet)
|
||||
{
|
||||
compound_packet_size = get_sr_packet_size(flags_, reports);
|
||||
LOG_DEBUG("Sending SR. Compound packet size: %li", compound_packet_size);
|
||||
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);
|
||||
LOG_DEBUG("Sending RR. Compound packet size: %li", compound_packet_size);
|
||||
UVG_LOG_DEBUG("Sending RR. Compound packet size: %li", compound_packet_size);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_ERROR("RTCP compound packet must start with either SR or RR");
|
||||
UVG_LOG_ERROR("RTCP compound packet must start with either SR or RR");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (sdes_packet)
|
||||
{
|
||||
compound_packet_size += get_sdes_packet_size(ourItems_);
|
||||
LOG_DEBUG("Sending SDES. Compound packet size: %li", compound_packet_size);
|
||||
UVG_LOG_DEBUG("Sending SDES. Compound packet size: %li", compound_packet_size);
|
||||
}
|
||||
|
||||
if (app_size != 0)
|
||||
{
|
||||
compound_packet_size += app_size;
|
||||
LOG_DEBUG("Sending APP. Compound packet size: %li", compound_packet_size);
|
||||
UVG_LOG_DEBUG("Sending APP. Compound packet size: %li", compound_packet_size);
|
||||
}
|
||||
|
||||
if (bye_packet)
|
||||
{
|
||||
compound_packet_size += get_bye_packet_size(bye_ssrcs_);
|
||||
LOG_DEBUG("Sending BYE. Compound packet size: %li", compound_packet_size);
|
||||
UVG_LOG_DEBUG("Sending BYE. Compound packet size: %li", compound_packet_size);
|
||||
}
|
||||
|
||||
return compound_packet_size;
|
||||
|
@ -1584,12 +1584,12 @@ rtp_error_t uvgrtp::rtcp::generate_report()
|
|||
|
||||
if (compound_packet_size == 0)
|
||||
{
|
||||
LOG_WARN("Failed to get compound packet size");
|
||||
UVG_LOG_WARN("Failed to get compound packet size");
|
||||
return RTP_GENERIC_ERROR;
|
||||
}
|
||||
else if (compound_packet_size > mtu_size_)
|
||||
{
|
||||
LOG_WARN("Generate RTCP packet is too large %lli/%lli, reports should be circled, but not implemented!",
|
||||
UVG_LOG_WARN("Generate RTCP packet is too large %lli/%lli, reports should be circled, but not implemented!",
|
||||
compound_packet_size, mtu_size_);
|
||||
}
|
||||
|
||||
|
@ -1621,7 +1621,7 @@ rtp_error_t uvgrtp::rtcp::generate_report()
|
|||
!construct_ssrc(frame, write_ptr, ssrc_) ||
|
||||
!construct_sender_info(frame, write_ptr, ntp_ts, rtp_ts, our_stats.sent_pkts, our_stats.sent_bytes))
|
||||
{
|
||||
LOG_ERROR("Failed to construct SR");
|
||||
UVG_LOG_ERROR("Failed to construct SR");
|
||||
return RTP_GENERIC_ERROR;
|
||||
}
|
||||
|
||||
|
@ -1633,7 +1633,7 @@ rtp_error_t uvgrtp::rtcp::generate_report()
|
|||
if (!construct_rtcp_header(frame, write_ptr, receiver_report_size, reports, uvgrtp::frame::RTCP_FT_RR) ||
|
||||
!construct_ssrc(frame, write_ptr, ssrc_))
|
||||
{
|
||||
LOG_ERROR("Failed to construct RR");
|
||||
UVG_LOG_ERROR("Failed to construct RR");
|
||||
return RTP_GENERIC_ERROR;
|
||||
}
|
||||
}
|
||||
|
@ -1679,7 +1679,7 @@ rtp_error_t uvgrtp::rtcp::generate_report()
|
|||
uvgrtp::frame::RTCP_FT_SDES) ||
|
||||
!construct_sdes_chunk(frame, write_ptr, { ssrc_, ourItems_ }))
|
||||
{
|
||||
LOG_ERROR("Failed to add SDES packet");
|
||||
UVG_LOG_ERROR("Failed to add SDES packet");
|
||||
delete[] frame;
|
||||
return RTP_GENERIC_ERROR;
|
||||
}
|
||||
|
@ -1706,7 +1706,7 @@ rtp_error_t uvgrtp::rtcp::generate_report()
|
|||
!construct_ssrc(frame, write_ptr, ssrc_) ||
|
||||
!construct_app_packet(frame, write_ptr, next_packet.name, next_packet.payload, next_packet.payload_len))
|
||||
{
|
||||
LOG_ERROR("Failed to construct APP packet");
|
||||
UVG_LOG_ERROR("Failed to construct APP packet");
|
||||
delete[] frame;
|
||||
app_name.second.pop_front();
|
||||
return RTP_GENERIC_ERROR;
|
||||
|
@ -1726,7 +1726,7 @@ rtp_error_t uvgrtp::rtcp::generate_report()
|
|||
!construct_bye_packet(frame, write_ptr, bye_ssrcs_))
|
||||
{
|
||||
bye_ssrcs_.clear();
|
||||
LOG_ERROR("Failed to construct BYE");
|
||||
UVG_LOG_ERROR("Failed to construct BYE");
|
||||
delete[] frame;
|
||||
return RTP_GENERIC_ERROR;
|
||||
}
|
||||
|
@ -1735,7 +1735,7 @@ rtp_error_t uvgrtp::rtcp::generate_report()
|
|||
}
|
||||
|
||||
|
||||
LOG_DEBUG("Sending RTCP report compound packet, Total size: %lli",
|
||||
UVG_LOG_DEBUG("Sending RTCP report compound packet, Total size: %lli",
|
||||
compound_packet_size);
|
||||
|
||||
return send_rtcp_packet_to_participants(frame, compound_packet_size, true);
|
||||
|
@ -1745,7 +1745,7 @@ rtp_error_t uvgrtp::rtcp::send_sdes_packet(const std::vector<uvgrtp::frame::rtcp
|
|||
{
|
||||
if (items.empty())
|
||||
{
|
||||
LOG_ERROR("Cannot send an empty SDES packet!");
|
||||
UVG_LOG_ERROR("Cannot send an empty SDES packet!");
|
||||
return RTP_INVALID_VALUE;
|
||||
}
|
||||
|
||||
|
@ -1761,7 +1761,7 @@ rtp_error_t uvgrtp::rtcp::send_bye_packet(std::vector<uint32_t> ssrcs)
|
|||
// ssrcs contains all our ssrcs which we usually have one unless we are a mixer
|
||||
if (ssrcs.empty())
|
||||
{
|
||||
LOG_WARN("Source Count in RTCP BYE packet is 0. Not sending.");
|
||||
UVG_LOG_WARN("Source Count in RTCP BYE packet is 0. Not sending.");
|
||||
}
|
||||
packet_mutex_.lock();
|
||||
bye_ssrcs_ = ssrcs;
|
||||
|
@ -1776,7 +1776,7 @@ rtp_error_t uvgrtp::rtcp::send_app_packet(const char* name, uint8_t subtype,
|
|||
packet_mutex_.lock();
|
||||
if (!app_packets_[name].empty())
|
||||
{
|
||||
LOG_WARN("Adding a new APP packet for sending when %llu packets are waiting to be sent",
|
||||
UVG_LOG_WARN("Adding a new APP packet for sending when %llu packets are waiting to be sent",
|
||||
app_packets_[name].size());
|
||||
}
|
||||
app_packets_[name].emplace_back(name, subtype, payload_len, payload);
|
||||
|
@ -1805,4 +1805,4 @@ void uvgrtp::rtcp::set_session_bandwidth(int kbps)
|
|||
void uvgrtp::rtcp::set_mtu_size(size_t mtu_size)
|
||||
{
|
||||
mtu_size_ = mtu_size;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ size_t uvgrtp::get_sdes_packet_size(const std::vector<uvgrtp::frame::rtcp_sdes_i
|
|||
}
|
||||
else
|
||||
{
|
||||
LOG_ERROR("SDES item text must not be longer than 255 characters");
|
||||
UVG_LOG_ERROR("SDES item text must not be longer than 255 characters");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -65,13 +65,13 @@ bool uvgrtp::construct_rtcp_header(uint8_t* frame, int& ptr, size_t packet_size,
|
|||
{
|
||||
if (packet_size > UINT16_MAX)
|
||||
{
|
||||
LOG_ERROR("RTCP receiver report packet size too large!");
|
||||
UVG_LOG_ERROR("RTCP receiver report packet size too large!");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (packet_size % 4 != 0)
|
||||
{
|
||||
LOG_ERROR("RTCP packet size should be measured in 32-bit words!");
|
||||
UVG_LOG_ERROR("RTCP packet size should be measured in 32-bit words!");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -155,7 +155,7 @@ bool uvgrtp::construct_sdes_chunk(uint8_t* frame, int& ptr,
|
|||
|
||||
if (!have_cname)
|
||||
{
|
||||
LOG_ERROR("SDES chunk did not contain cname!");
|
||||
UVG_LOG_ERROR("SDES chunk did not contain cname!");
|
||||
}
|
||||
|
||||
return have_cname;
|
||||
|
@ -169,4 +169,4 @@ bool uvgrtp::construct_bye_packet(uint8_t* frame, int& ptr, const std::vector<ui
|
|||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
16
src/rtp.cc
16
src/rtp.cc
|
@ -60,7 +60,7 @@ void uvgrtp::rtp::set_payload(rtp_format_t fmt)
|
|||
break;
|
||||
|
||||
default:
|
||||
LOG_WARN("Unknown RTP format, setting clock rate to 8000");
|
||||
UVG_LOG_WARN("Unknown RTP format, setting clock rate to 8000");
|
||||
clock_rate_ = 8000;
|
||||
break;
|
||||
}
|
||||
|
@ -167,7 +167,7 @@ rtp_error_t uvgrtp::rtp::packet_handler(ssize_t size, void *packet, int flags, u
|
|||
/* not an RTP frame */
|
||||
if (size < 12)
|
||||
{
|
||||
LOG_WARN("Received RTP packet is too small to contain header");
|
||||
UVG_LOG_WARN("Received RTP packet is too small to contain header");
|
||||
return RTP_PKT_NOT_HANDLED;
|
||||
}
|
||||
|
||||
|
@ -176,7 +176,7 @@ rtp_error_t uvgrtp::rtp::packet_handler(ssize_t size, void *packet, int flags, u
|
|||
/* invalid version */
|
||||
if (((ptr[0] >> 6) & 0x03) != 0x2)
|
||||
{
|
||||
LOG_WARN("Received RTP packet with invalid version");
|
||||
UVG_LOG_WARN("Received RTP packet with invalid version");
|
||||
return RTP_PKT_NOT_HANDLED;
|
||||
}
|
||||
|
||||
|
@ -200,14 +200,14 @@ rtp_error_t uvgrtp::rtp::packet_handler(ssize_t size, void *packet, int flags, u
|
|||
ptr += sizeof(uvgrtp::frame::rtp_header);
|
||||
|
||||
if ((*out)->header.cc > 0) {
|
||||
LOG_DEBUG("frame contains csrc entries");
|
||||
UVG_LOG_DEBUG("frame contains csrc entries");
|
||||
|
||||
if ((ssize_t)((*out)->payload_len - (*out)->header.cc * sizeof(uint32_t)) < 0) {
|
||||
LOG_DEBUG("Invalid frame length, %d CSRC entries, total length %zu", (*out)->header.cc, (*out)->payload_len);
|
||||
UVG_LOG_DEBUG("Invalid frame length, %d CSRC entries, total length %zu", (*out)->header.cc, (*out)->payload_len);
|
||||
(void)uvgrtp::frame::dealloc_frame(*out);
|
||||
return RTP_GENERIC_ERROR;
|
||||
}
|
||||
LOG_DEBUG("Allocating %u CSRC entries", (*out)->header.cc);
|
||||
UVG_LOG_DEBUG("Allocating %u CSRC entries", (*out)->header.cc);
|
||||
|
||||
(*out)->csrc = new uint32_t[(*out)->header.cc];
|
||||
(*out)->payload_len -= (*out)->header.cc * sizeof(uint32_t);
|
||||
|
@ -219,7 +219,7 @@ rtp_error_t uvgrtp::rtp::packet_handler(ssize_t size, void *packet, int flags, u
|
|||
}
|
||||
|
||||
if ((*out)->header.ext) {
|
||||
LOG_DEBUG("Frame contains extension information");
|
||||
UVG_LOG_DEBUG("Frame contains extension information");
|
||||
(*out)->ext = new uvgrtp::frame::ext_header;
|
||||
|
||||
(*out)->ext->type = ntohs(*(uint16_t *)&ptr[0]);
|
||||
|
@ -233,7 +233,7 @@ rtp_error_t uvgrtp::rtp::packet_handler(ssize_t size, void *packet, int flags, u
|
|||
* how many padding bytes was used. Make sure the padding length is
|
||||
* valid and subtract the amount of padding bytes from payload length */
|
||||
if ((*out)->header.padding) {
|
||||
LOG_DEBUG("Frame contains padding");
|
||||
UVG_LOG_DEBUG("Frame contains padding");
|
||||
uint8_t padding_len = (*out)->payload[(*out)->payload_len - 1];
|
||||
|
||||
if (!padding_len || (*out)->payload_len <= padding_len) {
|
||||
|
|
|
@ -37,7 +37,7 @@ uvgrtp::media_stream *uvgrtp::session::create_stream(int r_port, int s_port, rtp
|
|||
uvgrtp::media_stream *stream = nullptr;
|
||||
|
||||
if (flags & RCE_SYSTEM_CALL_DISPATCHER) {
|
||||
LOG_ERROR("SCD is no longer supported!");
|
||||
UVG_LOG_ERROR("SCD is no longer supported!");
|
||||
rtp_errno = RTP_NOT_SUPPORTED;
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ uvgrtp::media_stream *uvgrtp::session::create_stream(int r_port, int s_port, rtp
|
|||
|
||||
if (flags & RCE_SRTP) {
|
||||
if (!uvgrtp::crypto::enabled()) {
|
||||
LOG_ERROR("Recompile uvgRTP with -D__RTP_CRYPTO__");
|
||||
UVG_LOG_ERROR("Recompile uvgRTP with -D__RTP_CRYPTO__");
|
||||
rtp_errno = RTP_GENERIC_ERROR;
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ uvgrtp::media_stream *uvgrtp::session::create_stream(int r_port, int s_port, rtp
|
|||
if (flags & RCE_SRTP_KMNGMNT_ZRTP) {
|
||||
|
||||
if (flags & (RCE_SRTP_KEYSIZE_192 | RCE_SRTP_KEYSIZE_256)) {
|
||||
LOG_ERROR("Only 128-bit keys are supported with ZRTP");
|
||||
UVG_LOG_ERROR("Only 128-bit keys are supported with ZRTP");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -69,19 +69,19 @@ uvgrtp::media_stream *uvgrtp::session::create_stream(int r_port, int s_port, rtp
|
|||
}
|
||||
|
||||
if (stream->init(zrtp_) != RTP_OK) {
|
||||
LOG_ERROR("Failed to initialize media stream %s:%d/%d", addr_.c_str(), r_port, s_port);
|
||||
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) {
|
||||
LOG_DEBUG("SRTP with user-managed keys enabled, postpone initialization");
|
||||
UVG_LOG_DEBUG("SRTP with user-managed keys enabled, postpone initialization");
|
||||
} else {
|
||||
LOG_ERROR("SRTP key management scheme not specified!");
|
||||
UVG_LOG_ERROR("SRTP key management scheme not specified!");
|
||||
rtp_errno = RTP_INVALID_VALUE;
|
||||
return nullptr;
|
||||
}
|
||||
} else {
|
||||
if (stream->init() != RTP_OK) {
|
||||
LOG_ERROR("Failed to initialize media stream %s:%d/%d", addr_.c_str(), r_port, s_port);
|
||||
UVG_LOG_ERROR("Failed to initialize media stream %s:%d/%d", addr_.c_str(), r_port, s_port);
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ uvgrtp::socket::socket(int flags):
|
|||
|
||||
uvgrtp::socket::~socket()
|
||||
{
|
||||
LOG_DEBUG("Socket total sent packets is %lu and received packets is %lu", sent_packets_, received_packets_);
|
||||
UVG_LOG_DEBUG("Socket total sent packets is %lu and received packets is %lu", sent_packets_, received_packets_);
|
||||
|
||||
#ifndef _WIN32
|
||||
close(socket_);
|
||||
|
@ -50,7 +50,7 @@ rtp_error_t uvgrtp::socket::init(short family, int type, int protocol)
|
|||
win_get_last_error();
|
||||
#else
|
||||
if ((socket_ = ::socket(family, type, protocol)) < 0) {
|
||||
LOG_ERROR("Failed to create socket: %s", strerror(errno));
|
||||
UVG_LOG_ERROR("Failed to create socket: %s", strerror(errno));
|
||||
#endif
|
||||
return RTP_SOCKET_ERROR;
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ rtp_error_t uvgrtp::socket::init(short family, int type, int protocol)
|
|||
rtp_error_t uvgrtp::socket::setsockopt(int level, int optname, const void *optval, socklen_t optlen)
|
||||
{
|
||||
if (::setsockopt(socket_, level, optname, (const char *)optval, optlen) < 0) {
|
||||
LOG_ERROR("Failed to set socket options: %s", strerror(errno));
|
||||
UVG_LOG_ERROR("Failed to set socket options: %s", strerror(errno));
|
||||
return RTP_GENERIC_ERROR;
|
||||
}
|
||||
|
||||
|
@ -87,7 +87,7 @@ rtp_error_t uvgrtp::socket::bind(short family, unsigned host, short port)
|
|||
#else
|
||||
fprintf(stderr, "%s\n", strerror(errno));
|
||||
#endif
|
||||
LOG_ERROR("Binding to port %u failed!", port);
|
||||
UVG_LOG_ERROR("Binding to port %u failed!", port);
|
||||
return RTP_BIND_ERROR;
|
||||
}
|
||||
|
||||
|
@ -156,7 +156,7 @@ rtp_error_t uvgrtp::socket::__sendto(sockaddr_in& addr, uint8_t *buf, size_t buf
|
|||
|
||||
#ifndef _WIN32
|
||||
if ((nsend = ::sendto(socket_, buf, buf_len, flags, (const struct sockaddr *)&addr, sizeof(addr_))) == -1) {
|
||||
LOG_ERROR("Failed to send data: %s", strerror(errno));
|
||||
UVG_LOG_ERROR("Failed to send data: %s", strerror(errno));
|
||||
|
||||
if (bytes_sent)
|
||||
*bytes_sent = -1;
|
||||
|
@ -233,7 +233,7 @@ rtp_error_t uvgrtp::socket::__sendtov(
|
|||
header_.msg_hdr.msg_controllen = 0;
|
||||
|
||||
if (sendmmsg(socket_, &header_, 1, flags) < 0) {
|
||||
LOG_ERROR("Failed to send RTP frame: %s!", strerror(errno));
|
||||
UVG_LOG_ERROR("Failed to send RTP frame: %s!", strerror(errno));
|
||||
set_bytes(bytes_sent, -1);
|
||||
return RTP_SEND_ERROR;
|
||||
}
|
||||
|
@ -243,7 +243,7 @@ rtp_error_t uvgrtp::socket::__sendtov(
|
|||
// DWORD corresponds to uint16 on most platforms
|
||||
if (buffers.size() > UINT16_MAX)
|
||||
{
|
||||
LOG_ERROR("Trying to send too large buffer");
|
||||
UVG_LOG_ERROR("Trying to send too large buffer");
|
||||
return RTP_INVALID_VALUE;
|
||||
}
|
||||
|
||||
|
@ -278,7 +278,7 @@ rtp_error_t uvgrtp::socket::sendto(buf_vec& buffers, int flags)
|
|||
|
||||
for (auto& handler : vec_handlers_) {
|
||||
if ((ret = (*handler.handler)(handler.arg, buffers)) != RTP_OK) {
|
||||
LOG_ERROR("Malformed packet");
|
||||
UVG_LOG_ERROR("Malformed packet");
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
@ -292,7 +292,7 @@ rtp_error_t uvgrtp::socket::sendto(buf_vec& buffers, int flags, int *bytes_sent)
|
|||
|
||||
for (auto& handler : vec_handlers_) {
|
||||
if ((ret = (*handler.handler)(handler.arg, buffers)) != RTP_OK) {
|
||||
LOG_ERROR("Malformed packet");
|
||||
UVG_LOG_ERROR("Malformed packet");
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
@ -306,7 +306,7 @@ rtp_error_t uvgrtp::socket::sendto(sockaddr_in& addr, buf_vec& buffers, int flag
|
|||
|
||||
for (auto& handler : vec_handlers_) {
|
||||
if ((ret = (*handler.handler)(handler.arg, buffers)) != RTP_OK) {
|
||||
LOG_ERROR("Malformed packet");
|
||||
UVG_LOG_ERROR("Malformed packet");
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
@ -324,7 +324,7 @@ rtp_error_t uvgrtp::socket::sendto(
|
|||
|
||||
for (auto& handler : vec_handlers_) {
|
||||
if ((ret = (*handler.handler)(handler.arg, buffers)) != RTP_OK) {
|
||||
LOG_ERROR("Malformed packet");
|
||||
UVG_LOG_ERROR("Malformed packet");
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
@ -389,7 +389,7 @@ rtp_error_t uvgrtp::socket::__sendtov(
|
|||
for (auto& buffer : buffers) {
|
||||
|
||||
if (buffer.size() > WSABUF_SIZE) {
|
||||
LOG_ERROR("Input vector to __sendtov() has more than %u elements!", WSABUF_SIZE);
|
||||
UVG_LOG_ERROR("Input vector to __sendtov() has more than %u elements!", WSABUF_SIZE);
|
||||
return RTP_GENERIC_ERROR;
|
||||
}
|
||||
/* create WSABUFs from input buffer and send them at once */
|
||||
|
@ -437,7 +437,7 @@ rtp_error_t uvgrtp::socket::sendto(pkt_vec& buffers, int flags)
|
|||
for (auto& buffer : buffers) {
|
||||
for (auto& handler : vec_handlers_) {
|
||||
if ((ret = (*handler.handler)(handler.arg, buffer)) != RTP_OK) {
|
||||
LOG_ERROR("Malformed packet");
|
||||
UVG_LOG_ERROR("Malformed packet");
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
@ -453,7 +453,7 @@ rtp_error_t uvgrtp::socket::sendto(pkt_vec& buffers, int flags, int *bytes_sent)
|
|||
for (auto& buffer : buffers) {
|
||||
for (auto& handler : vec_handlers_) {
|
||||
if ((ret = (*handler.handler)(handler.arg, buffer)) != RTP_OK) {
|
||||
LOG_ERROR("Malformed packet");
|
||||
UVG_LOG_ERROR("Malformed packet");
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
@ -469,7 +469,7 @@ rtp_error_t uvgrtp::socket::sendto(sockaddr_in& addr, pkt_vec& buffers, int flag
|
|||
for (auto& buffer : buffers) {
|
||||
for (auto& handler : vec_handlers_) {
|
||||
if ((ret = (*handler.handler)(handler.arg, buffer)) != RTP_OK) {
|
||||
LOG_ERROR("Malformed packet");
|
||||
UVG_LOG_ERROR("Malformed packet");
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
@ -485,7 +485,7 @@ rtp_error_t uvgrtp::socket::sendto(sockaddr_in& addr, pkt_vec& buffers, int flag
|
|||
for (auto& buffer : buffers) {
|
||||
for (auto& handler : vec_handlers_) {
|
||||
if ((ret = (*handler.handler)(handler.arg, buffer)) != RTP_OK) {
|
||||
LOG_ERROR("Malformed packet");
|
||||
UVG_LOG_ERROR("Malformed packet");
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
@ -509,7 +509,7 @@ rtp_error_t uvgrtp::socket::__recv(uint8_t *buf, size_t buf_len, int flags, int
|
|||
set_bytes(bytes_read, 0);
|
||||
return RTP_INTERRUPTED;
|
||||
}
|
||||
LOG_ERROR("recv(2) failed: %s", strerror(errno));
|
||||
UVG_LOG_ERROR("recv(2) failed: %s", strerror(errno));
|
||||
|
||||
set_bytes(bytes_read, -1);
|
||||
return RTP_GENERIC_ERROR;
|
||||
|
@ -572,7 +572,7 @@ rtp_error_t uvgrtp::socket::__recvfrom(uint8_t *buf, size_t buf_len, int flags,
|
|||
set_bytes(bytes_read, 0);
|
||||
return RTP_INTERRUPTED;
|
||||
}
|
||||
LOG_ERROR("recvfrom failed: %s", strerror(errno));
|
||||
UVG_LOG_ERROR("recvfrom failed: %s", strerror(errno));
|
||||
|
||||
set_bytes(bytes_read, -1);
|
||||
return RTP_GENERIC_ERROR;
|
||||
|
|
|
@ -85,7 +85,7 @@ bool uvgrtp::base_srtp::is_replayed_packet(uint8_t *digest)
|
|||
memcpy(&truncated, digest, sizeof(uint64_t));
|
||||
|
||||
if (replay_list_.find(truncated) != replay_list_.end()) {
|
||||
LOG_ERROR("Replayed packet received, discarding!");
|
||||
UVG_LOG_ERROR("Replayed packet received, discarding!");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -49,13 +49,13 @@ rtp_error_t uvgrtp::srtcp::handle_rtcp_decryption(int flags, uint32_t ssrc,
|
|||
|
||||
if (flags & RCE_SRTP) {
|
||||
if ((ret = verify_auth_tag(packet, packet_size)) != RTP_OK) {
|
||||
LOG_ERROR("Failed to verify RTCP authentication tag!");
|
||||
UVG_LOG_ERROR("Failed to verify RTCP authentication tag!");
|
||||
return RTP_AUTH_TAG_MISMATCH;
|
||||
}
|
||||
|
||||
if (((srtpi >> 31) & 0x1) && !(flags & RCE_SRTP_NULL_CIPHER)) {
|
||||
if (decrypt(ssrc, srtpi & 0x7fffffff, packet, packet_size) != RTP_OK) {
|
||||
LOG_ERROR("Failed to decrypt RTCP Sender Report");
|
||||
UVG_LOG_ERROR("Failed to decrypt RTCP Sender Report");
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ rtp_error_t uvgrtp::srtcp::encrypt(uint32_t ssrc, uint64_t seq, uint8_t *buffer,
|
|||
uint8_t iv[UVG_IV_LENGTH] = { 0 };
|
||||
|
||||
if (create_iv(iv, ssrc, seq, srtp_ctx_->key_ctx.local.salt_key) != RTP_OK) {
|
||||
LOG_ERROR("Failed to create IV, unable to encrypt the RTP packet!");
|
||||
UVG_LOG_ERROR("Failed to create IV, unable to encrypt the RTP packet!");
|
||||
return RTP_INVALID_VALUE;
|
||||
}
|
||||
|
||||
|
@ -103,12 +103,12 @@ rtp_error_t uvgrtp::srtcp::verify_auth_tag(uint8_t *buffer, size_t len)
|
|||
hmac_sha1.final(digest, UVG_AUTH_TAG_LENGTH);
|
||||
|
||||
if (memcmp(digest, &buffer[len - UVG_AUTH_TAG_LENGTH], UVG_AUTH_TAG_LENGTH)) {
|
||||
LOG_ERROR("STCP authentication tag mismatch!");
|
||||
UVG_LOG_ERROR("STCP authentication tag mismatch!");
|
||||
return RTP_AUTH_TAG_MISMATCH;
|
||||
}
|
||||
|
||||
if (is_replayed_packet(digest)) {
|
||||
LOG_ERROR("Replayed packet received, discarding!");
|
||||
UVG_LOG_ERROR("Replayed packet received, discarding!");
|
||||
return RTP_INVALID_VALUE;
|
||||
}
|
||||
|
||||
|
@ -120,7 +120,7 @@ rtp_error_t uvgrtp::srtcp::decrypt(uint32_t ssrc, uint32_t seq, uint8_t *buffer,
|
|||
uint8_t iv[UVG_IV_LENGTH] = { 0 };
|
||||
|
||||
if (create_iv(iv, ssrc, seq, srtp_ctx_->key_ctx.remote.salt_key) != RTP_OK) {
|
||||
LOG_ERROR("Failed to create IV, unable to encrypt the RTP packet!");
|
||||
UVG_LOG_ERROR("Failed to create IV, unable to encrypt the RTP packet!");
|
||||
return RTP_INVALID_VALUE;
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ rtp_error_t uvgrtp::srtp::encrypt(uint32_t ssrc, uint16_t seq, uint8_t *buffer,
|
|||
srtp_ctx_->roc++;
|
||||
|
||||
if (create_iv(iv, ssrc, index, srtp_ctx_->key_ctx.local.salt_key) != RTP_OK) {
|
||||
LOG_ERROR("Failed to create IV, unable to encrypt the RTP packet!");
|
||||
UVG_LOG_ERROR("Failed to create IV, unable to encrypt the RTP packet!");
|
||||
return RTP_INVALID_VALUE;
|
||||
}
|
||||
|
||||
|
@ -60,12 +60,12 @@ rtp_error_t uvgrtp::srtp::recv_packet_handler(void *arg, int flags, frame::rtp_f
|
|||
hmac_sha1.final((uint8_t *)digest, UVG_AUTH_TAG_LENGTH);
|
||||
|
||||
if (memcmp(digest, &frame->dgram[frame->dgram_size - UVG_AUTH_TAG_LENGTH], UVG_AUTH_TAG_LENGTH)) {
|
||||
LOG_ERROR("Authentication tag mismatch!");
|
||||
UVG_LOG_ERROR("Authentication tag mismatch!");
|
||||
return RTP_GENERIC_ERROR;
|
||||
}
|
||||
|
||||
if (srtp->is_replayed_packet(digest)) {
|
||||
LOG_ERROR("Replayed packet received, discarding!");
|
||||
UVG_LOG_ERROR("Replayed packet received, discarding!");
|
||||
return RTP_GENERIC_ERROR;
|
||||
}
|
||||
frame->payload_len -= UVG_AUTH_TAG_LENGTH;
|
||||
|
@ -103,7 +103,7 @@ rtp_error_t uvgrtp::srtp::recv_packet_handler(void *arg, int flags, frame::rtp_f
|
|||
}
|
||||
|
||||
if (srtp->create_iv(iv, ssrc, index, ctx->key_ctx.remote.salt_key) != RTP_OK) {
|
||||
LOG_ERROR("Failed to create IV, unable to encrypt the RTP packet!");
|
||||
UVG_LOG_ERROR("Failed to create IV, unable to encrypt the RTP packet!");
|
||||
return RTP_GENERIC_ERROR;
|
||||
}
|
||||
|
||||
|
@ -134,7 +134,7 @@ rtp_error_t uvgrtp::srtp::send_packet_handler(void *arg, uvgrtp::buf_vec& buffer
|
|||
);
|
||||
|
||||
if (ret != RTP_OK) {
|
||||
LOG_ERROR("Failed to encrypt RTP packet!");
|
||||
UVG_LOG_ERROR("Failed to encrypt RTP packet!");
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
64
src/zrtp.cc
64
src/zrtp.cc
|
@ -96,7 +96,7 @@ void uvgrtp::zrtp::derive_key(const char *label, uint32_t key_len, uint8_t *out_
|
|||
/* Key length might differ from the digest length in which case the digest
|
||||
* must be generated to a temporary buffer and truncated to fit the "out_key" buffer */
|
||||
if (key_len != 256) {
|
||||
LOG_DEBUG("Truncate key to %u bits!", key_len);
|
||||
UVG_LOG_DEBUG("Truncate key to %u bits!", key_len);
|
||||
|
||||
hmac_sha256.final((uint8_t *)tmp);
|
||||
memcpy(out_key, tmp, key_len / 8);
|
||||
|
@ -276,7 +276,7 @@ rtp_error_t uvgrtp::zrtp::validate_session()
|
|||
session_.hash_ctx.r_mac[3]
|
||||
))
|
||||
{
|
||||
LOG_ERROR("Hash mismatch for Hello Message!");
|
||||
UVG_LOG_ERROR("Hash mismatch for Hello Message!");
|
||||
return RTP_INVALID_VALUE;
|
||||
}
|
||||
|
||||
|
@ -290,7 +290,7 @@ rtp_error_t uvgrtp::zrtp::validate_session()
|
|||
session_.hash_ctx.r_mac[2]
|
||||
))
|
||||
{
|
||||
LOG_ERROR("Hash mismatch for Commit Message!");
|
||||
UVG_LOG_ERROR("Hash mismatch for Commit Message!");
|
||||
return RTP_INVALID_VALUE;
|
||||
}
|
||||
}
|
||||
|
@ -303,11 +303,11 @@ rtp_error_t uvgrtp::zrtp::validate_session()
|
|||
session_.hash_ctx.r_mac[1]
|
||||
))
|
||||
{
|
||||
LOG_ERROR("Hash mismatch for DHPart1/DHPart2 Message!");
|
||||
UVG_LOG_ERROR("Hash mismatch for DHPart1/DHPart2 Message!");
|
||||
return RTP_INVALID_VALUE;
|
||||
}
|
||||
|
||||
LOG_DEBUG("All hashes match!");
|
||||
UVG_LOG_DEBUG("All hashes match!");
|
||||
return RTP_OK;
|
||||
}
|
||||
|
||||
|
@ -350,7 +350,7 @@ rtp_error_t uvgrtp::zrtp::begin_session()
|
|||
|
||||
for (i = 0; i < 20; ++i) {
|
||||
if ((ret = hello.send_msg(socket_, addr_)) != RTP_OK) {
|
||||
LOG_ERROR("Failed to send Hello message");
|
||||
UVG_LOG_ERROR("Failed to send Hello message");
|
||||
}
|
||||
|
||||
if ((type = receiver_.recv_msg(socket_, rto, 0)) > 0) {
|
||||
|
@ -379,13 +379,13 @@ rtp_error_t uvgrtp::zrtp::begin_session()
|
|||
* indicating failure to support this ZRTP version."
|
||||
*/
|
||||
if (session_.capabilities.version < ZRTP_VERSION) {
|
||||
LOG_ERROR("Remote supports version %d, uvgRTP supports %d. Session cannot continue!",
|
||||
UVG_LOG_ERROR("Remote supports version %d, uvgRTP supports %d. Session cannot continue!",
|
||||
session_.capabilities.version, ZRTP_VERSION);
|
||||
|
||||
return RTP_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
LOG_WARN("ZRTP Protocol version %u not supported, keep sending Hello Messages",
|
||||
UVG_LOG_WARN("ZRTP Protocol version %u not supported, keep sending Hello Messages",
|
||||
session_.capabilities.version);
|
||||
hello_recv = false;
|
||||
}
|
||||
|
@ -441,7 +441,7 @@ rtp_error_t uvgrtp::zrtp::init_session(int key_agreement)
|
|||
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
if ((ret = commit.send_msg(socket_, addr_)) != RTP_OK) {
|
||||
LOG_ERROR("Failed to send Commit message!");
|
||||
UVG_LOG_ERROR("Failed to send Commit message!");
|
||||
}
|
||||
|
||||
if ((type = receiver_.recv_msg(socket_, rto, 0)) > 0) {
|
||||
|
@ -482,16 +482,16 @@ rtp_error_t uvgrtp::zrtp::dh_part1()
|
|||
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
if ((ret = dhpart.send_msg(socket_, addr_)) != RTP_OK) {
|
||||
LOG_ERROR("Failed to send DHPart1 Message!");
|
||||
UVG_LOG_ERROR("Failed to send DHPart1 Message!");
|
||||
}
|
||||
|
||||
if ((type = receiver_.recv_msg(socket_, rto, 0)) > 0) {
|
||||
if (type == ZRTP_FT_DH_PART2) {
|
||||
if ((ret = dhpart.parse_msg(receiver_, session_)) != RTP_OK) {
|
||||
LOG_ERROR("Failed to parse DHPart2 Message!");
|
||||
UVG_LOG_ERROR("Failed to parse DHPart2 Message!");
|
||||
continue;
|
||||
}
|
||||
LOG_DEBUG("DHPart2 received and parse successfully!");
|
||||
UVG_LOG_DEBUG("DHPart2 received and parse successfully!");
|
||||
|
||||
/* parse_msg() above extracted the public key of remote and saved it to session_.
|
||||
* Now we must generate shared secrets (DHResult, total_hash, and s0) */
|
||||
|
@ -516,7 +516,7 @@ rtp_error_t uvgrtp::zrtp::dh_part2()
|
|||
auto dhpart = uvgrtp::zrtp_msg::dh_key_exchange(session_, 2);
|
||||
|
||||
if ((ret = dhpart.parse_msg(receiver_, session_)) != RTP_OK) {
|
||||
LOG_ERROR("Failed to parse DHPart1 Message!");
|
||||
UVG_LOG_ERROR("Failed to parse DHPart1 Message!");
|
||||
return RTP_INVALID_VALUE;
|
||||
}
|
||||
|
||||
|
@ -526,12 +526,12 @@ rtp_error_t uvgrtp::zrtp::dh_part2()
|
|||
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
if ((ret = dhpart.send_msg(socket_, addr_)) != RTP_OK) {
|
||||
LOG_ERROR("Failed to send DHPart2 Message!");
|
||||
UVG_LOG_ERROR("Failed to send DHPart2 Message!");
|
||||
}
|
||||
|
||||
if ((type = receiver_.recv_msg(socket_, rto, 0)) > 0) {
|
||||
if (type == ZRTP_FT_CONFIRM1) {
|
||||
LOG_DEBUG("Confirm1 Message received");
|
||||
UVG_LOG_DEBUG("Confirm1 Message received");
|
||||
return RTP_OK;
|
||||
}
|
||||
}
|
||||
|
@ -553,18 +553,18 @@ rtp_error_t uvgrtp::zrtp::responder_finalize_session()
|
|||
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
if ((ret = confirm.send_msg(socket_, addr_)) != RTP_OK) {
|
||||
LOG_ERROR("Failed to send Confirm1 Message!");
|
||||
UVG_LOG_ERROR("Failed to send Confirm1 Message!");
|
||||
}
|
||||
|
||||
if ((type = receiver_.recv_msg(socket_, rto, 0)) > 0) {
|
||||
if (type == ZRTP_FT_CONFIRM2) {
|
||||
if ((ret = confirm.parse_msg(receiver_, session_)) != RTP_OK) {
|
||||
LOG_ERROR("Failed to parse Confirm2 Message!");
|
||||
UVG_LOG_ERROR("Failed to parse Confirm2 Message!");
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((ret = validate_session()) != RTP_OK) {
|
||||
LOG_ERROR("Mismatch on one of the received MACs/Hashes, session cannot continue");
|
||||
UVG_LOG_ERROR("Mismatch on one of the received MACs/Hashes, session cannot continue");
|
||||
return RTP_INVALID_VALUE;
|
||||
}
|
||||
|
||||
|
@ -589,23 +589,23 @@ rtp_error_t uvgrtp::zrtp::initiator_finalize_session()
|
|||
int type = 0;
|
||||
|
||||
if ((ret = confirm.parse_msg(receiver_, session_)) != RTP_OK) {
|
||||
LOG_ERROR("Failed to parse Confirm1 Message!");
|
||||
UVG_LOG_ERROR("Failed to parse Confirm1 Message!");
|
||||
return RTP_INVALID_VALUE;
|
||||
}
|
||||
|
||||
if ((ret = validate_session()) != RTP_OK) {
|
||||
LOG_ERROR("Mismatch on one of the received MACs/Hashes, session cannot continue");
|
||||
UVG_LOG_ERROR("Mismatch on one of the received MACs/Hashes, session cannot continue");
|
||||
return RTP_INVALID_VALUE;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
if ((ret = confirm.send_msg(socket_, addr_)) != RTP_OK) {
|
||||
LOG_ERROR("Failed to send Confirm2 Message!");
|
||||
UVG_LOG_ERROR("Failed to send Confirm2 Message!");
|
||||
}
|
||||
|
||||
if ((type = receiver_.recv_msg(socket_, rto, 0)) > 0) {
|
||||
if (type == ZRTP_FT_CONF2_ACK) {
|
||||
LOG_DEBUG("Conf2ACK received successfully!");
|
||||
UVG_LOG_DEBUG("Conf2ACK received successfully!");
|
||||
return RTP_OK;
|
||||
}
|
||||
}
|
||||
|
@ -651,7 +651,7 @@ rtp_error_t uvgrtp::zrtp::init_dhm(uint32_t ssrc, std::shared_ptr<uvgrtp::socket
|
|||
* After begin_session() we know what remote is capable of
|
||||
* and whether we are compatible implementations */
|
||||
if ((ret = begin_session()) != RTP_OK) {
|
||||
LOG_ERROR("Session initialization failed, ZRTP cannot be used!");
|
||||
UVG_LOG_ERROR("Session initialization failed, ZRTP cannot be used!");
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -681,7 +681,7 @@ rtp_error_t uvgrtp::zrtp::init_dhm(uint32_t ssrc, std::shared_ptr<uvgrtp::socket
|
|||
* init_session() will exchange the Commit messages and select roles for the
|
||||
* participants (initiator/responder) based on rules determined in RFC 6189 */
|
||||
if ((ret = init_session(DH3k)) != RTP_OK) {
|
||||
LOG_ERROR("Could not agree on ZRTP session parameters or roles of participants!");
|
||||
UVG_LOG_ERROR("Could not agree on ZRTP session parameters or roles of participants!");
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -689,23 +689,23 @@ rtp_error_t uvgrtp::zrtp::init_dhm(uint32_t ssrc, std::shared_ptr<uvgrtp::socket
|
|||
* and different message that they need to send in order to finalize the ZRTP connection */
|
||||
if (session_.role == INITIATOR) {
|
||||
if ((ret = dh_part2()) != RTP_OK) {
|
||||
LOG_ERROR("Failed to perform Diffie-Hellman key exchange Part2");
|
||||
UVG_LOG_ERROR("Failed to perform Diffie-Hellman key exchange Part2");
|
||||
return ret;
|
||||
}
|
||||
|
||||
if ((ret = initiator_finalize_session()) != RTP_OK) {
|
||||
LOG_ERROR("Failed to finalize session using Confirm2");
|
||||
UVG_LOG_ERROR("Failed to finalize session using Confirm2");
|
||||
return ret;
|
||||
}
|
||||
|
||||
} else {
|
||||
if ((ret = dh_part1()) != RTP_OK) {
|
||||
LOG_ERROR("Failed to perform Diffie-Hellman key exchange Part1");
|
||||
UVG_LOG_ERROR("Failed to perform Diffie-Hellman key exchange Part1");
|
||||
return ret;
|
||||
}
|
||||
|
||||
if ((ret = responder_finalize_session()) != RTP_OK) {
|
||||
LOG_ERROR("Failed to finalize session using Confirm1/Conf2ACK");
|
||||
UVG_LOG_ERROR("Failed to finalize session using Confirm1/Conf2ACK");
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
@ -734,12 +734,12 @@ rtp_error_t uvgrtp::zrtp::init_msm(uint32_t ssrc, std::shared_ptr<uvgrtp::socket
|
|||
session_.seq = 0;
|
||||
|
||||
if ((ret = begin_session()) != RTP_OK) {
|
||||
LOG_ERROR("Session initialization failed, ZRTP cannot be used!");
|
||||
UVG_LOG_ERROR("Session initialization failed, ZRTP cannot be used!");
|
||||
return ret;
|
||||
}
|
||||
|
||||
if ((ret = init_session(MULT)) != RTP_OK) {
|
||||
LOG_ERROR("Could not agree on ZRTP session parameters or roles of participants!");
|
||||
UVG_LOG_ERROR("Could not agree on ZRTP session parameters or roles of participants!");
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -747,14 +747,14 @@ rtp_error_t uvgrtp::zrtp::init_msm(uint32_t ssrc, std::shared_ptr<uvgrtp::socket
|
|||
generate_shared_secrets_msm();
|
||||
|
||||
if ((ret = initiator_finalize_session()) != RTP_OK) {
|
||||
LOG_ERROR("Failed to finalize session using Confirm2");
|
||||
UVG_LOG_ERROR("Failed to finalize session using Confirm2");
|
||||
return ret;
|
||||
}
|
||||
} else {
|
||||
generate_shared_secrets_msm();
|
||||
|
||||
if ((ret = responder_finalize_session()) != RTP_OK) {
|
||||
LOG_ERROR("Failed to finalize session using Confirm1/Conf2ACK");
|
||||
UVG_LOG_ERROR("Failed to finalize session using Confirm1/Conf2ACK");
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ uvgrtp::zrtp_msg::commit::commit(zrtp_session_t& session):
|
|||
/* temporary storage for the full hmac hash */
|
||||
uint8_t mac_full[32] = { 0 };
|
||||
|
||||
LOG_DEBUG("Create ZRTP Commit message!");
|
||||
UVG_LOG_DEBUG("Create ZRTP Commit message!");
|
||||
|
||||
allocate_frame(sizeof(zrtp_commit));
|
||||
zrtp_commit *msg = (zrtp_commit *)frame_;
|
||||
|
@ -67,7 +67,7 @@ rtp_error_t uvgrtp::zrtp_msg::commit::parse_msg(uvgrtp::zrtp_msg::receiver& rece
|
|||
allocate_rframe(sizeof(zrtp_commit));
|
||||
|
||||
if ((len = receiver.get_msg(rframe_, rlen_)) < 0) {
|
||||
LOG_ERROR("Failed to get message from ZRTP receiver");
|
||||
UVG_LOG_ERROR("Failed to get message from ZRTP receiver");
|
||||
return RTP_INVALID_VALUE;
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
uvgrtp::zrtp_msg::confack::confack(zrtp_session_t& session):
|
||||
zrtp_message()
|
||||
{
|
||||
LOG_DEBUG("Create ZRTP Conf2ACK message!");
|
||||
UVG_LOG_DEBUG("Create ZRTP Conf2ACK message!");
|
||||
|
||||
allocate_frame(sizeof(zrtp_confack));
|
||||
zrtp_confack* msg = (zrtp_confack*)frame_;
|
||||
|
@ -33,7 +33,7 @@ rtp_error_t uvgrtp::zrtp_msg::confack::parse_msg(uvgrtp::zrtp_msg::receiver& rec
|
|||
allocate_rframe(sizeof(zrtp_confack));
|
||||
|
||||
if ((len = receiver.get_msg(rframe_, rlen_)) < 0) {
|
||||
LOG_ERROR("Failed to get message from ZRTP receiver");
|
||||
UVG_LOG_ERROR("Failed to get message from ZRTP receiver");
|
||||
return RTP_INVALID_VALUE;
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ uvgrtp::zrtp_msg::confirm::confirm(zrtp_session_t& session, int part):
|
|||
/* temporary storage for the full hmac hash */
|
||||
uint8_t mac_full[32];
|
||||
|
||||
LOG_DEBUG("Create ZRTP Confirm%d message!", part);
|
||||
UVG_LOG_DEBUG("Create ZRTP Confirm%d message!", part);
|
||||
|
||||
allocate_frame(sizeof(zrtp_confirm));
|
||||
zrtp_confirm* msg = (zrtp_confirm*)frame_;
|
||||
|
@ -80,7 +80,7 @@ rtp_error_t uvgrtp::zrtp_msg::confirm::parse_msg(uvgrtp::zrtp_msg::receiver& rec
|
|||
|
||||
allocate_rframe(sizeof(zrtp_confirm));
|
||||
if ((len = receiver.get_msg(rframe_, rlen_)) < 0) {
|
||||
LOG_ERROR("Failed to get message from ZRTP receiver");
|
||||
UVG_LOG_ERROR("Failed to get message from ZRTP receiver");
|
||||
return RTP_INVALID_VALUE;
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ uvgrtp::zrtp_msg::dh_key_exchange::dh_key_exchange(zrtp_session_t& session, int
|
|||
}
|
||||
};
|
||||
|
||||
LOG_DEBUG("Create ZRTP DHPart%d message", part);
|
||||
UVG_LOG_DEBUG("Create ZRTP DHPart%d message", part);
|
||||
|
||||
allocate_frame(sizeof(zrtp_dh));
|
||||
zrtp_dh* msg = (zrtp_dh*)frame_;
|
||||
|
@ -97,12 +97,12 @@ uvgrtp::zrtp_msg::dh_key_exchange::~dh_key_exchange()
|
|||
|
||||
rtp_error_t uvgrtp::zrtp_msg::dh_key_exchange::parse_msg(uvgrtp::zrtp_msg::receiver& receiver, zrtp_session_t& session)
|
||||
{
|
||||
LOG_DEBUG("Parsing DHPart1/DHPart2 message...");
|
||||
UVG_LOG_DEBUG("Parsing DHPart1/DHPart2 message...");
|
||||
|
||||
ssize_t len = 0;
|
||||
allocate_rframe(sizeof(zrtp_dh));
|
||||
if ((len = receiver.get_msg(rframe_, rlen_)) < 0) {
|
||||
LOG_ERROR("Failed to get message from ZRTP receiver");
|
||||
UVG_LOG_ERROR("Failed to get message from ZRTP receiver");
|
||||
return RTP_INVALID_VALUE;
|
||||
}
|
||||
|
||||
|
|
|
@ -72,14 +72,14 @@ rtp_error_t uvgrtp::zrtp_msg::hello::parse_msg(uvgrtp::zrtp_msg::receiver& recei
|
|||
ssize_t len = 0;
|
||||
allocate_rframe(sizeof(zrtp_hello) + 5 * 8);
|
||||
if ((len = receiver.get_msg(rframe_, rlen_)) < 0) {
|
||||
LOG_ERROR("Failed to get message from ZRTP receiver");
|
||||
UVG_LOG_ERROR("Failed to get message from ZRTP receiver");
|
||||
return RTP_INVALID_VALUE;
|
||||
}
|
||||
|
||||
zrtp_hello *msg = (zrtp_hello *)rframe_;
|
||||
|
||||
if (strncmp((const char *)&msg->version, ZRTP_VERSION, 4)) {
|
||||
LOG_ERROR("Invalid ZRTP version!");
|
||||
UVG_LOG_ERROR("Invalid ZRTP version!");
|
||||
session.capabilities.version = 0;
|
||||
} else {
|
||||
session.capabilities.version = 110;
|
||||
|
|
|
@ -17,7 +17,7 @@ uvgrtp::zrtp_msg::zrtp_message::zrtp_message():
|
|||
|
||||
uvgrtp::zrtp_msg::zrtp_message::~zrtp_message()
|
||||
{
|
||||
LOG_DEBUG("Freeing zrtp message...");
|
||||
UVG_LOG_DEBUG("Freeing zrtp message...");
|
||||
|
||||
if (frame_)
|
||||
(void)uvgrtp::frame::dealloc_frame(frame_);
|
||||
|
@ -69,7 +69,7 @@ void uvgrtp::zrtp_msg::zrtp_message::set_zrtp_start_base(uvgrtp::zrtp_msg::zrtp_
|
|||
start.length = length/4 - 1;
|
||||
memcpy(&start.msgblock, msgblock.c_str(), 8);
|
||||
|
||||
LOG_DEBUG("Constructed ZRTP header. Length: %u", start.length);
|
||||
UVG_LOG_DEBUG("Constructed ZRTP header. Length: %u", start.length);
|
||||
}
|
||||
|
||||
void uvgrtp::zrtp_msg::zrtp_message::set_zrtp_start(uvgrtp::zrtp_msg::zrtp_msg& start,
|
||||
|
|
|
@ -39,7 +39,7 @@ uvgrtp::zrtp_msg::receiver::receiver()
|
|||
|
||||
uvgrtp::zrtp_msg::receiver::~receiver()
|
||||
{
|
||||
LOG_DEBUG("destroy receiver");
|
||||
UVG_LOG_DEBUG("destroy receiver");
|
||||
delete[] mem_;
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,7 @@ int uvgrtp::zrtp_msg::receiver::recv_msg(std::shared_ptr<uvgrtp::socket> socket,
|
|||
int nread = 0;
|
||||
rlen_ = 0;
|
||||
|
||||
LOG_DEBUG("Receiving a ZRTP message");
|
||||
UVG_LOG_DEBUG("Receiving a ZRTP message");
|
||||
|
||||
#ifdef _WIN32
|
||||
if ((ret = uvgrtp::poll::blocked_recv(socket, mem_, len_, timeout, &nread)) != RTP_OK) {
|
||||
|
@ -84,19 +84,19 @@ int uvgrtp::zrtp_msg::receiver::recv_msg(std::shared_ptr<uvgrtp::socket> socket,
|
|||
rlen_ = nread;
|
||||
|
||||
if (msg->header.version != 0 || msg->header.magic != ZRTP_HEADER_MAGIC) {
|
||||
LOG_DEBUG("Invalid header version or magic");
|
||||
UVG_LOG_DEBUG("Invalid header version or magic");
|
||||
return RTP_INVALID_VALUE;
|
||||
}
|
||||
|
||||
if (msg->magic != ZRTP_MSG_MAGIC) {
|
||||
LOG_DEBUG("invalid ZRTP magic");
|
||||
UVG_LOG_DEBUG("invalid ZRTP magic");
|
||||
return RTP_INVALID_VALUE;
|
||||
}
|
||||
|
||||
switch (msg->msgblock) {
|
||||
case ZRTP_MSG_HELLO:
|
||||
{
|
||||
LOG_DEBUG("Hello message received, verify CRC32!");
|
||||
UVG_LOG_DEBUG("Hello message received, verify CRC32!");
|
||||
|
||||
zrtp_hello *hello = (zrtp_hello *)msg;
|
||||
|
||||
|
@ -107,7 +107,7 @@ int uvgrtp::zrtp_msg::receiver::recv_msg(std::shared_ptr<uvgrtp::socket> socket,
|
|||
|
||||
case ZRTP_MSG_HELLO_ACK:
|
||||
{
|
||||
LOG_DEBUG("HelloACK message received, verify CRC32!");
|
||||
UVG_LOG_DEBUG("HelloACK message received, verify CRC32!");
|
||||
|
||||
zrtp_hello_ack *ha_msg = (zrtp_hello_ack *)msg;
|
||||
|
||||
|
@ -118,7 +118,7 @@ int uvgrtp::zrtp_msg::receiver::recv_msg(std::shared_ptr<uvgrtp::socket> socket,
|
|||
|
||||
case ZRTP_MSG_COMMIT:
|
||||
{
|
||||
LOG_DEBUG("Commit message received, verify CRC32!");
|
||||
UVG_LOG_DEBUG("Commit message received, verify CRC32!");
|
||||
|
||||
zrtp_commit *commit = (zrtp_commit *)msg;
|
||||
|
||||
|
@ -129,7 +129,7 @@ int uvgrtp::zrtp_msg::receiver::recv_msg(std::shared_ptr<uvgrtp::socket> socket,
|
|||
|
||||
case ZRTP_MSG_DH_PART1:
|
||||
{
|
||||
LOG_DEBUG("DH Part1 message received, verify CRC32!");
|
||||
UVG_LOG_DEBUG("DH Part1 message received, verify CRC32!");
|
||||
|
||||
zrtp_dh *dh = (zrtp_dh *)msg;
|
||||
|
||||
|
@ -140,7 +140,7 @@ int uvgrtp::zrtp_msg::receiver::recv_msg(std::shared_ptr<uvgrtp::socket> socket,
|
|||
|
||||
case ZRTP_MSG_DH_PART2:
|
||||
{
|
||||
LOG_DEBUG("DH Part2 message received, verify CRC32!");
|
||||
UVG_LOG_DEBUG("DH Part2 message received, verify CRC32!");
|
||||
|
||||
zrtp_dh *dh = (zrtp_dh *)msg;
|
||||
|
||||
|
@ -151,7 +151,7 @@ int uvgrtp::zrtp_msg::receiver::recv_msg(std::shared_ptr<uvgrtp::socket> socket,
|
|||
|
||||
case ZRTP_MSG_CONFIRM1:
|
||||
{
|
||||
LOG_DEBUG("Confirm1 message received, verify CRC32!");
|
||||
UVG_LOG_DEBUG("Confirm1 message received, verify CRC32!");
|
||||
|
||||
zrtp_confirm *dh = (zrtp_confirm *)msg;
|
||||
|
||||
|
@ -162,7 +162,7 @@ int uvgrtp::zrtp_msg::receiver::recv_msg(std::shared_ptr<uvgrtp::socket> socket,
|
|||
|
||||
case ZRTP_MSG_CONFIRM2:
|
||||
{
|
||||
LOG_DEBUG("Confirm2 message received, verify CRC32!");
|
||||
UVG_LOG_DEBUG("Confirm2 message received, verify CRC32!");
|
||||
|
||||
zrtp_confirm *dh = (zrtp_confirm *)msg;
|
||||
|
||||
|
@ -173,7 +173,7 @@ int uvgrtp::zrtp_msg::receiver::recv_msg(std::shared_ptr<uvgrtp::socket> socket,
|
|||
|
||||
case ZRTP_MSG_CONF2_ACK:
|
||||
{
|
||||
LOG_DEBUG("Conf2 ACK message received, verify CRC32!");
|
||||
UVG_LOG_DEBUG("Conf2 ACK message received, verify CRC32!");
|
||||
|
||||
zrtp_confack *ca = (zrtp_confack *)msg;
|
||||
|
||||
|
@ -183,27 +183,27 @@ int uvgrtp::zrtp_msg::receiver::recv_msg(std::shared_ptr<uvgrtp::socket> socket,
|
|||
return ZRTP_FT_CONF2_ACK;
|
||||
|
||||
case ZRTP_MSG_ERROR:
|
||||
LOG_DEBUG("Error message received");
|
||||
UVG_LOG_DEBUG("Error message received");
|
||||
return ZRTP_FT_ERROR;
|
||||
|
||||
case ZRTP_MSG_ERROR_ACK:
|
||||
LOG_DEBUG("Error ACK message received");
|
||||
UVG_LOG_DEBUG("Error ACK message received");
|
||||
return ZRTP_FT_ERROR_ACK;
|
||||
|
||||
case ZRTP_MSG_SAS_RELAY:
|
||||
LOG_DEBUG("SAS Relay message received");
|
||||
UVG_LOG_DEBUG("SAS Relay message received");
|
||||
return ZRTP_FT_SAS_RELAY;
|
||||
|
||||
case ZRTP_MSG_RELAY_ACK:
|
||||
LOG_DEBUG("Relay ACK message received");
|
||||
UVG_LOG_DEBUG("Relay ACK message received");
|
||||
return ZRTP_FT_RELAY_ACK;
|
||||
|
||||
case ZRTP_MSG_PING_ACK:
|
||||
LOG_DEBUG("Ping ACK message received");
|
||||
UVG_LOG_DEBUG("Ping ACK message received");
|
||||
return ZRTP_FT_PING_ACK;
|
||||
}
|
||||
|
||||
LOG_WARN("Unknown message type received: 0x%lx", (int)msg->msgblock);
|
||||
UVG_LOG_WARN("Unknown message type received: 0x%lx", (int)msg->msgblock);
|
||||
return RTP_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
|
@ -216,7 +216,7 @@ ssize_t uvgrtp::zrtp_msg::receiver::get_msg(void *ptr, size_t len)
|
|||
|
||||
if (len < rlen_) {
|
||||
cpy_len = len;
|
||||
LOG_WARN("Destination buffer too small, cannot copy full message (%zu %zu)!", len, rlen_);
|
||||
UVG_LOG_WARN("Destination buffer too small, cannot copy full message (%zu %zu)!", len, rlen_);
|
||||
}
|
||||
|
||||
memcpy(ptr, mem_, cpy_len);
|
||||
|
|
Loading…
Reference in New Issue