@@ -198,6 +198,7 @@ export class ConferencePeerConnectionChannel extends EventDispatcher {
198
198
this . _internalId = data . id ;
199
199
const offerOptions = { } ;
200
200
if ( typeof this . _pc . addTransceiver === 'function' ) {
201
+ let setPromise = Promise . resolve ( ) ;
201
202
// |direction| seems not working on Safari.
202
203
if ( mediaOptions . audio && stream . mediaStream . getAudioTracks ( ) . length >
203
204
0 ) {
@@ -207,8 +208,15 @@ export class ConferencePeerConnectionChannel extends EventDispatcher {
207
208
if ( this . _isRtpEncodingParameters ( options . audio ) ) {
208
209
transceiverInit . sendEncodings = options . audio ;
209
210
}
210
- this . _pc . addTransceiver ( stream . mediaStream . getAudioTracks ( ) [ 0 ] ,
211
+ const transceiver = this . _pc . addTransceiver ( stream . mediaStream . getAudioTracks ( ) [ 0 ] ,
211
212
transceiverInit ) ;
213
+
214
+ if ( Utils . isFirefox ( ) ) {
215
+ // Firefox does not support encodings setting in addTransceiver.
216
+ const parameters = transceiver . sender . getParameters ( ) ;
217
+ parameters . encodings = transceiverInit . sendEncodings ;
218
+ setPromise = transceiver . sender . setParameters ( parameters ) ;
219
+ }
212
220
}
213
221
if ( mediaOptions . video && stream . mediaStream . getVideoTracks ( ) . length >
214
222
0 ) {
@@ -219,24 +227,32 @@ export class ConferencePeerConnectionChannel extends EventDispatcher {
219
227
transceiverInit . sendEncodings = options . video ;
220
228
this . _videoCodecs = videoCodecs ;
221
229
}
222
- this . _pc . addTransceiver ( stream . mediaStream . getVideoTracks ( ) [ 0 ] ,
230
+ const transceiver = this . _pc . addTransceiver ( stream . mediaStream . getVideoTracks ( ) [ 0 ] ,
223
231
transceiverInit ) ;
232
+
233
+ if ( Utils . isFirefox ( ) ) {
234
+ // Firefox does not support encodings setting in addTransceiver.
235
+ const parameters = transceiver . sender . getParameters ( ) ;
236
+ parameters . encodings = transceiverInit . sendEncodings ;
237
+ setPromise = setPromise . then (
238
+ ( ) => transceiver . sender . setParameters ( parameters ) ) ;
239
+ }
224
240
}
241
+ return setPromise . then ( ( ) => offerOptions ) ;
225
242
} else {
226
243
if ( mediaOptions . audio && stream . mediaStream . getAudioTracks ( ) . length > 0 ) {
227
244
for ( const track of stream . mediaStream . getAudioTracks ( ) )
228
245
this . _pc . addTrack ( track , stream . mediaStream ) ;
229
246
}
230
-
231
247
if ( mediaOptions . video && stream . mediaStream . getVideoTracks ( ) . length > 0 ) {
232
248
for ( const track of stream . mediaStream . getVideoTracks ( ) )
233
249
this . _pc . addTrack ( track , stream . mediaStream ) ;
234
250
}
235
-
236
251
offerOptions . offerToReceiveAudio = false ;
237
252
offerOptions . offerToReceiveVideo = false ;
238
253
}
239
-
254
+ return offerOptions ;
255
+ } ) . then ( ( offerOptions ) => {
240
256
let localDesc ;
241
257
this . _pc . createOffer ( offerOptions ) . then ( ( desc ) => {
242
258
if ( options ) {
0 commit comments