feat: add properties to offset frame
This commit is contained in:
parent
52dbf859ee
commit
504ad3ae03
|
@ -1,4 +1,4 @@
|
||||||
use gstreamer::glib::{self, ParamSpec, ParamSpecBoolean, ParamSpecString, Value};
|
use gstreamer::glib::{self, ParamSpec, ParamSpecBoolean, ParamSpecString, ParamSpecUInt, Value};
|
||||||
use gstreamer::prelude::*;
|
use gstreamer::prelude::*;
|
||||||
use gstreamer::subclass::prelude::*;
|
use gstreamer::subclass::prelude::*;
|
||||||
use gstreamer::subclass::ElementMetadata;
|
use gstreamer::subclass::ElementMetadata;
|
||||||
|
@ -35,6 +35,8 @@ struct Settings {
|
||||||
bind_address: Option<SocketAddr>,
|
bind_address: Option<SocketAddr>,
|
||||||
diff_only: bool,
|
diff_only: bool,
|
||||||
prefix: Option<Ipv6Addr>,
|
prefix: Option<Ipv6Addr>,
|
||||||
|
x: u32,
|
||||||
|
y: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
|
@ -79,6 +81,14 @@ impl ObjectImpl for PingxelflutSink {
|
||||||
.nick("Destination prefix")
|
.nick("Destination prefix")
|
||||||
.blurb("Prefix of pingxelflut server")
|
.blurb("Prefix of pingxelflut server")
|
||||||
.build(),
|
.build(),
|
||||||
|
ParamSpecUInt::builder("x")
|
||||||
|
.nick("X offset")
|
||||||
|
.blurb("Offset along X axis")
|
||||||
|
.build(),
|
||||||
|
ParamSpecUInt::builder("y")
|
||||||
|
.nick("Y offset")
|
||||||
|
.blurb("Offset along Y axis")
|
||||||
|
.build(),
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -106,6 +116,12 @@ impl ObjectImpl for PingxelflutSink {
|
||||||
.map(|s| s.parse().ok())
|
.map(|s| s.parse().ok())
|
||||||
.unwrap_or(None);
|
.unwrap_or(None);
|
||||||
}
|
}
|
||||||
|
"x" => {
|
||||||
|
settings.x = value.get::<u32>().unwrap();
|
||||||
|
}
|
||||||
|
"y" => {
|
||||||
|
settings.y = value.get::<u32>().unwrap();
|
||||||
|
}
|
||||||
_ => unimplemented!(),
|
_ => unimplemented!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -125,6 +141,8 @@ impl ObjectImpl for PingxelflutSink {
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|addr| addr.to_string())
|
.map(|addr| addr.to_string())
|
||||||
.to_value(),
|
.to_value(),
|
||||||
|
"x" => settings.x.to_value(),
|
||||||
|
"y" => settings.y.to_value(),
|
||||||
_ => unimplemented!(),
|
_ => unimplemented!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -246,10 +264,11 @@ impl VideoSinkImpl for PingxelflutSink {
|
||||||
let prefix = settings.prefix.as_ref().unwrap();
|
let prefix = settings.prefix.as_ref().unwrap();
|
||||||
|
|
||||||
if let State::Started { ref socket } = *self.state.lock().unwrap() {
|
if let State::Started { ref socket } = *self.state.lock().unwrap() {
|
||||||
for y in 0..cmp::min(frame.height(), HEIGHT) {
|
for y in settings.y..cmp::min(settings.y + frame.height(), HEIGHT) {
|
||||||
for x in 0..cmp::min(frame.width(), WIDTH) {
|
for x in settings.x..cmp::min(settings.x + frame.width(), WIDTH) {
|
||||||
let i =
|
let i = ((y - settings.y) * frame.plane_stride()[0] as u32
|
||||||
(y * frame.plane_stride()[0] as u32 + x * frame.n_components()) as usize;
|
+ (x - settings.x) * frame.n_components())
|
||||||
|
as usize;
|
||||||
let (r, g, b) = (data[i] as u16, data[i + 1] as u16, data[i + 2] as u16);
|
let (r, g, b) = (data[i] as u16, data[i + 1] as u16, data[i + 2] as u16);
|
||||||
|
|
||||||
if settings.diff_only
|
if settings.diff_only
|
||||||
|
|
Loading…
Reference in New Issue