@@ -11,7 +11,7 @@ var mp2t = require('../lib/m2ts'),
11
11
mp4Transmuxer = require ( '../lib/mp4/transmuxer' ) ,
12
12
mp4AudioProperties = mp4Transmuxer . AUDIO_PROPERTIES ,
13
13
mp4VideoProperties = mp4Transmuxer . VIDEO_PROPERTIES ,
14
- generateVideoSegmentTimingInfo = mp4Transmuxer . generateVideoSegmentTimingInfo ,
14
+ generateSegmentTimingInfo = mp4Transmuxer . generateSegmentTimingInfo ,
15
15
clock = require ( '../lib/utils/clock' ) ,
16
16
utils = require ( './utils' ) ,
17
17
TransportPacketStream = mp2t . TransportPacketStream ,
@@ -2532,7 +2532,7 @@ QUnit.test('alignGopsAtEnd_ filters gops appropriately', function(assert) {
2532
2532
'match with an alignment candidate' ) ;
2533
2533
} ) ;
2534
2534
2535
- QUnit . test ( 'generateVideoSegmentTimingInfo generates correct timing info object' , function ( assert ) {
2535
+ QUnit . test ( 'generateSegmentTimingInfo generates correct timing info object' , function ( assert ) {
2536
2536
var
2537
2537
firstFrame = {
2538
2538
dts : 12 ,
@@ -2548,7 +2548,7 @@ QUnit.test('generateVideoSegmentTimingInfo generates correct timing info object'
2548
2548
prependedContentDuration = 0 ;
2549
2549
2550
2550
assert . deepEqual (
2551
- generateVideoSegmentTimingInfo (
2551
+ generateSegmentTimingInfo (
2552
2552
baseMediaDecodeTime ,
2553
2553
firstFrame . dts ,
2554
2554
firstFrame . pts ,
@@ -2573,7 +2573,7 @@ QUnit.test('generateVideoSegmentTimingInfo generates correct timing info object'
2573
2573
} , 'generated correct timing info object' ) ;
2574
2574
} ) ;
2575
2575
2576
- QUnit . test ( 'generateVideoSegmentTimingInfo accounts for prepended GOPs' , function ( assert ) {
2576
+ QUnit . test ( 'generateSegmentTimingInfo accounts for prepended GOPs' , function ( assert ) {
2577
2577
var
2578
2578
firstFrame = {
2579
2579
dts : 12 ,
@@ -2589,7 +2589,7 @@ QUnit.test('generateVideoSegmentTimingInfo accounts for prepended GOPs', functio
2589
2589
prependedContentDuration = 7 ;
2590
2590
2591
2591
assert . deepEqual (
2592
- generateVideoSegmentTimingInfo (
2592
+ generateSegmentTimingInfo (
2593
2593
baseMediaDecodeTime ,
2594
2594
firstFrame . dts ,
2595
2595
firstFrame . pts ,
@@ -2615,7 +2615,7 @@ QUnit.test('generateVideoSegmentTimingInfo accounts for prepended GOPs', functio
2615
2615
'included prepended content duration in timing info' ) ;
2616
2616
} ) ;
2617
2617
2618
- QUnit . test ( 'generateVideoSegmentTimingInfo handles GOPS where pts is < dts' , function ( assert ) {
2618
+ QUnit . test ( 'generateSegmentTimingInfo handles GOPS where pts is < dts' , function ( assert ) {
2619
2619
var
2620
2620
firstFrame = {
2621
2621
dts : 14 ,
@@ -2631,7 +2631,7 @@ QUnit.test('generateVideoSegmentTimingInfo handles GOPS where pts is < dts', fun
2631
2631
prependedContentDuration = 7 ;
2632
2632
2633
2633
assert . deepEqual (
2634
- generateVideoSegmentTimingInfo (
2634
+ generateSegmentTimingInfo (
2635
2635
baseMediaDecodeTime ,
2636
2636
firstFrame . dts ,
2637
2637
firstFrame . pts ,
@@ -3221,6 +3221,60 @@ QUnit.test('audio track metadata takes on the value of the last metadata seen',
3221
3221
assert . equal ( events [ 0 ] . track . channelcount , 4 , 'kept the later channelcount' ) ;
3222
3222
} ) ;
3223
3223
3224
+ QUnit . test ( 'audio segment stream triggers segmentTimingInfo with timing info' ,
3225
+ function ( assert ) {
3226
+ var
3227
+ events = [ ] ,
3228
+ samplerate = 48000 ,
3229
+ baseMediaDecodeTimeInVideoClock = 30 ,
3230
+ audioFrameDurationInVideoClock = 90000 * 1024 / samplerate ,
3231
+ firstFrame = {
3232
+ channelcount : 2 ,
3233
+ samplerate : samplerate ,
3234
+ pts : 112 ,
3235
+ dts : 111 ,
3236
+ data : new Uint8Array ( [ 0 ] )
3237
+ } ,
3238
+ secondFrame = {
3239
+ channelcount : 2 ,
3240
+ samplerate : samplerate ,
3241
+ pts : firstFrame . pts + audioFrameDurationInVideoClock ,
3242
+ dts : firstFrame . dts + audioFrameDurationInVideoClock ,
3243
+ data : new Uint8Array ( [ 1 ] )
3244
+ } ;
3245
+
3246
+ audioSegmentStream . on ( 'segmentTimingInfo' , function ( event ) {
3247
+ events . push ( event ) ;
3248
+ } ) ;
3249
+ audioSegmentStream . track . timelineStartInfo . baseMediaDecodeTime =
3250
+ baseMediaDecodeTimeInVideoClock ;
3251
+
3252
+ audioSegmentStream . push ( firstFrame ) ;
3253
+ audioSegmentStream . push ( secondFrame ) ;
3254
+ audioSegmentStream . flush ( ) ;
3255
+
3256
+ assert . equal ( events . length , 1 , 'a segmentTimingInfo event was fired' ) ;
3257
+ assert . deepEqual (
3258
+ events [ 0 ] ,
3259
+ {
3260
+ start : {
3261
+ dts : baseMediaDecodeTimeInVideoClock ,
3262
+ pts : baseMediaDecodeTimeInVideoClock + ( firstFrame . pts - firstFrame . dts )
3263
+ } ,
3264
+ end : {
3265
+ dts : baseMediaDecodeTimeInVideoClock + ( secondFrame . dts - firstFrame . dts ) +
3266
+ audioFrameDurationInVideoClock ,
3267
+ pts : baseMediaDecodeTimeInVideoClock + ( secondFrame . pts - firstFrame . pts ) +
3268
+ audioFrameDurationInVideoClock
3269
+ } ,
3270
+ prependedContentDuration : 0 ,
3271
+ baseMediaDecodeTime : baseMediaDecodeTimeInVideoClock
3272
+ } ,
3273
+ 'has correct segmentTimingInfo'
3274
+ ) ;
3275
+ } ) ;
3276
+
3277
+
3224
3278
QUnit . module ( 'Transmuxer - options' ) ;
3225
3279
3226
3280
QUnit . test ( 'no options creates combined output' , function ( assert ) {
0 commit comments