Class: Discorb::Voice::OggStream::Page
- Inherits:
-
Object
- Object
- Discorb::Voice::OggStream::Page
- Defined in:
- lib/discorb/voice/ogg.rb
Overview
Represents a page of the Ogg stream.
Defined Under Namespace
Classes: Packet
Instance Attribute Summary collapse
-
#bitstream_serial_number ⇒ Integer
readonly
The bitstream serial number of the page.
-
#body ⇒ String
readonly
The body of the page.
-
#crc_checksum ⇒ Integer
readonly
The CRC checksum of the page.
-
#granule_position ⇒ Integer
readonly
The granule position of the page.
-
#header_type ⇒ Integer
readonly
The header type of the page.
-
#page_segments ⇒ Integer
readonly
The length of the page segment table.
-
#page_sequence_number ⇒ Integer
readonly
The page sequence number of the page.
-
#version ⇒ Integer
readonly
The version of the page.
Instance Method Summary collapse
-
#initialize(io) ⇒ Page
constructor
Creates a new page.
-
#packets ⇒ Enumerator<Discorb::Voice::OggStream::Page::Packet>
Enumerates the packets of the page.
Constructor Details
#initialize(io) ⇒ Page
This method will seek the io.
Creates a new page.
84 85 86 87 88 89 90 |
# File 'lib/discorb/voice/ogg.rb', line 84 def initialize(io) @version, @header_type, @granule_position, @bitstream_serial_number, @page_sequence_number, @crc_checksum, @page_segments = io.read(23).unpack("CCQ<L<L<L<C") @segtable = io.read(@page_segments) len = @segtable.unpack("C*").sum @body = io.read(len) end |
Instance Attribute Details
#bitstream_serial_number ⇒ Integer (readonly)
Returns The bitstream serial number of the page.
68 69 70 |
# File 'lib/discorb/voice/ogg.rb', line 68 def bitstream_serial_number @bitstream_serial_number end |
#body ⇒ String (readonly)
Returns The body of the page.
76 77 78 |
# File 'lib/discorb/voice/ogg.rb', line 76 def body @body end |
#crc_checksum ⇒ Integer (readonly)
Returns The CRC checksum of the page.
72 73 74 |
# File 'lib/discorb/voice/ogg.rb', line 72 def crc_checksum @crc_checksum end |
#granule_position ⇒ Integer (readonly)
Returns The granule position of the page.
66 67 68 |
# File 'lib/discorb/voice/ogg.rb', line 66 def granule_position @granule_position end |
#header_type ⇒ Integer (readonly)
Returns The header type of the page.
64 65 66 |
# File 'lib/discorb/voice/ogg.rb', line 64 def header_type @header_type end |
#page_segments ⇒ Integer (readonly)
Returns The length of the page segment table.
74 75 76 |
# File 'lib/discorb/voice/ogg.rb', line 74 def page_segments @page_segments end |
#page_sequence_number ⇒ Integer (readonly)
Returns The page sequence number of the page.
70 71 72 |
# File 'lib/discorb/voice/ogg.rb', line 70 def page_sequence_number @page_sequence_number end |
#version ⇒ Integer (readonly)
Returns The version of the page.
62 63 64 |
# File 'lib/discorb/voice/ogg.rb', line 62 def version @version end |
Instance Method Details
#packets ⇒ Enumerator<Discorb::Voice::OggStream::Page::Packet>
Enumerates the packets of the page.
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/discorb/voice/ogg.rb', line 97 def packets Enumerator.new do |enum| offset = 0 length = 0 partial = true @segtable.bytes.each do |seg| if seg == 255 length += 255 partial = true else length += seg partial = false enum << Packet.new(@body[offset, length], partial, self) offset += length length = 0 end end enum << Packet.new(@body[offset, length], partial, self) if partial end end |