Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
brainfood
/
videojs-contrib-hls
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
ae126725
authored
2014-09-16 15:41:14 -0700
by
Simeon Bateman
Committed by
David LaPalomento
2015-07-31 16:40:37 -0400
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Added the sidx parsing and test file from mp4 spec
1 parent
e5b1ef5b
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
75 additions
and
0 deletions
test/mp4-inspector_test.js
test/muxer/js/mp4-inspector.js
test/mp4-inspector_test.js
View file @
ae12672
...
...
@@ -704,6 +704,54 @@ test('can parse a trun', function() {
}]);
});
test
(
'can parse a sidx'
,
function
(){
var
data
=
box
(
'sidx'
,
0x00
,
// version
0x00
,
0x00
,
0x00
,
// flags
0x00
,
0x00
,
0x00
,
0x02
,
// reference_ID
0x00
,
0x00
,
0x00
,
0x01
,
// timescale
0x01
,
0x02
,
0x03
,
0x04
,
// earliest_presentation_time
0x00
,
0x00
,
0x00
,
0x00
,
// first_offset
0x00
,
0x00
,
// reserved
0x00
,
0x02
,
// reference_count
// first reference
0x80
,
0x00
,
0x00
,
0x07
,
// reference_type(1) + referenced_size(31)
0x00
,
0x00
,
0x00
,
0x08
,
// subsegment_duration
0x80
,
0x00
,
0x00
,
0x09
,
// starts_with_SAP(1) + SAP_type(3) + SAP_delta_time(28)
// second reference
0x00
,
0x00
,
0x00
,
0x03
,
// reference_type(1) + referenced_size(31)
0x00
,
0x00
,
0x00
,
0x04
,
// subsegment_duration
0x10
,
0x00
,
0x00
,
0x05
// starts_with_SAP(1) + SAP_type(3) + SAP_delta_time(28)
);
deepEqual
(
videojs
.
inspectMp4
(
new
Uint8Array
(
data
)),
[{
type
:
'sidx'
,
version
:
0
,
flags
:
new
Uint8Array
([
0
,
0x00
,
0x00
]),
timescale
:
1
,
earliestPresentationTime
:
0x01020304
,
firstOffset
:
0
,
referenceId
:
2
,
size
:
56
,
references
:
[{
referenceType
:
1
,
referencedSize
:
7
,
subsegmentDuration
:
8
,
startsWithSap
:
true
,
sapType
:
0
,
sapDeltaTime
:
9
},{
referenceType
:
0
,
referencedSize
:
3
,
subsegmentDuration
:
4
,
startsWithSap
:
false
,
sapType
:
1
,
sapDeltaTime
:
5
}]
}]);
});
test
(
'can parse a series of boxes'
,
function
()
{
var
ftyp
=
[
0x00
,
0x00
,
0x00
,
0x18
// size 4 * 6 = 24
...
...
test/muxer/js/mp4-inspector.js
View file @
ae12672
...
...
@@ -266,6 +266,33 @@ var
initialDelay
:
view
.
getUint32
(
8
)
};
},
sidx
:
function
(
data
)
{
var
view
=
new
DataView
(
data
.
buffer
,
data
.
byteOffset
,
data
.
byteLength
),
result
=
{
version
:
data
[
0
],
flags
:
new
Uint8Array
(
data
.
subarray
(
1
,
4
)),
references
:
[],
referenceId
:
view
.
getUint32
(
4
),
timescale
:
view
.
getUint32
(
8
),
earliestPresentationTime
:
view
.
getUint32
(
12
),
firstOffset
:
view
.
getUint32
(
16
)
},
referenceCount
=
view
.
getUint16
(
22
),
i
;
for
(
i
=
24
;
referenceCount
;
i
+=
12
,
referenceCount
--
)
{
result
.
references
.
push
({
referenceType
:
(
data
[
i
]
&
0x80
)
>>>
7
,
referencedSize
:
view
.
getUint32
(
i
)
&
0x7FFFFFFF
,
subsegmentDuration
:
view
.
getUint32
(
i
+
4
),
startsWithSap
:
!!
(
data
[
i
+
8
]
&
0x80
),
sapType
:
(
data
[
i
+
8
]
&
0x70
)
>>>
4
,
sapDeltaTime
:
view
.
getUint32
(
i
+
8
)
&
0x0FFFFFFF
});
}
return
result
;
},
stbl
:
function
(
data
)
{
return
{
boxes
:
videojs
.
inspectMp4
(
data
)
...
...
Please
register
or
sign in
to post a comment