[Gambas-devel] gb.v4l update

Benoit Minisini gambas at ...1...
Fri Jul 1 23:42:52 CEST 2005


On Wednesday 29 June 2005 17:27, Daniel Campos wrote:
> Hi:
>
> I've finished all that I wanted for the v4l component: capture support,
> and support
> for a Tuner, so you can select the frequency on a TV card. So I've
> placed the
> stable release at:
>
> http://gambas.gnulinex.org/v4l
>
>  (gnulinex DNS is already up and running, so if you
> can not enter today, please wait a few hours).
>
> I changed some names to be more generic. The main class now is
> "VideoDev" instead
> of "WebCam". There are two virtual classes:
>
> - VideoDevTuner : to manage to frequencies
> - VideoDevFeatures: to get video device capabilities.
>
> Note that this component is just intended for capture, do not expect to
> show images at
> 1024x768 over a remote desktop and things like this :-)). However, one
> of the properties,
> "id", gives you the possibility of using the new API-Call capabilities
> of Gambas, if you
> want to perform special actions.
>
> I've updated the example, too.
>
> Benoît: even if this component is just for Linux (it is sure Windows has
> not a v4l interface,
> and I don't know about FreeBSD), it can be useful for a lot of people:
> some market applications,
> for example, use to allow to connect to a webcam so the owner of the
> store can view remotely if somebody
> is stealing (or sleeping :-)), and it is useful to show images on a web
> page, using a CGI, too.
> Do you plan to include it in the main sources?

Yes, of course!

But before I suggest... :-)

1) Renaming "VideoDev" to "VideoDevice"

2) Replacing the ToString() method by sort of "Data" property that returns a 
Byte[] array.

3) Make VideoDevice a stream, so that reading returns the image data.

4) When a method receives a file name as argument, you *must* use the 
GB.FileName() API to get it, and not use the string argument directly:

BEGIN_METHOD(save_me, GB_STRING path)
  char *filename = GB.FileName(STRING(path), LENGTH(path));
  ...
END_METHOD

Look at CIMAGE_save() in ./src/gb.qt/src/CImage.cpp if you need an example.

GB.FileName() converts the file name given by the user (in UTF-8) to the 
encoding used by the system (ISO8859-15 on my Mandrake).

If you don't that, file names including non-ASCII characters won't work!

5) Use the file extension to guess the file format, when the format argument 
is not specified in the Save method.

6) GB_PROPERTY_READ("Tuner",".VideoDevTuner",CWEBCAM_self) is not needed 
anymore. You can use: GB_PROPERTY_SELF("Tuner",".VideoDevTuner"), and then 
remove CWEBCAM_self.

7) Do not prefix constants when there is no ambiguity: NormPAL -> PAL,  
SourceCOMPOSITE -> Composite, and so on.

8) Replacing SelectSource() method by an integer property named Source, that 
combines Source and Norm arguments. Something like:

MyVideoDevice.Source = VideoDevice.PAL + VideoDevice.Composite

You may have to change the value of the constants to do that.

9) I have an article in french Linux magazine that explains how to capture 
image from IEEE 1394 device. But they use a specific API... Can v4l use IEEE 
1394 devices ?

10) Don't use GB.ReturnNewString("", 0); - berk! Just use GB.ReturnNull();

11) Instead of using GB.ReturnNewString(str, 0);, use 
GB.ReturnNewZeroString(str);

Regards,

-- 
Benoit Minisini
mailto:gambas at ...1...




More information about the Devel mailing list