Skip to content

Commit 40fdb1a

Browse files
committed
Fix: User pacing test
Signed-off-by: Kasiewicz, Marek <[email protected]>
1 parent be5563d commit 40fdb1a

File tree

14 files changed

+241
-74
lines changed

14 files changed

+241
-74
lines changed

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
@@ -217,6 +217,8 @@ static int rx_st20p_frame_ready(void* priv, void* frame,
217217
framebuff->src.timestamp = framebuff->dst.timestamp = meta->timestamp;
218218
framebuff->src.rtp_timestamp = framebuff->dst.rtp_timestamp = meta->rtp_timestamp;
219219
framebuff->src.status = framebuff->dst.status = meta->status;
220+
framebuff->src.receive_timestamp = framebuff->dst.receive_timestamp =
221+
meta->timestamp_first_pkt;
220222

221223
framebuff->src.pkts_total = framebuff->dst.pkts_total = meta->pkts_total;
222224
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_ancillary_session.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ static int tx_ancillary_session_init_hdr(struct mtl_main_impl* impl,
189189
rtp->base.ssrc = htonl(ssrc);
190190
s->st40_seq_id = 0;
191191
s->st40_ext_seq_id = 0;
192+
s->st40_rtp_time = -1;
192193

193194
info("%s(%d,%d), ip %u.%u.%u.%u port %u:%u\n", __func__, idx, s_port, dip[0], dip[1],
194195
dip[2], dip[3], s->st40_src_port[s_port], s->st40_dst_port[s_port]);

lib/src/st2110/st_tx_audio_session.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ static int tx_audio_session_init_hdr(struct mtl_main_impl* impl,
188188
rtp->ssrc = htonl(ssrc);
189189

190190
s->st30_seq_id = 0;
191+
s->st30_rtp_time = -1;
191192

192193
info("%s(%d,%d), ip %u.%u.%u.%u port %u:%u payload_type %u\n", __func__, idx, s_port,
193194
dip[0], dip[1], dip[2], dip[3], s->st30_src_port[s_port], s->st30_dst_port[s_port],

lib/src/st2110/st_tx_fastmetadata_session.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ static int tx_fastmetadata_session_init_hdr(struct mtl_main_impl* impl,
188188
uint32_t ssrc = ops->ssrc ? ops->ssrc : s->idx + 0x323450;
189189
rtp->base.ssrc = htonl(ssrc);
190190
s->st41_seq_id = 0;
191+
s->st41_rtp_time = -1;
191192

192193
info("%s(%d,%d), ip %u.%u.%u.%u port %u:%u\n", __func__, idx, s_port, dip[0], dip[1],
193194
dip[2], dip[3], s->st41_src_port[s_port], s->st41_dst_port[s_port]);

lib/src/st2110/st_tx_video_session.c

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

4346+
int st20_tx_get_pacing_params(st20_tx_handle handle, double* tr_offset_ns, double* trs_ns,
4347+
uint32_t* vrx_pkts) {
4348+
struct st_tx_video_session_handle_impl* s_impl = handle;
4349+
4350+
if (!handle) {
4351+
err("%s, invalid handle %p\n", __func__, handle);
4352+
return -EINVAL;
4353+
}
4354+
4355+
if (s_impl->type != MT_HANDLE_TX_VIDEO) {
4356+
err("%s, invalid type %d\n", __func__, s_impl->type);
4357+
return -EINVAL;
4358+
}
4359+
4360+
struct st_tx_video_session_impl* s = s_impl->impl;
4361+
if (tr_offset_ns) *tr_offset_ns = s->pacing.tr_offset;
4362+
if (trs_ns) *trs_ns = s->pacing.trs;
4363+
if (vrx_pkts) *vrx_pkts = s->pacing.vrx;
4364+
return 0;
4365+
}
4366+
43464367
int st20_tx_get_session_stats(st20_tx_handle handle, struct st20_tx_user_stats* stats) {
43474368
struct st_tx_video_session_handle_impl* s_impl = handle;
43484369

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/noctx/noctx.hpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,15 @@ class FrameTestStrategy {
120120
virtual void txTestFrameModifier(void* frame, size_t frame_size){};
121121
virtual void rxTestFrameModifier(void* frame, size_t frame_size){};
122122

123+
FrameTestStrategy(Handlers* parent = nullptr, bool enable_tx_modifier = false,
124+
bool enable_rx_modifier = false)
125+
: parent(parent),
126+
idx_tx(0),
127+
idx_rx(0),
128+
enable_tx_modifier(enable_tx_modifier),
129+
enable_rx_modifier(enable_rx_modifier) {
130+
}
131+
123132
virtual ~FrameTestStrategy() {
124133
parent = nullptr;
125134
}

0 commit comments

Comments
 (0)