Skip to content

Commit 7207b31

Browse files
author
evgeny-nadymov
committed
Add support for data channels at p2p sdp
1 parent bf377e5 commit 7207b31

File tree

4 files changed

+91
-3
lines changed

4 files changed

+91
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"homepage": "https://evgeny-nadymov.github.io/telegram-react",
33
"name": "telegram_react",
4-
"version": "0.0.967",
4+
"version": "0.0.968",
55
"private": true,
66
"dependencies": {
77
"tdweb": "^1.7.2",

src/Calls/P2P/ChromeP2PSdpBuilder.js

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,27 @@ a=fingerprint:${hash} ${fingerprint}`;
2222
sdp += `
2323
a=group:BUNDLE ${media.map(x => x.mid).join(' ')}
2424
a=extmap-allow-mixed
25-
a=msid-semantic: WMS`;
25+
a=msid-semantic: WMS *`;
2626
const streamName = 'stream' + media.map(x => x.ssrc).join('_');
2727
for (let i = 0; i < media.length; i++) {
2828
const m = media[i];
2929
const { type, ssrc, ssrcGroup, types, ufrag, pwd, hash, fingerprint, setup, dir, mid, extmap } = m;
3030
switch (type) {
31+
case 'application': {
32+
const { port, maxSize } = m;
33+
sdp += `
34+
m=application 9 UDP/DTLS/SCTP webrtc-datachannel
35+
c=IN IP4 0.0.0.0
36+
a=ice-ufrag:${ufrag}
37+
a=ice-pwd:${pwd}
38+
a=ice-options:trickle
39+
a=fingerprint:${hash} ${fingerprint}
40+
a=setup:${setup}
41+
a=mid:${mid}
42+
a=sctp-port:${port}
43+
a=max-message-size:${maxSize}`;
44+
break;
45+
}
3146
case 'audio': {
3247
sdp += `
3348
m=audio 56930 UDP/TLS/RTP/SAVPF ${types.map(x => x.id).join(' ')}
@@ -104,12 +119,27 @@ a=fingerprint:${hash} ${fingerprint}`;
104119
sdp += `
105120
a=group:BUNDLE ${media.map(x => x.mid).join(' ')}
106121
a=extmap-allow-mixed
107-
a=msid-semantic: WMS`;
122+
a=msid-semantic: WMS *`;
108123
const streamName = 'stream' + media.map(x => x.ssrc).join('_');
109124
for (let i = 0; i < media.length; i++) {
110125
const m = media[i];
111126
const { type, mid, ssrc, ssrcGroup, types, ufrag, pwd, hash, fingerprint, setup, dir, extmap } = m;
112127
switch (type) {
128+
case 'application': {
129+
const { port, maxSize } = m;
130+
sdp += `
131+
m=application 9 UDP/DTLS/SCTP webrtc-datachannel
132+
c=IN IP4 0.0.0.0
133+
a=ice-ufrag:${ufrag}
134+
a=ice-pwd:${pwd}
135+
a=ice-options:trickle
136+
a=fingerprint:${hash} ${fingerprint}
137+
a=setup:${setup}
138+
a=mid:${mid}
139+
a=sctp-port:${port}
140+
a=max-message-size:${maxSize}`;
141+
break;
142+
}
113143
case 'audio': {
114144
sdp += `
115145
m=audio 56930 UDP/TLS/RTP/SAVPF ${types.map(x => x.id).join(' ')}

src/Calls/P2P/FirefoxP2PSdpBuilder.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,20 @@ a=msid-semantic:WMS *`;
2727
const m = media[i];
2828
const { type, mid, ssrc, ssrcGroup, types, ufrag, pwd, hash, fingerprint, setup, dir, extmap } = m;
2929
switch (type) {
30+
case 'application': {
31+
const { port, maxSize } = m;
32+
sdp += `
33+
m=application 9 UDP/DTLS/SCTP webrtc-datachannel
34+
c=IN IP4 0.0.0.0
35+
a=ice-ufrag:${ufrag}
36+
a=ice-pwd:${pwd}
37+
a=ice-options:trickle
38+
a=setup:${setup}
39+
a=mid:${mid}
40+
a=sctp-port:${port}
41+
a=max-message-size:${maxSize}`;
42+
break;
43+
}
3044
case 'audio': {
3145
sdp += `
3246
m=audio 9 UDP/TLS/RTP/SAVPF ${types.map(x => x.id).join(' ')}
@@ -95,6 +109,20 @@ a=msid-semantic:WMS *`;
95109
const m = media[i];
96110
const { type, mid, ssrc, ssrcGroup, types, ufrag, pwd, hash, fingerprint, setup, dir, extmap } = m;
97111
switch (type) {
112+
case 'application': {
113+
const { port, maxSize } = m;
114+
sdp += `
115+
m=application 9 UDP/DTLS/SCTP webrtc-datachannel
116+
c=IN IP4 0.0.0.0
117+
a=ice-ufrag:${ufrag}
118+
a=ice-pwd:${pwd}
119+
a=ice-options:trickle
120+
a=setup:${setup}
121+
a=mid:${mid}
122+
a=sctp-port:${port}
123+
a=max-message-size:${maxSize}`;
124+
break;
125+
}
98126
case 'audio': {
99127
sdp += `
100128
m=audio 9 UDP/TLS/RTP/SAVPF ${types.map(x => x.id).join(' ')}

src/Calls/P2P/SafariP2PSdpBuilder.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,21 @@ a=msid-semantic: WMS *`;
3636
const m = media[i];
3737
const { type, ssrc, ssrcGroup, types, ufrag, pwd, hash, fingerprint, setup, dir, mid, extmap } = m;
3838
switch (type) {
39+
case 'application': {
40+
const { port, maxSize } = m;
41+
sdp += `
42+
m=application 9 UDP/DTLS/SCTP webrtc-datachannel
43+
c=IN IP4 0.0.0.0
44+
a=ice-ufrag:${ufrag}
45+
a=ice-pwd:${pwd}
46+
a=ice-options:trickle
47+
a=fingerprint:${hash} ${fingerprint}
48+
a=setup:${setup}
49+
a=mid:${mid}
50+
a=sctp-port:${port}
51+
a=max-message-size:${maxSize}`;
52+
break;
53+
}
3954
case 'audio': {
4055
sdp += `
4156
m=audio 9 UDP/TLS/RTP/SAVPF ${types.map(x => x.id).join(' ')}
@@ -127,6 +142,21 @@ a=msid-semantic: WMS *`;
127142
const m = media[i];
128143
const { type, ssrc, ssrcGroup, types, ufrag, pwd, hash, fingerprint, setup, dir, mid, extmap } = m;
129144
switch (type) {
145+
case 'application': {
146+
const { port, maxSize } = m;
147+
sdp += `
148+
m=application 9 UDP/DTLS/SCTP webrtc-datachannel
149+
c=IN IP4 0.0.0.0
150+
a=ice-ufrag:${ufrag}
151+
a=ice-pwd:${pwd}
152+
a=ice-options:trickle
153+
a=fingerprint:${hash} ${fingerprint}
154+
a=setup:${setup}
155+
a=mid:${mid}
156+
a=sctp-port:${port}
157+
a=max-message-size:${maxSize}`;
158+
break;
159+
}
130160
case 'audio': {
131161
sdp += `
132162
m=audio 9 UDP/TLS/RTP/SAVPF ${types.map(x => x.id).join(' ')}

0 commit comments

Comments
 (0)