RTCP 发送方报告中的 NTP 时间戳不正确

问题描述 投票:0回答:2

我正在使用 Amazon 的示例代码将 rtsp 流从 IP 摄像头上传到 Kinesis 视频流。代码在这里找到:https://github.com/awslabs/amazon-kinesis-video-streams- Producer-sdk-cpp/blob/master/samples/kvs_gstreamer_sample.cpp

我想从相机获取每一帧的 NTP 时间。我的理解是,执行此操作的第一步是读取 RTCP 发送器报告以获取相机 RTP 和 NTP 时间的同步时间。

为此,我添加了接收 RTCP 数据包的回调,如下所示:

g_signal_connect_after(session, "on-receiving-rtcp", G_CALLBACK(on_rtcp_callback), data);

然后,在从缓冲区获取 SR 数据包后的回调函数中,我尝试获取两个时间戳:

gst_rtcp_packet_sr_get_sender_info (packet, ssrc, ntptime, rtptime, packet_count, octet_count);

将我在这里得到的“ntptime”和“rtptime”变量与我在 Wireshark 中看到的变量进行比较时,rtp 时间完全匹配。然而,我在 C++ 代码中获得的 NTP 时间非常错误,它显示了大约一个月前的时间,而 Wireshark 数据包显示的 NTP 时间似乎是正确的。

是否有某些设置导致 gstreamer 覆盖我的发件人报告数据包中的 NTP 时间,如果是,如何禁用该设置?

c++ gstreamer amazon-kinesis-video-streams rtcp
2个回答
1
投票

事实证明,gst_rtcp_packet_sr_get_sender_info 提供的 NTP 时间不是我以前见过的任何格式。要转换为有意义的时间戳,您必须使用 gst_rtcp_ntp_to_unix ,然后它会给您一个实际上有意义的 unix 时间。


0
投票

假设

gst_rtcp_packet_sr_get_sender_info
函数不提供直接的NTP时钟值,而是提供guint32+guint32字节(time_s +分数)。

以防万一,我将分享这段简短的代码片段,它可能有助于其他人将这些字节转换为纳秒 UTC 时间。

#include <gst/rtp/gstrtcpbuffer.h>
...
GstClockTime ntp_epoch_ns = gst_rtcp_ntp_to_unix(rtcp_sr_ntp);
© www.soinside.com 2019 - 2024. All rights reserved.