Giter VIP home page Giter VIP logo

node-ogg-packet's Introduction

node-ogg-packet

Manually construct ogg_packet struct instances

This module lets you construct your own ogg_packet struct instances using JavaScript and Buffers. You'll most likely not need to use this module for any practical purposes, but it is useful for testing purposes.

The more common way to get proper ogg_packet structs is via a decoded OGG file and node-ogg's ogg.Decoder class, or one of the codec's encoder classes like node-vorbis' vorbis.Encoder class.

Installation

$ npm install ogg-packet

Example

var ogg_packet = require('ogg-packet');

// create an `ogg_packet` struct instance
var packet = new ogg_packet();

// the contents of the "packet"
var buf = new Buffer('hello world');
packet.packet = buf;
packet.bytes = buf.length;

// this will be the first packet in the ogg stream
packet.b_o_s = 1;

// there will be more `ogg_packet`s after this one in the ogg stream
packet.e_o_s = 0;

// the "granulepos" is a time-constant value used by the codec decoder
packet.granulepos = 12345;

// the "packetno" should increment by one for each packet in the ogg stream
packet.packetno = 0;

// now send the packet off to an `ogg.Encoder` or
// a codec-specific decoder like `vorbis.Decoder`...
stream.packetin(packet.buffer, function (err) { /* ... */ });

API

ogg_packet class

A ref-struct class that mirrors the ogg_packet fields in the ogg.h file.

typedef struct {
  unsigned char *packet;
  long  bytes;
  long  b_o_s;
  long  e_o_s;
  ogg_int64_t  granulepos;
  ogg_int64_t  packetno;
} ogg_packet;

node-ogg-packet's People

Contributors

itsphant avatar tootallnate avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.