Timestamping is now handled by respective base classes (src / sink) + new raw nodes#82
Conversation
03b800f to
5712ada
Compare
|
I've updated the PR to include raw nodes used for metadata transport together with a new message type mostly because the string node's message does not have header / timestamp information. |
|
This is great, I'll have to draw out some diagrams to get my head around the new timestamp options; the conversions between ntp and unix don't seem fully consistent between src and sink
yes, those were intended to interact with text-to-speech and subtitle systems, and are probably due for revisiting. Your choice to introduce a stamped blob message is extremely welcome. Is there any reason not to set the default rosrawsrc and rosrawsink caps to Would it make sense to deduce the ntp/unix conversion mode from the caps of the GstReferenceTimestampMeta? ie "timestamp/x-ntp" vs "timestamp/x-unix" I don't fully understand the utility of |
|
Hi! Awesome, thanks for the review.
I agree. At the moment, the only reason why that option was added was because when using onvif-mode=1 the PTS of the receiver will be in NTP which requires a conversion to Unix when dumping it back to ROS. I will need to look up what happens if different clocks are used. It is, however, implied that any timestamp coming from ROS is Unix so I could add a new parameter to override it.
No, mostly convenience for the use-case presented, but there is no preference here. I will change it.
I don't understand the use case here. Currently, the conversion is explicit, in the sense that if you know the used timestamps but want a different one, you can force a conversion of NTP -> Unix (no other currently added since I had no other use cases). But you don't have to convert, you can use the clocks as is, meaning if the reference timestamp is already in the type you want, you can just use "timestamp-mode=reference" and leave the conversion to none. What I could see potentially being useful is setting the desired clock-end type and try to deduce the conversion if one is needed, but I do not know how feasible this is.
This was added because onvif-mode will set the PTS to the timestamps sent in the onvif extended headers :(. Don't know if there is a different way to tackle it. |
|
Timestamps and clocking easy to get wrong in gstreamer, and they lead to subtle bugs. there are already too many timestamp config gotchas in this repo that can cause the pipeline to silently hang, and that's not fair on my users.
It's generally unsafe to assume that rostime is unixtime because gazebo can override it using the
GstReferenceTimestampMeta struct suggests the use of the caps string to specify the nature of the clock
This convention allows us to specify the epoch and protocol of the clock, including allowing us to specify that the timestamp is a raw rostime from a specific host by saying something like
Setting PTS to onvif timestamp requires that the pipeline time is driven by whatever is decoding the onvif stream, otherwise the pipeline will hang when a user adds a live sink. |
|
I've added a new property to rosbasesrc.cpp for manually setting the clock caps and set the default to I've also set the default caps of rosrawsrc to
Yep, totally agree, and I ran into this issue a fair bit of times while working with ONVIF since it sets the PTS on the receiver. Don't really have ideas here on how to improve the situation. My default is always to build from source and inspect / debug, but I understand that is not something others are comfortable doing. If you have any ideas on what helped overcome these issues, let me know and I can implement them.
Hopefully this is addressed by the new property
Currently, I do not have a use case for a GstReferenceTimestampMeta where I read the same caps that I set. My use-case is destructive in this sense. For the "server"
Indeed, this is an issue and that is why I need to use |
|
@BrettRD Does this address your concerns or is there anything else you'd like changed? |
Timestamp propagation (configurable) + raw metadata src/sink (
rosrawsrc,rosrawsink) + base-class timestamping refactor.TL;DR
timestamp-mode=ros-offset(default) |reference|ptstimestamp-conversion-mode=none(default) |ntp2unixrosrawsrcandrosrawsinkusinggst_msgs/StreamStampedDatarosimagesrc,rostextsrc) now stamp buffers via a shared helper that can also attach reference timestamp meta (attach-reference-timestamp).time-capsMotivation
GstReferenceTimestampMeta. Making this configurable lets pipelines pick the right truth source.rosrawsrc/sinkprovide a clean, typed way to move these bytes between ROS and GStreamer, keeping the door open for sync with video.What’s in this MR
1) Sink-side timestamping is configurable (base class)
New properties on all ROS sinks (via
RosBaseSink):timestamp-mode(ros-offset|reference|pts)ros-offset(default): previous behavior (ROS clock → PTS adjusted by base time and ROS clock offset).reference: take the time fromGstReferenceTimestampMeta(if present).pts: use the buffer PTS verbatim.timestamp-conversion-mode(none|ntp2unix)2) Source-side stamping & optional reference meta attachment (base class)
New property on all ROS sources (via
RosBaseSrc):attach-reference-timestamp(bool, defaultfalse)true, the source attachesGstReferenceTimestampMetawith capstimestamp/x-unixand the message time.set_timestamps(...)so sources don’t duplicate logic.3) New raw metadata bridge
Elements:
rosrawsrc(caps:application/x-onvif-metadata, format=xml, type=metadata)GstBuffers.rosrawsink(caps:application/x-onvif-metadata)GstBuffers and publishes a ROS raw byte stream.Message type:
Introduces
gst_msgs/StreamStampedDatarosrawsrc/sinkusegst_msgs::msg::StreamStampedData(with header timestamps).How it fits together (common scenarios)
A) RTSP/ONVIF pipeline using reference timestamps
attach-reference-timestamp=trueonros*srcto attachtimestamp/x-unixmeta.timestamp-mode=reference.timestamp-conversion-mode=ntp2unix. If your reference meta is already UNIX (e.g., fromros*srcwithattach-reference-timestamp=true), keeptimestamp-conversion-mode=none.B) PTS-driven stamping (e.g.,
rtponvifparseput the authoritative clock in PTS)timestamp-mode=pts, typically withtimestamp-conversion-mode=ntp2unix.C) Legacy/default behavior
timestamp-mode=ros-offset+timestamp-conversion-mode=none.Example
RTSP server (video) with reference timestamps and metadata
Client version
gst-launch-1.0 \ rtspsrc location=rtsp://localhost:8554/test_video \ onvif-mode=1 onvif-rate-control=0 latency=200 \ buffer-mode=0 ntp-sync=false name=src \ \ src. ! application/x-rtp,media=application,encoding-name=VND.ONVIF.METADATA \ ! queue \ ! rtponvifparse \ ! rtponvifmetadatadepay \ ! queue \ ! rosrawsink ros-topic=/received/meta_raw \ timestamp-mode=pts \ timestamp-conversion-mode=ntp2unix \ sync=false \ \ src. ! application/x-rtp,media=video \ ! queue \ ! rtponvifparse \ ! rtph264depay \ ! avdec_h264 \ ! videoconvert \ ! timeoverlay time-mode=0 show-times-as-dates=true \ datetime-format="%d.%m.%Y %H:%M:%S.%f" \ halignment=right valignment=bottom \ ! rosimagesink ros-topic=/received/image \ timestamp-mode=pts \ timestamp-conversion-mode=ntp2unix \ sync=falseCompatibility & defaults
timestamp-mode=ros-offset,timestamp-conversion-mode=none,attach-reference-timestamp=false.gst_buffer_add_reference_timestamp_metaworks on 1.18+ (so sources can attach meta).rtspsrcto inject reference meta, the convenient property is 1.20+. Not required when sources attach meta themselves.