()
| 605 | } |
| 606 | |
| 607 | _createOffer () { |
| 608 | if (this.destroyed) return |
| 609 | |
| 610 | this._pc.createOffer(this.offerOptions) |
| 611 | .then(offer => { |
| 612 | if (this.destroyed) return |
| 613 | if (!this.trickle && !this.allowHalfTrickle) offer.sdp = filterTrickle(offer.sdp) |
| 614 | offer.sdp = this.sdpTransform(offer.sdp) |
| 615 | |
| 616 | const sendOffer = () => { |
| 617 | if (this.destroyed) return |
| 618 | const signal = this._pc.localDescription || offer |
| 619 | this._debug('signal') |
| 620 | this.emit('signal', { |
| 621 | type: signal.type, |
| 622 | sdp: signal.sdp |
| 623 | }) |
| 624 | } |
| 625 | |
| 626 | const onSuccess = () => { |
| 627 | this._debug('createOffer success') |
| 628 | if (this.destroyed) return |
| 629 | if (this.trickle || this._iceComplete) sendOffer() |
| 630 | else this.once('_iceComplete', sendOffer) // wait for candidates |
| 631 | } |
| 632 | |
| 633 | const onError = err => { |
| 634 | this.destroy(errCode(err, 'ERR_SET_LOCAL_DESCRIPTION')) |
| 635 | } |
| 636 | |
| 637 | this._pc.setLocalDescription(offer) |
| 638 | .then(onSuccess) |
| 639 | .catch(onError) |
| 640 | }) |
| 641 | .catch(err => { |
| 642 | this.destroy(errCode(err, 'ERR_CREATE_OFFER')) |
| 643 | }) |
| 644 | } |
| 645 | |
| 646 | _requestMissingTransceivers () { |
| 647 | if (this._pc.getTransceivers) { |
no test coverage detected