Class: FLV::Tag
Overview
FLV files consists of a single header and a collection of Tags. Tags all have a timestamp and a body; this body can be Audio, Video, or Event.
Constant Summary collapse
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#timestamp ⇒ Object
Returns the value of attribute timestamp.
Instance Method Summary collapse
-
#debug(format, compared_with = nil) ⇒ Object
:nodoc.
-
#initialize(timestamp = 0, body = nil) ⇒ Tag
constructor
A new instance of Tag.
-
#is?(what) ⇒ Boolean
:nodoc.
- #method_missing(*arg, &block) ⇒ Object
-
#read_packed(io, options) ⇒ Object
:nodoc.
-
#write_packed(io) ⇒ Object
:nodoc.
Methods included from Base
#getters, included, #size, #to_hash
Constructor Details
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(*arg, &block) ⇒ Object
55 56 57 58 59 |
# File 'lib/flvedit/flv/tag.rb', line 55 def method_missing(*arg, &block) super rescue NoMethodError body.send(*arg, &block) end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
6 7 8 |
# File 'lib/flvedit/flv/tag.rb', line 6 def body @body end |
#timestamp ⇒ Object
Returns the value of attribute timestamp.
6 7 8 |
# File 'lib/flvedit/flv/tag.rb', line 6 def @timestamp end |
Instance Method Details
#debug(format, compared_with = nil) ⇒ Object
:nodoc
46 47 48 49 |
# File 'lib/flvedit/flv/tag.rb', line 46 def debug(format, compared_with = nil) #:nodoc format.header("#{} ", @body.title) @body.debug(format) unless compared_with && @body.similar_to?(compared_with.body) end |
#is?(what) ⇒ Boolean
:nodoc
51 52 53 |
# File 'lib/flvedit/flv/tag.rb', line 51 def is?(what) #:nodoc super || body.is?(what) end |
#read_packed(io, options) ⇒ Object
:nodoc
36 37 38 39 40 41 42 43 44 |
# File 'lib/flvedit/flv/tag.rb', line 36 def read_packed(io, ) #:nodoc len = io.pos_change do code, body_len, , , streamid = io >>:char >>:unsigned_24bits >>:unsigned_24bits >>:char >>:unsigned_24bits @timestamp = Timestamp.in_milliseconds( + ( << 24)) @body = io.read CLASS_CODE[code] || Body, :bytes => body_len end FLV::Util.double_check :size, len, io.read(:unsigned_long) #todo end |
#write_packed(io) ⇒ Object
:nodoc
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/flvedit/flv/tag.rb', line 23 def write_packed(io, *) #:nodoc packed_body = @body.pack len = io.pos_change do io << [CLASS_CODE.key(self.body.class), :char] \ << [packed_body.length, :unsigned_24bits] \ << [@timestamp.in_milliseconds, :unsigned_24bits] \ << [@timestamp.in_milliseconds >>24, :char] \ << [streamid=0, :unsigned_24bits] \ << packed_body end io << [len, :unsigned_long] end |