@@ -45,8 +45,6 @@ import {
45
45
mp4VideoInit as mp4VideoInitSegment ,
46
46
mp4Audio as mp4AudioSegment ,
47
47
mp4AudioInit as mp4AudioInitSegment ,
48
- encrypted as encryptedSegment ,
49
- encryptionKey ,
50
48
zeroLength as zeroLengthSegment
51
49
} from 'create-test-data!segments' ;
52
50
import sinon from 'sinon' ;
@@ -1433,141 +1431,6 @@ QUnit.module('SegmentLoader', function(hooks) {
1433
1431
} ) ;
1434
1432
} ) ;
1435
1433
1436
- QUnit . test ( 'segmentKey will cache new encrypted keys with cacheEncryptionKeys true' , function ( assert ) {
1437
- loader . cacheEncryptionKeys_ = true ;
1438
-
1439
- return this . setupMediaSource ( loader . mediaSource_ , loader . sourceUpdater_ ) . then ( ( ) => {
1440
- loader . playlist ( playlistWithDuration ( 10 , { isEncrypted : true } ) ) ;
1441
- loader . load ( ) ;
1442
- this . clock . tick ( 1 ) ;
1443
-
1444
- const keyCache = loader . keyCache_ ;
1445
- const bytes = new Uint32Array ( [ 1 , 2 , 3 , 4 ] ) ;
1446
-
1447
- assert . strictEqual ( Object . keys ( keyCache ) . length , 0 , 'no keys have been cached' ) ;
1448
-
1449
- const result = loader . segmentKey ( { resolvedUri : 'key.php' , bytes} ) ;
1450
-
1451
- assert . deepEqual ( result , { resolvedUri : 'key.php' } , 'gets by default' ) ;
1452
- loader . segmentKey ( { resolvedUri : 'key.php' , bytes} , true ) ;
1453
- assert . deepEqual ( keyCache [ 'key.php' ] . bytes , bytes , 'key has been cached' ) ;
1454
- } ) ;
1455
- } ) ;
1456
-
1457
- QUnit . test ( 'segmentKey will not cache encrypted keys with cacheEncryptionKeys false' , function ( assert ) {
1458
- loader . cacheEncryptionKeys_ = false ;
1459
-
1460
- return this . setupMediaSource ( loader . mediaSource_ , loader . sourceUpdater_ ) . then ( ( ) => {
1461
- loader . playlist ( playlistWithDuration ( 10 , { isEncrypted : true } ) ) ;
1462
- loader . load ( ) ;
1463
- this . clock . tick ( 1 ) ;
1464
-
1465
- const keyCache = loader . keyCache_ ;
1466
- const bytes = new Uint32Array ( [ 1 , 2 , 3 , 4 ] ) ;
1467
-
1468
- assert . strictEqual ( Object . keys ( keyCache ) . length , 0 , 'no keys have been cached' ) ;
1469
- loader . segmentKey ( { resolvedUri : 'key.php' , bytes} , true ) ;
1470
-
1471
- assert . strictEqual ( Object . keys ( keyCache ) . length , 0 , 'no keys have been cached' ) ;
1472
- } ) ;
1473
- } ) ;
1474
-
1475
- QUnit . test ( 'new segment requests will use cached keys' , function ( assert ) {
1476
- loader . cacheEncryptionKeys_ = true ;
1477
-
1478
- return this . setupMediaSource ( loader . mediaSource_ , loader . sourceUpdater_ ) . then ( ( ) => {
1479
- return new Promise ( ( resolve , reject ) => {
1480
- loader . one ( 'appended' , resolve ) ;
1481
- loader . one ( 'error' , reject ) ;
1482
- loader . playlist ( playlistWithDuration ( 20 , { isEncrypted : true } ) ) ;
1483
-
1484
- // make the keys the same
1485
- loader . playlist_ . segments [ 1 ] . key =
1486
- videojs . mergeOptions ( { } , loader . playlist_ . segments [ 0 ] . key ) ;
1487
- // give 2nd key an iv
1488
- loader . playlist_ . segments [ 1 ] . key . iv = new Uint32Array ( [ 0 , 1 , 2 , 3 ] ) ;
1489
-
1490
- loader . load ( ) ;
1491
- this . clock . tick ( 1 ) ;
1492
-
1493
- assert . strictEqual ( this . requests . length , 2 , 'one request' ) ;
1494
- assert . strictEqual ( this . requests [ 0 ] . uri , '0-key.php' , 'key request' ) ;
1495
- assert . strictEqual ( this . requests [ 1 ] . uri , '0.ts' , 'segment request' ) ;
1496
-
1497
- // key response
1498
- standardXHRResponse ( this . requests . shift ( ) , encryptionKey ( ) ) ;
1499
- this . clock . tick ( 1 ) ;
1500
-
1501
- // segment
1502
- standardXHRResponse ( this . requests . shift ( ) , encryptedSegment ( ) ) ;
1503
- this . clock . tick ( 1 ) ;
1504
-
1505
- // decryption tick for syncWorker
1506
- this . clock . tick ( 1 ) ;
1507
-
1508
- // tick for web worker segment probe
1509
- this . clock . tick ( 1 ) ;
1510
- } ) ;
1511
- } ) . then ( ( ) => {
1512
- assert . deepEqual ( loader . keyCache_ [ '0-key.php' ] , {
1513
- resolvedUri : '0-key.php' ,
1514
- bytes : new Uint32Array ( [ 609867320 , 2355137646 , 2410040447 , 480344904 ] )
1515
- } , 'previous key was cached' ) ;
1516
-
1517
- this . clock . tick ( 1 ) ;
1518
- assert . deepEqual ( loader . pendingSegment_ . segment . key , {
1519
- resolvedUri : '0-key.php' ,
1520
- uri : '0-key.php' ,
1521
- iv : new Uint32Array ( [ 0 , 1 , 2 , 3 ] )
1522
- } , 'used cached key for request and own initialization vector' ) ;
1523
-
1524
- assert . strictEqual ( this . requests . length , 1 , 'one request' ) ;
1525
- assert . strictEqual ( this . requests [ 0 ] . uri , '1.ts' , 'only segment request' ) ;
1526
- } ) ;
1527
- } ) ;
1528
-
1529
- QUnit . test ( 'new segment request keys every time' , function ( assert ) {
1530
- return this . setupMediaSource ( loader . mediaSource_ , loader . sourceUpdater_ ) . then ( ( ) => {
1531
- return new Promise ( ( resolve , reject ) => {
1532
- loader . one ( 'appended' , resolve ) ;
1533
- loader . one ( 'error' , reject ) ;
1534
- loader . playlist ( playlistWithDuration ( 20 , { isEncrypted : true } ) ) ;
1535
-
1536
- loader . load ( ) ;
1537
- this . clock . tick ( 1 ) ;
1538
-
1539
- assert . strictEqual ( this . requests . length , 2 , 'one request' ) ;
1540
- assert . strictEqual ( this . requests [ 0 ] . uri , '0-key.php' , 'key request' ) ;
1541
- assert . strictEqual ( this . requests [ 1 ] . uri , '0.ts' , 'segment request' ) ;
1542
-
1543
- // key response
1544
- standardXHRResponse ( this . requests . shift ( ) , encryptionKey ( ) ) ;
1545
- this . clock . tick ( 1 ) ;
1546
-
1547
- // segment
1548
- standardXHRResponse ( this . requests . shift ( ) , encryptedSegment ( ) ) ;
1549
- this . clock . tick ( 1 ) ;
1550
-
1551
- // decryption tick for syncWorker
1552
- this . clock . tick ( 1 ) ;
1553
-
1554
- } ) ;
1555
- } ) . then ( ( ) => {
1556
- this . clock . tick ( 1 ) ;
1557
-
1558
- assert . notOk ( loader . keyCache_ [ '0-key.php' ] , 'not cached' ) ;
1559
-
1560
- assert . deepEqual ( loader . pendingSegment_ . segment . key , {
1561
- resolvedUri : '1-key.php' ,
1562
- uri : '1-key.php'
1563
- } , 'used cached key for request and own initialization vector' ) ;
1564
-
1565
- assert . strictEqual ( this . requests . length , 2 , 'two requests' ) ;
1566
- assert . strictEqual ( this . requests [ 0 ] . uri , '1-key.php' , 'key request' ) ;
1567
- assert . strictEqual ( this . requests [ 1 ] . uri , '1.ts' , 'segment request' ) ;
1568
- } ) ;
1569
- } ) ;
1570
-
1571
1434
QUnit . test ( 'triggers syncinfoupdate before attempting a resync' , function ( assert ) {
1572
1435
let syncInfoUpdates = 0 ;
1573
1436
0 commit comments