Selection of video input, audio input, and audio output is not easy
because navigator.mediaDevices.enumerateDevices() does not work as expected.
This is a simplified example code for learning how-to.
For mobile device videoConstraints.facingMode = 'environment' may be required
instead of deviceId.
See:
https://github.com/philnash/mediadevices-camera-selection/blob/master/app.js
enumerateDevices() works only with https connection.
(file:/// is OK with Firefox)
getUserMedia() then enumerateDevices() without closing the stream got from
getUserMedia()
Close each track of the stream when device selection has been changed.