@@ -9,7 +9,7 @@ import {addExtmap, addPayloadTypes, addSsrc} from './P2PSdpBuilder';
9
9
10
10
export class ChromeP2PSdpBuilder {
11
11
static generateOffer ( info ) {
12
- const { sessionId, fingerprints, media } = info ;
12
+ const { sessionId, fingerprints, ufrag , pwd , media } = info ;
13
13
14
14
let sdp = `v=0
15
15
o=- ${ sessionId } 2 IN IP4 127.0.0.1
@@ -23,6 +23,11 @@ a=fingerprint:${hash} ${fingerprint}
23
23
a=setup:${ setup } ` ;
24
24
} ) ;
25
25
}
26
+ if ( ufrag && pwd ) {
27
+ sdp += `
28
+ a=ice-ufrag:${ ufrag }
29
+ a=ice-pwd:${ pwd } ` ;
30
+ }
26
31
27
32
sdp += `
28
33
a=group:BUNDLE ${ media . map ( x => x . mid ) . join ( ' ' ) }
@@ -38,8 +43,6 @@ a=msid-semantic: WMS *`;
38
43
sdp += `
39
44
m=application 9 UDP/DTLS/SCTP webrtc-datachannel
40
45
c=IN IP4 0.0.0.0
41
- a=ice-ufrag:${ ufrag }
42
- a=ice-pwd:${ pwd }
43
46
a=ice-options:trickle
44
47
a=mid:${ mid }
45
48
a=sctp-port:${ port }
@@ -51,8 +54,6 @@ a=max-message-size:${maxSize}`;
51
54
m=audio 56930 UDP/TLS/RTP/SAVPF ${ types . map ( x => x . id ) . join ( ' ' ) }
52
55
c=IN IP4 0.0.0.0
53
56
a=rtcp:9 IN IP4 0.0.0.0
54
- a=ice-ufrag:${ ufrag }
55
- a=ice-pwd:${ pwd }
56
57
a=ice-options:trickle
57
58
a=mid:${ mid } ` ;
58
59
sdp += addExtmap ( extmap ) ;
@@ -76,8 +77,6 @@ a=rtcp-mux`;
76
77
m=video 61986 UDP/TLS/RTP/SAVPF ${ types . map ( x => x . id ) . join ( ' ' ) }
77
78
c=IN IP4 0.0.0.0
78
79
a=rtcp:9 IN IP4 0.0.0.0
79
- a=ice-ufrag:${ ufrag }
80
- a=ice-pwd:${ pwd }
81
80
a=ice-options:trickle
82
81
a=mid:${ mid } ` ;
83
82
sdp += addExtmap ( extmap ) ;
@@ -105,7 +104,7 @@ a=rtcp-rsize`;
105
104
}
106
105
107
106
static generateAnswer ( info ) {
108
- const { sessionId, fingerprints, media } = info ;
107
+ const { sessionId, fingerprints, ufrag , pwd , media } = info ;
109
108
110
109
let sdp = `v=0
111
110
o=- ${ sessionId } 2 IN IP4 127.0.0.1
@@ -119,6 +118,12 @@ a=fingerprint:${hash} ${fingerprint}
119
118
a=setup:${ setup } ` ;
120
119
} ) ;
121
120
}
121
+ if ( ufrag && pwd ) {
122
+ sdp += `
123
+ a=ice-ufrag:${ ufrag }
124
+ a=ice-pwd:${ pwd } ` ;
125
+ }
126
+
122
127
sdp += `
123
128
a=group:BUNDLE ${ media . map ( x => x . mid ) . join ( ' ' ) }
124
129
a=extmap-allow-mixed
@@ -133,8 +138,6 @@ a=msid-semantic: WMS *`;
133
138
sdp += `
134
139
m=application 9 UDP/DTLS/SCTP webrtc-datachannel
135
140
c=IN IP4 0.0.0.0
136
- a=ice-ufrag:${ ufrag }
137
- a=ice-pwd:${ pwd }
138
141
a=ice-options:trickle
139
142
a=mid:${ mid }
140
143
a=sctp-port:${ port }
@@ -146,8 +149,6 @@ a=max-message-size:${maxSize}`;
146
149
m=audio 56930 UDP/TLS/RTP/SAVPF ${ types . map ( x => x . id ) . join ( ' ' ) }
147
150
c=IN IP4 0.0.0.0
148
151
a=rtcp:9 IN IP4 0.0.0.0
149
- a=ice-ufrag:${ ufrag }
150
- a=ice-pwd:${ pwd }
151
152
a=ice-options:trickle
152
153
a=mid:${ mid } ` ;
153
154
sdp += addExtmap ( extmap ) ;
@@ -170,8 +171,6 @@ a=rtcp-mux`;
170
171
m=video 61986 UDP/TLS/RTP/SAVPF ${ types . map ( x => x . id ) . join ( ' ' ) }
171
172
c=IN IP4 0.0.0.0
172
173
a=rtcp:9 IN IP4 0.0.0.0
173
- a=ice-ufrag:${ ufrag }
174
- a=ice-pwd:${ pwd }
175
174
a=ice-options:trickle
176
175
a=mid:${ mid } ` ;
177
176
sdp += addExtmap ( extmap ) ;
0 commit comments