-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
NEW PROTOCOL: Support viewing stream over RTSP. v7.0.47 #4333
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
Merged
+32,805
−289
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds support for RTSP stream pulling by introducing a new RTSP protocol stack and connection type, updating server setup and configuration, and extending SDP processing.
- Added unit tests in the configuration suite to verify RTSP server environment variables.
- Introduced a new RTSP protocol stack header and corresponding connection implementation (SrsRtspConn).
- Updated server initialization, heartbeat reporting, and configuration handling to incorporate RTSP endpoints.
Reviewed Changes
Copilot reviewed 15 out of 17 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
trunk/src/utest/srs_utest_config.cpp | Added unit test for RTSP configuration environment variables. |
trunk/src/protocol/srs_protocol_rtsp_stack.hpp | Introduced RTSP protocol stack definitions and constants. |
trunk/src/app/srs_app_server.hpp & .cpp | Added RTSP listener initialization, management, and integration into connection dispatching. |
trunk/src/app/srs_app_rtsp.hpp | Defined SrsRtspConn and related RTSP connection functionality. |
trunk/src/app/srs_app_rtc_sdp.hpp & .cpp | Extended SDP encoding to include RTSP control attributes. |
trunk/src/app/srs_app_rtc_conn.hpp | Updated do_send_packet to be virtual for proper RTSP connection overrides. |
trunk/src/app/srs_app_latest_version.cpp, srs_app_heartbeat.cpp, srs_app_config.hpp & .cpp | Integrated RTSP feature flags and configuration adjustments. |
Files not reviewed (2)
- trunk/conf/rtsp.conf: Language not supported
- trunk/configure: Language not supported
winlinvip
approved these changes
Jul 9, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Introduce
This PR adds support for viewing streams via the RTSP protocol. Note that it only supports viewing streams, not publishing streams via RTSP.
Currently, only publishing via RTMP is supported, which is then converted to RTSP. Further work is needed to support publishing RTC/SRT streams and converting them to RTSP.
Usage
Build and run SRS with RTSP support:
Push stream via RTMP by FFmpeg:
View the stream via RTSP protocol, try UDP first, then use TCP:
Or specify the transport protocol with TCP:
Unit Test
Run utest for RTSP:
Regression Test
You need to start SRS for regression testing.
Then run regression tests for RTSP.
Blackbox Test
For blackbox testing, SRS will be started by utest, so there is no need to start SRS manually.
UDP Transport
As UDP requires port allocation, this PR doesn't support delivering media stream via UDP transport, so it will fail if you try to use UDP as transport:
There are no plans to support UDP transport for RTSP. In the real world, UDP is rarely used; the vast majority of RTSP traffic uses TCP.
Play Before Publish
RTSP supports audio with AAC and OPUS codecs, which is significantly different from RTMP or WebRTC.
RTSP uses commands to exchange SDP and specify the audio track to play, unlike WHEP or HTTP-FLV, which use the query string of the URL. RTSP depends on the player’s behavior, making it very difficult to use and describe.
Considering the feature that allows playing the stream before publishing it, it requires generating some default parameters in the SDP. For OPUS, the sample rate is 48 kHz with 2 channels, while AAC is more complex, especially regarding the sample rate, which may be 44.1 kHz, 32 kHz, or 48 kHz.
Therefore, for RTSP, we cannot support play-then-publish. Instead, there must already be a stream when playing it, so that the audio codec is determined.
Opus Codec
No Opus codec support for RTSP, because for RTC2RTSP, it always converts RTC to RTMP frames, then converts them to RTSP packets. Therefore, the audio codec is always AAC after converting RTC to RTMP.
This means the bridge architecture needs some changes. We need a new bridge that binds to the target protocol. For example, RTC2RTMP converts the audio codec, but RTC2RTSP keeps the original audio codec.
Furthermore, the RTC2RTMP bridge should also support bypassing the Opus codec if we use enhanced-RTMP, which supports the Opus audio codec. I think it should be configurable to either transcode or bypass the audio codec. However, this is not relevant to RTSP.
AI Contributor
Below commits are contributed by AI:
Co-authored-by: Jacob Su [email protected]