From 8056e0eb44f872d39b24255e25f3382e030a9e62 Mon Sep 17 00:00:00 2001 From: "Kolelis, Szymon" Date: Fri, 6 Sep 2024 10:46:50 +0200 Subject: [PATCH] st41 working for frame and rtp modes --- app/src/app_base.h | 3 ++ app/src/args.c | 1 + app/src/parse_json.c | 40 +++++++++++++----- app/src/parse_json.h | 8 +--- app/src/rx_fastmetadata_app.c | 22 +++++++--- app/src/tx_fastmetadata_app.c | 33 +++++++++++---- include/st40_api.h | 2 +- include/st41_api.h | 47 +++++++++++++++++---- lib/src/st2110/st_fastmetadata.c | 2 +- lib/src/st2110/st_header.h | 2 +- lib/src/st2110/st_tx_fastmetadata_session.c | 37 ++++++++++------ 11 files changed, 141 insertions(+), 56 deletions(-) diff --git a/app/src/app_base.h b/app/src/app_base.h index 10ee856a7..66a4e3e39 100644 --- a/app/src/app_base.h +++ b/app/src/app_base.h @@ -247,6 +247,9 @@ struct st_app_tx_fmd_session { int st41_source_fd; pcap_t* st41_pcap; bool st41_pcap_input; + uint32_t fmd_dit; + uint32_t fmd_k_bit; + bool st41_rtp_input; uint8_t* st41_source_begin; uint8_t* st41_source_end; diff --git a/app/src/args.c b/app/src/args.c index cd5eef182..46392c556 100644 --- a/app/src/args.c +++ b/app/src/args.c @@ -358,6 +358,7 @@ static int app_args_json(struct st_app_context* ctx, struct mtl_init_params* p, ctx->json_ctx = NULL; return ret; } + 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; diff --git a/app/src/parse_json.c b/app/src/parse_json.c index d09c8f3e3..e260b4a2b 100644 --- a/app/src/parse_json.c +++ b/app/src/parse_json.c @@ -1229,15 +1229,35 @@ static int st_json_parse_tx_fmd(int idx, json_object* fmd_obj, err("%s, invalid fmd type %s\n", __func__, type); return -ST_JSON_NOT_VALID; } - /* parse fmd format */ - const char* fmd_format = - json_object_get_string(st_json_object_object_get(fmd_obj, "fastmetadata_format")); - REQUIRED_ITEM(fmd_format); - if (strcmp(fmd_format, "closed_caption") == 0) { - fmd->info.fmd_format = FMD_FORMAT_CLOSED_CAPTION; + + /* parse fmd data item type */ + json_object* fmd_dit_obj = st_json_object_object_get(fmd_obj, "fastmetadata_data_item_type"); + if (fmd_dit_obj) { + uint32_t fmd_dit = json_object_get_int(fmd_dit_obj); + if (fmd_dit < 0 || fmd_dit > 0x3fffff) { + err("%s, invalid fastmetadata_data_item_type 0x%x\n", __func__, fmd_dit); + return -ST_JSON_NOT_VALID; + } + fmd->info.fmd_dit = fmd_dit; + info("%s, fastmetadata_data_item_type = 0x%x\n", __func__, fmd_dit); } else { - err("%s, invalid fmd format %s\n", __func__, fmd_format); - return -ST_JSON_NOT_VALID; + err("%s, No fastmetadata_data_item_type !\n", __func__); + return -ST_JSON_NULL; + } + + /* parse fmd data item K-bit */ + json_object* fmd_k_bit_obj = st_json_object_object_get(fmd_obj, "fastmetadata_k_bit"); + if (fmd_k_bit_obj) { + uint8_t fmd_k_bit = json_object_get_int(fmd_k_bit_obj); + if (fmd_k_bit < 0 || fmd_k_bit > 1) { + err("%s, invalid fastmetadata_k_bit 0x%x\n", __func__, fmd_k_bit); + return -ST_JSON_NOT_VALID; + } + fmd->info.fmd_k_bit = fmd_k_bit; + info("%s, fastmetadata_k_bit = 0x%x\n", __func__, fmd_k_bit); + } else { + err("%s, No fastmetadata_k_bit !\n", __func__); + return -ST_JSON_NULL; } /* parse fmd fps */ @@ -1338,7 +1358,7 @@ static int parse_st22p_fps(json_object* st22p_obj, st_json_st22p_session_t* st22 } else if (strcmp(fps, "p29") == 0) { st22p->info.fps = ST_FPS_P29_97; } else { - err("%s, invalid anc fps %s\n", __func__, fps); //skolelis tbd: here I dont see corelation for st41(fmd), but why there is st40(anc) actually? + err("%s, invalid st22 fps %s\n", __func__, fps); return -ST_JSON_NOT_VALID; } return ST_JSON_SUCCESS; @@ -1646,7 +1666,7 @@ static int parse_st20p_fps(json_object* st20p_obj, st_json_st20p_session_t* st20 } else if (strcmp(fps, "p29") == 0) { st20p->info.fps = ST_FPS_P29_97; } else { - err("%s, invalid anc fps %s\n", __func__, fps); //skolelis tbd: here I dont see corelation for st41(fmd), but why there is st40(anc) actually? + err("%s, invalid st20 fps %s\n", __func__, fps); return -ST_JSON_NOT_VALID; } return ST_JSON_SUCCESS; diff --git a/app/src/parse_json.h b/app/src/parse_json.h index 9b8d449e8..e6283ce29 100644 --- a/app/src/parse_json.h +++ b/app/src/parse_json.h @@ -105,11 +105,6 @@ enum anc_format { ANC_FORMAT_MAX, }; -enum fmd_format { - FMD_FORMAT_CLOSED_CAPTION, - FMD_FORMAT_MAX, -}; // skolelis tbd: I don't think closed caption is relevant here in st41. The enum to be removed or changed. - struct st_video_fmt_desc { enum video_format fmt; char* name; @@ -187,7 +182,8 @@ typedef struct st_json_ancillary_info { typedef struct st_json_fastmetadata_info { enum st41_type type; - enum fmd_format fmd_format; + uint32_t fmd_dit; + uint8_t fmd_k_bit; enum st_fps fmd_fps; bool interlaced; diff --git a/app/src/rx_fastmetadata_app.c b/app/src/rx_fastmetadata_app.c index d2bf1238f..eb8ae00bb 100644 --- a/app/src/rx_fastmetadata_app.c +++ b/app/src/rx_fastmetadata_app.c @@ -4,15 +4,23 @@ #include "rx_fastmetadata_app.h" -static void app_rx_fmd_handle_rtp(struct st_app_rx_fmd_session* s) { //skolelis tbd remove }, void* usrptr) { - // skolelis tbd remove this line struct st41_rtp_hdr* hdr = (struct st41_rtp_hdr*)usrptr; - // skolelis tbd remove this line struct st41_rfc8331_payload_hdr* payload_hdr = - // skolelis tbd remove this line (struct st41_rfc8331_payload_hdr*)(&hdr[1]); +static void app_rx_fmd_handle_rtp(struct st_app_rx_fmd_session* s) { // skolelis tbd: remove }, void* usrptr) { + // skolelis tbd: struct st41_rtp_hdr* hdr = (struct st41_rtp_hdr*)usrptr; + // skolelis tbd: struct st41_rfc8331_payload_hdr* payload_hdr = (struct st41_rfc8331_payload_hdr*)(&hdr[1]); + dbg("%s(%d).\n", __func__, s->idx); - // skolelis what for this nthol() 2x ? payload_hdr->swaped_second_hdr_chunk = ntohl(payload_hdr->swaped_second_hdr_chunk); - // skolelis what for this nthol() 2x ? payload_hdr->swaped_second_hdr_chunk = htonl(payload_hdr->swaped_second_hdr_chunk); + // skolelis tbd: payload_hdr->swaped_second_hdr_chunk = htonl(payload_hdr->swaped_second_hdr_chunk); +/* // skolelis tbd: some checking should be done. in st40 here we were checking if checksums and parities are correct. + // skolelis tbd: here in st41 we dont have such mechanisms to verify. so what else? + if (!st41_check_parity_bits(payload_hdr->second_hdr_chunk.did) || + !st41_check_parity_bits(payload_hdr->second_hdr_chunk.sdid) || + !st41_check_parity_bits(payload_hdr->second_hdr_chunk.data_count)) { + err("%s(%d), fmd RTP checkParityBits error\n", __func__, s->idx); + return; + } +*/ s->stat_frame_total_received++; if (!s->stat_frame_first_rx_time) s->stat_frame_first_rx_time = st_app_get_monotonic_time(); @@ -37,7 +45,7 @@ static void* app_rx_fmd_read_thread(void* arg) { continue; } /* parse the packet */ - app_rx_fmd_handle_rtp(s); // skolelis tbd remove: , usrptr); + app_rx_fmd_handle_rtp(s); // skolelis tbd: remove: , usrptr); st41_rx_put_mbuf(s->handle, mbuf); } info("%s(%d), stop\n", __func__, idx); diff --git a/app/src/tx_fastmetadata_app.c b/app/src/tx_fastmetadata_app.c index 9e91b2fc4..f497ebfbe 100644 --- a/app/src/tx_fastmetadata_app.c +++ b/app/src/tx_fastmetadata_app.c @@ -4,9 +4,9 @@ #include "tx_fastmetadata_app.h" - +// skolelis tbd: where it shoud be defined? #define ST_PKT_ST41_PAYLOAD_MAX_BYTES \ - (1460 - sizeof(struct st41_rtp_hdr)) + (1460 - sizeof(struct st41_rtp_hdr) - 8) // skolelis tbd: why here we have "-8" ? (value found experimentally. "-7" would be not enough!) static int app_tx_fmd_next_frame(void* priv, uint16_t* next_frame_idx, struct st41_tx_frame_meta* meta) { @@ -79,6 +79,7 @@ static void app_tx_fmd_build_frame(struct st_app_tx_fmd_session* s, uint16_t data_item_length_bytes = s->st41_source_end - s->st41_frame_cursor > ST_PKT_ST41_PAYLOAD_MAX_BYTES ? ST_PKT_ST41_PAYLOAD_MAX_BYTES : s->st41_source_end - s->st41_frame_cursor; + dst->data_item_length_bytes = data_item_length_bytes; dst->data = s->st41_frame_cursor; s->st41_frame_cursor += data_item_length_bytes; @@ -108,7 +109,7 @@ static void* app_tx_fmd_frame_thread(void* arg) { struct st41_frame* frame_addr = st41_tx_get_framebuffer(s->handle, producer_idx); app_tx_fmd_build_frame(s, frame_addr); - + st_pthread_mutex_lock(&s->st41_wake_mutex); framebuff->size = sizeof(*frame_addr); framebuff->stat = ST_TX_FRAME_READY; @@ -191,9 +192,11 @@ static void app_tx_fmd_build_rtp(struct st_app_tx_fmd_session* s, void* usrptr, /* generate one fmd rtp for test purpose */ struct st41_rtp_hdr* hdr = (struct st41_rtp_hdr*)usrptr; uint8_t* payload_hdr = (uint8_t*)(&hdr[1]); - uint16_t data_item_length_bytes = s->st41_source_end - s->st41_frame_cursor > ST_PKT_ST41_PAYLOAD_MAX_BYTES - ? ST_PKT_ST41_PAYLOAD_MAX_BYTES + uint16_t data_item_length_bytes = s->st41_source_end - s->st41_frame_cursor > (MTL_PKT_MAX_RTP_BYTES-16) + ? (MTL_PKT_MAX_RTP_BYTES-16) : s->st41_source_end - s->st41_frame_cursor; + // skolelis tbd: (MTL_PKT_MAX_RTP_BYTES-16) - this is limit found in experimental way. no ST_PKT_ST41_PAYLOAD_MAX_BYTES !!! + uint16_t data_item_length; data_item_length = (data_item_length_bytes + 3) / 4; /* expressed in number of 4-byte words */ hdr->base.marker = 1; @@ -209,9 +212,9 @@ static void app_tx_fmd_build_rtp(struct st_app_tx_fmd_session* s, void* usrptr, s->st41_seq_id++; s->st41_rtp_tmstamp++; - // skolelis what for we have her this htonl() ??? payload_hdr->swaped_second_hdr_chunk = htonl(payload_hdr->swaped_second_hdr_chunk); + // skolelis tbd: what for we have her this htonl() ??? payload_hdr->swaped_second_hdr_chunk = htonl(payload_hdr->swaped_second_hdr_chunk); for (int i = 0; i < data_item_length_bytes; i++) { - payload_hdr[i] = s->st41_frame_cursor[i]; //skolelis tu ustal dobrze wskaznik na start paylodu a moze nawet 4-bajtowy? + payload_hdr[i] = s->st41_frame_cursor[i]; // skolelis tbd: here have the proper pointer on payload start, and maybe even 4-byte word? } /* filling with 0's the remianing bytes of last 4-byte word */ for (int i = data_item_length_bytes; i < data_item_length * 4; i++) { @@ -219,7 +222,12 @@ static void app_tx_fmd_build_rtp(struct st_app_tx_fmd_session* s, void* usrptr, } *mbuf_len = sizeof(struct st41_rtp_hdr) + data_item_length * 4; - hdr->data_item_length = htons(data_item_length); //tbd skolelis htons() ??? + hdr->st41_hdr_chunk.data_item_length = data_item_length; // skolelis tbd: htons() ??? + hdr->st41_hdr_chunk.data_item_type = s->fmd_dit; + hdr->st41_hdr_chunk.data_item_k_bit = s->fmd_k_bit; + + hdr->swaped_st41_hdr_chunk = htonl(hdr->swaped_st41_hdr_chunk); // skolelis tbd: and I added it instead of htons() 1 line above + s->st41_frame_cursor += data_item_length_bytes; if (s->st41_frame_cursor == s->st41_source_end) s->st41_frame_cursor = s->st41_source_begin; @@ -320,7 +328,7 @@ static int app_tx_fmd_close_source(struct st_app_tx_fmd_session* s) { static int app_tx_fmd_start_source(struct st_app_tx_fmd_session* s) { int ret = -EINVAL; int idx = s->idx; - + s->st41_app_thread_stop = false; if (s->st41_pcap_input) ret = pthread_create(&s->st41_app_thread, NULL, app_tx_fmd_pcap_thread, (void*)s); @@ -435,6 +443,8 @@ static int app_tx_fmd_init(struct st_app_context* ctx, st_json_fastmetadata_sess ops.notify_rtp_done = app_tx_fmd_rtp_done; ops.framebuff_cnt = s->framebuff_cnt; ops.fps = fmd ? fmd->info.fmd_fps : ST_FPS_P59_94; + ops.fmd_dit = fmd->info.fmd_dit; + ops.fmd_k_bit = fmd->info.fmd_k_bit; s->st41_pcap_input = false; ops.type = fmd ? fmd->info.type : ST41_TYPE_FRAME_LEVEL; ops.interlaced = fmd ? fmd->info.interlaced : false; @@ -464,6 +474,10 @@ static int app_tx_fmd_init(struct st_app_context* ctx, st_json_fastmetadata_sess return -EIO; } + /* added this s... = fmd... for RTP mode to function (by skolelis)*/ + s->fmd_dit = fmd->info.fmd_dit; + s->fmd_k_bit = fmd->info.fmd_k_bit; + s->handle = handle; snprintf(s->st41_source_url, sizeof(s->st41_source_url), "%s", fmd ? fmd->info.fmd_url : ctx->tx_fmd_url); @@ -508,6 +522,7 @@ int st_app_tx_fmd_sessions_init(struct st_app_context* ctx) { s->idx = i; ret = app_tx_fmd_init(ctx, ctx->json_ctx ? &ctx->json_ctx->tx_fmd_sessions[i] : NULL, s); + if (ret < 0) { err("%s(%d), app_tx_fmd_session_init fail %d\n", __func__, i, ret); return ret; diff --git a/include/st40_api.h b/include/st40_api.h index 08b239e79..2660e1180 100644 --- a/include/st40_api.h +++ b/include/st40_api.h @@ -200,7 +200,7 @@ struct st40_meta { /** * Max number of meta in one ST2110-40(ancillary) frame */ -#define ST40_MAX_META (20) //skolelis tbd according to rf8331 the limit is 255 (if it is the proper field for that) !!! +#define ST40_MAX_META (20) // skolelis tbd: according to rf8331 the limit is 255 (if it is the proper field for that) !!! /** * Structure for ST2110-40(ancillary) frame diff --git a/include/st41_api.h b/include/st41_api.h index 9bc2cd35b..54d51d48b 100644 --- a/include/st41_api.h +++ b/include/st41_api.h @@ -82,19 +82,44 @@ enum st41_type { }; /** - * A structure describing a st2110-41 (fast metadata framework) rtp header + * A structure describing a st2110-41(fast metadata) rtp header */ +#ifdef MTL_LITTLE_ENDIAN MTL_PACK(struct st41_rtp_hdr { // skolelis tbd: should we add little/big endian (double) versions struct to this structure (like in other places)? /** Rtp rfc3550 base hdr */ struct st_rfc3550_rtp_hdr base; - - /** Data Item Type */ - uint32_t data_item_type : 22; - /** Data Item K-bit */ - uint8_t data_item_k_bit : 1; // skolelis tbd: is it not better to have here uint_32_t type for compatibility with other 22 bits? - /** Data Item Contents - Number of 32-bit data elements that follow */ - uint16_t data_item_length : 9; // skolelis tbd: is it not better to have here uint_32_t type for compatibility with other 22 bits? + union { + struct { + /** Data Item Contents - Number of 32-bit data elements that follow */ + uint32_t data_item_length : 9; // skolelis tbd: is it not better to have here uint_32_t type for compatibility with other 22 bits? + /** Data Item K-bit */ + uint32_t data_item_k_bit : 1; // skolelis tbd: is it not better to have here uint_32_t type for compatibility with other 22 bits? + /** Data Item Type */ + uint32_t data_item_type : 22; + } st41_hdr_chunk; + /** Handle to make operating on st41_hdr_chunk buffer easier */ + uint32_t swaped_st41_hdr_chunk; + }; }); +#else +MTL_PACK(struct st41_rtp_hdr { // skolelis tbd: should we add little/big endian (double) versions struct to this structure (like in other places)? + /** Rtp rfc3550 base hdr */ + struct st_rfc3550_rtp_hdr base; + union { + struct { + /** Data Item Type */ + uint32_t data_item_type : 22; + /** Data Item K-bit */ + uint32_t data_item_k_bit : 1; // skolelis tbd: is it not better to have here uint_32_t type for compatibility with other 22 bits? + /** Data Item Contents - Number of 32-bit data elements that follow */ + uint32_t data_item_length : 9; // skolelis tbd: is it not better to have here uint_32_t type for compatibility with other 22 bits? + } st41_hdr_chunk; + /** Handle to make operating on st41_hdr_chunk buffer easier */ + uint32_t swaped_st41_hdr_chunk; + }; +}); +#endif + /** * Structure for ST2110-41(fast metadata) frame @@ -142,6 +167,11 @@ struct st41_tx_ops { enum st_fps fps; /** Mandatory. 7 bits payload type define in RFC3550 */ uint8_t payload_type; + /** Mandatory. 22 bits data item type */ + uint32_t fmd_dit; + /** Mandatory. 1 bit data item K-bit */ + uint8_t fmd_k_bit; + /** Mandatory. interlaced or not */ bool interlaced; @@ -233,6 +263,7 @@ struct st41_rx_ops { /** Optional. see ST41_RX_FLAG_* for possible flags */ uint32_t flags; + /** Mandatory. rtp ring queue size, must be power of 2 */ uint32_t rtp_ring_size; /** diff --git a/lib/src/st2110/st_fastmetadata.c b/lib/src/st2110/st_fastmetadata.c index 0886c01dc..076fdc3aa 100644 --- a/lib/src/st2110/st_fastmetadata.c +++ b/lib/src/st2110/st_fastmetadata.c @@ -5,4 +5,4 @@ #include "../mt_log.h" -//skolelis tbd remove this file if empty +// skolelis tbd: remove this file if empty diff --git a/lib/src/st2110/st_header.h b/lib/src/st2110/st_header.h index 439908362..5b4644f79 100644 --- a/lib/src/st2110/st_header.h +++ b/lib/src/st2110/st_header.h @@ -154,7 +154,7 @@ struct st_frame_trans { struct st30_tx_frame_meta ta_meta; struct st30_rx_frame_meta ra_meta; /* not use now */ struct st40_tx_frame_meta tc_meta; - struct st41_tx_frame_meta tf_meta; //skolelis TBD - field for st41 transport ? (fast meta data -> "f") !!! + struct st41_tx_frame_meta tf_meta; // skolelis tbd: - field for st41 transport ? (fast meta data -> "f") !!! }; }; diff --git a/lib/src/st2110/st_tx_fastmetadata_session.c b/lib/src/st2110/st_tx_fastmetadata_session.c index 82ff09c3d..62e055f8d 100644 --- a/lib/src/st2110/st_tx_fastmetadata_session.c +++ b/lib/src/st2110/st_tx_fastmetadata_session.c @@ -422,10 +422,10 @@ static void tx_fastmetadata_session_build_packet(struct st_tx_fastmetadata_sessi uint16_t data_item_length = (data_item_length_bytes + 3) / 4; /* expressed in number of 4-byte words */ if (!(data_item_length_bytes > s->max_pkt_len)) { - // skolelis what for we have her this htonl() ??? payload->swaped_second_hdr_chunk = htonl(payload->swaped_second_hdr_chunk); + // skolelis tbd: what for we have here this htonl() ??? payload->swaped_second_hdr_chunk = htonl(payload->swaped_second_hdr_chunk); int offset = 0; for (int i = 0; i < data_item_length_bytes; i++) { - payload[i] = src->data[offset++]; //skolelis tu ustal dobrze wskaznik na start paylodu a moze nawet 4-bajtowy? + payload[i] = src->data[offset++]; // skolelis tbd: here take care about proper pointer on paylod start and maybe even as 4-byte word ? } /* filling with 0's the remianing bytes of last 4-byte word */ for (int i = data_item_length_bytes; i < data_item_length * 4; i++) { @@ -435,8 +435,12 @@ static void tx_fastmetadata_session_build_packet(struct st_tx_fastmetadata_sessi pkt->data_len += sizeof(struct st41_rtp_hdr) + data_item_length * 4; pkt->pkt_len = pkt->data_len; - rtp->data_item_length = htons(data_item_length); //tbd skolelis what is the proper calculation? - // skolelis tbd: czy zoistawic te linie? rtp->base.marker = 1; + rtp->st41_hdr_chunk.data_item_type = s->ops.fmd_dit; + rtp->st41_hdr_chunk.data_item_k_bit = s->ops.fmd_k_bit; + rtp->st41_hdr_chunk.data_item_length = data_item_length; // skolelis tbd: I added this line without htons() (line below) + //rtp->st41_hdr_chunk.data_item_length = htons(data_item_length); // skolelis tbd: what is the proper calculation? + rtp->swaped_st41_hdr_chunk = htonl(rtp->swaped_st41_hdr_chunk); // skolelis tbd: and I added it instead of line up + // skolelis tbd: should this line be kept? rtp->base.marker = 1; dbg("%s(%d), payload_size (data_item_length_bytes) %d\n", __func__, s->idx, data_item_length_bytes); @@ -473,10 +477,10 @@ static void tx_fastmetadata_session_build_rtp_packet(struct st_tx_fastmetadata_s uint16_t data_item_length = (data_item_length_bytes + 3) / 4; /* expressed in number of 4-byte words */ if (!(data_item_length_bytes > s->max_pkt_len)) { - // skolelis what for we have her this htonl() ??? payload->swaped_second_hdr_chunk = htonl(payload->swaped_second_hdr_chunk); + // skolelis tbd: what for we have here this htonl() ??? payload->swaped_second_hdr_chunk = htonl(payload->swaped_second_hdr_chunk); int offset = 0; for (int i = 0; i < data_item_length_bytes; i++) { - payload[i] = src->data[offset++]; //skolelis tu ustal dobrze wskaznik na start paylodu a moze nawet 4-bajtowy? + payload[i] = src->data[offset++]; // skolelis tbd: here take care about proper pointer on paylod start and maybe even as 4-byte word ? } /* filling with 0's the remianing bytes of last 4-byte word */ for (int i = data_item_length_bytes; i < data_item_length * 4; i++) { @@ -486,8 +490,14 @@ static void tx_fastmetadata_session_build_rtp_packet(struct st_tx_fastmetadata_s pkt->data_len = sizeof(struct st41_rtp_hdr) + data_item_length * 4; pkt->pkt_len = pkt->data_len; - rtp->data_item_length = htons(data_item_length); //tbd skolelis what is the proper calculation? - /// skolelis tbd czy to zostawic rtp->base.marker = 1; + + rtp->st41_hdr_chunk.data_item_type = s->ops.fmd_dit; + rtp->st41_hdr_chunk.data_item_k_bit = s->ops.fmd_k_bit; + rtp->st41_hdr_chunk.data_item_length = data_item_length; // htons(data_item_length); // skolelis tbd: what is the proper calculation? + rtp->swaped_st41_hdr_chunk = htonl(rtp->swaped_st41_hdr_chunk); + + + /// skolelis tbd: should this line be kept? rtp->base.marker = 1; dbg("%s(%d), payload_size (data_item_length_bytes) %d\n", __func__, s->idx, data_item_length_bytes); @@ -518,7 +528,7 @@ static int tx_fastmetadata_session_rtp_update_packet(struct mtl_main_impl* impl, s->st41_pkt_idx = 0; rte_atomic32_inc(&s->st41_stat_frame_cnt); s->st41_rtp_time = rtp->tmstamp; - bool second_field = false; //skolelis tbd decide if it should be true or false (interlaced?) + bool second_field = false; // skolelis tbd: decide if it should be true or false (interlaced?) tx_fastmetadata_session_sync_pacing(impl, s, false, 0, second_field); } @@ -571,7 +581,7 @@ static int tx_fastmetadata_session_build_packet_chain(struct mtl_main_impl* impl s->st41_pkt_idx = 0; rte_atomic32_inc(&s->st41_stat_frame_cnt); s->st41_rtp_time = rtp->base.tmstamp; - bool second_field = false; // skolelis tbd decide if true or false (interlaced)? + bool second_field = false; // skolelis tbd: decide if true or false (interlaced)? tx_fastmetadata_session_sync_pacing(impl, s, false, 0, second_field); } if (s->ops.flags & ST41_TX_FLAG_USER_TIMESTAMP) { @@ -669,7 +679,7 @@ static int tx_fastmetadata_session_tasklet_frame(struct mtl_main_impl* impl, return MTL_TASKLET_ALL_DONE; } } - + if (ST41_TX_STAT_WAIT_FRAME == s->st41_frame_stat) { uint16_t next_frame_idx; int data_item_length_bytes = 0; @@ -732,7 +742,7 @@ static int tx_fastmetadata_session_tasklet_frame(struct mtl_main_impl* impl, MT_USDT_ST41_TX_FRAME_NEXT(s->mgr->idx, s->idx, next_frame_idx, frame->addr, 0, data_item_length_bytes); } - + /* sync pacing */ if (s->calculate_time_cursor) { struct st_frame_trans* frame = &s->st41_frames[s->st41_frame_idx]; @@ -789,6 +799,7 @@ static int tx_fastmetadata_session_tasklet_frame(struct mtl_main_impl* impl, s->stat_build_ret_code = -STI_FRAME_PKT_ALLOC_FAIL; return MTL_TASKLET_ALL_DONE; } + tx_fastmetadata_session_build_rtp_packet(s, pkt_rtp); tx_fastmetadata_session_build_packet_chain(impl, s, pkt, pkt_rtp, MTL_SESSION_PORT_P); @@ -1662,7 +1673,7 @@ static int tx_fastmetadata_sessions_mgr_init(struct mtl_main_impl* impl, struct mtl_tasklet_ops ops; int i; - RTE_BUILD_BUG_ON(sizeof(struct st41_fmd_hdr) != 58); //skolelis tbd used to be 62 for ANC, and IMHO should be 58!!! + RTE_BUILD_BUG_ON(sizeof(struct st41_fmd_hdr) != 58); // skolelis tbd: used to be 62 for ANC, and IMHO should be 58!!! mgr->parent = impl; mgr->idx = idx;