Commit Graph

54 Commits

Author SHA1 Message Date
OSSRS-AI
bfb91f9b82
AI: WebRTC: Support G.711 (PCMU/PCMA) audio codec for WebRTC. v7.0.124 (#4075) (#4568)
This PR adds G.711 (PCMU/PCMA) audio codec support for WebRTC in SRS,
enabling relay-only streaming of G.711 audio between WebRTC clients via
WHIP/WHEP. G.711 is a widely-used, royalty-free audio codec with
excellent compatibility across VoIP systems, IP cameras, and legacy
telephony equipment.

Fixes #4075

Many IP cameras, VoIP systems, and IoT devices use G.711 (PCMU/PCMA) as
their default audio codec. Previously, SRS only supported Opus for
WebRTC audio, requiring transcoding or rejecting G.711 streams entirely.
This PR enables direct relay of G.711 audio streams in WebRTC, similar
to how VP9/AV1 video codecs are supported.

Enhanced WHIP/WHEP players with URL-based codec selection:
```
# Audio codec only
http://localhost:8080/players/whip.html?acodec=pcmu
http://localhost:8080/players/whip.html?acodec=pcma

# Video + audio codecs
http://localhost:8080/players/whip.html?vcodec=vp9&acodec=pcmu
http://localhost:8080/players/whep.html?vcodec=h264&acodec=pcma

# Backward compatible (codec = vcodec)
http://localhost:8080/players/whip.html?codec=vp9
```

Testing

```bash
# Build and run unit tests
cd trunk
make utest -j && ./objs/srs_utest

# Test with WHIP player
# 1. Start SRS server
./objs/srs -c conf/rtc.conf

# 2. Open WHIP publisher with PCMU audio
http://localhost:8080/players/whip.html?acodec=pcmu

# 3. Open WHEP player to receive stream
http://localhost:8080/players/whep.html
```

## Related Issues

- Fixes #4075 - WebRTC G.711A Audio Codec Support
- Related to #4548 - VP9 codec support (similar relay-only pattern)
2025-11-09 12:08:03 -05:00
chundonglinlin
e7b629cd39
RTC: Refine FFmpeg opus audio noisy issue. v5.0.197 v6.0.97 (#3852)
### Description

When converting between AAC and Opus formats (aac2opus or opus2aac), the
`av_frame_get_buffer` API is frequently called.

### Objective

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.

### Additional Note

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>
2023-11-04 16:21:44 +08:00
Winlin
f9bba0a9b0
WebRTC: Support WHEP for play. v5.0.182 v6.0.80 (#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>
2023-09-21 18:41:33 +08:00
chundonglinlin
c0e931ae7a
Replace sprintf with snprintf to eliminate compile warnings. v6.0.45 (#3534)
* Replaced all occurrences of sprintf with snprintf to address deprecation warnings
* Ensured proper buffer size is passed to snprintf to prevent potential buffer overflows
* Ran tests to confirm that the changes do not introduce any new issues or regressions

---------

Co-authored-by: ChenGH <chengh_math@126.com>
2023-05-14 13:04:21 +08:00
Winlin
c001acaae9
Support WHIP and WHEP player. v5.0.147 and v6.0.35 (#3460)
Co-authored-by: chundonglinlin <chundonglinlin@163.com>
Co-authored-by: panda <542638787@qq.com>
2023-03-21 08:49:07 +08:00
CommanderRoot
8a75e8a165
Replace deprecated String.prototype.substr() (#2948)
String.prototype.substr() is deprecated (see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substr) so we replace it with slice() or substring() which work similarily but aren't deprecated.
Signed-off-by: Tobias Speicher <rootcommander@gmail.com>
2022-03-07 08:02:27 +08:00
winlin
93aa0eb5ba Squash: Fix bugs 2022-01-13 18:26:28 +08:00
winlin
0b62216999 SquashSRS4: Support av1 for Chrome M90 enabled it. 2021-04-30 08:13:38 +08:00
winlin
d4a8a72388 SquashSRS4: Add console. Disable cherrypy by default. 2021-04-24 19:45:05 +08:00
winlin
08e19406ef Player: Refine code 2020-11-02 17:21:51 +08:00
winlin
3eeeda6a12 Player: Remove jwplayer and osmf 2020-08-17 16:59:25 +08:00
winlin
cd3c15ec4e Support RTC publisher. 2020-04-25 20:32:37 +08:00
winlin
8d5f91f777 For rtc player, use target to overwrite server, vhost and eip. 2020-04-14 18:15:07 +08:00
winlin
57c23d93c1 Refactor url for rtc player 2020-03-23 13:36:17 +08:00
winlin
c2916acd92 For #1638, #307, define webrtc:// url for play 2020-03-14 22:48:02 +08:00
winlin
12e99f1897 For #1638, #307, use webrtc adapter.js for demo. 2020-03-14 21:14:17 +08:00
winlin
4276bea463 Migrating streaming service from ossrs.net to r.ossrs.net 2020-02-14 22:00:58 +08:00
winlin
23324cde31 Migrating streaming service from ossrs.net to r.ossrs.net 2020-02-14 21:57:02 +08:00
winlin
6eec7c1dfe Refactor the query string for srs-player 2019-12-18 14:46:21 +08:00
winlin
b52628ce01 Refactor the comments to use flash publisher 2019-12-18 14:37:39 +08:00
winlin
dd44d76d72 Refactor the comments to use flash publisher 2019-12-18 14:35:07 +08:00
winlin
901c69b381 Update srs-player version 2019-12-18 11:54:17 +08:00
winlin
b0afc00733 Detect whether flash enabled for srs-player. 3.0.73 2019-12-18 11:06:01 +08:00
winlin
a9b5d65ca7 For #1202, Support auth_key param for srs player 2018-08-12 11:52:18 +08:00
winlin
499fc07db1 refine the hls m3u8 refresh interval. 2016-08-02 16:52:23 +08:00
winlin
5fa500646e update srs player version 2016-08-02 16:37:52 +08:00
winlin
d7a28059ed remove jwplayer and osmf 2016-03-19 22:09:36 +08:00
winlin
d9f1ced732 change srs player to 1.28 2016-03-19 22:00:22 +08:00
winlin
46a31f4884 support play hls 2016-03-19 16:35:13 +08:00
winlin
10ce961a00 update version for bwtc 2016-03-14 10:23:20 +08:00
winlin
fe27e76492 support schema 2015-10-26 18:34:55 +08:00
winlin
b25c45c643 refine srs player, support set the bufferTimeMax. 2015-08-24 07:55:30 +08:00
winlin
018af55d65 refine the demo pages, move scripts after body. 2015-08-20 15:19:43 +08:00
winlin
93a1d097dc update jwplayer to support play HTTP flv. 2015-05-23 19:22:37 +08:00
winlin
6de81fdb1c refine fast id tracer 2014-05-27 19:34:18 +08:00
winlin
5ff1ce7cba for bug #87, response the server SrsId to flash. 2014-05-27 15:34:55 +08:00
winlin
15f651bccd update demo, support acodec 2014-04-11 14:13:14 +08:00
winlin
4e3fe36ae2 refine http server pages. change to 0.9.51 2014-04-05 13:14:59 +08:00
winlin
3c63cf0a86 update demo page, change http port to 8080 2014-04-04 23:09:58 +08:00
winlin
4c8d6d2eb1 fix bug of hls and rename demo player stream to live/demo. change to 0.9.36 2014-03-26 18:13:33 +08:00
winlin
62f1f23991 fix bug of bandwidth test, donot use vhost in query 2013-12-27 18:52:09 +08:00
winlin
7901b481e4 change ui version to 1.19 2013-12-27 18:50:43 +08:00
winlin
19f9342034 refine bandwidth test 2013-12-27 18:49:34 +08:00
winlin
51686b91d2 change ui version to 1.17 2013-12-26 15:41:54 +08:00
winlin
2e58de393a refine the ui of chat, to 5x3+1 2013-12-26 15:41:04 +08:00
winlin
5cec967931 refine the index. refine the parse_query_string, add user_query object to result 2013-12-26 13:31:52 +08:00
winlin
531fa6fb76 change ui version to 1.15, fix the publiser bug, support chrome/firefox/safari/ie browsers. 2013-12-26 08:56:13 +08:00
winlin
7b2f9d59a2 fix bug of identify the truevision camera 2013-12-25 22:18:05 +08:00
winlin
ec5e33f3bc refine the filter of camera and microphone 2013-12-25 22:01:59 +08:00
winlin
b1fe298def change ui version to 1.13 2013-12-25 18:17:44 +08:00