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.31k stars 5.33k forks source link

WebRTC: Support datachannel for text messages like chat room. #1815

Open winlinvip opened 4 years ago

winlinvip commented 4 years ago

PullRequest for SRS, #1809.

winlinvip commented 4 years ago

DataChannel example here.

Offer:

type: offer, sdp: v=0
o=- 5739606220282787625 2 IN IP4 127.0.0.1
s=-
t=0 0
a=group:BUNDLE 0
a=msid-semantic: WMS
m=application 9 UDP/DTLS/SCTP webrtc-datachannel
c=IN IP4 0.0.0.0
a=ice-ufrag:KN1R
a=ice-pwd:CwE/ajFG6xCFcYTuJXueC7y/
a=ice-options:trickle
a=fingerprint:sha-256 A6:5F:AF:18:11:5F:94:62:50:AB:D2:BB:1D:B3:98:F0:75:ED:CA:47:81:07:30:70:65:6B:D2:47:64:E8:2A:85
a=setup:actpass
a=mid:0
a=sctp-port:5000
a=max-message-size:262144

Answer:

type: answer, sdp: v=0
o=- 2162873500730598858 2 IN IP4 127.0.0.1
s=-
t=0 0
a=group:BUNDLE 0
a=msid-semantic: WMS
m=application 9 UDP/DTLS/SCTP webrtc-datachannel
c=IN IP4 0.0.0.0
b=AS:30
a=ice-ufrag:nRJo
a=ice-pwd:uSFhYgl3S1iB7VowZe1RLP73
a=ice-options:trickle
a=fingerprint:sha-256 C7:63:62:FC:24:5C:59:A2:F1:9E:20:DA:74:5D:4D:77:DA:65:2E:01:70:52:35:6C:DC:97:29:D2:E1:09:B8:7A
a=setup:active
a=mid:0
a=sctp-port:5000
a=max-message-size:262144
winlinvip commented 4 years ago

The SCTP library by default will open a thread, while SRS requires single-threaded execution, as multiple threads can cause issues.

SCTP transformed into single-threaded: link

TRANS_BY_GPT3

winlinvip commented 4 years ago

SRS supports DataChannel

Offer by Chrome:

type: offer, sdp: v=0
o=- 7473280969704313077 2 IN IP4 127.0.0.1
s=-
t=0 0
a=group:BUNDLE 0
a=msid-semantic: WMS
m=application 9 UDP/DTLS/SCTP webrtc-datachannel
c=IN IP4 0.0.0.0
a=ice-ufrag:vm7d
a=ice-pwd:1E2x7iHPPIYiCBM8mRZvIAw9
a=ice-options:trickle
a=fingerprint:sha-256 4F:9F:6A:76:6C:6D:D2:CD:21:2E:1B:9F:02:19:68:6C:6C:EF:9B:0F:E3:4C:15:BA:6A:8C:D1:CA:B3:FD:CB:F0
a=setup:actpass
a=mid:0
a=sctp-port:5000
a=max-message-size:262144

Answer by SRS:

type: answer, sdp: v=0
o=SRS/4.0.30(Leo) 140512764909008 2 IN IP4 0.0.0.0
s=SRSDataSession
t=0 0
a=ice-lite
a=group:BUNDLE 0
a=msid-semantic: WMS live/livestream
m=application 9 UDP/DTLS/SCTP webrtc-datachannel
c=IN IP4 0.0.0.0
a=ice-ufrag:uU9daqy6
a=ice-pwd:hsMWKfjnYPGTuROBoFwBn8NpMvjtW28d
a=fingerprint:sha-256 A7:E3:02:45:5C:93:4F:19:0C:95:30:4D:CB:E4:23:73:7F:A1:24:CA:7F:F2:D0:38:CB:35:2C:47:27:80:AF:04
a=setup:passive
a=mid:0
a=rtcp-mux
a=rtcp-rsize
a=candidate:0 1 udp 2130706431 30.225.52.25 8000 typ host generation 0

TRANS_BY_GPT3

winlinvip commented 3 years ago

Please wait a moment, QUIC is coming soon.

TRANS_BY_GPT3