Class: FLV::StreamReader
- Inherits:
-
Object
- Object
- FLV::StreamReader
- Defined in:
- lib/flv/stream_reader.rb
Class Method Summary collapse
Instance Method Summary collapse
- #eof? ⇒ Boolean
-
#initialize(io) ⇒ StreamReader
constructor
A new instance of StreamReader.
- #read_byte ⇒ Object
- #read_bytes(n) ⇒ Object
- #read_double_be ⇒ Object
- #read_sint16_be ⇒ Object
- #read_uint16_be ⇒ Object
- #read_uint24_be ⇒ Object
- #read_uint32_be ⇒ Object
- #read_uint32_weird_endian ⇒ Object
- #seek(offset) ⇒ Object
Constructor Details
#initialize(io) ⇒ StreamReader
Returns a new instance of StreamReader.
7 8 9 |
# File 'lib/flv/stream_reader.rb', line 7 def initialize(io) @io = io end |
Class Method Details
.for_string(str) ⇒ Object
11 12 13 |
# File 'lib/flv/stream_reader.rb', line 11 def self.for_string(str) new(StringIO.new(str)) end |
Instance Method Details
#eof? ⇒ Boolean
15 16 17 |
# File 'lib/flv/stream_reader.rb', line 15 def eof? @io.eof? end |
#read_byte ⇒ Object
27 28 29 |
# File 'lib/flv/stream_reader.rb', line 27 def read_byte @io.readbyte end |
#read_bytes(n) ⇒ Object
23 24 25 |
# File 'lib/flv/stream_reader.rb', line 23 def read_bytes(n) @io.read(n) end |
#read_double_be ⇒ Object
53 54 55 |
# File 'lib/flv/stream_reader.rb', line 53 def read_double_be read_bytes(8).unpack("G").first end |
#read_sint16_be ⇒ Object
43 44 45 |
# File 'lib/flv/stream_reader.rb', line 43 def read_sint16_be read_bytes(2).unpack("s>").first end |
#read_uint16_be ⇒ Object
39 40 41 |
# File 'lib/flv/stream_reader.rb', line 39 def read_uint16_be read_bytes(2).unpack("S>").first end |
#read_uint24_be ⇒ Object
35 36 37 |
# File 'lib/flv/stream_reader.rb', line 35 def read_uint24_be "\x00#{read_bytes(3)}".unpack("L>").first end |
#read_uint32_be ⇒ Object
31 32 33 |
# File 'lib/flv/stream_reader.rb', line 31 def read_uint32_be read_bytes(4).unpack("L>").first end |
#read_uint32_weird_endian ⇒ Object
47 48 49 50 51 |
# File 'lib/flv/stream_reader.rb', line 47 def read_uint32_weird_endian lower = read_uint24_be higher = read_byte lower | (higher << 24) end |
#seek(offset) ⇒ Object
19 20 21 |
# File 'lib/flv/stream_reader.rb', line 19 def seek(offset) @io.seek(offset, IO::SEEK_CUR) end |