Onvif - trying to understand how it works - c

First of all, I have no experience in working with ONVIF at all. I got myself a scholarship at a company and was asked to work with it (to control some cameras and get photos from them), but they don't know how it works either, so no-one can help me much...
I was reading through the specifications available at the ONVIF webpage but I don't really get it. I know I have to use SOAP, C (I was asked to do the app in C), XML and web services. That much I understand but I don't know how am I supposed to use them. I'm not here so that you can do the work for me (that ain't fun) I just would like to know if someone here could guide me a little about what to start learning and in which order. If there's something I forgot to explain I'll add it as soon as I can.

So, you have to start with gSOAP.
Pelco has a guide to get started with gSOAP, it is for windows but it is valid for Linux as well. As you start learning gSOAP, check the last FAQ of gSOAP about the namespaces.
Finally, on the ONVIF website there's an Application Programmers Guide, which is old but still interesting. ONVIF has a forum for all people willing to learn the protocol. It does not require you to be member to access it, you can join it for free and check all the questions there.

A good approach is to study existing code from open source projects. A few of them can be found from an ONVIF challenge top 10 list. Also from the top 7 ONVIF open source projects. Especially it looks the following ones should be a good starting points:
An ONVIF Service Server - onvif_srvd which runs on a linux machine so that your RTSP cameras will be discoverable by other ONVIF tools or clients.
An ONVIF server for PI that turns a webcam into an IP Camera.
An ONVIF client with GUI built-in.

Related

Issues with VICE

I have recently started using VICE, specifically x64sc, and I was thinking of coding a game for it. However, I know almost nothing about what I want to do, and the manual isn't very helpful either. Some issues are particularly hard to overcome, and so far I can't find any solution
How do I copy files from a 1541 to an FD-4000? I was going to compile multiple basic extensions together to create a sort of all-in-one extension, but I don't know how to do that either.
How do I replace the kernal ROMs? My intention with this is to implement a fastloader that will work with a virtual FD-4000.
How do I get a virtual FD-4000 to work in VICE?
How do the tape images work? So far I haven't been able to find a conclusive answer.
I have downloaded some basic extensions, but I am not sure whether they are all compatible with the C64. As such, I would like to know information about the following programs, primarily if they are compatible.
apsoft-64
basic lightning v1.2
basic4.0
Basic expansion 4.5
c64 basic v3.5
DotBASIC
Game BASIC
Graphics basic
laser basic
metabasic
metabasic plus
modem basic v1.2
northcastle structured basic v1.7
tape master pro 2
ultra basic
Please let me know is there is a more appropriate place to post this.

embedding a headless browser in C

Is any of env-js, phantom JS, slimmerJS or any of the headless browsers embeddable in a C application? This is what I need to do: I have a C application that connects to a couple of servers through HTTP & HTTPS. Up until now, I got every page, figured out what it did, (mainly Javascript), extracted the parts of code that I needed (I also implemented a very simple string parser/extracter) and implemented the flow by sending the HTML code through a (secure)Socket and reading back the response. That part still works smoothly.
That was until I bumped into a set of very complex (read: obfuscated and looong) javascript pages linked one after the other, with several scripts included, and server side programming, and then I realized that I wouldn't be able to get a "maintainable" program with the procedure I've taken.
So I have spent the last several days looking for an embeddable Javascript interpreter. Bumped into spider monkey which is embeddable in C, but since I don't have any control over the scripts received, its lack of the DOM implementation makes it unsuitable. I also considered implementing the DOM interface, but honestly is a way too long distraction from my main proyect.
Then I considered the headless browsers mentioned above. Have read all the information I found about them, looked for some sort of library to interface with them, and in abscence of such librarys, have considedered hacking the code, only to realize that even trying to hack phantomJS to embedded it in my C system would be even crazier than implementing the DOM interface in spider monkey.
The system currently works in Windows and I'm using MinGW to develop it, but its final target is to be implemented in a Raspberry PI, so the more I can have plain straight C source code, the easier it will be to move the system to its final destination. With this I mean: I can use windows libraries in the meantime if they are pre-built, but can't miss the need that they must be compilable and generated in a plain compiler. I don't have yet the Raspberry PI, but I'm not expecting any fancy development tool set (I might be wrong on this)
Lastly, for the curious inside, the system is a stock screener, generates graphics with indicators which are put in a web server and generates alerts (to send notifications of price conditions) through Yahoo Messenger (this choice was mainly due to portability and availability of source code).
I will really appreciate your help in find a way to implement/embed in C *any* Javascript interpreter that has a DOM interface implemented.
Regards.
Alfredo Meraz

Writing Windows Port Monitor Basics

I'm trying to find a basic example, tutorial, or blog post on how to write a printer port monitor. I downloaded the Windows DDK and dug through localmon, but it appears that this sample is much more complex than just the nuts and bolts basics and from my understanding it is a bit different than an OEM port monitor because of how it handles the registry key and port enumeration. Does anyone know of a blog post, tutorial, or even book that walks the reader through the basic code to get one up and going? I've found a few links talking about the conceptual stuff, but nothing that is hands on code.
I can recomend http://www.codeproject.com/KB/printing/wpa.aspx, which describes how to write a printer driver and also has good hints about what's necessary to build a port monitor.
But my opinion is that a good tutorial in this area is not available on the Internet (I would be glad to find somebody who can show me that I'm wrong). So, when I had to deal with this task I was forced to do it the hard way: I've read carefully the MSDN explanations starting from this point: http://msdn.microsoft.com/en-us/library/ff561109.aspx. In parallel with reading MSDN I also checked the code in DDK you mentioned and try to understand it. I'm sure this solution could also work for you.
I wrote mine from the specs, there aren't really that many API's to implement.
The one thing that regularaly trips people up is EnumPorts, the spooler allocates enough memory for ALL the ports, not just yours. So you need to make sure you fill any strings from the end of the spoolers buffer, don't put them straight after your structures.
It doesn't say so in the specs but you can safely put the UI and Server functions in the same DLL.
It's also possible to create a single port monitor that supports NT and the later Windows 2000 type port monitors.
The code in RedMon is much easier to read than the localmon example, it's worth looking at before you start. It's quite nice because you can compile it in VS, you don't need to use the DDK to build it.
I have been over that exact same territory for a serial printer. About the best example I found was this article in Dr Dobbs Journal. The good part is that both a serial port driver and the user-space control program are covered and the project can also be used as an example of how to set up Visual Studio to compile a driver. This is also something a little difficult to find information about. The article discusses an old NT style driver, which worked well for me on XP.
There are quite a few good articles on CodeProject about writing drivers and programs to interact with them. They include source code and most deal with the newer WDM and WDF style drivers.
OSROnline is another good source, especially for discussion of specific issues and common mistakes. They also have some great utilities you will need.
Some of the most clearly written and understandable driver code I came across was Mark Russinovich's sample code. Although Microsoft withdrew all of the source when they purchased Sysinternals, some of the best examples can still be found cached here and there.
Drivers are pretty interesting. Whatever else you do though, do it in a virtual machine. Really.

Coding a website in C?

I was just reading the http://www.meebo.com/ About Us page, and read this line :
"plus, we're one of the few still around using C!"
Considering that meebo is an online chat client, how do they work with C? How can they use C for the backend? How does it interact with the frontend? For example, let's say a user creates a new account, and new directory is to be made, how does the information go from the front end to the back end?
I'm sorry if it's an invalid question.
Thank you
Edit 1: The Intro Tutorial to CGI was great. Any good books I can pick up from my library regarding this?
Thanks a lot for the quick response guys!
I don't know how meebo does it, but given that it's chat software they probably have a custom server written in C to handle the actual message traffic.
However, Apache and most other HTTP servers have always been able to call C programs just as they can call PHP, CGI and other languages for certain requests. Some websites are even written in Lisp.
The backend has to be compiled each time, unlike an interpreted language, but that happens at rollout and is part of the build/production scripts.
The permissions given and user account that the C program runs under must be carefully chosen, and of course a C website suffers from the same issues any other C program can fall for, such as buffer overrun, segfault, stackoverflow, etc. As long as you run it with reduced permissions you are better protected, and it's no worse than any other language/platform/architecture.
For servers, however, it's still used widely - the gold standard, I suppose. You can find plenty of servers written in Java, C++, and every other language, but C just seems to stick around.
-Adam
I've rolled non-blocking HTTP 1.1 servers in as little as 50 lines of code (sparse) or a few hundred (better), up to about 5k (safe). The servers would load dynamic shared objects as modules to handle specific kinds of requests.
The parent code would handle connection tracking, keep alives, GET/POST/HEAD requests and feed them off to handlers that were loaded on start up. I did this when I was working with VERY little elbow room on embedded devices that had to have some kind of web based control panel .. specifically a device that controlled power outlets.
The entry point to each DSO was defined by the URL and method used (i.e. /foo behaved differently depending on the type of request it was serving).
My little server did quite well, could handle about 150 clients without forks or threads and even had a nice little template system so the UI folks could modify pages without needing hand-holding.
I would most decidedly not use this kind of setup on any kind of production site, even your basic hello world home page with a guest book.
Now, if all I have to do is listen on port 80/443, accept requests with a small POST payload, sanitize them and forward them along to other clients ... its a little different.But that's a task specific server that pretends to be a web server, its not using C to generate dynamic pages.
Meebo uses a custom Lighttpd module called mod_meebo. It doesn't fully answer your question, but I thought you might be interested.
A lot of server-side programs can be done in C, not to mention CGI programming. They could also be Using C with MySQL, which is very possible. But without access to their source code, we have no way of knowing just how much C they are using.
Claiming that they are "one of the few around still using C" was probably just a joke. With stats like this at least I would hope so.
-John
You can see a good example of a web site in C with source code: fossil.
It uses SQLite for the back end.

FastCGI on Windows and Lighttpd

I'm looking to make my CGI forum software FastCGI compatible.
The forum software consists of a few dlls and .exe (.cgi) files written in C and x86 assembly language. I also have a SQlite3 database.
Lighttpd runs all these cgi scripts as child processes and I much say that the whole thing works pretty damn well.
But I want to experiment with FastCGI. However, the examples are poor, the documentation is poor, and it really looks like it's made for Linux in mind. Did someone get FastCGI working on Windows? If someone has a code example around, and the lighttpd configuration lines, I would be really grateful.
i've done some work with fastcgi on windows. bottom line is its not a lot of fun - you are 100% correct that there aren't a lot of sample and it the documentation is poor. but, the developer who i was helping on this was in contact with the guys who write iis and the fastcgi spec and was able to get his software to work. some changes are in the works to help. here is a link to some information:
http://blogs.iis.net/ksingla/archive/2009/04/20/fastcgi-isapi-1-5-beta-for-winxp-and-win2k3.aspx
i should add that the guy i was working with had so many problems with libfcgi.dll that he ended up rewriting it (see the reference to libfcgi2.dll in the article linked above.)
best regards,
don

Resources