Skip to content

Commit

Permalink
Fix RX side dropping frames at the beginning.
Browse files Browse the repository at this point in the history
Address an issue where the RX is sending
ARP replies to the TX while still being completely
uninitialized, which leads to the session dropping
frames. The problem worsens as the TX outperforms
the RX in terms of initialization speed.

Resolve this by halting the FFmpeg plugin
initialization and starting the scheduled tasklets
because we don't want the CNI thread to respond to
the ARP requests sent in the tv_attach function
until the RX is ready to receive those packets.
  • Loading branch information
DawidWesierski4 committed Jun 27, 2024
1 parent 55e8423 commit 168f5ed
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 1 deletion.
1 change: 0 additions & 1 deletion ecosystem/ffmpeg_plugin/mtl_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ mtl_handle mtl_dev_get(AVFormatContext* ctx, const struct StDevArgs* args, int*
p.flags |= MTL_FLAG_RX_VIDEO_MIGRATE;
p.flags |= MTL_FLAG_RX_SEPARATE_VIDEO_LCORE;
p.flags |= MTL_FLAG_BIND_NUMA;
p.flags |= MTL_FLAG_DEV_AUTO_START_STOP;
p.log_level = MTL_LOG_LEVEL_INFO; // log level. ERROR, INFO, WARNING

if (args->dma_dev) {
Expand Down
7 changes: 7 additions & 0 deletions ecosystem/ffmpeg_plugin/mtl_st20p_rx.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,13 @@ static int mtl_st20p_read_header(AVFormatContext* ctx) {
return AVERROR(EIO);
}

ret = mtl_start(s->dev_handle);
if (ret < 0) {
err(ctx, "%s, mtl start fail %d\n", __func__, ret);
mtl_st20p_read_close(ctx);
return AVERROR(EIO);
}

info(ctx, "%s(%d), rx handle %p\n", __func__, s->idx, s->rx_handle);
return 0;
}
Expand Down
7 changes: 7 additions & 0 deletions ecosystem/ffmpeg_plugin/mtl_st20p_tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,13 @@ static int mtl_st20p_write_header(AVFormatContext* ctx) {
return AVERROR(EIO);
}

ret = mtl_start(s->dev_handle);
if (ret < 0) {
err(ctx, "%s, mtl start fail %d\n", __func__, ret);
mtl_st20p_write_close(ctx);
return AVERROR(EIO);
}

s->tx_handle = st20p_tx_create(s->dev_handle, &ops_tx);
if (!s->tx_handle) {
err(ctx, "%s, st20p_tx_create failed\n", __func__);
Expand Down
14 changes: 14 additions & 0 deletions ecosystem/ffmpeg_plugin/mtl_st22p_rx.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,13 @@ static int mtl_st22p_read_header(AVFormatContext* ctx) {
return AVERROR(EIO);
}

ret = mtl_start(s->dev_handle);
if (ret < 0) {
err(ctx, "%s, mtl start fail %d\n", __func__, ret);
mtl_st22p_read_close(ctx);
return AVERROR(EIO);
}

info(ctx, "%s(%d), rx handle %p\n", __func__, s->idx, s->rx_handle);
return 0;
}
Expand Down Expand Up @@ -287,6 +294,13 @@ static int mtl_st22_read_header(AVFormatContext* ctx) {
st->codecpar->bit_rate =
av_rescale_q(ctx->packet_size, (AVRational){8, 1}, st->time_base);

ret = mtl_start(s->dev_handle);
if (ret < 0) {
err(ctx, "%s, mtl start fail %d\n", __func__, ret);
mtl_st22p_read_close(ctx);
return AVERROR(EIO);
}

info(ctx, "%s(%d), rx handle %p, max packet_size %u\n", __func__, s->idx, s->rx_handle,
ctx->packet_size);
return 0;
Expand Down
14 changes: 14 additions & 0 deletions ecosystem/ffmpeg_plugin/mtl_st22p_tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,13 @@ static int mtl_st22p_write_header(AVFormatContext* ctx) {
return AVERROR(EIO);
}

ret = mtl_start(s->dev_handle);
if (ret < 0) {
err(ctx, "%s, mtl start fail %d\n", __func__, ret);
mtl_st22p_write_close(ctx);
return AVERROR(EIO);
}

s->frame_size = st22p_tx_frame_size(s->tx_handle);
info(ctx, "%s(%d), tx_handle %p\n", __func__, s->idx, s->tx_handle);
return 0;
Expand Down Expand Up @@ -211,6 +218,13 @@ static int mtl_st22_write_header(AVFormatContext* ctx) {
return AVERROR(EIO);
}

ret = mtl_start(s->dev_handle);
if (ret < 0) {
err(ctx, "%s, mtl start fail %d\n", __func__, ret);
mtl_st22p_write_close(ctx);
return AVERROR(EIO);
}

s->tx_handle = st22p_tx_create(s->dev_handle, &ops_tx);
if (!s->tx_handle) {
err(ctx, "%s, st22p_tx_create failed\n", __func__);
Expand Down
7 changes: 7 additions & 0 deletions ecosystem/ffmpeg_plugin/mtl_st30p_rx.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,13 @@ static int mtl_st30p_read_header(AVFormatContext* ctx) {
return AVERROR(EIO);
}

ret = mtl_start(s->dev_handle);
if (ret < 0) {
err(ctx, "%s, mtl start fail %d\n", __func__, ret);
mtl_st30p_read_close(ctx);
return AVERROR(EIO);
}

info(ctx, "%s(%d), rx handle %p\n", __func__, s->idx, s->rx_handle);
return 0;
}
Expand Down
7 changes: 7 additions & 0 deletions ecosystem/ffmpeg_plugin/mtl_st30p_tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,13 @@ static int mtl_st30p_write_header(AVFormatContext* ctx) {
return AVERROR(EIO);
}

ret = mtl_start(s->dev_handle);
if (ret < 0) {
err(ctx, "%s, mtl start fail %d\n", __func__, ret);
mtl_st30p_write_close(ctx);
return AVERROR(EIO);
}

s->tx_handle = st30p_tx_create(s->dev_handle, &ops_tx);
if (!s->tx_handle) {
err(ctx, "%s, st30p_tx_create failed\n", __func__);
Expand Down

0 comments on commit 168f5ed

Please sign in to comment.