Skip to content

Repository files navigation

ogg-ruby Gem VersionRuby

Ruby FFI bindings for libogg, the OGG container format library.

Requirements

  • Ruby 3.1+
  • libogg installed on your system

Installing libogg

macOS:

brew install libogg

Debian/Ubuntu:

sudo apt-get install libogg-dev

Fedora/RHEL:

sudo dnf install libogg-devel

Installation

Add this line to your application's Gemfile:

gem"ogg-ruby"

And then execute:

bundle install

Or install it yourself as:

gem install ogg-ruby

Usage

Encoding (Packet → StreamState → Page)

require"ogg"stream=Ogg::StreamState.new(1)# serial number# Add packets to the streampacket=Ogg::Packet.new(data: "Hello, OGG!",bos: true,granulepos: 0,packetno: 0)stream.packetin(packet)packet2=Ogg::Packet.new(data: "More data",eos: true,granulepos: 1,packetno: 1)stream.packetin(packet2)# Extract pagespages=[]while(page=stream.flush)pages << page.to_sendstream.clear

Decoding (SyncState → Page → StreamState → Packet)

require"ogg"sync=Ogg::SyncState.new# Write encoded data into syncsync.write(encoded_page_data)# Extract pageswhile(page=sync.pageout)# Create a stream decoder with the same serial numberstream=Ogg::StreamState.new(page.serialno)stream.pagein(page)# Extract packetswhile(packet=stream.packetout)putspacket.dataendstream.clearendsync.clear

Thread Safety

libogg functions are not thread-safe. Do not share SyncState or StreamState objects across threads without external synchronization.

License

The gem is available as open source under the terms of the MIT License.

About

Ruby FFI bindings for libogg, the OGG container format library.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages