Skip to content

Commit

Permalink
2.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ibc committed Dec 14, 2015
1 parent 6ce5558 commit fb236f6
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 59 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Absolutely **not**. This plugin exposes the WebRTC W3C API for Cordova iOS apps

Check the [release announcement](https://eface2face.com/blog/cordova-plugin-iosrtc.html) at the [eFace2Face](https://eface2face.com) site.

**Resources:**
**Resources**

* [NPM package](https://www.npmjs.com/package/cordova-plugin-iosrtc).
* [Public Google Group](https://groups.google.com/forum/#!forum/cordova-plugin-iosrtc) for questions and discussions about *cordova-plugin-iosrtc*.
Expand Down Expand Up @@ -105,10 +105,12 @@ Again, there is no real video attached to the `<video>` element so some peropert
Read the full [documentation](docs/index.md) in the *docs* folder.


## Demo application
## Demo Application

Check our [iOSRTCApp](https://github.com/eface2face/iOSRTCApp) (Google's [AppRTC](https://apprtc.appspot.com/) adapted to Cordova iOS with pure HTML5/JavaScript and *cordova-plugin-iosrtc*).

*NOTE:* The demo app is currently unmaintained and it may just fail.


## Who Uses It

Expand Down Expand Up @@ -141,6 +143,7 @@ Methods such as `play()`, `pause()` are not implemented. In order to pause a vid

* Move from `getMediaDevices()` to `enumerateDevices()`.
* Implement video constraints in `getUserMedia()`: `deviceId`, `width.min`, `width.max`, `height.min`, `height.max`, `frameRate`, `frameRate.min`, `frameRate.max`).
* Update deps and build on Node >= 4.


#### Version 2.1.0
Expand Down
123 changes: 77 additions & 46 deletions dist/cordova-plugin-iosrtc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* cordova-plugin-iosrtc v2.1.0
* cordova-plugin-iosrtc v2.2.0
* Cordova iOS plugin exposing the full WebRTC W3C JavaScript APIs
* Copyright 2015 Iñaki Baz Castillo at eFace2Face, inc. (https://eface2face.com)
* License MIT
Expand Down Expand Up @@ -830,7 +830,7 @@ module.exports = MediaStreamTrack;
var
debug = require('debug')('iosrtc:MediaStreamTrack'),
exec = require('cordova/exec'),
getMediaDevices = require('./getMediaDevices'),
enumerateDevices = require('./enumerateDevices'),
EventTarget = require('yaeti').EventTarget;


Expand Down Expand Up @@ -897,7 +897,7 @@ MediaStreamTrack.prototype.stop = function () {
MediaStreamTrack.getSources = function () {
debug('getSources()');

return getMediaDevices.apply(this, arguments);
return enumerateDevices.apply(this, arguments);
};


Expand Down Expand Up @@ -932,7 +932,7 @@ function onEvent(data) {
}
}

},{"./getMediaDevices":10,"cordova/exec":undefined,"debug":15,"yaeti":20}],6:[function(require,module,exports){
},{"./enumerateDevices":10,"cordova/exec":undefined,"debug":15,"yaeti":20}],6:[function(require,module,exports){
/**
* Expose the RTCDataChannel class.
*/
Expand Down Expand Up @@ -1911,21 +1911,21 @@ function RTCSessionDescription(data) {

},{}],10:[function(require,module,exports){
/**
* Expose the getMediaDevices function.
* Expose the enumerateDevices function.
*/
module.exports = getMediaDevices;
module.exports = enumerateDevices;


/**
* Dependencies.
*/
var
debug = require('debug')('iosrtc:getMediaDevices'),
debug = require('debug')('iosrtc:enumerateDevices'),
exec = require('cordova/exec'),
MediaDeviceInfo = require('./MediaDeviceInfo');


function getMediaDevices() {
function enumerateDevices() {
debug('');

var isPromise,
Expand All @@ -1941,20 +1941,20 @@ function getMediaDevices() {
if (isPromise) {
return new Promise(function (resolve) {
function onResultOK(data) {
debug('getMediaDevices() | success');
debug('enumerateDevices() | success');
resolve(getMediaDeviceInfos(data.devices));
}

exec(onResultOK, null, 'iosrtcPlugin', 'getMediaDevices', []);
exec(onResultOK, null, 'iosrtcPlugin', 'enumerateDevices', []);
});
}

function onResultOK(data) {
debug('getMediaDevices() | success');
debug('enumerateDevices() | success');
callback(getMediaDeviceInfos(data.devices));
}

exec(onResultOK, null, 'iosrtcPlugin', 'getMediaDevices', []);
exec(onResultOK, null, 'iosrtcPlugin', 'enumerateDevices', []);
}


Expand Down Expand Up @@ -1995,20 +1995,26 @@ var
MediaStream = require('./MediaStream'),
Errors = require('./Errors');


debugerror.log = console.warn.bind(console);


function isPositiveInteger(number) {
return typeof number === 'number' && number >= 0 && number % 1 === 0;
}

function isPositiveFloat(number) {
return typeof number === 'number' && number >= 0;
}


function getUserMedia(constraints) {
debug('[constraints:%o]', constraints);
debug('[original constraints:%o]', constraints);

var isPromise,
var
isPromise,
callback, errback,
audioRequested = false,
videoRequested = false,
videoOptionalConstraints,
videoMandatoryConstraints,
videoDeviceId,
newConstraints = {
audio: false,
video: false
Expand All @@ -2028,11 +2034,11 @@ function getUserMedia(constraints) {
) {
if (isPromise) {
return new Promise(function (resolve, reject) {
reject(new Errors.MediaStreamError('constraints must be an object with at least "audio" or "video" boolean fields'));
reject(new Errors.MediaStreamError('constraints must be an object with at least "audio" or "video" keys'));
});
} else {
if (typeof errback === 'function') {
errback(new Errors.MediaStreamError('constraints must be an object with at least "audio" or "video" boolean fields'));
errback(new Errors.MediaStreamError('constraints must be an object with at least "audio" or "video" keys'));
}
return;
}
Expand All @@ -2052,36 +2058,59 @@ function getUserMedia(constraints) {
// getUserMedia({
// audio: true,
// video: {
// optional: [
// { sourceId: 'qwe-asd-zxc-123' }
// ]
// deviceId: 'qwer-asdf-zxcv',
// width: {
// min: 400,
// max: 600
// },
// frameRate: {
// min: 1.0,
// max: 60.0
// }
// }
// });

if (videoRequested && Array.isArray(constraints.video.optional)) {
videoOptionalConstraints = constraints.video.optional;

if (videoOptionalConstraints[0]) {
videoDeviceId = videoOptionalConstraints[0].sourceId;
// Get video constraints
if (videoRequested) {
// Get requested video deviceId.
if (typeof constraints.video.deviceId === 'string') {
newConstraints.videoDeviceId = constraints.video.deviceId;
}

if (typeof videoDeviceId === 'string') {
newConstraints.videoDeviceId = videoDeviceId;
// Get requested min/max width.
if (typeof constraints.video.width === 'object') {
if (isPositiveInteger(constraints.video.width.min)) {
newConstraints.videoMinWidth = constraints.video.width.min;
}
if (isPositiveInteger(constraints.video.width.max)) {
newConstraints.videoMaxWidth = constraints.video.width.max;
}
}
}

if (videoRequested && Array.isArray(constraints.video.mandatory)) {
videoMandatoryConstraints = constraints.video.mandatory;

if (videoMandatoryConstraints[0]) {
videoDeviceId = videoMandatoryConstraints[0].sourceId;

if (typeof videoDeviceId === 'string') {
newConstraints.videoDeviceId = videoDeviceId;
// Get requested min/max height.
if (typeof constraints.video.height === 'object') {
if (isPositiveInteger(constraints.video.height.min)) {
newConstraints.videoMinHeight = constraints.video.height.min;
}
if (isPositiveInteger(constraints.video.height.max)) {
newConstraints.videoMaxHeight = constraints.video.height.max;
}
}
// Get requested min/max frame rate.
if (typeof constraints.video.frameRate === 'object') {
if (isPositiveFloat(constraints.video.frameRate.min)) {
newConstraints.videoMinFrameRate = constraints.video.frameRate.min;
}
if (isPositiveFloat(constraints.video.frameRate.max)) {
newConstraints.videoMaxFrameRate = constraints.video.frameRate.max;
}
} else if (isPositiveFloat(constraints.video.frameRate)) {
newConstraints.videoMinFrameRate = constraints.video.frameRate;
newConstraints.videoMaxFrameRate = constraints.video.frameRate;
}
}

debug('[computed constraints:%o]', newConstraints);

if (isPromise) {
return new Promise(function (resolve, reject) {
function onResultOK(data) {
Expand Down Expand Up @@ -2146,7 +2175,7 @@ var
domready = require('domready'),

getUserMedia = require('./getUserMedia'),
getMediaDevices = require('./getMediaDevices'),
enumerateDevices = require('./enumerateDevices'),
RTCPeerConnection = require('./RTCPeerConnection'),
RTCSessionDescription = require('./RTCSessionDescription'),
RTCIceCandidate = require('./RTCIceCandidate'),
Expand All @@ -2162,7 +2191,8 @@ var
module.exports = {
// Expose WebRTC classes and functions.
getUserMedia: getUserMedia,
getMediaDevices: getMediaDevices,
enumerateDevices: enumerateDevices,
getMediaDevices: enumerateDevices, // TMP
RTCPeerConnection: RTCPeerConnection,
RTCSessionDescription: RTCSessionDescription,
RTCIceCandidate: RTCIceCandidate,
Expand Down Expand Up @@ -2240,7 +2270,7 @@ function registerGlobals() {
navigator.getUserMedia = getUserMedia;
navigator.webkitGetUserMedia = getUserMedia;
navigator.mediaDevices.getUserMedia = getUserMedia;
navigator.mediaDevices.enumerateDevices = getMediaDevices;
navigator.mediaDevices.enumerateDevices = enumerateDevices;
window.RTCPeerConnection = RTCPeerConnection;
window.webkitRTCPeerConnection = RTCPeerConnection;
window.RTCSessionDescription = RTCSessionDescription;
Expand All @@ -2256,7 +2286,7 @@ function dump() {
}

}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
},{"./MediaStream":3,"./MediaStreamTrack":5,"./RTCIceCandidate":7,"./RTCPeerConnection":8,"./RTCSessionDescription":9,"./getMediaDevices":10,"./getUserMedia":11,"./rtcninjaPlugin":13,"./videoElementsHandler":14,"cordova/exec":undefined,"debug":15,"domready":18}],13:[function(require,module,exports){
},{"./MediaStream":3,"./MediaStreamTrack":5,"./RTCIceCandidate":7,"./RTCPeerConnection":8,"./RTCSessionDescription":9,"./enumerateDevices":10,"./getUserMedia":11,"./rtcninjaPlugin":13,"./videoElementsHandler":14,"cordova/exec":undefined,"debug":15,"domready":18}],13:[function(require,module,exports){
/**
* Expose the rtcninjaPlugin object.
*/
Expand All @@ -2271,11 +2301,12 @@ module.exports = {

interface: {
getUserMedia: require('./getUserMedia'),
enumerateDevices: require('./enumerateDevices'),
getMediaDevices: require('./enumerateDevices'), // TMP
RTCPeerConnection: require('./RTCPeerConnection'),
RTCSessionDescription: require('./RTCSessionDescription'),
RTCIceCandidate: require('./RTCIceCandidate'),
MediaStreamTrack: require('./MediaStreamTrack'),
getMediaDevices: require('./getMediaDevices'),
attachMediaStream: attachMediaStream,
canRenegotiate: true
}
Expand All @@ -2287,7 +2318,7 @@ function attachMediaStream(element, stream) {
return element;
}

},{"./MediaStreamTrack":5,"./RTCIceCandidate":7,"./RTCPeerConnection":8,"./RTCSessionDescription":9,"./getMediaDevices":10,"./getUserMedia":11}],14:[function(require,module,exports){
},{"./MediaStreamTrack":5,"./RTCIceCandidate":7,"./RTCPeerConnection":8,"./RTCSessionDescription":9,"./enumerateDevices":10,"./getUserMedia":11}],14:[function(require,module,exports){
(function (global){
/**
* Expose a function that must be called when the library is loaded.
Expand Down
5 changes: 2 additions & 3 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ var gulp = require('gulp'),
stylish = require('gulp-jscs-stylish'),
browserify = require('browserify'),
vinyl_source_stream = require('vinyl-source-stream'),
vinyl_buffer = require('vinyl-buffer'),
jshint = require('gulp-jshint'),
filelog = require('gulp-filelog'),
header = require('gulp-header'),
path = require('path'),
fs = require('fs'),
Expand All @@ -31,7 +31,6 @@ gulp.task('lint', function () {
var src = ['gulpfile.js', 'js/**/*.js', 'hooks/**/*.js', 'extra/**/*.js'];

return gulp.src(src)
.pipe(filelog('lint'))
.pipe(jshint('.jshintrc')) // Enforce good practics.
.pipe(jscs('.jscsrc')) // Enforce style guide.
.pipe(stylish.combineWithHintResults())
Expand All @@ -47,7 +46,7 @@ gulp.task('browserify', function () {
.exclude('cordova/exec') // Exclude require('cordova/exec').
.bundle()
.pipe(vinyl_source_stream(PKG.name + '.js'))
.pipe(filelog('browserify'))
.pipe(vinyl_buffer())
.pipe(header(banner, banner_options))
.pipe(gulp.dest('dist/'));
});
Expand Down
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cordova-plugin-iosrtc",
"version": "2.2.0-pre",
"version": "2.2.0",
"description": "Cordova iOS plugin exposing the full WebRTC W3C JavaScript APIs",
"author": "Iñaki Baz Castillo at eFace2Face, inc. (https://eface2face.com)",
"license": "MIT",
Expand All @@ -25,14 +25,14 @@
"yaeti": "^0.0.4"
},
"devDependencies": {
"browserify": "^11.2.0",
"browserify": "^12.0.1",
"gulp": "git+https://github.com/gulpjs/gulp.git#4.0",
"gulp-filelog": "^0.4.1",
"gulp-header": "^1.7.1",
"gulp-jscs": "^3.0.1",
"gulp-jscs-stylish": "^1.2.1",
"gulp-jshint": "^1.11.2",
"jshint-stylish": "~2.0.1",
"gulp-jscs": "^3.0.2",
"gulp-jscs-stylish": "^1.3.0",
"gulp-jshint": "^2.0.0",
"jshint-stylish": "~2.1.0",
"vinyl-buffer": "^1.0.0",
"vinyl-source-stream": "^1.1.0"
},
"cordova": {
Expand Down
2 changes: 1 addition & 1 deletion plugin.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
id="cordova-plugin-iosrtc"
version="2.2.0-pre">
version="2.2.0">

<name>iosrtc</name>
<description>Cordova iOS plugin exposing the full WebRTC W3C JavaScript APIs</description>
Expand Down

0 comments on commit fb236f6

Please sign in to comment.