mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2024-11-29 23:11:01 +00:00
Add timestamp/timecode into ReferenceTimestampMeta on every buffer
This commit is contained in:
parent
fabcc65460
commit
a4890d3295
4 changed files with 56 additions and 1 deletions
|
@ -19,8 +19,9 @@ byte-slice-cast = "0.2.0"
|
|||
gst-plugin-version-helper = "0.1"
|
||||
|
||||
[features]
|
||||
default = ["interlaced-fields"]
|
||||
default = ["interlaced-fields", "reference-timestamps"]
|
||||
interlaced-fields = ["gstreamer/v1_16", "gstreamer-video/v1_16"]
|
||||
reference-timestamps = ["gstreamer/v1_14"]
|
||||
|
||||
[lib]
|
||||
name = "gstndi"
|
||||
|
|
10
src/lib.rs
10
src/lib.rs
|
@ -48,6 +48,16 @@ lazy_static! {
|
|||
let m = HashMap::new();
|
||||
Mutex::new(m)
|
||||
};
|
||||
|
||||
#[cfg(feature = "reference-timestamps")]
|
||||
static ref TIMECODE_CAPS: gst::Caps = {
|
||||
gst::Caps::new_simple("timestamp/x-ndi-timecode", &[])
|
||||
};
|
||||
|
||||
#[cfg(feature = "reference-timestamps")]
|
||||
static ref TIMESTAMP_CAPS: gst::Caps = {
|
||||
gst::Caps::new_simple("timestamp/x-ndi-timestamp", &[])
|
||||
};
|
||||
}
|
||||
|
||||
static ID_RECEIVER: AtomicUsize = AtomicUsize::new(0);
|
||||
|
|
|
@ -18,6 +18,10 @@ use ndisys;
|
|||
use stop_ndi;
|
||||
|
||||
use HASHMAP_RECEIVERS;
|
||||
#[cfg(feature = "reference-timestamps")]
|
||||
use TIMECODE_CAPS;
|
||||
#[cfg(feature = "reference-timestamps")]
|
||||
use TIMESTAMP_CAPS;
|
||||
|
||||
use byte_slice_cast::AsMutSliceOf;
|
||||
|
||||
|
@ -400,6 +404,24 @@ impl BaseSrcImpl for NdiAudioSrc {
|
|||
buffer.set_pts(pts);
|
||||
buffer.set_duration(duration);
|
||||
|
||||
#[cfg(feature = "reference-timestamps")]
|
||||
{
|
||||
gst::ReferenceTimestampMeta::add(
|
||||
buffer,
|
||||
&*TIMECODE_CAPS,
|
||||
gst::ClockTime::from(audio_frame.timecode() as u64 * 100),
|
||||
gst::CLOCK_TIME_NONE,
|
||||
);
|
||||
if audio_frame.timestamp() != ndisys::NDIlib_recv_timestamp_undefined {
|
||||
gst::ReferenceTimestampMeta::add(
|
||||
buffer,
|
||||
&*TIMESTAMP_CAPS,
|
||||
gst::ClockTime::from(audio_frame.timestamp() as u64 * 100),
|
||||
gst::CLOCK_TIME_NONE,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
audio_frame.copy_to_interleaved_16s(
|
||||
buffer
|
||||
.map_writable()
|
||||
|
|
|
@ -21,6 +21,10 @@ use connect_ndi;
|
|||
use stop_ndi;
|
||||
|
||||
use HASHMAP_RECEIVERS;
|
||||
#[cfg(feature = "reference-timestamps")]
|
||||
use TIMECODE_CAPS;
|
||||
#[cfg(feature = "reference-timestamps")]
|
||||
use TIMESTAMP_CAPS;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
struct Settings {
|
||||
|
@ -497,6 +501,24 @@ impl BaseSrcImpl for NdiVideoSrc {
|
|||
buffer.set_pts(pts);
|
||||
buffer.set_duration(duration);
|
||||
|
||||
#[cfg(feature = "reference-timestamps")]
|
||||
{
|
||||
gst::ReferenceTimestampMeta::add(
|
||||
buffer,
|
||||
&*TIMECODE_CAPS,
|
||||
gst::ClockTime::from(video_frame.timecode() as u64 * 100),
|
||||
gst::CLOCK_TIME_NONE,
|
||||
);
|
||||
if video_frame.timestamp() != ndisys::NDIlib_recv_timestamp_undefined {
|
||||
gst::ReferenceTimestampMeta::add(
|
||||
buffer,
|
||||
&*TIMESTAMP_CAPS,
|
||||
gst::ClockTime::from(video_frame.timestamp() as u64 * 100),
|
||||
gst::CLOCK_TIME_NONE,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "interlaced-fields")]
|
||||
{
|
||||
match video_frame.frame_format_type() {
|
||||
|
|
Loading…
Reference in a new issue