You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-12-04 05:02:41 +03:00
Glue in call handling into MatrixClient. Outbound calls work.
This commit is contained in:
@@ -7,7 +7,7 @@ var utils = require("../utils");
|
||||
var EventEmitter = require("events").EventEmitter;
|
||||
var DEBUG = true; // set true to enable console logging.
|
||||
|
||||
// events: onHangup, callPlaced, error
|
||||
// events: onHangup, error, replaced
|
||||
|
||||
/**
|
||||
* Construct a new Matrix Call.
|
||||
@@ -68,8 +68,10 @@ MatrixCall.prototype.placeVoiceCall = function() {
|
||||
|
||||
/**
|
||||
* Place a video call to this room.
|
||||
* @param {Element} localVideoElement a DOM element with the local camera preview.
|
||||
* @param {Element} remoteVideoElement a DOM element to render video to.
|
||||
* @param {Element} localVideoElement a <code><video></code> DOM element
|
||||
* to render the local camera preview.
|
||||
* @param {Element} remoteVideoElement a <code><video></code> DOM element
|
||||
* to render video to.
|
||||
* @throws If you have not specified a listener for 'error' events.
|
||||
*/
|
||||
MatrixCall.prototype.placeVideoCall = function(localVideoElement, remoteVideoElement) {
|
||||
@@ -82,7 +84,7 @@ MatrixCall.prototype.placeVideoCall = function(localVideoElement, remoteVideoEle
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieve the local video DOM element.
|
||||
* Retrieve the local <code><video></code> DOM element.
|
||||
* @return {Element} The dom element
|
||||
*/
|
||||
MatrixCall.prototype.getLocalVideoElement = function() {
|
||||
@@ -90,7 +92,7 @@ MatrixCall.prototype.getLocalVideoElement = function() {
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieve the remote video DOM element.
|
||||
* Retrieve the remote <code><video></code> DOM element.
|
||||
* @return {Element} The dom element
|
||||
*/
|
||||
MatrixCall.prototype.getRemoteVideoElement = function() {
|
||||
@@ -98,9 +100,9 @@ MatrixCall.prototype.getRemoteVideoElement = function() {
|
||||
};
|
||||
|
||||
/**
|
||||
* Set the remote video DOM element. If this call is active, video will be
|
||||
* rendered to it.
|
||||
* @param {Element} element The DOM element.
|
||||
* Set the remote <code><video></code> DOM element. If this call is active,
|
||||
* video will be rendered to it immediately.
|
||||
* @param {Element} element The <code><video></code> DOM element.
|
||||
*/
|
||||
MatrixCall.prototype.setRemoteVideoElement = function(element) {
|
||||
this.remoteVideoElement = element;
|
||||
@@ -208,6 +210,7 @@ MatrixCall.prototype._replacedBy = function(newCall) {
|
||||
newCall.localVideoElement = this.localVideoElement;
|
||||
newCall.remoteVideoElement = this.remoteVideoElement;
|
||||
this.successor = newCall;
|
||||
this.emit("replaced", newCall);
|
||||
this.hangup(true);
|
||||
};
|
||||
|
||||
@@ -740,7 +743,7 @@ var _sendCandidateQueue = function(self) {
|
||||
};
|
||||
|
||||
var _placeCallWithConstraints = function(self, constraints) {
|
||||
self.emit("callPlaced", self);
|
||||
self.client.callList[self.callId] = self;
|
||||
self.webRtc.getUserMedia(
|
||||
constraints,
|
||||
hookCallback(self, self._gotUserMediaForInvite),
|
||||
@@ -830,6 +833,9 @@ module.exports.MatrixCall = MatrixCall;
|
||||
module.exports.createNewMatrixCall = function(client, roomId) {
|
||||
var w = global.window;
|
||||
var doc = global.document;
|
||||
if (!w || !doc) {
|
||||
return null;
|
||||
}
|
||||
var webRtc = {};
|
||||
webRtc.isOpenWebRTC = function() {
|
||||
var scripts = doc.getElementById("script");
|
||||
|
||||
Reference in New Issue
Block a user