Motion - Netcam With FTP

Add capability to connect to FTP server as well as HTTP server

Description of Patch

At least one netcam (the Dlink-2000) does not allow fetching an image with the HTTP protocol, but does allow getting it with the FTP protocol. This patch adds a new source module (netcam_ftp.c) and enhances the existing netcam code to use it. The facility is activated by simply setting the configuration parameter "netcam_url" to be a URL starting with "ftp://".

The patch should be considered experimental at this time. It has very limited error handling capabilities at the moment, and in several places uses "blocking I/O", meaning that it can take a long time before timeout will occur. Also, there is no current facility for using a proxy server. On the other hand, it does provide a "proper" facility for fetching an ftp image. I shall continue working to improve the error recovery, but I hope than others can try it out and let me know of any other places which need to be enhanced.

I have attached a tarball containing replacement source files for netcam.c, netcam.h and Makefile.in (to allow the compilation of the new module netcam_ftp.c), and new source files netcam_ftp.c and netcam_ftp.h.

Installation of Patch

Download the attached file into the motion source directory and unpack it with
tar xzf netcam_ftp.tgz
Then re-build Motion and test the patch.

Note: you must re-run ./configure in order to generate a new Makefile which will include compiling the new source module netcam_ftp.c

Change History of Patch

  • 1.0 Initial revision

Discussion and Comments


Great work Bill.

I will consider integrating it in the next snap. I would like anyone having tested the patch to give feedback.

I am a bit hung up on work (the kind I am paid to do) including the weekend so I will wait a few days before you see this patch in a snap. But I 100% support the feature.

The implementation using ftp:// syntax is perfect. Intuitive and sensible.

-- KennethLavrsen - 24 Sep 2005

Integrated. Took me 8 hours to change all the camelCase to motion_code_standard and fix indentation. At tab setting 4 there was no indentation at all. I can see it must have been inherited from the nanoftp sources because the indentation so bad that many places even with tab setting 8 the indentation was either missing or completely wrong.

While doing the code editing I went through all the netcam code and changed the code lines that I found hard to read. Especially the lines that were broken into pieces to keep a 80 character line width. I think in 2005 we can expect all programmers to have at least 1024 pixel wide monitors - even on a labtop - so code lines round 100 is quite OK. I usually try to keep below 120 because that is 70% of the screen width on my 17" LCD monitor. And often I stay with 100-110 as maximum. Comments I try to keep shorter. But breaking at 80 makes the code so line-fragmented that it is hard to follow.

I also added some white spacing according to my personal taste where I felt it enhanced readability.

Make sure that further editing of the netcam files are done based on motion-3.2.4_snap4 or motion-20051010-051001 daily snap so my changes are not lost.

-- KennethLavrsen - 08 Oct 2005

Asbjørn Pettersen sent some code enhancements for this patch , look at NetcamWithFtpEnhancements.

-- AngelCarpintero - 24 Oct 2005
Topic revision: r8 - 20 Dec 2005, KennethLavrsen
Copyright © 1999-2017 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Please do not email Kenneth for support questions (read why). Use the Support Requests page or join the Mailing List.
This website only use harmless session cookies. See Cookie Policy for details. By using this website you accept the use of these cookies.