bmff 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +25 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +183 -0
- data/Rakefile +9 -0
- data/bmff.gemspec +25 -0
- data/lib/bmff/binary_accessor.rb +186 -0
- data/lib/bmff/box/audio_sample_entry.rb +16 -0
- data/lib/bmff/box/base.rb +66 -0
- data/lib/bmff/box/bit_rate.rb +14 -0
- data/lib/bmff/box/chunk_large_offset.rb +16 -0
- data/lib/bmff/box/chunk_offset.rb +16 -0
- data/lib/bmff/box/clean_aperture.rb +20 -0
- data/lib/bmff/box/colour_information.rb +27 -0
- data/lib/bmff/box/compact_sample_size.rb +32 -0
- data/lib/bmff/box/composition_offset.rb +25 -0
- data/lib/bmff/box/composition_to_decode.rb +17 -0
- data/lib/bmff/box/container.rb +70 -0
- data/lib/bmff/box/copyright.rb +13 -0
- data/lib/bmff/box/data_entry_url.rb +12 -0
- data/lib/bmff/box/data_entry_urn.rb +13 -0
- data/lib/bmff/box/data_information.rb +12 -0
- data/lib/bmff/box/data_reference.rb +14 -0
- data/lib/bmff/box/degradation_priority.rb +19 -0
- data/lib/bmff/box/edit.rb +12 -0
- data/lib/bmff/box/edit_list.rb +27 -0
- data/lib/bmff/box/file_type.rb +17 -0
- data/lib/bmff/box/free_space.rb +6 -0
- data/lib/bmff/box/full.rb +11 -0
- data/lib/bmff/box/handler.rb +15 -0
- data/lib/bmff/box/hint_media_header.rb +16 -0
- data/lib/bmff/box/hint_sample_entry.rb +14 -0
- data/lib/bmff/box/level_assignment.rb +35 -0
- data/lib/bmff/box/map.rb +15 -0
- data/lib/bmff/box/media.rb +12 -0
- data/lib/bmff/box/media_data.rb +6 -0
- data/lib/bmff/box/media_header.rb +25 -0
- data/lib/bmff/box/media_information.rb +12 -0
- data/lib/bmff/box/meta_data_sample_entry.rb +5 -0
- data/lib/bmff/box/movie.rb +12 -0
- data/lib/bmff/box/movie_extends.rb +12 -0
- data/lib/bmff/box/movie_extends_header.rb +16 -0
- data/lib/bmff/box/movie_fragment.rb +12 -0
- data/lib/bmff/box/movie_fragment_header.rb +12 -0
- data/lib/bmff/box/movie_fragment_random_access.rb +12 -0
- data/lib/bmff/box/movie_fragment_random_access_offset.rb +12 -0
- data/lib/bmff/box/movie_header.rb +36 -0
- data/lib/bmff/box/null_media_header.rb +6 -0
- data/lib/bmff/box/padding_bits.rb +23 -0
- data/lib/bmff/box/pixel_aspect_ratio.rb +13 -0
- data/lib/bmff/box/progressive_download_info.rb +17 -0
- data/lib/bmff/box/sample_auxiliary_information_offsets.rb +24 -0
- data/lib/bmff/box/sample_auxiliary_information_sizes.rb +23 -0
- data/lib/bmff/box/sample_dependency_type.rb +26 -0
- data/lib/bmff/box/sample_description.rb +27 -0
- data/lib/bmff/box/sample_entry.rb +15 -0
- data/lib/bmff/box/sample_size.rb +19 -0
- data/lib/bmff/box/sample_table.rb +12 -0
- data/lib/bmff/box/sample_to_chunk.rb +20 -0
- data/lib/bmff/box/shadow_sync_sample.rb +18 -0
- data/lib/bmff/box/sound_media_header.rb +13 -0
- data/lib/bmff/box/sub_sample_information.rb +41 -0
- data/lib/bmff/box/sync_sample.rb +16 -0
- data/lib/bmff/box/text_meta_data_sample_entry.rb +18 -0
- data/lib/bmff/box/time_to_sample.rb +18 -0
- data/lib/bmff/box/track.rb +12 -0
- data/lib/bmff/box/track_extends.rb +17 -0
- data/lib/bmff/box/track_fragment.rb +12 -0
- data/lib/bmff/box/track_fragment_base_media_decode_time.rb +16 -0
- data/lib/bmff/box/track_fragment_header.rb +18 -0
- data/lib/bmff/box/track_fragment_random_access.rb +54 -0
- data/lib/bmff/box/track_group.rb +12 -0
- data/lib/bmff/box/track_group_type.rb +12 -0
- data/lib/bmff/box/track_header.rb +36 -0
- data/lib/bmff/box/track_reference.rb +12 -0
- data/lib/bmff/box/track_reference_type.rb +15 -0
- data/lib/bmff/box/track_run.rb +31 -0
- data/lib/bmff/box/track_selection.rb +16 -0
- data/lib/bmff/box/unknown.rb +5 -0
- data/lib/bmff/box/uri.rb +12 -0
- data/lib/bmff/box/uri_init.rb +15 -0
- data/lib/bmff/box/uri_meta_sample_entry.rb +24 -0
- data/lib/bmff/box/user_data.rb +12 -0
- data/lib/bmff/box/video_media_header.rb +13 -0
- data/lib/bmff/box/visual_sample_entry.rb +37 -0
- data/lib/bmff/box/xml_meta_data_sample_entry.rb +19 -0
- data/lib/bmff/box.rb +115 -0
- data/lib/bmff/file_container.rb +20 -0
- data/lib/bmff/version.rb +3 -0
- data/lib/bmff.rb +7 -0
- data/test/bmff/box/test_audio_sample_entry.rb +46 -0
- data/test/bmff/box/test_base.rb +37 -0
- data/test/bmff/box/test_bit_rate.rb +30 -0
- data/test/bmff/box/test_chunk_large_offset.rb +35 -0
- data/test/bmff/box/test_chunk_offset.rb +35 -0
- data/test/bmff/box/test_clean_aperture.rb +40 -0
- data/test/bmff/box/test_colour_information.rb +73 -0
- data/test/bmff/box/test_compact_sample_size.rb +99 -0
- data/test/bmff/box/test_composition_offset.rb +64 -0
- data/test/bmff/box/test_composition_to_decode.rb +38 -0
- data/test/bmff/box/test_copyright.rb +55 -0
- data/test/bmff/box/test_data_entry_url.rb +30 -0
- data/test/bmff/box/test_data_entry_urn.rb +32 -0
- data/test/bmff/box/test_data_information.rb +26 -0
- data/test/bmff/box/test_data_reference.rb +58 -0
- data/test/bmff/box/test_degradation_priority.rb +62 -0
- data/test/bmff/box/test_edit.rb +26 -0
- data/test/bmff/box/test_edit_list.rb +72 -0
- data/test/bmff/box/test_file_type.rb +30 -0
- data/test/bmff/box/test_free_space.rb +42 -0
- data/test/bmff/box/test_handler.rb +67 -0
- data/test/bmff/box/test_hint_media_header.rb +38 -0
- data/test/bmff/box/test_hint_sample_entry.rb +38 -0
- data/test/bmff/box/test_level_assignment.rb +50 -0
- data/test/bmff/box/test_media.rb +26 -0
- data/test/bmff/box/test_media_data.rb +25 -0
- data/test/bmff/box/test_media_header.rb +72 -0
- data/test/bmff/box/test_media_information.rb +26 -0
- data/test/bmff/box/test_movie.rb +26 -0
- data/test/bmff/box/test_movie_extends.rb +26 -0
- data/test/bmff/box/test_movie_extends_header.rb +52 -0
- data/test/bmff/box/test_movie_fragment.rb +26 -0
- data/test/bmff/box/test_movie_fragment_header.rb +30 -0
- data/test/bmff/box/test_movie_fragment_random_access.rb +26 -0
- data/test/bmff/box/test_movie_fragment_random_access_offset.rb +30 -0
- data/test/bmff/box/test_movie_header.rb +110 -0
- data/test/bmff/box/test_null_media_header.rb +28 -0
- data/test/bmff/box/test_padding_bits.rb +38 -0
- data/test/bmff/box/test_pixel_aspect_ratio.rb +28 -0
- data/test/bmff/box/test_progressive_download_info.rb +36 -0
- data/test/bmff/box/test_sample_auxiliary_information_offsets.rb +94 -0
- data/test/bmff/box/test_sample_auxiliary_information_sizes.rb +70 -0
- data/test/bmff/box/test_sample_dependency_type.rb +70 -0
- data/test/bmff/box/test_sample_description.rb +355 -0
- data/test/bmff/box/test_sample_size.rb +61 -0
- data/test/bmff/box/test_sample_table.rb +26 -0
- data/test/bmff/box/test_sample_to_chunk.rb +39 -0
- data/test/bmff/box/test_shadow_sync_sample.rb +36 -0
- data/test/bmff/box/test_sound_media_header.rb +32 -0
- data/test/bmff/box/test_sub_sample_information.rb +90 -0
- data/test/bmff/box/test_sync_sample.rb +34 -0
- data/test/bmff/box/test_text_meta_data_sample_entry.rb +49 -0
- data/test/bmff/box/test_time_to_sample.rb +36 -0
- data/test/bmff/box/test_track.rb +26 -0
- data/test/bmff/box/test_track_extends.rb +38 -0
- data/test/bmff/box/test_track_fragment.rb +26 -0
- data/test/bmff/box/test_track_fragment_base_media_decode_time.rb +52 -0
- data/test/bmff/box/test_track_fragment_header.rb +200 -0
- data/test/bmff/box/test_track_fragment_random_access.rb +96 -0
- data/test/bmff/box/test_track_group.rb +26 -0
- data/test/bmff/box/test_track_group_type.rb +30 -0
- data/test/bmff/box/test_track_header.rb +118 -0
- data/test/bmff/box/test_track_reference.rb +26 -0
- data/test/bmff/box/test_track_reference_type.rb +100 -0
- data/test/bmff/box/test_track_run.rb +282 -0
- data/test/bmff/box/test_track_selection.rb +33 -0
- data/test/bmff/box/test_uri.rb +30 -0
- data/test/bmff/box/test_uri_init.rb +32 -0
- data/test/bmff/box/test_uri_meta_sample_entry.rb +74 -0
- data/test/bmff/box/test_user_data.rb +26 -0
- data/test/bmff/box/test_video_media_header.rb +34 -0
- data/test/bmff/box/test_visual_sample_entry.rb +95 -0
- data/test/bmff/box/test_xml_meta_data_sample_entry.rb +51 -0
- data/test/bmff/test_binary_accessor.rb +805 -0
- data/test/bmff/test_file_container.rb +58 -0
- data/test/minitest_helper.rb +7 -0
- metadata +323 -0
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
# vim: set expandtab tabstop=2 shiftwidth=2 softtabstop=2 autoindent:
|
3
|
+
|
4
|
+
class BMFF::Box::SampleAuxiliaryInformationOffsets < BMFF::Box::Full
|
5
|
+
attr_accessor :aux_info_type, :aux_info_type_parameter, :entry_count, :offsets
|
6
|
+
register_box "saio"
|
7
|
+
|
8
|
+
def parse_data
|
9
|
+
super
|
10
|
+
if flags & 1 > 0
|
11
|
+
@aux_info_type = io.get_uint32
|
12
|
+
@aux_info_type_parameter = io.get_uint32
|
13
|
+
end
|
14
|
+
@entry_count = io.get_uint32
|
15
|
+
@offsets = []
|
16
|
+
@entry_count.times do
|
17
|
+
if version == 0
|
18
|
+
@offsets << io.get_uint32
|
19
|
+
else
|
20
|
+
@offsets << io.get_uint64
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
# vim: set expandtab tabstop=2 shiftwidth=2 softtabstop=2 autoindent:
|
3
|
+
|
4
|
+
class BMFF::Box::SampleAuxiliaryInformationSizes < BMFF::Box::Full
|
5
|
+
attr_accessor :aux_info_type, :aux_info_type_parameter, :default_sample_info_size, :sample_count, :sample_info_size
|
6
|
+
register_box "saiz"
|
7
|
+
|
8
|
+
def parse_data
|
9
|
+
super
|
10
|
+
if flags & 1 > 0
|
11
|
+
@aux_info_type = io.get_uint32
|
12
|
+
@aux_info_type_parameter = io.get_uint32
|
13
|
+
end
|
14
|
+
@default_sample_info_size = io.get_uint8
|
15
|
+
@sample_count = io.get_uint32
|
16
|
+
if @default_sample_info_size == 0
|
17
|
+
@sample_info_size = []
|
18
|
+
@sample_count.times do
|
19
|
+
@sample_info_size << io.get_uint8
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
# vim: set expandtab tabstop=2 shiftwidth=2 softtabstop=2 autoindent:
|
3
|
+
|
4
|
+
class BMFF::Box::SampleDependencyType < BMFF::Box::Full
|
5
|
+
attr_accessor :is_leading, :sample_depends_on, :sample_is_depended_on, :sample_has_redundancy
|
6
|
+
register_box "sdtp"
|
7
|
+
|
8
|
+
def parse_data
|
9
|
+
super
|
10
|
+
sample_size_box = parent.find(BMFF::Box::SampleSize)
|
11
|
+
if sample_size_box
|
12
|
+
sample_count = sample_size_box.sample_count
|
13
|
+
@is_leading = []
|
14
|
+
@sample_depends_on = []
|
15
|
+
@sample_is_depended_on = []
|
16
|
+
@sample_has_redundancy = []
|
17
|
+
sample_count.times do
|
18
|
+
tmp = io.get_uint8
|
19
|
+
@is_leading << (tmp >> 6)
|
20
|
+
@sample_depends_on << ((tmp >> 4) & 0x03)
|
21
|
+
@sample_is_depended_on << ((tmp >> 2) & 0x03)
|
22
|
+
@sample_has_redundancy << (tmp & 0x03)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
# vim: set expandtab tabstop=2 shiftwidth=2 softtabstop=2 autoindent:
|
3
|
+
|
4
|
+
class BMFF::Box::SampleDescription < BMFF::Box::Full
|
5
|
+
attr_accessor :entry_count
|
6
|
+
register_box "stsd"
|
7
|
+
include(BMFF::Box::Container)
|
8
|
+
|
9
|
+
def parse_data
|
10
|
+
super
|
11
|
+
@entry_count = io.get_uint32
|
12
|
+
if handler = parent.parent.parent.find(BMFF::Box::Handler)
|
13
|
+
@entry_count.times do
|
14
|
+
case handler.handler_type
|
15
|
+
when "soun"
|
16
|
+
add_child BMFF::Box.get_box(io, self, BMFF::Box::AudioSampleEntry)
|
17
|
+
when "vide"
|
18
|
+
add_child BMFF::Box.get_box(io, self, BMFF::Box::VisualSampleEntry)
|
19
|
+
when "hint"
|
20
|
+
add_child BMFF::Box.get_box(io, self, BMFF::Box::HintSampleEntry)
|
21
|
+
when "meta"
|
22
|
+
add_child BMFF::Box.get_box(io, self)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
# vim: set expandtab tabstop=2 shiftwidth=2 softtabstop=2 autoindent:
|
3
|
+
|
4
|
+
class BMFF::Box::SampleEntry < BMFF::Box::Base
|
5
|
+
attr_accessor :reserved1, :data_reference_index
|
6
|
+
|
7
|
+
def parse_data
|
8
|
+
super
|
9
|
+
@reserved1 = []
|
10
|
+
6.times do
|
11
|
+
@reserved1 << io.get_uint8
|
12
|
+
end
|
13
|
+
@data_reference_index = io.get_uint16
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
# vim: set expandtab tabstop=2 shiftwidth=2 softtabstop=2 autoindent:
|
3
|
+
|
4
|
+
class BMFF::Box::SampleSize < BMFF::Box::Full
|
5
|
+
attr_accessor :sample_size, :sample_count, :entry_size
|
6
|
+
register_box "stsz"
|
7
|
+
|
8
|
+
def parse_data
|
9
|
+
super
|
10
|
+
@sample_size = io.get_uint32
|
11
|
+
@sample_count = io.get_uint32
|
12
|
+
@entry_size = []
|
13
|
+
if @sample_size == 0
|
14
|
+
@sample_count.times do
|
15
|
+
@entry_size << io.get_uint32
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
# vim: set expandtab tabstop=2 shiftwidth=2 softtabstop=2 autoindent:
|
3
|
+
|
4
|
+
class BMFF::Box::SampleToChunk < BMFF::Box::Full
|
5
|
+
attr_accessor :entry_count, :first_chunk, :samples_per_chunk, :sample_description_index
|
6
|
+
register_box "stsc"
|
7
|
+
|
8
|
+
def parse_data
|
9
|
+
super
|
10
|
+
@entry_count = io.get_uint32
|
11
|
+
@first_chunk = []
|
12
|
+
@samples_per_chunk = []
|
13
|
+
@sample_description_index = []
|
14
|
+
@entry_count.times do
|
15
|
+
@first_chunk << io.get_uint32
|
16
|
+
@samples_per_chunk << io.get_uint32
|
17
|
+
@sample_description_index << io.get_uint32
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
# vim: set expandtab tabstop=2 shiftwidth=2 softtabstop=2 autoindent:
|
3
|
+
|
4
|
+
class BMFF::Box::ShadowSyncSample < BMFF::Box::Full
|
5
|
+
attr_accessor :entry_count, :shadowed_sample_number, :sync_sample_number
|
6
|
+
register_box "stsh"
|
7
|
+
|
8
|
+
def parse_data
|
9
|
+
super
|
10
|
+
@entry_count = io.get_uint32
|
11
|
+
@shadowed_sample_number = []
|
12
|
+
@sync_sample_number = []
|
13
|
+
@entry_count.times do
|
14
|
+
@shadowed_sample_number << io.get_uint32
|
15
|
+
@sync_sample_number << io.get_uint32
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
# vim: set expandtab tabstop=2 shiftwidth=2 softtabstop=2 autoindent:
|
3
|
+
|
4
|
+
class BMFF::Box::SoundMediaHeader < BMFF::Box::Full
|
5
|
+
attr_accessor :balance, :reserved1
|
6
|
+
register_box "smhd"
|
7
|
+
|
8
|
+
def parse_data
|
9
|
+
super
|
10
|
+
@balance = io.get_int16
|
11
|
+
@reserved1 = io.get_uint16
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
# vim: set expandtab tabstop=2 shiftwidth=2 softtabstop=2 autoindent:
|
3
|
+
|
4
|
+
class BMFF::Box::SubSampleInformation < BMFF::Box::Full
|
5
|
+
attr_accessor :entry_count, :sample_delta, :subsample_count, :subsamples
|
6
|
+
register_box "subs"
|
7
|
+
|
8
|
+
class SubSample
|
9
|
+
attr_accessor :subsample_size, :subsample_priority, :discardable, :reserved1
|
10
|
+
def initialize
|
11
|
+
@subsample_size = []
|
12
|
+
@subsample_priority = []
|
13
|
+
@discardable = []
|
14
|
+
@reserved1 = []
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def parse_data
|
19
|
+
super
|
20
|
+
@entry_count = io.get_uint32
|
21
|
+
@sample_delta = []
|
22
|
+
@subsample_count = []
|
23
|
+
@subsamples = []
|
24
|
+
@entry_count.times do
|
25
|
+
@sample_delta << io.get_uint32
|
26
|
+
@subsample_count << io.get_uint16
|
27
|
+
subsample = SubSample.new
|
28
|
+
@subsample_count.last.times do
|
29
|
+
if version == 1
|
30
|
+
subsample.subsample_size << io.get_uint32
|
31
|
+
else
|
32
|
+
subsample.subsample_size << io.get_uint16
|
33
|
+
end
|
34
|
+
subsample.subsample_priority << io.get_uint8
|
35
|
+
subsample.discardable << io.get_uint8
|
36
|
+
subsample.reserved1 << io.get_uint32
|
37
|
+
end
|
38
|
+
@subsamples << subsample
|
39
|
+
end
|
40
|
+
end
|
41
|
+
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::SyncSample < BMFF::Box::Full
|
5
|
+
attr_accessor :entry_count, :sample_number
|
6
|
+
register_box "stss"
|
7
|
+
|
8
|
+
def parse_data
|
9
|
+
super
|
10
|
+
@entry_count = io.get_uint32
|
11
|
+
@sample_number = []
|
12
|
+
@entry_count.times do
|
13
|
+
@sample_number << io.get_uint32
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
# vim: set expandtab tabstop=2 shiftwidth=2 softtabstop=2 autoindent:
|
3
|
+
|
4
|
+
class BMFF::Box::TextMetaDataSampleEntry < BMFF::Box::MetaDataSampleEntry
|
5
|
+
attr_accessor :content_encoding, :mime_format, :bit_rate_box
|
6
|
+
register_box "mett"
|
7
|
+
include(BMFF::Box::Container)
|
8
|
+
|
9
|
+
def parse_data
|
10
|
+
super
|
11
|
+
@content_encoding = io.get_null_terminated_string unless eob?
|
12
|
+
@mime_format = io.get_null_terminated_string unless eob?
|
13
|
+
unless eob?
|
14
|
+
@bit_rate_box = BMFF::Box.get_box(io, self, BMFF::Box::BitRate)
|
15
|
+
add_child @bit_rate_box
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
# vim: set expandtab tabstop=2 shiftwidth=2 softtabstop=2 autoindent:
|
3
|
+
|
4
|
+
class BMFF::Box::TimeToSample < BMFF::Box::Full
|
5
|
+
attr_accessor :entry_count, :sample_count, :sample_delta
|
6
|
+
register_box "stts"
|
7
|
+
|
8
|
+
def parse_data
|
9
|
+
super
|
10
|
+
@entry_count = io.get_uint32
|
11
|
+
@sample_count = []
|
12
|
+
@sample_delta = []
|
13
|
+
@entry_count.times do
|
14
|
+
@sample_count << io.get_uint32
|
15
|
+
@sample_delta << io.get_uint32
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
# vim: set expandtab tabstop=2 shiftwidth=2 softtabstop=2 autoindent:
|
3
|
+
|
4
|
+
class BMFF::Box::TrackExtends < BMFF::Box::Full
|
5
|
+
attr_accessor :track_id, :default_sample_description_index, :default_sample_duration,
|
6
|
+
:default_sample_size, :default_sample_flags
|
7
|
+
register_box "trex"
|
8
|
+
|
9
|
+
def parse_data
|
10
|
+
super
|
11
|
+
@track_id = io.get_uint32
|
12
|
+
@default_sample_description_index = io.get_uint32
|
13
|
+
@default_sample_duration = io.get_uint32
|
14
|
+
@default_sample_size = io.get_uint32
|
15
|
+
@default_sample_flags = io.get_uint32
|
16
|
+
end
|
17
|
+
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::TrackFragmentBaseMediaDecodeTime < BMFF::Box::Full
|
5
|
+
attr_accessor :base_media_decode_time
|
6
|
+
register_box "tfdt"
|
7
|
+
|
8
|
+
def parse_data
|
9
|
+
super
|
10
|
+
if version == 1
|
11
|
+
@base_media_decode_time = io.get_uint64
|
12
|
+
else
|
13
|
+
@base_media_decode_time = io.get_uint32
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
# vim: set expandtab tabstop=2 shiftwidth=2 softtabstop=2 autoindent:
|
3
|
+
|
4
|
+
class BMFF::Box::TrackFragmentHeader < BMFF::Box::Full
|
5
|
+
attr_accessor :track_id, :base_data_offset, :sample_description_index,
|
6
|
+
:default_sample_duration, :default_sample_size, :default_sample_flags
|
7
|
+
register_box "tfhd"
|
8
|
+
|
9
|
+
def parse_data
|
10
|
+
super
|
11
|
+
@track_id = io.get_uint32
|
12
|
+
@base_data_offset = io.get_uint64 if flags & 0x01 > 0
|
13
|
+
@sample_description_index = io.get_uint32 if flags & 0x02 > 0
|
14
|
+
@default_sample_duration = io.get_uint32 if flags & 0x08 > 0
|
15
|
+
@default_sample_size = io.get_uint32 if flags & 0x10 > 0
|
16
|
+
@default_sample_flags = io.get_uint32 if flags & 0x20 > 0
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
# vim: set expandtab tabstop=2 shiftwidth=2 softtabstop=2 autoindent:
|
3
|
+
|
4
|
+
class BMFF::Box::TrackFragmentRandomAccess < BMFF::Box::Full
|
5
|
+
attr_accessor :track_id, :reserved1,
|
6
|
+
:length_size_of_traf_num, :length_size_of_trun_num, :length_size_of_sample_num,
|
7
|
+
:number_of_entry, :time, :moof_offset, :traf_number, :trun_number, :sample_number
|
8
|
+
register_box "tfra"
|
9
|
+
|
10
|
+
def parse_data
|
11
|
+
super
|
12
|
+
@track_id = io.get_uint32
|
13
|
+
tmp = io.get_uint32
|
14
|
+
@reserved1 = (tmp >> 6)
|
15
|
+
@length_size_of_traf_num = (tmp >> 4) & 0x03
|
16
|
+
@length_size_of_trun_num = (tmp >> 2) & 0x03
|
17
|
+
@length_size_of_sample_num = (tmp & 0x03)
|
18
|
+
@number_of_entry = io.get_uint32
|
19
|
+
@time = []
|
20
|
+
@moof_offset = []
|
21
|
+
@traf_number = []
|
22
|
+
@trun_number = []
|
23
|
+
@sample_number = []
|
24
|
+
@number_of_entry.times do
|
25
|
+
if version == 1
|
26
|
+
@time << io.get_uint64
|
27
|
+
@moof_offset << io.get_uint64
|
28
|
+
else
|
29
|
+
@time << io.get_uint32
|
30
|
+
@moof_offset << io.get_uint32
|
31
|
+
end
|
32
|
+
@traf_number << get_variable_size_uint((@length_size_of_traf_num + 1) * 8)
|
33
|
+
@trun_number << get_variable_size_uint((@length_size_of_trun_num + 1) * 8)
|
34
|
+
@sample_number << get_variable_size_uint((@length_size_of_sample_num + 1) * 8)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def get_variable_size_uint(size)
|
39
|
+
case size
|
40
|
+
when 8
|
41
|
+
io.get_uint8
|
42
|
+
when 16
|
43
|
+
io.get_uint16
|
44
|
+
when 24
|
45
|
+
io.get_uint24
|
46
|
+
when 32
|
47
|
+
io.get_uint32
|
48
|
+
else
|
49
|
+
raise ArgumentError, "Unsupported field size."
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
private :get_variable_size_uint
|
54
|
+
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::TrackGroupType < BMFF::Box::Full
|
5
|
+
attr_accessor :track_group_id
|
6
|
+
register_box "msrc"
|
7
|
+
|
8
|
+
def parse_data
|
9
|
+
super
|
10
|
+
@track_group_id = io.get_uint32
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
# vim: set expandtab tabstop=2 shiftwidth=2 softtabstop=2 autoindent:
|
3
|
+
|
4
|
+
class BMFF::Box::TrackHeader < BMFF::Box::Full
|
5
|
+
attr_accessor :creation_time, :modification_time, :track_id, :reserved1, :duration,
|
6
|
+
:reserved2, :layer, :alternate_group, :volume, :reserved3, :matrix, :width, :height
|
7
|
+
register_box "tkhd"
|
8
|
+
|
9
|
+
def parse_data
|
10
|
+
super
|
11
|
+
if version == 1
|
12
|
+
@creation_time = io.get_uint64
|
13
|
+
@modification_time = io.get_uint64
|
14
|
+
@track_id = io.get_uint32
|
15
|
+
@reserved1 = io.get_uint32
|
16
|
+
@duration = io.get_uint64
|
17
|
+
else
|
18
|
+
@creation_time = io.get_uint32
|
19
|
+
@modification_time = io.get_uint32
|
20
|
+
@track_id = io.get_uint32
|
21
|
+
@reserved1 = io.get_uint32
|
22
|
+
@duration = io.get_uint32
|
23
|
+
end
|
24
|
+
@reserved2 = [io.get_uint32, io.get_uint32]
|
25
|
+
@layer = io.get_int16
|
26
|
+
@alternate_group = io.get_int16
|
27
|
+
@volume = io.get_int16
|
28
|
+
@reserved3 = io.get_uint16
|
29
|
+
@matrix = []
|
30
|
+
9.times do
|
31
|
+
@matrix << io.get_int32
|
32
|
+
end
|
33
|
+
@width = io.get_uint32
|
34
|
+
@height = io.get_uint32
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
# vim: set expandtab tabstop=2 shiftwidth=2 softtabstop=2 autoindent:
|
3
|
+
|
4
|
+
class BMFF::Box::TrackReferenceType < BMFF::Box::Base
|
5
|
+
attr_accessor :track_ids
|
6
|
+
register_box "hint", "cdsc", "hind", "vdep", "vplx"
|
7
|
+
|
8
|
+
def parse_data
|
9
|
+
super
|
10
|
+
@track_ids = []
|
11
|
+
until eob?
|
12
|
+
@track_ids << io.get_uint32
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
# vim: set expandtab tabstop=2 shiftwidth=2 softtabstop=2 autoindent:
|
3
|
+
|
4
|
+
class BMFF::Box::TrackRun < BMFF::Box::Full
|
5
|
+
attr_accessor :sample_count, :data_offset, :first_sample_flags,
|
6
|
+
:sample_duration, :sample_size, :sample_flags, :sample_composition_time_offset
|
7
|
+
register_box "trun"
|
8
|
+
|
9
|
+
def parse_data
|
10
|
+
super
|
11
|
+
@sample_count = io.get_uint32
|
12
|
+
@data_offset = io.get_int32 if flags & 0x01 > 0
|
13
|
+
@first_sample_flags = io.get_uint32 if flags & 0x04 > 0
|
14
|
+
@sample_duration = [] if flags & 0x0100 > 0
|
15
|
+
@sample_size = [] if flags & 0x0200 > 0
|
16
|
+
@sample_flags = [] if flags & 0x0400 > 0
|
17
|
+
@sample_composition_time_offset = [] if flags & 0x0800 > 0
|
18
|
+
@sample_count.times do
|
19
|
+
@sample_duration << io.get_uint32 if flags & 0x0100 > 0
|
20
|
+
@sample_size << io.get_uint32 if flags & 0x0200 > 0
|
21
|
+
@sample_flags << io.get_uint32 if flags & 0x0400 > 0
|
22
|
+
if flags & 0x0800 > 0
|
23
|
+
if version == 0
|
24
|
+
@sample_composition_time_offset << io.get_uint32
|
25
|
+
else
|
26
|
+
@sample_composition_time_offset << io.get_int32
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
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::TrackSelection < BMFF::Box::Full
|
5
|
+
attr_accessor :switch_group, :attribute_list
|
6
|
+
register_box "tsel"
|
7
|
+
|
8
|
+
def parse_data
|
9
|
+
super
|
10
|
+
@switch_group = io.get_int32
|
11
|
+
@attribute_list = []
|
12
|
+
until eob?
|
13
|
+
@attribute_list << io.get_ascii(4)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/bmff/box/uri.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
# vim: set expandtab tabstop=2 shiftwidth=2 softtabstop=2 autoindent:
|
3
|
+
|
4
|
+
class BMFF::Box::URI < BMFF::Box::Full
|
5
|
+
attr_accessor :the_uri
|
6
|
+
register_box "uri "
|
7
|
+
|
8
|
+
def parse_data
|
9
|
+
super
|
10
|
+
@the_uri = io.get_null_terminated_string
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
# vim: set expandtab tabstop=2 shiftwidth=2 softtabstop=2 autoindent:
|
3
|
+
|
4
|
+
class BMFF::Box::URIInit < BMFF::Box::Full
|
5
|
+
attr_accessor :uri_initialization_data
|
6
|
+
register_box "uriI"
|
7
|
+
|
8
|
+
def parse_data
|
9
|
+
super
|
10
|
+
@uri_initialization_data = []
|
11
|
+
until eob?
|
12
|
+
@uri_initialization_data << io.get_uint8
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
# vim: set expandtab tabstop=2 shiftwidth=2 softtabstop=2 autoindent:
|
3
|
+
|
4
|
+
class BMFF::Box::URIMetaSampleEntry < BMFF::Box::MetaDataSampleEntry
|
5
|
+
attr_accessor :uri_box, :uri_init_box, :mpeg4_bit_rate_box
|
6
|
+
register_box "urim"
|
7
|
+
include(BMFF::Box::Container)
|
8
|
+
|
9
|
+
def parse_data
|
10
|
+
super
|
11
|
+
@uri_box = BMFF::Box.get_box(io, self, BMFF::Box::URI)
|
12
|
+
add_child @uri_box
|
13
|
+
until eob?
|
14
|
+
box = BMFF::Box.get_box(io, self)
|
15
|
+
add_child box
|
16
|
+
case box
|
17
|
+
when BMFF::Box::URIInit
|
18
|
+
@uri_init_box = box
|
19
|
+
when BMFF::Box::BitRate
|
20
|
+
@mpeg4_bit_rate_box = box
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|