Skip to content

Commit

Permalink
fix: Add more information on why the frame was not sent.
Browse files Browse the repository at this point in the history
  • Loading branch information
nickolay168 authored and iphydf committed Jan 14, 2025
1 parent ab88700 commit e32ac00
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions toxav/rtp.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include "rtp.h"

#include <assert.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>

Expand Down Expand Up @@ -768,22 +767,35 @@ void rtp_stop_receiving(Tox *tox)
tox_callback_friend_lossy_packet_per_pktid(tox, nullptr, RTP_TYPE_VIDEO);
}

/**
* Log the neterror error if any.
*
* @param error the error from rtp_send_custom_lossy_packet.
* @param rdata_size The package length to be shown in the log.
*/
static void rtp_report_error_maybe(const Logger *log, Tox_Err_Friend_Custom_Packet error, uint16_t rdata_size)
{
if (error != TOX_ERR_FRIEND_CUSTOM_PACKET_OK) {
char *netstrerror = net_new_strerror(net_error());
const char *toxerror = tox_err_friend_custom_packet_to_string(error);
LOGGER_WARNING(log, "RTP send failed (len: %u)! tox error: %s net error: %s",
rdata_size, toxerror, netstrerror);
net_kill_strerror(netstrerror);

Check warning on line 783 in toxav/rtp.c

View check run for this annotation

Codecov / codecov/patch

toxav/rtp.c#L779-L783

Added lines #L779 - L783 were not covered by tests
}
}

static void rtp_send_piece(const Logger *log, Tox *tox, uint32_t friend_number, const struct RTPHeader *header,
const uint8_t *data, uint8_t *rdata, uint16_t length)
{
rtp_header_pack(rdata + 1, header);
memcpy(rdata + 1 + RTP_HEADER_SIZE, data, length);

const uint16_t rdata_size = length + RTP_HEADER_SIZE + 1;

Tox_Err_Friend_Custom_Packet error;
tox_friend_send_lossy_packet(tox, friend_number,
rdata, length + RTP_HEADER_SIZE + 1, &error);
tox_friend_send_lossy_packet(tox, friend_number, rdata, rdata_size, &error);

if (error != TOX_ERR_FRIEND_CUSTOM_PACKET_OK) {
char *netstrerror = net_new_strerror(net_error());
LOGGER_WARNING(log, "RTP send failed (len: %d)! tox error: %s, net error: %s",
length + RTP_HEADER_SIZE + 1, tox_err_friend_custom_packet_to_string(error), netstrerror);
net_kill_strerror(netstrerror);
}
rtp_report_error_maybe(log, error, rdata_size);
}

static struct RTPHeader rtp_default_header(const RTPSession *session, uint32_t length, bool is_keyframe)
Expand Down

0 comments on commit e32ac00

Please sign in to comment.