class Ogg::Reader
Reads pages and packets from an ogg stream
Attributes
input[R]
Public Class Methods
new(input)
click to toggle source
# File lib/ogg/reader.rb, line 6 def initialize(input) @input = input end
Public Instance Methods
each_pages(options = {}) { |read| ... }
click to toggle source
# File lib/ogg/reader.rb, line 10 def each_pages(options = {}) until @input.eof? yield Page.read(@input, options) end end
read_packets(max_packets)
click to toggle source
# File lib/ogg/reader.rb, line 16 def read_packets(max_packets) result = [] partial_packet = "" each_pages do |page| partial_packet = page.segments.inject(partial_packet) do |packet,segment| packet << segment if segment.length < 255 #end of packet result << packet return result if result.length == max_packets "" else packet end end end # We expect packets to reach page boundaries, consider raising exception if partial_packet here. result end