Commit Graph

356 Commits (55026a4fc79e70905e562e634701f09c6a1d1b2a)

Author SHA1 Message Date
Haibo Chen ef5d216dbc Enhancing the compatibility of options.sh. v5.0.204 (#3916)
Accommodate certain complex parameters that include the "=" character,
for example.
`configure --extra-flags="-O2 -D_FORTIFY_SOURCE=2"`

---------

Co-authored-by: john <hondaxiao@tencent.com>
1 year ago
john 43d15ed3d8 RTC: Support OPUS stereo SDP option. v5.0.203 (#3910)
In an SDK that supports RTC Opus stereo, the parameter "stereo=1" may
appear. SRS (Spatial Reference System) needs to handle this correctly
and return an answer to enable WebRTC stereo support.

---------

`TRANS_BY_GPT4`
1 year ago
john 52b01b14e9 Security: Support IP whitelist for HTTP-FLV, HLS, WebRTC, and SRT. v5.0.202 (#3902)
Security is the built-in IP whitelist feature of SRS, which allows and
denies certain IP and IP range users. Previously, it only supported
RTMP, but this PR now supports HTTP-FLV, HLS, WebRTC, SRT, and other
protocols.

See https://ossrs.io/lts/en-us/docs/v6/doc/security as example.

---------

Co-authored-by: john <hondaxiao@tencent.com>
1 year ago
john 0808be18ad fix 'sed' error in options.sh. v5.0.201 (#3891)
The `-` character, when placed in the middle of a regular expression, is
interpreted as a range. It must be placed at the beginning or end to be
interpreted as a literal character.

---------

`TRANS_BY_GPT4`

---------

Co-authored-by: john <hondaxiao@tencent.com>
1 year ago
winlin f1b419df4c Release v5.0-b7, 5.0 beta7, v5.0.200, 163305 lines. 1 year ago
Winlin a1901b5213 Change the hls_aof_ratio to 2.1. v5.0.200 (#3886)
In pure audio mode, there are no keyframes. Therefore, we can only rely
on the length of the slice to determine whether it should be output.
`hls_aof_ratio` is the coefficient that, once reached, will generate a
new slice.

In scenarios with video, if the `hls_aof_ratio` is too small, for
example 1.2, and the GOP (Group of Pictures) is 10 seconds, then a slice
will definitely be generated at 12 seconds. At this point, if there are
no keyframes, it will cause the next slice to start with a non-keyframe.

A safer coefficient is twice the GOP (Group of Pictures). This way, it
won't trigger incorrectly and prevent the individual transcoding of a ts
segment file.

---------

Co-authored-by: Haibo Chen <495810242@qq.com>
1 year ago
Haibo Chen 4e4cce867b Support configure with --extra-ldflags. v5.0.199 (#3879)
1. add --extra-ldflags
2. support  commas in configure file
3. support link system library for utest

```
./configure --extra-ldflags=-Wl,-z,now
```
1 year ago
Haibo Chen 316f4641ac Don't compile libopus when enable sys-ffmpeg. v5.0.198 (#3851) 1 year ago
chundonglinlin f1db76011b RTC: Refine FFmpeg opus audio noisy issue. v5.0.197 (#3852)
When converting between AAC and Opus formats (aac2opus or opus2aac), the
`av_frame_get_buffer` API is frequently called.

The goal is to optimize the code logic and reduce the frequent
allocation and deallocation of memory.

In the case of aac2opus, av_frame_get_buffer is still frequently called.
In the case of opus2aac, the goal is to avoid calling
av_frame_get_buffer and reduce memory allocations.

Before calling the `av_audio_fifo_read` API, use
`av_frame_make_writable` to check if the frame is writable. If it is not
writable, create a new frame.

---------

Co-authored-by: john <hondaxiao@tencent.com>
1 year ago
chundonglinlin 35f479c6bc Support build without cache to test if actions fail. v5.0.196 (#3858)
By default, caching is enabled during compilation, which means that data
is cached in Docker. This helps to avoid compiling third-party
dependency libraries. However, sometimes when updating third-party
libraries, it's necessary to disable caching to temporarily verify if
the pipeline can succeed. Therefore, a configure option should be added.
When this option is enabled, the compilation cache will not be used, and
all third-party libraries will be compiled from scratch.

---------

Co-authored-by: winlin <winlinvip@gmail.com>
1 year ago
john 268bac58bd RTC: Fix FFmpeg opus audio noisy issue. v5.0.195 (#3845)
Follow the example in FFmpeg's doc, before calling the API
`avcodec_send_frame`, always use `av_frame_alloc` to create a new frame.

---------

Co-authored-by: Haibo Chen <495810242@qq.com>
1 year ago
chundonglinlin d51cabb4b7 WebRTC: TCP transport should use read_fully instead of read. v5.0.194 (#3847)
SRS supports TCP WebRTC by reading 2 bytes of length, like `read(buf,
2)`. However, in some cases, it might receive 1 byte, causing subsequent
data to be incorrect and making it unable to push or play streams.

---------

Co-authored-by: john <hondaxiao@tencent.com>
1 year ago
john a9223ebe47 Added system library option for ffmpeg, srtp, srt libraries. v5.0.193 (#3846)
---------

Co-authored-by: john <hondaxiao@tencent.com>
1 year ago
john 56a4ca3f7e Disable asan by default. v5.0.192 (#3840)
---------

Co-authored-by: john <hondaxiao@tencent.com>
1 year ago
john ba33bb8f8b Support set the ice-ufrag and ice-pwd for connectivity check. v5.0.191 (#3837)
Checking the HTTPS API or UDP connectivity for WHIP tests can be
difficult. For example, if the UDP port isn't available but the API is
fine, OBS only says it can't connect to the server. It's hard to see the
HTTPS API response or check if the UDP port is available.

This feature lets you set the ice username and password in SRS. You can
then send a STUN request using nc and see the response, making it easier
to check UDP port connectivity.

1. Use curl to test the WHIP API, including ice-frag and ice-pwd
queries.
2. Use nc to send a STUN binding request to test UDP connectivity.
3. If both the API and UDP are working, you should get a STUN response.

---------

Co-authored-by: john <hondaxiao@tencent.com>
1 year ago
john 3da81e4b75 Refine docker detect mechenism. v5.0.190 (#3758)
When using Docker, logs are usually printed to console (stdout and
stderr). However, since Docker detection occurs late, after log
initialization, the default log output may be incorrect. In Docker, logs
may still be written to a file instead of the console as expected.

Additionally, the Dockerfile has been improved with a new environment
variable `SRS_IN_DOCKER=on` to clearly indicate a Docker environment. If
automatic Docker detection fails, the configuration will be read, and
this variable will correctly inform SRS that it's in a Docker
environment.

Lastly, the default configuration values have been improved for Docker
environments. By default, `SRS_LOG_TANK=console` and daemon mode is
disabled.

---------

Co-authored-by: john <hondaxiao@tencent.com>
1 year ago
肖志宏 ef7fe1b186 Fix bug for upgrading to OpenSSL 3.0. v5.0.189 (#3827)
The fix is for the DH_set_length error. As shown in lines 2-5, OpenSSL
3.0 added a check for length, which allowed this issue to be exposed.
```
1 if (dh->params.q == NULL) {
2       /* secret exponent length, must satisfy 2^(l-1) <= p */
3        if (dh->length != 0
4            && dh->length >= BN_num_bits(dh->params.p))
5            goto err;
6        l = dh->length ? dh->length : BN_num_bits(dh->params.p) - 1;
7        if (!BN_priv_rand_ex(priv_key, l, BN_RAND_TOP_ONE,
8                             BN_RAND_BOTTOM_ANY, 0, ctx))
9            goto err;
        ... ...
    }
```

---------

Co-authored-by: john <hondaxiao@tencent.com>
1 year ago
肖志宏 53ebf58583 SRT: Fix the missing config mss. v5.0.188 (#3825)
---------

Co-authored-by: john <hondaxiao@tencent.com>
1 year ago
john 75c9c5a849 Solve the problem of inaccurate HLS TS duration. v5.0.187 (#3824) 1 year ago
肖志宏 8b80566f78 Use new cache image name. v5.0.186 1 year ago
Haibo Chen 4455065246
Cherry-pick from develop, for srt utest. v5.0.185 (#3816) 1 year ago
Haibo Chen 3ddacdb47b Build: Support sys-ssl for srt. v5.0.184 (#3806)
support sys-ssl for srt

---------

Co-authored-by: john <hondaxiao@tencent.com>
1 year ago
winlin 632d457194 Upgrade libsrt to v1.5.3. v5.0.183 (#3808) 1 year ago
Winlin 389a62ee3a WebRTC: Support WHEP for play. v5.0.182 (#3404)
RFC for WHIP: https://datatracker.ietf.org/doc/draft-ietf-wish-whip/

RFC for WHEP: https://datatracker.ietf.org/doc/draft-murillo-whep/

Please note that SRS 5.0 already had WHIP support. I didn't write a
document about WHIP, because WHIP is not a RFC right now, but there are
clues in
[srs-unity](https://github.com/ossrs/srs-unity#usage-publisher). SRS
WHIP url for publisher:
`http://localhost:1985/rtc/v1/whip/?app=live&stream=livestream`

This PR is for WHEP, the url for player is
`http://localhost:1985/rtc/v1/whep/?app=live&stream=livestream`

PS: There is a great PR for OBS to have WHIP support, see
https://github.com/obsproject/obs-studio/pull/7926 and #3581

PS: WHIP for FFmpeg https://github.com/ossrs/ffmpeg-webrtc/pull/1

See #3170

---------

Co-authored-by: Haibo Chen <495810242@qq.com>
Co-authored-by: john <hondaxiao@tencent.com>
Co-authored-by: ChenGH <chengh_math@126.com>
1 year ago
john 456f5d64a9 Prevent the output of srt logs in utest. v5.0.181 (#3807)
Prevent the output of srt logs in utest.

---------

Co-authored-by: chundonglinlin <chundonglinlin@163.com>
1 year ago
john 21ae618c48 SRT: Log level to debug when no socket to accept. v5.0.180 (#3696) 1 year ago
Winlin bc0a516fd1 Support FFmpeg timecode, fix AMF0 parsing failed. v5.0.179 (#3804)
Please see https://github.com/ossrs/srs/issues/3803 for detail:

1. When using FFmpeg with the `-map 0` option, there may be a 4-byte
timecode in the AMF0 Data.
2. SRS should be able to handle this packet without causing a parsing
error, as it's generally expected to be an AMF0 string, not a 4-byte
timecode.
3. Disregard the timecode since SRS doesn't utilize it.

See [Error submitting a packet to the muxer: Broken pipe, Error muxing a
packet](https://trac.ffmpeg.org/ticket/10565)

---------

Co-authored-by: john <hondaxiao@tencent.com>
1 year ago
Mr. Li b352fd0cfe Fix RBSP issue, where 0x03 should be removed. v5.0.178 (#3597)
ISO_IEC_14496-10-AVC-2012.pdf, page 65
7.4.1.1 Encapsulation of an SODB within an RBSP (informative)

... 00 00 03 xx, the 03 byte should be drop where xx represents any 2
bit pattern: 00, 01, 10, or 11.

---------

Co-authored-by: john <hondaxiao@tencent.com>
Co-authored-by: chundonglinlin <chundonglinlin@163.com>
Co-authored-by: winlin <winlin@vip.126.com>
1 year ago
john fc9a44d4b4 Fix dash crash if format not supported. v5.0.177 (#3795)
Fix the issue of DASH crashing when audio/video formats are not
supported.

---------

Co-authored-by: Haibo Chen <495810242@qq.com>
1 year ago
Winlin 0df81c3b34 Support HTTP-API for fetching reload result. v5.0.176 (#3779)
During a Reload, several stages will be passed through:
1. Parsing new configurations: Parse.
2. Transforming configurations: Transform.
3. Applying configurations: Apply.

Previously, any error at any stage would result in a direct exit, making
the system completely dependent on configuration checks:

```bash
./objs/srs -c conf/srs.conf -t
echo $?
```

Optimized to: If an error occurs before applying the configuration, it
can be ignored. If an error occurs during the application of the
configuration, some of the configuration may have already taken effect,
leading to unpredictable behavior, so SRS will exit directly.

Added a new HTTP API to query the result of the reload.

```nginx
http_api {
    enabled         on;
    raw_api {
        enabled on;
        allow_reload on;
    }
}
```

```bash
curl http://localhost:1985/api/v1/raw?rpc=reload-fetch
```

```json
{
  "code": 0,
  "data": {
    "err": 0,
    "msg": "Success",
    "state": 0,
    "rid": "0s6y0n9"
  }
}

{
  "code": 0,
  "data": {
    "err": 1023,
    "msg": "code=1023(ConfigInvalid) : parse file : parse buffer containers/conf/srs.release-local.conf : root parse : parse dir : parse include buffer containers/data/config/srs.vhost.conf : read token, line=0, state=0 : line 3: unexpected end of file, expecting ; or \"}\"",
    "state": 1,
    "rid": "0g4z471"
  }
}
```

This way, you can know if the last reload of the system was successful.

---------

Co-authored-by: Haibo Chen <495810242@qq.com>
1 year ago
Jacob Su cbb5edcc3c SrsContextId assignment can be improved without create a duplicated one. v5.0.175 (#3503)
SrsContextId object creation can be improved on `srs_protocol_log.cpp`,
No need to create one, then assign it back. It seems a common mistake
for Cpp programmers.

---------

Co-authored-by: john <hondaxiao@tencent.com>
1 year ago
Winlin 8d6b882034 HLS: Fix on_hls and hls_dispose critical zone issue. v5.0.174 (#3781)
on_hls and hls_dispose are two coroutines, with potential race
conditions. That is, during on_hls, if the API Server being accessed is
slower, it will switch to the hls_dispose coroutine to start cleaning
up. However, when the API Server is processing the slice, a situation
may occur where the slice does not exist, resulting in the following
log:

```
[2023-08-22 12:03:20.309][WARN][40][x5l48q7b][11] ignore task failed code=4005(HttpStatus)(Invalid HTTP status code) : callback on_hls http://localhost:2024/terraform/v1/hooks/srs/hls : http: post http://localhost:2024/terraform/v1/hooks/srs/hls with {"server_id":"vid-5d7dxn8","service_id":"cu153o7g","action":"on_hls","client_id":"x5l48q7b","ip":"172.17.0.1","vhost":"__defaultVhost__","app":"live","tcUrl":"srt://172.17.0.2/live","stream":"stream-44572-2739617660809856576","param":"secret=1ed8e0ffbc53439c8fc8da30ab8c19f0","duration":4.57,"cwd":"/usr/local/srs-stack/platform","file":"./objs/nginx/html/live/stream-44572-2739617660809856576-1.ts","url":"live/stream-44572-2739617660809856576-1.ts","m3u8":"./objs/nginx/html/live/stream-44572-2739617660809856576.m3u8","m3u8_url":"live/stream-44572-2739617660809856576.m3u8","seq_no":1,"stream_url":"/live/stream-44572-2739617660809856576","stream_id":"vid-0n9zoz3"}, status=500, res=invalid ts file ./objs/nginx/html/live/stream-44572-2739617660809856576-1.ts: stat ./objs/nginx/html/live/stream-44572-2739617660809856576-1.ts: no such file or directory
thread [40][x5l48q7b]: call() [./src/app/srs_app_hls.cpp:122][errno=11]
thread [40][x5l48q7b]: on_hls() [./src/app/srs_app_http_hooks.cpp:401][errno=11]
thread [40][x5l48q7b]: do_post() [./src/app/srs_app_http_hooks.cpp:638][errno=11]

[error] 2023/08/22 12:03:20.076984 [52][1001] Serve /terraform/v1/hooks/srs/hls failed, err is stat ./objs/nginx/html/live/stream-44572-2739617660809856576-1.ts: no such file or directory
invalid ts file ./objs/nginx/html/live/stream-44572-2739617660809856576-1.ts
main.handleOnHls.func1.1
	/g/platform/srs-hooks.go:684
main.handleOnHls.func1
	/g/platform/srs-hooks.go:720
net/http.HandlerFunc.ServeHTTP
	/usr/local/go/src/net/http/server.go:2084
net/http.(*ServeMux).ServeHTTP
	/usr/local/go/src/net/http/server.go:2462
net/http.serverHandler.ServeHTTP
	/usr/local/go/src/net/http/server.go:2916
net/http.(*conn).serve
	/usr/local/go/src/net/http/server.go:1966
runtime.goexit
	/usr/local/go/src/runtime/asm_amd64.s:1571
```

Similarly, when stopping the stream, on_hls will also be called to
handle the last slice. If the API Server is slower at this time, it will
enter hls_dispose and call unpublish repeatedly. Since the previous
unpublish is still blocked in on_hls, the following interference log
will appear:

```
[2023-08-22 12:03:18.748][INFO][40][6498088c] hls cycle to dispose hls /live/stream-44572-2739617660809856576, timeout=10000000ms
[2023-08-22 12:03:18.752][WARN][40][6498088c][115] flush audio ignored, for segment is not open.
[2023-08-22 12:03:18.752][WARN][40][6498088c][115] ignore the segment close, for segment is not open.
```

Although this log will not cause problems, it can interfere with
judgment.

The solution is to add an 'unpublishing' status. If it is in the
'unpublishing' status, then do not clean up the slices.

---------

Co-authored-by: Haibo Chen <495810242@qq.com>
1 year ago
Winlin fdcff383ae Support include empty config file. v5.0.173 (#3768)
SRS supports including another configuration in the include package.
When generating configurations, we can only generate the changed
configurations, while the unchanged configurations are in the fixed
files, for example:

```nginx
listen 1935;
include server.conf;
```

In `server.conf`, we can manage the changing configurations with the
program:

```nginx
http_api { enabled on; }
```

However, during system initialization, we often create an empty
`server.conf`, and the content is generated only after the program
starts, so `server.conf` might be an empty file. This also makes it
convenient to use a script to confirm the existence of this file:

```bash
touch server.conf
```

Currently, SRS does not support empty configurations and will report an
error. This PR is to solve this problem, making it more convenient to
use include.

`TRANS_BY_GPT4`

---------

Co-authored-by: Haibo Chen <495810242@qq.com>
1 year ago
Winlin 20f238eb9a HLS: Support reload HLS asynchronously. v5.0.172 (#3782)
When reloading HLS, it directly operates unpublish and publish. At this
time, if HLS is pushed, an exception may occur.

The reason is that these two coroutines operated on the HLS object at
the same time, causing a null pointer.

Solution: Use asynchronous reload. During reload, only set variables and
let the message processing coroutine implement the reload.

---------

Co-authored-by: Haibo Chen <495810242@qq.com>
Co-authored-by: chundonglinlin <chundonglinlin@163.com>
1 year ago
terrencetang2023 df8c028054 Bugfix: Log format output type does not match. v5.0.171 (#3775)
A segmentation fault occurred on arm
https://github.com/ossrs/srs/issues/3714

---------

Co-authored-by: Haibo Chen <495810242@qq.com>
1 year ago
winlin 939f6b484b HLS: Ignore empty NALU to avoid error. v5.0.170 2 years ago
Mr. Li 08147f81bf Bugfix: Eliminate the redundant declaration of the _srs_rtc_manager variable. v5.0.169 (#3699)
It is advised to eliminate any instances of _srs_rtc_manager that occur
multiple times.

---------

Co-authored-by: john <hondaxiao@tencent.com>
Co-authored-by: chundonglinlin <chundonglinlin@163.com>
2 years ago
john c7851da464 API: Fix HTTPS callback issue using SNI in TLS client handshake. v5.0.168 (#3695)
---------

Co-authored-by: chundonglinlin <chundonglinlin@163.com>
2 years ago
chundonglinlin e11b93d664 WebRTC: Support config the bitrate of transcoding AAC to Opus. v5.0.167, v6.0.60 (#3515)
---------

Co-authored-by: john <hondaxiao@tencent.com>
2 years ago
chundonglinlin 29271a46d3 Compile: Fix typo for 3rdparty. v5.0.166, v6.0.59 (#3615)
---------

Co-authored-by: john <hondaxiao@tencent.com>
2 years ago
winlin c6eddc72e9 Fix issue of srs-player failing to play HTTP-FLV. v5.0.165 2 years ago
Winlin 6d679fd0e3 WHIP: Improve WHIP deletion by token verification. v5.0.164, v6.0.58 (#3595)
------

Co-authored-by: chundonglinlin <chundonglinlin@163.com>
2 years ago
wangzhen 17f0d1fefc BugFix: Resolve the problem of srs_error_t memory leak. v5.0.163, v6.0.57 (#3605)
---------

Co-authored-by: Haibo Chen <495810242@qq.com>
Co-authored-by: chundonglinlin <chundonglinlin@163.com>
2 years ago
Haibo Chen 3955d3fe55 Improve the usage of "transcode" in the "full.conf" file. v5.0.162, v6.0.56 (#3596)
---------

Co-authored-by: chundonglinlin <chundonglinlin@163.com>
Co-authored-by: john <hondaxiao@tencent.com>
2 years ago
Kazuo 596270feff H264: Fix H.264 ISOM reserved bit value. v5.0.161, v6.0.55 (#3551)
---------

Co-authored-by: chundonglinlin <chundonglinlin@163.com>
2 years ago
Haibo Chen fbccdb92b7 Fix Permission Issue in depend.sh for OpenSSL Compilation. v5.0.160, v6.0.53 (#3592)
---------

Co-authored-by: john <hondaxiao@tencent.com>
2 years ago
john ca46185ace Fix crash when process rtcp feedback message. v5.0.159, v6.0.52 (#3591)
---------

Co-authored-by: johzzy <hellojinqiang@gmail.com>
2 years ago
Winlin 5759025e43 WHIP: Add OBS support, ensuring compatibility with a unique SDP. v5.0.158, v6.0.51 (#3581)
1. Ignore SDP GROUP LS.
2. Support ice in global session info.
3. Support audio codec "OPUS" or "opus".

---------

Co-authored-by: Johnny <hellojinqiang@gmail.com>
2 years ago
panda 1e43bb6b9f Fix command injection in api-server for HTTP callback. v5.0.157, v6.0.48 2 years ago
Winlin 900c4cdd97 DTLS: Use bio callback to get fragment packet. v5.0.156, v6.0.47 (#3565)
1. The MTU is effective, with the certificate being split into two DTLS records to comply with the limit.
2. The issue occurs when using BIO_get_mem_data, which retrieves all DTLS packets in a single call, even though each is smaller than the MTU.
3. An alternative callback is available for using BIO_new with BIO_s_mem.
4. Improvements to the MTU setting were made, including adding the DTLS_set_link_mtu function and removing the SSL_set_max_send_fragment function.
5. The handshake process was refined, calling SSL_do_handshake only after ICE completion, and using SSL_read to handle handshake messages.
6. The session close code was improved to enable immediate closure upon receiving an SSL CloseNotify or fatal message.

------

Co-authored-by: chundonglinlin <chundonglinlin@163.com>
2 years ago