Skip to content

Commit 45ae634

Browse files
Add: Ability to drop old frames
Change the way pipeline TX handles the order of framebuffers. Track per-frame sequence numbers so transport can dequeue the newest converted frame instead of always taking the next one, needed as otherwise we cannot drop frames, as they will not be in order. (This also makes it easier for multi threaded applications to use the api should improve performance with multiple threads from the api only). Add a new flag to the TX pipeline to enable droping frames when we jump over epoch. Mostly will aid with user control pacing. Implemented in a way that only drops one frame in a scenario where late is detected. This creates limitation for extreamly high drops The stream will still not adjust immidiately instead doing send frame | drop frame | send frame | drop frame ... until we catch up. (Done mostly as big jumps over more than 2 frames could be undesirable and if you have that big of a drop ... well this is the least of your troubles). Due to lack of consumer and producer print stats of the queue via reporting the framebuffers statuses (removed the ACCURATE_FRAMEBUFF) as it became redundant. Reverts: 772621d All above done in pipeline as the purpose of the api pipeline is to smoothe the library tight timing requirements from the user applications. Fix the st20p wrong user timestamp reporting in frames snapped to the next frame. if times given by the application looks as follows ----|--frame-1--|--frame-2--|--frame-3--|--frame-4--|-... epoch-1--|--epoch-2--|--epoch-3--|--epoch-4--|... This causes frames to snap to the next epoch, resulting in incorrect timestamp reporting where every frame appears to have a "wrong user timestamp" due to the forward snapping behavior. Fixes: 88c3566 Fix the usdt for st40p tx (only to add the spurn event). Fixes: 921fa0d
1 parent f69e8ac commit 45ae634

18 files changed

+490
-118
lines changed

include/experimental/st40_pipeline_api.h

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@ enum st40p_tx_flag {
6464
* lib will wait until timestamp is reached for each frame.
6565
*/
6666
ST40P_TX_FLAG_USER_PACING = (MTL_BIT32(3)),
67+
/**
68+
* Drop frames when the mtl reports late frames (transport can't keep up).
69+
* When late frame is detected, next frame from pipeline is ommited.
70+
* Untill we resume normal frame sending.
71+
*/
72+
ST40P_TX_FLAG_DROP_WHEN_LATE = (MTL_BIT32(7)),
6773
/**
6874
* Flag bit in flags of struct st40_tx_ops.
6975
* If enabled, lib will assign the rtp timestamp to the value in
@@ -88,10 +94,6 @@ enum st40p_tx_flag {
8894
/** Enable the st40p_tx_get_frame block behavior to wait until a frame becomes
8995
available or timeout(default: 1s, use st40p_tx_set_block_timeout to customize)*/
9096
ST40P_TX_FLAG_BLOCK_GET = (MTL_BIT32(15)),
91-
/**
92-
** Enable verbose reporting of framebuffer statuses in statistics output
93-
*/
94-
ST40P_TX_FLAG_ACCURATE_FRAMEBUFF_STATISTICS = (MTL_BIT32(25)),
9597
};
9698

9799
/**
@@ -128,6 +130,13 @@ struct st40p_tx_ops {
128130
*/
129131
int (*notify_frame_done)(void* priv, struct st40_frame_info* frame_info);
130132

133+
/**
134+
* Optional. Callback when frame done in the lib.
135+
* And only non-block method can be used within this callback as it run from lcore
136+
* tasklet routine.
137+
*/
138+
int (*notify_frame_late)(void* priv, uint64_t epoch_skipped);
139+
131140
/**
132141
* Optional. tx destination mac address.
133142
* Valid if ST40P_TX_FLAG_USER_P(R)_MAC is enabled

include/st20_api.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1169,6 +1169,12 @@ struct st20_tx_ops {
11691169
int (*notify_frame_done)(void* priv, uint16_t frame_idx,
11701170
struct st20_tx_frame_meta* meta);
11711171

1172+
/**
1173+
* Optional. Callback when frame done in the lib.
1174+
* And only non-block method can be used within this callback as it run from lcore
1175+
* tasklet routine.
1176+
*/
1177+
int (*notify_frame_late)(void* priv, uint64_t epoch_skipped);
11721178
/**
11731179
* Optional. The event callback when there is some event(vsync or others) happened for
11741180
* this session. Only non-block method can be used in this callback as it run from lcore
@@ -1318,6 +1324,12 @@ struct st22_tx_ops {
13181324
*/
13191325
int (*notify_frame_done)(void* priv, uint16_t frame_idx,
13201326
struct st22_tx_frame_meta* meta);
1327+
/**
1328+
* Optional. Callback when frame done in the lib.
1329+
* And only non-block method can be used within this callback as it run from lcore
1330+
* tasklet routine.
1331+
*/
1332+
int (*notify_frame_late)(void* priv, uint64_t epoch_skipped);
13211333

13221334
/**
13231335
* Optional. The event callback when there is some event(vsync or others) happened for

include/st30_api.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,12 @@ struct st30_tx_ops {
382382
*/
383383
int (*notify_frame_done)(void* priv, uint16_t frame_idx,
384384
struct st30_tx_frame_meta* meta);
385+
/**
386+
* Optional. Callback when frame done in the lib.
387+
* And only non-block method can be used within this callback as it run from lcore
388+
* tasklet routine.
389+
*/
390+
int (*notify_frame_late)(void* priv, uint64_t epoch_skipped);
385391

386392
/*
387393
* Optional. The size of fifo ring which used between the packet builder and pacing.

include/st30_pipeline_api.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,13 @@ enum st30p_tx_flag {
5252
/** Enable the st30p_tx_get_frame block behavior to wait until a frame becomes
5353
available or timeout(default: 1s, use st30p_tx_set_block_timeout to customize)*/
5454
ST30P_TX_FLAG_BLOCK_GET = (MTL_BIT32(15)),
55+
56+
/**
57+
* Drop frames when the mtl reports late frames (transport can't keep up).
58+
* When late frame is detected, next frame from pipeline is ommited.
59+
* Untill we resume normal frame sending.
60+
*/
61+
ST30P_TX_FLAG_DROP_WHEN_LATE = (MTL_BIT32(16)),
5562
};
5663

5764
/** The structure info for st30 frame meta. */
@@ -131,6 +138,12 @@ struct st30p_tx_ops {
131138
* tasklet routine.
132139
*/
133140
int (*notify_frame_done)(void* priv, struct st30_frame* frame);
141+
/**
142+
* Optional. Callback when frame done in the lib.
143+
* And only non-block method can be used within this callback as it run from lcore
144+
* tasklet routine.
145+
*/
146+
int (*notify_frame_late)(void* priv, uint64_t epoch_skipped);
134147

135148
/**
136149
* Optional. The rtp timestamp delta(us) to the start time of frame.

include/st40_api.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,8 @@ struct st40_tx_ops {
337337
int (*notify_frame_done)(void* priv, uint16_t frame_idx,
338338
struct st40_tx_frame_meta* meta);
339339

340+
int (*notify_frame_late)(void* priv, uint64_t epoch_skipped);
341+
340342
/** Optional. UDP source port number, leave as 0 to use same port as dst */
341343
uint16_t udp_src_port[MTL_SESSION_PORT_MAX];
342344
/**

include/st41_api.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,13 @@ typedef struct st_rx_fastmetadata_session_handle_impl* st41_rx_handle;
4343
* lib will wait until timestamp is reached for each frame.
4444
*/
4545
#define ST41_TX_FLAG_USER_PACING (MTL_BIT32(3))
46+
/**
47+
* Flag bit in flags of struct st41_tx_ops.
48+
* Drop all packets that are old to recover from overflow situations and user
49+
* mismanagement. This flag works in conjunction with ST41_TX_FLAG_USER_PACING to handle
50+
* overflow scenarios.
51+
*/
52+
#define ST41_TX_FLAG_DROP_OLD (MTL_BIT32(7))
4653
/**
4754
* Flag bit in flags of struct st41_tx_ops.
4855
* If enabled, lib will assign the rtp timestamp to the value in

include/st_pipeline_api.h

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,12 @@ enum st22p_tx_flag {
384384
* lib will wait until timestamp is reached for each frame.
385385
*/
386386
ST22P_TX_FLAG_USER_PACING = (MTL_BIT32(3)),
387+
/**
388+
* Drop frames when the mtl reports late frames (transport can't keep up).
389+
* When late frame is detected, next frame from pipeline is ommited.
390+
* Untill we resume normal frame sending.
391+
*/
392+
ST22P_TX_FLAG_DROP_WHEN_LATE = (MTL_BIT32(12)),
387393
/**
388394
* If enabled, lib will assign the rtp timestamp to the value in
389395
* tx_frame_meta(ST10_TIMESTAMP_FMT_MEDIA_CLK is used)
@@ -413,6 +419,8 @@ enum st22p_tx_flag {
413419
/** Enable the st22p_tx_get_frame block behavior to wait until a frame becomes
414420
available or timeout(default: 1s, use st22p_tx_set_block_timeout to customize) */
415421
ST22P_TX_FLAG_BLOCK_GET = (MTL_BIT32(15)),
422+
/** If enabled, drop old frames when user pacing is used */
423+
ST22P_TX_FLAG_USER_TIMESTAMP_DROP_OLD = (MTL_BIT32(16)),
416424
};
417425

418426
/** Bit define for flags of struct st20p_tx_ops. */
@@ -437,6 +445,12 @@ enum st20p_tx_flag {
437445
* aligned with virtual receiver read schedule.
438446
*/
439447
ST20P_TX_FLAG_USER_PACING = (MTL_BIT32(3)),
448+
/**
449+
* Drop frames when the mtl reports late frames (transport can't keep up).
450+
* When late frame is detected, next frame from pipeline is ommited.
451+
* Untill we resume normal frame sending.
452+
*/
453+
ST20P_TX_FLAG_DROP_WHEN_LATE = (MTL_BIT32(12)),
440454
/**
441455
* If enabled, lib will assign the rtp timestamp to the value of timestamp in
442456
* st_frame.timestamp (if needed the value will be converted to
@@ -881,6 +895,13 @@ struct st20p_tx_ops {
881895
*/
882896
int (*notify_frame_done)(void* priv, struct st_frame* frame);
883897

898+
/**
899+
* Optional. Callback when frame done in the lib.
900+
* And only non-block method can be used within this callback as it run from lcore
901+
* tasklet routine.
902+
*/
903+
int (*notify_frame_late)(void* priv, uint64_t epoch_skipped);
904+
884905
/** Optional. Linesize for transport frame, only for non-convert mode */
885906
size_t transport_linesize;
886907

@@ -1052,6 +1073,13 @@ struct st22p_tx_ops {
10521073
*/
10531074
int (*notify_frame_done)(void* priv, struct st_frame* frame);
10541075

1076+
/**
1077+
* Optional. Callback when frame done in the lib.
1078+
* And only non-block method can be used within this callback as it run from lcore
1079+
* tasklet routine.
1080+
*/
1081+
int (*notify_frame_late)(void* priv, uint64_t epoch_skipped);
1082+
10551083
/** Optional for ST22P_TX_FLAG_ENABLE_RTCP. RTCP info */
10561084
struct st_tx_rtcp_ops rtcp;
10571085
/**

lib/src/mt_usdt.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@
104104
MT_DTRACE_PROBE4(st20p, tx_frame_put, idx, f_idx, va, stat)
105105
#define MT_USDT_ST20P_TX_FRAME_DONE(idx, f_idx, tmstamp) \
106106
MT_DTRACE_PROBE3(st20p, tx_frame_done, idx, f_idx, tmstamp)
107+
#define MT_USDT_ST20P_TX_FRAME_SPURN(idx, f_idx, tmstamp) \
108+
MT_DTRACE_PROBE3(st20p, tx_frame_done, idx, f_idx, tmstamp)
107109
#define MT_USDT_ST20P_TX_FRAME_NEXT(idx, f_idx) \
108110
MT_DTRACE_PROBE2(st20p, tx_frame_next, idx, f_idx)
109111
#define MT_USDT_ST20P_TX_FRAME_DUMP(idx, file, va, sz) \
@@ -126,6 +128,8 @@
126128
MT_DTRACE_PROBE3(st30p, tx_frame_put, idx, f_idx, va)
127129
#define MT_USDT_ST30P_TX_FRAME_DONE(idx, f_idx, tmstamp) \
128130
MT_DTRACE_PROBE3(st30p, tx_frame_done, idx, f_idx, tmstamp)
131+
#define MT_USDT_ST30P_TX_FRAME_SPURN(idx, f_idx, tmstamp) \
132+
MT_DTRACE_PROBE3(st30p, tx_frame_done, idx, f_idx, tmstamp)
129133
#define MT_USDT_ST30P_TX_FRAME_NEXT(idx, f_idx) \
130134
MT_DTRACE_PROBE2(st30p, tx_frame_next, idx, f_idx)
131135
#define MT_USDT_ST30P_TX_FRAME_DUMP(idx, file, frames) \
@@ -142,6 +146,17 @@
142146
MT_DTRACE_PROBE3(st30p, rx_frame_dump, idx, file, frames)
143147
#define MT_USDT_ST30P_RX_FRAME_DUMP_ENABLED() ST30P_RX_FRAME_DUMP_ENABLED()
144148

149+
#define MT_USDT_ST40P_TX_FRAME_GET(idx, f_idx, va) \
150+
MT_DTRACE_PROBE3(st40p, tx_frame_get, idx, f_idx, va)
151+
#define MT_USDT_ST40P_TX_FRAME_PUT(idx, f_idx, va) \
152+
MT_DTRACE_PROBE3(st40p, tx_frame_put, idx, f_idx, va)
153+
#define MT_USDT_ST40P_TX_FRAME_DONE(idx, f_idx, tmstamp) \
154+
MT_DTRACE_PROBE3(st40p, tx_frame_done, idx, f_idx, tmstamp)
155+
#define MT_USDT_ST40P_TX_FRAME_SPURN(idx, f_idx, tmstamp) \
156+
MT_DTRACE_PROBE3(st30p, tx_frame_done, idx, f_idx, tmstamp)
157+
#define MT_USDT_ST40P_TX_FRAME_NEXT(idx, f_idx) \
158+
MT_DTRACE_PROBE2(st40p, tx_frame_next, idx, f_idx)
159+
145160
#define MT_USDT_ST20_TX_FRAME_NEXT(m_idx, s_idx, f_idx, va, tmstamp) \
146161
MT_DTRACE_PROBE5(st20, tx_frame_next, m_idx, s_idx, f_idx, va, tmstamp)
147162
#define MT_USDT_ST20_TX_FRAME_DONE(m_idx, s_idx, f_idx, tmstamp) \

lib/src/mt_usdt_provider.d

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ provider st20p {
8080
probe tx_frame_put(int idx, int f_idx, void* va, int stat);
8181
probe tx_frame_next(int idx, int f_idx);
8282
probe tx_frame_done(int idx, int f_idx, uint32_t tmstamp);
83+
probe tx_frame_spurn(int idx, int f_idx, uint32_t tmstamp);
8384
/* attach to enable the frame dump at runtime */
8485
probe tx_frame_dump(int idx, char* dump_file, void* va, uint32_t data_size);
8586
/* rx */
@@ -94,6 +95,7 @@ provider st22 {
9495
/* tx */
9596
probe tx_frame_next(int m_idx, int s_idx, int f_idx, void* va, uint32_t tmstamp, uint32_t codestream_size);
9697
probe tx_frame_done(int m_idx, int s_idx, int f_idx, uint32_t tmstamp);
98+
probe tx_frame_spurn(int m_idx, int s_idx, int f_idx, uint32_t tmstamp);
9799
/* attach to enable the frame dump at runtime */
98100
probe tx_frame_dump(int m_idx, int s_idx, char* dump_file, void* va, uint32_t data_size);
99101
/* rx */
@@ -110,6 +112,7 @@ provider st22p {
110112
probe tx_frame_put(int idx, int f_idx, void* va, int stat, uint32_t data_size);
111113
probe tx_frame_next(int idx, int f_idx);
112114
probe tx_frame_done(int idx, int f_idx, uint32_t tmstamp);
115+
probe tx_frame_spurn(int idx, int f_idx, uint32_t tmstamp);
113116
/* attach to enable the frame dump at runtime */
114117
probe tx_frame_dump(int idx, char* dump_file, void* va, uint32_t data_size);
115118
/* rx */
@@ -132,6 +135,7 @@ provider st30p {
132135
probe tx_frame_put(int idx, int f_idx, void* va);
133136
probe tx_frame_next(int idx, int f_idx);
134137
probe tx_frame_done(int idx, int f_idx, uint32_t tmstamp);
138+
probe tx_frame_spurn(int idx, int f_idx, uint32_t tmstamp);
135139
/* attach to enable the frame dump at runtime */
136140
probe tx_frame_dump(int idx, char* dump_file, int frames);
137141
/* rx */
@@ -141,3 +145,12 @@ provider st30p {
141145
/* attach to enable the frame dump at runtime */
142146
probe rx_frame_dump(int idx, char* dump_file, int frames);
143147
}
148+
149+
provider st40p {
150+
/* tx */
151+
probe tx_frame_get(int idx, int f_idx, void* va);
152+
probe tx_frame_put(int idx, int f_idx, void* va);
153+
probe tx_frame_next(int idx, int f_idx);
154+
probe tx_frame_done(int idx, int f_idx, uint32_t tmstamp);
155+
probe tx_frame_spurn(int idx, int f_idx, uint32_t tmstamp);
156+
}

0 commit comments

Comments
 (0)