Skip to content

@moq/hang

npmTypeScript

Core media library for Media over QUIC, built on top of @moq/lite. Provides shared primitives used by @moq/watch and @moq/publish.

Overview

@moq/hang provides:

  • Catalog - JSON track describing other tracks and their codec properties (audio, video, chat, location, etc.)
  • Container - Media framing in two formats: CMAF (fMP4) and Legacy (varint-timestamp + raw codec bitstream)
  • Support - Browser capability detection and <hang-support> Web Component
  • Utilities - Hex encoding, Opus audio polyfill (libav), latency computation, browser detection workarounds

Installation

bash
bun add @moq/hang
# or
npm add @moq/hang
pnpm add @moq/hang

Web Component

<hang-support>

Display browser support information:

html
<script type="module">
    import "@moq/hang/support/element";
</script>

<hang-support mode="publish" show="partial"></hang-support>

JavaScript API

typescript
import * as Hang from "@moq/hang";

// Catalog — describes tracks and their codec properties
import * as Catalog from "@moq/hang/catalog";

// Container — media framing (CMAF and Legacy formats)
import * as Container from "@moq/hang/container";

// CMAF (fMP4) and Legacy (varint-timestamp + raw bitstream) are both available:
// Container.Cmaf — createVideoInitSegment, createAudioInitSegment, encodeDataSegment, decodeDataSegment, etc.
// Container.Legacy — Producer / Consumer classes

For watching and publishing, use the dedicated packages:

typescript
import * as Watch from "@moq/watch";
import * as Publish from "@moq/publish";

Protocol Specification

See the hang specification.

Next Steps

Licensed under MIT or Apache-2.0