ossrs / srs

SRS is a simple, high-efficiency, real-time media server supporting RTMP, WebRTC, HLS, HTTP-FLV, HTTP-TS, SRT, MPEG-DASH, and GB28181.
https://ossrs.io
MIT License
25.91k stars 5.4k forks source link

WebRTC: Support WHIP(WebRTC-HTTP ingestion protocol) #3170

Closed winlinvip closed 2 years ago

winlinvip commented 2 years ago

RFC: https://datatracker.ietf.org/doc/draft-ietf-wish-whip/

Usage

Start SRS SRS 6.0.36+ or SRS 5.0.148+, there is a WHIP and WHEP client in srs-player:

./objs/srs -c conf/rtc.conf

Then open WHIP and click Publish button.

Finally, open WHEP and click Play button.

OBS-WHIP

See https://github.com/ossrs/srs/pull/3581 and Experience Ultra-Low Latency Live Streaming with OBS WHIP!

Larix

Larix Broadcaster Apps and SDKs for capturing and streaming from mobile devices.

Please use SRS 6.0.36+ or SRS 5.0.148+.

Add a connection in Larix:

  1. Settings > Connections > New WebRTC connection
  2. URL: http://your-ip:1985/rtc/v1/whip/?app=live&stream=livestream

Click the publish button.

whip-go

whip-go is a simple WHIP client implementation in go using the WebRTC Pion libraries. It includes a WHIPClient class and a simple command line client supporrting screensharing to a WHIP ingestion endpoint.

First, clone code and build it, by Go 1.20+:

git clone https://github.com/ggarber/whip-go.git
cd whip-go
go build .

Run with:

./whip-go -v screen -vc h264 'http://localhost:1985/rtc/v1/whip/?app=live&stream=livestream'

Note that it requires:

It works with SRS WHIP.

Protocol

The endpoint of SRS for WHIP:

HTTP POST http://localhost:1985/rtc/v1/whip/?app=live&stream=livestream
Content-Type: application/sdp
Body: SDP offer.

Query string:

Note: Please read rtmp-url for detail.

The response of WHIP:

Content-Type: application/sdp
Body: SDP answer.

There is an example of WHIP publish:

whip-publish.pcapng.zip

The snapshot for request:

image

The snapshot for response:

image

SDP offer

v=0
o=- 8155286585472813923 1679356492 IN IP4 0.0.0.0
s=-
t=0 0
a=fingerprint:sha-256 70:C7:51:C8:37:57:54:F0:2A:4A:A8:B5:78:59:55:8E:DC:E8:60:4E:81:ED:6F:BA:D0:C8:4B:40:FA:11:7C:CC
a=ice-lite
a=extmap-allow-mixed
a=group:BUNDLE 0 1

m=video 9 UDP/TLS/RTP/SAVPF 97 98
c=IN IP4 0.0.0.0
a=setup:actpass
a=mid:0
a=ice-ufrag:gvJoSLvvsgHgCAnj
a=ice-pwd:PoDmihiESWHpaBeyieudWrIoOEtywnqZ
a=rtcp-mux
a=rtcp-rsize
a=rtpmap:97 H264/90000
a=fmtp:97 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=640032
a=rtcp-fb:97 nack 
a=rtcp-fb:97 nack pli
a=rtcp-fb:97 transport-cc 
a=rtpmap:98 H264/90000
a=fmtp:98 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42001f
a=rtcp-fb:98 nack 
a=rtcp-fb:98 nack pli
a=rtcp-fb:98 transport-cc 
a=extmap:1 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01
a=ssrc:2918296482 cname:Larix
a=ssrc:2918296482 msid:Larix video
a=ssrc:2918296482 mslabel:Larix
a=ssrc:2918296482 label:video
a=msid:Larix video
a=sendonly

m=audio 9 UDP/TLS/RTP/SAVPF 96
c=IN IP4 0.0.0.0
a=setup:actpass
a=mid:1
a=ice-ufrag:gvJoSLvvsgHgCAnj
a=ice-pwd:PoDmihiESWHpaBeyieudWrIoOEtywnqZ
a=rtcp-mux
a=rtcp-rsize
a=rtpmap:96 opus/48000/2
a=rtcp-fb:96 nack 
a=rtcp-fb:96 transport-cc 
a=extmap:1 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01
a=ssrc:881261638 cname:Larix
a=ssrc:881261638 msid:Larix audio
a=ssrc:881261638 mslabel:Larix
a=ssrc:881261638 label:audio
a=msid:Larix audio
a=sendonly

SDP answer

v=0
o=SRS/6.0.35(Bee) 107408542208384 2 IN IP4 0.0.0.0
s=SRSPublishSession
t=0 0
a=ice-lite
a=group:BUNDLE 0 1
a=msid-semantic: WMS live/livestream

m=video 9 UDP/TLS/RTP/SAVPF 97
c=IN IP4 0.0.0.0
a=ice-ufrag:596woj5r
a=ice-pwd:3s0c79x33874iw43b1tx493y586mg69u
a=fingerprint:sha-256 AB:B1:6D:00:10:66:7B:B6:12:45:83:49:45:70:0A:99:54:03:67:89:A3:9C:83:62:9E:29:3C:2D:1A:CB:4B:3E
a=setup:passive
a=mid:0
a=extmap:1 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01
a=recvonly
a=rtcp-mux
a=rtcp-rsize
a=rtpmap:97 H264/90000
a=rtcp-fb:97 nack
a=rtcp-fb:97 nack pli
a=rtcp-fb:97 transport-cc
a=fmtp:97 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=640032
a=candidate:0 1 udp 2130706431 10.211.55.2 8000 typ host generation 0
a=candidate:1 1 udp 2130706431 10.37.129.2 8000 typ host generation 0
a=candidate:2 1 udp 2130706431 192.168.3.85 8000 typ host generation 0

m=audio 9 UDP/TLS/RTP/SAVPF 96
c=IN IP4 0.0.0.0
a=ice-ufrag:596woj5r
a=ice-pwd:3s0c79x33874iw43b1tx493y586mg69u
a=fingerprint:sha-256 AB:B1:6D:00:10:66:7B:B6:12:45:83:49:45:70:0A:99:54:03:67:89:A3:9C:83:62:9E:29:3C:2D:1A:CB:4B:3E
a=setup:passive
a=mid:1
a=extmap:1 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01
a=recvonly
a=rtcp-mux
a=rtcp-rsize
a=rtpmap:96 opus/48000/2
a=rtcp-fb:96 nack
a=rtcp-fb:96 transport-cc
a=candidate:0 1 udp 2130706431 10.211.55.2 8000 typ host generation 0
a=candidate:1 1 udp 2130706431 10.37.129.2 8000 typ host generation 0
a=candidate:2 1 udp 2130706431 192.168.3.85 8000 typ host generation 0
tyisme614 commented 1 year ago

request http://localhost:1985/rtc/v1/whip/ returns HTTP CODE: 502
version: SRS/5.0.128

is whip still supported on this version? @winlinvip

winlinvip commented 1 year ago

Please see https://github.com/ossrs/srs-unity#usage-publisher