Skip to content

Commit

Permalink
st20p/rx: add pkts meta info (#568)
Browse files Browse the repository at this point in the history
Signed-off-by: Frank Du <[email protected]>
  • Loading branch information
frankdjx authored Nov 6, 2023
1 parent 9da4df0 commit c5d992c
Show file tree
Hide file tree
Showing 6 changed files with 106 additions and 4 deletions.
13 changes: 13 additions & 0 deletions app/src/rx_st20p_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,19 @@ static int app_rx_st20p_frame_available(void* priv) {
static void app_rx_st20p_consume_frame(struct st_app_rx_st20p_session* s,
struct st_frame* frame) {
struct st_display* d = s->display;
int idx = s->idx;

if (s->num_port > 1) {
dbg("%s(%d): pkts_total %u, pkts per port P %u R %u\n", __func__, idx,
frame->pkts_total, frame->pkts_recv[MTL_SESSION_PORT_P],
frame->pkts_recv[MTL_SESSION_PORT_R]);
if (frame->pkts_recv[MTL_SESSION_PORT_P] < (frame->pkts_total / 2))
warn("%s(%d): P port only receive %u pkts while total pkts is %u\n", __func__, idx,
frame->pkts_recv[MTL_SESSION_PORT_P], frame->pkts_total);
if (frame->pkts_recv[MTL_SESSION_PORT_R] < (frame->pkts_total / 2))
warn("%s(%d): R port only receive %u pkts while total pkts is %u\n", __func__, idx,
frame->pkts_recv[MTL_SESSION_PORT_R], frame->pkts_total);
}

if (d && d->front_frame) {
if (st_pthread_mutex_trylock(&d->display_frame_mutex) == 0) {
Expand Down
7 changes: 7 additions & 0 deletions include/st_pipeline_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ struct st_frame {
uint32_t flags;
/** frame status, complete or not */
enum st_frame_status status;

/**
* The user meta data buffer for current frame of st20, the size must smaller than
* MTL_PKT_MAX_RTP_BYTES. This data will be transported to RX with video data and passed
Expand All @@ -279,6 +280,12 @@ struct st_frame {
const void* user_meta;
/** size for meta data buffer */
size_t user_meta_size;
/** the total packets received, not include the redundant packets */
uint32_t pkts_total;
/** the valid packets received on each session port. For each session port, the validity
* of received packets can be assessed by comparing 'pkts_recv[s_port]' with
* 'pkts_total,' which serves as an indicator of signal quality. */
uint32_t pkts_recv[MTL_SESSION_PORT_MAX];

/** priv pointer for lib, do not touch this */
void* priv;
Expand Down
7 changes: 7 additions & 0 deletions lib/src/st2110/pipeline/st20_pipeline_rx.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,13 @@ static int rx_st20p_frame_ready(void* priv, void* frame,
framebuff->src.timestamp = framebuff->dst.timestamp = meta->timestamp;
framebuff->src.status = framebuff->dst.status = meta->status;

framebuff->src.pkts_total = framebuff->dst.pkts_total = meta->pkts_total;
for (enum mtl_session_port s_port = MTL_SESSION_PORT_P; s_port < MTL_SESSION_PORT_MAX;
s_port++) {
framebuff->src.pkts_recv[s_port] = framebuff->dst.pkts_recv[s_port] =
meta->pkts_recv[s_port];
}

/* check user meta */
framebuff->user_meta_data_size = 0;
if (meta->user_meta) {
Expand Down
8 changes: 8 additions & 0 deletions lib/src/st2110/pipeline/st22_pipeline_rx.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,14 @@ static int rx_st22p_frame_ready(void* priv, void* frame,
framebuff->dst.tfmt = meta->tfmt;
/* set dst timestamp to same as src? */
framebuff->dst.timestamp = meta->timestamp;

framebuff->src.pkts_total = framebuff->dst.pkts_total = meta->pkts_total;
for (enum mtl_session_port s_port = MTL_SESSION_PORT_P; s_port < MTL_SESSION_PORT_MAX;
s_port++) {
framebuff->src.pkts_recv[s_port] = framebuff->dst.pkts_recv[s_port] =
meta->pkts_recv[s_port];
}

framebuff->stat = ST22P_RX_FRAME_READY;
/* point to next */
ctx->framebuff_producer_idx = rx_st22p_next_idx(ctx, framebuff->idx);
Expand Down
12 changes: 8 additions & 4 deletions lib/src/st2110/st_rx_video_session.c
Original file line number Diff line number Diff line change
Expand Up @@ -1130,8 +1130,10 @@ static void rv_frame_notify(struct st_rx_video_session_impl* s,
meta->uframe_total_size = s->st20_uframe_size;
meta->frame_recv_size = rv_slot_get_frame_size(slot);
meta->pkts_total = slot->pkts_received;
meta->pkts_recv[MTL_SESSION_PORT_P] = slot->pkts_recv_per_port[MTL_SESSION_PORT_P];
meta->pkts_recv[MTL_SESSION_PORT_R] = slot->pkts_recv_per_port[MTL_SESSION_PORT_R];
for (enum mtl_session_port s_port = MTL_SESSION_PORT_P; s_port < MTL_SESSION_PORT_MAX;
s_port++) {
meta->pkts_recv[s_port] = slot->pkts_recv_per_port[s_port];
}

if (slot->frame->user_meta_data_size) {
meta->user_meta_size = slot->frame->user_meta_data_size;
Expand Down Expand Up @@ -1199,8 +1201,10 @@ static void rv_st22_frame_notify(struct st_rx_video_session_impl* s,
meta->frame_total_size = rv_slot_get_frame_size(slot);
meta->status = status;
meta->pkts_total = slot->pkts_received;
meta->pkts_recv[MTL_SESSION_PORT_P] = slot->pkts_recv_per_port[MTL_SESSION_PORT_P];
meta->pkts_recv[MTL_SESSION_PORT_R] = slot->pkts_recv_per_port[MTL_SESSION_PORT_R];
for (enum mtl_session_port s_port = MTL_SESSION_PORT_P; s_port < MTL_SESSION_PORT_MAX;
s_port++) {
meta->pkts_recv[s_port] = slot->pkts_recv_per_port[s_port];
}

/* notify frame */
int ret = -EIO;
Expand Down
63 changes: 63 additions & 0 deletions tests/script/native_af_xdp_json/st20p_redundant.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{
"interfaces": [
{
"name": "native_af_xdp:enp0s3np0",
},
{
"name": "native_af_xdp:enp0s4np0",
}
],
"tx_sessions": [
{
"dip": [
"local:1",
"local:0"
],
"interface": [
0,
1,
],
"st20p": [
{
"replicas": 1,
"start_port": 20000,
"payload_type": 112,
"width": 1920,
"height": 1080,
"fps": "p59",
"device": "AUTO",
"input_format": "YUV422PLANAR10LE",
"transport_format": "YUV_422_10bit",
"st20p_url": "./test.yuv"
}
]
}
],
"rx_sessions": [
{
"ip": [
"local:0",
"local:1"
],
"interface": [
1,
0,
],
"st20p": [
{
"replicas": 1,
"start_port": 20000,
"payload_type": 112,
"width": 1920,
"height": 1080,
"fps": "p59",
"device": "AUTO",
"output_format": "YUV422PLANAR10LE",
"transport_format": "YUV_422_10bit",
"display": false,
"measure_latency": true
}
]
}
]
}

0 comments on commit c5d992c

Please sign in to comment.