Skip to content

Commit

Permalink
hls
Browse files Browse the repository at this point in the history
  • Loading branch information
warycat committed Apr 23, 2021
1 parent da2d435 commit 077401c
Show file tree
Hide file tree
Showing 20 changed files with 362 additions and 264 deletions.
60 changes: 42 additions & 18 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ script = "tar -czvf static.tar.gz static"

[tasks.watch-wasm]
run_task = { name = ["wasm-pack"] }
watch = { postpone = true, watch = ["./wasm/", "./msg/"] }
watch = { postpone = true, watch = ["./wasm/", "./msg/", "./consts"] }

[tasks.watch-server]
script = "cargo watch -w server -w msg -x 'run --bin rustgym-server'"
script = "cargo watch -w server -w msg -w consts -x 'run --bin rustgym-server'"
dependencies = ["wasm-pack"]

[tasks.sonic]
Expand Down
3 changes: 2 additions & 1 deletion consts/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ pub const SONIC_BUCKET: &str = "bucket";
pub const SEARCH_PLACEHOLDER: &str = "Search Rust Solutions";

pub const TIME_SLICE: i32 = 100;
pub const MIME_TYPE: &str = "video/webm;codecs=vp8,opus";
pub const MIME_TYPE: &str = "video/x-matroska;codecs=avc1,opus";
pub const STREAM_DIR: &str = "/Users/larry/Documents/rustgym/stream";
2 changes: 1 addition & 1 deletion infra/config.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

[server]

log_level = "debug"
log_level = "error"


[channel]
Expand Down
22 changes: 18 additions & 4 deletions msg/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,29 @@ use uuid::Uuid;

#[derive(Serialize, Deserialize, Debug, Clone)]
pub enum Msg {
In(MsgIn),
Out(MsgOut),
}

#[derive(Serialize, Deserialize, Debug, Clone)]
pub enum MsgIn {
Ping,
Pong,
SearchText(String),
QueryText(String),
StreamStart(String),
}

#[derive(Serialize, Deserialize, Debug, Clone)]
pub enum MsgOut {
Ping,
Pong,
RegistorClient(ClientInfo),
UnRegistorClient(ClientInfo),
SessionClients(HashSet<ClientInfo>),
SearchText(String),
SessionClients(Vec<ClientInfo>),
AllClients(Vec<ClientInfo>),
SearchSuggestions(Vec<String>),
QueryText(String),
QueryResults(Vec<QueryResult>),
StreamStart(String),
}

#[derive(Serialize, Deserialize, Debug, Clone, Hash, Eq, PartialEq, new)]
Expand All @@ -25,6 +38,7 @@ pub struct ClientInfo {
pub client_uuid: Uuid,
pub name: String,
pub chrome: bool,
pub streaming: bool,
}

#[derive(Serialize, Deserialize, Debug, Clone, new)]
Expand Down
2 changes: 1 addition & 1 deletion server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@ serde = "1.0.118"
serde_json = "1.0.61"
uuid = { version = "0.8", features = ["serde", "v4"] }
sonic-channel = "0.4.0"
tokio = { version = "1.5.0", features = ["sync"] }
tokio = { version = "0.2", features = ["full"] }
uaparser = "0.4.0"
3 changes: 0 additions & 3 deletions server/src/agents/chunk.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
use crate::agents::websocket::SocketClient;
use actix::prelude::*;
use actix_web::web::Bytes;
use rustgym_msg::ClientInfo;
use rustgym_msg::Msg;

#[derive(Message, Clone, new)]
#[rtype(result = "()")]
pub struct Chunk {
pub client_addr: Addr<SocketClient>,
pub client_info: ClientInfo,
pub bytes: Bytes,
}
43 changes: 40 additions & 3 deletions server/src/agents/envelope.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,46 @@
use crate::agents::websocket::SocketClient;
use actix::prelude::*;
use rustgym_msg::ClientInfo;
use rustgym_msg::Msg;
use serde::{Deserialize, Serialize};
use rustgym_msg::*;
use std::fmt;

#[derive(Debug, Deserialize, Serialize, Clone, new)]
#[derive(Message, Debug, Clone, new)]
#[rtype(result = "()")]
pub struct Envelope {
pub client_addr: Addr<SocketClient>,
pub client_info: ClientInfo,
pub msg: Msg,
}

impl Envelope {
pub fn from_msg_in(
client_addr: Addr<SocketClient>,
client_info: ClientInfo,
msg_in: MsgIn,
) -> Self {
let msg = Msg::In(msg_in);
Envelope {
client_addr,
client_info,
msg,
}
}
pub fn from_msg_out(
client_addr: Addr<SocketClient>,
client_info: ClientInfo,
msg_out: MsgOut,
) -> Self {
let msg = Msg::Out(msg_out);
Envelope {
client_addr,
client_info,
msg,
}
}
}

impl fmt::Debug for SocketClient {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "<SocketClient>")
}
}
1 change: 0 additions & 1 deletion server/src/agents/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
pub mod chunk;
pub mod envelope;
pub mod package;
pub mod registry;
pub mod search;
pub mod uap;
Expand Down
26 changes: 0 additions & 26 deletions server/src/agents/package.rs

This file was deleted.

Loading

0 comments on commit 077401c

Please sign in to comment.