Compare commits

..

No commits in common. "main" and "fix-flake" have entirely different histories.

9 changed files with 260 additions and 434 deletions

523
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -1,7 +1,7 @@
[package] [package]
name = "servicepoint-cli" name = "servicepoint-cli"
description = "A command line interface for the ServicePoint display." description = "A command line interface for the ServicePoint display."
version = "0.4.1" version = "0.4.0"
edition = "2021" edition = "2021"
rust-version = "1.80.0" rust-version = "1.80.0"
publish = true publish = true
@ -17,11 +17,14 @@ clap = { version = "4.5", features = ["derive"] }
env_logger = "0.11" env_logger = "0.11"
log = "0.4" log = "0.4"
scap = "0.0.8" scap = "0.0.8"
image = "0.25" image = "0.25.5"
fast_image_resize = { version = "5.1", features = ["image"] } fast_image_resize = { version = "5.1", features = ["image"] }
tungstenite = "0.26" tungstenite = "0.26"
ffmpeg-next = "7.1" ffmpeg-next = "7.1.0"
servicepoint = "0.15.1"
[dependencies.servicepoint]
package = "servicepoint"
version = "0.14.1"
[profile.release] [profile.release]
lto = true # Enable link-time optimization lto = true # Enable link-time optimization

View file

@ -21,9 +21,14 @@ If you have set your PATH to include the ~/.cargo/bin, you can now run `servicep
## Running with nix ## Running with nix
```shell ```shell
# from CCCB Forgejo
nix run git+https://git.berlin.ccc.de/servicepoint/servicepoint-cli.git -- <args> nix run git+https://git.berlin.ccc.de/servicepoint/servicepoint-cli.git -- <args>
# from GitHub mirror
nix run github:kaesaecracker/servicepoint-cli -- <args>
``` ```
## Running a debug build ## Running a debug build
```shell ```shell

83
flake.lock generated
View file

@ -1,40 +1,17 @@
{ {
"nodes": { "nodes": {
"fenix": {
"inputs": {
"nixpkgs": [
"naersk",
"nixpkgs"
],
"rust-analyzer-src": "rust-analyzer-src"
},
"locked": {
"lastModified": 1752475459,
"narHash": "sha256-z6QEu4ZFuHiqdOPbYss4/Q8B0BFhacR8ts6jO/F/aOU=",
"owner": "nix-community",
"repo": "fenix",
"rev": "bf0d6f70f4c9a9cf8845f992105652173f4b617f",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "fenix",
"type": "github"
}
},
"naersk": { "naersk": {
"inputs": { "inputs": {
"fenix": "fenix",
"nixpkgs": [ "nixpkgs": [
"nixpkgs" "nixpkgs"
] ]
}, },
"locked": { "locked": {
"lastModified": 1763384566, "lastModified": 1745925850,
"narHash": "sha256-r+wgI+WvNaSdxQmqaM58lVNvJYJ16zoq+tKN20cLst4=", "narHash": "sha256-cyAAMal0aPrlb1NgzMxZqeN1mAJ2pJseDhm2m6Um8T0=",
"owner": "nix-community", "owner": "nix-community",
"repo": "naersk", "repo": "naersk",
"rev": "d4155d6ebb70fbe2314959842f744aa7cabbbf6a", "rev": "38bc60bbc157ae266d4a0c96671c6c742ee17a5f",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -45,11 +22,11 @@
}, },
"nix-filter": { "nix-filter": {
"locked": { "locked": {
"lastModified": 1757882181, "lastModified": 1731533336,
"narHash": "sha256-+cCxYIh2UNalTz364p+QYmWHs0P+6wDhiWR4jDIKQIU=", "narHash": "sha256-oRam5PS1vcrr5UPgALW0eo1m/5/pls27Z/pabHNy2Ms=",
"owner": "numtide", "owner": "numtide",
"repo": "nix-filter", "repo": "nix-filter",
"rev": "59c44d1909c72441144b93cf0f054be7fe764de5", "rev": "f7653272fd234696ae94229839a99b73c9ab7de0",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -60,16 +37,16 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1764677808, "lastModified": 1746183838,
"narHash": "sha256-H3lC7knbXOBrHI9hITQ7modLuX20mYJVhZORL5ioms0=", "narHash": "sha256-kwaaguGkAqTZ1oK0yXeQ3ayYjs8u/W7eEfrFpFfIDFA=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "1aab89277eb2d87823d5b69bae631a2496cff57a", "rev": "bf3287dac860542719fe7554e21e686108716879",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "nixos", "owner": "nixos",
"ref": "nixos-25.11", "ref": "nixos-24.11",
"repo": "nixpkgs", "repo": "nixpkgs",
"type": "github" "type": "github"
} }
@ -78,45 +55,7 @@
"inputs": { "inputs": {
"naersk": "naersk", "naersk": "naersk",
"nix-filter": "nix-filter", "nix-filter": "nix-filter",
"nixpkgs": "nixpkgs", "nixpkgs": "nixpkgs"
"treefmt-nix": "treefmt-nix"
}
},
"rust-analyzer-src": {
"flake": false,
"locked": {
"lastModified": 1752428706,
"narHash": "sha256-EJcdxw3aXfP8Ex1Nm3s0awyH9egQvB2Gu+QEnJn2Sfg=",
"owner": "rust-lang",
"repo": "rust-analyzer",
"rev": "591e3b7624be97e4443ea7b5542c191311aa141d",
"type": "github"
},
"original": {
"owner": "rust-lang",
"ref": "nightly",
"repo": "rust-analyzer",
"type": "github"
}
},
"treefmt-nix": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1762938485,
"narHash": "sha256-AlEObg0syDl+Spi4LsZIBrjw+snSVU4T8MOeuZJUJjM=",
"owner": "numtide",
"repo": "treefmt-nix",
"rev": "5b4ee75aeefd1e2d5a1cc43cf6ba65eba75e83e4",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "treefmt-nix",
"type": "github"
} }
} }
}, },

View file

@ -2,36 +2,23 @@
description = "Flake for command line interface of the ServicePoint display."; description = "Flake for command line interface of the ServicePoint display.";
inputs = { inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-25.11"; nixpkgs.url = "github:nixos/nixpkgs/nixos-24.11";
nix-filter.url = "github:numtide/nix-filter"; nix-filter.url = "github:numtide/nix-filter";
naersk = { naersk = {
url = "github:nix-community/naersk"; url = "github:nix-community/naersk";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
treefmt-nix = {
url = "github:numtide/treefmt-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
}; };
outputs = outputs =
{ inputs@{
self, self,
nixpkgs, nixpkgs,
naersk, naersk,
nix-filter, nix-filter,
treefmt-nix,
}: }:
let let
lib = nixpkgs.lib; lib = nixpkgs.lib;
treefmt-config = {
projectRootFile = "flake.nix";
programs = {
nixfmt.enable = true;
keep-sorted.enable = true;
rustfmt.enable = true;
};
};
supported-systems = [ supported-systems = [
"x86_64-linux" "x86_64-linux"
"aarch64-linux" "aarch64-linux"
@ -44,7 +31,6 @@
system: system:
f rec { f rec {
pkgs = nixpkgs.legacyPackages.${system}; pkgs = nixpkgs.legacyPackages.${system};
treefmt-eval = treefmt-nix.lib.evalModule pkgs treefmt-config;
inherit system; inherit system;
} }
); );
@ -56,7 +42,7 @@
naersk' = pkgs.callPackage naersk { }; naersk' = pkgs.callPackage naersk { };
in in
rec { rec {
servicepoint-cli = naersk'.buildPackage { servicepoint-cli = naersk'.buildPackage rec {
src = nix-filter.lib.filter { src = nix-filter.lib.filter {
root = ./.; root = ./.;
include = [ include = [
@ -77,7 +63,7 @@
[ [
xe xe
xz xz
ffmpeg_6-headless.dev ffmpeg-headless
] ]
++ lib.optionals pkgs.stdenv.isLinux ( ++ lib.optionals pkgs.stdenv.isLinux (
with pkgs; with pkgs;
@ -94,14 +80,6 @@
legacyPackages = packages; legacyPackages = packages;
nixosModules.default = {
nixpkgs.overlays = [ self.overlays.default ];
};
overlays.default = final: prev: {
servicepoint-cli = self.legacyPackages."${prev.system}".servicepoint-cli;
};
devShells = forAllSystems ( devShells = forAllSystems (
{ {
pkgs, pkgs,
@ -128,12 +106,10 @@
]; ];
LD_LIBRARY_PATH = "${pkgs.lib.makeLibraryPath (builtins.concatMap (d: d.buildInputs) inputsFrom)}"; LD_LIBRARY_PATH = "${pkgs.lib.makeLibraryPath (builtins.concatMap (d: d.buildInputs) inputsFrom)}";
RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}"; RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";
RUST_LOG = "all";
RUST_BACKTRACE = "1";
}; };
} }
); );
formatter = forAllSystems ({ treefmt-eval, ... }: treefmt-eval.config.build.wrapper); formatter = forAllSystems ({ pkgs, ... }: pkgs.nixfmt-rfc-style);
}; };
} }

View file

@ -164,7 +164,9 @@ impl ImageProcessingPipeline {
let result = (width, height); let result = (width, height);
trace!( trace!(
"scaling {:?} to {:?} to fit {:?}", "scaling {:?} to {:?} to fit {:?}",
source, result, self.render_size source,
result,
self.render_size
); );
result result
} }

View file

@ -92,8 +92,7 @@ fn pixels_video(
) { ) {
ffmpeg::init().unwrap(); ffmpeg::init().unwrap();
let mut ictx = let mut ictx = ffmpeg::format::input(&options.file_name).expect("failed to open video input file");
ffmpeg::format::input(&options.file_name).expect("failed to open video input file");
let input = ictx let input = ictx
.streams() .streams()
@ -104,14 +103,12 @@ fn pixels_video(
let context_decoder = ffmpeg::codec::context::Context::from_parameters(input.parameters()) let context_decoder = ffmpeg::codec::context::Context::from_parameters(input.parameters())
.expect("could not extract video context from parameters"); .expect("could not extract video context from parameters");
let mut decoder = context_decoder let mut decoder = context_decoder.decoder().video()
.decoder()
.video()
.expect("failed to create decoder for video stream"); .expect("failed to create decoder for video stream");
let src_width = decoder.width(); let src_width = decoder.width();
let src_height = decoder.height(); let src_height = decoder.height();
let mut scaler = ffmpeg::software::scaling::Context::get( let mut scaler = ffmpeg::software::scaling::Context::get(
decoder.format(), decoder.format(),
src_width, src_width,
@ -120,8 +117,7 @@ fn pixels_video(
src_width, src_width,
src_height, src_height,
ffmpeg::software::scaling::Flags::BILINEAR, ffmpeg::software::scaling::Flags::BILINEAR,
) ).expect("failed to create scaling context");
.expect("failed to create scaling context");
let mut frame_index = 0; let mut frame_index = 0;
@ -132,16 +128,14 @@ fn pixels_video(
let mut decoded = ffmpeg::util::frame::video::Video::empty(); let mut decoded = ffmpeg::util::frame::video::Video::empty();
let mut rgb_frame = ffmpeg::util::frame::video::Video::empty(); let mut rgb_frame = ffmpeg::util::frame::video::Video::empty();
while decoder.receive_frame(&mut decoded).is_ok() { while decoder.receive_frame(&mut decoded).is_ok() {
scaler scaler.run(&decoded, &mut rgb_frame)
.run(&decoded, &mut rgb_frame)
.expect("failed to scale frame"); .expect("failed to scale frame");
let image = RgbImage::from_raw(src_width, src_height, rgb_frame.data(0).to_owned()) let image = RgbImage::from_raw(src_width, src_height, rgb_frame.data(0).to_owned())
.expect("could not read rgb data to image"); .expect("could not read rgb data to image");
let image = DynamicImage::from(image); let image = DynamicImage::from(image);
let bitmap = processing_pipeline.process(image); let bitmap= processing_pipeline.process(image);
connection connection.send_command(BitmapCommand::from(bitmap))
.send_command(BitmapCommand::from(bitmap))
.expect("failed to send image command"); .expect("failed to send image command");
frame_index += 1; frame_index += 1;
@ -151,13 +145,13 @@ fn pixels_video(
for (stream, packet) in ictx.packets() { for (stream, packet) in ictx.packets() {
if stream.index() == video_stream_index { if stream.index() == video_stream_index {
decoder decoder.send_packet(&packet)
.send_packet(&packet)
.expect("failed to send video packet"); .expect("failed to send video packet");
receive_and_process_decoded_frames(&mut decoder) receive_and_process_decoded_frames(&mut decoder)
.expect("failed to process video packet"); .expect("failed to process video packet");
} }
} }
decoder.send_eof().expect("failed to send eof"); decoder.send_eof().expect("failed to send eof");
receive_and_process_decoded_frames(&mut decoder).expect("failed to eof packet"); receive_and_process_decoded_frames(&mut decoder)
.expect("failed to eof packet");
} }

View file

@ -4,9 +4,7 @@ use servicepoint::*;
use std::thread::sleep; use std::thread::sleep;
pub(crate) fn stream_stdin(connection: &Transport, slow: bool) { pub(crate) fn stream_stdin(connection: &Transport, slow: bool) {
warn!( warn!("This mode will break when using multi-byte characters and does not support ANSI escape sequences yet.");
"This mode will break when using multi-byte characters and does not support ANSI escape sequences yet."
);
let mut app = App { let mut app = App {
connection, connection,
mirror: CharGrid::new(TILE_WIDTH, TILE_HEIGHT), mirror: CharGrid::new(TILE_WIDTH, TILE_HEIGHT),

View file

@ -7,10 +7,10 @@ use image::{DynamicImage, ImageBuffer, Rgb, Rgba};
use log::{debug, error, info, trace, warn}; use log::{debug, error, info, trace, warn};
use scap::{ use scap::{
capturer::{Capturer, Options}, capturer::{Capturer, Options},
frame::Frame,
frame::convert_bgra_to_rgb, frame::convert_bgra_to_rgb,
frame::Frame,
}; };
use servicepoint::{BitmapCommand, CompressionCode, FRAME_PACING, Origin}; use servicepoint::{BitmapCommand, CompressionCode, Origin, FRAME_PACING};
use std::time::{Duration, Instant}; use std::time::{Duration, Instant};
pub fn stream_window( pub fn stream_window(