UDP 上的 RTP 扩展报头

RTP Extension Headers over UDP

我正在尝试使用 gstreamer 通过 UDP 发送带有特定元数据的图像。 sender 进程从相机抓取图像,并将它们作为 appsrc ! rtpvrawpay ! udpsink 在管道中发送(下面是完整的管道字符串,以防它很重要)。在接收方,我使用 udpsrc ! rtpvrawdepay ! appsink.

为了添加元数据,我在 rtpvrawpay 的 Source Pad 上放置了一个探针,并在 rtpvrawdepay 的 Sink Pad 上读取 - 探针。目前我遇到的问题:

  1. “源”探测器接收 GST_PAD_PROBE_TYPE_BUFFER_LIST 数据,而“接收器”探测器 - GST_PAD_PROBE_TYPE_BUFFER。我希望我会在 UDP 的两端获得相同的数据类型,那为什么不呢?
  2. 我未能读取发件人添加的 twobytes_header,在尝试 gst_rtp_buffer_map 探测器中的缓冲区时它已经失败了。 UPDATE: 成功读取接收端的头部信息,见下面的代码。仍然想了解为什么我在两个探测位置上看到 Buffer List VS Buffer

将不胜感激任何见解,或者可能是通过 UDP 发送带有图像的元数据的更好方向。

发件人管道:appsrc ! videoconvert ! queue ! rtpvrawpay name=ToRTP ! queue ! udpsink host=192.168.42.49 port=5566 sync=false async=false

接收管道:udpsrc port=5566 caps="application/x-rtp, media=(string)video, sampling=(string)BGR, clock-rate=(int)90000, depth=(string)8, width=(string)640, height=(string)480, encoding-name=(string)RAW" ! rtpvrawdepay name=FromRTP ! queue ! videoconvert ! appsink

更新:对我有用的代码:

发件人代码:

GstRTPBuffer rtp_buf = GST_RTP_BUFFER_INIT;
gst_rtp_buffer_map(*buffer, GST_MAP_READWRITE, &rtp_buf);
gst_rtp_buffer_add_extension_twobytes_header(&rtp_buf, 1, 1, myInfo->buf, sizeof(myInfo->buf));
gst_rtp_buffer_unmap(&rtp_buf);

收件人代码:

GstRTPBuffer rtp_buf = GST_RTP_BUFFER_INIT;
GstBuffer* buf = GST_PAD_PROBE_INFO_BUFFER(info);
gst_rtp_buffer_map(buf, GST_MAP_READ, &rtp_buf);
gpointer myInfoBuf = nullptr;
guint size         = 0;
gst_rtp_buffer_get_extension_twobytes_header(&rtp_buf, &appbits, 1, 0, &myInfoBuf, &size);
gst_rtp_buffer_unmap(&rtp_buf);

The "source" probe receives GST_PAD_PROBE_TYPE_BUFFER_LIST data, while the "sink" probe - GST_PAD_PROBE_TYPE_BUFFER. I would expect that I will get the same data type on both sides of UDP, so why it's not?

在发送方,这取决于通过 RTP 有效载荷的数据类型:适合有效载荷的 MTU 配置的小数据包(例如音频或小视频帧)将触发 GST_PAD_PROBE_TYPE_BUFFER 探测而超过 MTU 的数据包将被拆分成一个数据包列表并触发 GST_PAD_PROBE_TYPE_BUFFER_LIST 探测。

在接收器上,您在 RTP depayloader 接收器垫上的探测总是从 UDP 源接收单个数据包,在这种情况下 GST_PAD_PROBE_TYPE_BUFFER 适用。