# ogg-packet

> Manually construct `ogg_packet` struct instances

Latest version **1.0.1** (published 2019-03-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install ogg-packet
pnpm add ogg-packet
yarn add ogg-packet
bun add ogg-packet
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2019-03-13 |
| First published | 2012-12-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 3.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 6 |
| Author | Nathan Rajlich |
| Maintainers | tootallnate |
| Keywords | ogg, libogg, packet, ogg_packet, struct |

## Links

- npm: https://www.npmjs.com/package/ogg-packet
- Repository: https://github.com/TooTallNate/node-ogg-packet
- Homepage: https://github.com/TooTallNate/node-ogg-packet#readme
- Issues: https://github.com/TooTallNate/node-ogg-packet/issues
- npm.io page: https://npm.io/package/ogg-packet

## Dependencies (1)

- [ref-struct](https://npm.io/package/ref-struct.md) *

## Alternatives

- [cli-color](https://npm.io/package/cli-color.md) — 3.4M weekly downloads
- [log](https://npm.io/package/log.md) — 1.3M weekly downloads
- [logstash-client](https://npm.io/package/logstash-client.md) — 4.5K weekly downloads
- [@nocobase/plugin-logger](https://npm.io/package/@nocobase/plugin-logger.md) — 2.0K weekly downloads
- [child-process-debug](https://npm.io/package/child-process-debug.md) — 695 weekly downloads

## Recent versions

- 1.0.1 (latest) — 2019-03-13
- 1.0.0 — 2012-12-02

## README

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
------------

``` bash
$ npm install ogg-packet
```


Example
-------

``` javascript
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.

``` c
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;
 ```

---
_Source: https://npm.io/package/ogg-packet · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
