Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
joaoantoniocardoso committed Jul 18, 2024
1 parent 16ee51a commit 76d8a58
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 12 deletions.
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ turn = "0.7"
## Image/Thumbnail
image = "0.24"

statrs = "0.17.1"

## GSTREAMER
gst = { package = "gstreamer", version = "0.22", features = ["v1_16"] }
gst-app = { package = "gstreamer-app", version = "0.22", features = ["v1_16"] }
Expand Down
2 changes: 1 addition & 1 deletion src/lib/stream/pipeline/redirect_pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ impl RedirectPipeline {
"udp" => {
format!(
concat!(
"udpsrc address={address} port={port} close-socket=false auto-multicast=true",
"udpsrc address={address} port={port} close-socket=false auto-multicast=true do-timestamp=true",
" ! application/x-rtp",
" ! tee name={sink_tee_name} allow-not-linked=true"
),
Expand Down
1 change: 1 addition & 0 deletions src/lib/stream/pipeline/v4l_pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ impl V4lPipeline {
concat!(
"v4l2src device={device} do-timestamp=true",
// We don't need a jpegparse, as it leads to incompatible caps, spoiling the negotiation.
// " ! jpegparse", TODO: test it again, it was possibly a gstreamer bug
" ! capsfilter name={filter_name} caps=image/jpeg,width={width},height={height},framerate={interval_denominator}/{interval_numerator}",
" ! tee name={video_tee_name} allow-not-linked=true",
" ! rtpjpegpay pt=96",
Expand Down
4 changes: 4 additions & 0 deletions src/lib/stream/sink/image_sink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ impl ImageSink {
match encoding {
VideoEncodeType::H264 => {
// For h264, we need to filter-out unwanted non-key frames here, before decoding it.
// let parser = gst::ElementFactory::make("h264parse").build()?;
let filter = gst::ElementFactory::make("identity")
.property("drop-buffer-flags", gst::BufferFlags::DELTA_UNIT)
.property("sync", false)
Expand All @@ -354,12 +355,15 @@ impl ImageSink {
.property_from_str("lowres", "2") // (0) is 'full'; (1) is '1/2-size'; (2) is '1/4-size'
.build()?;
decoder.has_property("discard-corrupted-frames", None).then(|| decoder.set_property("discard-corrupted-frames", true));
// _transcoding_elements.push(parser);
_transcoding_elements.push(filter);
_transcoding_elements.push(decoder);
}
VideoEncodeType::Mjpg => {
// let parser = gst::ElementFactory::make("jpegparse").build()?;
let decoder = gst::ElementFactory::make("jpegdec").build()?;
decoder.has_property("discard-corrupted-frames", None).then(|| decoder.set_property("discard-corrupted-frames", true));
// _transcoding_elements.push(parser);
_transcoding_elements.push(decoder);
}
VideoEncodeType::Rgb => {}
Expand Down
16 changes: 5 additions & 11 deletions tests/v4l2_latency_and_jitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,6 @@ impl V4l2LoopBack {
unreachable!();
};

let endpoint = video_and_stream_information
.stream_information
.endpoints
.first()
.unwrap();

let pipeline_description = match configuration.encode {
VideoEncodeType::H264 => format!(
concat!(
Expand Down Expand Up @@ -186,7 +180,7 @@ impl QrTimeStampSink {
" ! rtph264depay",
" ! h264parse",
" ! video/x-h264,width={width},height={height},framerate={framerate_num}/{framerate_den}",
" ! avdec_h264",
" ! avdec_h264 discard-corrupted-frames=true",
" ! videoconvert",
" ! qrtimestampsink name=qrsink",
),
Expand Down Expand Up @@ -311,7 +305,7 @@ impl Baseline {
" ! video/x-h264,profile=constrained-baseline,stream-format=byte-stream,alignment=au",
" ! h264parse",
" ! video/x-h264,width={width},height={height},framerate={framerate_num}/{framerate_den}",
" ! avdec_h264",
" ! avdec_h264 discard-corrupted-frames=true",
" ! videoconvert",
" ! qrtimestampsink name=qrsink",
),
Expand Down Expand Up @@ -556,9 +550,9 @@ async fn main() {
let buffers = 100;

let test_cases = [
(VideoEncodeType::H264, format!("udp://{address}:5600"), 5.),
(VideoEncodeType::Mjpg, format!("udp://{address}:5600"), 5.),
(VideoEncodeType::Yuyv, format!("udp://{address}:5600"), 8.),
// (VideoEncodeType::H264, format!("udp://{address}:5600"), 5.),
// (VideoEncodeType::Mjpg, format!("udp://{address}:5600"), 5.),
// (VideoEncodeType::Yuyv, format!("udp://{address}:5600"), 8.),
(
VideoEncodeType::H264,
format!("rtsp://{address}:8554/test"),
Expand Down

0 comments on commit 76d8a58

Please sign in to comment.