Skip to content

Commit c4a99a9

Browse files
committed
Address Comments
1 parent f83a04b commit c4a99a9

5 files changed

Lines changed: 20 additions & 23 deletions

File tree

scylla-server/src/controllers/file_insertion_controller.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use crate::{
1313
error::ScyllaError, proto::playback_data, services::run_service, ClientData, PoolHandle,
1414
};
1515

16-
use super::video_streamer_controller::OutputDirectory;
16+
use super::OutputDirectory;
1717

1818
/// Inserts a logger file using http multipart
1919
/// This file is parsed and clientdata values are extracted, the run ID of each variable is inferred, and then data is batch uploaded
@@ -118,7 +118,7 @@ pub async fn insert_file(
118118
continue;
119119
};
120120

121-
println!("Inserting file: {}", name);
121+
info!("Inserting file: {}", name);
122122

123123
fs::write(format!("{}/{}", output_directory.0, name), data)
124124
.await

scylla-server/src/controllers/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,9 @@ pub mod run_controller;
77

88
pub mod file_insertion_controller;
99
pub mod video_streamer_controller;
10+
11+
#[derive(Clone)]
12+
pub struct VideoSuffix(pub String);
13+
14+
#[derive(Clone)]
15+
pub struct OutputDirectory(pub String);

scylla-server/src/controllers/video_streamer_controller.rs

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,11 @@ use crate::{
1919
proto::serverdata::{self},
2020
};
2121

22-
#[derive(Clone)]
23-
pub struct VideoSuffix(pub String);
24-
25-
#[derive(Clone)]
26-
pub struct OutputDirectory(pub String);
22+
use super::{OutputDirectory, VideoSuffix};
2723

2824
const INITIAL_CHUNK_SIZE: u64 = 1_048_576; // 1 MB for faster initial load
2925

26+
// Inspired by https://github.com/henningcullin/rustflix/blob/90cbcf2f33a2c26792a21fcbe295db146d2333a5/src-tauri/src/server/stream_film.rs#L35
3027
pub async fn stream_video(
3128
Path(file_path): Path<String>,
3229
Extension(output_directory): Extension<OutputDirectory>,
@@ -125,17 +122,6 @@ pub async fn request_updated_videos(
125122
)
126123
.await
127124
.map_err(|err| ScyllaError::MqttError(format!("Failed to send mqtt message: {}", err)))?;
128-
129-
payload.values = vec![0.0];
130-
mqtt_client
131-
.publish(
132-
"Scylla/Video/Send",
133-
rumqttc::v5::mqttbytes::QoS::ExactlyOnce,
134-
false,
135-
protobuf::Message::write_to_bytes(&payload)
136-
.unwrap_or_else(|e| format!("failed to serialize {}", e).as_bytes().to_vec()),
137-
)
138-
.await
139-
.map_err(|err| ScyllaError::MqttError(format!("Failed to send mqtt message: {}", err)))?;
125+
140126
Ok(Json::from("Sent Request to update videos".to_string()))
141127
}

scylla-server/src/main.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ use scylla_server::{
2525
self,
2626
car_command_controller::{self},
2727
data_type_controller, file_insertion_controller, run_controller, scylla_config_controller,
28-
video_streamer_controller::{self, OutputDirectory, VideoSuffix},
28+
video_streamer_controller::{self},
29+
OutputDirectory, VideoSuffix,
2930
},
3031
services::run_service::{self},
3132
socket_handler::{socket_handler, socket_handler_with_metadata},
@@ -74,7 +75,7 @@ struct ScyllaArgs {
7475
short = 'u',
7576
long,
7677
env = "SCYLLA_SIREN_HOST_URL",
77-
default_value = "192.168.100.11:1883"
78+
default_value = "localhost:1883"
7879
)]
7980
siren_host_url: String,
8081

@@ -355,14 +356,17 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
355356
"/videos/{file_name}",
356357
get(video_streamer_controller::stream_video),
357358
)
358-
.route("/videos", get(video_streamer_controller::get_videos))
359+
.route(
360+
"/videos",
361+
get(video_streamer_controller::get_videos)
362+
.layer(Extension(VideoSuffix(cli.video_suffix))),
363+
)
359364
.route(
360365
"/videos/update",
361366
post(video_streamer_controller::request_updated_videos),
362367
)
363368
.layer(Extension(db_send))
364369
.layer(Extension(OutputDirectory(cli.output_directory)))
365-
.layer(Extension(VideoSuffix(cli.video_suffix)))
366370
.layer(Extension(client_sharable))
367371
.layer(DefaultBodyLimit::disable())
368372
// for CORS handling

scylla-server/src/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
pub mod command_data;
44
pub mod playback_data;
55
pub mod serverdata;
6+

0 commit comments

Comments
 (0)