Browse Source

Use video waiter for screensharing videos and show screen sharing resolution in log.

pull/3/head
Simon Eisenmann 12 years ago
parent
commit
7ea867d4e5
  1. 41
      static/js/directives/audiovideo.js
  2. 7
      static/js/directives/screenshare.js
  3. 1
      static/js/mediastream/peerscreenshare.js
  4. 9
      static/js/services/services.js
  5. 72
      static/js/services/videowaiter.js

41
static/js/directives/audiovideo.js

@ -20,48 +20,11 @@ @@ -20,48 +20,11 @@
*/
define(['jquery', 'underscore', 'text!partials/audiovideo.html', 'text!partials/audiovideopeer.html', 'bigscreen', 'injectCSS', 'webrtc.adapter', 'rAF'], function($, _, template, templatePeer, BigScreen) {
return ["$window", "$compile", "$filter", "mediaStream", "safeApply", "desktopNotify", "buddyData", function($window, $compile, $filter, mediaStream, safeApply, desktopNotify, buddyData) {
return ["$window", "$compile", "$filter", "mediaStream", "safeApply", "desktopNotify", "buddyData", "videoWaiter", function($window, $compile, $filter, mediaStream, safeApply, desktopNotify, buddyData, videoWaiter) {
var requestAnimationFrame = $window.requestAnimationFrame;
var peerTemplate = $compile(templatePeer);
var waitForVideo = function(video, stream, cb, err_cb) {
var Waiter = function() {
this.stop = false;
this.count = 0;
this.retries = 100;
_.defer(_.bind(this.start, this), this);
};
Waiter.prototype.start = function() {
if (this.stop) {
if (err_cb) {
err_cb(video, stream);
}
return;
}
var videoTracks = stream.getVideoTracks();
//console.log("wait for video", videoTracks.length, video.currentTime, video)
if (videoTracks.length === 0) {
cb(false, video, stream);
} else if (video.currentTime > 0 && video.videoHeight > 0) {
cb(true, video, stream);
} else {
this.count++;
if (this.count < this.retries) {
$window.setTimeout(_.bind(this.start, this), 100);
} else {
if (err_cb) {
err_cb(video, stream);
}
}
}
};
Waiter.prototype.stop = function() {
this.stop = true;
};
return new Waiter();
};
var controller = ['$scope', '$element', '$attrs', function($scope, $element, $attrs) {
var peers = {};
@ -109,7 +72,7 @@ define(['jquery', 'underscore', 'text!partials/audiovideo.html', 'text!partials/ @@ -109,7 +72,7 @@ define(['jquery', 'underscore', 'text!partials/audiovideo.html', 'text!partials/
var video = clonedElement.find("video").get(0);
$window.attachMediaStream(video, stream);
// Waiter callbacks also count as connected, as browser support (FireFox 25) is not setting state changes properly.
waitForVideo(video, stream, function(withvideo) {
videoWaiter.wait(video, stream, function(withvideo) {
peers[peerid] = scope;
if (withvideo) {
scope.$apply(function($scope) {

7
static/js/directives/screenshare.js

@ -20,7 +20,7 @@ @@ -20,7 +20,7 @@
*/
define(['jquery', 'underscore', 'text!partials/screenshare.html', 'text!partials/screensharepeer.html', 'bigscreen'], function($, _, template, templatePeer, BigScreen) {
return ["$window", "mediaStream", "$compile", "safeApply", function($window, mediaStream, $compile, safeApply) {
return ["$window", "mediaStream", "$compile", "safeApply", "videoWaiter", function($window, mediaStream, $compile, safeApply, videoWaiter) {
var peerTemplate = $compile(templatePeer);
@ -91,6 +91,11 @@ define(['jquery', 'underscore', 'text!partials/screenshare.html', 'text!partials @@ -91,6 +91,11 @@ define(['jquery', 'underscore', 'text!partials/screenshare.html', 'text!partials
scope.element = clonedElement;
var video = clonedElement.find("video").get(0);
$window.attachMediaStream(video, stream);
videoWaiter.wait(video, stream, function() {
console.log("Screensharing size: ", video.videoWidth, video.videoHeight);
}, function() {
console.warn("We did not receive screen sharing video data", currentscreenshare, stream, video);
});
screens[peerid] = scope;
});

1
static/js/mediastream/peerscreenshare.js

@ -93,6 +93,7 @@ define(['jquery', 'underscore', 'mediastream/peercall', 'mediastream/tokens'], f @@ -93,6 +93,7 @@ define(['jquery', 'underscore', 'mediastream/peercall', 'mediastream/tokens'], f
optional: []
}
}
console.log("Setting screen sharing media constraints", mandatoryVideoConstraints);
return mediaConstraints;
};

9
static/js/services/services.js

@ -41,7 +41,8 @@ define([ @@ -41,7 +41,8 @@ define([
'services/filetransfer',
'services/safedisplayname',
'services/randomgen',
'services/fastscroll'
'services/fastscroll',
'services/videowaiter'
], function(_,
desktopNotify,
playSound,
@ -63,7 +64,8 @@ define([ @@ -63,7 +64,8 @@ define([
fileTransfer,
safeDisplayName,
randomGen,
fastScroll
fastScroll,
videoWaiter
) {
var services = {
@ -87,7 +89,8 @@ define([ @@ -87,7 +89,8 @@ define([
fileTransfer: fileTransfer,
safeDisplayName: safeDisplayName,
randomGen: randomGen,
fastScroll: fastScroll
fastScroll: fastScroll,
videoWaiter: videoWaiter
};
var initialize = function (angModule) {

72
static/js/services/videowaiter.js

@ -0,0 +1,72 @@ @@ -0,0 +1,72 @@
/*
* Spreed Speak Freely.
* Copyright (C) 2013-2014 struktur AG
*
* This file is part of Spreed Speak Freely.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
define(["underscore"], function(_) {
return ["$window", function($window) {
var Waiter = function() {
this.stop = false;
this.count = 0;
this.retries = 100;
};
Waiter.prototype.start = function(video, stream, cb, err_cb) {
if (this.stop) {
if (err_cb) {
err_cb(video, stream);
}
return;
}
var videoTracks = stream.getVideoTracks();
//console.log("wait for video", videoTracks.length, video.currentTime, video)
if (videoTracks.length === 0) {
cb(false, video, stream);
} else if (video.currentTime > 0 && video.videoHeight > 0) {
cb(true, video, stream);
} else {
this.count++;
if (this.count < this.retries) {
$window.setTimeout(_.bind(this.start, this, video, stream, cb, err_cb), 100);
} else {
if (err_cb) {
err_cb(video, stream);
}
}
}
};
Waiter.prototype.stop = function() {
this.stop = true;
};
// videoWaiter wait
return {
wait: function(video, stream, cb, err_cb) {
var waiter = new Waiter();
_.defer(function() {
waiter.start(video, stream, cb, err_cb);
});
return waiter;
}
}
}]
});
Loading…
Cancel
Save