Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var ref = require("ref");
- var ffi = require('ffi');
- var path = require('path');
- var config = {
- username: 'admin',
- password: 'audio123',
- ip : '10.191.95.197',
- port: 37777
- }
- var cameraLibrary = ffi.Library(path.join(__dirname, 'libs/libviewpath.so'), {
- "openCameraLensCover": ['int', ['string', 'string', 'string', 'int']],
- "closeCameraLensCover": ['int', ['string', 'string', 'string', 'int']],
- "ptzControlZoomIn": ['bool', ['string', 'string', 'string', 'int', 'int']],
- "ptzControlZoomOut": ['bool', ['string', 'string', 'string', 'int', 'int']],
- "ptzControlMoveUp": ['bool', ['string', 'string', 'string', 'int', 'int']],
- "ptzControlMoveDown": ['bool', ['string', 'string', 'string', 'int', 'int']],
- "ptzControlMoveLeft": ['bool', ['string', 'string', 'string', 'int', 'int']],
- "ptzControlMoveRight": ['bool', ['string', 'string', 'string', 'int', 'int']],
- "cameraStartRecordingInSDCard": ['bool', ['string', 'string', 'string', 'int']],
- "cameraStoptRecordingInSDCard": ['bool', ['string', 'string', 'string', 'int']],
- "cameraStartDownLoadFromSDCard": ['bool', ['string', 'string', 'string', 'string', 'string', 'string', 'int', 'pointer']],
- "fisheyeMode": ['bool', ['string', 'string', 'string', 'int', 'int']],
- "cameraGetCurrentMode": ['int', ['string', 'string', 'string', 'int']]
- //"registerDownloadCompleteEventCallBack": ['void', ['pointer']]
- });
- function closeLens(){
- console.log("config: ",config)
- result = cameraLibrary.closeCameraLensCover(config.username, config.password, config.ip, config.port);
- console.log("\n************* Camera Close Response: ", result);
- }
- function openLens(){
- result = cameraLibrary.openCameraLensCover(config.username, config.password, config.ip, config.port);
- console.log("\n************* Camera Open Response: ", result)
- }
- try{
- console.log("=---------------------")
- openLens();
- // closeLens();
- // openLens();
- // closeLens();
- // openLens();
- // closeLens();
- // openLens();
- // closeLens();
- // openLens();
- // closeLens();
- // openLens();
- // closeLens();
- // openLens();
- // closeLens();
- // openLens();
- // closeLens();
- // openLens();
- // closeLens();
- // openLens();
- // closeLens();
- // openLens();
- // closeLens();
- // openLens();
- // closeLens();
- /*setTimeout(function(){
- openLens();
- setTimeout(function () {
- closeLens();
- }, 1000);
- },2000);
- setTimeout(function () {
- openLens();
- setTimeout(function () {
- closeLens();
- }, 1000);
- }, 4000);
- setTimeout(function () {
- openLens();
- setTimeout(function () {
- closeLens();
- }, 1000);
- }, 10000);*/
- /*var _send = {
- recStart : '2018,12,12,16,54,00',
- recStop: '2018,12,12,23,59,00',
- filename : 'camera.mp4'
- }*/
- /* //1.2 GB Fie
- var _send = {
- recStart: '2018,12,12,12,00,0',
- recStop: '2018,12,12,21,53,0',
- filename: 'camera.mp4'
- }
- */
- ///failing at 57%
- var _send = {
- recStart: '2018,12,12,21,43,0',
- recStop: '2018,12,12,21,44,30',
- filename: 'camera2.mp4'
- }
- /* 148744 kb 140bm
- //working same file
- var _send = {
- recStart: '2018,12,12,21,42,0',
- recStop: '2018,12,12,21,44,40',
- filename: 'camera2.mp4'
- }
- */
- /*
- var _send = {
- recStart: '2018,12,13,15,35,0',
- recStop: '2018,12,13,15,44,30',
- filename: 'camera2.mp4'
- }
- */
- // // Callback from the native lib back into js
- // var callback = ffi.Callback('void', ['string'],
- // function (name) {
- // console.log("***********************************************************************************");
- // console.log("***********************************************************************************");
- // console.log("***********************************************************************************");
- // console.log("***********************************************************************************");
- // console.log("*********************************Download Completd call back received filename is : ", name);
- // console.log("***********************************************************************************");
- // console.log("***********************************************************************************");
- // console.log("***********************************************************************************");
- // console.log("***********************************************************************************");
- // });
- // console.log("registering the callback");
- // cameraLibrary.registerDownloadCompleteEventCallBack(callback);
- // console.log('done');
- // var downloadResult = cameraLibrary.cameraStartDownLoadFromSDCard.async(config.username, config.password, config.ip, _send.recStart, _send.recStop, _send.filename, config.port, () => {
- // console.log("************* download result ", downloadResult)
- // });
- // Callback from the native lib back into js
- var callback = ffi.Callback('void', ['string'],
- function (name) {
- console.log("***********************************************************************************");
- console.log("***********************************************************************************");
- console.log("***********************************************************************************");
- console.log("***********************************************************************************");
- console.log("*********************************Download Completd call back received filename is : ", name);
- console.log("***********************************************************************************");
- console.log("***********************************************************************************");
- console.log("***********************************************************************************");
- console.log("***********************************************************************************");
- });
- /*console.log("registering the callback");
- cameraLibrary.registerDownloadCompleteEventCallBack(callback);
- console.log('done');*/
- // var downloadResult = cameraLibrary.cameraStartDownLoadFromSDCard.async(config.username, config.password, config.ip, _send.recStart, _send.recStop, _send.filename, config.port, callback, () => {
- // console.log("************* download result ", downloadResult)
- // });
- var downloadResult = cameraLibrary.cameraStartDownLoadFromSDCard(config.username, config.password, config.ip, _send.recStart, _send.recStop, _send.filename, config.port, callback );
- setTimeout(function () {
- console.log('Blah blah blah blah extra-blah');
- }, 300000);
- /*startDownload();
- var count = 1;
- var max = 3;
- function startDownload(){
- console.log("Download starting for : ", count);
- var downloadResult = cameraLibrary.cameraStartDownLoadFromSDCard.async(config.username, config.password, config.ip, _send.recStart, _send.recStop, _send.filename, config.port, () => {
- console.log("************* download result ", downloadResult)
- count++;
- if(count <= max){
- startDownload();
- }
- });
- }
- */
- /*
- new Promise(function(resolve, reject){
- var downloadResult = cameraLibrary.cameraStartDownLoadFromSDCard.async(config.username, config.password, config.ip, _send.recStart, _send.recStop, _send.filename, config.port, () => {
- console.log("************* download 1 result In Callback ", downloadResult)
- });
- }).then(function(){
- }).catch(function(ex){
- console.log("*****************************************************************exception from download 1 ",ex.toString())
- }).then(function(){
- setTimeout(function(){
- console.log("execution 2-----------")
- var downloadResult = cameraLibrary.cameraStartDownLoadFromSDCard.async(config.username, config.password, config.ip, _send.recStart, _send.recStop, _send.filename, config.port, () => {
- console.log("************* download 2 result In Callback ", downloadResult)
- });
- },2000)
- });
- */
- }catch(ex){
- console.log(ex);
- }
- // console.log(cameraLibrary);
Add Comment
Please, Sign In to add comment