Fixed bug in event-handling; Updated webrtc-adapter

This commit is contained in:
Christoph Oberhofer
2016-06-07 23:04:23 +02:00
parent 36205f8ceb
commit 3df696a1f7
8 changed files with 3093 additions and 2048 deletions
+13 -1
View File
@@ -50,10 +50,22 @@ export default (function() {
var event = getEvent(eventName),
subscribers = event.subscribers;
event.subscribers = subscribers.filter(function(subscriber) {
// Publish one-time subscriptions
subscribers.filter(function(subscriber) {
return !!subscriber.once;
}).forEach((subscriber) => {
publishSubscription(subscriber, data);
});
// remove them from the subscriber
event.subscribers = subscribers.filter(function(subscriber) {
return !subscriber.once;
});
// publish the rest
event.subscribers.forEach((subscriber) => {
publishSubscription(subscriber, data);
});
},
once: function(event, callback, async) {
subscribe(event, {
+12 -12
View File
@@ -1,7 +1,6 @@
import {merge, pick} from 'lodash';
var streamRef,
loadedDataHandler;
var streamRef;
function waitForVideo(video) {
return new Promise((resolve, reject) => {
@@ -35,13 +34,14 @@ function waitForVideo(video) {
function initCamera(video, constraints) {
return navigator.mediaDevices.getUserMedia(constraints)
.then((stream) => {
return new Promise((resolve, reject) => {
return new Promise((resolve) => {
streamRef = stream;
video.src = window.URL.createObjectURL(stream);
video.onloadedmetadata = (e) => {
video.setAttribute("autoplay", 'true');
video.srcObject = stream;
video.addEventListener('loadedmetadata', () => {
video.play();
resolve();
};
});
});
})
.then(waitForVideo.bind(null, video));
@@ -51,13 +51,13 @@ function deprecatedConstraints(videoConstraints) {
const normalized = pick(videoConstraints, ["width", "height", "facingMode",
"aspectRatio", "deviceId"]);
if (typeof videoConstraints["minAspectRatio"] !== 'undefined' &&
videoConstraints["minAspectRatio"] > 0) {
normalized["aspectRatio"] = videoConstraints["minAspectRatio"];
if (typeof videoConstraints.minAspectRatio !== 'undefined' &&
videoConstraints.minAspectRatio > 0) {
normalized.aspectRatio = videoConstraints.minAspectRatio;
console.log("WARNING: Constraint 'minAspectRatio' is deprecated; Use 'aspectRatio' instead");
}
if (typeof videoConstraints["facing"] !== 'undefined') {
normalized["facingMode"] = videoConstraints["facing"];
if (typeof videoConstraints.facing !== 'undefined') {
normalized.facingMode = videoConstraints.facing;
console.log("WARNING: Constraint 'facing' is deprecated. Use 'facingMode' instead'");
}
return normalized;
@@ -69,7 +69,7 @@ function applyCameraFacing(facing, constraints) {
}
if ( typeof MediaStreamTrack !== 'undefined' &&
typeof MediaStreamTrack.getSources !== 'undefined') {
return new Promise((resolve, reject) => {
return new Promise((resolve) => {
MediaStreamTrack.getSources((sourceInfos) => {
const videoSource = sourceInfos.filter((sourceInfo) => (
sourceInfo.kind === "video" && sourceInfo.facing === facing
-1
View File
@@ -67,7 +67,6 @@ function initInputStream(cb) {
}
_inputStream.setAttribute("preload", "auto");
_inputStream.setAttribute("autoplay", true);
_inputStream.setInputStream(_config.inputStream);
_inputStream.addEventListener("canrecord", canRecord.bind(undefined, cb));
}