How to use onvif - 8 common examples

To help you get started, we’ve selected a few onvif examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bartbutenaers / node-red-contrib-onvif-nodes / onvif_discovery.js View on Github external
console.info("Discovery request ignored, since other discovery is active");
                return;
            }
            
            node.status({fill:"yellow",shape:"dot",text:"discovering"});
            node.counter = 0;
            node.discovering = true;
            
            var options = { 
                timeout: node.timeout, // Discovery should end after the specified timeout
                resolve: false // Return discovered devices as data objects, instead of Cam instances
            };

            // Start discovery of the ONVIF network devices.
            // The callback function will be called only once, when the broadcast is finished (after the timeout).
            onvif.Discovery.probe(options, function(err, result) {
                if (err) { 
                    console.error(err.message);
                    node.status({fill:"red",shape:"dot",text: "failed"});
                }
                else {
                    node.status({fill:"green",shape:"dot",text: "completed (" + node.counter + "x)"});
                }           
                
                if (!node.separate) {
                    var devices = [];
                    
                    // Convert the array to an easy format
                    for (var i = 0; i < result.length; i++) {
                        devices.push(simplifyResult(result[i]));
                    }
github bartbutenaers / node-red-contrib-onvif-nodes / onvif_discovery.js View on Github external
return probeMatch;
        }
        
        function handleResult(result) {
            node.counter++;
            
            if (node.separate) {
                // Send a separate output message for every discovered OnVif-compliant IP device
                node.send({payload: simplifyResult(result)}); 
            }
        }
        
        // Register once a listener for device events.
        // The callback function will be called immediately when a device responses.
        onvif.Discovery.on('device', handleResult);
        
        node.on("input", function(msg) {         
            if (node.discovering) {
                console.info("Discovery request ignored, since other discovery is active");
                return;
            }
            
            node.status({fill:"yellow",shape:"dot",text:"discovering"});
            node.counter = 0;
            node.discovering = true;
            
            var options = { 
                timeout: node.timeout, // Discovery should end after the specified timeout
                resolve: false // Return discovered devices as data objects, instead of Cam instances
            };
github bartbutenaers / node-red-contrib-onvif-nodes / onvif_config.js View on Github external
// TODO checken of er altijd een this.credentials bestaat, indien username en paswoord niet ingevuld is.
            
            // The client credentials will only contain the data (i.e. user name or password) which has changed.
            // The other data is not changed, so we will need use the original data stored on the server.
            clientConfig.username = clientConfig.user || this.credentials.user;
            clientConfig.password = clientConfig.password || this.credentials.password;
                    
            // When the user appends some new text to the existing password, then the original password is passed via the client as __PWRD__
            // So replace __PWRD__ again by the original password.
            if (clientConfig.password && this.credentials.password) {
               clientConfig.password.replace('___PWRD__', this.credentials.password);
            }
     
            if (this.credentials.user !== clientConfig.user || this.credentials.password !== clientConfig.password || this.xaddress !== clientConfig.hostname){
                var cam = new onvif.Cam(clientConfig, function(err) {             
                    if (!err) {
                        if (cam.profiles) {
                            for(var i = 0; i < cam.profiles.length; i++) {
                                profileNames.push({
                                    label: cam.profiles[i].name,
                                    value: cam.profiles[i].$.token
                                });
                            }
                        }
                        
                        response.json(profileNames);
                    }
                });
            }
            else {
                if (this.cam.profiles) {
github bartbutenaers / node-red-contrib-onvif-nodes / onvif_config.js View on Github external
return;
        }
        
        setOnvifStatus(node, "initializing");
        
        var options = {};
        options.hostname = this.xaddress;
        options.port = this.port;
        
        if (this.credentials && this.credentials.user) {
            options.username = this.credentials.user;
            options.password = this.credentials.password;
        }

        // Create a new camera instance, which will automatically connect to the device (to load configuration data)
        this.cam = new onvif.Cam(options, function(err) { 
            if (err) {
                // Make sure the Catch-node can catch the error
                node.error( err, {} );
                
                setOnvifStatus(node, "disconnected");
            }
            else {  
                setOnvifStatus(node, "connected"); 
            }
        });
        
        node.on('close', function(){
			setOnvifStatus(node, "");
            
            node.removeAllListeners("onvif_status");
		});
github out4b / cdif / modules / onvif-manager / index.js View on Github external
OnvifManager.prototype.discoverDevices = function(callback) {

    console.log("Hello OnvifManager!");

    onvif.Discovery.probe(function(err, cams) {
    if(err) { throw err; }

        cams.forEach(function(cam) {
            //FIXME: this user/pass info is just a test
            cam.username = 'admin';
            cam.password = 'xsVLX842';
            cam.connect(function(err) {
                if (err) {throw err;}
                cam.getDeviceInformation(function(err, info, xml) {
                    if (err) {throw err;}
                    console.log("Camera Info:  " + JSON.stringify(info));
                    fs.readFile('./onvif.json', 'utf8', function(err, data) {
                        if (err) { throw err; }
                        var devSpec = JSON.parse(data);
                        devSpec.device.friendlyName = info.manufacturer;
                        devSpec.device.manufacturer = info.manufacturer;
github godka / node-rtsp-live555 / example / server.js View on Github external
app.get('/search', function (req, res) {
			onvif.Discovery.probe(function (err, cams) {
				if (err) {
					console.log(err);
					res.send({ result: false });
					return;
				}
				searchForNextTick(res, [], cams, 0);
			});
		});
		app.use(express.static('html'));

onvif

Client to ONVIF NVT devices Profile S: cameras

MIT
Latest version published 4 months ago

Package Health Score

76 / 100
Full package analysis

Popular onvif functions