sipml5 icon indicating copy to clipboard operation
sipml5 copied to clipboard

How to select wished microphone / camera devices ?

Open derMani opened this issue 9 years ago • 4 comments

Problem: Currently it is not possible to select a specific camera or microphone with sipml5.

Expected output: Providing a way to select the wished camera / microphone for the getUserMedia method

SipML Revision: 1.5.230

Possible solution: This answer on stackoverflow suggests how to retrieve the device ID for WebRTC amongst different browsers by using the enumerateDevices function specified by the W3C:

http://stackoverflow.com/a/20087996/666208

The next thing to do would be to include the device's ID in the constraints object of getUserMedia

var constraints = {
  audio: {
    optional: [{
      sourceId: audioSource
    }]
  },
  video: {
    optional: [{
      sourceId: videoSource
    }]
  }
};

With this approach, the user would be able to select a camera in the application and not from the browser's camera dialog, which is sometimes acting weird.

Regards Rlf

derMani avatar Dec 09 '15 17:12 derMani

I made this with super-hack (run this code after sipml5 is loaded):

var stored_getUserMedia_function = navigator.getUserMedia.bind(navigator); navigator.getUserMedia = my_getUserMedia;

function my_getUserMedia(constraints, onSuccessCallback, onErrorCallback){ if (variable_with_my_microphone_id) { constraints['audio'] = {"mandatory":{"sourceId": variable_with_my_microphone_id } }; }; return stored_getUserMedia_function(constraints, onSuccessCallback, onErrorCallback); };

roginvs avatar Apr 01 '16 10:04 roginvs

By adding some conditions lines in SIPml5 js file, it worked very good!!!! The method above didn't work in my case.

louk88 avatar Feb 21 '17 04:02 louk88

@louk88 , maybe you were using development version of sipml5, so it was loaded after that part of the code, even the SIPml-api.js was loaded before.

roginvs avatar Feb 21 '17 07:02 roginvs

Yes maybe i don't work in the same version

louk88 avatar Feb 21 '17 15:02 louk88