Skip to content

Commit

Permalink
Add support for new ST2110-41 (Fast Metadata Framework, "fmd") standa…
Browse files Browse the repository at this point in the history
…rd. (OpenVisualCloud#951)

Add support for new ST2110-41 (Fast Metadata Framework) standard.

Add support for new ST2110-41 (Fast Metadata Framework, "fmd") standard.
As abbreviation in the code "fmd".

Support for st41 in /include/ directory.
Support for st41 in RxTxApp.
with added options in JSON file in RxTxApp (for RX and TX):
            "fastmetadata": [
with options for TX:
                    "fastmetadata_data_item_type": 3648364,
                    "fastmetadata_k_bit": 1,
                    "fastmetadata_url": "test_abc.txt", 
                    "fastmetadata_fps": "p59"
  • Loading branch information
skolelis authored Sep 9, 2024
1 parent c45c3d1 commit c43152d
Show file tree
Hide file tree
Showing 30 changed files with 5,197 additions and 22 deletions.
58 changes: 58 additions & 0 deletions app/src/app_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <mtl/st30_api.h>
#include <mtl/st30_pipeline_api.h>
#include <mtl/st40_api.h>
#include <mtl/st41_api.h>
#include <mtl/st_pipeline_api.h>
#include <pcap.h>
#include <pthread.h>
Expand Down Expand Up @@ -41,6 +42,10 @@
#define ST_APP_MAX_TX_ANC_SESSIONS (180)
#define ST_APP_MAX_RX_ANC_SESSIONS (180)

/* FMD = Fast Metadata (ST2110-41) */
#define ST_APP_MAX_TX_FMD_SESSIONS (180)
#define ST_APP_MAX_RX_FMD_SESSIONS (180)

#define ST_APP_MAX_LCORES (32)

#define ST_APP_DEFAULT_FB_CNT (3)
Expand Down Expand Up @@ -226,6 +231,37 @@ struct st_app_tx_anc_session {
uint32_t st40_seq_id;
};

struct st_app_tx_fmd_session {
int idx;
st41_tx_handle handle;

uint16_t framebuff_cnt;

uint16_t framebuff_producer_idx;
uint16_t framebuff_consumer_idx;
struct st_tx_frame* framebuffs;

uint32_t st41_frame_done_cnt;
uint32_t st41_packet_done_cnt;

char st41_source_url[ST_APP_URL_MAX_LEN + 1];
int st41_source_fd;
pcap_t* st41_pcap;
bool st41_pcap_input;
uint32_t st41_dit;
uint32_t st41_k_bit;
bool st41_rtp_input;
uint8_t* st41_source_begin;
uint8_t* st41_source_end;
uint8_t* st41_frame_cursor; /* cursor to current frame */
pthread_t st41_app_thread;
bool st41_app_thread_stop;
pthread_cond_t st41_wake_cond;
pthread_mutex_t st41_wake_mutex;
uint32_t st41_rtp_tmstamp;
uint32_t st41_seq_id;
};

struct st_app_rx_video_session {
int idx;
mtl_handle st;
Expand Down Expand Up @@ -327,6 +363,19 @@ struct st_app_rx_anc_session {
uint64_t stat_frame_first_rx_time;
};

struct st_app_rx_fmd_session {
int idx;
st41_rx_handle handle;
pthread_t st41_app_thread;
pthread_cond_t st41_wake_cond;
pthread_mutex_t st41_wake_mutex;
bool st41_app_thread_stop;

/* stat */
int stat_frame_total_received;
uint64_t stat_frame_first_rx_time;
};

struct st22_app_tx_session {
int idx;
st22_tx_handle handle;
Expand Down Expand Up @@ -610,6 +659,12 @@ struct st_app_context {
int tx_anc_rtp_ring_size; /* the ring size for tx anc rtp type */
bool tx_anc_dedicate_queue;

struct st_app_tx_fmd_session* tx_fmd_sessions;
char tx_fmd_url[ST_APP_URL_MAX_LEN];
int tx_fmd_session_cnt;
int tx_fmd_rtp_ring_size; /* the ring size for tx fmd rtp type */
bool tx_fmd_dedicate_queue;

char tx_st22p_url[ST_APP_URL_MAX_LEN]; /* send st22p content url*/
struct st_app_tx_st22p_session* tx_st22p_sessions;
int tx_st22p_session_cnt;
Expand Down Expand Up @@ -640,6 +695,9 @@ struct st_app_context {
struct st_app_rx_anc_session* rx_anc_sessions;
int rx_anc_session_cnt;

struct st_app_rx_fmd_session* rx_fmd_sessions;
int rx_fmd_session_cnt;

struct st_app_rx_st22p_session* rx_st22p_sessions;
int rx_st22p_session_cnt;

Expand Down
27 changes: 27 additions & 0 deletions app/src/args.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ enum st_args_cmd {
ST_ARG_TX_ANC_URL,
ST_ARG_TX_ANC_SESSIONS_CNT,
ST_ARG_TX_ANC_RTP_RING_SIZE,
ST_ARG_TX_FMD_URL,
ST_ARG_TX_FMD_SESSIONS_CNT,
ST_ARG_TX_FMD_RTP_RING_SIZE,
ST22_ARG_TX_SESSIONS_CNT,
ST22_ARG_TX_URL,
ST_ARG_RX_VIDEO_SESSIONS_CNT,
Expand All @@ -48,6 +51,7 @@ enum st_args_cmd {
ST_ARG_RX_AUDIO_RTP_RING_SIZE,
ST_ARG_RX_AUDIO_DUMP_TIME_S,
ST_ARG_RX_ANC_SESSIONS_CNT,
ST_ARG_RX_FMD_SESSIONS_CNT,
ST22_ARG_RX_SESSIONS_CNT,
ST_ARG_HDR_SPLIT,
ST_ARG_PACING_WAY,
Expand Down Expand Up @@ -134,6 +138,7 @@ enum st_args_cmd {
ST_ARG_AUDIO_RL_OFFSET_US,
ST_ARG_AUDIO_FIFO_SIZE,
ST_ARG_ANC_DEDICATE_QUEUE,
ST_ARG_FMD_DEDICATE_QUEUE,
ST_ARG_TX_NO_BURST_CHECK,
ST_ARG_DHCP,
ST_ARG_IOVA_MODE,
Expand Down Expand Up @@ -183,6 +188,9 @@ static struct option st_app_args_options[] = {
{"tx_anc_url", required_argument, 0, ST_ARG_TX_ANC_URL},
{"tx_anc_sessions_count", required_argument, 0, ST_ARG_TX_ANC_SESSIONS_CNT},
{"tx_anc_rtp_ring_size", required_argument, 0, ST_ARG_TX_ANC_RTP_RING_SIZE},
{"tx_fmd_url", required_argument, 0, ST_ARG_TX_FMD_URL},
{"tx_fmd_sessions_count", required_argument, 0, ST_ARG_TX_FMD_SESSIONS_CNT},
{"tx_fmd_rtp_ring_size", required_argument, 0, ST_ARG_TX_FMD_RTP_RING_SIZE},
{"tx_st22_sessions_count", required_argument, 0, ST22_ARG_TX_SESSIONS_CNT},
{"tx_st22_url", required_argument, 0, ST22_ARG_TX_URL},

Expand All @@ -195,6 +203,7 @@ static struct option st_app_args_options[] = {
{"rx_audio_rtp_ring_size", required_argument, 0, ST_ARG_RX_AUDIO_RTP_RING_SIZE},
{"rx_audio_dump_time_s", required_argument, 0, ST_ARG_RX_AUDIO_DUMP_TIME_S},
{"rx_anc_sessions_count", required_argument, 0, ST_ARG_RX_ANC_SESSIONS_CNT},
{"rx_fmd_sessions_count", required_argument, 0, ST_ARG_RX_FMD_SESSIONS_CNT},
{"rx_st22_sessions_count", required_argument, 0, ST22_ARG_RX_SESSIONS_CNT},
{"hdr_split", no_argument, 0, ST_ARG_HDR_SPLIT},
{"pacing_way", required_argument, 0, ST_ARG_PACING_WAY},
Expand Down Expand Up @@ -277,6 +286,7 @@ static struct option st_app_args_options[] = {
{"audio_rl_offset", required_argument, 0, ST_ARG_AUDIO_RL_OFFSET_US},
{"audio_fifo_size", required_argument, 0, ST_ARG_AUDIO_FIFO_SIZE},
{"anc_dedicate_queue", no_argument, 0, ST_ARG_ANC_DEDICATE_QUEUE},
{"fmd_dedicate_queue", no_argument, 0, ST_ARG_FMD_DEDICATE_QUEUE},
{"tx_no_burst_check", no_argument, 0, ST_ARG_TX_NO_BURST_CHECK},
{"dhcp", no_argument, 0, ST_ARG_DHCP},
{"iova_mode", required_argument, 0, ST_ARG_IOVA_MODE},
Expand Down Expand Up @@ -351,12 +361,14 @@ static int app_args_json(struct st_app_context* ctx, struct mtl_init_params* p,
ctx->tx_video_session_cnt = ctx->json_ctx->tx_video_session_cnt;
ctx->tx_audio_session_cnt = ctx->json_ctx->tx_audio_session_cnt;
ctx->tx_anc_session_cnt = ctx->json_ctx->tx_anc_session_cnt;
ctx->tx_fmd_session_cnt = ctx->json_ctx->tx_fmd_session_cnt;
ctx->tx_st22p_session_cnt = ctx->json_ctx->tx_st22p_session_cnt;
ctx->tx_st20p_session_cnt = ctx->json_ctx->tx_st20p_session_cnt;
ctx->tx_st30p_session_cnt = ctx->json_ctx->tx_st30p_session_cnt;
ctx->rx_video_session_cnt = ctx->json_ctx->rx_video_session_cnt;
ctx->rx_audio_session_cnt = ctx->json_ctx->rx_audio_session_cnt;
ctx->rx_anc_session_cnt = ctx->json_ctx->rx_anc_session_cnt;
ctx->rx_fmd_session_cnt = ctx->json_ctx->rx_fmd_session_cnt;
ctx->rx_st22p_session_cnt = ctx->json_ctx->rx_st22p_session_cnt;
ctx->rx_st20p_session_cnt = ctx->json_ctx->rx_st20p_session_cnt;
ctx->rx_st30p_session_cnt = ctx->json_ctx->rx_st30p_session_cnt;
Expand Down Expand Up @@ -513,6 +525,15 @@ int st_app_parse_args(struct st_app_context* ctx, struct mtl_init_params* p, int
case ST_ARG_TX_ANC_SESSIONS_CNT:
ctx->tx_anc_session_cnt = atoi(optarg);
break;
case ST_ARG_TX_FMD_URL:
snprintf(ctx->tx_fmd_url, sizeof(ctx->tx_fmd_url), "%s", optarg);
break;
case ST_ARG_TX_FMD_RTP_RING_SIZE:
ctx->tx_fmd_rtp_ring_size = atoi(optarg);
break;
case ST_ARG_TX_FMD_SESSIONS_CNT:
ctx->tx_fmd_session_cnt = atoi(optarg);
break;
case ST_ARG_RX_VIDEO_SESSIONS_CNT:
ctx->rx_video_session_cnt = atoi(optarg);
break;
Expand Down Expand Up @@ -540,6 +561,9 @@ int st_app_parse_args(struct st_app_context* ctx, struct mtl_init_params* p, int
case ST_ARG_RX_ANC_SESSIONS_CNT:
ctx->rx_anc_session_cnt = atoi(optarg);
break;
case ST_ARG_RX_FMD_SESSIONS_CNT:
ctx->rx_fmd_session_cnt = atoi(optarg);
break;
case ST22_ARG_TX_SESSIONS_CNT:
ctx->tx_st22_session_cnt = atoi(optarg);
break;
Expand Down Expand Up @@ -856,6 +880,9 @@ int st_app_parse_args(struct st_app_context* ctx, struct mtl_init_params* p, int
case ST_ARG_ANC_DEDICATE_QUEUE:
ctx->tx_anc_dedicate_queue = true;
break;
case ST_ARG_FMD_DEDICATE_QUEUE:
ctx->tx_fmd_dedicate_queue = true;
break;
case ST_ARG_DHCP:
for (int port = 0; port < MTL_PORT_MAX; ++port)
p->net_proto[port] = MTL_PROTO_DHCP;
Expand Down
1 change: 1 addition & 0 deletions app/src/fmt.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#define ST_APP_PAYLOAD_TYPE_AUDIO (111)
#define ST_APP_PAYLOAD_TYPE_ANCILLARY (113)
#define ST_APP_PAYLOAD_TYPE_ST22 (114)
#define ST_APP_PAYLOAD_TYPE_FASTMETADATA (115)

#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof(arr[0]))

Expand Down
1 change: 1 addition & 0 deletions app/src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ sources = files('rxtx_app.c', 'args.c', 'parse_json.c', 'fmt.c',
'tx_st20p_app.c', 'rx_st20p_app.c',
'tx_st22p_app.c', 'rx_st22p_app.c',
'tx_ancillary_app.c', 'rx_ancillary_app.c',
'tx_fastmetadata_app.c', 'rx_fastmetadata_app.c',
'tx_st30p_app.c', 'rx_st30p_app.c',
)

Expand Down
Loading

0 comments on commit c43152d

Please sign in to comment.