mediasoup-client
Advanced tools
Comparing version 0.1.2 to 0.2.0
/* | ||
* <%= pkg.name %> v<%= pkg.version %> | ||
* <%= pkg.description %> | ||
* <%= pkg.homepage %> | ||
* Copyright © 2017, Iñaki Baz Castillo <ibc@aliax.net> | ||
@@ -5,0 +6,0 @@ * License: <%= pkg.license %> |
@@ -10,3 +10,3 @@ 'use strict'; // eslint-disable-line strict | ||
const browserify = require('browserify'); | ||
const uglify = require('gulp-uglify'); // TODO: TMP | ||
const uglify = require('gulp-uglify'); | ||
const source = require('vinyl-source-stream'); | ||
@@ -13,0 +13,0 @@ const buffer = require('vinyl-buffer'); |
@@ -16,2 +16,15 @@ import bowser from 'bowser'; | ||
/** | ||
* Get the device flag. | ||
* | ||
* @return {String} | ||
*/ | ||
static get flag() | ||
{ | ||
if (!Device._detected) | ||
Device._detect(); | ||
return Device._flag; | ||
} | ||
/** | ||
* Get the device name. | ||
@@ -79,2 +92,3 @@ * | ||
Device._detected = true; | ||
Device._flag = undefined; | ||
Device._name = browser.name || 'unknown device'; | ||
@@ -84,30 +98,38 @@ Device._version = browser.version || 'unknown vesion'; | ||
// Chrome, Chromium, Opera (desktop and mobile). | ||
if (bowser.check({ chrome: '55', chromium: '55', opera: '44' }, true, ua)) | ||
// Chrome, Chromium (desktop and mobile). | ||
if (bowser.check({ chrome: '55' }, true, ua)) | ||
{ | ||
Device._flag = 'chrome'; | ||
Device._handlerClass = Chrome55; | ||
} | ||
// Firefox (desktop and mobile). | ||
else if (bowser.check({ firefox: '50' }, true, ua)) | ||
{ | ||
Device._flag = 'firefox'; | ||
Device._handlerClass = Firefox50; | ||
} | ||
// Safari (desktop and mobile). | ||
else if (bowser.check({ safari: '11' }, true, ua)) | ||
{ | ||
Device._flag = 'safari'; | ||
Device._handlerClass = Safari11; | ||
} | ||
// Firefox (desktop and mobile). | ||
else if (bowser.check({ firefox: '50' }, true, ua)) | ||
{ | ||
Device._handlerClass = Firefox50; | ||
} | ||
// Edge (desktop). | ||
else if (bowser.check({ msedge: '11' }, true, ua)) | ||
{ | ||
Device._flag = 'msedge'; | ||
Device._handlerClass = Edge11; | ||
} | ||
// Opera (desktop and mobile). | ||
if (bowser.check({ opera: '44' }, true, ua)) | ||
{ | ||
Device._flag = 'opera'; | ||
Device._handlerClass = Chrome55; | ||
} | ||
// TODO: More devices. | ||
if (Device.isSupported()) | ||
{ | ||
logger.debug( | ||
'device supported [name:%s, version:%s, handler:%s]', | ||
Device._name, Device._version, Device._handlerClass.name); | ||
'device supported [flag:%s, name:"%s", version:%s, handler:%s]', | ||
Device._flag, Device._name, Device._version, Device._handlerClass.name); | ||
} | ||
@@ -127,2 +149,6 @@ else | ||
// Device flag. | ||
// @type {String} | ||
Device._flag = undefined; | ||
// Device name. | ||
@@ -129,0 +155,0 @@ // @type {String} |
@@ -22,3 +22,3 @@ import sdpTransform from 'sdp-transform'; | ||
iceServers : settings.turnServers || [], | ||
iceTransportPolicy : 'relay', | ||
iceTransportPolicy : 'all', | ||
bundlePolicy : 'max-bundle', | ||
@@ -94,2 +94,5 @@ rtcpMuxPolicy : 'require' | ||
if (this._stream.getTrackById(track.id)) | ||
return Promise.reject('track already added'); | ||
let localSdpObj; | ||
@@ -456,5 +459,5 @@ | ||
static getLocalRtpCapabilities() | ||
static getNativeRtpCapabilities() | ||
{ | ||
logger.debug('getLocalRtpCapabilities()'); | ||
logger.debug('getNativeRtpCapabilities()'); | ||
@@ -464,3 +467,3 @@ const pc = new RTCPeerConnection( | ||
iceServers : [], | ||
iceTransportPolicy : 'relay', | ||
iceTransportPolicy : 'all', | ||
bundlePolicy : 'max-bundle', | ||
@@ -481,5 +484,5 @@ rtcpMuxPolicy : 'require' | ||
const sdpObj = sdpTransform.parse(offer.sdp); | ||
const localRtpCapabilities = sdpCommonUtils.extractRtpCapabilities(sdpObj); | ||
const nativeRtpCapabilities = sdpCommonUtils.extractRtpCapabilities(sdpObj); | ||
return localRtpCapabilities; | ||
return nativeRtpCapabilities; | ||
}) | ||
@@ -486,0 +489,0 @@ .catch((error) => |
@@ -1,11 +0,12 @@ | ||
/* global RTCIceGatherer, RTCIceTransport, RTCDtlsTransport, RTCRtpReceiver */ | ||
/* global RTCIceGatherer, RTCIceTransport, RTCDtlsTransport, RTCRtpReceiver, RTCRtpSender */ | ||
import Logger from '../Logger'; | ||
import EnhancedEventEmitter from '../EnhancedEventEmitter'; | ||
// import * as utils from '../utils'; | ||
import * as utils from '../utils'; | ||
import * as edgeUtils from './ortc/edgeUtils'; | ||
const CNAME = `CNAME-EDGE-${utils.randomNumber()}`; | ||
const logger = new Logger('Edge11'); | ||
// const CNAME = `cname-${utils.randomNumber()}`; | ||
export default class Edge11 extends EnhancedEventEmitter | ||
@@ -18,8 +19,7 @@ { | ||
static getLocalRtpCapabilities() | ||
static getNativeRtpCapabilities() | ||
{ | ||
logger.debug('getLocalRtpCapabilities()'); | ||
logger.debug('getNativeRtpCapabilities()'); | ||
// TODO: Not enough since Edge does not set mimeType, etc. | ||
return RTCRtpReceiver.getCapabilities(); | ||
return edgeUtils.getCapabilities(); | ||
} | ||
@@ -35,2 +35,10 @@ | ||
// Generic sending RTP parameters for audio and video. | ||
// @type {Object} | ||
this._rtpParametersByKind = | ||
{ | ||
audio : utils.getSendingRtpParameters('audio', extendedRtpCapabilities), | ||
video : utils.getSendingRtpParameters('video', extendedRtpCapabilities) | ||
}; | ||
// Got transport local and remote parameters. | ||
@@ -61,4 +69,2 @@ // @type {Boolean} | ||
this._setDtlsTransport(); | ||
// TODO | ||
} | ||
@@ -98,5 +104,5 @@ | ||
addProducer(producer) | ||
addProducer(producer, track = null) | ||
{ | ||
const { track } = producer; | ||
track = track || producer.track; | ||
@@ -107,2 +113,5 @@ logger.debug( | ||
if (this._rtpSenders.has(producer.id)) | ||
return Promise.reject('Producer already added'); | ||
return Promise.resolve() | ||
@@ -113,5 +122,46 @@ .then(() => | ||
return this._setupTransport(); | ||
}) | ||
.then(() => | ||
{ | ||
const rtpSender = new RTCRtpSender(track, this._dtlsTransport); | ||
const rtpParameters = | ||
utils.clone(this._rtpParametersByKind[producer.kind]); | ||
// Fill RTCRtpParameters.encodings. | ||
const encoding = | ||
{ | ||
ssrc : utils.randomNumber() | ||
}; | ||
if (rtpParameters.codecs.some((codec) => codec.name === 'rtx')) | ||
{ | ||
encoding.rtx = | ||
{ | ||
ssrc : utils.randomNumber() | ||
}; | ||
} | ||
rtpParameters.encodings.push(encoding); | ||
// Fill RTCRtpParameters.rtcp. | ||
rtpParameters.rtcp = | ||
{ | ||
cname : CNAME, | ||
reducedSize : true, | ||
mux : true | ||
}; | ||
// NOTE: Convert our standard RTCRtpParameters into those that Edge | ||
// expects. | ||
const edgeRtpParameters = | ||
edgeUtils.mangleRtpParameters(rtpParameters); | ||
// Send it. | ||
rtpSender.send(edgeRtpParameters); | ||
// Store it. | ||
this._rtpSenders.set(producer.id, rtpSender); | ||
return rtpParameters; | ||
}); | ||
// TODO | ||
} | ||
@@ -127,5 +177,47 @@ | ||
// TODO | ||
return Promise.resolve() | ||
.then(() => | ||
{ | ||
const rtpSender = this._rtpSenders.get(producer.id); | ||
if (!rtpSender) | ||
throw new Error('RTCRtpSender not found'); | ||
this._rtpSenders.delete(producer.id); | ||
try | ||
{ | ||
rtpSender.stop(); | ||
} | ||
catch (error) | ||
{ | ||
logger.warn('rtpSender.stop() failed:%o', error); | ||
} | ||
}); | ||
} | ||
replaceProducerTrack(producer, track) | ||
{ | ||
logger.debug( | ||
'replaceProducerTrack() [id:%s, kind:%s, trackId:%s]', | ||
producer.id, producer.kind, track.id); | ||
// NOTE: Edge does not support rtpSender.replaceTrack(). | ||
return Promise.resolve() | ||
.then(() => | ||
{ | ||
return this.removeProducer(producer); | ||
}) | ||
.then(() => | ||
{ | ||
return this.addProducer(producer, track); | ||
}) | ||
.then((rtpParameters) => | ||
{ | ||
// We need to provide new RTP parameters. | ||
this.safeEmit('@needupdateproducer', producer, rtpParameters); | ||
}); | ||
} | ||
addConsumer(consumer) | ||
@@ -136,3 +228,27 @@ { | ||
// TODO | ||
if (this._rtpReceivers.has(consumer.id)) | ||
return Promise.reject('Consumer already added'); | ||
return Promise.resolve() | ||
.then(() => | ||
{ | ||
const rtpReceiver = | ||
new RTCRtpReceiver(this._dtlsTransport, consumer.kind); | ||
rtpReceiver.addEventListener('error', (event) => | ||
{ | ||
logger.error('iceGatherer "error" event [event:%o]', event); | ||
}); | ||
// NOTE: Convert our standard RTCRtpParameters into those that Edge | ||
// expects. | ||
const edgeRtpParameters = | ||
edgeUtils.mangleRtpParameters(consumer.rtpParameters); | ||
// Receive it. | ||
rtpReceiver.receive(edgeRtpParameters); | ||
// Store it. | ||
this._rtpReceivers.set(consumer.id, rtpReceiver); | ||
}); | ||
} | ||
@@ -145,3 +261,21 @@ | ||
// TODO | ||
return Promise.resolve() | ||
.then(() => | ||
{ | ||
const rtpReceiver = this._rtpReceivers.get(consumer.id); | ||
if (!rtpReceiver) | ||
throw new Error('RTCRtpReceiver not found'); | ||
this._rtpReceivers.delete(consumer.id); | ||
try | ||
{ | ||
rtpReceiver.stop(); | ||
} | ||
catch (error) | ||
{ | ||
logger.warn('rtpReceiver.stop() failed:%o', error); | ||
} | ||
}); | ||
} | ||
@@ -154,3 +288,3 @@ | ||
iceServers : settings.turnServers || [], | ||
gatherPolicy : 'relay' | ||
gatherPolicy : 'all' | ||
}); | ||
@@ -160,6 +294,3 @@ | ||
{ | ||
const { errorCode, errorText } = event; | ||
logger.error( | ||
`iceGatherer "error" event [errorCode:${errorCode}, errorText:${errorText}]`); | ||
logger.error('iceGatherer "error" event [event:%o]', event); | ||
}); | ||
@@ -174,3 +305,3 @@ | ||
{ | ||
logger.debug(`iceGatherer.gather() failed:${error}`); | ||
logger.debug('iceGatherer.gather() failed: %s', error.toString()); | ||
} | ||
@@ -236,3 +367,3 @@ | ||
logger.debug( | ||
`iceTransport "candidatepairchange" event [pair:${event.pair}]`); | ||
'iceTransport "candidatepairchange" event [pair:%o]', event.pair); | ||
}); | ||
@@ -251,3 +382,3 @@ | ||
logger.debug( | ||
`dtlsTransport "statechange" event [state:${dtlsTransport.state}]`); | ||
'dtlsTransport "statechange" event [state:%s]', dtlsTransport.state); | ||
}); | ||
@@ -259,3 +390,3 @@ | ||
logger.debug( | ||
`dtlsTransport "dtlsstatechange" event [state:${dtlsTransport.state}]`); | ||
'dtlsTransport "dtlsstatechange" event [state:%s]', dtlsTransport.state); | ||
}); | ||
@@ -265,10 +396,3 @@ | ||
{ | ||
let error; | ||
if (event.message) | ||
error = event.message; | ||
else if (event.error) | ||
error = event.error.message; | ||
logger.error(`dtlsTransport "error" event:${error}`); | ||
logger.error('dtlsTransport "error" event [event:%o]', event); | ||
}); | ||
@@ -275,0 +399,0 @@ |
@@ -22,3 +22,3 @@ import sdpTransform from 'sdp-transform'; | ||
iceServers : settings.turnServers || [], | ||
iceTransportPolicy : 'relay', | ||
iceTransportPolicy : 'all', | ||
bundlePolicy : 'max-bundle', | ||
@@ -94,2 +94,5 @@ rtcpMuxPolicy : 'require' | ||
if (this._stream.getTrackById(track.id)) | ||
return Promise.reject('track already added'); | ||
let rtpSender; | ||
@@ -165,3 +168,3 @@ let localSdpObj; | ||
if (!rtpSender) | ||
throw new Error('local track not found'); | ||
throw new Error('RTCRtpSender found'); | ||
@@ -438,5 +441,5 @@ // Remove the associated RtpSender. | ||
static getLocalRtpCapabilities() | ||
static getNativeRtpCapabilities() | ||
{ | ||
logger.debug('getLocalRtpCapabilities()'); | ||
logger.debug('getNativeRtpCapabilities()'); | ||
@@ -446,3 +449,3 @@ const pc = new RTCPeerConnection( | ||
iceServers : [], | ||
iceTransportPolicy : 'relay', | ||
iceTransportPolicy : 'all', | ||
bundlePolicy : 'max-bundle', | ||
@@ -463,5 +466,5 @@ rtcpMuxPolicy : 'require' | ||
const sdpObj = sdpTransform.parse(offer.sdp); | ||
const localRtpCapabilities = sdpCommonUtils.extractRtpCapabilities(sdpObj); | ||
const nativeRtpCapabilities = sdpCommonUtils.extractRtpCapabilities(sdpObj); | ||
return localRtpCapabilities; | ||
return nativeRtpCapabilities; | ||
}) | ||
@@ -468,0 +471,0 @@ .catch((error) => |
@@ -22,3 +22,3 @@ import sdpTransform from 'sdp-transform'; | ||
iceServers : settings.turnServers || [], | ||
iceTransportPolicy : 'relay', | ||
iceTransportPolicy : 'all', | ||
bundlePolicy : 'max-bundle', | ||
@@ -94,2 +94,5 @@ rtcpMuxPolicy : 'require' | ||
if (this._stream.getTrackById(track.id)) | ||
return Promise.reject('track already added'); | ||
let rtpSender; | ||
@@ -165,3 +168,3 @@ let localSdpObj; | ||
if (!rtpSender) | ||
throw new Error('local track not found'); | ||
throw new Error('RTCRtpSender found'); | ||
@@ -445,5 +448,5 @@ // Remove the associated RtpSender. | ||
static getLocalRtpCapabilities() | ||
static getNativeRtpCapabilities() | ||
{ | ||
logger.debug('getLocalRtpCapabilities()'); | ||
logger.debug('getNativeRtpCapabilities()'); | ||
@@ -453,3 +456,3 @@ const pc = new RTCPeerConnection( | ||
iceServers : [], | ||
iceTransportPolicy : 'relay', | ||
iceTransportPolicy : 'all', | ||
bundlePolicy : 'max-bundle', | ||
@@ -469,5 +472,5 @@ rtcpMuxPolicy : 'require' | ||
const sdpObj = sdpTransform.parse(offer.sdp); | ||
const localRtpCapabilities = sdpCommonUtils.extractRtpCapabilities(sdpObj); | ||
const nativeRtpCapabilities = sdpCommonUtils.extractRtpCapabilities(sdpObj); | ||
return localRtpCapabilities; | ||
return nativeRtpCapabilities; | ||
}) | ||
@@ -474,0 +477,0 @@ .catch((error) => |
@@ -64,4 +64,6 @@ import sdpTransform from 'sdp-transform'; | ||
if (!(codec.channels > 1)) | ||
if (codec.kind !== 'audio') | ||
delete codec.channels; | ||
else if (!codec.channels) | ||
codec.channels = 1; | ||
@@ -68,0 +70,0 @@ codecsMap.set(codec.preferredPayloadType, codec); |
@@ -25,3 +25,3 @@ import Device from './Device'; | ||
* getDeviceInfo() | ||
* // => { name: "Chrome", version: "59.0" } | ||
* // => { flag: 'chrome', name: 'Chrome', version: '59.0' } | ||
*/ | ||
@@ -31,2 +31,3 @@ export function getDeviceInfo() | ||
return { | ||
flag : Device.flag, | ||
name : Device.name, | ||
@@ -33,0 +34,0 @@ version : Device.version |
@@ -169,4 +169,2 @@ import Logger from './Logger'; | ||
let localRtpCapabilities; | ||
return Promise.resolve() | ||
@@ -190,15 +188,16 @@ .then(() => | ||
{ | ||
return Device.Handler.getLocalRtpCapabilities(); | ||
return Device.Handler.getNativeRtpCapabilities(); | ||
}) | ||
.then((rtpCapabilities) => | ||
.then((nativeRtpCapabilities) => | ||
{ | ||
localRtpCapabilities = rtpCapabilities; | ||
logger.debug( | ||
'join() | got local RTP capabilities:%o', localRtpCapabilities); | ||
'join() | native RTP capabilities:%o', nativeRtpCapabilities); | ||
// Get extended RTP capabilities. | ||
this._extendedRtpCapabilities = utils.getExtendedRtpCapabilities( | ||
localRtpCapabilities, roomSettings.rtpCapabilities); | ||
nativeRtpCapabilities, roomSettings.rtpCapabilities); | ||
logger.debug( | ||
'join() | extended RTP capabilities:%o', this._extendedRtpCapabilities); | ||
// Check unsupported codecs. | ||
@@ -232,3 +231,3 @@ const unsupportedRoomCodecs = utils.getUnsupportedCodecs( | ||
logger.debug( | ||
'join() | got effective local RTP capabilities:%o', | ||
'join() | effective local RTP capabilities for receiving:%o', | ||
effectiveLocalRtpCapabilities); | ||
@@ -235,0 +234,0 @@ |
@@ -74,3 +74,3 @@ import randomNumberLib from 'random-number'; | ||
if (!(extendedCodec.channels > 1)) | ||
if (!extendedCodec.channels) | ||
delete extendedCodec.channels; | ||
@@ -134,3 +134,4 @@ | ||
/** | ||
* Generate RTP capabilities based on the given extended RTP capabilities. | ||
* Generate RTP capabilities for receiving media based on the given extended | ||
* RTP capabilities. | ||
* | ||
@@ -163,3 +164,3 @@ * @param {RTCExtendedRtpCapabilities} extendedRtpCapabilities | ||
if (!(codec.channels > 1)) | ||
if (!codec.channels) | ||
delete codec.channels; | ||
@@ -308,3 +309,3 @@ | ||
if (!(codec.channels > 1)) | ||
if (!codec.channels) | ||
delete codec.channels; | ||
@@ -391,3 +392,3 @@ | ||
if (!(codec.channels > 1)) | ||
if (!codec.channels) | ||
delete codec.channels; | ||
@@ -394,0 +395,0 @@ |
{ | ||
"name": "mediasoup-client", | ||
"version": "0.1.2", | ||
"description": "mediasoup client SDK for mediasoup 2.X", | ||
"version": "0.2.0", | ||
"description": "mediasoup client SDK for mediasoup >= 2.0.0", | ||
"author": "Iñaki Baz Castillo <ibc@aliax.net> (https://inakibaz.me)", | ||
"license": "ISC", | ||
"homepage": "https://mediasoup.org", | ||
"main": "lib/index.js", | ||
"dependencies": { | ||
"bowser": "^1.7.2", | ||
"debug": "^3.0.0", | ||
"random-number": "0.0.7", | ||
"sdp-transform": "^2.3.0", | ||
"supports-color": "^4.2.1" | ||
"debug": "git://github.com/ibc/debug.git#disable-colors-in-edge-and-ie", | ||
"random-number": "0.0.9", | ||
"sdp-transform": "^2.3.0" | ||
}, | ||
@@ -39,3 +39,3 @@ "browserify": { | ||
"browserify": "^14.4.0", | ||
"eslint": "^4.4.1", | ||
"eslint": "^4.5.0", | ||
"eslint-plugin-import": "^2.7.0", | ||
@@ -42,0 +42,0 @@ "gulp": "git://github.com/gulpjs/gulp.git#4.0", |
@@ -23,5 +23,3 @@ # TODO | ||
* Implement `sender.replaceTrack(newTrack)`. | ||
# TODO in mediasoup 2.0.0 (server) | ||
@@ -37,6 +35,4 @@ | ||
* mediasoup must ignore a `resumeReceiver` request (so re-enabling a client `Sender`) if it was remotely paused in mediasoup. However, mediasoup `RtpReceiver` must also keep state about `locallyPaused` and `remotelyPaused`. | ||
* mediasoup must be ready for the case in which the client closes a `Transport` on which a `Producer` was running. | ||
* mediasoup must be ready for the case in which the client closes a `Transport` on which a `RtpReceiver` was running. | ||
* Upon a `updateProducer` notification, map the new SSRCs of the `Producer` and send a PLI back to the browser (otherwise, consumers will get frozen video). |
Git dependency
Supply chain riskContains a dependency which resolves to a remote git URL. Dependencies fetched from git URLs are not immutable and can be used to inject untrusted code or reduce the likelihood of a reproducible install.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
171847
4
35
6086
1
1
+ Addedrandom-number@0.0.9(transitive)
- Removedsupports-color@^4.2.1
- Removeddebug@3.2.7(transitive)
- Removedhas-flag@2.0.0(transitive)
- Removedms@2.1.3(transitive)
- Removedrandom-number@0.0.7(transitive)
- Removedsupports-color@4.5.0(transitive)
Updateddebug@git://github.com/ibc/debug.git#disable-colors-in-edge-and-ie
Updatedrandom-number@0.0.9