class FLV::FLVTag
Constants
- AUDIO
- META
- UNDEFINED
- VIDEO
Attributes
Public Class Methods
Source
# File lib/flv/tag.rb, line 43 def initialize(stream = nil) @tag_type = UNDEFINED @byte_offset = nil unless stream.nil? data_size = stream.read__UI24 @timestamp = stream.read__UI24 stream.read__UI32 @data = stream.read(data_size) else @timestamp = 0 @data = '' end after_initialize(stream.nil?) if respond_to? :after_initialize end
Source
# File lib/flv/tag.rb, line 96 def self.type2name(type) case type when AUDIO 'audio' when VIDEO 'video' when META 'meta' when UNDEFINED 'undefined' else "unknown(#{type})" end end
Public Instance Methods
Source
# File lib/flv/tag.rb, line 84 def info "#{name}: timestamp #{timestamp}, size #{size}, data size #{data_size}" end
Source
# File lib/flv/tag.rb, line 88 def inspect out = ["tag: #{self.class}"] out << "timestamp: #{@timestamp}" out << "size: #{size}" out << "data_size: #{data_size}" out end
Source
# File lib/flv/tag.rb, line 76 def serialize(stream) stream.write__UI8 tag_type stream.write__UI24 data_size stream.write__UI24 timestamp stream.write__UI32 0 stream.write__STRING data end
Source
# File lib/flv/tag.rb, line 59 def size # header(11) + body(data_size) 11 + data_size end
Private Instance Methods
Source
# File lib/flv/tag.rb, line 112 def bit2uint(sequence) int = 0 sequence.split(//).each_with_index do |character, i| int += 2 ** (sequence.length - i - 1) if character == '1' end int end