Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the vulkan video decoder to the compositor #803

Merged
merged 13 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from 7 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
107 changes: 103 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ members = [
"decklink",
"compositor_api",
"compositor_web",
"vk-video",
]
resolver = "2"

Expand Down Expand Up @@ -56,6 +57,7 @@ schemars = { git = "https://github.com/membraneframework-labs/schemars", rev = "
"preserve_order",
] }
shared_memory = "0.12.4"
vk-video = { path = "vk-video" }
wgpu = { version = "22.1.0", default-features = false, features = [
"wgsl",
"dx12",
Expand Down Expand Up @@ -100,6 +102,10 @@ http-body-util = "0.1.2"
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
shared_memory = { workspace = true }

# platforms that support vulkan are: windows and all non-apple unixes. emscripten is something for the web, where vulkan is not available either
jerzywilczek marked this conversation as resolved.
Show resolved Hide resolved
[target.'cfg(any(windows, all(unix, not(target_os = "emscripten"), not(target_os = "ios"), not(target_os = "macos"))))'.dependencies]
jerzywilczek marked this conversation as resolved.
Show resolved Hide resolved
compositor_api = { workspace = true, features = ["vk-video"] }

[[bin]]
name = "process_helper"
path = "src/bin/process_helper/main.rs"
Expand Down
1 change: 1 addition & 0 deletions compositor_api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ license = "BUSL-1.1"
[features]
decklink = ["compositor_pipeline/decklink"]
web_renderer = ["compositor_render/web_renderer"]
vk-video = ["compositor_pipeline/vk-video"]

[dependencies]
compositor_render = { workspace = true }
Expand Down
20 changes: 13 additions & 7 deletions compositor_api/src/types/from_register_input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,19 @@ impl TryFrom<RtpInput> for pipeline::RegisterInputOptions {
}

let rtp_stream = input::rtp::RtpStream {
video: video.as_ref().map(|video| input::rtp::InputVideoStream {
options: match video {
InputRtpVideoOptions::FfmepgH264 => decoder::VideoDecoderOptions {
codec: pipeline::VideoCodec::H264,
},
},
}),
video: video
.as_ref()
.map(|video| {
Ok(input::rtp::InputVideoStream {
options: match video {
InputRtpVideoOptions::FfmepgH264 => decoder::VideoDecoderOptions {
codec: pipeline::VideoCodec::H264,
decoder: pipeline::VideoDecoder::FFmpegH264,
jerzywilczek marked this conversation as resolved.
Show resolved Hide resolved
},
},
})
})
.transpose()?,
audio: audio.map(TryFrom::try_from).transpose()?,
};

Expand Down
5 changes: 5 additions & 0 deletions compositor_pipeline/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ license = "BUSL-1.1"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[features]
decklink = ["dep:decklink"]
vk-video = ["dep:vk-video"]

[dependencies]
compositor_render = { workspace = true }
Expand All @@ -32,3 +33,7 @@ glyphon = { workspace = true }

[target.x86_64-unknown-linux-gnu.dependencies]
decklink = { path = "../decklink", optional = true }

# platforms that support vulkan are: windows and all non-apple unixes. emscripten is something for the web, where vulkan is not available either
[target.'cfg(any(windows, all(unix, not(target_os = "emscripten"), not(target_os = "ios"), not(target_os = "macos"))))'.dependencies]
vk-video = { path = "../vk-video/", optional = true }
20 changes: 20 additions & 0 deletions compositor_pipeline/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,19 @@ use compositor_render::{
use crate::pipeline::{decoder::AacDecoderError, VideoCodec};
use fdk_aac_sys as fdk;

#[derive(Debug, thiserror::Error)]
pub enum InitPipelineError {
#[error(transparent)]
InitRendererEngine(#[from] InitRendererEngineError),

#[error("Failed to create a download directory.")]
CreateDownloadDir(#[source] std::io::Error),

#[cfg(feature = "vk-video")]
#[error(transparent)]
VulkanCtxError(#[from] vk_video::VulkanCtxError),
}

#[derive(Debug, thiserror::Error)]
pub enum RegisterInputError {
#[error("Failed to register input stream. Stream \"{0}\" is already registered.")]
Expand Down Expand Up @@ -120,6 +133,13 @@ pub enum InputInitError {

#[error("Couldn't read decoder init result.")]
CannotReadInitResult,

#[cfg(feature = "vk-video")]
#[error(transparent)]
VulkanDecoderError(#[from] vk_video::DecoderError),

#[error("Pipeline couldn't detect a vulkan video compatible device when it was being initialized. Cannot create a vulkan video decoder")]
VulkanContextRequiredForVulkanDecoder,
}

pub enum ErrorType {
Expand Down
Loading