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

InterleavedBinaryData should be read until self.reader.len() < a.length #147

Open
huiminghao opened this issue Aug 30, 2024 · 0 comments
Open

Comments

@huiminghao
Copy link

XIU version
For example: v0.13.0

Describe the bug
When running on ARM, RTSP stream push over tcp will cause:

[1970-01-01T00:09:06Z INFO  xrtsp::session::server_session] media_name: video
[1970-01-01T00:09:06Z INFO  xrtsp::session::server_session] media_name: audio
[1970-01-01T00:09:06Z INFO  xrtsp::session::server_session] audio codec info: RtspCodecInfo { codec_id: AAC, payload_type: 97, sample_rate: 48000, channel_count: 2 }
[1970-01-01T00:09:06Z INFO  streamhub] transceiver run success, idetifier: RTSP - stream_name: 1
[1970-01-01T00:09:06Z INFO  xrtsp::rtsp] session run exit: session id: 546 session type: push , err: bytes read error: not enough bytes to read
[1970-01-01T00:09:06Z INFO  xrtsp::session::server_session] session exit: send event success: {"UnPublish":{"identifier":{"rtsp":{"stream_path":"1"}},"info":{"id":"546\u0000\u0000\u0000\u0000\u0000\u0000\u0000","pub_type":"RtspPush","notify_info":{"request_url":"","remote_addr":""}}}}
[1970-01-01T00:09:06Z INFO  xrtsp::rtsp] session exit successfully: session id: 546 session type: push 
[1970-01-01T00:09:06Z INFO  streamhub] unpublish remove stream, stream identifier: RTSP - stream_name: 1
[1970-01-01T00:09:06Z INFO  streamhub::statistics] avstatistics shutting down

To Reproduce
Run xiu on a less powerfull ARM cpu, use ffmpeg to push RTSP stream, eg:

./ffmpeg.exe -re -i /d/out.mkv -codec copy -f rtsp -rtsp_transport tcp rtsp://192.168.4.201:554/1

Expected behavior
push works well.

Code related
protocol/rtsp/src/server_session.rs:
old:

            if let Ok(data) = InterleavedBinaryData::new(&mut self.reader) {
                match data {
                    Some(a) => {
                        if self.reader.len() < a.length as usize {
                            let data = self.io.lock().await.read().await?;
                            self.reader.extend_from_slice(&data[..]);
                        }
                        self.on_rtp_over_rtsp_message(a.channel_identifier, a.length as usize)
                            .await?;
                    }
                    None => {
                        self.on_rtsp_message().await?;
                    }
                }
            }

should be:

            if let Ok(data) = InterleavedBinaryData::new(&mut self.reader) {
                match data {
                    Some(a) => {
                        while self.reader.len() < a.length as usize {
                            let data = self.io.lock().await.read().await?;
                            self.reader.extend_from_slice(&data[..]);
                        }
                        self.on_rtp_over_rtsp_message(a.channel_identifier, a.length as usize)
                            .await?;
                    }
                    None => {
                        self.on_rtsp_message().await?;
                    }
                }
            }

``

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant