Skip to content

Commit 6e3e665

Browse files
committed
Add: RX timestamp to st30_frame & st40_frame_info
Signed-off-by: Kasiewicz, Marek <[email protected]>
1 parent 4bc1aa5 commit 6e3e665

File tree

7 files changed

+25
-1
lines changed

7 files changed

+25
-1
lines changed

include/st30_api.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,8 @@ struct st30_rx_frame_meta {
278278
enum st10_timestamp_fmt tfmt;
279279
/** Frame timestamp value */
280280
uint64_t timestamp;
281+
/** TAI timestamp measured right after the RTP packet for this frame was received */
282+
uint64_t timestamp_first_pkt;
281283
/** Timestamp value in the rtp header */
282284
uint32_t rtp_timestamp;
283285
/** received data size for current frame */

include/st30_pipeline_api.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ struct st30_frame {
8585
* 'pkts_total,' which serves as an indicator of signal quality. */
8686
uint32_t pkts_recv[MTL_SESSION_PORT_MAX];
8787

88+
/** TAI timestamp measured right after the first packet of the frame was received */
89+
uint64_t receive_timestamp;
90+
8891
/** priv pointer for lib, do not touch this */
8992
void* priv;
9093
};

include/st40_pipeline_api.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ struct st40_frame_info {
4545
* 'pkts_total,' which serves as an indicator of signal quality. */
4646
uint32_t pkts_recv[MTL_SESSION_PORT_MAX];
4747

48+
/** TAI timestamp measured right after the RTP packet for this frame was received */
49+
uint64_t receive_timestamp;
50+
4851
/** priv pointer for lib, do not touch this */
4952
void* priv;
5053
};

lib/src/st2110/pipeline/st30_pipeline_rx.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ static int rx_st30p_frame_ready(void* priv, void* addr, struct st30_rx_frame_met
8989
frame->data_size = meta->frame_recv_size;
9090
frame->tfmt = meta->tfmt;
9191
frame->timestamp = meta->timestamp;
92+
frame->receive_timestamp = meta->timestamp_first_pkt;
9293
frame->rtp_timestamp = meta->rtp_timestamp;
9394
framebuff->stat = ST30P_RX_FRAME_READY;
9495
/* point to next */
@@ -186,6 +187,7 @@ static int rx_st30p_init_fbs(struct st30p_rx_ctx* ctx, struct st30p_rx_ops* ops)
186187
frame->ptime = ops->ptime;
187188
/* same to framebuffer size */
188189
frame->buffer_size = frame->data_size = ops->framebuff_size;
190+
frame->receive_timestamp = 0;
189191
dbg("%s(%d), init fb %u\n", __func__, idx, i);
190192
}
191193

lib/src/st2110/pipeline/st40_pipeline_rx.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,14 @@ static int rx_st40p_rtp_ready(void* priv) {
8686
mbuf = st40_rx_get_mbuf(ctx->transport, &usrptr, &len);
8787
if (!mbuf) return -EBUSY;
8888

89+
struct rte_mbuf* pkt = mbuf;
90+
enum mtl_port port = mt_port_by_id(ctx->impl, pkt->port);
91+
uint64_t receive_timestamp = 0;
92+
if (port < MTL_PORT_MAX)
93+
receive_timestamp = mt_mbuf_time_stamp(ctx->impl, pkt, port);
94+
else
95+
receive_timestamp = mtl_ptp_read_time(ctx->impl);
96+
8997
uint32_t hdr_bytes = sizeof(struct st40_rfc8331_rtp_hdr);
9098
if (len < hdr_bytes) {
9199
warn("%s(%d), RTP packet too small (%u < %u)\n", __func__, ctx->idx, len, hdr_bytes);
@@ -109,6 +117,7 @@ static int rx_st40p_rtp_ready(void* priv) {
109117
}
110118

111119
frame_info = &framebuff->frame_info;
120+
frame_info->receive_timestamp = receive_timestamp;
112121

113122
/* parse RTP packet and copy metadata */
114123
payload = (uint8_t*)(hdr + 1);
@@ -314,6 +323,7 @@ static int rx_st40p_init_fbs(struct st40p_rx_ctx* ctx, struct st40p_rx_ops* ops)
314323
frame_info->udw_buffer_fill = 0;
315324
frame_info->meta_num = 0;
316325
frame_info->meta = framebuff->meta;
326+
frame_info->receive_timestamp = 0;
317327
frame_info->priv = framebuff;
318328

319329
dbg("%s(%d), init fb %u\n", __func__, idx, i);

lib/src/st2110/st_header.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,6 +1033,7 @@ struct st_rx_audio_session_impl {
10331033
int redundant_error_cnt[MTL_SESSION_PORT_MAX];
10341034

10351035
uint32_t first_pkt_rtp_ts; /* rtp time stamp for the first pkt */
1036+
uint64_t first_pkt_ptp_ts; /* PTP time stamp for the first pkt */
10361037
int64_t tmstamp;
10371038
size_t frame_recv_size;
10381039

lib/src/st2110/st_rx_audio_session.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,11 @@ static int rx_audio_session_handle_frame_pkt(struct mtl_main_impl* impl,
288288
return -EINVAL;
289289
}
290290

291+
enum mtl_port port = mt_port_logic2phy(s->port_maps, s_port);
292+
291293
if (s->st30_pkt_idx == 0) {
292294
s->first_pkt_rtp_ts = tmstamp;
295+
s->first_pkt_ptp_ts = mt_mbuf_time_stamp(impl, mbuf, port);
293296
}
294297

295298
if (unlikely(s->latest_seq_id[s_port] == -1)) s->latest_seq_id[s_port] = seq_id - 1;
@@ -359,7 +362,6 @@ static int rx_audio_session_handle_frame_pkt(struct mtl_main_impl* impl,
359362
s->st30_pkt_idx++;
360363

361364
if (s->enable_timing_parser) {
362-
enum mtl_port port = mt_port_logic2phy(s->port_maps, s_port);
363365
ra_tp_on_packet(s, s_port, tmstamp, mt_mbuf_time_stamp(impl, mbuf, port));
364366
}
365367

@@ -388,6 +390,7 @@ static int rx_audio_session_handle_frame_pkt(struct mtl_main_impl* impl,
388390

389391
meta->tfmt = ST10_TIMESTAMP_FMT_MEDIA_CLK;
390392
meta->timestamp = s->first_pkt_rtp_ts;
393+
meta->timestamp_first_pkt = s->first_pkt_ptp_ts;
391394
meta->fmt = ops->fmt;
392395
meta->sampling = ops->sampling;
393396
meta->channel = ops->channel;

0 commit comments

Comments
 (0)