Skip to content

Commit

Permalink
add retries to the initial read packet
Browse files Browse the repository at this point in the history
Add retries to the initial read packet in FFmpeg
to prevent immediate failures. This will aid
in the synchronization of unicast FFmpeg streams
and allow for some leniency in the RX session
establishment.
  • Loading branch information
DawidWesierski4 committed Jul 2, 2024
1 parent 168f5ed commit 68d2428
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
12 changes: 11 additions & 1 deletion ecosystem/ffmpeg_plugin/mtl_st20p_rx.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,17 @@ static int mtl_st20p_read_packet(AVFormatContext* ctx, AVPacket* pkt) {
struct st_frame* frame;

dbg("%s(%d), start\n", __func__, s->idx);
frame = st20p_rx_get_frame(s->rx_handle);

if (0 == s->frame_counter) {
for (int i = 1; i <= 10; i++) {
frame = st20p_rx_get_frame(s->rx_handle);
if (frame)
break;
info(ctx, "%s(%d) session initialization retry %d\n", __func__, s->idx, i);
}
} else
frame = st20p_rx_get_frame(s->rx_handle);

if (!frame) {
info(ctx, "%s(%d), st20p_rx_get_frame timeout\n", __func__, s->idx);
return AVERROR(EIO);
Expand Down
12 changes: 11 additions & 1 deletion ecosystem/ffmpeg_plugin/mtl_st22p_rx.c
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,17 @@ static int mtl_st22p_read_packet(AVFormatContext* ctx, AVPacket* pkt) {
struct st_frame* frame;

dbg("%s(%d), start\n", __func__, s->idx);
frame = st22p_rx_get_frame(s->rx_handle);

if (0 == s->frame_counter) {
for (int i = 1; i <= 10; i++) {
frame = st22p_rx_get_frame(s->rx_handle);
if (frame)
break;
info(ctx, "%s(%d) session initialization retry %d\n", __func__, s->idx, i);
}
} else
frame = st22p_rx_get_frame(s->rx_handle);

if (!frame) {
info(ctx, "%s(%d), st22p_rx_get_frame timeout\n", __func__, s->idx);
return AVERROR(EIO);
Expand Down
12 changes: 11 additions & 1 deletion ecosystem/ffmpeg_plugin/mtl_st30p_rx.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,17 @@ static int mtl_st30p_read_packet(AVFormatContext* ctx, AVPacket* pkt) {
struct st30_frame* frame;

dbg("%s(%d), start\n", __func__, s->idx);
frame = st30p_rx_get_frame(s->rx_handle);

if (0 == s->frame_counter) {
for (int i = 1; i <= 10; i++) {
frame = st30p_rx_get_frame(s->rx_handle);
if (frame)
break;
info(ctx, "%s(%d) session initialization retry %d\n", __func__, s->idx, i);
}
} else
frame = st30p_rx_get_frame(s->rx_handle);

if (!frame) {
info(ctx, "%s(%d), st30p_rx_get_frame timeout\n", __func__, s->idx);
return AVERROR(EIO);
Expand Down

0 comments on commit 68d2428

Please sign in to comment.