bmff 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (167) hide show
  1. data/.gitignore +25 -0
  2. data/Gemfile +4 -0
  3. data/LICENSE.txt +22 -0
  4. data/README.md +183 -0
  5. data/Rakefile +9 -0
  6. data/bmff.gemspec +25 -0
  7. data/lib/bmff/binary_accessor.rb +186 -0
  8. data/lib/bmff/box/audio_sample_entry.rb +16 -0
  9. data/lib/bmff/box/base.rb +66 -0
  10. data/lib/bmff/box/bit_rate.rb +14 -0
  11. data/lib/bmff/box/chunk_large_offset.rb +16 -0
  12. data/lib/bmff/box/chunk_offset.rb +16 -0
  13. data/lib/bmff/box/clean_aperture.rb +20 -0
  14. data/lib/bmff/box/colour_information.rb +27 -0
  15. data/lib/bmff/box/compact_sample_size.rb +32 -0
  16. data/lib/bmff/box/composition_offset.rb +25 -0
  17. data/lib/bmff/box/composition_to_decode.rb +17 -0
  18. data/lib/bmff/box/container.rb +70 -0
  19. data/lib/bmff/box/copyright.rb +13 -0
  20. data/lib/bmff/box/data_entry_url.rb +12 -0
  21. data/lib/bmff/box/data_entry_urn.rb +13 -0
  22. data/lib/bmff/box/data_information.rb +12 -0
  23. data/lib/bmff/box/data_reference.rb +14 -0
  24. data/lib/bmff/box/degradation_priority.rb +19 -0
  25. data/lib/bmff/box/edit.rb +12 -0
  26. data/lib/bmff/box/edit_list.rb +27 -0
  27. data/lib/bmff/box/file_type.rb +17 -0
  28. data/lib/bmff/box/free_space.rb +6 -0
  29. data/lib/bmff/box/full.rb +11 -0
  30. data/lib/bmff/box/handler.rb +15 -0
  31. data/lib/bmff/box/hint_media_header.rb +16 -0
  32. data/lib/bmff/box/hint_sample_entry.rb +14 -0
  33. data/lib/bmff/box/level_assignment.rb +35 -0
  34. data/lib/bmff/box/map.rb +15 -0
  35. data/lib/bmff/box/media.rb +12 -0
  36. data/lib/bmff/box/media_data.rb +6 -0
  37. data/lib/bmff/box/media_header.rb +25 -0
  38. data/lib/bmff/box/media_information.rb +12 -0
  39. data/lib/bmff/box/meta_data_sample_entry.rb +5 -0
  40. data/lib/bmff/box/movie.rb +12 -0
  41. data/lib/bmff/box/movie_extends.rb +12 -0
  42. data/lib/bmff/box/movie_extends_header.rb +16 -0
  43. data/lib/bmff/box/movie_fragment.rb +12 -0
  44. data/lib/bmff/box/movie_fragment_header.rb +12 -0
  45. data/lib/bmff/box/movie_fragment_random_access.rb +12 -0
  46. data/lib/bmff/box/movie_fragment_random_access_offset.rb +12 -0
  47. data/lib/bmff/box/movie_header.rb +36 -0
  48. data/lib/bmff/box/null_media_header.rb +6 -0
  49. data/lib/bmff/box/padding_bits.rb +23 -0
  50. data/lib/bmff/box/pixel_aspect_ratio.rb +13 -0
  51. data/lib/bmff/box/progressive_download_info.rb +17 -0
  52. data/lib/bmff/box/sample_auxiliary_information_offsets.rb +24 -0
  53. data/lib/bmff/box/sample_auxiliary_information_sizes.rb +23 -0
  54. data/lib/bmff/box/sample_dependency_type.rb +26 -0
  55. data/lib/bmff/box/sample_description.rb +27 -0
  56. data/lib/bmff/box/sample_entry.rb +15 -0
  57. data/lib/bmff/box/sample_size.rb +19 -0
  58. data/lib/bmff/box/sample_table.rb +12 -0
  59. data/lib/bmff/box/sample_to_chunk.rb +20 -0
  60. data/lib/bmff/box/shadow_sync_sample.rb +18 -0
  61. data/lib/bmff/box/sound_media_header.rb +13 -0
  62. data/lib/bmff/box/sub_sample_information.rb +41 -0
  63. data/lib/bmff/box/sync_sample.rb +16 -0
  64. data/lib/bmff/box/text_meta_data_sample_entry.rb +18 -0
  65. data/lib/bmff/box/time_to_sample.rb +18 -0
  66. data/lib/bmff/box/track.rb +12 -0
  67. data/lib/bmff/box/track_extends.rb +17 -0
  68. data/lib/bmff/box/track_fragment.rb +12 -0
  69. data/lib/bmff/box/track_fragment_base_media_decode_time.rb +16 -0
  70. data/lib/bmff/box/track_fragment_header.rb +18 -0
  71. data/lib/bmff/box/track_fragment_random_access.rb +54 -0
  72. data/lib/bmff/box/track_group.rb +12 -0
  73. data/lib/bmff/box/track_group_type.rb +12 -0
  74. data/lib/bmff/box/track_header.rb +36 -0
  75. data/lib/bmff/box/track_reference.rb +12 -0
  76. data/lib/bmff/box/track_reference_type.rb +15 -0
  77. data/lib/bmff/box/track_run.rb +31 -0
  78. data/lib/bmff/box/track_selection.rb +16 -0
  79. data/lib/bmff/box/unknown.rb +5 -0
  80. data/lib/bmff/box/uri.rb +12 -0
  81. data/lib/bmff/box/uri_init.rb +15 -0
  82. data/lib/bmff/box/uri_meta_sample_entry.rb +24 -0
  83. data/lib/bmff/box/user_data.rb +12 -0
  84. data/lib/bmff/box/video_media_header.rb +13 -0
  85. data/lib/bmff/box/visual_sample_entry.rb +37 -0
  86. data/lib/bmff/box/xml_meta_data_sample_entry.rb +19 -0
  87. data/lib/bmff/box.rb +115 -0
  88. data/lib/bmff/file_container.rb +20 -0
  89. data/lib/bmff/version.rb +3 -0
  90. data/lib/bmff.rb +7 -0
  91. data/test/bmff/box/test_audio_sample_entry.rb +46 -0
  92. data/test/bmff/box/test_base.rb +37 -0
  93. data/test/bmff/box/test_bit_rate.rb +30 -0
  94. data/test/bmff/box/test_chunk_large_offset.rb +35 -0
  95. data/test/bmff/box/test_chunk_offset.rb +35 -0
  96. data/test/bmff/box/test_clean_aperture.rb +40 -0
  97. data/test/bmff/box/test_colour_information.rb +73 -0
  98. data/test/bmff/box/test_compact_sample_size.rb +99 -0
  99. data/test/bmff/box/test_composition_offset.rb +64 -0
  100. data/test/bmff/box/test_composition_to_decode.rb +38 -0
  101. data/test/bmff/box/test_copyright.rb +55 -0
  102. data/test/bmff/box/test_data_entry_url.rb +30 -0
  103. data/test/bmff/box/test_data_entry_urn.rb +32 -0
  104. data/test/bmff/box/test_data_information.rb +26 -0
  105. data/test/bmff/box/test_data_reference.rb +58 -0
  106. data/test/bmff/box/test_degradation_priority.rb +62 -0
  107. data/test/bmff/box/test_edit.rb +26 -0
  108. data/test/bmff/box/test_edit_list.rb +72 -0
  109. data/test/bmff/box/test_file_type.rb +30 -0
  110. data/test/bmff/box/test_free_space.rb +42 -0
  111. data/test/bmff/box/test_handler.rb +67 -0
  112. data/test/bmff/box/test_hint_media_header.rb +38 -0
  113. data/test/bmff/box/test_hint_sample_entry.rb +38 -0
  114. data/test/bmff/box/test_level_assignment.rb +50 -0
  115. data/test/bmff/box/test_media.rb +26 -0
  116. data/test/bmff/box/test_media_data.rb +25 -0
  117. data/test/bmff/box/test_media_header.rb +72 -0
  118. data/test/bmff/box/test_media_information.rb +26 -0
  119. data/test/bmff/box/test_movie.rb +26 -0
  120. data/test/bmff/box/test_movie_extends.rb +26 -0
  121. data/test/bmff/box/test_movie_extends_header.rb +52 -0
  122. data/test/bmff/box/test_movie_fragment.rb +26 -0
  123. data/test/bmff/box/test_movie_fragment_header.rb +30 -0
  124. data/test/bmff/box/test_movie_fragment_random_access.rb +26 -0
  125. data/test/bmff/box/test_movie_fragment_random_access_offset.rb +30 -0
  126. data/test/bmff/box/test_movie_header.rb +110 -0
  127. data/test/bmff/box/test_null_media_header.rb +28 -0
  128. data/test/bmff/box/test_padding_bits.rb +38 -0
  129. data/test/bmff/box/test_pixel_aspect_ratio.rb +28 -0
  130. data/test/bmff/box/test_progressive_download_info.rb +36 -0
  131. data/test/bmff/box/test_sample_auxiliary_information_offsets.rb +94 -0
  132. data/test/bmff/box/test_sample_auxiliary_information_sizes.rb +70 -0
  133. data/test/bmff/box/test_sample_dependency_type.rb +70 -0
  134. data/test/bmff/box/test_sample_description.rb +355 -0
  135. data/test/bmff/box/test_sample_size.rb +61 -0
  136. data/test/bmff/box/test_sample_table.rb +26 -0
  137. data/test/bmff/box/test_sample_to_chunk.rb +39 -0
  138. data/test/bmff/box/test_shadow_sync_sample.rb +36 -0
  139. data/test/bmff/box/test_sound_media_header.rb +32 -0
  140. data/test/bmff/box/test_sub_sample_information.rb +90 -0
  141. data/test/bmff/box/test_sync_sample.rb +34 -0
  142. data/test/bmff/box/test_text_meta_data_sample_entry.rb +49 -0
  143. data/test/bmff/box/test_time_to_sample.rb +36 -0
  144. data/test/bmff/box/test_track.rb +26 -0
  145. data/test/bmff/box/test_track_extends.rb +38 -0
  146. data/test/bmff/box/test_track_fragment.rb +26 -0
  147. data/test/bmff/box/test_track_fragment_base_media_decode_time.rb +52 -0
  148. data/test/bmff/box/test_track_fragment_header.rb +200 -0
  149. data/test/bmff/box/test_track_fragment_random_access.rb +96 -0
  150. data/test/bmff/box/test_track_group.rb +26 -0
  151. data/test/bmff/box/test_track_group_type.rb +30 -0
  152. data/test/bmff/box/test_track_header.rb +118 -0
  153. data/test/bmff/box/test_track_reference.rb +26 -0
  154. data/test/bmff/box/test_track_reference_type.rb +100 -0
  155. data/test/bmff/box/test_track_run.rb +282 -0
  156. data/test/bmff/box/test_track_selection.rb +33 -0
  157. data/test/bmff/box/test_uri.rb +30 -0
  158. data/test/bmff/box/test_uri_init.rb +32 -0
  159. data/test/bmff/box/test_uri_meta_sample_entry.rb +74 -0
  160. data/test/bmff/box/test_user_data.rb +26 -0
  161. data/test/bmff/box/test_video_media_header.rb +34 -0
  162. data/test/bmff/box/test_visual_sample_entry.rb +95 -0
  163. data/test/bmff/box/test_xml_meta_data_sample_entry.rb +51 -0
  164. data/test/bmff/test_binary_accessor.rb +805 -0
  165. data/test/bmff/test_file_container.rb +58 -0
  166. data/test/minitest_helper.rb +7 -0
  167. metadata +323 -0
@@ -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 TestBMFFBoxMedia < 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("mdia")
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::Media, box)
21
+ assert_equal(size, box.actual_size)
22
+ assert_equal("mdia", box.type)
23
+ assert_equal([], box.children)
24
+ assert(box.container?)
25
+ end
26
+ end
@@ -0,0 +1,25 @@
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 TestBMFFBoxMediaData < 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("mdat")
14
+ io.write_byte("abcdefg") # data
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::MediaData, box)
22
+ assert_equal(size, box.actual_size)
23
+ assert_equal("mdat", box.type)
24
+ end
25
+ end
@@ -0,0 +1,72 @@
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 TestBMFFBoxMediaHeader < MiniTest::Unit::TestCase
9
+ def test_parse_v0
10
+ io = StringIO.new("", "r+:ascii-8bit")
11
+ io.extend(BMFF::BinaryAccessor)
12
+ io.write_uint32(0)
13
+ io.write_ascii("mdhd")
14
+ io.write_uint8(0) # version
15
+ io.write_uint24(0) # flags
16
+ io.write_uint32(3482338006) # creation_time
17
+ io.write_uint32(3482338007) # modification_time
18
+ io.write_uint32(1000000) # timescale
19
+ io.write_uint32(30000000) # duration
20
+ io.write_byte("\x15\xC7") # language (eng)
21
+ io.write_uint16(0) # pre_defined
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::MediaHeader, box)
29
+ assert_equal(size, box.actual_size)
30
+ assert_equal("mdhd", box.type)
31
+ assert_equal(0, box.version)
32
+ assert_equal(0, box.flags)
33
+ assert_equal(3482338006, box.creation_time)
34
+ assert_equal(3482338007, box.modification_time)
35
+ assert_equal(1000000, box.timescale)
36
+ assert_equal(30000000, box.duration)
37
+ assert_equal("eng", box.language)
38
+ assert_equal(0, box.pre_defined)
39
+ end
40
+
41
+ def test_parse_v1
42
+ io = StringIO.new("", "r+:ascii-8bit")
43
+ io.extend(BMFF::BinaryAccessor)
44
+ io.write_uint32(0)
45
+ io.write_ascii("mdhd")
46
+ io.write_uint8(1) # version
47
+ io.write_uint24(0) # flags
48
+ io.write_uint64(3482338006) # creation_time
49
+ io.write_uint64(3482338007) # modification_time
50
+ io.write_uint32(1000000) # timescale
51
+ io.write_uint64(30000000) # duration
52
+ io.write_byte("\x2A\x0E") # language (jpn)
53
+ io.write_uint16(0) # pre_defined
54
+ size = io.pos
55
+ io.pos = 0
56
+ io.write_uint32(size)
57
+ io.pos = 0
58
+
59
+ box = BMFF::Box.get_box(io, nil)
60
+ assert_instance_of(BMFF::Box::MediaHeader, box)
61
+ assert_equal(size, box.actual_size)
62
+ assert_equal("mdhd", box.type)
63
+ assert_equal(1, box.version)
64
+ assert_equal(0, box.flags)
65
+ assert_equal(3482338006, box.creation_time)
66
+ assert_equal(3482338007, box.modification_time)
67
+ assert_equal(1000000, box.timescale)
68
+ assert_equal(30000000, box.duration)
69
+ assert_equal("jpn", box.language)
70
+ assert_equal(0, box.pre_defined)
71
+ end
72
+ 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 TestBMFFBoxMediaInformation < 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("minf")
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::MediaInformation, box)
21
+ assert_equal(size, box.actual_size)
22
+ assert_equal("minf", box.type)
23
+ assert_equal([], box.children)
24
+ assert(box.container?)
25
+ end
26
+ 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 TestBMFFBoxMovie < 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("moov")
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::Movie, box)
21
+ assert_equal(size, box.actual_size)
22
+ assert_equal("moov", box.type)
23
+ assert_equal([], box.children)
24
+ assert(box.container?)
25
+ end
26
+ 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 TestBMFFBoxMovieExtends < 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("mvex")
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::MovieExtends, box)
21
+ assert_equal(size, box.actual_size)
22
+ assert_equal("mvex", box.type)
23
+ assert_equal([], box.children)
24
+ assert(box.container?)
25
+ end
26
+ end
@@ -0,0 +1,52 @@
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 TestBMFFBoxMovieExtendsHeader < MiniTest::Unit::TestCase
9
+ def test_parse_v0
10
+ io = StringIO.new("", "r+:ascii-8bit")
11
+ io.extend(BMFF::BinaryAccessor)
12
+ io.write_uint32(0)
13
+ io.write_ascii("mehd")
14
+ io.write_uint8(0) # version
15
+ io.write_uint24(0) # flags
16
+ io.write_uint32(1000000) # fragment_duration
17
+ size = io.pos
18
+ io.pos = 0
19
+ io.write_uint32(size)
20
+ io.pos = 0
21
+
22
+ box = BMFF::Box.get_box(io, nil)
23
+ assert_instance_of(BMFF::Box::MovieExtendsHeader, box)
24
+ assert_equal(size, box.actual_size)
25
+ assert_equal("mehd", box.type)
26
+ assert_equal(0, box.version)
27
+ assert_equal(0, box.flags)
28
+ assert_equal(1000000, box.fragment_duration)
29
+ end
30
+
31
+ def test_parse_v1
32
+ io = StringIO.new("", "r+:ascii-8bit")
33
+ io.extend(BMFF::BinaryAccessor)
34
+ io.write_uint32(0)
35
+ io.write_ascii("mehd")
36
+ io.write_uint8(1) # version
37
+ io.write_uint24(0) # flags
38
+ io.write_uint64(1000000) # fragment_duration
39
+ size = io.pos
40
+ io.pos = 0
41
+ io.write_uint32(size)
42
+ io.pos = 0
43
+
44
+ box = BMFF::Box.get_box(io, nil)
45
+ assert_instance_of(BMFF::Box::MovieExtendsHeader, box)
46
+ assert_equal(size, box.actual_size)
47
+ assert_equal("mehd", box.type)
48
+ assert_equal(1, box.version)
49
+ assert_equal(0, box.flags)
50
+ assert_equal(1000000, box.fragment_duration)
51
+ end
52
+ 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 TestBMFFBoxMovieFragment < 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("moof")
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::MovieFragment, box)
21
+ assert_equal(size, box.actual_size)
22
+ assert_equal("moof", box.type)
23
+ assert_equal([], box.children)
24
+ assert(box.container?)
25
+ end
26
+ end
@@ -0,0 +1,30 @@
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 TestBMFFBoxMovieFragmentHeader < 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("mfhd")
14
+ io.write_uint8(0) # version
15
+ io.write_uint24(0) # flags
16
+ io.write_uint32(1) # sequence_number
17
+ size = io.pos
18
+ io.pos = 0
19
+ io.write_uint32(size)
20
+ io.pos = 0
21
+
22
+ box = BMFF::Box.get_box(io, nil)
23
+ assert_instance_of(BMFF::Box::MovieFragmentHeader, box)
24
+ assert_equal(size, box.actual_size)
25
+ assert_equal("mfhd", box.type)
26
+ assert_equal(0, box.version)
27
+ assert_equal(0, box.flags)
28
+ assert_equal(1, box.sequence_number)
29
+ end
30
+ 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 TestBMFFBoxMovieFragmentRandomAccess < 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("mfra")
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::MovieFragmentRandomAccess, box)
21
+ assert_equal(size, box.actual_size)
22
+ assert_equal("mfra", box.type)
23
+ assert_equal([], box.children)
24
+ assert(box.container?)
25
+ end
26
+ end
@@ -0,0 +1,30 @@
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 TestBMFFBoxMovieFragmentRandomAccessOffset < 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("mfro")
14
+ io.write_uint8(0) # version
15
+ io.write_uint24(0) # flags
16
+ io.write_uint32(1) # mfra_size
17
+ size = io.pos
18
+ io.pos = 0
19
+ io.write_uint32(size)
20
+ io.pos = 0
21
+
22
+ box = BMFF::Box.get_box(io, nil)
23
+ assert_instance_of(BMFF::Box::MovieFragmentRandomAccessOffset, box)
24
+ assert_equal(size, box.actual_size)
25
+ assert_equal("mfro", box.type)
26
+ assert_equal(0, box.version)
27
+ assert_equal(0, box.flags)
28
+ assert_equal(1, box.mfra_size)
29
+ end
30
+ end
@@ -0,0 +1,110 @@
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 TestBMFFBoxMovieHeader < MiniTest::Unit::TestCase
9
+ def test_parse_v0
10
+ io = StringIO.new("", "r+:ascii-8bit")
11
+ io.extend(BMFF::BinaryAccessor)
12
+ io.write_uint32(0)
13
+ io.write_ascii("mvhd")
14
+ io.write_uint8(0) # version
15
+ io.write_uint24(0) # flags
16
+ io.write_uint32(3482338006) # creation_time
17
+ io.write_uint32(3482338007) # modification_time
18
+ io.write_uint32(1000000) # timescale
19
+ io.write_uint32(30000000) # duration
20
+ io.write_int32(65536) # rate
21
+ io.write_int16(256) # volume
22
+ io.write_byte("\x00\x00") # reserved1
23
+ io.write_uint32(0) # reserved2
24
+ io.write_uint32(0) # reserved2
25
+ io.write_int32(65536) # matrix
26
+ io.write_int32(0) # matrix
27
+ io.write_int32(0) # matrix
28
+ io.write_int32(0) # matrix
29
+ io.write_int32(65536) # matrix
30
+ io.write_int32(0) # matrix
31
+ io.write_int32(0) # matrix
32
+ io.write_int32(0) # matrix
33
+ io.write_int32(1073741824) # matrix
34
+ io.write_byte("\x00\x00\x00\x00" * 6) # pre_defined
35
+ io.write_uint32(1) # next_track_id
36
+ size = io.pos
37
+ io.pos = 0
38
+ io.write_uint32(size)
39
+ io.pos = 0
40
+
41
+ box = BMFF::Box.get_box(io, nil)
42
+ assert_instance_of(BMFF::Box::MovieHeader, box)
43
+ assert_equal(size, box.actual_size)
44
+ assert_equal("mvhd", box.type)
45
+ assert_equal(0, box.version)
46
+ assert_equal(0, box.flags)
47
+ assert_equal(3482338006, box.creation_time)
48
+ assert_equal(3482338007, box.modification_time)
49
+ assert_equal(1000000, box.timescale)
50
+ assert_equal(30000000, box.duration)
51
+ assert_equal(65536, box.rate)
52
+ assert_equal(256, box.volume)
53
+ assert_equal("\x00\x00", box.reserved1)
54
+ assert_equal([0, 0], box.reserved2)
55
+ assert_equal([65536, 0, 0, 0, 65536, 0, 0, 0, 1073741824], box.matrix)
56
+ assert_equal(["\x00\x00\x00\x00"] * 6, box.pre_defined)
57
+ assert_equal(1, box.next_track_id)
58
+ end
59
+
60
+ def test_parse_v1
61
+ io = StringIO.new("", "r+:ascii-8bit")
62
+ io.extend(BMFF::BinaryAccessor)
63
+ io.write_uint32(0)
64
+ io.write_ascii("mvhd")
65
+ io.write_uint8(1) # version
66
+ io.write_uint24(0) # flags
67
+ io.write_uint64(3482338006) # creation_time
68
+ io.write_uint64(3482338007) # modification_time
69
+ io.write_uint32(1000000) # timescale
70
+ io.write_uint64(30000000) # duration
71
+ io.write_int32(65536) # rate
72
+ io.write_int16(256) # volume
73
+ io.write_byte("\x00\x00") # reserved1
74
+ io.write_uint32(0) # reserved2
75
+ io.write_uint32(0) # reserved2
76
+ io.write_int32(65536) # matrix
77
+ io.write_int32(0) # matrix
78
+ io.write_int32(0) # matrix
79
+ io.write_int32(0) # matrix
80
+ io.write_int32(65536) # matrix
81
+ io.write_int32(0) # matrix
82
+ io.write_int32(0) # matrix
83
+ io.write_int32(0) # matrix
84
+ io.write_int32(1073741824) # matrix
85
+ io.write_byte("\x00\x00\x00\x00" * 6) # pre_defined
86
+ io.write_uint32(1) # next_track_id
87
+ size = io.pos
88
+ io.pos = 0
89
+ io.write_uint32(size)
90
+ io.pos = 0
91
+
92
+ box = BMFF::Box.get_box(io, nil)
93
+ assert_instance_of(BMFF::Box::MovieHeader, box)
94
+ assert_equal(size, box.actual_size)
95
+ assert_equal("mvhd", box.type)
96
+ assert_equal(1, box.version)
97
+ assert_equal(0, box.flags)
98
+ assert_equal(3482338006, box.creation_time)
99
+ assert_equal(3482338007, box.modification_time)
100
+ assert_equal(1000000, box.timescale)
101
+ assert_equal(30000000, box.duration)
102
+ assert_equal(65536, box.rate)
103
+ assert_equal(256, box.volume)
104
+ assert_equal("\x00\x00", box.reserved1)
105
+ assert_equal([0, 0], box.reserved2)
106
+ assert_equal([65536, 0, 0, 0, 65536, 0, 0, 0, 1073741824], box.matrix)
107
+ assert_equal(["\x00\x00\x00\x00"] * 6, box.pre_defined)
108
+ assert_equal(1, box.next_track_id)
109
+ end
110
+ end
@@ -0,0 +1,28 @@
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 TestBMFFBoxNullMediaHeader < 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("nmhd")
14
+ io.write_uint8(0) # version
15
+ io.write_uint24(0) # flags
16
+ size = io.pos
17
+ io.pos = 0
18
+ io.write_uint32(size)
19
+ io.pos = 0
20
+
21
+ box = BMFF::Box.get_box(io, nil)
22
+ assert_instance_of(BMFF::Box::NullMediaHeader, box)
23
+ assert_equal(size, box.actual_size)
24
+ assert_equal("nmhd", box.type)
25
+ assert_equal(0, box.version)
26
+ assert_equal(0, box.flags)
27
+ end
28
+ 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 TestBMFFBoxPaddingBits < 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("padb")
14
+ io.write_uint8(0) # version
15
+ io.write_uint24(0) # flags
16
+ io.write_uint32(3) # sample_count
17
+ # sample
18
+ 2.times do |i|
19
+ io.write_uint8(118) # reserved1, pad1, reserved2, pad2
20
+ end
21
+ size = io.pos
22
+ io.pos = 0
23
+ io.write_uint32(size)
24
+ io.pos = 0
25
+
26
+ box = BMFF::Box.get_box(io, nil)
27
+ assert_instance_of(BMFF::Box::PaddingBits, box)
28
+ assert_equal(size, box.actual_size)
29
+ assert_equal("padb", box.type)
30
+ assert_equal(0, box.version)
31
+ assert_equal(0, box.flags)
32
+ assert_equal(3, box.sample_count)
33
+ assert_equal([false, false], box.reserved1)
34
+ assert_equal([7, 7], box.pad1)
35
+ assert_equal([false, false], box.reserved2)
36
+ assert_equal([6, 6], box.pad2)
37
+ end
38
+ end
@@ -0,0 +1,28 @@
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 TestBMFFBoxPixelAspectRatio < 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("pasp")
14
+ io.write_uint32(16) # h_spacing
15
+ io.write_uint32(9) # v_spacing
16
+ size = io.pos
17
+ io.pos = 0
18
+ io.write_uint32(size)
19
+ io.pos = 0
20
+
21
+ box = BMFF::Box.get_box(io, nil)
22
+ assert_instance_of(BMFF::Box::PixelAspectRatio, box)
23
+ assert_equal(size, box.actual_size)
24
+ assert_equal("pasp", box.type)
25
+ assert_equal(16, box.h_spacing)
26
+ assert_equal(9, box.v_spacing)
27
+ end
28
+ end
@@ -0,0 +1,36 @@
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 TestBMFFBoxProgressiveDownloadInfo < 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("pdin")
14
+ io.write_uint8(0) # version
15
+ io.write_uint24(0) # flags
16
+ io.write_uint32(0) # rate
17
+ io.write_uint32(0) # initial_delay
18
+ io.write_uint32(255) # rate
19
+ io.write_uint32(65535) # initial_delay
20
+ io.write_uint32(16777215) # rate
21
+ io.write_uint32(4294967295) # initial_delay
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::ProgressiveDownloadInfo, box)
29
+ assert_equal(size, box.actual_size)
30
+ assert_equal("pdin", box.type)
31
+ assert_equal(0, box.version)
32
+ assert_equal(0, box.flags)
33
+ assert_equal([0, 255, 16777215], box.rate)
34
+ assert_equal([0, 65535, 4294967295], box.initial_delay)
35
+ end
36
+ end