(window)
| 2412 | } |
| 2413 | |
| 2414 | function shimCallbacksAPI(window) { |
| 2415 | if ((typeof window === 'undefined' ? 'undefined' : _typeof(window)) !== 'object' || !window.RTCPeerConnection) { |
| 2416 | return; |
| 2417 | } |
| 2418 | var prototype = window.RTCPeerConnection.prototype; |
| 2419 | var origCreateOffer = prototype.createOffer; |
| 2420 | var origCreateAnswer = prototype.createAnswer; |
| 2421 | var setLocalDescription = prototype.setLocalDescription; |
| 2422 | var setRemoteDescription = prototype.setRemoteDescription; |
| 2423 | var addIceCandidate = prototype.addIceCandidate; |
| 2424 | |
| 2425 | prototype.createOffer = function createOffer(successCallback, failureCallback) { |
| 2426 | var options = arguments.length >= 2 ? arguments[2] : arguments[0]; |
| 2427 | var promise = origCreateOffer.apply(this, [options]); |
| 2428 | if (!failureCallback) { |
| 2429 | return promise; |
| 2430 | } |
| 2431 | promise.then(successCallback, failureCallback); |
| 2432 | return Promise.resolve(); |
| 2433 | }; |
| 2434 | |
| 2435 | prototype.createAnswer = function createAnswer(successCallback, failureCallback) { |
| 2436 | var options = arguments.length >= 2 ? arguments[2] : arguments[0]; |
| 2437 | var promise = origCreateAnswer.apply(this, [options]); |
| 2438 | if (!failureCallback) { |
| 2439 | return promise; |
| 2440 | } |
| 2441 | promise.then(successCallback, failureCallback); |
| 2442 | return Promise.resolve(); |
| 2443 | }; |
| 2444 | |
| 2445 | var withCallback = function withCallback(description, successCallback, failureCallback) { |
| 2446 | var promise = setLocalDescription.apply(this, [description]); |
| 2447 | if (!failureCallback) { |
| 2448 | return promise; |
| 2449 | } |
| 2450 | promise.then(successCallback, failureCallback); |
| 2451 | return Promise.resolve(); |
| 2452 | }; |
| 2453 | prototype.setLocalDescription = withCallback; |
| 2454 | |
| 2455 | withCallback = function withCallback(description, successCallback, failureCallback) { |
| 2456 | var promise = setRemoteDescription.apply(this, [description]); |
| 2457 | if (!failureCallback) { |
| 2458 | return promise; |
| 2459 | } |
| 2460 | promise.then(successCallback, failureCallback); |
| 2461 | return Promise.resolve(); |
| 2462 | }; |
| 2463 | prototype.setRemoteDescription = withCallback; |
| 2464 | |
| 2465 | withCallback = function withCallback(candidate, successCallback, failureCallback) { |
| 2466 | var promise = addIceCandidate.apply(this, [candidate]); |
| 2467 | if (!failureCallback) { |
| 2468 | return promise; |
| 2469 | } |
| 2470 | promise.then(successCallback, failureCallback); |
| 2471 | return Promise.resolve(); |
nothing calls this directly
no outgoing calls
no test coverage detected