Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rtsp udp remote address fix; rust 1.83 disable lint warning:non_local_definitions #160

Merged
merged 2 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions application/xiu/src/config/errors.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(non_local_definitions)]
use {
failure::{Backtrace, Fail},
std::{fmt, io::Error},
Expand Down
1 change: 1 addition & 0 deletions library/bytesio/src/bits_errors.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(non_local_definitions)]
use super::bytes_errors::BytesReadError;
use super::bytes_errors::BytesWriteError;
use failure::{Backtrace, Fail};
Expand Down
1 change: 1 addition & 0 deletions library/bytesio/src/bytes_errors.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(non_local_definitions)]
use super::bytesio_errors::BytesIOError;
use std::io;
// use tokio::time::Elapsed;
Expand Down
1 change: 1 addition & 0 deletions library/bytesio/src/bytesio_errors.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(non_local_definitions)]
use failure::{Backtrace, Fail};
use std::fmt;
use std::io;
Expand Down
1 change: 1 addition & 0 deletions library/codec/h264/src/errors.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(non_local_definitions)]
use bytesio::bits_errors::BitError;
use failure::{Backtrace, Fail};
use std::fmt;
Expand Down
1 change: 1 addition & 0 deletions library/common/src/errors.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(non_local_definitions)]
use failure::{Backtrace, Fail};
use std::fmt;

Expand Down
1 change: 1 addition & 0 deletions library/container/flv/src/amf0/errors.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(non_local_definitions)]
use {
bytesio::bytes_errors::{BytesReadError, BytesWriteError},
failure::{Backtrace, Fail},
Expand Down
1 change: 1 addition & 0 deletions library/container/flv/src/errors.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(non_local_definitions)]
use {
bytesio::bits_errors::BitError,
bytesio::bytes_errors::{BytesReadError, BytesWriteError},
Expand Down
1 change: 1 addition & 0 deletions library/container/mpegts/src/errors.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(non_local_definitions)]
use {
bytesio::bytes_errors::{BytesReadError, BytesWriteError},
failure::{Backtrace, Fail},
Expand Down
1 change: 1 addition & 0 deletions library/logger/src/errors.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(non_local_definitions)]
use failure::Fail;

pub struct LogError {
Expand Down
1 change: 1 addition & 0 deletions library/streamhub/src/errors.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(non_local_definitions)]
use bytesio::bytes_errors::BytesReadError;
use bytesio::bytes_errors::BytesWriteError;
use failure::Backtrace;
Expand Down
1 change: 1 addition & 0 deletions protocol/hls/src/errors.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(non_local_definitions)]
use {
failure::{Backtrace, Fail},
std::fmt,
Expand Down
1 change: 1 addition & 0 deletions protocol/httpflv/src/errors.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(non_local_definitions)]
use streamhub::errors::StreamHubError;

use {
Expand Down
1 change: 1 addition & 0 deletions protocol/rtmp/src/cache/errors.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(non_local_definitions)]
use {
crate::chunk::errors::PackError,
bytesio::bytes_errors::BytesReadError,
Expand Down
1 change: 1 addition & 0 deletions protocol/rtmp/src/chunk/errors.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(non_local_definitions)]
use {
failure::{Backtrace, Fail},
bytesio::bytes_errors::{BytesReadError, BytesWriteError},
Expand Down
1 change: 1 addition & 0 deletions protocol/rtmp/src/handshake/errors.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(non_local_definitions)]
use {
bytesio::bytes_errors::{BytesReadError, BytesWriteError},
failure::{Backtrace, Fail},
Expand Down
1 change: 1 addition & 0 deletions protocol/rtmp/src/messages/errors.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(non_local_definitions)]
use {
crate::{
protocol_control_messages::errors::ProtocolControlMessageReaderError,
Expand Down
1 change: 1 addition & 0 deletions protocol/rtmp/src/netconnection/errors.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(non_local_definitions)]
use {
crate::chunk::errors::PackError,
failure::{Backtrace, Fail},
Expand Down
1 change: 1 addition & 0 deletions protocol/rtmp/src/netstream/errors.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(non_local_definitions)]
use {
crate::chunk::errors::PackError,
failure::{Backtrace, Fail},
Expand Down
1 change: 1 addition & 0 deletions protocol/rtmp/src/protocol_control_messages/errors.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(non_local_definitions)]
use {
failure::{Backtrace, Fail},
bytesio::bytes_errors::{BytesReadError, BytesWriteError},
Expand Down
1 change: 1 addition & 0 deletions protocol/rtmp/src/relay/errors.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(non_local_definitions)]
use {
failure::Fail,
std::{fmt, io::Error},
Expand Down
1 change: 1 addition & 0 deletions protocol/rtmp/src/remuxer/errors.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(non_local_definitions)]
use {
crate::{cache::errors::MetadataError, session::errors::SessionError},
bytesio::bytes_errors::{BytesReadError, BytesWriteError},
Expand Down
1 change: 1 addition & 0 deletions protocol/rtmp/src/session/errors.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(non_local_definitions)]
use {
crate::{
cache::errors::CacheError,
Expand Down
1 change: 1 addition & 0 deletions protocol/rtmp/src/user_control_messages/errors.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(non_local_definitions)]
use {
bytesio::bytes_errors::{BytesReadError, BytesWriteError},
failure::{Backtrace, Fail},
Expand Down
1 change: 1 addition & 0 deletions protocol/rtmp/src/utils/errors.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(non_local_definitions)]
use {
failure::{Backtrace, Fail},
std::fmt,
Expand Down
1 change: 1 addition & 0 deletions protocol/rtsp/src/relay/errors.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(non_local_definitions)]
use {
failure::Fail,
std::{fmt, io::Error},
Expand Down
1 change: 1 addition & 0 deletions protocol/rtsp/src/rtp/errors.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(non_local_definitions)]
use {
failure::{Backtrace, Fail},
std::fmt,
Expand Down
1 change: 1 addition & 0 deletions protocol/rtsp/src/rtp/rtcp/errors.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(non_local_definitions)]
use bytesio::bytes_errors::BytesReadError;
use bytesio::bytes_errors::BytesWriteError;
use failure::Fail;
Expand Down
1 change: 1 addition & 0 deletions protocol/rtsp/src/session/errors.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(non_local_definitions)]
use {
crate::rtp::errors::{PackerError, UnPackerError},
bytesio::bytes_errors::BytesReadError,
Expand Down
8 changes: 6 additions & 2 deletions protocol/rtsp/src/session/server_session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ use bytesio::bytesio::TcpIO;

use std::collections::HashMap;
use std::sync::Arc;
use std::net::SocketAddr;
use tokio::sync::mpsc;

use commonlib::auth::Auth;
Expand Down Expand Up @@ -81,6 +82,7 @@ pub struct RtspServerSession {

pub stream_identifier: Option<StreamIdentifier>,
pub is_normal_exit: bool,
remote_addr: SocketAddr,
}

pub struct InterleavedBinaryData {
Expand Down Expand Up @@ -125,6 +127,7 @@ impl RtspServerSession {
// None
// };

let remote_addr = stream.peer_addr().unwrap_or(stream.local_addr().unwrap());
let net_io: Box<dyn TNetIO + Send + Sync> = Box::new(TcpIO::new(stream));
let io = Arc::new(Mutex::new(net_io));

Expand All @@ -141,6 +144,7 @@ impl RtspServerSession {
auth,
stream_identifier: None,
is_normal_exit: false,
remote_addr,
}
}

Expand All @@ -159,7 +163,7 @@ impl RtspServerSession {
if let Ok(data) = InterleavedBinaryData::new(&mut self.reader) {
match data {
Some(a) => {
if self.reader.len() < a.length as usize {
while self.reader.len() < a.length as usize {
let data = self.io.lock().await.read().await?;
self.reader.extend_from_slice(&data[..]);
}
Expand Down Expand Up @@ -428,7 +432,7 @@ impl RtspServerSession {
(0, 0)
};

let address = rtsp_request.uri.host.clone();
let address = self.remote_addr.ip().to_string();
if let Some(rtp_io) = UdpIO::new(address.clone(), rtp_port, 0).await {
rtp_server_port = rtp_io.get_local_port();

Expand Down
1 change: 1 addition & 0 deletions protocol/webrtc/src/errors.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(non_local_definitions)]
use {
audiopus::error::Error as OpusError,
failure::{Backtrace, Fail},
Expand Down
1 change: 1 addition & 0 deletions protocol/webrtc/src/session/errors.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(non_local_definitions)]
use streamhub::errors::StreamHubError;
use {
bytesio::bytes_errors::BytesReadError,
Expand Down
Loading