bmff 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +10 -0
- data/CHANGELOG.md +73 -0
- data/README.md +16 -4
- data/bmff.gemspec +2 -0
- data/lib/bmff/binary_accessor.rb +16 -2
- data/lib/bmff/box/base.rb +10 -6
- data/lib/bmff/box/container.rb +3 -3
- data/lib/bmff/box/map.rb +12 -2
- data/lib/bmff/box/original_format.rb +12 -0
- data/lib/bmff/box/protection_scheme_info.rb +22 -0
- data/lib/bmff/box/protection_system_specific_header.rb +14 -0
- data/lib/bmff/box/sample_encryption.rb +70 -0
- data/lib/bmff/box/scheme_information.rb +12 -0
- data/lib/bmff/box/scheme_type.rb +16 -0
- data/lib/bmff/box/track_encryption.rb +14 -0
- data/lib/bmff/box.rb +30 -5
- data/lib/bmff/version.rb +1 -1
- data/test/bmff/box/test_original_format.rb +26 -0
- data/test/bmff/box/test_protection_sheme_info.rb +82 -0
- data/test/bmff/box/test_protection_system_specific_header.rb +38 -0
- data/test/bmff/box/test_sample_encryption.rb +177 -0
- data/test/bmff/box/test_sheme_information.rb +26 -0
- data/test/bmff/box/test_sheme_type.rb +59 -0
- data/test/bmff/box/test_track_encryption.rb +38 -0
- data/test/bmff/test_binary_accessor.rb +47 -1
- data/test/bmff/test_file_container.rb +9 -0
- metadata +42 -3
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
#### 0.1.0
|
2
|
+
|
3
|
+
* Support for UUID box parsing
|
4
|
+
* Add dependency on UUIDTools
|
5
|
+
* Add support for following boxes
|
6
|
+
* Protection Scheme Information Box
|
7
|
+
* Original Format Box
|
8
|
+
* Scheme Type Box
|
9
|
+
* Scheme Information Box
|
10
|
+
* Protection System Specific Header Box (PIFF 1.1)
|
11
|
+
* Sample Encryption Box (PIFF 1.1)
|
12
|
+
* Track Encryption Box (PIFF 1.1)
|
13
|
+
|
14
|
+
|
15
|
+
#### 0.0.1
|
16
|
+
|
17
|
+
* First release
|
18
|
+
* Support following boxes
|
19
|
+
* File Type Box
|
20
|
+
* Media Data Box
|
21
|
+
* Free Space Box
|
22
|
+
* Progressive Download Information Box
|
23
|
+
* Movie Box
|
24
|
+
* Movie Header Box
|
25
|
+
* Track Box
|
26
|
+
* Track Header Box
|
27
|
+
* Track Reference Box
|
28
|
+
* Track Group Box
|
29
|
+
* Media Box
|
30
|
+
* Media Header Box
|
31
|
+
* Handler Reference Box
|
32
|
+
* Media Information Box
|
33
|
+
* Video Media Header Box
|
34
|
+
* Sound Media Header Box
|
35
|
+
* Hint Media Header Box
|
36
|
+
* Null Media Header Box
|
37
|
+
* Sample Table Box
|
38
|
+
* Sample Description Box
|
39
|
+
* Degradation Priority Box
|
40
|
+
* Decoding Time to Sample Box
|
41
|
+
* Composition Time to Sample Box
|
42
|
+
* Composition to Decode Box
|
43
|
+
* Sync Sample Box
|
44
|
+
* Shadow Sync Sample Box
|
45
|
+
* Independent and Disposable Samples Box
|
46
|
+
* Edit Box
|
47
|
+
* Edit List Box
|
48
|
+
* Data Information Box
|
49
|
+
* Data Reference Box
|
50
|
+
* Sample Size Box
|
51
|
+
* Compact Sample Size Box
|
52
|
+
* Sample to Chunk Box
|
53
|
+
* Chunk Offset Box
|
54
|
+
* Padding Bits Box
|
55
|
+
* Sub-Sample Information Box
|
56
|
+
* Sample Auxiliary Information Sizes Box
|
57
|
+
* Sample Auxiliary Information Offsets Box
|
58
|
+
* Movie Extends Box
|
59
|
+
* Movie Extends Header Box
|
60
|
+
* Track Extends Box
|
61
|
+
* Movie Fragment Box
|
62
|
+
* Movie Fragment Header Box
|
63
|
+
* Track Fragment Box
|
64
|
+
* Track Fragment Header Box
|
65
|
+
* Track Fragment Run Box
|
66
|
+
* Movie Fragment Random Access Box
|
67
|
+
* Track Fragment Random Access Box
|
68
|
+
* Movie Fragment Random Access Offset Box
|
69
|
+
* Track fragment decode time
|
70
|
+
* Level Assignment Box
|
71
|
+
* User Data Box
|
72
|
+
* Copyright Box
|
73
|
+
* Track Selection Box
|
data/README.md
CHANGED
@@ -4,6 +4,9 @@ This gem library is an ISO Base Media File Format (BMFF) parser.
|
|
4
4
|
You can parse BMFF file.
|
5
5
|
And you may be able to parse a file related to BMFF like MP4.
|
6
6
|
|
7
|
+
[![Build Status](https://travis-ci.org/zuku/bmff.svg?branch=master)](https://travis-ci.org/zuku/bmff)
|
8
|
+
[![Gem Version](https://badge.fury.io/rb/bmff.svg)](http://badge.fury.io/rb/bmff)
|
9
|
+
|
7
10
|
## Installation
|
8
11
|
|
9
12
|
Add this line to your application's Gemfile:
|
@@ -143,10 +146,10 @@ end
|
|
143
146
|
|Metabox Relation Box | mere |Not yet | \ 8.11.8
|
144
147
|
|Item Data Box | idat |Not yet | \ 8.11.11
|
145
148
|
|Item Reference Box | iref |Not yet | \ 8.11.12
|
146
|
-
|Protection Scheme Information Box | sinf |
|
147
|
-
|Original Format Box | frma |
|
148
|
-
|Scheme Type Box | schm |
|
149
|
-
|Scheme Information Box | schi |
|
149
|
+
|Protection Scheme Information Box | sinf |OK | \ 8.12.1
|
150
|
+
|Original Format Box | frma |OK | \ 8.12.2
|
151
|
+
|Scheme Type Box | schm |OK | \ 8.12.5
|
152
|
+
|Scheme Information Box | schi |OK | \ 8.12.6
|
150
153
|
|FD Item Information Box | fiin |Not yet | \ 8.13.2
|
151
154
|
|File Partition Box | fpar |Not yet | \ 8.13.3
|
152
155
|
|FEC Reservoir Box | fecr |Not yet | \ 8.13.4
|
@@ -165,6 +168,15 @@ end
|
|
165
168
|
|Producer Reference Time Box | prft |Not yet | \ 8.16.5
|
166
169
|
|
167
170
|
|
171
|
+
### Protected Interoperable File Format (PIFF) 1.1
|
172
|
+
|
173
|
+
|Box Name | UUID | Status |
|
174
|
+
|:--------------------------------------------|:----------------------------------:|:---------:|
|
175
|
+
|Protection System Specific Header Box |d08a4f18-10f3-4a82-b6c8-32d8aba183d3|OK | \ 5.3.1
|
176
|
+
|Sample Encryption Box |a2394f52-5a9b-4f14-a244-6c427c648df4|OK | \ 5.3.2
|
177
|
+
|Track Encryption Box |8974dbce-7be7-4c51-84f9-7148f9882554|OK | \ 5.3.3
|
178
|
+
|
179
|
+
|
168
180
|
## Contributing
|
169
181
|
|
170
182
|
1. Fork it ( http://github.com/zuku/bmff/fork )
|
data/bmff.gemspec
CHANGED
data/lib/bmff/binary_accessor.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
# vim: set expandtab tabstop=2 shiftwidth=2 softtabstop=2 autoindent:
|
3
3
|
|
4
|
+
require "uuidtools"
|
5
|
+
|
4
6
|
module BMFF::BinaryAccessor
|
5
7
|
BYTE_ORDER = "\xFE\xFF".unpack("s").first == 0xFEFF ? :be : :le
|
6
8
|
|
@@ -151,8 +153,20 @@ module BMFF::BinaryAccessor
|
|
151
153
|
end
|
152
154
|
|
153
155
|
def get_uuid
|
154
|
-
|
155
|
-
|
156
|
+
UUIDTools::UUID.parse_raw(_read(16))
|
157
|
+
end
|
158
|
+
|
159
|
+
def write_uuid(uuid)
|
160
|
+
uuid_to_write = nil
|
161
|
+
case uuid
|
162
|
+
when UUIDTools::UUID
|
163
|
+
uuid_to_write = uuid
|
164
|
+
when String
|
165
|
+
uuid_to_write = UUIDTools::UUID.parse(uuid)
|
166
|
+
else
|
167
|
+
raise TypeError
|
168
|
+
end
|
169
|
+
write(uuid_to_write.raw)
|
156
170
|
end
|
157
171
|
|
158
172
|
private
|
data/lib/bmff/box/base.rb
CHANGED
@@ -11,6 +11,10 @@ class BMFF::Box::Base
|
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
+
def self.register_uuid_box(uuid)
|
15
|
+
BMFF::Box::Map.register_uuid_box(uuid, self)
|
16
|
+
end
|
17
|
+
|
14
18
|
def actual_size
|
15
19
|
return largesize if size == 1
|
16
20
|
return nil if size == 0
|
@@ -52,15 +56,15 @@ class BMFF::Box::Base
|
|
52
56
|
end
|
53
57
|
|
54
58
|
def parse_data
|
55
|
-
if size == 1
|
56
|
-
@largesize = io.get_uint64
|
57
|
-
end
|
58
|
-
if type == 'uuid'
|
59
|
-
@usertype = io.get_uuid
|
60
|
-
end
|
61
59
|
end
|
62
60
|
|
63
61
|
def container?
|
64
62
|
false
|
65
63
|
end
|
64
|
+
|
65
|
+
def root
|
66
|
+
ancestor = parent
|
67
|
+
ancestor = ancestor.parent while ancestor.respond_to?(:parent) && ancestor.parent
|
68
|
+
ancestor
|
69
|
+
end
|
66
70
|
end
|
data/lib/bmff/box/container.rb
CHANGED
@@ -24,7 +24,7 @@ module BMFF::Box::Container
|
|
24
24
|
@children << child
|
25
25
|
end
|
26
26
|
|
27
|
-
# Find a box which has a specific type from
|
27
|
+
# Find a box which has a specific type from my children.
|
28
28
|
def find(boxtype)
|
29
29
|
(@children || []).each do |child|
|
30
30
|
case boxtype
|
@@ -37,7 +37,7 @@ module BMFF::Box::Container
|
|
37
37
|
nil
|
38
38
|
end
|
39
39
|
|
40
|
-
# Find boxes which have a specific type from
|
40
|
+
# Find boxes which have a specific type from my children.
|
41
41
|
def find_all(boxtype)
|
42
42
|
found_boxes = []
|
43
43
|
(@children || []).each do |child|
|
@@ -51,7 +51,7 @@ module BMFF::Box::Container
|
|
51
51
|
found_boxes
|
52
52
|
end
|
53
53
|
|
54
|
-
# Find boxes which have a specific type from
|
54
|
+
# Find boxes which have a specific type from my descendants.
|
55
55
|
def select_descendants(boxtype)
|
56
56
|
selected_boxes = []
|
57
57
|
(@children || []).each do |child|
|
data/lib/bmff/box/map.rb
CHANGED
@@ -3,13 +3,23 @@
|
|
3
3
|
|
4
4
|
class BMFF::Box::Map
|
5
5
|
class << self
|
6
|
+
@@map = {}
|
7
|
+
@@uuid_map = {}
|
8
|
+
|
6
9
|
def register_box(type, klass)
|
7
|
-
@@map ||= {}
|
8
10
|
@@map[type] = klass
|
9
11
|
end
|
10
12
|
|
11
13
|
def get_box_class(type)
|
12
|
-
|
14
|
+
@@map[type]
|
15
|
+
end
|
16
|
+
|
17
|
+
def register_uuid_box(uuid, klass)
|
18
|
+
@@uuid_map[UUIDTools::UUID.parse(uuid).to_s] = klass
|
19
|
+
end
|
20
|
+
|
21
|
+
def get_uuid_box_class(uuid)
|
22
|
+
@@uuid_map[uuid.to_s]
|
13
23
|
end
|
14
24
|
end
|
15
25
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
# vim: set expandtab tabstop=2 shiftwidth=2 softtabstop=2 autoindent:
|
3
|
+
|
4
|
+
class BMFF::Box::OriginalFormat < BMFF::Box::Base
|
5
|
+
attr_accessor :data_format
|
6
|
+
register_box "frma"
|
7
|
+
|
8
|
+
def parse_data
|
9
|
+
super
|
10
|
+
@data_format = io.get_ascii(4)
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
# vim: set expandtab tabstop=2 shiftwidth=2 softtabstop=2 autoindent:
|
3
|
+
|
4
|
+
class BMFF::Box::ProtectionSchemeInfo < BMFF::Box::Base
|
5
|
+
attr_accessor :original_format, :scheme_type_box, :info
|
6
|
+
register_box "sinf"
|
7
|
+
include(BMFF::Box::Container)
|
8
|
+
|
9
|
+
def parse_data
|
10
|
+
super
|
11
|
+
@original_format = BMFF::Box.get_box(io, self)
|
12
|
+
add_child(@original_format)
|
13
|
+
unless eob?
|
14
|
+
@scheme_type_box = BMFF::Box.get_box(io, self)
|
15
|
+
add_child(@scheme_type_box)
|
16
|
+
unless eob?
|
17
|
+
@info = BMFF::Box.get_box(io, self)
|
18
|
+
add_child(@info)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
# vim: set expandtab tabstop=2 shiftwidth=2 softtabstop=2 autoindent:
|
3
|
+
|
4
|
+
class BMFF::Box::ProtectionSystemSpecificHeader < BMFF::Box::Full
|
5
|
+
attr_accessor :system_id, :data_size, :data
|
6
|
+
register_uuid_box "d08a4f18-10f3-4a82-b6c8-32d8aba183d3"
|
7
|
+
|
8
|
+
def parse_data
|
9
|
+
super
|
10
|
+
@system_id = io.get_uuid
|
11
|
+
@data_size = io.get_uint32
|
12
|
+
@data = io.get_byte(@data_size)
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
# vim: set expandtab tabstop=2 shiftwidth=2 softtabstop=2 autoindent:
|
3
|
+
|
4
|
+
class BMFF::Box::SampleEncryption < BMFF::Box::Full
|
5
|
+
attr_accessor :algorithm_id, :iv_size, :kid, :sample_count, :samples
|
6
|
+
register_uuid_box "a2394f52-5a9b-4f14-a244-6c427c648df4"
|
7
|
+
|
8
|
+
DEFAULT_IV_SIZE = 8
|
9
|
+
|
10
|
+
class Sample
|
11
|
+
attr_accessor :initialization_vector, :number_of_entries, :entries
|
12
|
+
end
|
13
|
+
|
14
|
+
class Entry
|
15
|
+
attr_accessor :bytes_of_clear_data, :bytes_of_encrypted_data
|
16
|
+
end
|
17
|
+
|
18
|
+
def parse_data
|
19
|
+
super
|
20
|
+
if flags & 0x01 > 0
|
21
|
+
@algorithm_id = io.get_uint24
|
22
|
+
@iv_size = io.get_uint8
|
23
|
+
@kid = io.get_uuid
|
24
|
+
end
|
25
|
+
@sample_count = io.get_uint32
|
26
|
+
@samples = []
|
27
|
+
@sample_count.times do
|
28
|
+
sample = Sample.new
|
29
|
+
if @iv_size
|
30
|
+
iv_size_to_read = @iv_size
|
31
|
+
else
|
32
|
+
iv_size_to_read = default_iv_size
|
33
|
+
end
|
34
|
+
sample.initialization_vector = io.get_byte(iv_size_to_read)
|
35
|
+
if flags & 0x02 > 0
|
36
|
+
sample.number_of_entries = io.get_uint16
|
37
|
+
sample.entries = []
|
38
|
+
sample.number_of_entries.times do
|
39
|
+
entry = Entry.new
|
40
|
+
entry.bytes_of_clear_data = io.get_uint16
|
41
|
+
entry.bytes_of_encrypted_data = io.get_uint32
|
42
|
+
sample.entries << entry
|
43
|
+
end
|
44
|
+
end
|
45
|
+
@samples << sample
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def default_iv_size
|
50
|
+
if track_encryption = find_track_encryption
|
51
|
+
track_encryption.default_iv_size
|
52
|
+
else
|
53
|
+
DEFAULT_IV_SIZE
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
@@cached_root_object_id = nil
|
58
|
+
@@cached_track_encryption = nil
|
59
|
+
|
60
|
+
def find_track_encryption
|
61
|
+
root_container = root
|
62
|
+
unless root_container.object_id == @@cached_root_object_id
|
63
|
+
@@cached_root_object_id = root_container.object_id
|
64
|
+
@@cached_track_encryption = root_container.select_descendants(BMFF::Box::TrackEncryption).first
|
65
|
+
end
|
66
|
+
@@cached_track_encryption
|
67
|
+
end
|
68
|
+
|
69
|
+
private :default_iv_size, :find_track_encryption
|
70
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
# vim: set expandtab tabstop=2 shiftwidth=2 softtabstop=2 autoindent:
|
3
|
+
|
4
|
+
class BMFF::Box::SchemeInformation < BMFF::Box::Base
|
5
|
+
register_box "schi"
|
6
|
+
include(BMFF::Box::Container)
|
7
|
+
|
8
|
+
def parse_data
|
9
|
+
super
|
10
|
+
parse_children
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
# vim: set expandtab tabstop=2 shiftwidth=2 softtabstop=2 autoindent:
|
3
|
+
|
4
|
+
class BMFF::Box::SchemeType < BMFF::Box::Full
|
5
|
+
attr_accessor :scheme_type, :scheme_version, :scheme_url
|
6
|
+
register_box "schm"
|
7
|
+
|
8
|
+
def parse_data
|
9
|
+
super
|
10
|
+
@scheme_type = io.get_ascii(4)
|
11
|
+
@scheme_version = io.get_uint32
|
12
|
+
if @flags & 0x01 > 0
|
13
|
+
@scheme_url = io.get_null_terminated_string
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
# vim: set expandtab tabstop=2 shiftwidth=2 softtabstop=2 autoindent:
|
3
|
+
|
4
|
+
class BMFF::Box::TrackEncryption < BMFF::Box::Full
|
5
|
+
attr_accessor :default_algorithm_id, :default_iv_size, :default_kid
|
6
|
+
register_uuid_box "8974dbce-7be7-4c51-84f9-7148f9882554"
|
7
|
+
|
8
|
+
def parse_data
|
9
|
+
super
|
10
|
+
@default_algorithm_id = io.get_uint24
|
11
|
+
@default_iv_size = io.get_uint8
|
12
|
+
@default_kid = io.get_uuid
|
13
|
+
end
|
14
|
+
end
|
data/lib/bmff/box.rb
CHANGED
@@ -83,33 +83,58 @@ require "bmff/box/level_assignment"
|
|
83
83
|
require "bmff/box/user_data"
|
84
84
|
require "bmff/box/copyright"
|
85
85
|
require "bmff/box/track_selection"
|
86
|
+
require "bmff/box/protection_scheme_info"
|
87
|
+
require "bmff/box/original_format"
|
88
|
+
require "bmff/box/scheme_type"
|
89
|
+
require "bmff/box/scheme_information"
|
90
|
+
|
91
|
+
# UUID boxes
|
92
|
+
require "bmff/box/protection_system_specific_header"
|
93
|
+
require "bmff/box/track_encryption"
|
94
|
+
require "bmff/box/sample_encryption"
|
86
95
|
|
87
96
|
module BMFF::Box
|
88
97
|
def self.get_box(io, parent, box_class = nil)
|
89
98
|
offset = io.pos
|
90
99
|
size = io.get_uint32
|
91
100
|
type = io.get_ascii(4)
|
101
|
+
largesize = nil
|
102
|
+
if size == 1
|
103
|
+
largesize = io.get_uint64
|
104
|
+
end
|
105
|
+
usertype = nil
|
106
|
+
if type == 'uuid'
|
107
|
+
usertype = io.get_uuid
|
108
|
+
end
|
92
109
|
|
93
110
|
if box_class
|
94
111
|
klass = box_class
|
95
112
|
else
|
96
|
-
|
113
|
+
if usertype
|
114
|
+
klass = get_uuid_box_class(usertype)
|
115
|
+
else
|
116
|
+
klass = get_box_class(type)
|
117
|
+
end
|
97
118
|
end
|
119
|
+
klass ||= BMFF::Box::Unknown
|
98
120
|
box = klass.new
|
99
121
|
box.io = io
|
100
122
|
box.offset = offset
|
101
123
|
box.parent = parent
|
102
124
|
box.size = size
|
103
125
|
box.type = type
|
126
|
+
box.largesize = largesize
|
127
|
+
box.usertype = usertype
|
104
128
|
|
105
129
|
box.parse
|
106
130
|
return box
|
107
131
|
end
|
108
132
|
|
109
133
|
def self.get_box_class(type)
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
134
|
+
Map.get_box_class(type)
|
135
|
+
end
|
136
|
+
|
137
|
+
def self.get_uuid_box_class(uuid)
|
138
|
+
Map.get_uuid_box_class(uuid)
|
114
139
|
end
|
115
140
|
end
|
data/lib/bmff/version.rb
CHANGED
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
# vim: set expandtab tabstop=2 shiftwidth=2 softtabstop=2 autoindent:
|
3
|
+
|
4
|
+
require_relative '../../minitest_helper'
|
5
|
+
require 'bmff/box'
|
6
|
+
require 'stringio'
|
7
|
+
|
8
|
+
class TestBMFFBoxOriginalFormat < MiniTest::Unit::TestCase
|
9
|
+
def test_parse
|
10
|
+
io = StringIO.new("", "r+:ascii-8bit")
|
11
|
+
io.extend(BMFF::BinaryAccessor)
|
12
|
+
io.write_uint32(0)
|
13
|
+
io.write_ascii("frma")
|
14
|
+
io.write_ascii("mp4v") # data_format
|
15
|
+
size = io.pos
|
16
|
+
io.pos = 0
|
17
|
+
io.write_uint32(size)
|
18
|
+
io.pos = 0
|
19
|
+
|
20
|
+
box = BMFF::Box.get_box(io, nil)
|
21
|
+
assert_instance_of(BMFF::Box::OriginalFormat, box)
|
22
|
+
assert_equal(size, box.actual_size)
|
23
|
+
assert_equal("frma", box.type)
|
24
|
+
assert_equal("mp4v", box.data_format)
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
# vim: set expandtab tabstop=2 shiftwidth=2 softtabstop=2 autoindent:
|
3
|
+
|
4
|
+
require_relative '../../minitest_helper'
|
5
|
+
require 'bmff/box'
|
6
|
+
require 'stringio'
|
7
|
+
|
8
|
+
class TestBMFFBoxProtectionSchemeInfo < MiniTest::Unit::TestCase
|
9
|
+
def test_parse_only_original_format
|
10
|
+
io = StringIO.new("", "r+:ascii-8bit")
|
11
|
+
io.extend(BMFF::BinaryAccessor)
|
12
|
+
io.write_uint32(0)
|
13
|
+
io.write_ascii("sinf")
|
14
|
+
|
15
|
+
# original_format
|
16
|
+
io.write_uint32(12)
|
17
|
+
io.write_ascii("frma")
|
18
|
+
io.write_ascii("mp4v") # data_format
|
19
|
+
|
20
|
+
size = io.pos
|
21
|
+
io.pos = 0
|
22
|
+
io.write_uint32(size)
|
23
|
+
io.pos = 0
|
24
|
+
|
25
|
+
box = BMFF::Box.get_box(io, nil)
|
26
|
+
assert_instance_of(BMFF::Box::ProtectionSchemeInfo, box)
|
27
|
+
assert_equal(size, box.actual_size)
|
28
|
+
assert_equal("sinf", box.type)
|
29
|
+
assert_instance_of(BMFF::Box::OriginalFormat, box.original_format)
|
30
|
+
assert_equal("mp4v", box.original_format.data_format)
|
31
|
+
assert_equal(1, box.children.count)
|
32
|
+
assert_nil(box.scheme_type_box)
|
33
|
+
assert_nil(box.info)
|
34
|
+
assert(box.container?)
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_parse_with_scheme_type_info
|
38
|
+
io = StringIO.new("", "r+:ascii-8bit")
|
39
|
+
io.extend(BMFF::BinaryAccessor)
|
40
|
+
io.write_uint32(0)
|
41
|
+
io.write_ascii("sinf")
|
42
|
+
|
43
|
+
# original_format
|
44
|
+
io.write_uint32(12)
|
45
|
+
io.write_ascii("frma")
|
46
|
+
io.write_ascii("mp4v") # data_format
|
47
|
+
|
48
|
+
# scheme_type_box
|
49
|
+
io.write_uint32(20)
|
50
|
+
io.write_ascii("schm")
|
51
|
+
io.write_uint8(0) # version
|
52
|
+
io.write_uint24(0) # flags
|
53
|
+
io.write_ascii("abcd") # scheme_type
|
54
|
+
io.write_uint32(1) # scheme_version
|
55
|
+
|
56
|
+
# info
|
57
|
+
io.write_uint32(8)
|
58
|
+
io.write_ascii("schi")
|
59
|
+
|
60
|
+
size = io.pos
|
61
|
+
io.pos = 0
|
62
|
+
io.write_uint32(size)
|
63
|
+
io.pos = 0
|
64
|
+
|
65
|
+
box = BMFF::Box.get_box(io, nil)
|
66
|
+
assert_instance_of(BMFF::Box::ProtectionSchemeInfo, box)
|
67
|
+
assert_equal(size, box.actual_size)
|
68
|
+
assert_equal("sinf", box.type)
|
69
|
+
|
70
|
+
assert_instance_of(BMFF::Box::OriginalFormat, box.original_format)
|
71
|
+
assert_equal("mp4v", box.original_format.data_format)
|
72
|
+
|
73
|
+
assert_instance_of(BMFF::Box::SchemeType, box.scheme_type_box)
|
74
|
+
assert_equal("abcd", box.scheme_type_box.scheme_type)
|
75
|
+
assert_equal(1, box.scheme_type_box.scheme_version)
|
76
|
+
|
77
|
+
assert_instance_of(BMFF::Box::SchemeInformation, box.info)
|
78
|
+
|
79
|
+
assert_equal(3, box.children.count)
|
80
|
+
assert(box.container?)
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
# vim: set expandtab tabstop=2 shiftwidth=2 softtabstop=2 autoindent:
|
3
|
+
|
4
|
+
require_relative '../../minitest_helper'
|
5
|
+
require 'bmff/box'
|
6
|
+
require 'stringio'
|
7
|
+
|
8
|
+
class TestBMFFBoxProtectionSystemSpecificHeader < MiniTest::Unit::TestCase
|
9
|
+
def test_parse_playready
|
10
|
+
io = StringIO.new("", "r+:ascii-8bit")
|
11
|
+
io.extend(BMFF::BinaryAccessor)
|
12
|
+
io.write_uint32(0)
|
13
|
+
io.write_ascii("uuid")
|
14
|
+
io.write_uuid("d08a4f18-10f3-4a82-b6c8-32d8aba183d3") # uuid
|
15
|
+
io.write_uint8(0) # version
|
16
|
+
io.write_uint24(0) # flags
|
17
|
+
|
18
|
+
io.write_uuid("9a04f079-9840-4286-ab92-e65be0885f95") # system_id (PlayReady)
|
19
|
+
io.write_uint32(16) # data_size
|
20
|
+
io.write_byte("datadatadatadata") # data
|
21
|
+
|
22
|
+
size = io.pos
|
23
|
+
io.pos = 0
|
24
|
+
io.write_uint32(size)
|
25
|
+
io.pos = 0
|
26
|
+
|
27
|
+
box = BMFF::Box.get_box(io, nil)
|
28
|
+
assert_instance_of(BMFF::Box::ProtectionSystemSpecificHeader, box)
|
29
|
+
assert_equal(size, box.actual_size)
|
30
|
+
assert_equal("uuid", box.type)
|
31
|
+
assert_equal("d08a4f18-10f3-4a82-b6c8-32d8aba183d3", box.usertype.to_s)
|
32
|
+
assert_equal(0, box.version)
|
33
|
+
assert_equal(0, box.flags)
|
34
|
+
assert_equal("9a04f079-9840-4286-ab92-e65be0885f95", box.system_id.to_s)
|
35
|
+
assert_equal(16, box.data_size)
|
36
|
+
assert_equal("datadatadatadata", box.data)
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,177 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
# vim: set expandtab tabstop=2 shiftwidth=2 softtabstop=2 autoindent:
|
3
|
+
|
4
|
+
require_relative '../../minitest_helper'
|
5
|
+
require 'bmff/box'
|
6
|
+
require 'stringio'
|
7
|
+
|
8
|
+
class TestBMFFBoxSampleEncryption < MiniTest::Unit::TestCase
|
9
|
+
def get_dummy_parent
|
10
|
+
io = StringIO.new("", "r+:ascii-8bit")
|
11
|
+
io.extend(BMFF::BinaryAccessor)
|
12
|
+
# Track
|
13
|
+
io.write_uint32(56)
|
14
|
+
io.write_ascii("trak")
|
15
|
+
# Track Encryption
|
16
|
+
io.write_uint32(48)
|
17
|
+
io.write_ascii("uuid")
|
18
|
+
io.write_uuid("8974dbce-7be7-4c51-84f9-7148f9882554") # uuid
|
19
|
+
io.write_uint8(0) # version
|
20
|
+
io.write_uint24(0) # flags
|
21
|
+
|
22
|
+
io.write_uint24(1) # default_algorithm_id
|
23
|
+
io.write_uint8(8) # default_iv_size
|
24
|
+
io.write_uuid("00010203-0405-0607-0809-0a0b0c0d0e0f") # default_kid
|
25
|
+
io.pos = 0
|
26
|
+
BMFF::FileContainer.parse(io)
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_parse_flags_0
|
30
|
+
io = StringIO.new("", "r+:ascii-8bit")
|
31
|
+
io.extend(BMFF::BinaryAccessor)
|
32
|
+
io.write_uint32(0)
|
33
|
+
io.write_ascii("uuid")
|
34
|
+
io.write_uuid("a2394f52-5a9b-4f14-a244-6c427c648df4") # uuid
|
35
|
+
io.write_uint8(0) # version
|
36
|
+
io.write_uint24(0) # flags
|
37
|
+
|
38
|
+
io.write_uint32(3) # sample_count
|
39
|
+
io.write_byte("01234567") # initialization_vector
|
40
|
+
io.write_byte("89ABCDEF") # initialization_vector
|
41
|
+
io.write_byte("GHIJKLMN") # initialization_vector
|
42
|
+
|
43
|
+
size = io.pos
|
44
|
+
io.pos = 0
|
45
|
+
io.write_uint32(size)
|
46
|
+
io.pos = 0
|
47
|
+
|
48
|
+
box = BMFF::Box.get_box(io, get_dummy_parent)
|
49
|
+
assert_instance_of(BMFF::Box::SampleEncryption, box)
|
50
|
+
assert_equal(size, box.actual_size)
|
51
|
+
assert_equal("uuid", box.type)
|
52
|
+
assert_equal("a2394f52-5a9b-4f14-a244-6c427c648df4", box.usertype.to_s)
|
53
|
+
assert_equal(0, box.version)
|
54
|
+
assert_equal(0, box.flags)
|
55
|
+
assert_nil(box.algorithm_id)
|
56
|
+
assert_nil(box.iv_size)
|
57
|
+
assert_nil(box.kid)
|
58
|
+
assert_equal(3, box.sample_count)
|
59
|
+
assert_equal("01234567", box.samples[0].initialization_vector)
|
60
|
+
assert_nil(box.samples[0].number_of_entries)
|
61
|
+
assert_equal("89ABCDEF", box.samples[1].initialization_vector)
|
62
|
+
assert_nil(box.samples[1].number_of_entries)
|
63
|
+
assert_equal("GHIJKLMN", box.samples[2].initialization_vector)
|
64
|
+
assert_nil(box.samples[2].number_of_entries)
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_parse_flags_1
|
68
|
+
io = StringIO.new("", "r+:ascii-8bit")
|
69
|
+
io.extend(BMFF::BinaryAccessor)
|
70
|
+
io.write_uint32(0)
|
71
|
+
io.write_ascii("uuid")
|
72
|
+
io.write_uuid("a2394f52-5a9b-4f14-a244-6c427c648df4") # uuid
|
73
|
+
io.write_uint8(0) # version
|
74
|
+
io.write_uint24(1) # flags
|
75
|
+
|
76
|
+
io.write_uint24(2) # algorithm_id
|
77
|
+
io.write_uint8(16) # iv_size
|
78
|
+
io.write_uuid("00010203-0405-0607-0809-0a0b0c0d0e0f") # kid
|
79
|
+
io.write_uint32(3) # sample_count
|
80
|
+
io.write_byte("0123456789ABCDEF") # initialization_vector
|
81
|
+
io.write_byte("GHIJKLMNOPQRSTUV") # initialization_vector
|
82
|
+
io.write_byte("WXYZabcdefghijkl") # initialization_vector
|
83
|
+
|
84
|
+
size = io.pos
|
85
|
+
io.pos = 0
|
86
|
+
io.write_uint32(size)
|
87
|
+
io.pos = 0
|
88
|
+
|
89
|
+
box = BMFF::Box.get_box(io, nil)
|
90
|
+
assert_instance_of(BMFF::Box::SampleEncryption, box)
|
91
|
+
assert_equal(size, box.actual_size)
|
92
|
+
assert_equal("uuid", box.type)
|
93
|
+
assert_equal("a2394f52-5a9b-4f14-a244-6c427c648df4", box.usertype.to_s)
|
94
|
+
assert_equal(0, box.version)
|
95
|
+
assert_equal(1, box.flags)
|
96
|
+
assert_equal(2, box.algorithm_id)
|
97
|
+
assert_equal(16, box.iv_size)
|
98
|
+
assert_equal("00010203-0405-0607-0809-0a0b0c0d0e0f", box.kid.to_s)
|
99
|
+
assert_equal(3, box.sample_count)
|
100
|
+
assert_equal("0123456789ABCDEF", box.samples[0].initialization_vector)
|
101
|
+
assert_nil(box.samples[0].number_of_entries)
|
102
|
+
assert_equal("GHIJKLMNOPQRSTUV", box.samples[1].initialization_vector)
|
103
|
+
assert_nil(box.samples[1].number_of_entries)
|
104
|
+
assert_equal("WXYZabcdefghijkl", box.samples[2].initialization_vector)
|
105
|
+
assert_nil(box.samples[2].number_of_entries)
|
106
|
+
end
|
107
|
+
|
108
|
+
def test_parse_flags_2
|
109
|
+
io = StringIO.new("", "r+:ascii-8bit")
|
110
|
+
io.extend(BMFF::BinaryAccessor)
|
111
|
+
io.write_uint32(0)
|
112
|
+
io.write_ascii("uuid")
|
113
|
+
io.write_uuid("a2394f52-5a9b-4f14-a244-6c427c648df4") # uuid
|
114
|
+
io.write_uint8(0) # version
|
115
|
+
io.write_uint24(2) # flags
|
116
|
+
|
117
|
+
io.write_uint32(3) # sample_count
|
118
|
+
io.write_byte("01234567") # initialization_vector
|
119
|
+
io.write_uint16(3) # number_of_entries
|
120
|
+
io.write_uint16(255) # bytes_of_clear_data
|
121
|
+
io.write_uint32(16777215) # bytes_of_encrypted_data
|
122
|
+
io.write_uint16(4095) # bytes_of_clear_data
|
123
|
+
io.write_uint32(268435455) # bytes_of_encrypted_data
|
124
|
+
io.write_uint16(65535) # bytes_of_clear_data
|
125
|
+
io.write_uint32(4294967295) # bytes_of_encrypted_data
|
126
|
+
|
127
|
+
io.write_byte("89ABCDEF") # initialization_vector
|
128
|
+
io.write_uint16(2) # number_of_entries
|
129
|
+
io.write_uint16(255) # bytes_of_clear_data
|
130
|
+
io.write_uint32(16777215) # bytes_of_encrypted_data
|
131
|
+
io.write_uint16(4095) # bytes_of_clear_data
|
132
|
+
io.write_uint32(268435455) # bytes_of_encrypted_data
|
133
|
+
|
134
|
+
io.write_byte("GHIJKLMN") # initialization_vector
|
135
|
+
io.write_uint16(1) # number_of_entries
|
136
|
+
io.write_uint16(255) # bytes_of_clear_data
|
137
|
+
io.write_uint32(16777215) # bytes_of_encrypted_data
|
138
|
+
|
139
|
+
size = io.pos
|
140
|
+
io.pos = 0
|
141
|
+
io.write_uint32(size)
|
142
|
+
io.pos = 0
|
143
|
+
|
144
|
+
box = BMFF::Box.get_box(io, get_dummy_parent)
|
145
|
+
assert_instance_of(BMFF::Box::SampleEncryption, box)
|
146
|
+
assert_equal(size, box.actual_size)
|
147
|
+
assert_equal("uuid", box.type)
|
148
|
+
assert_equal("a2394f52-5a9b-4f14-a244-6c427c648df4", box.usertype.to_s)
|
149
|
+
assert_equal(0, box.version)
|
150
|
+
assert_equal(2, box.flags)
|
151
|
+
assert_nil(box.algorithm_id)
|
152
|
+
assert_nil(box.iv_size)
|
153
|
+
assert_nil(box.kid)
|
154
|
+
assert_equal(3, box.sample_count)
|
155
|
+
assert_equal("01234567", box.samples[0].initialization_vector)
|
156
|
+
assert_equal(3, box.samples[0].number_of_entries)
|
157
|
+
assert_equal(3, box.samples[0].entries.count)
|
158
|
+
assert_equal(255, box.samples[0].entries[0].bytes_of_clear_data)
|
159
|
+
assert_equal(16777215, box.samples[0].entries[0].bytes_of_encrypted_data)
|
160
|
+
assert_equal(4095, box.samples[0].entries[1].bytes_of_clear_data)
|
161
|
+
assert_equal(268435455, box.samples[0].entries[1].bytes_of_encrypted_data)
|
162
|
+
assert_equal(65535, box.samples[0].entries[2].bytes_of_clear_data)
|
163
|
+
assert_equal(4294967295, box.samples[0].entries[2].bytes_of_encrypted_data)
|
164
|
+
assert_equal("89ABCDEF", box.samples[1].initialization_vector)
|
165
|
+
assert_equal(2, box.samples[1].number_of_entries)
|
166
|
+
assert_equal(2, box.samples[1].entries.count)
|
167
|
+
assert_equal(255, box.samples[1].entries[0].bytes_of_clear_data)
|
168
|
+
assert_equal(16777215, box.samples[1].entries[0].bytes_of_encrypted_data)
|
169
|
+
assert_equal(4095, box.samples[1].entries[1].bytes_of_clear_data)
|
170
|
+
assert_equal(268435455, box.samples[1].entries[1].bytes_of_encrypted_data)
|
171
|
+
assert_equal("GHIJKLMN", box.samples[2].initialization_vector)
|
172
|
+
assert_equal(1, box.samples[2].number_of_entries)
|
173
|
+
assert_equal(1, box.samples[2].entries.count)
|
174
|
+
assert_equal(255, box.samples[2].entries[0].bytes_of_clear_data)
|
175
|
+
assert_equal(16777215, box.samples[2].entries[0].bytes_of_encrypted_data)
|
176
|
+
end
|
177
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
# vim: set expandtab tabstop=2 shiftwidth=2 softtabstop=2 autoindent:
|
3
|
+
|
4
|
+
require_relative '../../minitest_helper'
|
5
|
+
require 'bmff/box'
|
6
|
+
require 'stringio'
|
7
|
+
|
8
|
+
class TestBMFFBoxSchemeInformation < MiniTest::Unit::TestCase
|
9
|
+
def test_parse
|
10
|
+
io = StringIO.new("", "r+:ascii-8bit")
|
11
|
+
io.extend(BMFF::BinaryAccessor)
|
12
|
+
io.write_uint32(0)
|
13
|
+
io.write_ascii("schi")
|
14
|
+
size = io.pos
|
15
|
+
io.pos = 0
|
16
|
+
io.write_uint32(size)
|
17
|
+
io.pos = 0
|
18
|
+
|
19
|
+
box = BMFF::Box.get_box(io, nil)
|
20
|
+
assert_instance_of(BMFF::Box::SchemeInformation, box)
|
21
|
+
assert_equal(size, box.actual_size)
|
22
|
+
assert_equal("schi", box.type)
|
23
|
+
assert_equal([], box.children)
|
24
|
+
assert(box.container?)
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
# vim: set expandtab tabstop=2 shiftwidth=2 softtabstop=2 autoindent:
|
3
|
+
|
4
|
+
require_relative '../../minitest_helper'
|
5
|
+
require 'bmff/box'
|
6
|
+
require 'stringio'
|
7
|
+
|
8
|
+
class TestBMFFBoxSchemeType < MiniTest::Unit::TestCase
|
9
|
+
def test_parse
|
10
|
+
io = StringIO.new("", "r+:ascii-8bit")
|
11
|
+
io.extend(BMFF::BinaryAccessor)
|
12
|
+
io.write_uint32(0)
|
13
|
+
io.write_ascii("schm")
|
14
|
+
io.write_uint8(0) # version
|
15
|
+
io.write_uint24(0) # flags
|
16
|
+
io.write_ascii("abcd") # scheme_type
|
17
|
+
io.write_uint32(1) # scheme_version
|
18
|
+
size = io.pos
|
19
|
+
io.pos = 0
|
20
|
+
io.write_uint32(size)
|
21
|
+
io.pos = 0
|
22
|
+
|
23
|
+
box = BMFF::Box.get_box(io, nil)
|
24
|
+
assert_instance_of(BMFF::Box::SchemeType, box)
|
25
|
+
assert_equal(size, box.actual_size)
|
26
|
+
assert_equal("schm", box.type)
|
27
|
+
assert_equal(0, box.version)
|
28
|
+
assert_equal(0, box.flags)
|
29
|
+
assert_equal("abcd", box.scheme_type)
|
30
|
+
assert_equal(1, box.scheme_version)
|
31
|
+
assert_nil(box.scheme_url)
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_parse_with_scheme_url
|
35
|
+
io = StringIO.new("", "r+:ascii-8bit")
|
36
|
+
io.extend(BMFF::BinaryAccessor)
|
37
|
+
io.write_uint32(0)
|
38
|
+
io.write_ascii("schm")
|
39
|
+
io.write_uint8(0) # version
|
40
|
+
io.write_uint24(1) # flags
|
41
|
+
io.write_ascii("abcd") # scheme_type
|
42
|
+
io.write_uint32(1) # scheme_version
|
43
|
+
io.write_null_terminated_string("http://example.com/") # scheme_url
|
44
|
+
size = io.pos
|
45
|
+
io.pos = 0
|
46
|
+
io.write_uint32(size)
|
47
|
+
io.pos = 0
|
48
|
+
|
49
|
+
box = BMFF::Box.get_box(io, nil)
|
50
|
+
assert_instance_of(BMFF::Box::SchemeType, box)
|
51
|
+
assert_equal(size, box.actual_size)
|
52
|
+
assert_equal("schm", box.type)
|
53
|
+
assert_equal(0, box.version)
|
54
|
+
assert_equal(1, box.flags)
|
55
|
+
assert_equal("abcd", box.scheme_type)
|
56
|
+
assert_equal(1, box.scheme_version)
|
57
|
+
assert_equal("http://example.com/", box.scheme_url)
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
# vim: set expandtab tabstop=2 shiftwidth=2 softtabstop=2 autoindent:
|
3
|
+
|
4
|
+
require_relative '../../minitest_helper'
|
5
|
+
require 'bmff/box'
|
6
|
+
require 'stringio'
|
7
|
+
|
8
|
+
class TestBMFFBoxTrackEncryption < MiniTest::Unit::TestCase
|
9
|
+
def test_parse_flags_0
|
10
|
+
io = StringIO.new("", "r+:ascii-8bit")
|
11
|
+
io.extend(BMFF::BinaryAccessor)
|
12
|
+
io.write_uint32(0)
|
13
|
+
io.write_ascii("uuid")
|
14
|
+
io.write_uuid("8974dbce-7be7-4c51-84f9-7148f9882554") # uuid
|
15
|
+
io.write_uint8(0) # version
|
16
|
+
io.write_uint24(0) # flags
|
17
|
+
|
18
|
+
io.write_uint24(1) # default_algorithm_id
|
19
|
+
io.write_uint8(8) # default_iv_size
|
20
|
+
io.write_uuid("00010203-0405-0607-0809-0a0b0c0d0e0f") # default_kid
|
21
|
+
|
22
|
+
size = io.pos
|
23
|
+
io.pos = 0
|
24
|
+
io.write_uint32(size)
|
25
|
+
io.pos = 0
|
26
|
+
|
27
|
+
box = BMFF::Box.get_box(io, nil)
|
28
|
+
assert_instance_of(BMFF::Box::TrackEncryption, box)
|
29
|
+
assert_equal(size, box.actual_size)
|
30
|
+
assert_equal("uuid", box.type)
|
31
|
+
assert_equal("8974dbce-7be7-4c51-84f9-7148f9882554", box.usertype.to_s)
|
32
|
+
assert_equal(0, box.version)
|
33
|
+
assert_equal(0, box.flags)
|
34
|
+
assert_equal(1, box.default_algorithm_id)
|
35
|
+
assert_equal(8, box.default_iv_size)
|
36
|
+
assert_equal("00010203-0405-0607-0809-0a0b0c0d0e0f", box.default_kid.to_s)
|
37
|
+
end
|
38
|
+
end
|
@@ -798,8 +798,54 @@ class TestBMFFBinaryAccessor < MiniTest::Unit::TestCase
|
|
798
798
|
def test_get_uuid
|
799
799
|
io = StringIO.new("\x00\x01\x02\x03\x04\x05\x06\x07\x80\x90\xA0\xB0\xC0\xD0\xE0\xF0", "r:ascii-8bit")
|
800
800
|
io.extend(BMFF::BinaryAccessor)
|
801
|
-
|
801
|
+
uuid = io.get_uuid
|
802
|
+
assert_kind_of(UUIDTools::UUID, uuid)
|
803
|
+
assert_equal("00010203-0405-0607-8090-a0b0c0d0e0f0", uuid.to_s)
|
802
804
|
assert(io.eof?)
|
803
805
|
end
|
804
806
|
|
807
|
+
def test_write_uuid_string
|
808
|
+
io = StringIO.new("", "r+:ascii-8bit")
|
809
|
+
io.extend(BMFF::BinaryAccessor)
|
810
|
+
io.write_uuid("00010203-0405-0607-8090-a0b0c0d0e0f0")
|
811
|
+
io.pos = 0
|
812
|
+
assert_equal("\x00\x01\x02\x03\x04\x05\x06\x07\x80\x90\xA0\xB0\xC0\xD0\xE0\xF0", io.read)
|
813
|
+
end
|
814
|
+
|
815
|
+
def test_write_uuid_object
|
816
|
+
io = StringIO.new("", "r+:ascii-8bit")
|
817
|
+
io.extend(BMFF::BinaryAccessor)
|
818
|
+
io.write_uuid(UUIDTools::UUID.parse("00010203-0405-0607-8090-a0b0c0d0e0f0"))
|
819
|
+
io.pos = 0
|
820
|
+
assert_equal("\x00\x01\x02\x03\x04\x05\x06\x07\x80\x90\xA0\xB0\xC0\xD0\xE0\xF0", io.read)
|
821
|
+
end
|
822
|
+
|
823
|
+
def test_write_uuid_invalid_value
|
824
|
+
io = StringIO.new("", "r+:ascii-8bit")
|
825
|
+
io.extend(BMFF::BinaryAccessor)
|
826
|
+
assert_raises(TypeError) do
|
827
|
+
io.write_uuid(nil)
|
828
|
+
end
|
829
|
+
assert_raises(TypeError) do
|
830
|
+
io.write_uuid(0)
|
831
|
+
end
|
832
|
+
assert_raises(TypeError) do
|
833
|
+
io.write_uuid(0.1)
|
834
|
+
end
|
835
|
+
assert_raises(TypeError) do
|
836
|
+
io.write_uuid(true)
|
837
|
+
end
|
838
|
+
assert_raises(TypeError) do
|
839
|
+
io.write_uuid(false)
|
840
|
+
end
|
841
|
+
assert_raises(TypeError) do
|
842
|
+
io.write_uuid(:uuid)
|
843
|
+
end
|
844
|
+
assert_raises(ArgumentError) do
|
845
|
+
io.write_uuid("ZZZZZZZZ-YYYY-XXXX-WWWW-VVVVVVVVVVVV")
|
846
|
+
end
|
847
|
+
assert_raises(ArgumentError) do
|
848
|
+
io.write_uuid("0")
|
849
|
+
end
|
850
|
+
end
|
805
851
|
end
|
@@ -55,4 +55,13 @@ class TestBMFFFileContainer < MiniTest::Unit::TestCase
|
|
55
55
|
assert_equal(0, boxes.count)
|
56
56
|
end
|
57
57
|
end
|
58
|
+
|
59
|
+
def test_root
|
60
|
+
open(get_sample_file_path(SAMPLE_FILE_COMMON_MP4), "rb:ascii-8bit") do |f|
|
61
|
+
file_container = BMFF::FileContainer.parse(f)
|
62
|
+
assert_kind_of(BMFF::FileContainer, file_container)
|
63
|
+
stco = file_container.select_descendants(BMFF::Box::ChunkOffset).first
|
64
|
+
assert_same(file_container, stco.root)
|
65
|
+
end
|
66
|
+
end
|
58
67
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bmff
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,8 +9,24 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-06-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: uuidtools
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
14
30
|
- !ruby/object:Gem::Dependency
|
15
31
|
name: bundler
|
16
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -51,6 +67,8 @@ extensions: []
|
|
51
67
|
extra_rdoc_files: []
|
52
68
|
files:
|
53
69
|
- .gitignore
|
70
|
+
- .travis.yml
|
71
|
+
- CHANGELOG.md
|
54
72
|
- Gemfile
|
55
73
|
- LICENSE.txt
|
56
74
|
- README.md
|
@@ -100,17 +118,23 @@ files:
|
|
100
118
|
- lib/bmff/box/movie_fragment_random_access_offset.rb
|
101
119
|
- lib/bmff/box/movie_header.rb
|
102
120
|
- lib/bmff/box/null_media_header.rb
|
121
|
+
- lib/bmff/box/original_format.rb
|
103
122
|
- lib/bmff/box/padding_bits.rb
|
104
123
|
- lib/bmff/box/pixel_aspect_ratio.rb
|
105
124
|
- lib/bmff/box/progressive_download_info.rb
|
125
|
+
- lib/bmff/box/protection_scheme_info.rb
|
126
|
+
- lib/bmff/box/protection_system_specific_header.rb
|
106
127
|
- lib/bmff/box/sample_auxiliary_information_offsets.rb
|
107
128
|
- lib/bmff/box/sample_auxiliary_information_sizes.rb
|
108
129
|
- lib/bmff/box/sample_dependency_type.rb
|
109
130
|
- lib/bmff/box/sample_description.rb
|
131
|
+
- lib/bmff/box/sample_encryption.rb
|
110
132
|
- lib/bmff/box/sample_entry.rb
|
111
133
|
- lib/bmff/box/sample_size.rb
|
112
134
|
- lib/bmff/box/sample_table.rb
|
113
135
|
- lib/bmff/box/sample_to_chunk.rb
|
136
|
+
- lib/bmff/box/scheme_information.rb
|
137
|
+
- lib/bmff/box/scheme_type.rb
|
114
138
|
- lib/bmff/box/shadow_sync_sample.rb
|
115
139
|
- lib/bmff/box/sound_media_header.rb
|
116
140
|
- lib/bmff/box/sub_sample_information.rb
|
@@ -118,6 +142,7 @@ files:
|
|
118
142
|
- lib/bmff/box/text_meta_data_sample_entry.rb
|
119
143
|
- lib/bmff/box/time_to_sample.rb
|
120
144
|
- lib/bmff/box/track.rb
|
145
|
+
- lib/bmff/box/track_encryption.rb
|
121
146
|
- lib/bmff/box/track_extends.rb
|
122
147
|
- lib/bmff/box/track_fragment.rb
|
123
148
|
- lib/bmff/box/track_fragment_base_media_decode_time.rb
|
@@ -177,23 +202,30 @@ files:
|
|
177
202
|
- test/bmff/box/test_movie_fragment_random_access_offset.rb
|
178
203
|
- test/bmff/box/test_movie_header.rb
|
179
204
|
- test/bmff/box/test_null_media_header.rb
|
205
|
+
- test/bmff/box/test_original_format.rb
|
180
206
|
- test/bmff/box/test_padding_bits.rb
|
181
207
|
- test/bmff/box/test_pixel_aspect_ratio.rb
|
182
208
|
- test/bmff/box/test_progressive_download_info.rb
|
209
|
+
- test/bmff/box/test_protection_sheme_info.rb
|
210
|
+
- test/bmff/box/test_protection_system_specific_header.rb
|
183
211
|
- test/bmff/box/test_sample_auxiliary_information_offsets.rb
|
184
212
|
- test/bmff/box/test_sample_auxiliary_information_sizes.rb
|
185
213
|
- test/bmff/box/test_sample_dependency_type.rb
|
186
214
|
- test/bmff/box/test_sample_description.rb
|
215
|
+
- test/bmff/box/test_sample_encryption.rb
|
187
216
|
- test/bmff/box/test_sample_size.rb
|
188
217
|
- test/bmff/box/test_sample_table.rb
|
189
218
|
- test/bmff/box/test_sample_to_chunk.rb
|
190
219
|
- test/bmff/box/test_shadow_sync_sample.rb
|
220
|
+
- test/bmff/box/test_sheme_information.rb
|
221
|
+
- test/bmff/box/test_sheme_type.rb
|
191
222
|
- test/bmff/box/test_sound_media_header.rb
|
192
223
|
- test/bmff/box/test_sub_sample_information.rb
|
193
224
|
- test/bmff/box/test_sync_sample.rb
|
194
225
|
- test/bmff/box/test_text_meta_data_sample_entry.rb
|
195
226
|
- test/bmff/box/test_time_to_sample.rb
|
196
227
|
- test/bmff/box/test_track.rb
|
228
|
+
- test/bmff/box/test_track_encryption.rb
|
197
229
|
- test/bmff/box/test_track_extends.rb
|
198
230
|
- test/bmff/box/test_track_fragment.rb
|
199
231
|
- test/bmff/box/test_track_fragment_base_media_decode_time.rb
|
@@ -237,7 +269,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
237
269
|
version: '0'
|
238
270
|
segments:
|
239
271
|
- 0
|
240
|
-
hash: -
|
272
|
+
hash: -3184414125580658475
|
241
273
|
requirements: []
|
242
274
|
rubyforge_project:
|
243
275
|
rubygems_version: 1.8.25
|
@@ -282,23 +314,30 @@ test_files:
|
|
282
314
|
- test/bmff/box/test_movie_fragment_random_access_offset.rb
|
283
315
|
- test/bmff/box/test_movie_header.rb
|
284
316
|
- test/bmff/box/test_null_media_header.rb
|
317
|
+
- test/bmff/box/test_original_format.rb
|
285
318
|
- test/bmff/box/test_padding_bits.rb
|
286
319
|
- test/bmff/box/test_pixel_aspect_ratio.rb
|
287
320
|
- test/bmff/box/test_progressive_download_info.rb
|
321
|
+
- test/bmff/box/test_protection_sheme_info.rb
|
322
|
+
- test/bmff/box/test_protection_system_specific_header.rb
|
288
323
|
- test/bmff/box/test_sample_auxiliary_information_offsets.rb
|
289
324
|
- test/bmff/box/test_sample_auxiliary_information_sizes.rb
|
290
325
|
- test/bmff/box/test_sample_dependency_type.rb
|
291
326
|
- test/bmff/box/test_sample_description.rb
|
327
|
+
- test/bmff/box/test_sample_encryption.rb
|
292
328
|
- test/bmff/box/test_sample_size.rb
|
293
329
|
- test/bmff/box/test_sample_table.rb
|
294
330
|
- test/bmff/box/test_sample_to_chunk.rb
|
295
331
|
- test/bmff/box/test_shadow_sync_sample.rb
|
332
|
+
- test/bmff/box/test_sheme_information.rb
|
333
|
+
- test/bmff/box/test_sheme_type.rb
|
296
334
|
- test/bmff/box/test_sound_media_header.rb
|
297
335
|
- test/bmff/box/test_sub_sample_information.rb
|
298
336
|
- test/bmff/box/test_sync_sample.rb
|
299
337
|
- test/bmff/box/test_text_meta_data_sample_entry.rb
|
300
338
|
- test/bmff/box/test_time_to_sample.rb
|
301
339
|
- test/bmff/box/test_track.rb
|
340
|
+
- test/bmff/box/test_track_encryption.rb
|
302
341
|
- test/bmff/box/test_track_extends.rb
|
303
342
|
- test/bmff/box/test_track_fragment.rb
|
304
343
|
- test/bmff/box/test_track_fragment_base_media_decode_time.rb
|