Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Task/589/implement addtransceiver #625

Merged
2 changes: 1 addition & 1 deletion js/MediaStream.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module.exports = MediaStream;
var debug = require('debug')('iosrtc:MediaStream'),
exec = require('cordova/exec'),
EventTarget = require('./EventTarget'),
MediaStreamTrack = require('./MediaStreamTrack'),
{ MediaStreamTrack } = require('./MediaStreamTrack'),
/**
* Local variables.
*/
Expand Down
8 changes: 6 additions & 2 deletions js/MediaStreamTrack.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/**
* Expose the MediaStreamTrack class.
*/
module.exports = MediaStreamTrack;
module.exports.MediaStreamTrack = MediaStreamTrack;
module.exports.newMediaStreamTrackId = newMediaStreamTrackId;

/**
* Spec: http://w3c.github.io/mediacapture-main/#mediastreamtrack
Expand Down Expand Up @@ -48,6 +49,8 @@ function MediaStreamTrack(dataFromEvent) {
this._enabled = dataFromEvent.enabled;
this._ended = false;

this.dataFromEvent = dataFromEvent;

function onResultOK(data) {
onEvent.call(self, data);
}
Expand Down Expand Up @@ -92,7 +95,8 @@ MediaStreamTrack.prototype.clone = function () {
kind: this.kind,
label: this.label,
readyState: this.readyState,
enabled: this.enabled
enabled: this.enabled,
trackId: this.dataFromEvent.trackId
});
};

Expand Down
66 changes: 34 additions & 32 deletions js/RTCDataChannel.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,38 +141,40 @@ RTCDataChannel.prototype.send = function (data) {
return;
}

if (typeof data === 'string' || data instanceof String) {
exec(null, null, 'iosrtcPlugin', 'RTCPeerConnection_RTCDataChannel_sendString', [
this.peerConnection.pcId,
this.dcId,
data
]);
} else if (window.ArrayBuffer && data instanceof window.ArrayBuffer) {
exec(null, null, 'iosrtcPlugin', 'RTCPeerConnection_RTCDataChannel_sendBinary', [
this.peerConnection.pcId,
this.dcId,
data
]);
} else if (
(window.Int8Array && data instanceof window.Int8Array) ||
(window.Uint8Array && data instanceof window.Uint8Array) ||
(window.Uint8ClampedArray && data instanceof window.Uint8ClampedArray) ||
(window.Int16Array && data instanceof window.Int16Array) ||
(window.Uint16Array && data instanceof window.Uint16Array) ||
(window.Int32Array && data instanceof window.Int32Array) ||
(window.Uint32Array && data instanceof window.Uint32Array) ||
(window.Float32Array && data instanceof window.Float32Array) ||
(window.Float64Array && data instanceof window.Float64Array) ||
(window.DataView && data instanceof window.DataView)
) {
exec(null, null, 'iosrtcPlugin', 'RTCPeerConnection_RTCDataChannel_sendBinary', [
this.peerConnection.pcId,
this.dcId,
data.buffer
]);
} else {
throw new Error('invalid data type');
}
setImmediate(() => {
if (typeof data === 'string' || data instanceof String) {
exec(null, null, 'iosrtcPlugin', 'RTCPeerConnection_RTCDataChannel_sendString', [
this.peerConnection.pcId,
this.dcId,
data
]);
} else if (window.ArrayBuffer && data instanceof window.ArrayBuffer) {
exec(null, null, 'iosrtcPlugin', 'RTCPeerConnection_RTCDataChannel_sendBinary', [
this.peerConnection.pcId,
this.dcId,
data
]);
} else if (
(window.Int8Array && data instanceof window.Int8Array) ||
(window.Uint8Array && data instanceof window.Uint8Array) ||
(window.Uint8ClampedArray && data instanceof window.Uint8ClampedArray) ||
(window.Int16Array && data instanceof window.Int16Array) ||
(window.Uint16Array && data instanceof window.Uint16Array) ||
(window.Int32Array && data instanceof window.Int32Array) ||
(window.Uint32Array && data instanceof window.Uint32Array) ||
(window.Float32Array && data instanceof window.Float32Array) ||
(window.Float64Array && data instanceof window.Float64Array) ||
(window.DataView && data instanceof window.DataView)
) {
exec(null, null, 'iosrtcPlugin', 'RTCPeerConnection_RTCDataChannel_sendBinary', [
this.peerConnection.pcId,
this.dcId,
data.buffer
]);
} else {
throw new Error('invalid data type');
}
});
};

RTCDataChannel.prototype.close = function () {
Expand Down
Loading