Module: FLV::Packing
- Defined in:
- lib/flvedit/flv/packing.rb
Overview
FLV files can contain structured data. This modules makes it easy to (un)pack that data. The packing option flv_value
can (un)pack any kind of variable. It corresponds to SCRIPTDATAVALUE
in the official FLV file format spec. Implementation Note: flv_value
is actually simply a wrapper that will (un)pack the type of variable; the actual data is (un)packed with the format flv
, which is independently defined for each type
Defined Under Namespace
Classes: EndOfList
Constant Summary collapse
- TYPE_TO_CLASS =
Top-level :flv_value filter:
Hash.new do |h, type| #EndOfList raise IOError, "Invalid type for a flash variable. #{type.inspect} is not in #{h.keys}" #todo: handle error for corrupted da end.merge!( 0 => Numeric , 1 => TrueClass , # There really should be a Boolean class! 2 => String , 3 => Hash , 8 => [Hash, :flv_with_size], 9 => EndOfList , 10 => Array , 11 => Time , nil => NilClass ).freeze
- CLASS_TO_TYPE =
Hash.new do |h, klass| # Makes it such that CLASS_TO_TYPE[Fixnum] = CLASS_TO_TYPE[Integer], etc. h[klass] = h[klass.superclass] end.merge!(TYPE_TO_CLASS.invert).merge!( Event => TYPE_TO_CLASS.key([Hash, :flv_with_size]), # Write Events as hashes with size FalseClass => TYPE_TO_CLASS.key(TrueClass) )