How to use the react-native-webrtc.RTCPeerConnection.prototype function in react-native-webrtc

To help you get started, we’ve selected a few react-native-webrtc examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jitsi / jitsi-meet / react / features / base / lib-jitsi-meet / native / RTCPeerConnection.js View on Github external
return new Promise((resolve, reject) => {

        /* eslint-disable no-invalid-this */

        // Ensure I'm not remembering onaddstream invocations from previous
        // setRemoteDescription calls. I shouldn't be but... anyway.
        this._onaddstreamQueue = [];

        RTCPeerConnection.prototype.setRemoteDescription.call(this, description)
            .then((...args) => {
                let q;

                try {
                    resolve(...args);
                } finally {
                    q = this._onaddstreamQueue;
                    this._onaddstreamQueue = undefined;
                }

                this._invokeQueuedOnaddstream(q);
            }, (...args) => {
                this._onaddstreamQueue = undefined;

                reject(...args);
            });
github jitsi / jitsi-meet-react / features / base / lib-jitsi-meet / native / polyfills-webrtc.js View on Github external
function (sessionDescription, successCallback, errorCallback) {
                // Ensure I'm not remembering onaddstream invocations from
                // previous setRemoteDescription calls. I shouldn't be but...
                // anyway.
                this._onaddstreamQueue = [];
                return RTCPeerConnection.prototype.setRemoteDescription.call(
                    this,
                    sessionDescription,
                    () => {
                        var r;
                        var q;
                        try {
                            if (successCallback) {
                                r = successCallback.apply(null, arguments);
                            }
                        } finally {
                            q = this._onaddstreamQueue;
                            this._onaddstreamQueue = undefined;
                        }
                        this._invokeQueuedOnaddstream(q);
                        return r;
                    },
github jitsi / jitsi-meet / react / features / base / lib-jitsi-meet / native / RTCPeerConnection.js View on Github external
// $FlowFixMe
    Object.defineProperty(this, 'onaddstream', {
        configurable: true,
        enumerable: true,
        get() {
            return this._onaddstream;
        },
        set(value) {
            this._onaddstream = value;
        }
    });

    /* eslint-enable indent, no-invalid-this */
}

_RTCPeerConnection.prototype = Object.create(RTCPeerConnection.prototype);
_RTCPeerConnection.prototype.constructor = _RTCPeerConnection;

_RTCPeerConnection.prototype._invokeOnaddstream = function(...args) {
    const onaddstream = this._onaddstream;

    return onaddstream && onaddstream.apply(this, args);
};

_RTCPeerConnection.prototype._invokeQueuedOnaddstream = function(q) {
    q && q.forEach(args => {
        try {
            this._invokeOnaddstream(...args);
        } catch (e) {
            // TODO Determine whether the combination of the standard
            // setRemoteDescription and onaddstream results in a similar
            // swallowing of errors.
github jitsi / jitsi-meet-react / features / base / lib-jitsi-meet / native / polyfills-webrtc.js View on Github external
// following approach appears to work and I understand it.
            Object.defineProperty(this, 'onaddstream', {
                configurable: true,
                enumerable: true,
                get: function () {
                    return this._onaddstream;
                },
                set: function (value) {
                    this._onaddstream = value;
                }
            });
        }
        /*eslint-enable no-inner-declarations */

        _RTCPeerConnection.prototype =
            Object.create(RTCPeerConnection.prototype);
        _RTCPeerConnection.prototype.constructor = _RTCPeerConnection;
        _RTCPeerConnection.prototype._invokeOnaddstream = function () {
            var onaddstream = this._onaddstream;
            var r;
            if (onaddstream) {
                r = onaddstream.apply(this, arguments);
            }
            return r;
        };
        _RTCPeerConnection.prototype._invokeQueuedOnaddstream = function (q) {
            q && q.every(function (args) {
                try {
                    this._invokeOnaddstream.apply(this, args);
                } catch (e) {
                    // TODO Determine whether the combination of the standard
                    // setRemoteDescription and onaddstream results in a similar