|
@@ -697,93 +697,90 @@ TraceablePeerConnection.prototype.createDataChannel = function(label, opts) {
|
697
|
697
|
};
|
698
|
698
|
|
699
|
699
|
TraceablePeerConnection.prototype.setLocalDescription
|
700
|
|
- = function(description, successCallback, failureCallback) {
|
701
|
|
- this.trace(
|
702
|
|
- 'setLocalDescription::preTransform',
|
703
|
|
- dumpSDP(description));
|
704
|
|
-
|
705
|
|
- // if we're running on FF, transform to Plan A first.
|
706
|
|
- if (RTCBrowserType.usesUnifiedPlan()) {
|
707
|
|
- description = this.interop.toUnifiedPlan(description);
|
708
|
|
- this.trace('setLocalDescription::postTransform (Plan A)',
|
709
|
|
- dumpSDP(description));
|
710
|
|
- }
|
|
700
|
+ = function(description, successCallback, failureCallback) {
|
|
701
|
+ let d = description;
|
711
|
702
|
|
712
|
|
- const self = this;
|
|
703
|
+ this.trace('setLocalDescription::preTransform', dumpSDP(d));
|
713
|
704
|
|
714
|
|
- this.peerconnection.setLocalDescription(description,
|
715
|
|
- () => {
|
716
|
|
- self.trace('setLocalDescriptionOnSuccess');
|
717
|
|
- successCallback();
|
718
|
|
- },
|
719
|
|
- err => {
|
720
|
|
- self.trace('setLocalDescriptionOnFailure', err);
|
721
|
|
- self.eventEmitter.emit(
|
722
|
|
- RTCEvents.SET_LOCAL_DESCRIPTION_FAILED,
|
723
|
|
- err, self.peerconnection);
|
724
|
|
- failureCallback(err);
|
|
705
|
+ // if we're running on FF, transform to Plan A first.
|
|
706
|
+ if (RTCBrowserType.usesUnifiedPlan()) {
|
|
707
|
+ d = this.interop.toUnifiedPlan(d);
|
|
708
|
+ this.trace(
|
|
709
|
+ 'setLocalDescription::postTransform (Plan A)',
|
|
710
|
+ dumpSDP(d));
|
725
|
711
|
}
|
726
|
|
- );
|
727
|
|
- };
|
728
|
712
|
|
729
|
|
-TraceablePeerConnection.prototype.setRemoteDescription
|
730
|
|
- = function(description, successCallback, failureCallback) {
|
731
|
|
- this.trace(
|
732
|
|
- 'setRemoteDescription::preTransform',
|
733
|
|
- dumpSDP(description));
|
|
713
|
+ const self = this;
|
|
714
|
+
|
|
715
|
+ this.peerconnection.setLocalDescription(
|
|
716
|
+ d,
|
|
717
|
+ () => {
|
|
718
|
+ self.trace('setLocalDescriptionOnSuccess');
|
|
719
|
+ successCallback();
|
|
720
|
+ },
|
|
721
|
+ err => {
|
|
722
|
+ self.trace('setLocalDescriptionOnFailure', err);
|
|
723
|
+ self.eventEmitter.emit(
|
|
724
|
+ RTCEvents.SET_LOCAL_DESCRIPTION_FAILED,
|
|
725
|
+ err, self.peerconnection);
|
|
726
|
+ failureCallback(err);
|
|
727
|
+ }
|
|
728
|
+ );
|
|
729
|
+ };
|
734
|
730
|
|
735
|
|
- // TODO the focus should squeze or explode the remote simulcast
|
736
|
|
- description = this.simulcast.mungeRemoteDescription(description);
|
737
|
|
- this.trace(
|
738
|
|
- 'setRemoteDescription::postTransform (simulcast)',
|
739
|
|
- dumpSDP(description));
|
|
731
|
+TraceablePeerConnection.prototype.setRemoteDescription
|
|
732
|
+ = function(description, successCallback, failureCallback) {
|
|
733
|
+ this.trace('setRemoteDescription::preTransform', dumpSDP(description));
|
|
734
|
+
|
|
735
|
+ // TODO the focus should squeze or explode the remote simulcast
|
|
736
|
+ // eslint-disable-next-line no-param-reassign
|
|
737
|
+ description = this.simulcast.mungeRemoteDescription(description);
|
|
738
|
+ this.trace(
|
|
739
|
+ 'setRemoteDescription::postTransform (simulcast)',
|
|
740
|
+ dumpSDP(description));
|
740
|
741
|
|
741
|
|
- if (this.options.preferH264) {
|
742
|
|
- const parsedSdp = transform.parse(description.sdp);
|
743
|
|
- const videoMLine
|
744
|
|
- = parsedSdp.media.find(m => m.type === 'video');
|
|
742
|
+ if (this.options.preferH264) {
|
|
743
|
+ const parsedSdp = transform.parse(description.sdp);
|
|
744
|
+ const videoMLine = parsedSdp.media.find(m => m.type === 'video');
|
745
|
745
|
|
746
|
|
- SDPUtil.preferVideoCodec(videoMLine, 'h264');
|
747
|
|
- description.sdp = transform.write(parsedSdp);
|
748
|
|
- }
|
|
746
|
+ SDPUtil.preferVideoCodec(videoMLine, 'h264');
|
|
747
|
+ description.sdp = transform.write(parsedSdp);
|
|
748
|
+ }
|
749
|
749
|
|
750
|
|
- // if we're running on FF, transform to Plan A first.
|
751
|
|
- if (RTCBrowserType.usesUnifiedPlan()) {
|
752
|
|
- description.sdp = this.rtxModifier.stripRtx(description.sdp);
|
753
|
|
- this.trace(
|
|
750
|
+ // if we're running on FF, transform to Plan A first.
|
|
751
|
+ if (RTCBrowserType.usesUnifiedPlan()) {
|
|
752
|
+ description.sdp = this.rtxModifier.stripRtx(description.sdp);
|
|
753
|
+ this.trace(
|
754
|
754
|
'setRemoteDescription::postTransform (stripRtx)',
|
755
|
755
|
dumpSDP(description));
|
756
|
|
- description = this.interop.toUnifiedPlan(description);
|
757
|
|
- this.trace(
|
758
|
|
- 'setRemoteDescription::postTransform (Plan A)',
|
759
|
|
- dumpSDP(description));
|
760
|
|
- }
|
761
|
756
|
|
762
|
|
- if (RTCBrowserType.usesPlanB()) {
|
763
|
|
- description = normalizePlanB(description);
|
764
|
|
- }
|
765
|
|
-
|
766
|
|
- const self = this;
|
|
757
|
+ // eslint-disable-next-line no-param-reassign
|
|
758
|
+ description = this.interop.toUnifiedPlan(description);
|
|
759
|
+ this.trace(
|
|
760
|
+ 'setRemoteDescription::postTransform (Plan A)',
|
|
761
|
+ dumpSDP(description));
|
|
762
|
+ }
|
767
|
763
|
|
768
|
|
- this.peerconnection.setRemoteDescription(description,
|
769
|
|
- () => {
|
770
|
|
- self.trace('setRemoteDescriptionOnSuccess');
|
771
|
|
- successCallback();
|
772
|
|
- },
|
773
|
|
- err => {
|
774
|
|
- self.trace('setRemoteDescriptionOnFailure', err);
|
775
|
|
- self.eventEmitter.emit(RTCEvents.SET_REMOTE_DESCRIPTION_FAILED,
|
776
|
|
- err, self.peerconnection);
|
777
|
|
- failureCallback(err);
|
|
764
|
+ if (RTCBrowserType.usesPlanB()) {
|
|
765
|
+ // eslint-disable-next-line no-param-reassign
|
|
766
|
+ description = normalizePlanB(description);
|
778
|
767
|
}
|
779
|
|
- );
|
780
|
768
|
|
781
|
|
- /*
|
782
|
|
- if (this.statsinterval === null && this.maxstats > 0) {
|
783
|
|
- // start gathering stats
|
784
|
|
- }
|
785
|
|
- */
|
786
|
|
- };
|
|
769
|
+ this.peerconnection.setRemoteDescription(
|
|
770
|
+ description,
|
|
771
|
+ () => {
|
|
772
|
+ this.trace('setRemoteDescriptionOnSuccess');
|
|
773
|
+ successCallback();
|
|
774
|
+ },
|
|
775
|
+ err => {
|
|
776
|
+ this.trace('setRemoteDescriptionOnFailure', err);
|
|
777
|
+ this.eventEmitter.emit(
|
|
778
|
+ RTCEvents.SET_REMOTE_DESCRIPTION_FAILED,
|
|
779
|
+ err,
|
|
780
|
+ this.peerconnection);
|
|
781
|
+ failureCallback(err);
|
|
782
|
+ });
|
|
783
|
+ };
|
787
|
784
|
|
788
|
785
|
/**
|
789
|
786
|
* Makes the underlying TraceablePeerConnection generate new SSRC for
|
|
@@ -880,9 +877,9 @@ const _fixAnswerRFC4145Setup = function(offer, answer) {
|
880
|
877
|
};
|
881
|
878
|
|
882
|
879
|
TraceablePeerConnection.prototype.createAnswer
|
883
|
|
- = function(successCallback, failureCallback, constraints) {
|
884
|
|
- this.trace('createAnswer', JSON.stringify(constraints, null, ' '));
|
885
|
|
- this.peerconnection.createAnswer(
|
|
880
|
+ = function(successCallback, failureCallback, constraints) {
|
|
881
|
+ this.trace('createAnswer', JSON.stringify(constraints, null, ' '));
|
|
882
|
+ this.peerconnection.createAnswer(
|
886
|
883
|
answer => {
|
887
|
884
|
try {
|
888
|
885
|
this.trace(
|
|
@@ -890,6 +887,7 @@ TraceablePeerConnection.prototype.createAnswer
|
890
|
887
|
|
891
|
888
|
// if we're running on FF, transform to Plan A first.
|
892
|
889
|
if (RTCBrowserType.usesUnifiedPlan()) {
|
|
890
|
+ // eslint-disable-next-line no-param-reassign
|
893
|
891
|
answer = this.interop.toPlanB(answer);
|
894
|
892
|
this.trace('createAnswerOnSuccess::postTransform (Plan B)',
|
895
|
893
|
dumpSDP(answer));
|
|
@@ -916,7 +914,9 @@ TraceablePeerConnection.prototype.createAnswer
|
916
|
914
|
|
917
|
915
|
// Add simulcast streams if simulcast is enabled
|
918
|
916
|
if (!this.options.disableSimulcast
|
919
|
|
- && this.simulcast.isSupported()) {
|
|
917
|
+ && this.simulcast.isSupported()) {
|
|
918
|
+
|
|
919
|
+ // eslint-disable-next-line no-param-reassign
|
920
|
920
|
answer = this.simulcast.mungeLocalDescription(answer);
|
921
|
921
|
this.trace(
|
922
|
922
|
'createAnswerOnSuccess::postTransform (simulcast)',
|
|
@@ -955,9 +955,8 @@ TraceablePeerConnection.prototype.createAnswer
|
955
|
955
|
this.peerconnection);
|
956
|
956
|
failureCallback(err);
|
957
|
957
|
},
|
958
|
|
- constraints
|
959
|
|
- );
|
960
|
|
- };
|
|
958
|
+ constraints);
|
|
959
|
+ };
|
961
|
960
|
|
962
|
961
|
TraceablePeerConnection.prototype.addIceCandidate
|
963
|
962
|
|
|
@@ -986,13 +985,13 @@ TraceablePeerConnection.prototype.getStats = function(callback, errback) {
|
986
|
985
|
if (RTCBrowserType.isFirefox()
|
987
|
986
|
|| RTCBrowserType.isTemasysPluginUsed()
|
988
|
987
|
|| RTCBrowserType.isReactNative()) {
|
989
|
|
- if (!errback) {
|
990
|
|
- errback = function() {
|
|
988
|
+ this.peerconnection.getStats(
|
|
989
|
+ null,
|
|
990
|
+ callback,
|
|
991
|
+ errback || (() => {
|
991
|
992
|
// Making sure that getStats won't fail if error callback is
|
992
|
993
|
// not passed.
|
993
|
|
- };
|
994
|
|
- }
|
995
|
|
- this.peerconnection.getStats(null, callback, errback);
|
|
994
|
+ }));
|
996
|
995
|
} else {
|
997
|
996
|
this.peerconnection.getStats(callback);
|
998
|
997
|
}
|