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

upnp-device

v0.2.0

Published

Create UPnP devices in Node.js

Downloads

4

Readme

UPnP Devices for Node.js

upnp-device lets you create UPnP Devices in Node.js. The goal is to have an easy to use API, rather than exposing all UPnP internals.

Limitations

  • 2 implemented device specification included: MediaServer:1 and BinaryLight:1
  • MediaServer has only been tested with audio

Install

npm install upnp-device

In case you want to use the built in media server you also need to install Redis, preferrably using your system package manager.

Documentation

Basic usage

var upnp = require('upnp-device');

var mediaServer = upnp.createDevice('MediaServer', 'My Media Application');

mediaServer.on('ready', function() {
    mediaServer.addMedia(0, media, function(err, id) {
        console.log("Added new media with ID:" + id);
    });
    mediaServer.ssdpAnnounce();
});

For a real world usage example, look at Bragi, a media server using node-upnp-device.

API

upnp.Device

Event: 'ready'

function() { }

Emitted when the server has been assigned an IP, the HTTP server has started and SSDP messaging has been initialized.

Event: 'error'

function(err) { }

upnp.createMyDevice(device, name[, address])

Create an instance of your own device implementation. Check the examples on how to create your own devices and services.

  • implementation - A implementation of a device specified by the UPnP Forum
  • name - The name of the device as it shows up in the network.
  • address - Optional IP address to bind server to. If the address is omitted an IPv4 address will guessed using the IP configuration
var myDevice = require('./MyDevice')

var device = upnp.createMyDevice(myDevice, 'My Device');

device.on('ready', function() {
    device.ssdpAnnounce();
});

upnp.createDevice(type, name[, address])

  • type - A device specified by the UPnP Forum.
  • name - The name of the device as it shows up in the network.
  • address - Optional IP address to bind server to. If the address is omitted an IPv4 address will guessed using the IP configuration

device.addMedia(parentID, media[, callback])

Applies to MediaServer.

The metadata needs to be extracted by the client, either through user input or by reading for example ID3 tags.

  • parentID - Parent container of media. 0 means root.
  • properties - Object with class properties. Example below.
  • [callback(err, id)] - Called when all media has been added to the database. Returns the ID of the top container added.
container = {
    'class': 'object.container.album.musicAlbum',
    'title': 'My album'
};
item = {
    'class': 'object.container.audioItem.musicTrack',
    'title': 'My song',
    'creator': 'An artist',
    'location': '/media/mp3/an_artist-my_song.mp3',
    'album': 'My album'
};

Other official UPnP classes and properties are defined in the MediaServer specification.

The server only stores the media info for as long as it is running. It is the responsibility of the client to store media information across restarts if desired.

device.removeMedia(id[, callback])

  • id - ID of object to remove. If it has children, they will also be removed.
  • [callback(err)]

Development

upnp-device is written in CoffeeScript.

Contributions and comments are welcome on GitHub or IRC (jacobrask@FreeNode).

Acronyms

  • UDA: [UPnP Device Architecture] upnp-uda
  • DCP: [UPnP Device Control Protocol] upnp-dcp
  • DIDL: Digital Item Declaration Language, XML dialect for describing media. To describe content in AV devices, UPnP uses DIDL-Lite, a subset of DIDL.
  • UPnP AV: [UPnP Audio/Video] upnp-av

See also