Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
joaoantoniocardoso committed Aug 31, 2022
1 parent 1d44f87 commit b67e12c
Show file tree
Hide file tree
Showing 4 changed files with 232 additions and 122 deletions.
6 changes: 5 additions & 1 deletion src/settings/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ mod tests {
use crate::stream::types::{
CaptureConfiguration, StreamInformation, VideoCaptureConfiguration,
};
use crate::video::video_source_local::LocalSourceDevice;
use crate::video::{
types::{FrameInterval, VideoEncodeType, VideoSourceType},
video_source_local::{VideoSourceLocal, VideoSourceLocalType},
Expand Down Expand Up @@ -267,7 +268,10 @@ mod tests {
},
video_source: VideoSourceType::Local(VideoSourceLocal {
name: "Fake Potato Test Video Source Camera".into(),
device_path: "/dev/potatovideo".into(),
devices: vec![LocalSourceDevice {
path: "/dev/potatovideo".into(),
encodings: vec![VideoEncodeType::H264],
}],
typ: VideoSourceLocalType::Usb("usb-0420:08:47.42-77".into()),
}),
}];
Expand Down
8 changes: 7 additions & 1 deletion src/stream/gst/pipeline_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,13 @@ impl Pipeline {
},
VideoSourceType::Local(local_device) => match &local_device.typ {
VideoSourceLocalType::Usb(_) | VideoSourceLocalType::LegacyRpiCam(_) => {
format!("v4l2src device={}", &local_device.device_path)
let device_path = local_device.get_device_path_for_encoding(
&video_and_stream_information
.stream_information
.configuration,
)?;

format!("v4l2src device={device_path}")
}
typ => {
return Err(simple_error!(format!(
Expand Down
16 changes: 15 additions & 1 deletion src/stream/stream_backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ fn create_stream(
mod tests {
use super::*;
use crate::stream::types::CaptureConfiguration;
use crate::video::video_source_local::LocalSourceDevice;
use crate::video::{
types::FrameInterval,
video_source_local::{VideoSourceLocal, VideoSourceLocalType},
Expand Down Expand Up @@ -327,11 +328,16 @@ mod tests {
},
video_source: VideoSourceType::Local(VideoSourceLocal {
name: "PotatoCam".into(),
device_path: "/dev/video42".into(),
devices: vec![LocalSourceDevice {
path: "/dev/video42".into(),
encodings: vec![video_encode_type.clone()],
}],
typ: VideoSourceLocalType::Usb("TestPotatoCam".into()),
}),
});

dbg!(&stream);

assert!(stream.is_ok());
stream.unwrap()
}
Expand All @@ -353,6 +359,8 @@ mod tests {
StreamType::UDP(video_stream_udp) => video_stream_udp.pipeline(),
_any_other_stream_type => panic!("Failed to create UDP stream: {stream:?}."),
};
dbg!(&pipeline);
dbg!(&expected_pipeline);
assert_eq!(&pipeline, expected_pipeline);
}
}
Expand All @@ -374,6 +382,8 @@ mod tests {
StreamType::RTSP(video_stream_rtsp) => video_stream_rtsp.pipeline(),
_any_other_stream_type => panic!("Failed to create RTSP stream: {stream:?}."),
};
dbg!(&pipeline);
dbg!(&expected_pipeline);
assert_eq!(&pipeline, expected_pipeline);
}
}
Expand Down Expand Up @@ -463,6 +473,8 @@ mod tests {
StreamType::WEBRTC(video_stream_webrtc) => video_stream_webrtc.pipeline(),
_any_other_stream_type => panic!("Failed to create WebRTC stream: {stream:?}."),
};
dbg!(&pipeline);
dbg!(&expected_pipeline);
assert_eq!(&pipeline, expected_pipeline);
}
}
Expand All @@ -484,6 +496,8 @@ mod tests {
StreamType::WEBRTC(video_stream_webrtc) => video_stream_webrtc.pipeline(),
_any_other_stream_type => panic!("Failed to create WebRTC stream: {stream:?}."),
};
dbg!(&pipeline);
dbg!(&expected_pipeline);
assert_eq!(&pipeline, expected_pipeline);
}
}
Expand Down
Loading

0 comments on commit b67e12c

Please sign in to comment.