Skip to content

Commit

Permalink
Fix counter output with RTP & file
Browse files Browse the repository at this point in the history
Fix incorrect output calculations with file output and RTP enabled.
  • Loading branch information
lars18th authored Mar 13, 2024
1 parent 4e1b1a3 commit ef812b8
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions output_write.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ ssize_t ts_frame_write(OUTPUT *o, uint8_t *data) {

// write RTP packets
ssize_t ts_frame_write_rtp(OUTPUT *o, uint8_t *data) {
ssize_t written;
ssize_t written, written2;
const size_t write_len = FRAME_PACKET_SIZE + RTP_HEADER_SIZE;
uint8_t rtp_buffer[write_len];

Expand Down Expand Up @@ -157,15 +157,18 @@ ssize_t ts_frame_write_rtp(OUTPUT *o, uint8_t *data) {
memcpy(&rtp_buffer[12], data, FRAME_PACKET_SIZE);

written = fdwrite(o->out_sock, (char *)rtp_buffer, write_len);
if (o->ofd)
written2 = write(o->ofd, data, FRAME_PACKET_SIZE);
else written2 = 0;

if (written2 > written)
written = written2 + RTP_HEADER_SIZE;
if (written >= RTP_HEADER_SIZE) {
written -= RTP_HEADER_SIZE;
o->traffic += written;
o->traffic_period += written;
}

if (o->ofd)
write(o->ofd, data, FRAME_PACKET_SIZE);

o->rtp_sequence_number++; // increment RTP sequence number

return written;
Expand Down

0 comments on commit ef812b8

Please sign in to comment.