class BMFF::Box::SampleEncryption
vim: set expandtab tabstop=2 shiftwidth=2 softtabstop=2 autoindent:
Constants
- DEFAULT_IV_SIZE
Attributes
algorithm_id[RW]
iv_size[RW]
kid[RW]
sample_count[RW]
samples[RW]
Public Instance Methods
parse_data()
click to toggle source
Calls superclass method
BMFF::Box::Full#parse_data
# File lib/bmff/box/sample_encryption.rb, line 18 def parse_data super if flags & 0x01 > 0 @algorithm_id = io.get_uint24 @iv_size = io.get_uint8 @kid = io.get_uuid end @sample_count = io.get_uint32 @samples = [] @sample_count.times do sample = Sample.new if @iv_size iv_size_to_read = @iv_size else iv_size_to_read = default_iv_size end sample.initialization_vector = io.get_byte(iv_size_to_read) if flags & 0x02 > 0 sample.number_of_entries = io.get_uint16 sample.entries = [] sample.number_of_entries.times do entry = Entry.new entry.bytes_of_clear_data = io.get_uint16 entry.bytes_of_encrypted_data = io.get_uint32 sample.entries << entry end end @samples << sample end end
Private Instance Methods
default_iv_size()
click to toggle source
# File lib/bmff/box/sample_encryption.rb, line 49 def default_iv_size if track_encryption = find_track_encryption track_encryption.default_iv_size else DEFAULT_IV_SIZE end end
find_track_encryption()
click to toggle source
# File lib/bmff/box/sample_encryption.rb, line 60 def find_track_encryption root_container = root unless root_container.object_id == @@cached_root_object_id @@cached_root_object_id = root_container.object_id @@cached_track_encryption = root_container.select_descendants(BMFF::Box::TrackEncryption).first end @@cached_track_encryption end