chore: convert to bin
This commit is contained in:
parent
82c12b725f
commit
7734ae9c84
@ -3,6 +3,10 @@ name = "zap-stream-core"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[[bin]]
|
||||
name = "zap-stream-core"
|
||||
path = "src/bin/zap_stream_core.rs"
|
||||
|
||||
[features]
|
||||
default = ["test-source"]
|
||||
srt = ["dep:srt-tokio"]
|
||||
|
@ -25,7 +25,7 @@ RUN git clone --depth=1 https://git.ffmpeg.org/ffmpeg.git && \
|
||||
--disable-static \
|
||||
--enable-shared && \
|
||||
make -j$(nproc) && make install
|
||||
RUN cargo install --path . --root /app/build
|
||||
RUN cargo install --path . --bin zap-stream-core --root /app/build
|
||||
|
||||
FROM $IMAGE as runner
|
||||
WORKDIR /app
|
||||
|
6
src/bin/nostr_sidecar.rs
Normal file
6
src/bin/nostr_sidecar.rs
Normal file
@ -0,0 +1,6 @@
|
||||
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> anyhow::Result<()> {
|
||||
|
||||
}
|
@ -5,17 +5,12 @@ use ffmpeg_rs_raw::rstr;
|
||||
use log::{error, info};
|
||||
use url::Url;
|
||||
|
||||
use crate::egress::http::listen_out_dir;
|
||||
use crate::settings::Settings;
|
||||
use zap_stream_core::egress::http::listen_out_dir;
|
||||
#[cfg(feature = "srt")]
|
||||
use zap_stream_core::ingress::srt;
|
||||
use zap_stream_core::ingress::{file, tcp, test};
|
||||
use zap_stream_core::settings::Settings;
|
||||
|
||||
mod egress;
|
||||
mod fraction;
|
||||
mod ingress;
|
||||
mod ipc;
|
||||
mod pipeline;
|
||||
mod settings;
|
||||
mod variant;
|
||||
mod webhook;
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
struct Args {
|
||||
@ -53,8 +48,8 @@ async fn main() -> anyhow::Result<()> {
|
||||
let addr = format!("{}:{}", u.host_str().unwrap(), u.port().unwrap());
|
||||
match u.scheme() {
|
||||
#[cfg(feature = "srt")]
|
||||
"srt" => listeners.push(tokio::spawn(ingress::srt::listen(addr, settings.clone()))),
|
||||
"tcp" => listeners.push(tokio::spawn(ingress::tcp::listen(addr, settings.clone()))),
|
||||
"srt" => listeners.push(tokio::spawn(srt::listen(addr, settings.clone()))),
|
||||
"tcp" => listeners.push(tokio::spawn(tcp::listen(addr, settings.clone()))),
|
||||
_ => {
|
||||
error!("Unknown endpoint config: {e}");
|
||||
}
|
||||
@ -66,14 +61,14 @@ async fn main() -> anyhow::Result<()> {
|
||||
)));
|
||||
|
||||
if let Some(p) = args.file {
|
||||
listeners.push(tokio::spawn(ingress::file::listen(
|
||||
listeners.push(tokio::spawn(file::listen(
|
||||
p.parse()?,
|
||||
settings.clone(),
|
||||
)));
|
||||
}
|
||||
#[cfg(feature = "test-source")]
|
||||
if args.test_pattern {
|
||||
listeners.push(tokio::spawn(ingress::test::listen(settings.clone())));
|
||||
listeners.push(tokio::spawn(test::listen(settings.clone())));
|
||||
}
|
||||
|
||||
for handle in listeners {
|
@ -1,34 +0,0 @@
|
||||
#[derive(Clone, Debug, Copy)]
|
||||
pub struct Fraction {
|
||||
pub num: usize,
|
||||
pub den: usize,
|
||||
}
|
||||
|
||||
fn gcd(mut a: usize, mut b: usize) -> usize {
|
||||
if a == b {
|
||||
return a;
|
||||
}
|
||||
if b > a {
|
||||
std::mem::swap(&mut a, &mut b);
|
||||
}
|
||||
while b > 0 {
|
||||
let temp = a;
|
||||
a = b;
|
||||
b = temp % b;
|
||||
}
|
||||
a
|
||||
}
|
||||
|
||||
impl From<(usize, usize)> for Fraction {
|
||||
fn from(value: (usize, usize)) -> Self {
|
||||
let num = value.0;
|
||||
let den = value.1;
|
||||
|
||||
let gcd = gcd(num, den);
|
||||
|
||||
Self {
|
||||
num: num / gcd,
|
||||
den: den / gcd,
|
||||
}
|
||||
}
|
||||
}
|
35
src/ipc.rs
35
src/ipc.rs
@ -1,35 +0,0 @@
|
||||
use anyhow::Error;
|
||||
use async_trait::async_trait;
|
||||
|
||||
#[async_trait]
|
||||
pub trait Rx<T> {
|
||||
async fn recv(&mut self) -> Result<T, Error>;
|
||||
fn try_recv_next(&mut self) -> Result<T, Error>;
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl<T> Rx<T> for tokio::sync::mpsc::UnboundedReceiver<T>
|
||||
where
|
||||
T: Send + Sync,
|
||||
{
|
||||
async fn recv(&mut self) -> Result<T, Error> {
|
||||
self.recv().await.ok_or(Error::msg("recv error"))
|
||||
}
|
||||
|
||||
fn try_recv_next(&mut self) -> Result<T, Error> {
|
||||
Ok(self.try_recv()?)
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl<T> Rx<T> for tokio::sync::broadcast::Receiver<T>
|
||||
where
|
||||
T: Send + Sync + Clone,
|
||||
{
|
||||
async fn recv(&mut self) -> Result<T, Error> {
|
||||
Ok(self.recv().await?)
|
||||
}
|
||||
fn try_recv_next(&mut self) -> Result<T, Error> {
|
||||
Ok(self.try_recv()?)
|
||||
}
|
||||
}
|
6
src/lib.rs
Normal file
6
src/lib.rs
Normal file
@ -0,0 +1,6 @@
|
||||
pub mod egress;
|
||||
pub mod ingress;
|
||||
pub mod pipeline;
|
||||
pub mod settings;
|
||||
pub mod variant;
|
||||
pub mod webhook;
|
@ -102,7 +102,7 @@ impl PipelineRunner {
|
||||
// Copy frame from GPU if using hwaccel decoding
|
||||
let frame = get_frame_from_hw(frame)?;
|
||||
|
||||
/// Get the variants which want this pkt
|
||||
// Get the variants which want this pkt
|
||||
let pkt_vars = self
|
||||
.config
|
||||
.variants
|
||||
|
Loading…
x
Reference in New Issue
Block a user