mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2024-11-23 12:01:01 +00:00
Added property stream-name
This commit is contained in:
parent
b0f9b7fae9
commit
227d750305
1 changed files with 35 additions and 5 deletions
|
@ -34,8 +34,9 @@ const DEFAULT_MUTE: bool = false;
|
||||||
const DEFAULT_IS_LIVE: bool = false;
|
const DEFAULT_IS_LIVE: bool = false;
|
||||||
|
|
||||||
// Property value storage
|
// Property value storage
|
||||||
#[derive(Debug, Clone, Copy)]
|
#[derive(Debug, Clone)]
|
||||||
struct Settings {
|
struct Settings {
|
||||||
|
stream_name: String,
|
||||||
samples_per_buffer: u32,
|
samples_per_buffer: u32,
|
||||||
freq: u32,
|
freq: u32,
|
||||||
volume: f64,
|
volume: f64,
|
||||||
|
@ -46,6 +47,7 @@ struct Settings {
|
||||||
impl Default for Settings {
|
impl Default for Settings {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Settings {
|
Settings {
|
||||||
|
stream_name: String::from("Fixed ndi stream name"),
|
||||||
samples_per_buffer: DEFAULT_SAMPLES_PER_BUFFER,
|
samples_per_buffer: DEFAULT_SAMPLES_PER_BUFFER,
|
||||||
freq: DEFAULT_FREQ,
|
freq: DEFAULT_FREQ,
|
||||||
volume: DEFAULT_VOLUME,
|
volume: DEFAULT_VOLUME,
|
||||||
|
@ -56,7 +58,14 @@ impl Default for Settings {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Metadata for the properties
|
// Metadata for the properties
|
||||||
static PROPERTIES: [Property; 5] = [
|
static PROPERTIES: [Property; 6] = [
|
||||||
|
Property::String(
|
||||||
|
"stream-name",
|
||||||
|
"Sream Name",
|
||||||
|
"Name of the streaming device",
|
||||||
|
None,
|
||||||
|
PropertyMutability::ReadWrite,
|
||||||
|
),
|
||||||
Property::UInt(
|
Property::UInt(
|
||||||
"samples-per-buffer",
|
"samples-per-buffer",
|
||||||
"Samples Per Buffer",
|
"Samples Per Buffer",
|
||||||
|
@ -255,6 +264,22 @@ impl ObjectImpl<BaseSrc> for NdiSrc {
|
||||||
let element = obj.clone().downcast::<BaseSrc>().unwrap();
|
let element = obj.clone().downcast::<BaseSrc>().unwrap();
|
||||||
|
|
||||||
match *prop {
|
match *prop {
|
||||||
|
Property::String("stream-name", ..) => {
|
||||||
|
let mut settings = self.settings.lock().unwrap();
|
||||||
|
let stream_name = value.get().unwrap();
|
||||||
|
gst_info!(
|
||||||
|
self.cat,
|
||||||
|
obj: &element,
|
||||||
|
"Changing stream-name from {} to {}",
|
||||||
|
settings.stream_name,
|
||||||
|
stream_name
|
||||||
|
);
|
||||||
|
settings.stream_name = stream_name;
|
||||||
|
drop(settings);
|
||||||
|
|
||||||
|
let _ =
|
||||||
|
element.post_message(&gst::Message::new_latency().src(Some(&element)).build());
|
||||||
|
}
|
||||||
Property::UInt("samples-per-buffer", ..) => {
|
Property::UInt("samples-per-buffer", ..) => {
|
||||||
let mut settings = self.settings.lock().unwrap();
|
let mut settings = self.settings.lock().unwrap();
|
||||||
let samples_per_buffer = value.get().unwrap();
|
let samples_per_buffer = value.get().unwrap();
|
||||||
|
@ -329,6 +354,11 @@ impl ObjectImpl<BaseSrc> for NdiSrc {
|
||||||
let prop = &PROPERTIES[id as usize];
|
let prop = &PROPERTIES[id as usize];
|
||||||
|
|
||||||
match *prop {
|
match *prop {
|
||||||
|
Property::UInt("stream-name", ..) => {
|
||||||
|
let settings = self.settings.lock().unwrap();
|
||||||
|
//TODO to_value supongo que solo funciona con numeros
|
||||||
|
Ok(settings.stream_name.to_value())
|
||||||
|
}
|
||||||
Property::UInt("samples-per-buffer", ..) => {
|
Property::UInt("samples-per-buffer", ..) => {
|
||||||
let settings = self.settings.lock().unwrap();
|
let settings = self.settings.lock().unwrap();
|
||||||
Ok(settings.samples_per_buffer.to_value())
|
Ok(settings.samples_per_buffer.to_value())
|
||||||
|
@ -393,7 +423,7 @@ impl BaseSrcImpl<BaseSrc> for NdiSrc {
|
||||||
|
|
||||||
element.set_blocksize(info.bpf() * (*self.settings.lock().unwrap()).samples_per_buffer);
|
element.set_blocksize(info.bpf() * (*self.settings.lock().unwrap()).samples_per_buffer);
|
||||||
|
|
||||||
let settings = *self.settings.lock().unwrap();
|
let settings = &*self.settings.lock().unwrap();
|
||||||
let mut state = self.state.lock().unwrap();
|
let mut state = self.state.lock().unwrap();
|
||||||
|
|
||||||
// If we have no caps yet, any old sample_offset and sample_stop will be
|
// If we have no caps yet, any old sample_offset and sample_stop will be
|
||||||
|
@ -468,7 +498,7 @@ impl BaseSrcImpl<BaseSrc> for NdiSrc {
|
||||||
// We can't output samples before they were produced, and the last sample of a buffer
|
// We can't output samples before they were produced, and the last sample of a buffer
|
||||||
// is produced that much after the beginning, leading to this latency calculation
|
// is produced that much after the beginning, leading to this latency calculation
|
||||||
QueryView::Latency(ref mut q) => {
|
QueryView::Latency(ref mut q) => {
|
||||||
let settings = *self.settings.lock().unwrap();
|
let settings = &*self.settings.lock().unwrap();
|
||||||
let state = self.state.lock().unwrap();
|
let state = self.state.lock().unwrap();
|
||||||
|
|
||||||
if let Some(ref info) = state.info {
|
if let Some(ref info) = state.info {
|
||||||
|
@ -497,7 +527,7 @@ impl BaseSrcImpl<BaseSrc> for NdiSrc {
|
||||||
// Keep a local copy of the values of all our properties at this very moment. This
|
// Keep a local copy of the values of all our properties at this very moment. This
|
||||||
// ensures that the mutex is never locked for long and the application wouldn't
|
// ensures that the mutex is never locked for long and the application wouldn't
|
||||||
// have to block until this function returns when getting/setting property values
|
// have to block until this function returns when getting/setting property values
|
||||||
let settings = *self.settings.lock().unwrap();
|
let settings = &*self.settings.lock().unwrap();
|
||||||
|
|
||||||
// Get a locked reference to our state, i.e. the input and output AudioInfo
|
// Get a locked reference to our state, i.e. the input and output AudioInfo
|
||||||
let mut state = self.state.lock().unwrap();
|
let mut state = self.state.lock().unwrap();
|
||||||
|
|
Loading…
Reference in a new issue