[RN] Simplify RTCPeerConnection.setRemoteDescription override
This commit is contained in:
parent
1354731fc5
commit
955e0a3382
|
@ -96,29 +96,14 @@ _RTCPeerConnection.prototype._queueOnaddstream = function(...args) {
|
||||||
this._onaddstreamQueue.push(Array.from(args));
|
this._onaddstreamQueue.push(Array.from(args));
|
||||||
};
|
};
|
||||||
|
|
||||||
_RTCPeerConnection.prototype.setRemoteDescription = function(
|
_RTCPeerConnection.prototype.setRemoteDescription = function(description) {
|
||||||
sessionDescription,
|
|
||||||
successCallback,
|
|
||||||
errorCallback) {
|
|
||||||
// If the deprecated callback-based version is used, translate it to the
|
|
||||||
// Promise-based version.
|
|
||||||
if (typeof successCallback !== 'undefined'
|
|
||||||
|| typeof errorCallback !== 'undefined') {
|
|
||||||
// XXX Returning a Promise is not necessary. But I don't see why it'd
|
|
||||||
// hurt (much).
|
|
||||||
return (
|
|
||||||
_RTCPeerConnection.prototype.setRemoteDescription.call(
|
|
||||||
this,
|
|
||||||
sessionDescription)
|
|
||||||
.then(successCallback, errorCallback));
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
_synthesizeIPv6Addresses(sessionDescription)
|
_synthesizeIPv6Addresses(description)
|
||||||
.catch(reason => {
|
.catch(reason => {
|
||||||
reason && _LOGE(reason);
|
reason && _LOGE(reason);
|
||||||
|
|
||||||
return sessionDescription;
|
return description;
|
||||||
})
|
})
|
||||||
.then(value => _setRemoteDescription.bind(this)(value)));
|
.then(value => _setRemoteDescription.bind(this)(value)));
|
||||||
|
|
||||||
|
@ -139,13 +124,13 @@ function _LOGE(...args) {
|
||||||
* implementation which uses the deprecated, callback-based version to the
|
* implementation which uses the deprecated, callback-based version to the
|
||||||
* {@code Promise}-based version.
|
* {@code Promise}-based version.
|
||||||
*
|
*
|
||||||
* @param {RTCSessionDescription} sessionDescription - The RTCSessionDescription
|
* @param {RTCSessionDescription} description - The RTCSessionDescription
|
||||||
* which specifies the configuration of the remote end of the connection.
|
* which specifies the configuration of the remote end of the connection.
|
||||||
* @private
|
* @private
|
||||||
* @private
|
* @private
|
||||||
* @returns {Promise}
|
* @returns {Promise}
|
||||||
*/
|
*/
|
||||||
function _setRemoteDescription(sessionDescription) {
|
function _setRemoteDescription(description) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
|
|
||||||
/* eslint-disable no-invalid-this */
|
/* eslint-disable no-invalid-this */
|
||||||
|
@ -154,10 +139,8 @@ function _setRemoteDescription(sessionDescription) {
|
||||||
// setRemoteDescription calls. I shouldn't be but... anyway.
|
// setRemoteDescription calls. I shouldn't be but... anyway.
|
||||||
this._onaddstreamQueue = [];
|
this._onaddstreamQueue = [];
|
||||||
|
|
||||||
RTCPeerConnection.prototype.setRemoteDescription.call(
|
RTCPeerConnection.prototype.setRemoteDescription.call(this, description)
|
||||||
this,
|
.then((...args) => {
|
||||||
sessionDescription,
|
|
||||||
(...args) => {
|
|
||||||
let q;
|
let q;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -168,8 +151,7 @@ function _setRemoteDescription(sessionDescription) {
|
||||||
}
|
}
|
||||||
|
|
||||||
this._invokeQueuedOnaddstream(q);
|
this._invokeQueuedOnaddstream(q);
|
||||||
},
|
}, (...args) => {
|
||||||
(...args) => {
|
|
||||||
this._onaddstreamQueue = undefined;
|
this._onaddstreamQueue = undefined;
|
||||||
|
|
||||||
reject(...args);
|
reject(...args);
|
||||||
|
|
Loading…
Reference in New Issue