sipml5
sipml5 copied to clipboard
How to select wished microphone / camera devices ?
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
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); };
By adding some conditions lines in SIPml5 js file, it worked very good!!!! The method above didn't work in my case.
@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.
Yes maybe i don't work in the same version