Class: Discorb::Voice::OggStream
- Inherits:
-
Object
- Object
- Discorb::Voice::OggStream
- Defined in:
- lib/discorb/voice/ogg.rb
Overview
Represents a Ogg stream.
Defined Under Namespace
Classes: Page
Instance Method Summary collapse
-
#initialize(io) ⇒ OggStream
constructor
Creates a new Ogg stream.
-
#packets ⇒ Enumerator<Discorb::Voice::OggStream::Page::Packet>
Enumerates the packets of the Ogg stream.
-
#raw_packets ⇒ Enumerator<Discorb::Voice::OggStream::Page::Packet>
Enumerates the raw packets of the Ogg stream.
Constructor Details
#initialize(io) ⇒ OggStream
Creates a new Ogg stream.
13 14 15 |
# File 'lib/discorb/voice/ogg.rb', line 13 def initialize(io) @io = io end |
Instance Method Details
#packets ⇒ Enumerator<Discorb::Voice::OggStream::Page::Packet>
Enumerates the packets of the Ogg stream.
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/discorb/voice/ogg.rb', line 22 def packets Enumerator.new do |enum| part = +"" raw_packets.each do |packet| part << packet.data unless packet.partial enum << part part = +"" end end end end |
#raw_packets ⇒ Enumerator<Discorb::Voice::OggStream::Page::Packet>
Enumerates the raw packets of the Ogg stream. This may include partial packets.
41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/discorb/voice/ogg.rb', line 41 def raw_packets Enumerator.new do |enum| loop do # p c += 1 break if @io.read(4) != "OggS" pg = Page.new(@io) pg.packets.each do |packet| enum << packet end # enum << pg.packets.next end end end |