Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 9 additions & 14 deletions integration-tests/examples/encoded_channel_output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,21 +79,16 @@ fn main() {
}),
};

let input_options = RegisterInputOptions {
input_options: ProtocolInputOptions::Mp4(Mp4InputOptions {
source: Mp4InputSource::File(root_dir.join(BUNNY_FILE_PATH).into()),
should_loop: false,
video_decoders: Mp4InputVideoDecoders {
h264: Some(VideoDecoderOptions::FfmpegH264),
},
buffer: InputBufferOptions::Const(None),
seek: None,
}),
queue_options: QueueInputOptions {
required: true,
offset: Some(Duration::ZERO),
let input_options = RegisterInputOptions::Mp4(Mp4InputOptions {
source: Mp4InputSource::File(root_dir.join(BUNNY_FILE_PATH).into()),
should_loop: false,
video_decoders: Mp4InputVideoDecoders {
h264: Some(VideoDecoderOptions::FfmpegH264),
},
};
seek: None,
required: true,
offset: Some(Duration::ZERO),
});

Pipeline::register_input(&state.pipeline().unwrap(), input_id.clone(), input_options).unwrap();

Expand Down
4 changes: 2 additions & 2 deletions integration-tests/examples/raw_channel_input.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![recursion_limit = "256"]

use core::panic;
use std::{
sync::{Arc, Mutex},
Expand Down Expand Up @@ -91,8 +93,6 @@ fn main() {
video: true,
audio: false,
buffer_duration: None,
},
QueueInputOptions {
required: true,
offset: Some(Duration::ZERO),
},
Expand Down
23 changes: 9 additions & 14 deletions integration-tests/examples/raw_channel_output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,21 +90,16 @@ fn main() {
}),
};

let input_options = RegisterInputOptions {
input_options: ProtocolInputOptions::Mp4(Mp4InputOptions {
source: Mp4InputSource::File(integration_tests_root().join(BUNNY_FILE_PATH).into()),
should_loop: false,
video_decoders: Mp4InputVideoDecoders {
h264: Some(VideoDecoderOptions::FfmpegH264),
},
buffer: InputBufferOptions::Const(None),
seek: None,
}),
queue_options: QueueInputOptions {
required: true,
offset: Some(Duration::ZERO),
let input_options = RegisterInputOptions::Mp4(Mp4InputOptions {
source: Mp4InputSource::File(integration_tests_root().join(BUNNY_FILE_PATH).into()),
should_loop: false,
video_decoders: Mp4InputVideoDecoders {
h264: Some(VideoDecoderOptions::FfmpegH264),
},
};
seek: None,
required: true,
offset: Some(Duration::ZERO),
});

Pipeline::register_input(&pipeline, input_id.clone(), input_options).unwrap();

Expand Down
21 changes: 9 additions & 12 deletions integration-tests/examples/v4l2_rust_api.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![recursion_limit = "256"]

#[cfg(not(target_os = "linux"))]
fn main() {
panic!("Your OS does not support Video for Linux 2.");
Expand Down Expand Up @@ -63,18 +65,13 @@ mod main_module {
.find(|d| d.formats.iter().any(|f| f.format == V4l2Format::Yuyv))
.expect("no device supports the required format");

RegisterInputOptions {
input_options: ProtocolInputOptions::V4l2(V4l2InputOptions {
path: device.path,
resolution: Some(VIDEO_RESOLUTION),
format: V4l2Format::Yuyv,
framerate: Some(Framerate { num: 30, den: 1 }),
}),
queue_options: QueueInputOptions {
required: false,
offset: None,
},
}
RegisterInputOptions::V4l2(V4l2InputOptions {
path: device.path,
resolution: Some(VIDEO_RESOLUTION),
format: V4l2Format::Yuyv,
framerate: Some(Framerate { num: 30, den: 1 }),
required: false,
})
}

#[cfg(target_os = "linux")]
Expand Down
27 changes: 10 additions & 17 deletions integration-tests/src/bin/benchmark/benchmark_pass.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,21 +285,16 @@ impl SingleBenchmarkPass {
Pipeline::register_input(
pipeline,
input_id.clone(),
RegisterInputOptions {
input_options: ProtocolInputOptions::Mp4(Mp4InputOptions {
should_loop: true,
video_decoders: Mp4InputVideoDecoders {
h264: Some(self.decoder),
},
source: Mp4InputSource::File(path.to_path_buf().into()),
buffer: InputBufferOptions::Const(None),
seek: None,
}),
queue_options: QueueInputOptions {
offset: None,
required: true,
RegisterInputOptions::Mp4(Mp4InputOptions {
should_loop: true,
video_decoders: Mp4InputVideoDecoders {
h264: Some(self.decoder),
},
},
source: Mp4InputSource::File(path.to_path_buf().into()),
seek: None,
required: true,
offset: None,
}),
)
}

Expand All @@ -315,10 +310,8 @@ impl SingleBenchmarkPass {
video: true,
audio: false,
buffer_duration: None,
},
QueueInputOptions {
offset: None,
required: true,
offset: None,
},
)?;

Expand Down
11 changes: 5 additions & 6 deletions smelter-api/src/input/decklink_into.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ impl TryFrom<DeckLink> for core::RegisterInputOptions {

#[cfg(feature = "decklink")]
fn try_from(value: DeckLink) -> Result<Self, Self::Error> {
use super::queue_options::new_queue_options;
const ID_PARSE_ERROR_MESSAGE: &str =
"\"persistent_id\" has to be a valid 32-bit hexadecimal number";

Expand All @@ -20,16 +19,16 @@ impl TryFrom<DeckLink> for core::RegisterInputOptions {
None => None,
};

Ok(core::RegisterInputOptions {
input_options: core::ProtocolInputOptions::DeckLink(core::DeckLinkInputOptions {
Ok(core::RegisterInputOptions::DeckLink(
core::DeckLinkInputOptions {
subdevice_index: value.subdevice_index,
display_name: value.display_name,
persistent_id,
enable_audio: value.enable_audio.unwrap_or(true),
pixel_format: Some(core::DeckLinkPixelFormat::Format8BitYUV),
}),
queue_options: new_queue_options(value.required, None)?,
})
required: value.required.unwrap_or(false),
},
))
}

#[cfg(not(feature = "decklink"))]
Expand Down
18 changes: 4 additions & 14 deletions smelter-api/src/input/hls_into.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,7 @@ impl TryFrom<HlsInput> for core::RegisterInputOptions {
decoder_map,
} = value;

let queue_options = new_queue_options(required, offset_ms)?;

let buffer = match &queue_options {
core::QueueInputOptions {
required: false,
offset: None,
} => core::InputBufferOptions::Adaptive,
_ => core::InputBufferOptions::None,
};
let (required, offset) = new_queue_options(required, offset_ms)?;

let h264 = decoder_map
.as_ref()
Expand All @@ -38,12 +30,10 @@ impl TryFrom<HlsInput> for core::RegisterInputOptions {
let input_options = core::HlsInputOptions {
url,
video_decoders,
buffer,
required,
offset,
};

Ok(core::RegisterInputOptions {
input_options: core::ProtocolInputOptions::Hls(input_options),
queue_options,
})
Ok(core::RegisterInputOptions::Hls(input_options))
}
}
28 changes: 9 additions & 19 deletions smelter-api/src/input/mp4_into.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,7 @@ impl TryFrom<Mp4Input> for core::RegisterInputOptions {

const BAD_URL_PATH_SPEC: &str = "Exactly one of `url` or `path` has to be specified in a register request for an mp4 input.";

let queue_options = new_queue_options(required, offset_ms)?;

let buffer = match &queue_options {
core::QueueInputOptions {
required: false,
offset: None,
} => core::InputBufferOptions::Const(None),
_ => core::InputBufferOptions::None,
};
let (required, offset) = new_queue_options(required, offset_ms)?;

let source = match (url, path) {
(Some(_), Some(_)) | (None, None) => {
Expand All @@ -55,15 +47,13 @@ impl TryFrom<Mp4Input> for core::RegisterInputOptions {
.transpose()
.map_err(|err| TypeError::new(format!("Invalid duration. {err}")))?;

Ok(core::RegisterInputOptions {
input_options: core::ProtocolInputOptions::Mp4(core::Mp4InputOptions {
source,
should_loop: should_loop.unwrap_or(false),
video_decoders,
buffer,
seek,
}),
queue_options,
})
Ok(core::RegisterInputOptions::Mp4(core::Mp4InputOptions {
source,
should_loop: should_loop.unwrap_or(false),
video_decoders,
seek,
required,
offset,
}))
}
}
15 changes: 7 additions & 8 deletions smelter-api/src/input/queue_options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@ use crate::*;
pub(super) fn new_queue_options(
required: Option<bool>,
offset_ms: Option<f64>,
) -> Result<smelter_core::QueueInputOptions, TypeError> {
Ok(smelter_core::QueueInputOptions {
required: required.unwrap_or(false),
offset: offset_ms
.map(|offset_ms| Duration::try_from_secs_f64(offset_ms / 1000.0))
.transpose()
.map_err(|err| TypeError::new(format!("Invalid duration. {err}")))?,
})
) -> Result<(bool, Option<Duration>), TypeError> {
let required = required.unwrap_or(false);
let offset = offset_ms
.map(|offset_ms| Duration::try_from_secs_f64(offset_ms / 1000.0))
.transpose()
.map_err(|err| TypeError::new(format!("Invalid duration. {err}")))?;
Ok((required, offset))
}
4 changes: 0 additions & 4 deletions smelter-api/src/input/rtmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ pub struct RtmpInput {
/// (**default=`false`**) If input is required and the stream is not delivered
/// on time, then Smelter will delay producing output frames.
pub required: Option<bool>,
/// Offset in milliseconds relative to the pipeline start (start request). If the offset is
/// not defined then the stream will be synchronized based on the delivery time of the initial
/// frames.
pub offset_ms: Option<f64>,
/// Assigns which decoder should be used for media encoded with a specific codec.
pub decoder_map: Option<HashMap<InputRtmpCodec, RtmpVideoDecoderOptions>>,
}
Expand Down
20 changes: 2 additions & 18 deletions smelter-api/src/input/rtmp_into.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
use crate::common_core::prelude as core;
use crate::*;

use super::queue_options::new_queue_options;

impl TryFrom<RtmpInput> for core::RegisterInputOptions {
type Error = TypeError;

Expand All @@ -11,20 +9,9 @@ impl TryFrom<RtmpInput> for core::RegisterInputOptions {
app,
stream_key,
required,
offset_ms,
decoder_map,
} = value;

let queue_options = new_queue_options(required, offset_ms)?;

let buffer = match &queue_options {
core::QueueInputOptions {
required: false,
offset: None,
} => core::InputBufferOptions::Const(None),
_ => core::InputBufferOptions::None,
};

let h264 = decoder_map
.as_ref()
.and_then(|decoders| decoders.get(&InputRtmpCodec::H264))
Expand All @@ -38,12 +25,9 @@ impl TryFrom<RtmpInput> for core::RegisterInputOptions {
app,
stream_key,
decoders: core::RtmpServerInputDecoders { h264 },
buffer,
required: required.unwrap_or(false),
};

Ok(core::RegisterInputOptions {
input_options: core::ProtocolInputOptions::RtmpServer(input_options),
queue_options,
})
Ok(core::RegisterInputOptions::RtmpServer(input_options))
}
}
Loading
Loading