Skip to content

Commit dd61100

Browse files
Add: GStreamer plugin 8331 input support (#1159)
Add support for 8331 adjacent ancillary data input for the GStreamer st40 ancillary data plugin. Which allows the user to take input from https://www.[ietf.org/rfc/rfc8331.html](https://www.ietf.org/rfc/rfc8331.html) Starting ANC_Count and ending with word_align. Add support for buffer size for UDW support that allows the user to change the size of the buffers, set it to the maximum by default as the wasted size of appropriately 2kb * framebuffer count is acceptable. Change the st40p api to hide the metadata, which should be clearer for users. Refactor: Isolate the parsing of data into gst_mtl_st40p_tx_parse_* functions. Fix the issue with the GST buffer size being taken from the whole GstBuffer instead of the mapped GstMemory.
1 parent 1954564 commit dd61100

File tree

14 files changed

+457
-94
lines changed

14 files changed

+457
-94
lines changed

ecosystem/gstreamer_plugin/README.md

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -395,14 +395,19 @@ The `mtl_st40p_tx` plugin supports all pad capabilities (the data is not checked
395395
- **Capabilities**: Any (GST_STATIC_CAPS_ANY)
396396
397397
**Arguments**
398-
| Property Name | Type | Description | Range | Default Value |
399-
|--------------------|----------|--------------------------------------------------------------------|---------------|---------------|
400-
| tx-framebuff-cnt | uint | Number of framebuffers to be used for transmission. | 0 to G_MAXUINT| 3 |
401-
| tx-fps | uint | Framerate of the video to which the ancillary data is synchronized.| [Supported video fps fractions](#231-supported-video-fps-fractions) | 25/1 |
402-
| tx-did | uint | Data ID for the ancillary data. | 0 to 255 | 0 |
403-
| tx-sdid | uint | Secondary Data ID for the ancillary data. | 0 to 255 | 0 |
404-
| use-pts-for-pacing | gboolean | [User controlled timestamping offset](#233-pts-controlled-pacing) | 0 to G_MAXUINT | 0 |
405-
| pts-pacing-offset | uint | [User controlled timestamping offset](#233-pts-controlled-pacing) | 0 to G_MAXUINT | 0 |
398+
| Property Name | Type | Description | Range | Default Value |
399+
|-----------------------|----------|--------------------------------------------------------------------|------------------|---------------|
400+
| tx-framebuff-cnt | uint | Number of framebuffers to be used for transmission. | 0 to G_MAXUINT | 3 |
401+
| tx-fps | uint | Framerate of the video to which the ancillary data is synchronized.| [Supported vid eo fps fractions](#231-supported-video-fps-fractions) | 25/1 |
402+
| tx-did | uint | Data ID for the ancillary data. | 0 to 255 | 0 |
403+
| tx-sdid | uint | Secondary Data ID for the ancillary data. | 0 to 255 | 0 |
404+
| use-pts-for-pacing | gboolean | [User controlled timestamping offset](#233-pts-controlled-pacing) | TRUE/FALSE | FALSE |
405+
| pts-pacing-offset | uint | [User controlled timestamping offset](#233-pts-controlled-pacing) | 0 to G_MAXUINT | 0 |
406+
| parse-8331-meta | gboolean | Treat the input as rfc8331 payload data | TRUE/FALSE | FALSE |
407+
| max-combined-udw-size | uint | Maximum combined size of all user data words to send in one buffer | 0 to (20 * 255) | 20 * 255 |
408+
409+
> **Note:**
410+
> If `parse-8331-meta` is not enabled, only one ANC packet per frame is supported. It is recommended to limit the `max-combined-udw-size` if you are only using this option, since by default `max-combined-udw-size` is set to its maximum value.
406411
407412
#### 5.1.2. Example GStreamer Pipeline for Transmission
408413

ecosystem/gstreamer_plugin/gst_mtl_st20p_tx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ static GstFlowReturn gst_mtl_st20p_tx_chain(GstPad* pad, GstObject* parent,
507507
frame->tfmt = ST10_TIMESTAMP_FMT_TAI;
508508
}
509509

510-
mtl_memcpy(frame->addr[0], map_info.data, buffer_size);
510+
memcpy(frame->addr[0], map_info.data, buffer_size);
511511
gst_memory_unmap(gst_buffer_memory, &map_info);
512512
st20p_tx_put_frame(sink->tx_handle, frame);
513513
}

ecosystem/gstreamer_plugin/gst_mtl_st30p_tx.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -546,12 +546,12 @@ static GstFlowReturn gst_mtl_st30p_tx_chain(GstPad* pad, GstObject* parent,
546546
cur_addr_buf = map_info.data + gst_buffer_get_size(buf) - bytes_to_write;
547547

548548
if (sink->cur_frame_available_size > bytes_to_write) {
549-
mtl_memcpy(cur_addr_frame, cur_addr_buf, bytes_to_write);
549+
memcpy(cur_addr_frame, cur_addr_buf, bytes_to_write);
550550
sink->cur_frame_available_size -= bytes_to_write;
551551
bytes_to_write = 0;
552552
break;
553553
} else {
554-
mtl_memcpy(cur_addr_frame, cur_addr_buf, sink->cur_frame_available_size);
554+
memcpy(cur_addr_frame, cur_addr_buf, sink->cur_frame_available_size);
555555

556556
// By default, timestamping is handled by MTL.
557557
if (sink->use_pts_for_pacing) {

ecosystem/gstreamer_plugin/gst_mtl_st40_rx.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -375,16 +375,16 @@ static void* gst_mtl_st40_rx_get_mbuf_with_timeout(Gst_Mtl_St40_Rx* src,
375375
static GstFlowReturn gst_mtl_st40_rx_fill_buffer(Gst_Mtl_St40_Rx* src, GstBuffer** buffer,
376376
void* usrptr) {
377377
struct st40_rfc8331_rtp_hdr* hdr;
378-
struct st40_rfc8331_payload_hdr* payload_hdr;
378+
struct st40_rfc8331_payload_hdr *payload_hdr, payload_hdr_swapped;
379379
GstMapInfo dest_info;
380380
guint16 data, fill_size;
381381
gint udw_size;
382382

383383
hdr = (struct st40_rfc8331_rtp_hdr*)usrptr;
384384
payload_hdr = (struct st40_rfc8331_payload_hdr*)(&hdr[1]);
385-
payload_hdr->swaped_second_hdr_chunk = ntohl(payload_hdr->swaped_second_hdr_chunk);
386-
udw_size = payload_hdr->second_hdr_chunk.data_count & 0xff;
387-
payload_hdr->swaped_second_hdr_chunk = htonl(payload_hdr->swaped_second_hdr_chunk);
385+
payload_hdr_swapped.swapped_second_hdr_chunk =
386+
ntohl(payload_hdr->swapped_second_hdr_chunk);
387+
udw_size = payload_hdr_swapped.second_hdr_chunk.data_count & 0xff;
388388

389389
if (udw_size == 0) {
390390
GST_ERROR("Ancillary data size is 0");
@@ -398,6 +398,7 @@ static GstFlowReturn gst_mtl_st40_rx_fill_buffer(Gst_Mtl_St40_Rx* src, GstBuffer
398398
free(src->anc_data);
399399
src->anc_data = NULL;
400400
}
401+
401402
src->udw_size = udw_size;
402403
src->anc_data = (char*)malloc(udw_size);
403404
}

0 commit comments

Comments
 (0)