Skip to content

Commit 38cb0df

Browse files
Add: RxTxApp unify support for drop frame for pipeline jsons
add unified drop-frame parsing in RxTxApp, allow users to test drop frame functionality.
1 parent 1a0c7b8 commit 38cb0df

File tree

5 files changed

+15
-1
lines changed

5 files changed

+15
-1
lines changed

lib/src/st2110/pipeline/st30_pipeline_tx.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ static bool tx_st30p_if_frame_late(struct st30p_tx_ctx* ctx,
9191

9292
uint64_t frame_tai = frame->timestamp;
9393
uint64_t cur_tai = mt_get_ptp_time(ctx->impl, MTL_PORT_P);
94-
uint64_t frame_period_ns = NS_PER_S / ctx->frames_per_sec;
94+
uint64_t frame_period_ns = (uint64_t)NS_PER_S / ctx->frames_per_sec;
9595

9696
if (cur_tai < frame_tai + frame_period_ns)
9797
return false; /* within acceptable TX window */
@@ -139,6 +139,8 @@ static int tx_st30p_next_frame(void* priv, uint16_t* next_frame_idx,
139139

140140
if (!ctx->ready) return -EBUSY; /* not ready */
141141

142+
uint32_t drops_before = ctx->stat_drop_frame;
143+
142144
mt_pthread_mutex_lock(&ctx->lock);
143145
do {
144146
framebuff = tx_st30p_newest_available(ctx, ST30P_TX_FRAME_READY);
@@ -148,6 +150,10 @@ static int tx_st30p_next_frame(void* priv, uint16_t* next_frame_idx,
148150
/* not any ready frame */
149151
if (!framebuff) {
150152
mt_pthread_mutex_unlock(&ctx->lock);
153+
/* Notify the app once after the entire drop batch so it can provide
154+
* fresh frames. Doing this here (instead of per-drop) avoids the
155+
* drop→refill→drop feedback loop with high-rate audio streams. */
156+
if (ctx->stat_drop_frame > drops_before) tx_st30p_notify_frame_available(ctx);
151157
return -EBUSY;
152158
}
153159

tests/tools/RxTxApp/src/parse_json.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,6 +1049,8 @@ static int st_json_parse_st30p(int idx, json_object* st30p_obj,
10491049

10501050
st30p->user_pacing =
10511051
json_object_get_boolean(st_json_object_object_get(st30p_obj, "user_pacing"));
1052+
st30p->drop_when_late =
1053+
json_object_get_boolean(st_json_object_object_get(st30p_obj, "drop_when_late"));
10521054
return ST_JSON_SUCCESS;
10531055
}
10541056

@@ -1118,6 +1120,8 @@ static int st_json_parse_tx_st40p(int idx, json_object* st40p_obj,
11181120
json_object_get_boolean(st_json_object_object_get(st40p_obj, "user_timestamp"));
11191121
st40p->enable_rtcp =
11201122
json_object_get_boolean(st_json_object_object_get(st40p_obj, "enable_rtcp"));
1123+
st40p->drop_when_late =
1124+
json_object_get_boolean(st_json_object_object_get(st40p_obj, "drop_when_late"));
11211125

11221126
return ST_JSON_SUCCESS;
11231127
}

tests/tools/RxTxApp/src/parse_json.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ typedef struct st_json_st30p_session {
244244
st_json_audio_info_t info;
245245
bool enable_rtcp;
246246
bool user_pacing;
247+
bool drop_when_late;
247248
} st_json_st30p_session_t;
248249

249250
typedef struct st_json_ancillary_session {
@@ -300,6 +301,7 @@ typedef struct st_json_st40p_session {
300301
bool exact_user_pacing;
301302
bool user_timestamp;
302303
bool enable_rtcp;
304+
bool drop_when_late;
303305
} st_json_st40p_session_t;
304306

305307
typedef struct st_json_context {

tests/tools/RxTxApp/src/tx_st30p_app.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ static int app_tx_st30p_init(struct st_app_context* ctx, st_json_st30p_session_t
231231
s->frame_num = 0;
232232
s->local_tai_base_time = 0;
233233
}
234+
if (st30p && st30p->drop_when_late) ops.flags |= ST30P_TX_FLAG_DROP_WHEN_LATE;
234235

235236
ops.flags |= ST30P_TX_FLAG_BLOCK_GET;
236237
s->num_port = ops.port.num_port;

tests/tools/RxTxApp/src/tx_st40p_app.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ static int app_tx_st40p_init(struct st_app_context* ctx, st_json_st40p_session_t
282282
if ((st40p && st40p->exact_user_pacing) || ctx->tx_exact_user_pacing)
283283
ops.flags |= ST40P_TX_FLAG_EXACT_USER_PACING;
284284
if (st40p && st40p->enable_rtcp) ops.flags |= ST40P_TX_FLAG_ENABLE_RTCP;
285+
if (st40p && st40p->drop_when_late) ops.flags |= ST40P_TX_FLAG_DROP_WHEN_LATE;
285286
if (ctx->tx_anc_dedicate_queue) ops.flags |= ST40P_TX_FLAG_DEDICATE_QUEUE;
286287

287288
handle = st40p_tx_create(ctx->st, &ops);

0 commit comments

Comments
 (0)