@@ -25,8 +25,7 @@ export function p2pParseCandidate(candidate) {
25
25
component,
26
26
protocol,
27
27
priority,
28
- ip,
29
- port
28
+ address : { ip, port }
30
29
} ;
31
30
32
31
for ( let i = 0 ; i < other . length ; i += 2 ) {
@@ -36,11 +35,19 @@ export function p2pParseCandidate(candidate) {
36
35
break ;
37
36
}
38
37
case 'raddr' : {
39
- c . relAddr = other [ i + 1 ] ;
38
+ if ( ! c . relAddress ) {
39
+ c . relAddress = { } ;
40
+ }
41
+
42
+ c . relAddress . ip = other [ i + 1 ] ;
40
43
break ;
41
44
}
42
45
case 'rport' : {
43
- c . relPort = other [ i + 1 ] ;
46
+ if ( ! c . relAddress ) {
47
+ c . relAddress = { } ;
48
+ }
49
+
50
+ c . relAddress . port = other [ i + 1 ] ;
44
51
break ;
45
52
}
46
53
case 'generation' : {
@@ -186,7 +193,7 @@ export function p2pParseSdp(sdp) {
186
193
for ( let i = 0 ; i < types . length ; i ++ ) {
187
194
const { id } = types [ i ] ;
188
195
if ( rtcpFb . has ( id ) ) {
189
- types [ i ] . feedback = rtcpFb . get ( id ) ;
196
+ types [ i ] . feedbackTypes = rtcpFb . get ( id ) ;
190
197
}
191
198
if ( fmtp . has ( id ) ) {
192
199
types [ i ] . parameters = fmtp . get ( id ) ;
@@ -252,11 +259,11 @@ export function addPayloadTypes(types) {
252
259
253
260
for ( let i = 0 ; i < types . length ; i ++ ) {
254
261
const type = types [ i ] ;
255
- const { id, name, clockrate, channels, feedback , parameters } = type ;
262
+ const { id, name, clockrate, channels, feedbackTypes , parameters } = type ;
256
263
sdp += `
257
264
a=rtpmap:${ id } ${ name } /${ clockrate } ${ channels ? '/' + channels : '' } ` ;
258
- if ( feedback ) {
259
- feedback . forEach ( x => {
265
+ if ( feedbackTypes ) {
266
+ feedbackTypes . forEach ( x => {
260
267
const { type, subtype } = x ;
261
268
sdp += `
262
269
a=rtcp-fb:${ id } ${ [ type , subtype ] . join ( ' ' ) } ` ;
@@ -320,17 +327,15 @@ export class P2PSdpBuilder {
320
327
static generateCandidate ( info ) {
321
328
if ( ! info ) return null ;
322
329
323
- const { sdpMLineIndex, sdpMid, foundation, component, protocol, priority, ip , port , type, relAddr , relPort , generation, tcpType, networkId, networkCost, username } = info ;
324
- let candidate = `candidate:${ foundation } ${ component } ${ protocol } ${ priority } ${ ip } ${ port } ` ;
330
+ const { sdpMLineIndex, sdpMid, foundation, component, protocol, priority, address , type, relAddress , generation, tcpType, networkId, networkCost, username } = info ;
331
+ let candidate = `candidate:${ foundation } ${ component } ${ protocol } ${ priority } ${ address . ip } ${ address . port } ` ;
325
332
const attrs = [ ]
326
333
if ( type ) {
327
334
attrs . push ( `typ ${ type } ` ) ;
328
335
}
329
- if ( relAddr ) {
330
- attrs . push ( `raddr ${ relAddr } ` ) ;
331
- }
332
- if ( relPort ) {
333
- attrs . push ( `rport ${ relPort } ` ) ;
336
+ if ( relAddress ) {
337
+ attrs . push ( `raddr ${ relAddress . ip } ` ) ;
338
+ attrs . push ( `rport ${ relAddress . port } ` ) ;
334
339
}
335
340
if ( generation ) {
336
341
attrs . push ( `generation ${ generation } ` ) ;
0 commit comments