Method: Ogg::Decoder#read_packet
- Defined in:
- lib/ogg.rb
#read_packet ⇒ Object
Seek to and read the next packet in the bitstream. Returns a string containing the packet’s binary data or nil if there are no packets left.
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/ogg.rb', line 123 def read_packet return @packets.pop unless @packets.empty? while @packets.empty? page = read_page raise EOFError.new("End of file reached") if page.nil? input = StringIO.new(page.data) page.segment_table.each do |seg| @partial ||= "" @partial << input.read(seg) if seg != 255 @packets.insert(0, @partial) @partial = nil end end end return @packets.pop end |