Commit Graph

546 Commits

Author SHA1 Message Date
OSSRS-AI
2810d32d60 AI: Only support AAC/MP3/Opus audio codec. v7.0.102 (#4516) 2025-10-22 22:08:25 -04:00
OSSRS-AI
0c9868b4a2 AI: Fix AAC audio sample rate reporting in API. v7.0.101 (#4518) 2025-10-22 21:28:45 -04:00
Winlin
845e0287c0 Forward: Reject RTMPS destinations with clear error message. v7.0.100 (#4537)
SRS forward feature only supports plain RTMP protocol, not RTMPS (RTMP over SSL/TLS). This is by design - SRS SSL is server-side only (accepting connections), not client-side (initiating connections). The forward feature uses SrsSimpleRtmpClient which has no SSL handshake or encryption capabilities for outgoing connections.

Changes:
1. Add RTMPS URL detection in SrsForwarder::initialize()
2. Return ERROR_NOT_SUPPORTED error when RTMPS destination is detected
3. Add unit test to verify RTMPS URLs are properly rejected
4. Add FAQ section to .augment-guidelines explaining the limitation

For users who need to forward to RTMPS destinations (e.g., AWS IVS), the recommended solution is to use FFmpeg with SRS HTTP Hooks:
- on_publish event: Automatically start FFmpeg to relay stream to RTMPS destination
- on_unpublish event: Automatically stop FFmpeg process when stream ends

This provides a fully automated, production-ready RTMPS relay solution without adding complexity to SRS core.

Related: #4536

---------

Co-authored-by: OSSRS-AI <winlinam@gmail.com>
2025-10-20 08:03:07 -04:00
Haibo Chen(陈海博)
0d43ed5dd6 HLS: Fix a iterator bug in hls_ctx cleanup function. v6.0.182 v7.0.99 (#4534)
Co-authored-by: OSSRS-AI <winlinam@gmail.com>
2025-10-17 07:16:42 -04:00
Haibo Chen(陈海博)
abaffdd4b9 fix crash issue caused by reload configuration file. v7.0.98 (#4530)
fix crash issue caused by reload configuration file, which occurs when a
vhost is added/removed in the new configuration.

Introduced by https://github.com/ossrs/srs/pull/4458

see https://github.com/ossrs/srs/issues/4529
2025-10-16 07:30:16 -04:00
Jack Lau
6f526284a3 RTC2RTMP: fix illegal memory access. v7.0.97 (#4520)
Regression since 20f6cd595c

The early code might meet bridge is empty when
there is no bridge(e.x. rtc to rtc). Then srs_freep will free the brige.

Remove this code that seems redundant.

---------

Co-authored-by: Jacob Su <suzp1984@gmail.com>
Signed-off-by: Jack Lau <jacklau1222@qq.com>
2025-10-15 10:16:03 -04:00
winlin
1bc18509a2 Disable sanitizer by default to fix memory leak. #4364 v7.0.96 2025-10-14 20:32:37 -04:00
OSSRS-AI
fc6a851d5f SRT: Support configurable default_streamid option. v6.0.180 v7.0.95 (#4515) 2025-10-01 22:05:15 -04:00
Winlin
c7821b4770 For Edge, only support RTMP or HTTP-FLV. v7.0.94 (#4513) 2025-09-27 19:35:34 -04:00
Haibo Chen(陈海博)
2dfa54e21b improve blackbox test for rtsp. v7.0.93 (#4505)
Co-authored-by: winlin <winlinvip@gmail.com>
2025-09-21 23:36:49 -04:00
winlin
10c0b66c0f Fix WHIP with transcoding bug. v7.0.92 (#4495) 2025-09-21 08:58:22 -04:00
Jacob Su
f4c54ab9a5 fix rtsp compiling warning. v7.0.91 (#4504)
## steps to produce:

1. ./configure --rtsp=off
2. make

---------

Co-authored-by: winlin <winlinvip@gmail.com>
2025-09-20 11:38:07 -04:00
Winlin
20f6cd595c AI: Refine RTMP/SRT/RTC bridge. v7.0.90 (#4503)
This PR refactors the stream bridge architecture in SRS to improve code
organization, type safety, and maintainability by replacing the generic
ISrsStreamBridge interface with protocol-specific bridge classes and
target interfaces.

1. New Target Interface Architecture:

- Introduces  ISrsFrameTarget for AV frame consumers (RTMP sources)
- Introduces  ISrsRtpTarget for RTP packet consumers (RTC sources)
- Introduces ISrsSrtTarget for SRT packet consumers (SRT sources)

2. Protocol-Specific Bridge Classes:

- SrsRtmpBridge: Converts RTMP frames to RTC/RTSP protocols
-  SrsSrtBridge: Converts SRT packets to RTMP/RTC protocols
-  SrsRtcBridge: Converts RTC packets to RTMP protocol

3. Simplified Bridge Management:

- Removes the generic SrsCompositeBridge chain pattern
- Each source type now uses its appropriate bridge type directly

With this improvement, you are able to implement very complex bridge and
protocol converting, for example, you can bridge RTMP to RTC with opus
audio when you support enhanced RTMP with opus.

Another plan is to support bridging RTC to RTSP, directly without
converting RTP to media frame packet, but directly deliver RTP packet
from RTC source to RTSP source.

---------

Co-authored-by: OSSRS-AI <winlinam@gmail.com>
2025-09-19 21:50:28 -04:00
Winlin
5b27c3fa7a RTC2RTMP: Fix sequence number wraparound assertion crashes. v6.0.177 v7.0.89 (#4491)
The issue occurred when srs_rtp_seq_distance(start, end) + 1 resulted in
values <= 0
due to sequence number wraparound (e.g., when end < start). This caused
assertion
failures and server crashes.

SrsRtcFrameBuilder::check_frame_complete(): Added validation to return
false
  for invalid sequence ranges instead of asserting.

However, it maybe cause converting RTC to RTMP stream failure, because
this issue
should be caused by the problem of sequence number of RTP, which means
there potentially
be stream problem in RTC stream. Even so, changing assert to warning
logs is better,
because SRS should not crash when stream is corrupt.

---------

Co-authored-by: OSSRS-AI <winlinam@gmail.com>
2025-09-15 11:02:30 -04:00
Winlin
4247bd1f90 Improve coverage for kernel. v7.0.88 (#4489)
Co-authored-by: OSSRS-AI <winlinam@gmail.com>
2025-09-14 21:57:12 -04:00
Winlin
fadc1215af AI: Add utests for kernel and protocol. v7.0.87 (#4488)
Co-authored-by: OSSRS-AI <winlinam@gmail.com>
2025-09-14 08:35:36 -04:00
Winlin
d4d1d5d8b5 AI: Move some app files to kernel. v7.0.86 (#4486)
Co-authored-by: OSSRS-AI <winlinam@gmail.com>
2025-09-13 10:26:47 -04:00
Winlin
2384f3fb06 AI: Fix naming problem for app module. v7.0.85 (#4485)
Co-authored-by: OSSRS-AI <winlinam@gmail.com>
2025-09-12 19:44:43 -04:00
Jacob Su
a6d14eb09a SRT2RTMP: fix srt bridge hevc to rtmp error. v7.0.84 (#4446)
try to fix #4428.

## Cause

rtmp do not support hevc, rtmp enhanced do.

## How to reproduce

1. start srs.
   `./objs/srs -c conf/srt.conf`
2. publish hevc (h.265) stream to srs by srt.
`ffmpeg -re -i ./doc/source.flv -c:v libx265 -crf 28 -preset medium -c:a
copy -pes_payload_size 0 -f mpegts
'srt://127.0.0.1:10080?streamid=#!::r=live/livestream,m=publish'`
3. probe the rtmp stream
   `ffprobe rtmp://localhost/live/livestream`

## About the Failed BlackBox test
The failed blackbox test: `TestSlow_SrtPublish_RtmpPlay_HEVC_Basic`
`TestSlow_SrtPublish_HttpFlvPlay_HEVC_Basic`

### Cause: 

The ffmpeg 5 is used to record a piece of video (DRV), the ffmpeg will
transcode the enhanced flv format to TS format, but ffmpeg 5 don't
support enhanced rtmp (or flv) in this case.

The solution is to replace the ffmpeg to version 7 in those 2 test
cases.

### why not upgrade ffmpeg to version 7?

The black tests dependency on ffmpeg 5 will fail, and there are a few of
them are not easy to resolve in ffmpeg 7.

---------

Co-authored-by: winlin <winlinvip@gmail.com>
2025-09-09 21:10:04 -04:00
Winlin
3a29e5c550 AI: Fix naming issue for protocol module. v7.0.83 (#4482)
Co-authored-by: OSSRS-AI <winlinam@gmail.com>
2025-09-09 21:06:45 -04:00
Winlin
8f87d4092b AI: Fix naming problem in kernel module. v7.0.82 (#4479)
Co-authored-by: OSSRS-AI <winlinam@gmail.com>
2025-09-07 21:09:08 -04:00
Winlin
7c1e87ef5c AI: Add more utests for kernel module. v7.0.81 (#4478)
This PR significantly enhances the kernel module by adding comprehensive
unit test coverage and improving interface design for core buffer and
load balancer components.

- **ISrsDecoder**: New interface for decoding/deserialization operations
- **ISrsLbRoundRobin**: Extracted interface from concrete
SrsLbRoundRobin class for better abstraction
- **Enhanced Documentation**: Added comprehensive inline documentation
for ISrsEncoder, ISrsCodec, SrsBuffer, and SrsBitBuffer classes

---------

Co-authored-by: OSSRS-AI <winlinam@gmail.com>
2025-09-06 12:39:46 -04:00
Winlin
8976ce4c8d AI: Support anonymous coroutine with code block. v7.0.80 (#4475)
This PR introduces anonymous coroutine macros for easier coroutine
creation and improves the State Threads (ST) mutex and condition
variable handling in SRS.

- **Added coroutine macros**: `SRS_COROUTINE_GO`, `SRS_COROUTINE_GO2`,
`SRS_COROUTINE_GO_CTX`, `SRS_COROUTINE_GO_CTX2`
- **Added `SrsCoroutineChan`**: Channel for sharing data between
coroutines with coroutine-safe operations
- **Simplified coroutine creation**: Go-like syntax for creating
anonymous coroutines with code blocks

---------

Co-authored-by: Jacob Su <suzp1984@gmail.com>
Co-authored-by: OSSRS-AI <winlinam@gmail.com>
2025-09-06 08:10:49 -04:00
Winlin
8f09c4186e WebRTC: Fix race condition in RTC nack timer callbacks. v7.0.79 (#4474)
See [WebRTC: Fix race condition in RTC publish timer
callbacks.](421ab6c3fb)
v7.0.76 (https://github.com/ossrs/srs/pull/4470)
2025-09-05 09:58:19 -04:00
why
57e1622e81 WebRTC: Fix NACK recovered packets not being added to receive queue. v7.0.78 (#4467)
Fixes a bug in WebRTC NACK packet recovery mechanism where recovered
packets were being discarded instead of processed.

In `SrsRtcRecvTrack::on_nack()`, when a retransmitted packet arrived
(found in NACK receiver), the method would:
1.  Remove the packet from NACK receiver (correct)
2.  Return early without adding the packet to RTP queue (BUG)

This caused recovered packets to be lost, defeating the purpose of the
NACK mechanism and potentially causing media quality issues.

Restructured the control flow in `on_nack()` to ensure both new and
recovered packets reach the packet insertion logic:

- **Before**: Early return for recovered packets → packets discarded
- **After**: Conditional NACK management + unified packet processing →
all packets queued

Closes #3820

---------

Co-authored-by: Haibo Chen <495810242@qq.com>
Co-authored-by: OSSRS-AI <winlinam@gmail.com>
2025-09-04 08:07:36 -04:00
Winlin
6720e96745 Upgrade HTTP parser from http-parser to llhttp. v7.0.77 (#4469)
This PR modernizes SRS's HTTP handling by upgrading from the legacy
http-parser library to the more performant and actively maintained
llhttp library.

* Replace http-parser with llhttp: Migrated from the deprecated
http-parser to llhttp for better performance and maintenance
* API compatibility: Updated all HTTP parsing logic to use llhttp APIs
while maintaining backward compatibility
* Simplified URL parsing: Replaced complex http-parser URL parsing with
custom simple parser implementation
Enhanced error handling: Improved error reporting with llhttp's better
error context and positioning


---------

Co-authored-by: OSSRS-AI <winlinam@gmail.com>
2025-09-03 20:12:59 -04:00
Winlin
421ab6c3fb WebRTC: Fix race condition in RTC publish timer callbacks. v7.0.76 (#4470)
WebRTC RTC publish streams use timer callbacks (`SrsRtcPublishRtcpTimer`
and `SrsRtcPublishTwccTimer`) that can cause race conditions in SRS's
coroutine-based architecture. The timer callbacks are heavy functions
that may trigger coroutine switches, during which the timer object can
be freed by another coroutine, leading to use-after-free crashes.

The race condition occurs because:
1. Timer callbacks (`on_timer`) perform heavy operations that can yield
control
2. During coroutine switches, other coroutines may destroy the timer
object
3. When control returns, the callback continues executing on a freed
object

Fixes potential crashes in WebRTC RTC publish streams under high
concurrency.
2025-09-03 19:45:24 -04:00
Winlin
d9fe2c458c AI: GB28181: Remove embedded SIP server and enforce external SIP usage. v7.0.75 (#4466)
This PR removes the embedded GB28181 SIP server implementation from SRS
and enforces the use of external SIP servers for production deployments.

The embedded SIP server depended on the deprecated `http-parser`
library. With the planned migration to `llhttp` (which doesn't support
SIP parsing), maintaining the embedded SIP server would require
significant additional work. Since external SIP servers are already the
recommended approach for production, removing the embedded
implementation simplifies the codebase and eliminates this dependency.

Eliminated `srs_gb28181_test` from CI workflow.

Removed SIP configuration validation tests.

---------

Co-authored-by: OSSRS-AI <winlinam@gmail.com>
Co-authored-by: haibo.chen <495810242@qq.com>
2025-09-02 09:59:40 -04:00
Winlin
3e8cb3f9d5 AI: Replace SrsSharedPtrMessage with SrsMediaPacket for unified media packet handling. v7.0.74 (#4465)
This PR introduces a major refactoring to replace `SrsSharedPtrMessage`
with `SrsMediaPacket` throughout the SRS codebase, providing a more
unified and cleaner approach to media packet handling.

---------

Co-authored-by: OSSRS-AI <winlinam@gmail.com>
2025-09-01 18:06:24 -04:00
Winlin
c534a265e5 AI: Update RTMP message memory management with shared pointers. v7.0.73 (#4464)
This PR modernizes the memory management architecture in SRS by
refactoring RTMP message handling to use shared pointers
(SrsSharedPtr<SrsMemoryBlock>) instead of manual memory management. This
change improves memory safety, reduces the risk of memory leaks, and
provides a cleaner abstraction for message payload handling.

* Introduced `SrsMemoryBlock`: A dedicated class for managing memory
buffers with size information
* Replaced manual memory management: `SrsCommonMessage` and
`SrsSharedPtrMessage` now use `SrsSharedPtr<SrsMemoryBlock>` instead of
raw pointers
* Updated `SrsRtpPacket`: Now uses `SrsSharedPtr<SrsMemoryBlock>` for
shared buffer management

---------

Co-authored-by: OSSRS-AI <winlinam@gmail.com>
2025-09-01 14:00:31 -04:00
Winlin
b834be67a9 AI: Use SrsHttpUri for URL parsing and add legacy RTMP URL conversion. v7.0.72 (#4463)
Refactors the `srs_net_url_parse_tcurl` function to use the robust
`SrsHttpUri` class for URL parsing and implements a dedicated legacy
RTMP URL conversion function to handle various URL formats consistently.

---------

Co-authored-by: OSSRS-AI <winlinam@gmail.com>
2025-09-01 10:12:27 -04:00
Winlin
0d6d36d1fb HTTP: Rename HTTP hijack to dynamic match for better clarity. v7.0.71 (#4462)
This PR refactors the HTTP routing system by renaming "hijack"
terminology to "dynamic match" for improved code clarity and better
semantic meaning.

Interface and Class Renaming
* ISrsHttpMatchHijacker → ISrsHttpDynamicMatcher
* hijack() method → dynamic_match() method
* hijackers member variables → dynamic_matchers_

Method Renaming
* SrsHttpServeMux::hijack() → SrsHttpServeMux::add_dynamic_matcher()
* SrsHttpServeMux::unhijack() →
SrsHttpServeMux::remove_dynamic_matcher()

The new "dynamic match" terminology better reflects that this is a
legitimate routing mechanism, not a security bypass or interception.
2025-09-01 08:33:31 -04:00
Winlin
728828e1dd AI: Extract shared components and improve SRS server architecture. v7.0.70 (#4461)
Move global xpps statistics variables from `srs_app_server.cpp` to
`srs_kernel_kbps.cpp`.

Extract global shared timers from `SrsServer` into new `SrsSharedTimer`
class.

Extract WebRTC session management logic from `SrsServer` into dedicated
`SrsRtcSessionManager` class.

Extract PID file handling into dedicated  `SrsPidFileLocker` class.

---------

Co-authored-by: OSSRS-AI <winlinam@gmail.com>
2025-08-31 19:14:34 -04:00
Winlin
3ca4f0a068 AI: Always enable SRT protocol. v7.0.69 (#4460)
Co-authored-by: OSSRS-AI <winlinam@gmail.com>
2025-08-31 17:30:19 -04:00
Winlin
32dfed43ef AI: Merge SRT and RTC servers into unified SrsServer. v7.0.68 (#4459)
This PR consolidates the SRT and RTC server functionality into the main
SrsServer class, eliminating the separate `SrsSrtServer` and
`SrsRtcServer` classes and their corresponding adapter classes. This
architectural change simplifies the codebase by removing the hybrid
server pattern and integrating all protocol handling directly into
`SrsServer`.

As unified connection manager (`_srs_conn_manager`) for all protocol
connections, all incoming connections are checked against the same
connection limit in `on_before_connection()`. This enables consistent
connection limits: `max_connections` now protects against resource
exhaustion from any protocol, not just RTMP.

Remove modules because it's not used now, so only keep the server
application module and main entry point. Remove the wait group to run
server, instead, directly run server and invoke the cycle method.

After this PR, the startup workflow and servers architecture should be
much easier to maintain.

---------

Co-authored-by: OSSRS-AI <winlinam@gmail.com>
2025-08-31 08:58:37 -04:00
Winlin
35e2808f0c Support IPv6 for all protocols: RTMP, HTTP/HTTPS, WebRTC, SRT, RTSP. v7.0.67 (#4457)
This PR adds comprehensive IPv6 support to SRS for all major protocols,
enabling dual-stack (IPv4/IPv6) operation across the entire streaming
server.

Key Features:

* RTMP/RTMPS: IPv6 support for streaming ingestion and playback
* HTTP/HTTPS: IPv6 support for HTTP-FLV streaming and API endpoints
* WebRTC: IPv6 support for UDP/TCP media transport (WHIP/WHEP)
* SRT: IPv6 support for low-latency streaming
* RTSP: IPv6 support for standards-based streaming

For config, see `conf/console.ipv46.conf` for example.

Publish RTMP or RTMPS via IPv6:

```bash
ffmpeg -re -i ./doc/source.flv -c copy -f flv 'rtmp://[::1]:1935/live/livestream'
ffmpeg -re -i ./doc/source.flv -c copy -f flv 'rtmps://[::1]:1443/live/livestream'
```

Play RTMP or RTMPS stream via IPv6 by ffplay:

```bash
ffplay 'rtmp://[::1]:1935/live/livestream'
ffplay 'rtmps://[::1]:1443/live/livestream'
```

Play by IPv6 via HTTP streaming:
* HTTP-FLV:
[http://[::1]:8080/live/livestream.flv](http://[::1]:8080/players/srs_player.html)
* HTTPS-FLV:
[https://[::1]:8088/live/livestream.flv](https://[::1]:8088/players/srs_player.html)

To access HTTP API via IPv6:

* HTTP API: `curl 'http://[::1]:1985/api/v1/versions'`
* HTTPS API: `curl -k 'https://[::1]:1990/api/v1/versions'`

```json
{
  "code": 0,
  "data": {
    "major": 7,
    "minor": 0,
    "revision": 66,
    "version": "7.0.66"
  }
}
```

Using HTTP API, publish by IPv6 WHIP via
[HTTP](http://[::1]:8080/players/whip.html), and play by
[WHEP](http://[::1]:8080/players/whep.html)

* WHIP: `http://[::1]:1985/rtc/v1/whip/?app=live&stream=livestream`
* WHEP: `http://[::1]:1985/rtc/v1/whep/?app=live&stream=livestream`

Using HTTPS API, publish by IPv6 WHIP via
[WHIP](https://[::1]:8088/players/whip.html), and play by
[WHEP](https://[::1]:8088/players/whep.html)

* WHIP: `https://[::1]:1990/rtc/v1/whip/?app=live&stream=livestream`
* WHEP: `https://[::1]:1990/rtc/v1/whep/?app=live&stream=livestream`

Publish SRT stream by FFmpeg via IPv6:

```bash
ffmpeg -re -i ./doc/source.flv -c copy -pes_payload_size 0 -f mpegts \
  'srt://[::1]:10080?streamid=#!::r=live/livestream,m=publish'
```

Play SRT stream by ffplay via IPv6:

```bash
ffplay 'srt://[::1]:10080?streamid=#!::r=live/livestream,m=request'
```

Play RTSP stream by ffplay via IPv6:

```bash
ffplay -rtsp_transport tcp -i 'rtsp://[::1]:8554/live/livestream'
```

---------

Co-authored-by: OSSRS-AI <winlinam@gmail.com>
2025-08-30 08:52:21 -04:00
Winlin
7a927c5bae AI: Remove cloud CLS and APM. v7.0.66 (#4456)
Co-authored-by: chundonglinlin <chundonglinlin@163.com>
Co-authored-by: OSSRS-AI <winlinam@gmail.com>
2025-08-28 10:37:57 -04:00
Winlin
1fa2cba7c0 Organize utility functions to kernel. v7.0.65 (#4455) 2025-08-27 21:35:58 -04:00
Winlin
1c4ecefcb6 AI: Config: Move RTMP configs to rtmp{} section. v7.0.64 (#4454)
This PR reorganizes SRS configuration structure by moving RTMP-specific
configurations from global scope to a dedicated `rtmp {}` section, and
includes various cleanups.

**Before (SRS 6.x):**

```nginx
listen 1935;
chunk_size 60000;
max_connections 1000;
```

**After (SRS 7.0+):**

```nginx
max_connections 1000;
rtmp {
    listen 1935;
    chunk_size 60000;
}
```

Cleanup:

* Removed unused threads_interval configuration and related code
* Cleaned up reload handlers and removed obsolete functionality

---------

Co-authored-by: OSSRS-AI <winlinam@gmail.com>
2025-08-27 19:27:23 -04:00
Jacob Su
eaa3d512ee RTC: Fix null pointer crash in RTC2RTMP when start packet is missing. v6.0.175 v7.0.63 (#4451)
Try to fix #4450

The SRS transcode rtp packets, whose sequence number in range [start,
end], to one rtmp packet, but when the first rtp packet is empty, then
this crash happens.

check #4450 for details.

5.0release and 6.0release branch.
develop branch already has its own solution.

So this PR is targeting to **6.0release**.

find the first not empty rtp packet in seq range [start, end].

---------

Co-authored-by: OSSRS-AI <winlinam@gmail.com>
Co-authored-by: winlin <winlinvip@gmail.com>
2025-08-26 18:46:39 -04:00
Winlin
72ddc28d97 AI: Implement stream publish token system to prevent race conditions across all protocols. v7.0.62 (#4452)
This PR introduces a comprehensive stream publish token system that
prevents race conditions when multiple publishers attempt to publish to
the same stream URL simultaneously across different protocols (RTMP,
WebRTC, SRT).

* Race Condition Issue: Multiple publishers could create duplicate
sources for the same stream when context switches occurred during source
initialization in SRS's coroutine-based architecture
* Cross-Protocol Conflicts: Different protocols (RTMP, RTC, SRT) could
simultaneously publish to the same stream URL without coordination
* Resource Management: No centralized mechanism to ensure exclusive
stream publishing access

---------

Co-authored-by: OSSRS-AI <winlinam@gmail.com>
2025-08-26 10:27:53 -04:00
Winlin
1b6f97bd2d Refine source lock to fix race condition in source managers. v7.0.61 (#4449)
This PR fixes a critical race condition in SRS source managers where
multiple coroutines could create duplicate sources for the same stream.

- **Atomic source creation**: Source lookup, creation, and pool
insertion now happen atomically within lock scope
- **Consistent interface**: Standardize on `ISrsRequest*` interface
throughout codebase
- **Handler simplification**: Remove `ISrsLiveSourceHandler*` parameter,
obtain from global server instance

---------

Co-authored-by: OSSRS-AI <winlinam@gmail.com>
2025-08-23 07:36:41 -06:00
Winlin
6ec97067de AI: Remove cygwin64, always enable WebRTC, and enforce C++98 compatibility. v7.0.60 (#4447)
This PR makes WebRTC a core feature of SRS and enforces C++98
compatibility by:

1. Always Enable WebRTC Support
- Remove `--rtc=on|off` configuration option - WebRTC is now always
enabled
- Eliminate all `#ifdef SRS_RTC` conditional compilation blocks
- Include WebRTC-related modules (RTC, SRTP, DTLS) in all builds
- Update build scripts to always link WebRTC dependencies

2. Enforce C++98 Compatibility  
- Remove `--cxx11=on|off` and `--cxx14=on|off` configuration options
- Force `SRS_CXX11=NO` and `SRS_CXX14=NO` in build system
- Move these options to deprecated section with warnings
- Ensure codebase maintains C++98 standard compatibility

3. Remove Windows/Cygwin Support
- Remove all Windows and Cygwin64 conditional compilation blocks (#ifdef
_WIN32, #ifdef CYGWIN64)
- Delete Cygwin64 build configurations from build scripts (
auto/options.sh, auto/depends.sh, configure)
- Remove Cygwin64 assembly files and State Threads platform support (
md_cygwin64.S)
- Eliminate Windows-specific GitHub Actions workflows and CI/CD jobs
- Remove NSIS packaging files and Windows installer generation
- Delete Windows documentation and update feature lists to mark support
as removed in v7.0
- Simplify OS detection to only support Unix-like systems (Linux, macOS)

4. Code Cleanup
- Remove conditional WebRTC code blocks throughout the codebase
- Simplify build configuration by removing WebRTC-related conditionals
- Update constructor delegation patterns to be C++98 compatible
- Fix vector initialization to use C++98 syntax
- Eliminate Windows-specific implementations for file operations, time
handling, and networking
- Unified platform handling with consistent POSIX API usage

---------

Co-authored-by: OSSRS-AI <winlinam@gmail.com>
2025-08-21 10:03:38 -06:00
Winlin
5adf684f59 AI: Remove multi-threading support and change to single-thread architecture. v7.0.59 (#4445)
This PR removes the multi-threading infrastructure from SRS and
consolidates the codebase to use single-thread architecture exclusively.
This is a architectural simplification that aligns with SRS's
coroutine-based design philosophy.

* Simplified Architecture: Eliminates complexity of multi-threading
coordination
* Better Alignment: Matches SRS's coroutine-based single-thread design
philosophy
* Reduced Complexity: Removes potential race conditions and threading
bugs
* Cleaner Code: More focused modules with clear responsibilities
* Easier Maintenance: Fewer moving parts and clearer execution flow

---------

Co-authored-by: OSSRS-AI <winlinam@gmail.com>
2025-08-20 15:12:51 -06:00
Winlin
f20a1eae84 Refactor: Convert HTTP hooks from static methods to interface-based architecture. v7.0.58 (#4444)
This PR refactors the HTTP hooks system from static methods to a proper
interface-based architecture, improving code maintainability,
testability, and extensibility.

1. **Testability**: Interface allows easy mocking for unit tests
1. **Extensibility**: Custom hook implementations can be injected
1. **Maintainability**: Clear separation of concerns and better code
organization
1. **Documentation**: Comprehensive inline documentation for all hook
methods
1. **Future-proofing**: Enables plugin architecture and custom hook
handlers

---------

Co-authored-by: OSSRS-AI <winlinam@gmail.com>
2025-08-19 23:10:14 -06:00
chundonglinlin
664e868972 HLS: restore HLS information when republish stream.(#3088). v7.0.57 (#3126)
### Feature
HLS continuous mode: In this mode HLS sequence number is started from
where it stopped last time. Old fragments are kept. Default is on.
### Configuration
```
vhost __defaultVhost__ {
    hls {
        enabled         on;
        hls_path        ./objs/nginx/html;
        hls_fragment    10;
        hls_window      60;
        hls_continuous  on;
    }
}
```

Contributed by AI:

* [AI: Refine and extract HLS
recover.](656e4e296d)

---------

Co-authored-by: Haibo Chen <495810242@qq.com>
Co-authored-by: winlin <winlinvip@gmail.com>
Co-authored-by: OSSRS-AI <winlinam@gmail.com>
2025-08-19 22:09:54 -06:00
Winlin
ebcaef43c6 RTMP: Support RTMPS server. v7.0.56 (#4443)
This PR is extracted by AI from #3949 to support RTMPS server in SRS.

Run SRS with RTMPS support:

```bash
./objs/srs -c conf/rtmps.conf
```

Publish RTMPS stream by FFmpeg:

```bash
ffmpeg -re -i doc/source.flv -c copy -f flv rtmps://localhost:1443/live/livetream
```

Play RTMPS stream by ffplay:

```bash
ffplay rtmps://localhost:1443/live/livetream
```

Below work is done by AI:

* [AI: Extract RTMP transport for
RTMPS.](7948111464)
* [AI: Extract RTMPS
transport.](a669cbba89)

---------

Co-authored-by: john <hondaxiao@tencent.com>
Co-authored-by: OSSRS-AI <winlinam@gmail.com>
2025-08-19 07:39:36 -06:00
Jacob Su
8cd4616147 fix err memory leak in rtc to rtmp bridge. v6.0.174 v7.0.55 (#4441)
1. print the error messages before dismiss it;
2. free the err to avoid memory leak;

## Cause
found this issue when research #4434 .


## Impact

 1. develop
 2. 5.0release
 3. 6.0release

---------

Co-authored-by: winlin <winlinvip@gmail.com>
2025-08-16 07:56:49 -06:00
Jacob Su
9b871fd862 Fix: Remove redundant enabled checks in HLS/DASH cleanup to prevent resource leaks. v6.0.173 v7.0.54 (#4161)
## Problem
HLS and DASH components had redundant `enabled` flag checks in their
`cycle()` and `cleanup_delay()` methods that prevented proper cleanup of
files when components were disabled. This created a race condition
where:

1. Stream stops publishing and HLS/DASH components get disabled
2. `cycle()` returns early without performing disposal operations  
3. `cleanup_delay()` returns 0 instead of configured disposal timeout
4. Source cleanup doesn't wait long enough for file disposal
5. HLS/DASH files remain on disk without proper cleanup

## Root Cause
The `enabled` flag should control processing of **new incoming
streams**, but should NOT prevent **cleanup of existing files** from
previously enabled streams.

## Solution
Remove redundant `enabled` checks from:
- `SrsHls::cycle()` and `SrsDash::cycle()` - Allow disposal logic to run
even when disabled
- `SrsHls::cleanup_delay()` and `SrsDash::cleanup_delay()` - Always
return proper disposal timeout

---------

Co-authored-by: winlin <winlinvip@gmail.com>
2025-08-14 06:55:27 -06:00
Jacob Su
7aba442a38 HLS: Remove deprecated hls_acodec/hls_vcodec configs. v7.0.53 (#4225)
## Summary
Removes the deprecated `hls_acodec` and `hls_vcodec` configuration
options and implements automatic codec detection for HLS streams, fixing
issues with video-only streams incorrectly showing audio information.

## Problem
- When streaming video-only content via RTMP, HLS output incorrectly
contained audio track information due to hardcoded default codec
settings
- The static `hls_acodec` and `hls_vcodec` configurations were
inflexible and caused compatibility issues with some players
- Users had to manually configure `hls_acodec an` to fix video-only
streams

## Solution
- **Remove deprecated configs**: Eliminates `hls_acodec` and
`hls_vcodec` configuration options entirely
- **Dynamic codec detection**: HLS muxer now automatically detects and
uses actual stream codecs in real-time
- **Improved defaults**: Changes from hardcoded AAC/H.264 defaults to
disabled state, letting actual stream content determine codec
information
- **Real-time codec switching**: Supports codec changes during streaming
with proper logging

## Changes
- Remove `get_hls_acodec()` and `get_hls_vcodec()` from SrsConfig
- Update HLS muxer to use `latest_acodec_`/`latest_vcodec_` for codec
detection
- Add codec detection logic in `write_audio()` and `write_video()`
methods
- Remove deprecated config options from all configuration files
- Add comprehensive unit tests for codec detection functionality

Fixes #4223

---------

Co-authored-by: Haibo Chen <495810242@qq.com>
Co-authored-by: OSSRS-AI <winlinam@gmail.com>
2025-08-13 06:34:05 -04:00