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 🙏

© 2026 – Pkg Stats / Ryan Hefner

ngwebrtc

v1.0.1

Published

AngularJS WebRTC Helpers

Readme

#AngularJS WebRTC Module

Dependencies

  • angular-base64

Setup

bower install https://github.com/lp1dev/ngWebRTC.git

Usage

Add the following lines to your index.html :

<script type="text/javascript" src="{bower_directory}/angular-base64/angular-base64.js"></script>
<script type="text/javascript" src="{bower_directory}/angular-webrtc/dist/js/ngWebRTC.js"></script>

And the following dependencies to your angular app :

angular.module('app',
  [
    'base64',
    'ngWebRTC'
  ])

This module provides a $webrtc service to handle your WebRTC interactions.

Browser-related interactions have been wrapped to be as easy to use as possible, but you will probably need at least a basic understanding of the WebRTC protocol.

Initialisation

First, you have to retrieve your local browser's stream using

$webrtc.getUserMedia (onUserMediaSuccess, onUserMediaError, constraints);
  • onUserMediaSuccess(stream) callback is entered when the browser has successfully retrieved a media stream from the local camera/microphone.
  • onUserMediaError(error) callback is entered when it failed, for instance if you refused to share your audio/video in the popup window.
  • constraints is an optional object, used to specify if you want to share your audio,video or both. By default its value is {audio:true, video:true}.

Then you have to call the init method to initialize the service.

$webrtc.init (stream, connectCallback, disconnectCallback, pendingCallback, iceConfig, serverConfig)
  • stream is the Stream object retrieved from the onUserMediaSuccess callback.
  • connectCallback is entered when you successfully connect to another user's stream
  • disconnectCallback is entered when this stream hangs.
  • pendingCallback is entered when you are trying to connect.
  • iceConfig is the configuration passed to the RTCPeerConnection Interface. If undefined { 'iceServers': [ { 'urls': 'stun.l.google.com:19302' } ] } will be used.
  • serverConfig is your own server configuration, the object needs to be formatted like this :
serverConfig = {
      url: 'http(s)://{Your Server's  URL}',
      methods: {
        postIceCandidate: function (candidate, emitter) { //Your post request here },
        postOffer: function (RTCDescription, emitter, type) { //Your post request here }
      }
    }

Actions on new offers

Now that you can send offers and IceCandidates on your server, you should be able to handle the offers reception inside your controller.

Once you've been able to retrieve an offer's data, you can accept another's user offer using

$webrtc.acceptOffer(offer)

The offer object must be formatted like this :

offer = {
    type: 'rdp-offer'
    emitter: {An identifier for the user emitting the offer},
    RDPDescription: {The same RTCDescription object given to the postOffer method}
}

Upon approval, an answer like this one :

answer = {
    type: 'sdp-answer'
    emitter: {An identifier for the user emitting the answer},
    RDPDescription: {Your RTCDescription}
}

will automatically be sent to your server using the same serverConfig.methods.postOffer method.

The Ice candidates will be automatically handled and sent to your server in an object like this :

iceCandidate = {
    type: 'ice',
    emitter: {An identifier for the user emitting the ice candidate},
    ice: {The ice candidate given by your the emitter's browser}
}

It must be communicated to the corresponding recipient and the same iceCandidate object given to the $webrtc.onExternalIceCandidate method for the connection to be established.

Streams

Once the local stream has been configured, you can retrieve it using : $webrtc.getLocalMediaStream().

If an external connection is successfull you can retrieve the external stream using : $webrtc.getExternalMediaStream().

You can now store these objects in a streamURL Object for your browser to be able to display it :

$scope.streamURL = window.URL.createObjectURL(stream)

They both can be displayed in a HTML video element like this

<video autoplay ng-src="{{ $scope.streamURL //Your stream object, $scope.streamURL for instance }}">

Standard - JavaScript Style Guide