Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Simple string descriptors for WebRTC video and audio streams
JavaScript
tag: v0.1.0

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
test
.gitignore
.travis.yml
AUTHORS
LICENSE
README.md
capture-config.js
docs.json
index.js
package.json

README.md

rtc-streamclass

This is a simple parser that takes a string of text and determines what that means in the context of WebRTC.

NPM

Build Status unstable

Why?

It provides a simple, textual way of describing your requirements for media capture. Trying to remember the structure of the constraints object is painful.

How

A simple text string is converted to an intermediate JS object representation, which can then be converted to a getUserMedia constraints data structure using a toConstraints() call.

For example, the following text input:

camera min:1280x720 max:1280x720 min:15fps max:25fps

Is converted into an intermedia representation (via the CaptureConfig utility class) that looks like the following:

{
  camera: 0,
  microphone: 0,
  res: {
    min: { w: 1280, h: 720 },
    max: { w: 1280, h: 720 }
  },

  fps: {
    min: 15,
    max: 25
  }
}

Which in turn is converted into the following media constraints for a getUserMedia call:

{
  audio: true,
  video: {
    mandatory: {
      minFrameRate: 15,
      maxFrameRate: 25,

      minWidth: 1280,
      minHeight: 720,
      maxWidth: 1280,
      maxHeight: 720
    },

    optional: []
  }
}

Reference

CaptureConfig

This is a utility class that is used to update capture configuration details and is able to generate suitable getUserMedia constraints based on the configuration.

camera(index)

Update the camera configuration to the specified index

microphone(index)

Update the microphone configuration to the specified index

max(data)

Update a maximum constraint. If an fps constraint this will be directed to the maxfps modifier.

maxfps(data)

Update the maximum fps

min(data)

Update a minimum constraint. This can be either related to resolution or FPS.

minfps(data)

Update the minimum fps

toConstraints(version?)

Convert the internal configuration object to a valid media constraints representation.

"Internal" methods

_parseRes(data)

Parse a resolution specifier (e.g. 1280x720) into a simple JS object (e.g. { w: 1280, h: 720 })

License(s)

Apache 2.0

Copyright 2013 National ICT Australia Limited (NICTA)

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Something went wrong with that request. Please try again.