Clippy fix
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
kieran 2024-08-29 11:47:19 +01:00
parent a64b54ba12
commit 76c2a1a6a6
Signed by: Kieran
GPG Key ID: DE71CEB3925BE941
11 changed files with 31 additions and 88 deletions

View File

@ -1,16 +1,13 @@
use std::io::Read;
use std::ptr;
use std::sync::Arc;
use std::time::Duration;
use anyhow::Error;
use bytes::{BufMut, Bytes};
use ffmpeg_sys_next::*;
use ffmpeg_sys_next::AVMediaType::{AVMEDIA_TYPE_AUDIO, AVMEDIA_TYPE_VIDEO};
use log::{info, warn};
use log::warn;
use tokio::sync::mpsc::{UnboundedReceiver, UnboundedSender};
use tokio::sync::mpsc::error::TryRecvError;
use tokio::sync::Mutex;
use tokio::time::Instant;
use crate::demux::info::{DemuxStreamInfo, StreamChannelType, StreamInfoChannel};
@ -53,7 +50,7 @@ unsafe extern "C" fn read_data(
loop {
match (*state).chan_in.try_recv() {
Ok(data) => {
if data.len() > 0 {
if !data.is_empty() {
(*state).buffer.put(data);
}
if (*state).buffer.len() >= size as usize {

View File

@ -1,30 +1,19 @@
use std::collections::{HashMap, HashSet, VecDeque};
use std::fmt::{Display, Formatter};
use std::mem::transmute;
use std::ptr;
use anyhow::Error;
use ffmpeg_sys_next::{
AV_CH_LAYOUT_STEREO, av_channel_layout_copy, av_dump_format, av_get_sample_fmt,
av_dump_format,
av_interleaved_write_frame, av_opt_set, av_packet_clone, av_packet_copy_props,
AVChannelLayout, AVChannelLayout__bindgen_ty_1, avcodec_find_encoder,
avcodec_parameters_from_context, avcodec_parameters_to_context, AVCodecContext, avformat_alloc_output_context2,
avformat_free_context, avformat_new_stream, avformat_write_header, AVFormatContext, AVPacket,
AVRational,
avcodec_parameters_from_context, avformat_alloc_output_context2,
avformat_free_context, avformat_write_header, AVFormatContext, AVPacket,
};
use ffmpeg_sys_next::AVChannelOrder::AV_CHANNEL_ORDER_NATIVE;
use ffmpeg_sys_next::AVColorSpace::AVCOL_SPC_BT709;
use ffmpeg_sys_next::AVMediaType::{AVMEDIA_TYPE_AUDIO, AVMEDIA_TYPE_VIDEO};
use ffmpeg_sys_next::AVPixelFormat::AV_PIX_FMT_YUV420P;
use futures_util::SinkExt;
use itertools::Itertools;
use log::info;
use serde::{Deserialize, Serialize};
use tokio::sync::mpsc::UnboundedReceiver;
use uuid::Uuid;
use crate::egress::{EgressConfig, map_variants_to_streams};
use crate::encode::dump_pkt_info;
use crate::pipeline::{AVPacketSource, PipelinePayload, PipelineProcessor};
use crate::utils::get_ffmpeg_error_msg;
use crate::variant::{VariantStream, VariantStreamType};

View File

@ -1,5 +1,4 @@
use std::collections::HashSet;
use std::fmt::Display;
use std::{fs, ptr};
use anyhow::Error;
@ -52,7 +51,7 @@ impl RecorderEgress {
}
unsafe fn setup_muxer(&mut self) -> Result<(), Error> {
let mut ctx = avformat_alloc_context();
let ctx = avformat_alloc_context();
if ctx.is_null() {
return Err(Error::msg("Failed to create muxer context"));
}

View File

@ -3,24 +3,20 @@ use std::mem::transmute;
use std::ptr;
use anyhow::Error;
use ffmpeg_sys_next::AVRounding::AV_ROUND_UP;
use ffmpeg_sys_next::AVSampleFormat::AV_SAMPLE_FMT_S16;
use ffmpeg_sys_next::{
av_audio_fifo_alloc, av_audio_fifo_free, av_audio_fifo_read, av_audio_fifo_realloc,
av_audio_fifo_size, av_audio_fifo_write, av_buffer_ref, av_buffer_unref,
av_channel_layout_copy, av_frame_alloc, av_frame_clone, av_frame_free, av_frame_get_buffer,
av_frame_unref, av_freep, av_get_sample_fmt_name, av_packet_alloc, av_packet_free,
av_rescale_q, av_rescale_rnd, av_samples_alloc, av_samples_alloc_array_and_samples,
avcodec_alloc_context3, avcodec_free_context, avcodec_open2, avcodec_parameters_from_context,
avcodec_receive_packet, avcodec_send_frame, swr_alloc_set_opts2, swr_config_frame, swr_convert,
swr_convert_frame, swr_free, swr_get_delay, swr_init, AVAudioFifo, AVBufferRef, AVCodec,
AVCodecContext, AVFrame, AVStream, SwrContext, AVERROR,
av_audio_fifo_alloc, av_audio_fifo_free, av_audio_fifo_read,
av_audio_fifo_size, av_audio_fifo_write,
av_channel_layout_copy, av_frame_alloc, av_frame_free, av_get_sample_fmt_name, av_packet_alloc, av_packet_free, av_samples_alloc_array_and_samples,
avcodec_alloc_context3, avcodec_free_context, avcodec_open2,
avcodec_receive_packet, avcodec_send_frame, swr_alloc_set_opts2,
swr_convert_frame, swr_free, swr_init, AVAudioFifo, AVCodec,
AVCodecContext, AVFrame, SwrContext, AVERROR,
};
use libc::EAGAIN;
use log::info;
use tokio::sync::mpsc::UnboundedSender;
use crate::encode::{dump_pkt_info, set_encoded_pkt_timing};
use crate::encode::set_encoded_pkt_timing;
use crate::ipc::Rx;
use crate::pipeline::{AVFrameSource, AVPacketSource, PipelinePayload, PipelineProcessor};
use crate::utils::get_ffmpeg_error_msg;
@ -206,12 +202,12 @@ where
av_frame_free(&mut out_frame);
let buff = av_audio_fifo_size(self.fifo);
return if buff < (*self.ctx).frame_size {
if buff < (*self.ctx).frame_size {
Ok(None)
} else {
let out_frame = self.read_fifo_frame()?;
Ok(Some(out_frame))
};
}
}
unsafe fn read_fifo_frame(&mut self) -> Result<*mut AVFrame, Error> {
@ -249,7 +245,7 @@ where
}
unsafe fn new_frame(&self) -> *mut AVFrame {
let mut out_frame = av_frame_alloc();
let out_frame = av_frame_alloc();
(*out_frame).nb_samples = (*self.ctx).frame_size;
av_channel_layout_copy(&mut (*out_frame).ch_layout, &(*self.ctx).ch_layout);
(*out_frame).format = (*self.ctx).sample_fmt as libc::c_int;
@ -268,7 +264,7 @@ where
};
self.setup_encoder(frame)?;
let mut frame = self.process_audio_frame(frame)?;
let frame = self.process_audio_frame(frame)?;
if frame.is_none() {
return Ok(());
}

View File

@ -1,8 +1,7 @@
use std::ptr;
use ffmpeg_sys_next::{
AV_LOG_INFO, AV_NOPTS_VALUE, av_packet_rescale_ts, av_pkt_dump_log2, AV_PKT_FLAG_KEY, av_q2d,
av_rescale_q, AVCodecContext, AVFrame, AVPacket, AVRational, AVStream,
AV_NOPTS_VALUE, AV_PKT_FLAG_KEY,
av_rescale_q, AVCodecContext, AVPacket, AVStream,
};
use ffmpeg_sys_next::AVMediaType::{AVMEDIA_TYPE_AUDIO, AVMEDIA_TYPE_VIDEO};
use log::info;

View File

@ -1,29 +1,6 @@
use std::{ptr, slice};
use std::mem::transmute;
use std::ops::Add;
use std::path::PathBuf;
use std::time::{Duration, SystemTime};
use bytes::BufMut;
use ffmpeg_sys_next::{
av_frame_alloc, av_frame_copy_props, av_frame_free, av_frame_get_buffer, av_packet_alloc,
av_packet_free, AV_PROFILE_AV1_HIGH, AV_PROFILE_H264_HIGH, av_q2d, av_write_frame,
avcodec_alloc_context3, avcodec_find_encoder, avcodec_get_name, avcodec_open2,
avcodec_receive_packet, avcodec_send_frame, AVERROR, avformat_alloc_context,
avformat_alloc_output_context2, AVRational, EAGAIN, sws_alloc_context, SWS_BILINEAR, sws_getContext,
sws_scale_frame,
};
use ffmpeg_sys_next::AVCodecID::{
AV_CODEC_ID_H264, AV_CODEC_ID_MPEG1VIDEO, AV_CODEC_ID_MPEG2VIDEO, AV_CODEC_ID_MPEG4,
AV_CODEC_ID_VP8, AV_CODEC_ID_WMV1,
};
use ffmpeg_sys_next::AVColorSpace::AVCOL_SPC_RGB;
use ffmpeg_sys_next::AVPictureType::{AV_PICTURE_TYPE_I, AV_PICTURE_TYPE_NONE};
use ffmpeg_sys_next::AVPixelFormat::{AV_PIX_FMT_RGB24, AV_PIX_FMT_YUV420P};
use futures_util::StreamExt;
use libc::memcpy;
use log::{error, info, warn};
use rand::random;
use log::{error, info};
use tokio::io::AsyncReadExt;
use tokio::sync::mpsc::unbounded_channel;

View File

@ -3,26 +3,17 @@ use std::mem::transmute;
use std::ops::Add;
use std::time::{Duration, SystemTime};
use bytes::BufMut;
use ffmpeg_sys_next::{
av_frame_alloc, av_frame_copy_props, av_frame_free, av_frame_get_buffer, av_packet_alloc,
av_packet_free, AV_PROFILE_AV1_HIGH, AV_PROFILE_H264_HIGH, AV_PROFILE_H264_MAIN, av_q2d,
av_write_frame, avcodec_alloc_context3, avcodec_find_encoder, avcodec_get_name,
avcodec_open2, avcodec_receive_packet, avcodec_send_frame, AVERROR,
avformat_alloc_context, avformat_alloc_output_context2, AVRational, EAGAIN, sws_alloc_context,
av_packet_free, AV_PROFILE_H264_MAIN, av_q2d, avcodec_alloc_context3, avcodec_find_encoder,
avcodec_open2, avcodec_receive_packet, avcodec_send_frame, AVERROR, AVRational, EAGAIN,
SWS_BILINEAR, sws_getContext, sws_scale_frame,
};
use ffmpeg_sys_next::AVCodecID::{
AV_CODEC_ID_H264, AV_CODEC_ID_MPEG1VIDEO, AV_CODEC_ID_MPEG2VIDEO, AV_CODEC_ID_MPEG4,
AV_CODEC_ID_VP8, AV_CODEC_ID_WMV1,
};
use ffmpeg_sys_next::AVCodecID::AV_CODEC_ID_H264;
use ffmpeg_sys_next::AVColorSpace::{AVCOL_SPC_BT709, AVCOL_SPC_RGB};
use ffmpeg_sys_next::AVPictureType::{AV_PICTURE_TYPE_I, AV_PICTURE_TYPE_NONE};
use ffmpeg_sys_next::AVPictureType::AV_PICTURE_TYPE_NONE;
use ffmpeg_sys_next::AVPixelFormat::{AV_PIX_FMT_RGB24, AV_PIX_FMT_YUV420P};
use futures_util::StreamExt;
use libc::memcpy;
use log::{error, info, warn};
use rand::random;
use log::{error, info};
use tokio::sync::mpsc::unbounded_channel;
use crate::ingress::ConnectionInfo;

View File

@ -1,15 +1,14 @@
use crate::tag_frame::TagFrame;
use std::ops::Add;
use std::time::{Duration, Instant};
use std::time::Instant;
use anyhow::Error;
use log::{info, warn};
use log::info;
use tokio::sync::broadcast;
use tokio::sync::mpsc::{unbounded_channel, UnboundedReceiver, UnboundedSender};
use crate::decode::Decoder;
use crate::demux::Demuxer;
use crate::demux::info::{DemuxStreamInfo, StreamChannelType};
use crate::demux::info::DemuxStreamInfo;
use crate::egress::EgressConfig;
use crate::egress::hls::HlsEgress;
use crate::egress::recorder::RecorderEgress;

View File

@ -3,7 +3,7 @@ use std::ptr;
use anyhow::Error;
use ffmpeg_sys_next::{
av_frame_alloc, av_frame_copy_props, AVBufferRef, AVFrame, SWS_BILINEAR,
av_frame_alloc, av_frame_copy_props, AVFrame, SWS_BILINEAR,
sws_freeContext, sws_getContext, sws_scale_frame, SwsContext,
};
use tokio::sync::broadcast;

View File

@ -1,5 +1,4 @@
use anyhow::Error;
use ffmpeg_sys_next::AVBufferRef;
use tokio::sync::mpsc::UnboundedSender;
use crate::ipc::Rx;

View File

@ -1,10 +1,7 @@
use std::ffi::CStr;
use anyhow::Error;
use ffmpeg_sys_next::{av_buffer_allocz, av_make_error_string, AVBufferRef, memcpy};
use uuid::{Bytes, Uuid};
use ffmpeg_sys_next::av_make_error_string;
use crate::variant::{AudioVariant, VariantStream, VideoVariant};
pub fn get_ffmpeg_error_msg(ret: libc::c_int) -> String {
unsafe {