@@ -17,18 +17,28 @@ ISOFile.prototype.createFragment = function(track_id, sampleNumber, stream_) {
17
17
}
18
18
return null ;
19
19
}
20
-
20
+
21
21
var stream = stream_ || new DataStream ( ) ;
22
22
stream . endianness = DataStream . BIG_ENDIAN ;
23
23
24
24
var moof = ISOFile . createSingleSampleMoof ( sample ) ;
25
+
26
+ // Extract sample encryption.
27
+ var senc = this . getBox ( 'senc' ) ;
28
+
29
+ // Add sample encryption if it exists.
30
+ if ( senc ) {
31
+ moof . trafs [ 0 ] . senc = senc ;
32
+ moof . trafs [ 0 ] . boxes . push ( senc ) ;
33
+ }
34
+
25
35
moof . write ( stream ) ;
26
36
27
37
/* adjusting the data_offset now that the moof size is known*/
28
38
moof . trafs [ 0 ] . truns [ 0 ] . data_offset = moof . size + 8 ; //8 is mdat header
29
39
Log . debug ( "MP4Box" , "Adjusting data_offset with new value " + moof . trafs [ 0 ] . truns [ 0 ] . data_offset ) ;
30
40
stream . adjustUint32 ( moof . trafs [ 0 ] . truns [ 0 ] . data_offset_position , moof . trafs [ 0 ] . truns [ 0 ] . data_offset ) ;
31
-
41
+
32
42
var mdat = new BoxParser . mdatBox ( ) ;
33
43
mdat . data = sample . data ;
34
44
mdat . write ( stream ) ;
@@ -47,7 +57,7 @@ ISOFile.writeInitializationSegment = function(ftyp, moov, total_duration, sample
47
57
var stream = new DataStream ( ) ;
48
58
stream . endianness = DataStream . BIG_ENDIAN ;
49
59
ftyp . write ( stream ) ;
50
-
60
+
51
61
/* we can now create the new mvex box */
52
62
var mvex = moov . add ( "mvex" ) ;
53
63
if ( total_duration ) {
@@ -70,7 +80,7 @@ ISOFile.prototype.save = function(name) {
70
80
var stream = new DataStream ( ) ;
71
81
stream . endianness = DataStream . BIG_ENDIAN ;
72
82
this . write ( stream ) ;
73
- stream . save ( name ) ;
83
+ stream . save ( name ) ;
74
84
}
75
85
76
86
ISOFile . prototype . getBuffer = function ( ) {
@@ -91,11 +101,11 @@ ISOFile.prototype.initializeSegmentation = function() {
91
101
Log . warn ( "MP4Box" , "No segmentation callback set!" ) ;
92
102
}
93
103
if ( ! this . isFragmentationInitialized ) {
94
- this . isFragmentationInitialized = true ;
104
+ this . isFragmentationInitialized = true ;
95
105
this . nextMoofNumber = 0 ;
96
106
this . resetTables ( ) ;
97
- }
98
- initSegs = [ ] ;
107
+ }
108
+ initSegs = [ ] ;
99
109
for ( i = 0 ; i < this . fragmentedTracks . length ; i ++ ) {
100
110
var moov = new BoxParser . moovBox ( ) ;
101
111
moov . mvhd = this . moov . mvhd ;
0 commit comments