Skip to content

Commit 7f7cd7e

Browse files
authored
Update dependeices (#46)
* bugfix * update all dependencies except messageio
1 parent 9fbe651 commit 7f7cd7e

File tree

7 files changed

+79
-51
lines changed

7 files changed

+79
-51
lines changed

Cargo.lock

Lines changed: 41 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,26 +15,28 @@ categories = ["command-line-utilities", "command-line-interface"]
1515
maintenance = { status = "actively-developed" }
1616

1717
[dependencies]
18+
#message-io = { default-features = false, features = ["udp", "tcp"], version = "0.6.0" }
1819
message-io = "0.6.0"
19-
serde = { version = "1.0.118", features = ["derive"] }
20+
serde = { version = "1.0.124", features = ["derive"] }
2021
#keep the same version as tui for faster compile time
2122
crossterm = "0.18.2"
2223
tui = { version = "0.14.0", default-features = false, features = ['crossterm', 'serde'] }
23-
whoami = "1.0.3"
24+
whoami = "1.1.0"
2425
chrono = "0.4.19"
2526
clap = "2.33.3"
2627
unicode-width = "0.1.8"
27-
resize = "0.5.5"
2828
shellwords = "1.1.0"
29-
shellexpand = "2.1"
29+
shellexpand = "2.1.0"
3030
toml = "0.5.8"
3131
dirs-next = "2.0.0"
32+
rgb = {version="0.8.25", features=["serde"]}
33+
resize = "0.7.0"
3234

3335
[target.'cfg(target_os = "linux")'.dependencies]
3436
v4l = { version = "0.12.0", optional = true }
3537

3638
[dev-dependencies]
37-
rand = "0.8.1"
39+
rand = "0.8.3"
3840

3941
[features]
4042
stream-video = ["v4l"]

src/application.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ impl<'a> Application<'a> {
188188
}
189189
}
190190
NetMessage::Stream(data) => match data {
191-
Some((data, width, height)) if data.len() / 3 == width * height / 2 => {
191+
Some((data, width, height)) if data.len() == width * height / 2 => {
192192
self.state
193193
.windows
194194
.entry(endpoint)

src/commands/send_stream/linux.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ use crate::message::{NetMessage};
55
use crate::util::{Result, Reportable};
66

77
use message_io::network::{Network};
8+
use resize::px::RGB;
9+
use rgb::RGB8;
810
use v4l::prelude::*;
911
use v4l::FourCC;
1012
use v4l::buffer::Type;
@@ -66,7 +68,7 @@ impl Action for SendStream {
6668
}
6769
};
6870
#[allow(non_snake_case)]
69-
let data: Vec<u8> = data.chunks_exact(4).fold(vec![], |mut acc, v| {
71+
let data: Vec<RGB8> = data.chunks_exact(4).fold(vec![], |mut acc, v| {
7072
// convert form YUYV to RGB
7173
let [Y, U, _, V]: [u8; 4] = std::convert::TryFrom::try_from(v).unwrap();
7274
let Y = Y as f32;
@@ -81,9 +83,8 @@ impl Action for SendStream {
8183
let r = r as u8;
8284
let g = g as u8;
8385
let b = b as u8;
84-
acc.push(r);
85-
acc.push(g);
86-
acc.push(b);
86+
87+
acc.push(RGB::new(r, g, b));
8788
acc
8889
});
8990

src/message.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use rgb::RGB8;
12
use serde::{Deserialize, Serialize};
23

34
#[derive(Serialize, Deserialize)]
@@ -9,9 +10,9 @@ pub enum Chunk {
910

1011
#[derive(Serialize, Deserialize)]
1112
pub enum NetMessage {
12-
HelloLan(String, u16), // user_name, server_port
13-
HelloUser(String), // user_name
14-
UserMessage(String), // content
15-
UserData(String, Chunk), // file_name, chunk
16-
Stream(Option<(Vec<u8>, usize, usize)>), // Option of (stream_data width, height ) None means stream has ended
13+
HelloLan(String, u16), // user_name, server_port
14+
HelloUser(String), // user_name
15+
UserMessage(String), // content
16+
UserData(String, Chunk), // file_name, chunk
17+
Stream(Option<(Vec<RGB8>, usize, usize)>), // Option of (stream_data width, height ) None means stream has ended
1718
}

src/state.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use message_io::network::Endpoint;
22
use chrono::{DateTime, Local};
3+
use rgb::RGB8;
34

45
use std::collections::HashMap;
56

@@ -38,7 +39,7 @@ impl ChatMessage {
3839
}
3940

4041
pub struct Window {
41-
pub data: Vec<u8>,
42+
pub data: Vec<RGB8>,
4243
pub width: usize,
4344
pub height: usize,
4445
}
@@ -259,11 +260,10 @@ impl State {
259260
pub fn update_window(
260261
&mut self,
261262
endpoint: &Endpoint,
262-
data: Vec<u8>,
263+
data: Vec<RGB8>,
263264
width: usize,
264265
height: usize,
265-
)
266-
{
266+
) {
267267
let window = self.windows.get_mut(endpoint).expect("Window should exist");
268268
window.width = width;
269269
window.height = height;

src/ui.rs

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use resize::Pixel::RGB24;
1+
use resize::{Pixel::RGB8, px::RGB};
22
use resize::Type::Lanczos3;
33
use crate::{config::Theme, state::Window};
44

@@ -20,8 +20,7 @@ pub fn draw(
2020
state: &State,
2121
chunk: Rect,
2222
theme: &Theme,
23-
)
24-
{
23+
) {
2524
let chunks = Layout::default()
2625
.direction(Direction::Vertical)
2726
.constraints([Constraint::Min(0), Constraint::Length(6)].as_ref())
@@ -48,8 +47,7 @@ fn draw_messages_panel(
4847
state: &State,
4948
chunk: Rect,
5049
theme: &Theme,
51-
)
52-
{
50+
) {
5351
let message_colors = &theme.message_colors;
5452

5553
let messages = state
@@ -121,8 +119,7 @@ fn add_progress_bar<'a>(
121119
panel_width: u16,
122120
progress: &'a ProgressState,
123121
theme: &Theme,
124-
) -> Vec<Span<'a>>
125-
{
122+
) -> Vec<Span<'a>> {
126123
let color = theme.progress_bar_color;
127124
let width = (panel_width - 20) as usize;
128125

@@ -174,8 +171,7 @@ fn draw_input_panel(
174171
state: &State,
175172
chunk: Rect,
176173
theme: &Theme,
177-
)
178-
{
174+
) {
179175
let inner_width = (chunk.width - 2) as usize;
180176

181177
let input = state.input().iter().collect::<String>();
@@ -244,19 +240,20 @@ impl tui::widgets::Widget for FrameBuffer<'_> {
244240
window.height,
245241
area.width as usize,
246242
area.height as usize,
247-
RGB24,
243+
RGB8,
248244
Lanczos3,
249-
);
250-
let mut dst = vec![0; (area.width * area.height) as usize * 3];
251-
resizer.resize(&window.data, &mut dst);
245+
)
246+
.unwrap();
247+
let mut dst = vec![RGB::new(0, 0, 0); (area.width * area.height) as usize];
248+
resizer.resize(&window.data, &mut dst).unwrap();
252249

253-
let mut dst = dst.chunks(3);
250+
let mut dst = dst.iter();
254251
for j in area.y..area.y + area.height {
255252
for i in area.x..area.x + area.width {
256-
let cell = dst.next().unwrap();
257-
let r = cell[0];
258-
let g = cell[1];
259-
let b = cell[2];
253+
let rgb = dst.next().unwrap();
254+
let r = rgb.r;
255+
let g = rgb.g;
256+
let b = rgb.b;
260257
buf.get_mut(i, j).set_bg(Color::Rgb(r, g, b));
261258
}
262259
}

0 commit comments

Comments
 (0)