Skip to content

Commit

Permalink
Add the vulkan video decoder to the compositor (#803)
Browse files Browse the repository at this point in the history
Co-authored-by: Jerzy Wilczek <[email protected]>
Co-authored-by: Wojciech Barczyński <[email protected]>
  • Loading branch information
3 people authored Oct 11, 2024
1 parent 8890ed4 commit ea29422
Show file tree
Hide file tree
Showing 51 changed files with 5,658 additions and 68 deletions.
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 a web-based platform, 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]
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
19 changes: 12 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,18 @@ 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 {
decoder: pipeline::VideoDecoder::FFmpegH264,
},
},
})
})
.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 a web-based platform, 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

0 comments on commit ea29422

Please sign in to comment.