function wrapEnumerateDevices(enumerateDevices) {
    return function (callback) {
        // enumerate devices only after initial getUserMedia
        afterUserMediaInitialized(function () {

            enumerateDevices().then(function (devices) {
                //add auto devices
                devices.unshift(
                    createAutoDeviceInfo('audioinput'),
                    createAutoDeviceInfo('videoinput')
                );

                callback(devices);
            }, function (err) {
                console.error('cannot enumerate devices: ', err);

                // return only auto devices
                callback([createAutoDeviceInfo('audioinput'),
                          createAutoDeviceInfo('videoinput')]);
            });
        });
    };
}
/**
 * Wrapper function which makes enumerateDevices to wait
 * until someone executes getUserMedia first time.
 * @param {Function} enumerateDevices native function
 * @returns {Funtion} wrapped function
 */
Wrapper function which makes enumerateDevices to wait
until someone executes getUserMedia first time.
@param {Function} enumerateDevices native function
@returns {Funtion} wrapped function
Wrapper function which makes enumerateDevices to wait until someone executes getUserMedia first time . @param { Function } enumerateDevices native function @returns { Funtion } wrapped function
function wrapEnumerateDevices(enumerateDevices) {
    return function (callback) {
        afterUserMediaInitialized(function () {
            enumerateDevices().then(function (devices) {
                devices.unshift(
                    createAutoDeviceInfo('audioinput'),
                    createAutoDeviceInfo('videoinput')
                );
                callback(devices);
            }, function (err) {
                console.error('cannot enumerate devices: ', err);
                callback([createAutoDeviceInfo('audioinput'),
                          createAutoDeviceInfo('videoinput')]);
            });
        });
    };
}
function wrapEnumerateDevices ( enumerateDevices ) { return function ( callback ) { afterUserMediaInitialized ( function ( ) { enumerateDevices ( ) . then ( function ( devices ) { devices . unshift ( createAutoDeviceInfo ( 'audioinput' ) , createAutoDeviceInfo ( 'videoinput' ) ) ; callback ( devices ) ; } , function ( err ) { console . error ( 'cannot enumerate devices: ' , err ) ; callback ( [ createAutoDeviceInfo ( 'audioinput' ) , createAutoDeviceInfo ( 'videoinput' ) ] ) ; } ) ; } ) ; } ; }
Wrapper function which makes enumerateDevices to wait
 until someone executes getUserMedia first time.
Wrapper function which makes enumerateDevices to wait until someone executes getUserMedia first time .
// enumerate devices only after initial getUserMedia //add auto devices // return only auto devices