@@ -198,6 +198,7 @@ export class ConferencePeerConnectionChannel extends EventDispatcher {
198198 this . _internalId = data . id ;
199199 const offerOptions = { } ;
200200 if ( typeof this . _pc . addTransceiver === 'function' ) {
201+ let setPromise = Promise . resolve ( ) ;
201202 // |direction| seems not working on Safari.
202203 if ( mediaOptions . audio && stream . mediaStream . getAudioTracks ( ) . length >
203204 0 ) {
@@ -207,8 +208,15 @@ export class ConferencePeerConnectionChannel extends EventDispatcher {
207208 if ( this . _isRtpEncodingParameters ( options . audio ) ) {
208209 transceiverInit . sendEncodings = options . audio ;
209210 }
210- this . _pc . addTransceiver ( stream . mediaStream . getAudioTracks ( ) [ 0 ] ,
211+ const transceiver = this . _pc . addTransceiver ( stream . mediaStream . getAudioTracks ( ) [ 0 ] ,
211212 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+ }
212220 }
213221 if ( mediaOptions . video && stream . mediaStream . getVideoTracks ( ) . length >
214222 0 ) {
@@ -219,24 +227,32 @@ export class ConferencePeerConnectionChannel extends EventDispatcher {
219227 transceiverInit . sendEncodings = options . video ;
220228 this . _videoCodecs = videoCodecs ;
221229 }
222- this . _pc . addTransceiver ( stream . mediaStream . getVideoTracks ( ) [ 0 ] ,
230+ const transceiver = this . _pc . addTransceiver ( stream . mediaStream . getVideoTracks ( ) [ 0 ] ,
223231 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+ }
224240 }
241+ return setPromise . then ( ( ) => offerOptions ) ;
225242 } else {
226243 if ( mediaOptions . audio && stream . mediaStream . getAudioTracks ( ) . length > 0 ) {
227244 for ( const track of stream . mediaStream . getAudioTracks ( ) )
228245 this . _pc . addTrack ( track , stream . mediaStream ) ;
229246 }
230-
231247 if ( mediaOptions . video && stream . mediaStream . getVideoTracks ( ) . length > 0 ) {
232248 for ( const track of stream . mediaStream . getVideoTracks ( ) )
233249 this . _pc . addTrack ( track , stream . mediaStream ) ;
234250 }
235-
236251 offerOptions . offerToReceiveAudio = false ;
237252 offerOptions . offerToReceiveVideo = false ;
238253 }
239-
254+ return offerOptions ;
255+ } ) . then ( ( offerOptions ) => {
240256 let localDesc ;
241257 this . _pc . createOffer ( offerOptions ) . then ( ( desc ) => {
242258 if ( options ) {
0 commit comments