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 linting on macos #823

Merged
merged 2 commits into from
Oct 14, 2024
Merged
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
38 changes: 38 additions & 0 deletions .github/workflows/macos_lint.yml
Original file line number Diff line number Diff line change
@@ -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

16 changes: 7 additions & 9 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 2 additions & 4 deletions compositor_pipeline/src/pipeline/graphics_context.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::error::InitPipelineError;
use compositor_render::{create_wgpu_ctx, error::InitRendererEngineError};
use std::sync::Arc;

#[derive(Debug)]
Expand All @@ -17,10 +18,7 @@ impl GraphicsContext {
features: wgpu::Features,
limits: wgpu::Limits,
) -> Result<Self, InitPipelineError> {
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 =
Expand Down
9 changes: 8 additions & 1 deletion compositor_pipeline/src/pipeline/input/rtp/depayloader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
12 changes: 6 additions & 6 deletions integration_tests/examples/manual_graphics_initialization.rs
Original file line number Diff line number Diff line change
@@ -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();

Expand Down
114 changes: 61 additions & 53 deletions integration_tests/examples/vulkan.rs
Original file line number Diff line number Diff line change
@@ -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();
Expand All @@ -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();
Expand Down