1
- ( function ( f ) { if ( typeof exports === "object" && typeof module !== "undefined" ) { module . exports = f ( ) } else if ( typeof define === "function" && define . amd ) { define ( [ ] , f ) } else { var g ; if ( typeof window !== "undefined" ) { g = window } else if ( typeof global !== "undefined" ) { g = global } else if ( typeof self !== "undefined" ) { g = self } else { g = this } g . adapter = f ( ) } } ) ( function ( ) { var define , module , exports ; return ( function e ( t , n , r ) { function s ( o , u ) { if ( ! n [ o ] ) { if ( ! t [ o ] ) { var a = typeof require == "function" && require ; if ( ! u && a ) return a ( o , ! 0 ) ; if ( i ) return i ( o , ! 0 ) ; var f = new Error ( "Cannot find module '" + o + "'" ) ; throw f . code = "MODULE_NOT_FOUND" , f } var l = n [ o ] = { exports :{ } } ; t [ o ] [ 0 ] . call ( l . exports , function ( e ) { var n = t [ o ] [ 1 ] [ e ] ; return s ( n ? n : e ) } , l , l . exports , e , t , n , r ) } return n [ o ] . exports } var i = typeof require == "function" && require ; for ( var o = 0 ; o < r . length ; o ++ ) s ( r [ o ] ) ; return s } ) ( { 1 :[ function ( require , module , exports ) {
1
+ ( function ( f ) { if ( typeof exports === "object" && typeof module !== "undefined" ) { module . exports = f ( ) } else if ( typeof define === "function" && define . amd ) { define ( [ ] , f ) } else { var g ; if ( typeof window !== "undefined" ) { g = window } else if ( typeof global !== "undefined" ) { g = global } else if ( typeof self !== "undefined" ) { g = self } else { g = this } g . adapter = f ( ) } } ) ( function ( ) { var define , module , exports ; return ( function ( ) { function r ( e , n , t ) { function o ( i , f ) { if ( ! n [ i ] ) { if ( ! e [ i ] ) { var c = "function" == typeof require && require ; if ( ! f && c ) return c ( i , ! 0 ) ; if ( u ) return u ( i , ! 0 ) ; var a = new Error ( "Cannot find module '" + i + "'" ) ; throw a . code = "MODULE_NOT_FOUND" , a } var p = n [ i ] = { exports :{ } } ; e [ i ] [ 0 ] . call ( p . exports , function ( r ) { var n = e [ i ] [ 1 ] [ r ] ; return o ( n || r ) } , p , p . exports , r , e , n , t ) } return n [ i ] . exports } for ( var u = "function" == typeof require && require , i = 0 ; i < t . length ; i ++ ) o ( t [ i ] ) ; return o } return r } ) ( ) ( { 1 :[ function ( require , module , exports ) {
2
2
/*
3
3
* Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
4
4
*
@@ -1140,6 +1140,19 @@ module.exports = function(window, edgeVersion) {
1140
1140
}
1141
1141
}
1142
1142
1143
+ // If the offer contained RTX but the answer did not,
1144
+ // remove RTX from sendEncodingParameters.
1145
+ var commonCapabilities = getCommonCapabilities (
1146
+ transceiver . localCapabilities ,
1147
+ transceiver . remoteCapabilities ) ;
1148
+
1149
+ var hasRtx = commonCapabilities . codecs . filter ( function ( c ) {
1150
+ return c . name . toLowerCase ( ) === 'rtx' ;
1151
+ } ) . length ;
1152
+ if ( ! hasRtx && transceiver . sendEncodingParameters [ 0 ] . rtx ) {
1153
+ delete transceiver . sendEncodingParameters [ 0 ] . rtx ;
1154
+ }
1155
+
1143
1156
pc . _transceive ( transceiver ,
1144
1157
direction === 'sendrecv' || direction === 'recvonly' ,
1145
1158
direction === 'sendrecv' || direction === 'sendonly' ) ;
@@ -1555,6 +1568,8 @@ module.exports = function(window, edgeVersion) {
1555
1568
return t . mid ;
1556
1569
} ) . join ( ' ' ) + '\r\n' ;
1557
1570
}
1571
+ sdp += 'a=ice-options:trickle\r\n' ;
1572
+
1558
1573
var mediaSectionsInOffer = SDPUtils . getMediaSections (
1559
1574
pc . _remoteDescription . sdp ) . length ;
1560
1575
pc . transceivers . forEach ( function ( transceiver , sdpMLineIndex ) {
@@ -1905,6 +1920,7 @@ SDPUtils.parseCandidate = function(line) {
1905
1920
protocol : parts [ 2 ] . toLowerCase ( ) ,
1906
1921
priority : parseInt ( parts [ 3 ] , 10 ) ,
1907
1922
ip : parts [ 4 ] ,
1923
+ address : parts [ 4 ] , // address is an alias for ip.
1908
1924
port : parseInt ( parts [ 5 ] , 10 ) ,
1909
1925
// skip parts[6] == 'typ'
1910
1926
type : parts [ 7 ]
@@ -1940,7 +1956,7 @@ SDPUtils.writeCandidate = function(candidate) {
1940
1956
sdp . push ( candidate . component ) ;
1941
1957
sdp . push ( candidate . protocol . toUpperCase ( ) ) ;
1942
1958
sdp . push ( candidate . priority ) ;
1943
- sdp . push ( candidate . ip ) ;
1959
+ sdp . push ( candidate . address || candidate . ip ) ;
1944
1960
sdp . push ( candidate . port ) ;
1945
1961
1946
1962
var type = candidate . type ;
@@ -1968,7 +1984,7 @@ SDPUtils.writeCandidate = function(candidate) {
1968
1984
// a=ice-options:foo bar
1969
1985
SDPUtils . parseIceOptions = function ( line ) {
1970
1986
return line . substr ( 14 ) . split ( ' ' ) ;
1971
- }
1987
+ } ;
1972
1988
1973
1989
// Parses an rtpmap line, returns RTCRtpCoddecParameters. Sample input:
1974
1990
// a=rtpmap:111 opus/48000/2
@@ -2101,14 +2117,24 @@ SDPUtils.parseSsrcMedia = function(line) {
2101
2117
return parts ;
2102
2118
} ;
2103
2119
2120
+ SDPUtils . parseSsrcGroup = function ( line ) {
2121
+ var parts = line . substr ( 13 ) . split ( ' ' ) ;
2122
+ return {
2123
+ semantics : parts . shift ( ) ,
2124
+ ssrcs : parts . map ( function ( ssrc ) {
2125
+ return parseInt ( ssrc , 10 ) ;
2126
+ } )
2127
+ } ;
2128
+ } ;
2129
+
2104
2130
// Extracts the MID (RFC 5888) from a media section.
2105
2131
// returns the MID or undefined if no mid line was found.
2106
2132
SDPUtils . getMid = function ( mediaSection ) {
2107
2133
var mid = SDPUtils . matchPrefix ( mediaSection , 'a=mid:' ) [ 0 ] ;
2108
2134
if ( mid ) {
2109
2135
return mid . substr ( 6 ) ;
2110
2136
}
2111
- }
2137
+ } ;
2112
2138
2113
2139
SDPUtils . parseFingerprint = function ( line ) {
2114
2140
var parts = line . substr ( 14 ) . split ( ' ' ) ;
@@ -2285,7 +2311,7 @@ SDPUtils.parseRtpEncodingParameters = function(mediaSection) {
2285
2311
if ( codec . name . toUpperCase ( ) === 'RTX' && codec . parameters . apt ) {
2286
2312
var encParam = {
2287
2313
ssrc : primarySsrc ,
2288
- codecPayloadType : parseInt ( codec . parameters . apt , 10 ) ,
2314
+ codecPayloadType : parseInt ( codec . parameters . apt , 10 )
2289
2315
} ;
2290
2316
if ( primarySsrc && secondarySsrc ) {
2291
2317
encParam . rtx = { ssrc : secondarySsrc } ;
@@ -2294,7 +2320,7 @@ SDPUtils.parseRtpEncodingParameters = function(mediaSection) {
2294
2320
if ( hasRed ) {
2295
2321
encParam = JSON . parse ( JSON . stringify ( encParam ) ) ;
2296
2322
encParam . fec = {
2297
- ssrc : secondarySsrc ,
2323
+ ssrc : primarySsrc ,
2298
2324
mechanism : hasUlpfec ? 'red+ulpfec' : 'red'
2299
2325
} ;
2300
2326
encodingParameters . push ( encParam ) ;
@@ -2330,8 +2356,7 @@ SDPUtils.parseRtpEncodingParameters = function(mediaSection) {
2330
2356
SDPUtils . parseRtcpParameters = function ( mediaSection ) {
2331
2357
var rtcpParameters = { } ;
2332
2358
2333
- var cname ;
2334
- // Gets the first SSRC. Note that with RTX there might be multiple
2359
+ // Gets the first SSRC. Note tha with RTX there might be multiple
2335
2360
// SSRCs.
2336
2361
var remoteSsrc = SDPUtils . matchPrefix ( mediaSection , 'a=ssrc:' )
2337
2362
. map ( function ( line ) {
@@ -2372,8 +2397,8 @@ SDPUtils.parseMsid = function(mediaSection) {
2372
2397
. map ( function ( line ) {
2373
2398
return SDPUtils . parseSsrcMedia ( line ) ;
2374
2399
} )
2375
- . filter ( function ( parts ) {
2376
- return parts . attribute === 'msid' ;
2400
+ . filter ( function ( msidParts ) {
2401
+ return msidParts . attribute === 'msid' ;
2377
2402
} ) ;
2378
2403
if ( planB . length > 0 ) {
2379
2404
parts = planB [ 0 ] . value . split ( ' ' ) ;
@@ -2393,17 +2418,20 @@ SDPUtils.generateSessionId = function() {
2393
2418
// sessId argument is optional - if not supplied it will
2394
2419
// be generated randomly
2395
2420
// sessVersion is optional and defaults to 2
2396
- SDPUtils . writeSessionBoilerplate = function ( sessId , sessVer ) {
2421
+ // sessUser is optional and defaults to 'thisisadapterortc'
2422
+ SDPUtils . writeSessionBoilerplate = function ( sessId , sessVer , sessUser ) {
2397
2423
var sessionId ;
2398
2424
var version = sessVer !== undefined ? sessVer : 2 ;
2399
2425
if ( sessId ) {
2400
2426
sessionId = sessId ;
2401
2427
} else {
2402
2428
sessionId = SDPUtils . generateSessionId ( ) ;
2403
2429
}
2430
+ var user = sessUser || 'thisisadapterortc' ;
2404
2431
// FIXME: sess-id should be an NTP timestamp.
2405
2432
return 'v=0\r\n' +
2406
- 'o=thisisadapterortc ' + sessionId + ' ' + version + ' IN IP4 127.0.0.1\r\n' +
2433
+ 'o=' + user + ' ' + sessionId + ' ' + version +
2434
+ ' IN IP4 127.0.0.1\r\n' +
2407
2435
's=-\r\n' +
2408
2436
't=0 0\r\n' ;
2409
2437
} ;
@@ -2513,9 +2541,24 @@ SDPUtils.parseOLine = function(mediaSection) {
2513
2541
sessionVersion : parseInt ( parts [ 2 ] , 10 ) ,
2514
2542
netType : parts [ 3 ] ,
2515
2543
addressType : parts [ 4 ] ,
2516
- address : parts [ 5 ] ,
2544
+ address : parts [ 5 ]
2517
2545
} ;
2518
- }
2546
+ } ;
2547
+
2548
+ // a very naive interpretation of a valid SDP.
2549
+ SDPUtils . isValidSDP = function ( blob ) {
2550
+ if ( typeof blob !== 'string' || blob . length === 0 ) {
2551
+ return false ;
2552
+ }
2553
+ var lines = SDPUtils . splitLines ( blob ) ;
2554
+ for ( var i = 0 ; i < lines . length ; i ++ ) {
2555
+ if ( lines [ i ] . length < 2 || lines [ i ] . charAt ( 1 ) !== '=' ) {
2556
+ return false ;
2557
+ }
2558
+ // TODO: check the modifier a bit more.
2559
+ }
2560
+ return true ;
2561
+ } ;
2519
2562
2520
2563
// Expose public methods.
2521
2564
if ( typeof module === 'object' ) {
@@ -2676,12 +2719,12 @@ module.exports = function(dependencies, opts) {
2676
2719
commonShim . shimCreateObjectURL ( window ) ;
2677
2720
2678
2721
safariShim . shimRTCIceServerUrls ( window ) ;
2722
+ safariShim . shimCreateOfferLegacy ( window ) ;
2679
2723
safariShim . shimCallbacksAPI ( window ) ;
2680
2724
safariShim . shimLocalStreamsAPI ( window ) ;
2681
2725
safariShim . shimRemoteStreamsAPI ( window ) ;
2682
2726
safariShim . shimTrackEventTransceiver ( window ) ;
2683
2727
safariShim . shimGetUserMedia ( window ) ;
2684
- safariShim . shimCreateOfferLegacy ( window ) ;
2685
2728
2686
2729
commonShim . shimRTCIceCandidate ( window ) ;
2687
2730
commonShim . shimMaxMessageSize ( window ) ;
@@ -2818,10 +2861,14 @@ module.exports = {
2818
2861
}
2819
2862
return origSetRemoteDescription . apply ( pc , arguments ) ;
2820
2863
} ;
2821
- } else if ( ! ( 'RTCRtpTransceiver' in window ) ) {
2864
+ } else {
2865
+ // even if RTCRtpTransceiver is in window, it is only used and
2866
+ // emitted in unified-plan. Unfortunately this means we need
2867
+ // to unconditionally wrap the event.
2822
2868
utils . wrapPeerConnectionEvent ( window , 'track' , function ( e ) {
2823
2869
if ( ! e . transceiver ) {
2824
- e . transceiver = { receiver : e . receiver } ;
2870
+ Object . defineProperty ( e , 'transceiver' ,
2871
+ { value : { receiver : e . receiver } } ) ;
2825
2872
}
2826
2873
return e ;
2827
2874
} ) ;
@@ -3433,35 +3480,6 @@ module.exports = {
3433
3480
}
3434
3481
} ) ;
3435
3482
}
3436
- } else {
3437
- // migrate from non-spec RTCIceServer.url to RTCIceServer.urls
3438
- var OrigPeerConnection = window . RTCPeerConnection ;
3439
- window . RTCPeerConnection = function ( pcConfig , pcConstraints ) {
3440
- if ( pcConfig && pcConfig . iceServers ) {
3441
- var newIceServers = [ ] ;
3442
- for ( var i = 0 ; i < pcConfig . iceServers . length ; i ++ ) {
3443
- var server = pcConfig . iceServers [ i ] ;
3444
- if ( ! server . hasOwnProperty ( 'urls' ) &&
3445
- server . hasOwnProperty ( 'url' ) ) {
3446
- utils . deprecated ( 'RTCIceServer.url' , 'RTCIceServer.urls' ) ;
3447
- server = JSON . parse ( JSON . stringify ( server ) ) ;
3448
- server . urls = server . url ;
3449
- newIceServers . push ( server ) ;
3450
- } else {
3451
- newIceServers . push ( pcConfig . iceServers [ i ] ) ;
3452
- }
3453
- }
3454
- pcConfig . iceServers = newIceServers ;
3455
- }
3456
- return new OrigPeerConnection ( pcConfig , pcConstraints ) ;
3457
- } ;
3458
- window . RTCPeerConnection . prototype = OrigPeerConnection . prototype ;
3459
- // wrap static methods. Currently just generateCertificate.
3460
- Object . defineProperty ( window . RTCPeerConnection , 'generateCertificate' , {
3461
- get : function ( ) {
3462
- return OrigPeerConnection . generateCertificate ;
3463
- }
3464
- } ) ;
3465
3483
}
3466
3484
3467
3485
var origGetStats = window . RTCPeerConnection . prototype . getStats ;
@@ -5379,3 +5397,4 @@ module.exports = {
5379
5397
5380
5398
} , { } ] } , { } , [ 3 ] ) ( 3 )
5381
5399
} ) ;
5400
+
0 commit comments