|
@@ -84,9 +84,31 @@ RTC.obtainAudioAndVideoPermissions = function (options) {
|
84
|
84
|
};
|
85
|
85
|
|
86
|
86
|
RTC.prototype.onIncommingCall = function(event) {
|
87
|
|
- if(this.options.config.openSctp)
|
|
87
|
+ if(this.options.config.openSctp) {
|
88
|
88
|
this.dataChannels = new DataChannels(event.peerconnection,
|
89
|
89
|
this.eventEmitter);
|
|
90
|
+ this._dataChannelOpenListener = () => {
|
|
91
|
+ // when the data channel becomes available, tell the bridge
|
|
92
|
+ // about video selections so that it can do adaptive simulcast,
|
|
93
|
+ // we want the notification to trigger even if userJid
|
|
94
|
+ // is undefined, or null.
|
|
95
|
+ // XXX why do we not do the same for pinned endpoints?
|
|
96
|
+ try {
|
|
97
|
+ this.dataChannels.sendSelectedEndpointMessage(
|
|
98
|
+ this.selectedEndpoint);
|
|
99
|
+ } catch (error) {
|
|
100
|
+ GlobalOnErrorHandler.callErrorHandler(error);
|
|
101
|
+ logger.error("Cannot sendSelectedEndpointMessage ",
|
|
102
|
+ this.selectedEndpoint, ". Error: ", error);
|
|
103
|
+ }
|
|
104
|
+
|
|
105
|
+ this.removeListener(RTCEvents.DATA_CHANNEL_OPEN,
|
|
106
|
+ this._dataChannelOpenListener);
|
|
107
|
+ this._dataChannelOpenListener = null;
|
|
108
|
+ };
|
|
109
|
+ this.addListener(RTCEvents.DATA_CHANNEL_OPEN,
|
|
110
|
+ this._dataChannelOpenListener);
|
|
111
|
+ }
|
90
|
112
|
};
|
91
|
113
|
|
92
|
114
|
/**
|
|
@@ -104,18 +126,19 @@ RTC.prototype.onCallEnded = function() {
|
104
|
126
|
};
|
105
|
127
|
|
106
|
128
|
/**
|
107
|
|
- * Elects the participant with the given id to be the pinned participant in
|
|
129
|
+ * Elects the participant with the given id to be the selected participant in
|
108
|
130
|
* order to always receive video for this participant (even when last n is
|
109
|
131
|
* enabled).
|
|
132
|
+ * If there is no data channel we store it and send it through the channel once
|
|
133
|
+ * it is created.
|
110
|
134
|
* @param id {string} the user id.
|
111
|
135
|
* @throws NetworkError or InvalidStateError or Error if the operation fails.
|
112
|
136
|
*/
|
113
|
137
|
RTC.prototype.selectEndpoint = function (id) {
|
114
|
|
- if(this.dataChannels) {
|
|
138
|
+ // cache the value if channel is missing, till we open it
|
|
139
|
+ this.selectedEndpoint = id;
|
|
140
|
+ if(this.dataChannels)
|
115
|
141
|
this.dataChannels.sendSelectedEndpointMessage(id);
|
116
|
|
- } else {
|
117
|
|
- throw new Error("Data channels support is disabled!");
|
118
|
|
- }
|
119
|
142
|
};
|
120
|
143
|
|
121
|
144
|
/**
|
|
@@ -129,6 +152,8 @@ RTC.prototype.pinEndpoint = function (id) {
|
129
|
152
|
if(this.dataChannels) {
|
130
|
153
|
this.dataChannels.sendPinnedEndpointMessage(id);
|
131
|
154
|
} else {
|
|
155
|
+ // FIXME: cache value while there is no data channel created
|
|
156
|
+ // and send the cached state once channel is created
|
132
|
157
|
throw new Error("Data channels support is disabled!");
|
133
|
158
|
}
|
134
|
159
|
};
|
|
@@ -527,7 +552,8 @@ RTC.prototype.handleRemoteTrackVideoTypeChanged = function (value, from) {
|
527
|
552
|
* @param to {string} the id of the endpoint that should receive the message.
|
528
|
553
|
* If "" the message will be sent to all participants.
|
529
|
554
|
* @param payload {object} the payload of the message.
|
530
|
|
- * @throws NetworkError or InvalidStateError or Error if the operation fails.
|
|
555
|
+ * @throws NetworkError or InvalidStateError or Error if the operation fails
|
|
556
|
+ * or there is no data channel created
|
531
|
557
|
*/
|
532
|
558
|
RTC.prototype.sendDataChannelMessage = function (to, payload) {
|
533
|
559
|
if(this.dataChannels) {
|