7

I'm trying to test a WebRTC application. Right now the best I can do is to open several private browser windows and let them talk to each other, but this clearly doesn't scale.

I'm looking for a way to create a large number of peers on a single machine. I was looking into Phantom.js but it didn't seem to support WebRTC yet. Any suggestions?

Derek Chiang
  • 3,330
  • 6
  • 27
  • 34

2 Answers2

7

The problem is that PhantomJS currently is based on QtWebKit, and WebRTC needs components from Chromium as well as WebKit.

It would be a lot of work for Phantom.js to re-implement all this -- and there are also issues with codec support, etc. Also occurs to me that in a headless environment it would be hard to test getUserMedia(), which is fundamental to WebRTC, but requires user interaction and can't be scripted.

Sam Dutton
  • 14,775
  • 6
  • 54
  • 64
  • 8
    I think that headless WebRTC would be useful for applications that use data channels rather than video. For example, peer-to-peer networks made up of a mixture of browser and non-browser nodes. – Jesse Hallett Aug 06 '13 at 06:53
1

For MediaStream it can be used https://www.npmjs.com/package/mediastream as:

import { MediaStream as libMediaStream } from 'mediastream';

For getUserMedia() it can be used https://www.npmjs.com/package/get-user-media-promise as:

(<any>window.navigator).mediaDevices = Object.assign({}, 
  window.navigator.mediaDevices,
  { getUserMedia: require('get-user-media-promise')}
);

RTCPeerConnection, depends on your unit tests, might be mocked as:

window['RTCPeerConnection'] = () => {
  return {
    close: () => { },
    getTracks: () => { },
    addStream: () => { },
    createOffer: () => { },
    addIceCandidate: () => { },
    setRemoteDescription: () => { },
    createAnswer: () => { },
    setLocalDescription: () => { }
  };
};
user3007799
  • 137
  • 1
  • 8