Skip to content

Commit dc7a477

Browse files
committed
Fix: User pacing test
- Split noctx code into more files - Simplify testcases by adding HandlerBundle - Use pacing info to better check receive time Signed-off-by: Kasiewicz, Marek <[email protected]>
1 parent 6e3e665 commit dc7a477

38 files changed

+1651
-882
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ tests/validation/logs
7070
html/
7171
test.*
7272
build/
73-
core*
7473
out*
7574
assets/
7675
*.pkg

include/st20_api.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,8 @@ struct st20_rx_tp_meta {
480480
enum st_rx_tp_compliant compliant;
481481
/** the failed cause if compliant is not ST_RX_TP_COMPLIANT_NARROW */
482482
char failed_cause[64];
483+
/** TAI timestamp measured right after first packet of the frame was received */
484+
uint64_t receive_timestamp;
483485

484486
/* packets count in current report meta */
485487
uint32_t pkts_cnt;
@@ -1876,6 +1878,24 @@ int st20_tx_put_mbuf(st20_tx_handle handle, void* mbuf, uint16_t len);
18761878
*/
18771879
int st20_tx_get_sch_idx(st20_tx_handle handle);
18781880

1881+
/**
1882+
* Retrieve pacing parameters for a tx st2110-20 session.
1883+
*
1884+
* @param handle
1885+
* The handle to the tx st2110-20(video) session.
1886+
* @param tr_offset_ns
1887+
* Optional output for the tr offset value in nanoseconds.
1888+
* @param trs_ns
1889+
* Optional output for the packet spacing (TRS) value in nanoseconds.
1890+
* @param vrx_pkts
1891+
* Optional output for the VRX packet count.
1892+
*
1893+
* @return
1894+
* 0 on success, negative value otherwise.
1895+
*/
1896+
int st20_tx_get_pacing_params(st20_tx_handle handle, double* tr_offset_ns, double* trs_ns,
1897+
uint32_t* vrx_pkts);
1898+
18791899
/**
18801900
* Retrieve the general statistics(I/O) for one tx st2110-20(video) session.
18811901
*

include/st_pipeline_api.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,8 @@ struct st_frame {
319319
/** timing parser meta for st20p_rx_get_frame, only active if
320320
* ST20P_RX_FLAG_TIMING_PARSER_META */
321321
struct st20_rx_tp_meta* tp[MTL_SESSION_PORT_MAX];
322+
/** TAI timestamp measured right after first packet of the frame was received */
323+
uint64_t receive_timestamp;
322324
};
323325

324326
/** Device type of st plugin */
@@ -1761,6 +1763,23 @@ size_t st20p_tx_frame_size(st20p_tx_handle handle);
17611763
*/
17621764
int st20p_tx_get_sch_idx(st20p_tx_handle handle);
17631765

1766+
/**
1767+
* Retrieve pacing parameters for a tx st2110-20(pipeline) session.
1768+
*
1769+
* @param handle
1770+
* The handle to the tx st2110-20(video) session.
1771+
* @param tr_offset_ns
1772+
* Optional output for the tr offset value in nanoseconds.
1773+
* @param trs_ns
1774+
* Optional output for the packet spacing (TRS) value in nanoseconds.
1775+
* @param vrx_pkts
1776+
* Optional output for the VRX packet count.
1777+
*
1778+
* @return
1779+
* 0 on success, negative value otherwise.
1780+
*/
1781+
int st20p_tx_get_pacing_params(st20p_tx_handle handle, double* tr_offset_ns,
1782+
double* trs_ns, uint32_t* vrx_pkts);
17641783
/**
17651784
* Retrieve the general statistics(I/O) for one tx st2110-20(pipeline) session.
17661785
*

lib/src/st2110/pipeline/st20_pipeline_rx.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,8 @@ static int rx_st20p_frame_ready(void* priv, void* frame,
218218
framebuff->src.timestamp = framebuff->dst.timestamp = meta->timestamp;
219219
framebuff->src.rtp_timestamp = framebuff->dst.rtp_timestamp = meta->rtp_timestamp;
220220
framebuff->src.status = framebuff->dst.status = meta->status;
221+
framebuff->src.receive_timestamp = framebuff->dst.receive_timestamp =
222+
meta->timestamp_first_pkt;
221223

222224
framebuff->src.pkts_total = framebuff->dst.pkts_total = meta->pkts_total;
223225
for (enum mtl_session_port s_port = 0; s_port < MTL_SESSION_PORT_MAX; s_port++) {

lib/src/st2110/pipeline/st20_pipeline_tx.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -984,6 +984,26 @@ int st20p_tx_get_sch_idx(st20p_tx_handle handle) {
984984
return st20_tx_get_sch_idx(ctx->transport);
985985
}
986986

987+
int st20p_tx_get_pacing_params(st20p_tx_handle handle, double* tr_offset_ns,
988+
double* trs_ns, uint32_t* vrx_pkts) {
989+
struct st20p_tx_ctx* ctx = handle;
990+
int cidx;
991+
992+
if (!handle) {
993+
err("%s, invalid handle %p\n", __func__, handle);
994+
return -EINVAL;
995+
}
996+
ctx = handle;
997+
cidx = ctx->idx;
998+
999+
if (ctx->type != MT_ST20_HANDLE_PIPELINE_TX) {
1000+
err("%s(%d), invalid type %d\n", __func__, cidx, ctx->type);
1001+
return -EINVAL;
1002+
}
1003+
1004+
return st20_tx_get_pacing_params(ctx->transport, tr_offset_ns, trs_ns, vrx_pkts);
1005+
}
1006+
9871007
int st20p_tx_get_session_stats(st20p_tx_handle handle, struct st20_tx_user_stats* stats) {
9881008
struct st20p_tx_ctx* ctx = handle;
9891009
int cidx;

lib/src/st2110/st_tx_video_session.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4314,6 +4314,27 @@ int st20_tx_get_sch_idx(st20_tx_handle handle) {
43144314
return s_impl->sch->idx;
43154315
}
43164316

4317+
int st20_tx_get_pacing_params(st20_tx_handle handle, double* tr_offset_ns, double* trs_ns,
4318+
uint32_t* vrx_pkts) {
4319+
struct st_tx_video_session_handle_impl* s_impl = handle;
4320+
4321+
if (!handle) {
4322+
err("%s, invalid handle %p\n", __func__, handle);
4323+
return -EINVAL;
4324+
}
4325+
4326+
if (s_impl->type != MT_HANDLE_TX_VIDEO) {
4327+
err("%s, invalid type %d\n", __func__, s_impl->type);
4328+
return -EINVAL;
4329+
}
4330+
4331+
struct st_tx_video_session_impl* s = s_impl->impl;
4332+
if (tr_offset_ns) *tr_offset_ns = s->pacing.tr_offset;
4333+
if (trs_ns) *trs_ns = s->pacing.trs;
4334+
if (vrx_pkts) *vrx_pkts = s->pacing.vrx;
4335+
return 0;
4336+
}
4337+
43174338
int st20_tx_get_session_stats(st20_tx_handle handle, struct st20_tx_user_stats* stats) {
43184339
struct st_tx_video_session_handle_impl* s_impl = handle;
43194340

lib/src/st2110/st_video_transmitter.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* This adds a superficial difference between the RTP timestamp and the transmission
1818
* time, which makes it look as if the packets have a slight latency immediately after
1919
* entering the wire. This prevents negative latency values. */
20-
#define LATENCY_COMPENSATION 1
20+
#define LATENCY_COMPENSATION 2
2121

2222
static int video_trs_tasklet_start(void* priv) {
2323
struct st_video_transmitter_impl* trs = priv;

tests/integration_tests/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ sources = files('tests.cpp', 'st_test.cpp', 'st20_test.cpp', 'st22_test.cpp',
88

99
subdir('noctx')
1010
sources += noctx_sources
11+
test_inc = include_directories('.', 'noctx')
1112

1213
ufd_sources = files('ufd_test.cpp', 'ufd_loop_test.cpp', 'test_util.cpp')
1314

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/* SPDX-License-Identifier: BSD-3-Clause
2+
* Copyright(c) 2025 Intel Corporation
3+
*/
4+
5+
#pragma once
6+
7+
#ifndef SESSION_SKIP_PORT
8+
#define SESSION_SKIP_PORT -1
9+
#endif
10+
11+
#ifndef VIDEO_CLOCK_HZ
12+
#define VIDEO_CLOCK_HZ 90000
13+
#endif
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/* SPDX-License-Identifier: BSD-3-Clause
2+
* Copyright(c) 2025 Intel Corporation
3+
*/
4+
5+
#include "handler_base.hpp"
6+
7+
#include <cstdio>
8+
#include <stdexcept>
9+
10+
Handlers::Handlers(st_tests_context* ctx, FrameTestStrategy* frameTestStrategy)
11+
: ctx(ctx), frameTestStrategy(frameTestStrategy) {
12+
}
13+
14+
Handlers::~Handlers() {
15+
session.stop();
16+
}
17+
18+
void Handlers::startSession(
19+
std::vector<std::function<void(std::atomic<bool>&)>> threadFunctions, bool isRx) {
20+
for (auto& func : threadFunctions) {
21+
session.addThread(func, isRx);
22+
}
23+
}
24+
25+
void Handlers::stopSession() {
26+
session.stop();
27+
}
28+
29+
void Handlers::setSessionPortsTx(struct st_tx_port* port, int txPortIdx,
30+
int txPortRedundantIdx) {
31+
if (!ctx) {
32+
throw std::runtime_error("setSessionPortsTx no ctx (ctx is null)");
33+
} else if (txPortIdx >= (int)ctx->para.num_ports) {
34+
throw std::runtime_error("setSessionPortsTx txPortIdx out of range");
35+
} else if (txPortRedundantIdx >= (int)ctx->para.num_ports) {
36+
throw std::runtime_error("setSessionPortsTx txPortRedundantIdx out of range");
37+
}
38+
39+
if (txPortIdx >= 0) {
40+
snprintf(port->port[MTL_SESSION_PORT_P], MTL_PORT_MAX_LEN, "%s",
41+
ctx->para.port[txPortIdx]);
42+
int num_ports = 1;
43+
44+
if (txPortRedundantIdx >= 0) {
45+
snprintf(port->port[MTL_SESSION_PORT_R], MTL_PORT_MAX_LEN, "%s",
46+
ctx->para.port[txPortRedundantIdx]);
47+
num_ports = 2;
48+
}
49+
50+
port->num_port = num_ports;
51+
}
52+
}
53+
54+
void Handlers::setSessionPortsRx(struct st_rx_port* port, int rxPortIdx,
55+
int rxPortRedundantIdx) {
56+
if (!ctx) {
57+
throw std::runtime_error("setSessionPortsRx no ctx (ctx is null)");
58+
} else if (rxPortIdx >= (int)ctx->para.num_ports) {
59+
throw std::runtime_error("setSessionPortsRx rxPortIdx out of range");
60+
} else if (rxPortRedundantIdx >= (int)ctx->para.num_ports) {
61+
throw std::runtime_error("setSessionPortsRx rxPortRedundantIdx out of range");
62+
}
63+
64+
if (rxPortIdx >= 0) {
65+
snprintf(port->port[MTL_SESSION_PORT_P], MTL_PORT_MAX_LEN, "%s",
66+
ctx->para.port[rxPortIdx]);
67+
int num_ports = 1;
68+
69+
if (rxPortRedundantIdx >= 0) {
70+
snprintf(port->port[MTL_SESSION_PORT_R], MTL_PORT_MAX_LEN, "%s",
71+
ctx->para.port[rxPortRedundantIdx]);
72+
num_ports = 2;
73+
}
74+
port->num_port = num_ports;
75+
}
76+
}

0 commit comments

Comments
 (0)