onvif: Rename onvif(de)pay to rtponvifmetadata(de)pay and include the metadata specifier in the other element names too

This is more descriptive and avoids any future conflicts with other
kinds of ONVIF specific RTP (de)payloaders.
This commit is contained in:
Sebastian Dröge 2022-08-25 14:16:37 +03:00
parent e391f1ef25
commit 420f36251a
10 changed files with 214 additions and 73 deletions

View file

@ -4404,6 +4404,80 @@
},
"rank": "primary"
},
"onvifmetadatacombiner": {
"author": "Mathieu Duponchelle <mathieu@centricular.com>",
"description": "ONVIF metadata combiner",
"hierarchy": [
"GstOnvifMetadataCombiner",
"GstAggregator",
"GstElement",
"GstObject",
"GInitiallyUnowned",
"GObject"
],
"klass": "Video/Metadata/Combiner/Muxer",
"long-name": "ONVIF metadata combiner",
"pad-templates": {
"media": {
"caps": "ANY",
"direction": "sink",
"presence": "always",
"type": "GstAggregatorPad"
},
"meta": {
"caps": "application/x-onvif-metadata:\n parsed: true\n",
"direction": "sink",
"presence": "always",
"type": "GstAggregatorPad"
},
"src": {
"caps": "ANY",
"direction": "src",
"presence": "always"
}
},
"rank": "primary"
},
"onvifmetadataoverlay": {
"author": "Mathieu Duponchelle <mathieu@centricular.com>",
"description": "Renders ONVIF analytics meta over raw video frames",
"hierarchy": [
"GstOnvifMetadataOverlay",
"GstElement",
"GstObject",
"GInitiallyUnowned",
"GObject"
],
"klass": "Video/Overlay",
"long-name": "ONVIF Metadata overlay",
"pad-templates": {
"sink": {
"caps": "video/x-raw:\n format: { ABGR64_LE, BGRA64_LE, AYUV64, ARGB64_LE, ARGB64, RGBA64_LE, ABGR64_BE, BGRA64_BE, ARGB64_BE, RGBA64_BE, GBRA_12LE, GBRA_12BE, Y412_LE, Y412_BE, A444_10LE, GBRA_10LE, A444_10BE, GBRA_10BE, A422_10LE, A422_10BE, A420_10LE, A420_10BE, RGB10A2_LE, BGR10A2_LE, Y410, GBRA, ABGR, VUYA, BGRA, AYUV, ARGB, RGBA, A420, AV12, Y444_16LE, Y444_16BE, v216, P016_LE, P016_BE, Y444_12LE, GBR_12LE, Y444_12BE, GBR_12BE, I422_12LE, I422_12BE, Y212_LE, Y212_BE, I420_12LE, I420_12BE, P012_LE, P012_BE, Y444_10LE, GBR_10LE, Y444_10BE, GBR_10BE, r210, I422_10LE, I422_10BE, NV16_10LE32, Y210, v210, UYVP, I420_10LE, I420_10BE, P010_10LE, NV12_10LE32, NV12_10LE40, P010_10BE, NV12_10BE_8L128, Y444, RGBP, GBR, BGRP, NV24, xBGR, BGRx, xRGB, RGBx, BGR, IYU2, v308, RGB, Y42B, NV61, NV16, VYUY, UYVY, YVYU, YUY2, I420, YV12, NV21, NV12, NV12_8L128, NV12_64Z32, NV12_4L4, NV12_32L32, NV12_16L32S, Y41B, IYU1, YVU9, YUV9, RGB16, BGR16, RGB15, BGR15, RGB8P, GRAY16_LE, GRAY16_BE, GRAY10_LE32, GRAY8 }\n width: [ 1, 2147483647 ]\n height: [ 1, 2147483647 ]\n framerate: [ 0/1, 2147483647/1 ]\n",
"direction": "sink",
"presence": "always"
},
"src": {
"caps": "video/x-raw:\n format: { ABGR64_LE, BGRA64_LE, AYUV64, ARGB64_LE, ARGB64, RGBA64_LE, ABGR64_BE, BGRA64_BE, ARGB64_BE, RGBA64_BE, GBRA_12LE, GBRA_12BE, Y412_LE, Y412_BE, A444_10LE, GBRA_10LE, A444_10BE, GBRA_10BE, A422_10LE, A422_10BE, A420_10LE, A420_10BE, RGB10A2_LE, BGR10A2_LE, Y410, GBRA, ABGR, VUYA, BGRA, AYUV, ARGB, RGBA, A420, AV12, Y444_16LE, Y444_16BE, v216, P016_LE, P016_BE, Y444_12LE, GBR_12LE, Y444_12BE, GBR_12BE, I422_12LE, I422_12BE, Y212_LE, Y212_BE, I420_12LE, I420_12BE, P012_LE, P012_BE, Y444_10LE, GBR_10LE, Y444_10BE, GBR_10BE, r210, I422_10LE, I422_10BE, NV16_10LE32, Y210, v210, UYVP, I420_10LE, I420_10BE, P010_10LE, NV12_10LE32, NV12_10LE40, P010_10BE, NV12_10BE_8L128, Y444, RGBP, GBR, BGRP, NV24, xBGR, BGRx, xRGB, RGBx, BGR, IYU2, v308, RGB, Y42B, NV61, NV16, VYUY, UYVY, YVYU, YUY2, I420, YV12, NV21, NV12, NV12_8L128, NV12_64Z32, NV12_4L4, NV12_32L32, NV12_16L32S, Y41B, IYU1, YVU9, YUV9, RGB16, BGR16, RGB15, BGR15, RGB8P, GRAY16_LE, GRAY16_BE, GRAY10_LE32, GRAY8 }\n width: [ 1, 2147483647 ]\n height: [ 1, 2147483647 ]\n framerate: [ 0/1, 2147483647/1 ]\n",
"direction": "src",
"presence": "always"
}
},
"properties": {
"font-desc": {
"blurb": "Pango font description of font to be used for rendering",
"conditionally-available": false,
"construct": false,
"construct-only": false,
"controllable": false,
"default": "monospace 12",
"mutable": "null",
"readable": true,
"type": "gchararray",
"writable": true
}
},
"rank": "primary"
},
"onvifmetadataparse": {
"author": "Sebastian Dröge <sebastian@centricular.com>",
"description": "Parses ONVIF Timed XML Metadata",
@ -4513,6 +4587,60 @@
},
"rank": "primary"
},
"rtponvifmetadatadepay": {
"author": "Mathieu Duponchelle <mathieu@centricular.com>",
"description": "ONVIF metadata RTP depayloader",
"hierarchy": [
"GstOnvifMetadataDepay",
"GstRTPBaseDepayload",
"GstElement",
"GstObject",
"GInitiallyUnowned",
"GObject"
],
"klass": "Depayloader/Network/RTP",
"long-name": "ONVIF metadata RTP depayloader",
"pad-templates": {
"sink": {
"caps": "application/x-rtp:\n media: application\n payload: [ 96, 127 ]\n clock-rate: 90000\n encoding-name: VND.ONVIF.METADATA\n",
"direction": "sink",
"presence": "always"
},
"src": {
"caps": "application/x-onvif-metadata:\n",
"direction": "src",
"presence": "always"
}
},
"rank": "primary"
},
"rtponvifmetadatapay": {
"author": "Mathieu Duponchelle <mathieu@centricular.com>",
"description": "ONVIF metadata RTP payloader",
"hierarchy": [
"GstOnvifMetadataPay",
"GstRTPBasePayload",
"GstElement",
"GstObject",
"GInitiallyUnowned",
"GObject"
],
"klass": "Payloader/Network/RTP",
"long-name": "ONVIF metadata RTP payloader",
"pad-templates": {
"sink": {
"caps": "application/x-onvif-metadata:\n",
"direction": "sink",
"presence": "always"
},
"src": {
"caps": "application/x-rtp:\n media: application\n payload: [ 96, 127 ]\n clock-rate: 90000\n encoding-name: VND.ONVIF.METADATA\n",
"direction": "src",
"presence": "always"
}
},
"rank": "primary"
},
"rtponvifpay": {
"author": "Mathieu Duponchelle <mathieu@centricular.com>",
"description": "ONVIF metadata RTP payloader",

View file

@ -15,11 +15,11 @@
use gst::glib;
use once_cell::sync::Lazy;
mod onvifaggregator;
mod onvifdepay;
mod onvifmetadatacombiner;
mod onvifmetadatadepay;
mod onvifmetadataoverlay;
mod onvifmetadataparse;
mod onvifoverlay;
mod onvifpay;
mod onvifmetadatapay;
// Offset in nanoseconds from midnight 01-01-1900 (prime epoch) to
// midnight 01-01-1970 (UNIX epoch)
@ -106,10 +106,10 @@ pub(crate) fn iterate_video_analytics_frames(
}
fn plugin_init(plugin: &gst::Plugin) -> Result<(), glib::BoolError> {
onvifpay::register(plugin)?;
onvifdepay::register(plugin)?;
onvifaggregator::register(plugin)?;
onvifoverlay::register(plugin)?;
onvifmetadatapay::register(plugin)?;
onvifmetadatadepay::register(plugin)?;
onvifmetadatacombiner::register(plugin)?;
onvifmetadataoverlay::register(plugin)?;
onvifmetadataparse::register(plugin)?;
gst::meta::CustomMeta::register("OnvifXMLFrameMeta", &[], |_, _, _, _| true);

View file

@ -16,7 +16,7 @@ struct State {
current_media_buffer: Option<gst::Buffer>,
}
pub struct OnvifAggregator {
pub struct OnvifMetadataCombiner {
// Input media stream, can be anything with a reference timestamp meta
media_sink_pad: gst_base::AggregatorPad,
// Input metadata stream, must be complete VideoAnalytics XML documents
@ -27,16 +27,16 @@ pub struct OnvifAggregator {
static CAT: Lazy<gst::DebugCategory> = Lazy::new(|| {
gst::DebugCategory::new(
"onvifaggregator",
"onvifmetadatacombiner",
gst::DebugColorFlags::empty(),
Some("ONVIF metadata / video aggregator"),
Some("ONVIF metadata / video combiner"),
)
});
#[glib::object_subclass]
impl ObjectSubclass for OnvifAggregator {
const NAME: &'static str = "GstOnvifAggregator";
type Type = super::OnvifAggregator;
impl ObjectSubclass for OnvifMetadataCombiner {
const NAME: &'static str = "GstOnvifMetadataCombiner";
type Type = super::OnvifMetadataCombiner;
type ParentType = gst_base::Aggregator;
fn with_class(klass: &Self::Class) -> Self {
@ -57,7 +57,7 @@ impl ObjectSubclass for OnvifAggregator {
}
}
impl ObjectImpl for OnvifAggregator {
impl ObjectImpl for OnvifMetadataCombiner {
fn constructed(&self, obj: &Self::Type) {
self.parent_constructed(obj);
@ -66,15 +66,15 @@ impl ObjectImpl for OnvifAggregator {
}
}
impl GstObjectImpl for OnvifAggregator {}
impl GstObjectImpl for OnvifMetadataCombiner {}
impl ElementImpl for OnvifAggregator {
impl ElementImpl for OnvifMetadataCombiner {
fn metadata() -> Option<&'static gst::subclass::ElementMetadata> {
static ELEMENT_METADATA: Lazy<gst::subclass::ElementMetadata> = Lazy::new(|| {
gst::subclass::ElementMetadata::new(
"ONVIF metadata aggregator",
"Aggregator",
"ONVIF metadata aggregator",
"ONVIF metadata combiner",
"Video/Metadata/Combiner/Muxer",
"ONVIF metadata combiner",
"Mathieu Duponchelle <mathieu@centricular.com>",
)
});
@ -135,7 +135,7 @@ impl ElementImpl for OnvifAggregator {
gst::error!(
CAT,
obj: element,
"onvifaggregator doesn't expose request pads"
"onvifmetadatacombiner doesn't expose request pads"
);
None
@ -145,16 +145,16 @@ impl ElementImpl for OnvifAggregator {
gst::error!(
CAT,
obj: element,
"onvifaggregator doesn't expose request pads"
"onvifmetadatacombiner doesn't expose request pads"
);
}
}
impl OnvifAggregator {
impl OnvifMetadataCombiner {
fn consume_meta(
&self,
state: &mut State,
element: &super::OnvifAggregator,
element: &super::OnvifMetadataCombiner,
end: gst::ClockTime,
) -> Result<bool, gst::FlowError> {
while let Some(buffer) = self.meta_sink_pad.peek_buffer() {
@ -179,7 +179,7 @@ impl OnvifAggregator {
fn media_buffer_duration(
&self,
element: &super::OnvifAggregator,
element: &super::OnvifMetadataCombiner,
current_media_buffer: &gst::Buffer,
timeout: bool,
) -> Option<gst::ClockTime> {
@ -239,7 +239,7 @@ impl OnvifAggregator {
fn consume_media(
&self,
state: &mut State,
element: &super::OnvifAggregator,
element: &super::OnvifMetadataCombiner,
timeout: bool,
) -> Result<Option<gst::Buffer>, gst::FlowError> {
if let Some(current_media_buffer) = state
@ -275,7 +275,7 @@ impl OnvifAggregator {
}
}
impl AggregatorImpl for OnvifAggregator {
impl AggregatorImpl for OnvifMetadataCombiner {
fn aggregate(
&self,
element: &Self::Type,

View file

@ -4,14 +4,14 @@ use gst::prelude::*;
mod imp;
glib::wrapper! {
pub struct OnvifDepay(ObjectSubclass<imp::OnvifDepay>) @extends gst_rtp::RTPBaseDepayload, gst::Element, gst::Object;
pub struct OnvifMetadataCombiner(ObjectSubclass<imp::OnvifMetadataCombiner>) @extends gst_base::Aggregator, gst::Element, gst::Object;
}
pub fn register(plugin: &gst::Plugin) -> Result<(), glib::BoolError> {
gst::Element::register(
Some(plugin),
"rtponvifdepay",
"onvifmetadatacombiner",
gst::Rank::Primary,
OnvifDepay::static_type(),
OnvifMetadataCombiner::static_type(),
)
}

View file

@ -12,30 +12,30 @@ struct State {
}
#[derive(Default)]
pub struct OnvifDepay {
pub struct OnvifMetadataDepay {
state: Mutex<State>,
}
static CAT: Lazy<gst::DebugCategory> = Lazy::new(|| {
gst::DebugCategory::new(
"onvifdepay",
"rtponvifmetadatadepay",
gst::DebugColorFlags::empty(),
Some("ONVIF metadata depayloader"),
)
});
#[glib::object_subclass]
impl ObjectSubclass for OnvifDepay {
const NAME: &'static str = "GstOnvifDepay";
type Type = super::OnvifDepay;
impl ObjectSubclass for OnvifMetadataDepay {
const NAME: &'static str = "GstOnvifMetadataDepay";
type Type = super::OnvifMetadataDepay;
type ParentType = gst_rtp::RTPBaseDepayload;
}
impl ObjectImpl for OnvifDepay {}
impl ObjectImpl for OnvifMetadataDepay {}
impl GstObjectImpl for OnvifDepay {}
impl GstObjectImpl for OnvifMetadataDepay {}
impl ElementImpl for OnvifDepay {
impl ElementImpl for OnvifMetadataDepay {
fn metadata() -> Option<&'static gst::subclass::ElementMetadata> {
static ELEMENT_METADATA: Lazy<gst::subclass::ElementMetadata> = Lazy::new(|| {
gst::subclass::ElementMetadata::new(
@ -81,7 +81,7 @@ impl ElementImpl for OnvifDepay {
}
}
impl RTPBaseDepayloadImpl for OnvifDepay {
impl RTPBaseDepayloadImpl for OnvifMetadataDepay {
fn set_caps(&self, element: &Self::Type, _caps: &gst::Caps) -> Result<(), gst::LoggableError> {
let src_pad = element.src_pad();
let src_caps = src_pad.pad_template_caps();

View file

@ -4,14 +4,14 @@ use gst::prelude::*;
mod imp;
glib::wrapper! {
pub struct OnvifPay(ObjectSubclass<imp::OnvifPay>) @extends gst_rtp::RTPBasePayload, gst::Element, gst::Object;
pub struct OnvifMetadataDepay(ObjectSubclass<imp::OnvifMetadataDepay>) @extends gst_rtp::RTPBaseDepayload, gst::Element, gst::Object;
}
pub fn register(plugin: &gst::Plugin) -> Result<(), glib::BoolError> {
gst::Element::register(
Some(plugin),
"rtponvifpay",
"rtponvifmetadatadepay",
gst::Rank::Primary,
OnvifPay::static_type(),
OnvifMetadataDepay::static_type(),
)
}

View file

@ -13,9 +13,9 @@ use minidom::Element;
static CAT: Lazy<gst::DebugCategory> = Lazy::new(|| {
gst::DebugCategory::new(
"onvifoverlay",
"onvifmetadataoverlay",
gst::DebugColorFlags::empty(),
Some("ONVIF overlay element"),
Some("ONVIF metadata overlay element"),
)
});
@ -64,15 +64,18 @@ impl Default for Settings {
}
}
pub struct OnvifOverlay {
pub struct OnvifMetadataOverlay {
srcpad: gst::Pad,
sinkpad: gst::Pad,
state: Mutex<State>,
settings: Mutex<Settings>,
}
impl OnvifOverlay {
fn negotiate(&self, element: &super::OnvifOverlay) -> Result<gst::FlowSuccess, gst::FlowError> {
impl OnvifMetadataOverlay {
fn negotiate(
&self,
element: &super::OnvifMetadataOverlay,
) -> Result<gst::FlowSuccess, gst::FlowError> {
let video_info = {
let state = self.state.lock().unwrap();
match state.video_info.as_ref() {
@ -288,7 +291,12 @@ impl OnvifOverlay {
}
// Update our overlay composition with a set of rectangles
fn overlay_shapes(&self, state: &mut State, element: &super::OnvifOverlay, shapes: Vec<Shape>) {
fn overlay_shapes(
&self,
state: &mut State,
element: &super::OnvifMetadataOverlay,
shapes: Vec<Shape>,
) {
if shapes.is_empty() {
state.composition = None;
return;
@ -382,7 +390,7 @@ impl OnvifOverlay {
fn sink_chain(
&self,
pad: &gst::Pad,
element: &super::OnvifOverlay,
element: &super::OnvifMetadataOverlay,
mut buffer: gst::Buffer,
) -> Result<gst::FlowSuccess, gst::FlowError> {
gst::trace!(CAT, obj: pad, "Handling buffer {:?}", buffer);
@ -684,7 +692,12 @@ impl OnvifOverlay {
self.srcpad.push(buffer)
}
fn sink_event(&self, pad: &gst::Pad, element: &super::OnvifOverlay, event: gst::Event) -> bool {
fn sink_event(
&self,
pad: &gst::Pad,
element: &super::OnvifMetadataOverlay,
event: gst::Event,
) -> bool {
use gst::EventView;
gst::log!(CAT, obj: pad, "Handling event {:?}", event);
@ -714,23 +727,23 @@ impl OnvifOverlay {
}
#[glib::object_subclass]
impl ObjectSubclass for OnvifOverlay {
const NAME: &'static str = "GstOnvifOverlay";
type Type = super::OnvifOverlay;
impl ObjectSubclass for OnvifMetadataOverlay {
const NAME: &'static str = "GstOnvifMetadataOverlay";
type Type = super::OnvifMetadataOverlay;
type ParentType = gst::Element;
fn with_class(klass: &Self::Class) -> Self {
let templ = klass.pad_template("sink").unwrap();
let sinkpad = gst::Pad::builder_with_template(&templ, Some("sink"))
.chain_function(|pad, parent, buffer| {
OnvifOverlay::catch_panic_pad_function(
OnvifMetadataOverlay::catch_panic_pad_function(
parent,
|| Err(gst::FlowError::Error),
|overlay, element| overlay.sink_chain(pad, element, buffer),
)
})
.event_function(|pad, parent, event| {
OnvifOverlay::catch_panic_pad_function(
OnvifMetadataOverlay::catch_panic_pad_function(
parent,
|| false,
|overlay, element| overlay.sink_event(pad, element, event),
@ -755,7 +768,7 @@ impl ObjectSubclass for OnvifOverlay {
}
}
impl ObjectImpl for OnvifOverlay {
impl ObjectImpl for OnvifMetadataOverlay {
fn properties() -> &'static [glib::ParamSpec] {
static PROPERTIES: Lazy<Vec<glib::ParamSpec>> = Lazy::new(|| {
vec![glib::ParamSpecString::builder("font-desc")
@ -802,13 +815,13 @@ impl ObjectImpl for OnvifOverlay {
}
}
impl GstObjectImpl for OnvifOverlay {}
impl GstObjectImpl for OnvifMetadataOverlay {}
impl ElementImpl for OnvifOverlay {
impl ElementImpl for OnvifMetadataOverlay {
fn metadata() -> Option<&'static gst::subclass::ElementMetadata> {
static ELEMENT_METADATA: Lazy<gst::subclass::ElementMetadata> = Lazy::new(|| {
gst::subclass::ElementMetadata::new(
"ONVIF overlay",
"ONVIF Metadata overlay",
"Video/Overlay",
"Renders ONVIF analytics meta over raw video frames",
"Mathieu Duponchelle <mathieu@centricular.com>",

View file

@ -4,14 +4,14 @@ use gst::prelude::*;
mod imp;
glib::wrapper! {
pub struct OnvifOverlay(ObjectSubclass<imp::OnvifOverlay>) @extends gst::Element, gst::Object;
pub struct OnvifMetadataOverlay(ObjectSubclass<imp::OnvifMetadataOverlay>) @extends gst::Element, gst::Object;
}
pub fn register(plugin: &gst::Plugin) -> Result<(), glib::BoolError> {
gst::Element::register(
Some(plugin),
"onvifoverlay",
"onvifmetadataoverlay",
gst::Rank::Primary,
OnvifOverlay::static_type(),
OnvifMetadataOverlay::static_type(),
)
}

View file

@ -5,20 +5,20 @@ use gst_rtp::subclass::prelude::*;
use once_cell::sync::Lazy;
#[derive(Default)]
pub struct OnvifPay {}
pub struct OnvifMetadataPay {}
#[glib::object_subclass]
impl ObjectSubclass for OnvifPay {
const NAME: &'static str = "GstOnvifPay";
type Type = super::OnvifPay;
impl ObjectSubclass for OnvifMetadataPay {
const NAME: &'static str = "GstOnvifMetadataPay";
type Type = super::OnvifMetadataPay;
type ParentType = gst_rtp::RTPBasePayload;
}
impl ObjectImpl for OnvifPay {}
impl ObjectImpl for OnvifMetadataPay {}
impl GstObjectImpl for OnvifPay {}
impl GstObjectImpl for OnvifMetadataPay {}
impl ElementImpl for OnvifPay {
impl ElementImpl for OnvifMetadataPay {
fn metadata() -> Option<&'static gst::subclass::ElementMetadata> {
static ELEMENT_METADATA: Lazy<gst::subclass::ElementMetadata> = Lazy::new(|| {
gst::subclass::ElementMetadata::new(
@ -64,7 +64,7 @@ impl ElementImpl for OnvifPay {
}
}
impl RTPBasePayloadImpl for OnvifPay {
impl RTPBasePayloadImpl for OnvifMetadataPay {
fn handle_buffer(
&self,
element: &Self::Type,

View file

@ -4,14 +4,14 @@ use gst::prelude::*;
mod imp;
glib::wrapper! {
pub struct OnvifAggregator(ObjectSubclass<imp::OnvifAggregator>) @extends gst_base::Aggregator, gst::Element, gst::Object;
pub struct OnvifMetadataPay(ObjectSubclass<imp::OnvifMetadataPay>) @extends gst_rtp::RTPBasePayload, gst::Element, gst::Object;
}
pub fn register(plugin: &gst::Plugin) -> Result<(), glib::BoolError> {
gst::Element::register(
Some(plugin),
"onvifaggregator",
"rtponvifmetadatapay",
gst::Rank::Primary,
OnvifAggregator::static_type(),
OnvifMetadataPay::static_type(),
)
}