module Ogg
Constants
- CHECKSUM_TABLE
Public Class Methods
compute_checksum(data_)
click to toggle source
Calculate the checksum from the page (or the pre packed data) If data it supplied it will be updated to record the checksum value
# File lib/ogg.rb, line 100 def compute_checksum(data_) data = data_.dup data[22..25] = [0].pack("V") crc = 0 data.each_byte do |byte| crc = (crc << 8)^CHECKSUM_TABLE[((crc >> 24)&0xff) ^ byte] crc = crc & 0xffffffff end crc end
detect_codec(input)
click to toggle source
# File lib/ogg.rb, line 81 def detect_codec(input) if input.kind_of?(Page) first_page = input else first_page = Page.read(input) input.rewind end codecs = Ogg::Codecs.constants.map { |module_name| Ogg::Codecs.class_eval(module_name.to_s) }.select { |c| c.is_a?(Class) } codec = codecs.detect { |c| c.match?(first_page.segments.first) } unless codec raise(StreamError,"unknown codec") end return codec end