diff --git a/.github/workflows/macos_lint.yml b/.github/workflows/macos_lint.yml new file mode 100644 index 000000000..66b034242 --- /dev/null +++ b/.github/workflows/macos_lint.yml @@ -0,0 +1,38 @@ +name: macos lint +on: + push: + branches: [master] + pull_request: + types: [opened, synchronize] + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} + +jobs: + check: + runs-on: macos-14 + steps: + - name: 🛠 Install system dependencies + run: brew install ffmpeg + + - name: 🔧 Install the rust toolchain + uses: dtolnay/rust-toolchain@stable + with: + components: rustfmt, clippy + + - name: 📥 Checkout repo + uses: actions/checkout@v4 + + - name: 📁 Rust cache + uses: Swatinem/rust-cache@v2 + + - name: 🪢 Generate Chromium Embedded Framework bindings + run: cargo build --package compositor_chromium + + - name: 📖 Check formatting + run: cargo fmt --all --check + + - name: 📎 Run clippy + run: cargo clippy --workspace --all-targets -- -D clippy::todo -D warnings + diff --git a/Cargo.lock b/Cargo.lock index c9e9d1f48..44267b97f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -254,16 +254,14 @@ dependencies = [ [[package]] name = "bindgen" -version = "0.69.4" +version = "0.70.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a00dc851838a2120612785d195287475a3ac45514741da670b735818822129a0" +checksum = "f49d8fed880d473ea71efb9bf597651e77201bdd4893efe54c9e5d65ae04ce6f" dependencies = [ "bitflags 2.6.0", "cexpr", "clang-sys", "itertools", - "lazy_static", - "lazycell", "proc-macro2", "quote", "regex", @@ -942,9 +940,9 @@ dependencies = [ [[package]] name = "ffmpeg-next" -version = "7.0.4" +version = "7.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19a340e3d664ad5f530147cd6d4a86ece739a829fe2d81c369389ef903bd96f6" +checksum = "da02698288e0275e442a47fc12ca26d50daf0d48b15398ba5906f20ac2e2a9f9" dependencies = [ "bitflags 2.6.0", "ffmpeg-sys-next", @@ -953,11 +951,11 @@ dependencies = [ [[package]] name = "ffmpeg-sys-next" -version = "7.0.2" +version = "7.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db1b7546e70609ead8c06b2b4c618a1ba352364675f81608f431dd4f321fe3f1" +checksum = "2bc3234d0a4b2f7d083699d0860c6c9dd83713908771b60f94a96f8704adfe45" dependencies = [ - "bindgen 0.69.4", + "bindgen 0.70.1", "cc", "libc", "num_cpus", diff --git a/Cargo.toml b/Cargo.toml index 564977e5f..5ff8a49ab 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -39,7 +39,7 @@ thiserror = "1.0.40" crossbeam-channel = "0.5.8" reqwest = { version = "0.12.3", features = ["blocking", "json"] } signal-hook = "0.3.15" -ffmpeg-next = "7.0.0" +ffmpeg-next = "7.1.0" anyhow = "1.0.71" image = { version = "0.24.7", features = ["jpeg", "png"] } rtp = "0.9.0" diff --git a/compositor_pipeline/src/pipeline/graphics_context.rs b/compositor_pipeline/src/pipeline/graphics_context.rs index 206d5d55b..d0bc15d0c 100644 --- a/compositor_pipeline/src/pipeline/graphics_context.rs +++ b/compositor_pipeline/src/pipeline/graphics_context.rs @@ -1,4 +1,5 @@ use crate::error::InitPipelineError; +use compositor_render::{create_wgpu_ctx, error::InitRendererEngineError}; use std::sync::Arc; #[derive(Debug)] @@ -17,10 +18,7 @@ impl GraphicsContext { features: wgpu::Features, limits: wgpu::Limits, ) -> Result { - use compositor_render::{ - create_wgpu_ctx, error::InitRendererEngineError, required_wgpu_features, - set_required_wgpu_limits, - }; + use compositor_render::{required_wgpu_features, set_required_wgpu_limits}; use tracing::warn; let vulkan_features = diff --git a/compositor_pipeline/src/pipeline/input/rtp/depayloader.rs b/compositor_pipeline/src/pipeline/input/rtp/depayloader.rs index 7f5518e10..2b3858555 100644 --- a/compositor_pipeline/src/pipeline/input/rtp/depayloader.rs +++ b/compositor_pipeline/src/pipeline/input/rtp/depayloader.rs @@ -83,7 +83,14 @@ pub enum VideoDepayloader { impl VideoDepayloader { pub fn new(options: &decoder::VideoDecoderOptions) -> Self { match options.decoder { - VideoDecoder::FFmpegH264 | VideoDecoder::VulkanVideoH264 => VideoDepayloader::H264 { + VideoDecoder::FFmpegH264 => VideoDepayloader::H264 { + depayloader: H264Packet::default(), + buffer: vec![], + rollover_state: RolloverState::default(), + }, + + #[cfg(feature = "vk-video")] + VideoDecoder::VulkanVideoH264 => VideoDepayloader::H264 { depayloader: H264Packet::default(), buffer: vec![], rollover_state: RolloverState::default(), diff --git a/integration_tests/examples/manual_graphics_initialization.rs b/integration_tests/examples/manual_graphics_initialization.rs index d26ca05ee..236edd7f9 100644 --- a/integration_tests/examples/manual_graphics_initialization.rs +++ b/integration_tests/examples/manual_graphics_initialization.rs @@ -1,14 +1,14 @@ -use compositor_pipeline::{ - pipeline::{GraphicsContext, Options}, - Pipeline, -}; -use live_compositor::config::read_config; - // This example illustrates how to initialize a GraphicsContext separately to get access to a wgpu // instance, adapter, queue and device. #[cfg(target_os = "linux")] fn main() { + use compositor_pipeline::{ + pipeline::{GraphicsContext, Options}, + Pipeline, + }; + use live_compositor::config::read_config; + let graphics_context = GraphicsContext::new(false, wgpu::Features::default(), wgpu::Limits::default()).unwrap(); diff --git a/integration_tests/examples/vulkan.rs b/integration_tests/examples/vulkan.rs index 7409ac83f..099515b41 100644 --- a/integration_tests/examples/vulkan.rs +++ b/integration_tests/examples/vulkan.rs @@ -1,60 +1,9 @@ use anyhow::Result; -use compositor_api::types::Resolution; -use compositor_pipeline::{ - pipeline::{ - decoder::VideoDecoderOptions, - encoder::{ - ffmpeg_h264::{EncoderPreset, Options as H264Options}, - VideoEncoderOptions, - }, - input::{ - rtp::{InputVideoStream, RtpReceiverOptions, RtpStream}, - InputOptions, - }, - output::{ - rtp::{RtpConnectionOptions, RtpSenderOptions}, - OutputOptions, OutputProtocolOptions, - }, - rtp::{RequestedPort, TransportProtocol}, - Options, OutputVideoOptions, PipelineOutputEndCondition, Port, RegisterInputOptions, - RegisterOutputOptions, VideoCodec, VideoDecoder, - }, - queue::QueueInputOptions, - Pipeline, -}; -use compositor_render::{ - error::ErrorStack, - scene::{ - Component, ComponentId, HorizontalAlign, InputStreamComponent, RGBAColor, TilesComponent, - VerticalAlign, - }, - InputId, OutputId, -}; +use integration_tests::examples::download_all_assets; use live_compositor::{ - config::{read_config, LoggerConfig, LoggerFormat}, + config::{LoggerConfig, LoggerFormat}, logger::{self, FfmpegLogLevel}, }; -use signal_hook::{consts, iterator::Signals}; -use std::{ - sync::{Arc, Mutex}, - time::Duration, -}; - -use integration_tests::{ - examples::{download_all_assets, TestSample}, - ffmpeg::{start_ffmpeg_receive, start_ffmpeg_send}, -}; - -const VIDEO_RESOLUTION: Resolution = Resolution { - width: 1280, - height: 720, -}; - -const IP: &str = "127.0.0.1"; -const INPUT_PORT: u16 = 8002; -const OUTPUT_PORT: u16 = 8004; - -const VIDEOS: u16 = 6; fn main() { ffmpeg_next::format::network::init(); @@ -69,7 +18,66 @@ fn main() { client_code().unwrap(); } +#[cfg(target_os = "macos")] +fn client_code() -> Result<()> { + panic!("Your OS does not support vulkan"); +} + +#[cfg(target_os = "linux")] fn client_code() -> Result<()> { + use compositor_api::types::Resolution; + use compositor_pipeline::{ + pipeline::{ + decoder::VideoDecoderOptions, + encoder::{ + ffmpeg_h264::{EncoderPreset, Options as H264Options}, + VideoEncoderOptions, + }, + input::{ + rtp::{InputVideoStream, RtpReceiverOptions, RtpStream}, + InputOptions, + }, + output::{ + rtp::{RtpConnectionOptions, RtpSenderOptions}, + OutputOptions, OutputProtocolOptions, + }, + rtp::{RequestedPort, TransportProtocol}, + Options, OutputVideoOptions, PipelineOutputEndCondition, Port, RegisterInputOptions, + RegisterOutputOptions, VideoCodec, VideoDecoder, + }, + queue::QueueInputOptions, + Pipeline, + }; + use compositor_render::{ + error::ErrorStack, + scene::{ + Component, ComponentId, HorizontalAlign, InputStreamComponent, RGBAColor, + TilesComponent, VerticalAlign, + }, + InputId, OutputId, + }; + use live_compositor::config::read_config; + use signal_hook::{consts, iterator::Signals}; + use std::{ + sync::{Arc, Mutex}, + time::Duration, + }; + + use integration_tests::{ + examples::TestSample, + ffmpeg::{start_ffmpeg_receive, start_ffmpeg_send}, + }; + + const VIDEO_RESOLUTION: Resolution = Resolution { + width: 1280, + height: 720, + }; + + const IP: &str = "127.0.0.1"; + const INPUT_PORT: u16 = 8002; + const OUTPUT_PORT: u16 = 8004; + + const VIDEOS: u16 = 6; start_ffmpeg_receive(Some(OUTPUT_PORT), None)?; let config = read_config();