@@ -333,11 +333,11 @@ export class MatrixCall extends EventEmitter {
333333 * Place a voice call to this room.
334334 * @throws If you have not specified a listener for 'error' events.
335335 */
336- placeVoiceCall ( ) {
336+ async placeVoiceCall ( ) {
337337 logger . debug ( "placeVoiceCall" ) ;
338338 this . checkForErrorListener ( ) ;
339339 const constraints = getUserMediaContraints ( ConstraintsType . Audio ) ;
340- this . placeCallWithConstraints ( constraints ) ;
340+ await this . placeCallWithConstraints ( constraints ) ;
341341 this . type = CallType . Voice ;
342342 }
343343
@@ -349,13 +349,13 @@ export class MatrixCall extends EventEmitter {
349349 * to render the local camera preview.
350350 * @throws If you have not specified a listener for 'error' events.
351351 */
352- placeVideoCall ( remoteVideoElement : HTMLVideoElement , localVideoElement : HTMLVideoElement ) {
352+ async placeVideoCall ( remoteVideoElement : HTMLVideoElement , localVideoElement : HTMLVideoElement ) {
353353 logger . debug ( "placeVideoCall" ) ;
354354 this . checkForErrorListener ( ) ;
355355 this . localVideoElement = localVideoElement ;
356356 this . remoteVideoElement = remoteVideoElement ;
357357 const constraints = getUserMediaContraints ( ConstraintsType . Video ) ;
358- this . placeCallWithConstraints ( constraints ) ;
358+ await this . placeCallWithConstraints ( constraints ) ;
359359 this . type = CallType . Video ;
360360 }
361361
@@ -864,7 +864,6 @@ export class MatrixCall extends EventEmitter {
864864
865865 // why do we enable audio (and only audio) tracks here? -- matthew
866866 setTracksEnabled ( stream . getAudioTracks ( ) , true ) ;
867- this . peerConn = this . createPeerConnection ( ) ;
868867
869868 for ( const audioTrack of stream . getAudioTracks ( ) ) {
870869 logger . info ( "Adding audio track with id " + audioTrack . id ) ;
@@ -1677,11 +1676,10 @@ export class MatrixCall extends EventEmitter {
16771676 logger . warn ( "Failed to get TURN credentials! Proceeding with call anyway..." ) ;
16781677 }
16791678
1680- // It would be really nice if we could start gathering candidates at this point
1681- // so the ICE agent could be gathering while we open our media devices: we already
1682- // know the type of the call and therefore what tracks we want to send.
1683- // Perhaps we could do this by making fake tracks now and then using replaceTrack()
1684- // once we have the actual tracks? (Can we make fake tracks?)
1679+ // create the peer connection now so it can be gathering candidates while we get user
1680+ // media (assuming a candidate pool size is configured)
1681+ this . peerConn = this . createPeerConnection ( ) ;
1682+
16851683 try {
16861684 const mediaStream = await navigator . mediaDevices . getUserMedia ( constraints ) ;
16871685 this . gotUserMediaForInvite ( mediaStream ) ;
0 commit comments