.module('storageService')
.service('splashscreen', ['$rootScope', '$q', 'storage', 'config', 'verto',
function($rootScope, $q, storage, config, verto) {
-
+
var checkBrowser = function() {
return $q(function(resolve, reject) {
var activity = 'browser-upgrade';
if (!navigator.getUserMedia) {
result['status'] = 'error';
result['message'] = 'Error: browser doesn\'t support WebRTC.';
- reject(result);
+ reject(result);
}
- resolve(result);
+ resolve(result);
});
};
reject(result);
}
verto.data.mediaPerm = true;
- resolve(result);
+ resolve(result);
});
});
};
'activity': activity,
'message': 'Refresh Media Devices.'
};
-
+
verto.refreshDevices(function(status) {
verto.refreshDevicesCallback(function() {
resolve(result);
});
};
+ var checkConnectionSpeed = function() {
+ return $q(function(resolve, reject) {
+ var activity = 'check-connection-speed';
+ var result = {
+ 'status': 'success',
+ 'soft': true,
+ 'activity': activity,
+ 'message': 'Check Connection Speed.'
+ };
+
+ if(!verto.instance) {
+ resolve(result);
+ return;
+ }
+
+ verto.testSpeed(cb);
+
+ function cb(data) {
+
+ resolve(result);
+ }
+ });
+ };
+
var provisionConfig = function() {
return $q(function(resolve, reject) {
var activity = 'provision-config';
});
result['promise'] = configPromise;
-
+
resolve(result);
});
};
verto.data.connecting = false;
resolve(result);
});
- };
+ };
};
if(storage.data.ui_connected && storage.data.ws_connected) {
- checkUserStored();
+ checkUserStored();
} else {
- resolve(result);
+ resolve(result);
};
});
};
checkMediaPerm,
refreshMediaDevices,
provisionConfig,
- checkLogin
+ checkLogin,
+ checkConnectionSpeed
];
var progress_message = [
'Checking media permissions',
'Refresh Media Devices.',
'Provisioning configuration.',
- 'Checking login.'
+ 'Checking login.',
+ 'Check Connection Speed.'
];
-
+
var getProgressMessage = function(current_progress) {
if(progress_message[current_progress] != undefined) {
- return progress_message[current_progress];
+ return progress_message[current_progress];
} else {
return 'Please wait...';
}
var calculateProgress = function(index) {
var _progress;
-
+
_progress = index + 1;
progress_percentage = (_progress / progress.length) * 100;
return progress_percentage;
var fn, fn_return, status, interrupt, activity, soft, message, promise;
interrupt = false;
current_progress++;
-
+
if(current_progress >= progress.length) {
$rootScope.$emit('progress.complete', current_progress);
return;
}
-
+
fn = progress[current_progress];
fn_return = fn();
emitNextProgress(fn_return);
}
);
-
+
};
return {
};
}]);
-
}
},
+ /**
+ * Do speed test.
+ *
+ * @param callback
+ */
+ testSpeed: function(cb) {
+
+ data.instance.rpcClient.speedTest(1024 * 256, function(e, data) {
+ var outBand = Math.ceil(data.upKPS * .75),
+ inBand = Math.ceil(data.downKPS * .75);
+
+ storage.data.vidQual = 'hd';
+
+ if (outBand < 1024) {
+ storage.data.vidQual = 'vga';
+ }
+ if (outBand < 512) {
+ storage.data.vidQual = 'qvga';
+ }
+
+ if(cb) cb(data);
+ // console.info("Up: " + data.upKPS, "Down: ", data.downKPS);
+ });
+ },
/**
* Mute the microphone for the current call.
*