1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-02-13 03:41:55 +00:00
Commit graph

6767 commits

Author SHA1 Message Date
Marc Olzheim
f76be5fe9b
HLS: Add missing newline to end of session manifest. v6.0.143 (#4115)
The session HLS manifest file lacks a terminating newline in the final
line.
This may cause strict players to reject it.

---------

Co-authored-by: winlin <winlinvip@gmail.com>
2024-07-24 22:37:30 +08:00
Jacob Su
3e1a4e4439
Player: Fix empty img tag occupy 20px size in safari. v6.0.142 (#4029)
the html img tag occupy 20px size in safari. 

427104f1da/trunk/research/players/rtc_player.html (L19)

> <img width="1011" alt="Screenshot 2024-04-17 at 9 17 07 AM"
src="https://github.com/ossrs/srs/assets/2757043/79a4edf8-5bbf-4300-8817-039088f13283">


(ignore the img css warning: `auto\9;` it's another problem, I will file
another PR.)

but, the empty img tag just occupy 1px size in chrome. So I guess it's a
html compatible problem.

> <img width="608" alt="Screenshot 2024-04-17 at 9 46 33 AM"
src="https://github.com/ossrs/srs/assets/2757043/40cb2eb6-3a6d-4bb7-9b17-51c5fd6d2272">

---------

`TRANS_BY_GPT4`

---------

Co-authored-by: winlin <winlinvip@gmail.com>
2024-07-24 11:20:56 +08:00
Jacob Su
eb788a62ad
HTTP-TS: Support guess_has_av for audio only stream. v6.0.141 (#4063)
## Describe ##
http_remux feature support config `has_audio`, `has_video` &
`guess_has_av` prop.


282d94d7bb/trunk/src/app/srs_app_http_stream.cpp (L630-L632)

Take `http_flv` as example, `srs` can accept both RTMP streams with only
audio, only video or both audio and video streams. It is controlled by
above three properties.

But `guess_has_av` is not implemented by `http_ts`. The problem is that
if I want publish a RTMP stream with audio or video track, the
`has_audio` and `has_video`, which are default true/on, must to be
config to match the RTMP stream, otherwise the `mpegts.js` player can't
play the `http-ts` stream.

## How to reproduce  ##

1. `export SRS_VHOST_HTTP_REMUX_HAS_AUDIO=on; export
SRS_VHOST_HTTP_REMUX_HAS_VIDEO=on; export
SRS_VHOST_HTTP_REMUX_GUESS_HAS_AV=on; ./objs/srs -c
conf/http.ts.live.conf`
2. publish rtmp stream without video: `ffmpeg -re -stream_loop -1 -i
srs/trunk/doc/source.200kbps.768x320.flv -vn -acodec copy -f flv
rtmp://localhost/live/livestream`
3. open chrome browser, open
`http://localhost:8080/players/srs_player.html?schema=http`, go to
`LivePlayer`, input URL: `http://localhost:8080/live/livestream.ts`,
click play.
4. the `http://localhost:8080/live/livestream.ts` can not play.

## Solution ##

Let `http-ts` support `guess_has_av`, `http-flv` already supported. The
`guess_has_av` default value is ture/on, so the `http-ts|flv` can play
any streams with audio, video or both.

---------

Co-authored-by: Winlin <winlinvip@gmail.com>
2024-07-24 11:00:18 +08:00
Marc Olzheim
d50fb1563a
Dockerfile: Consistently use proper ENV syntax using equal sign. v6.0.140 (#4116)
This not only silences a deprecation warning by docker build, but also
makes it consistent as the other ENV statement already uses the new
syntax.

---------

Co-authored-by: winlin <winlinvip@gmail.com>
2024-07-24 10:19:05 +08:00
Winlin
f04e9392fa
Edge: Improve stability for state and fd closing. v5.0.214 v6.0.139 (#4126)
1. Should always stop coroutine before close fd, see #511, #1784
2. When edge forwarder coroutine quit, always set the error code.
3. Do not unpublish if invalid state.

---------

Co-authored-by: Jacob Su <suzp1984@gmail.com>
2024-07-24 10:14:10 +08:00
winlin
8c034e5a13 Always use single thread by default. 2024-07-22 07:02:53 +08:00
Jacob Su
d220bf280e
DASH: Fix time unit error for disposing. v6.0.138 (#4111)
## Cause
dash auto dispose is configured by seconds, but the code compare by
usecond, 1 second = 1,000,000 useconds.

releated to #4097
Bug introduced after #4097 supported Dash auto dispose after a timeout
without media data.

## How to reproduce

1. `./objs/srs -c conf/dash.conf`
2. publish a rtmp stream.
3. play dash stream. -> no dash stream, always 404 error.

---------

Co-authored-by: winlin <winlinvip@gmail.com>
2024-07-13 16:14:33 +08:00
Jacob Su
f1d98b9830
HTTPS: Support config key/cert for HTTPS API. v6.0.137 (#4028)
Co-authored-by: winlin <winlinvip@gmail.com>
2024-07-09 15:43:02 +08:00
Winlin
23d2602c34
UniquePtr: Support SrsUniquePtr to replace SrsAutoFree. v6.0.136 (#4109)
To manage an object:

```cpp
// Before
MyClass* ptr = new MyClass();
SrsAutoFree(MyClass, ptr);
ptr->do_something();

// Now
SrsUniquePtr<MyClass> ptr(new MyClass());
ptr->do_something();
```

To manage an array of objects:

```cpp
// Before
char* ptr = new char[10];
SrsAutoFreeA(char, ptr);
ptr[0] = 0xf;

// Now
SrsUniquePtr<char[]> ptr(new char[10]);
ptr[0] = 0xf;
```

In fact, SrsUniquePtr is a limited subset of SrsAutoFree, mainly
managing pointers and arrays. SrsUniquePtr is better than SrsAutoFree
because it has the same API to standard unique ptr.

```cpp
SrsUniquePtr<MyClass> ptr(new MyClass());
ptr->do_something();
MyClass* p = ptr.get();
```

SrsAutoFree actually uses a pointer to a pointer, so it can be set to
NULL, allowing the pointer's value to be changed later (this usage is
different from SrsUniquePtr).

```cpp
// OK to free ptr correctly.
MyClass* ptr;
SrsAutoFree(MyClass, ptr);
ptr = new MyClass();

// Crash because ptr is an invalid pointer.
MyClass* ptr;
SrsUniquePtr<MyClass> ptr(ptr);
ptr = new MyClass();
```

Additionally, SrsAutoFreeH can use specific release functions, which
SrsUniquePtr does not support.

---------

Co-authored-by: Jacob Su <suzp1984@gmail.com>
2024-07-09 10:29:36 +08:00
Jacob Su
baf22d01c1
Refine config directive token parsing. v6.0.135 (#4042)
make sure one directive token don't span more than two lines.

try to fix #2228

---------

Co-authored-by: winlin <winlinvip@gmail.com>
2024-07-08 18:19:25 +08:00
Winlin
20c8e6423b
SmartPtr: Fix SRT source memory leaking. v6.0.134 (#4106)
---------

Co-authored-by: john <hondaxiao@tencent.com>
2024-07-04 16:08:42 +08:00
Jacob Su
75ddd8f5b6
Fix misspelling error in app config. v6.0.133 (#4077)
1. misspelling fix;
2. remove finished TODO;

---------

Co-authored-by: Haibo Chen <495810242@qq.com>
2024-06-29 11:18:26 +08:00
Winlin
7ab012c60f
SmartPtr: Support detect memory leak by valgrind. v6.0.132 (#4102)
1. Support detect memory leak by valgrind.
2. Free the http handler entry.
3. Free the stack of ST.

---

Co-authored-by: Jacob Su <suzp1984@gmail.com>
2024-06-29 11:16:32 +08:00
Jacob Su
ea7e2c2849
Fix security scan problems. v6.0.131 (#4100)
1. fix redundant null check, there is no potential risks by the way,
just redundant null check.
2. Potential use pointer after free, that's not true. So we can ignore
this one, or find a way to make stupid security tool happy.

---------

Co-authored-by: winlin <winlinvip@gmail.com>
2024-06-21 15:59:15 +08:00
Winlin
1f9309ae25
SmartPtr: Support load test for source by srs-bench. v6.0.130 (#4097)
1. Add live benchmark support in srs-bench, which only connects and
disconnects without any media transport, to test source creation and
disposal and verify source memory leaks.
2. SmartPtr: Support cleanup of HTTP-FLV stream. Unregister the HTTP-FLV
handler for the pattern and clean up the objects and resources.
3. Support benchmarking RTMP/SRT with srs-bench by integrating the gosrt
and oryx RTMP libraries.
4. Refine SRT and RTC sources by using a timer to clean up the sources,
following the same strategy as the Live source.

---------

Co-authored-by: Haibo Chen <495810242@qq.com>
Co-authored-by: Jacob Su <suzp1984@gmail.com>
2024-06-21 07:13:12 +08:00
winlin
e3d74fb045 Release v5.0-r3 and v6.0-d5. 2024-06-15 17:33:45 +08:00
Winlin
e7069788e9
SmartPtr: Support shared ptr for live source. v6.0.129 (#4089)
Detail change log:

1. [Simple,Refactor] Remove member fields of http entry, etc.
e34b3d3aa4
2. [Ignore] Rename source to live_source.
846f95ec96
3. [Ignore] Use directly ptr in consumer.
d38af021ad
4. [Complex, Important] Use shared ptr for live source.
88f922413a

The object relationship:

![live-source](https://github.com/ossrs/srs/assets/2777660/1adb59af-6e7a-40f3-9a4a-1cc849d7dae1)

---

Co-authored-by: Jacob Su <suzp1984@gmail.com>
2024-06-15 07:54:56 +08:00
Jacob Su
908c2f2a30
Fix hevc test failures (#4087)
Try to fix two blackbox test:
1. TestSlow_SrtPublish_HttpTsPlay_HEVC_Basic: fixed by enlarge the wait
time from 3 seconds to 4 before run ffprobe task, which will record the
stream by ffmpeg first.
2 TestSlow_SrtPublish_HlsPlay_HEVC_Basic: fixed by wait 16 seconds
before run ffprobe task.
About the 2 case: it seems ridiculous to add 16 seconds delay before run
ffprobe task.

> So, I start #4088 to check the github action workflow process, I start
this branch from a very earlier version `6.0.113
(srs/core/srs_core_version6.hpp)`, what I found it that, inside `SRS
blackbox-test`, the srs version `6.0.128`, the latest version, was
printed. That's really wired.

I confirmed this is not the SRS source code's problem, check
https://github.com/suzp1984/srs/actions/runs/9511600525/job/26218025559
the srs code 6.0.113 was checkout and running actions based on them,
still met same problem.

---------

Co-authored-by: winlin <winlinvip@gmail.com>
2024-06-14 18:56:07 +08:00
Winlin
9dba99a1cc
SmartPtr: Support shared ptr for RTC source. v6.0.128 (#4085)
---------

Co-authored-by: Haibo Chen <495810242@qq.com>
2024-06-14 08:07:26 +08:00
Winlin
242152bd6b
SmartPtr: Use shared ptr in RTC TCP connection. v6.0.127 (#4083)
Fix issue https://github.com/ossrs/srs/issues/3784

---

Co-authored-by: Jacob Su <suzp1984@gmail.com>
2024-06-13 16:04:31 +08:00
Winlin
7b9c52b283
SmartPtr: Support shared ptr for SRT source. (#4084)
---

Co-authored-by: Haibo Chen <495810242@qq.com>
2024-06-13 14:44:09 +08:00
Winlin
6834ec208d
SmartPtr: Use shared ptr to manage GB objects. v6.0.126 (#4080)
The object relations: 

![gb](https://github.com/ossrs/srs/assets/2777660/266e8a4e-3f1e-4805-8406-9008d6a63aa0)

Session manages SIP and Media object using shared resource or shared
ptr. Note that I actually use SrsExecutorCoroutine to delete the object
when each coroutine is done, because there is always a dedicate
coroutine for each object.

For SIP and Media object, they directly use the session by raw pointer,
it's safe because session always live longer than session and media
object.

---

Co-authored-by: Jacob Su <suzp1984@gmail.com>
2024-06-12 22:40:20 +08:00
Jacob Su
1656391c67
RTC: Support dropping h.264 SEI from NALUs. v5.0.213 v6.0.125 (#4057)
try to fix #4052.

---------

Co-authored-by: winlin <winlinvip@gmail.com>
2024-06-03 16:25:49 +08:00
johzzy
282d94d7bb
HEVC: Fix duplicated error code 4054 and 4055. (#4044)
Correct SRS_ERRNO_MAP_HTTP duplicate error code 4054 and 4055.

---------

Co-authored-by: winlin <winlinvip@gmail.com>
2024-04-26 07:53:01 +08:00
Winlin
37f0faae5a
RTMP: Do not response publish start message if hooks fail. v5.0.212 v6.0.123 (#4038)
Fix #4037 SRS should not send the publish start message
`onStatus(NetStream.Publish.Start)` if hooks fail, which causes OBS to
repeatedly reconnect.

Note that this fix does not send an RTMP error message when publishing
fails, because neither OBS nor FFmpeg process this specific error
message; they only display a general error.

Apart from the order of messages, nothing else has been changed.
Previously, we sent the publish start message
`onStatus(NetStream.Publish.Start)` before the HTTP hook `on_publish`;
now, we have modified it to send this message after the HTTP hook.
2024-04-23 15:21:36 +08:00
Jacob Su
5eb802daca
Support x509 certification chiain in single pem file. v5.0.211 v6.0.122 (#4033)
Fix #3967 There is an API `SSL_use_certificate_chain_file`, which can load the
certification chain and also single certificate.

---------

Co-authored-by: winlin <winlinvip@gmail.com>
2024-04-22 10:15:11 +08:00
winlin
427104f1da Release v5.0-r2, 5.0 release2, v5.0.210, 163515 lines. 2024-04-03 15:06:20 +08:00
Winlin
244ce7bc01
Merge pull request from GHSA-gv9r-qcjc-5hj7
* Filter JSONP callback function name. v5.0.210,v6.0.121

* Add utest.

* Refine utest
2024-03-26 19:30:52 +08:00
Jacob Su
08971e5905
Build: Refine workflow for cygwin and remove scorecard. v6.0.120 (#3995)
#3983 already fixed the `test` workflow, but I think the `release` will
have same issue.

---------

Co-authored-by: winlin <winlinvip@gmail.com>
2024-03-26 16:37:33 +08:00
Jacob Su
2199fd2b88
Build: Fix module failed for main_ingest_hls and mp4_parser. v6.0.119 (#4005)
1. fix src/main/srs_main_ingest_hls.cpp compiling error;
2. fix src/main/srs_main_mp4_parser.cpp compiling error;
3. remove empty target srs_ingest_hls;

---------

Co-authored-by: winlin <winlinvip@gmail.com>
2024-03-26 16:26:12 +08:00
Winlin
ff91757a3a
ST: Research adds examples that demos pthread and helloworld. v6.0.118 (#3989)
1. `trunk/research/st/exceptions.cpp` About exceptions with ST, works
well on linux and mac, not work on cygwin.
2. `trunk/research/st/pthreads.cpp` About pthreads with ST, works well
on all platforms.
3. `trunk/research/st/hello.cpp` Hello world, without ST, works well on
all platforms.
4. `trunk/research/st/hello-world.cpp` Hello world, with ST, works well
on all platforms.
5. `trunk/research/st/hello-st.cpp` A very simple version for hello
world with ST, works well on all platforms.
2024-03-24 09:28:46 +08:00
Winlin
ce2ce1542f
Add a TCP proxy for debugging. v6.0.117 (#3958)
When debugging the RTMP protocol, we can capture packets using tcpdump
and then replay the pcap file. For example:

```bash
cd ~/git/srs/trunk/3rdparty/srs-bench/pcap
tcpdump -i any -w t.pcap tcp port 1935
go run . -f ./t.pcap -s 127.0.0.1:1935
```

However, sometimes due to poor network conditions between the server and
the client, there may be many retransmitted packets. In such cases,
setting up a transparent TCP proxy that listens on port 1935 and
forwards to port 19350 can be a solution:

```bash
./objs/srs -c conf/origin.conf 
cd 3rdparty/srs-bench/tcpproxy/ && go run main.go
tcpdump -i any -w t.pcap tcp port 19350
```

This approach allows for the implementation of packet dumping,
multipoint replication, or the provision of detailed timestamps and byte
information at the proxy. It enables the collection of debugging
information without the need to modify the server.



---------

`TRANS_BY_GPT4`

---------

Co-authored-by: john <hondaxiao@tencent.com>
2024-03-19 21:10:10 +08:00
Winlin
26f4ab9923
WebRTC: Add support for A/V only WHEP/WHEP player. v6.0.116 (#3964)
---------

Co-authored-by: john <hondaxiao@tencent.com>
2024-03-19 21:08:03 +08:00
Winlin
84b184dd53
System: Disable feature that obtains versions and check features status. v5.0.209 v6.0.115 (#3990)
See https://github.com/ossrs/srs/issues/2424

---------

Co-authored-by: john <hondaxiao@tencent.com>
2024-03-19 19:12:41 +08:00
Jacob Su
954b1b7ef2
Typo: Fix some typos for #3973 #3976 #3982. v6.0.114 (#3973) 2024-03-18 10:17:00 +08:00
Winlin
7209b73660
WHIP: Fix bug for converting WHIP to RTMP/HLS. v5.0.208 v6.0.113 (#3920)
1. When converting RTC to RTMP, it is necessary to synchronize the audio
and video timestamps. When the synchronization status changes, whether
it is unsynchronized or synchronized, print logs to facilitate
troubleshooting of such issues.
2. Chrome uses the STAP-A packet, which means a single RTP packet
contains SPS/PPS information. OBS WHIP, on the other hand, sends SPS and
PPS in separate RTP packets. Therefore, SPS and PPS are in two
independent RTP packets, and SRS needs to cache these two packets.

---------

Co-authored-by: john <hondaxiao@tencent.com>
2024-02-06 14:06:34 +08:00
Winlin
22c2469414
Upgrade hls.js and set in low latency mode. v6.0.112 (#3924)
HLS typically has a delay of around 30 seconds, roughly comprising three
segments, each lasting 10 seconds. We can reduce the delay to about 5
seconds by lowering the segment duration to 2 seconds and starting
playback from the last segment, achieving a stable delay.

Of course, this requires setting the OBS's GOP to 1 second, and the
profile to baseline, preset to fast, and tune to zerolatency.
Additionally, updating a few configurations in the hls.js player is
necessary, such as setting it to start playback from the last segment,
setting the maximum buffer, and initiating accelerated playback to
reduce latency.

---------

Co-authored-by: chundonglinlin <chundonglinlin@163.com>
Co-authored-by: john <hondaxiao@tencent.com>
2024-02-05 21:37:29 +08:00
Jay
4ca7684e36
RTC: Fix video and audio track pt_ is not change in player before publisher. v5.0.207 v6.0.111 (#3925)
For WebRTC:
when player before publisher, it will happen track pt didn't change.

 - At source change step, change track pt 

---------

Co-authored-by: mingche.tsai <w41203208.work@gmail.com>
Co-authored-by: john <hondaxiao@tencent.com>
2024-02-05 15:15:06 +08:00
john
77af3dc8c4
Configure: print enabled/disable sanitizer. v5.0.206 v6.0.110 (#3923)
---------

Co-authored-by: chundonglinlin <chundonglinlin@163.com>
2024-02-05 12:14:22 +08:00
winlin
2a2da2253f Switch to 2013-2024. v6.0.109 2024-01-01 10:51:24 +08:00
Haibo Chen
8f70206a3b
Enhancing the compatibility of options.sh. v5.0.204 v6.0.108 (#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>
2023-12-30 09:08:41 +08:00
chundonglinlin
804ef3f98c
Forward: when unpublish crash caused by uninitialized forward connection. v6.0.107 (#3914)
Description
A crash occurs when a forward relay connection has not been established
and an unpublish event is triggered simultaneously. For instance, if DVR
and forward are configured with a specified DVR path that already
exists, initiating a stream will trigger a crash.

Objective
Fix the crash caused by the forward mechanism.

Additional Information
For detailed reproduction steps, please refer to issue #3901.

---------

Co-authored-by: john <hondaxiao@tencent.com>
2023-12-30 09:05:55 +08:00
winlin
360aaaf9e4 Fix version bug. 2023-12-30 09:04:38 +08:00
Winlin
1b99fcbe79
A demo for SRT proxy. (#3869)
See https://www.figma.com/file/kItb5HWOI4HimjDp62pas3/SRT-Proxy
2023-12-30 08:55:01 +08:00
Laurentiu
2f95f2ae6a
Typo: line 263 - srs_app_srt_conn.cpp. v6.0.106 (#3854)
regards,
laur
---------

Co-authored-by: john <hondaxiao@tencent.com>
Co-authored-by: Haibo Chen <495810242@qq.com>
2023-12-15 23:13:16 +08:00
john
15601b4b2a
RTC: Support OPUS stereo SDP option. v5.0.203 v6.0.105 (#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`
2023-12-14 23:29:22 +08:00
Haibo Chen
6d56c407c6
Security: Support IP whitelist for HTTP-FLV, HLS, WebRTC, and SRT. v5.0.202 v6.0.104 (#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>
2023-12-14 21:36:06 +08:00
Haibo Chen
1b34fc4d4e
fix 'sed' error in options.sh. v5.0.201 v6.0.103 (#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>
2023-11-23 13:29:49 +08:00
john
3e463a8e56
Fix opus delay options, use ffmpeg-opus in docker test. v6.0.102 (#3883)
The `ffmpeg-opus` tool allows you to control the delay using the
`opus_delay` option. The minimum delay can be set to 2.5ms. However, in
practice, you cannot set it this low. You need to set at least 10 frames
to allow the audio encoder to lookahead. Otherwise, the sound will be
distorted.

---------

Co-authored-by: chundonglinlin <chundonglinlin@163.com>
2023-11-22 14:58:30 +08:00
Winlin
8865ddd4bb
Change the hls_aof_ratio to 2.1. v5.0.200 v6.0.101 (#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>
2023-11-19 21:50:11 +08:00