video works both ways!!
This commit is contained in:
parent
f5b8aa7c61
commit
97014cdace
2 changed files with 12 additions and 12 deletions
|
|
@ -5,7 +5,11 @@ angular.module('copay.controllerUtils')
|
||||||
var root = {};
|
var root = {};
|
||||||
$rootScope.videoSrc = {};
|
$rootScope.videoSrc = {};
|
||||||
$rootScope.getVideoURL = function(copayer) {
|
$rootScope.getVideoURL = function(copayer) {
|
||||||
return $sce.trustAsResourceUrl(decodeURI($rootScope.videoSrc[copayer]));
|
var encoded = $rootScope.videoSrc[copayer];
|
||||||
|
if (!encoded) return;
|
||||||
|
var url = decodeURI(encoded);
|
||||||
|
var trusted = $sce.trustAsResourceUrl(url);
|
||||||
|
return trusted;
|
||||||
};
|
};
|
||||||
|
|
||||||
root.logout = function() {
|
root.logout = function() {
|
||||||
|
|
@ -34,8 +38,8 @@ angular.module('copay.controllerUtils')
|
||||||
var handlePeerVideo = function(err, peerID, url) {
|
var handlePeerVideo = function(err, peerID, url) {
|
||||||
if (err) {
|
if (err) {
|
||||||
root.onErrorDigest(err);
|
root.onErrorDigest(err);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
alert('add this video url='+url+' for peer '+peerID);
|
|
||||||
$rootScope.videoSrc[peerID] = encodeURI(url);
|
$rootScope.videoSrc[peerID] = encodeURI(url);
|
||||||
$rootScope.$apply();
|
$rootScope.$apply();
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,8 @@ var Video = function() {
|
||||||
navigator.getUserMedia = navigator.getUserMedia ||
|
navigator.getUserMedia = navigator.getUserMedia ||
|
||||||
navigator.webkitGetUserMedia ||
|
navigator.webkitGetUserMedia ||
|
||||||
navigator.mozGetUserMedia;
|
navigator.mozGetUserMedia;
|
||||||
|
|
||||||
|
this.mediaConnections = {};
|
||||||
};
|
};
|
||||||
|
|
||||||
Video.prototype.setOwnPeer = function(peer, wallet, cb) {
|
Video.prototype.setOwnPeer = function(peer, wallet, cb) {
|
||||||
|
|
@ -16,8 +18,9 @@ Video.prototype.setOwnPeer = function(peer, wallet, cb) {
|
||||||
// This is called when user accepts using webcam
|
// This is called when user accepts using webcam
|
||||||
self.localStream = stream;
|
self.localStream = stream;
|
||||||
var online = wallet.getOnlinePeerIDs();
|
var online = wallet.getOnlinePeerIDs();
|
||||||
for (var i=0; i<online.length; i++) {
|
for (var i = 0; i < online.length; i++) {
|
||||||
var o = online[i];
|
var o = online[i];
|
||||||
|
var mc = self.mediaConnections[o];
|
||||||
if (o !== peer.id) {
|
if (o !== peer.id) {
|
||||||
self.callPeer(o, cb);
|
self.callPeer(o, cb);
|
||||||
}
|
}
|
||||||
|
|
@ -29,17 +32,14 @@ Video.prototype.setOwnPeer = function(peer, wallet, cb) {
|
||||||
|
|
||||||
// Receiving a call
|
// Receiving a call
|
||||||
peer.on('call', function(mediaConnection) {
|
peer.on('call', function(mediaConnection) {
|
||||||
alert('answering call from ' + mediaConnection.peer);
|
|
||||||
if (self.localStream) {
|
if (self.localStream) {
|
||||||
mediaConnection.answer(self.localStream);
|
mediaConnection.answer(self.localStream);
|
||||||
} else {
|
} else {
|
||||||
mediaConnection.answer();
|
mediaConnection.answer();
|
||||||
}
|
}
|
||||||
|
self.mediaConnections[mediaConnection.peer] = mediaConnection;
|
||||||
self._addCall(mediaConnection, cb);
|
self._addCall(mediaConnection, cb);
|
||||||
});
|
});
|
||||||
peer.on('error', function(err) {
|
|
||||||
alert('error on video peer '+err);
|
|
||||||
});
|
|
||||||
this.peer = peer;
|
this.peer = peer;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -52,19 +52,15 @@ Video.prototype.callPeer = function(peerID, cb) {
|
||||||
|
|
||||||
Video.prototype._addCall = function(mediaConnection, cb) {
|
Video.prototype._addCall = function(mediaConnection, cb) {
|
||||||
var peerID = mediaConnection.peer;
|
var peerID = mediaConnection.peer;
|
||||||
alert('_addCall ' + peerID);
|
|
||||||
|
|
||||||
// Wait for stream on the call, then set peer video display
|
// Wait for stream on the call, then set peer video display
|
||||||
mediaConnection.on('stream', function(stream) {
|
mediaConnection.on('stream', function(stream) {
|
||||||
alert('STREAM ON ADD CALL');
|
|
||||||
cb(null, peerID, URL.createObjectURL(stream));
|
cb(null, peerID, URL.createObjectURL(stream));
|
||||||
});
|
});
|
||||||
|
|
||||||
mediaConnection.on('close', function() {
|
mediaConnection.on('close', function() {
|
||||||
alert('CLOSEEEEEEEEEEEEEEE ON ADD CALL');
|
|
||||||
});
|
});
|
||||||
mediaConnection.on('error', function() {
|
mediaConnection.on('error', function() {
|
||||||
alert('ERROR ON ADD CALL');
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue