npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@astronautlabs/rtmp

v1.1.0

Published

Real Time Messaging Protocol (RTMP)

Downloads

7

Readme

@/rtmp

📜 Adobe RTMP (December 21, 2012)
Adobe’s Real Time Messaging Protocol (RTMP)

Stable
This library is a mostly-complete and working implementation of RTMP. (stable, semver 1.x.x).

📺 Part of the Astronaut Labs Broadcast Suite

See also:

  • @/amf - Adobe's Action Message Format (AMF)
  • @/flv - Adobe's Flash Video format (FLV)

Comprehensive Typescript implementation of Adobe's Real Time Messaging Protocol (RTMP) using Bitstream

Motivation

This library is intended to provide an approachable and comprehensive RTMP implementation for Node.js using Typescript. It uses similar concepts to those of Adobe Flash / Flash Media Server / Flex in exposing RTMP to users. Supports AMF v0 and v3 via @astronautlabs/amf

Installation

npm i @astronautlabs/rtmp

Examples

Server

import 'reflect-metadata';
import 'source-map-support/register';

import { Socket } from 'net';
import * as RTMP from '@astronautlabs/rtmp';

class MyServer extends RTMP.Server {
    protected createSession(socket: Socket): RTMP.Session {
        return new MySession(this, socket);
    }
}

class MySession extends RTMP.Session {
    protected createStream(id: number): RTMP.ServerMediaStream {
        return new MyStream(this, id);
    }
}

class MyStream extends RTMP.ServerMediaStream {
    play(streamName: string, start: number, duration: number, reset: boolean): void {
        // Client wants to receive this stream.

        this.notifyBegin();

        this.sendVideo(Buffer.from([ ... ]));
        this.sendAudio(Buffer.from([ ... ]));
    }

    publish(streamName : string) {
        // Client is publishing this stream
    }

    receiveVideo(data : Uint8Array) {
        // Do something with the video packets
    }

    receiveAudio(data : Uint8Array) {
        // Do something with the audio packets
    }
}

let server = new MyServer();
server.listen();

Custom RPC

import 'reflect-metadata';
import 'source-map-support/register';

import { Socket } from 'net';
import * as RTMP from '.';

class MyServer extends RTMP.Server {
    protected createSession(socket: Socket): RTMP.Session {
        return new MySession(this, socket);
    }
}

class MySession extends RTMP.Session {
    protected createStream(id: number): RTMP.ServerMediaStream {
        return new MyStream(this, id);
    }
}

class MyStream extends RTMP.ServerMediaStream {

    /**
     * Mark any method with `@RPC()` to expose it as an RTMP command.
     * Here the command 'customMethod' gets mapped to this method, with
     * its parameters automatically converted from AMF0/3 to the appropriate
     * Javascript types, and the return value being sent back in a "_result" 
     * response. If an exception is thrown, an "_error" response is sent back with 
     * a summary of the error.
     */
    @RPC() customMethod(foo : string, bar : number[]) {
        return { message: 'All done!' };
    }

    play(streamName: string, start: number, duration: number, reset: boolean): void {
        console.log(`play('${streamName}', ${start}, ${duration}, ${reset})`);
        super.play(streamName, start, duration, reset);
    }
}

let server = new MyServer();
server.listen();