[asterisk-dev] how to generate periodic wakeup signals for achannel driver ?

Sergio Garcia Murillo sergio.garcia at fontventa.com
Mon Sep 17 17:34:28 CDT 2007


----- Original Message ----- 
From: "Luigi Rizzo" <rizzo at icir.org>
To: <asterisk-dev at lists.digium.com>
Sent: Monday, September 17, 2007 10:03 PM
Subject: [asterisk-dev] how to generate periodic wakeup signals for achannel
driver ?


> sorry if the question is trivial...
>
> while adding videosupport to chan_oss/chan_alsa, which you can find at
>
>     http://svn.digium.com/view/asterisk/team/rizzo/video_v2/
>
> I just realised that the various video sources that I am using
> (webcam using the 'gspca' driver, or X11 grabber) do not support
> a select()/poll() interface, so i cannot rely on that (and on
> ast_channel_set_fd() ) to wakeup the channel driver when data
> is ready; I need a separate timing source.
>
> What are the options ? Right now I am [ab]using the audio source
> to poll the video source, but audio too is not always available.
>
> Maybe i should create a new thread, and a scheduler context
> with sched_context_create(), and then have a periodic
> event fire every 20-50ms to call the video handler ?
>
> Other ideas ?
>

Hi Luigi,

If you're using v4l you'll have to call VIDIOCSYNC ioctl to wait the
mmped memory to be filled with the video frame, it's blocking so you'll
have to to for the thread approach.
In v4l2 the select/poll model is supported:

V4L:
The VIDIOCMCAPTURE ioctl prepares a buffer for capturing. It also determines
the image format for this buffer. The ioctl returns immediately, eventually
with an EAGAIN error code if no video signal had been detected. When the
driver supports more than one buffer applications can call the ioctl
multiple times and thus have multiple outstanding capture requests.

The VIDIOCSYNC ioctl suspends execution until a particular buffer has been
filled.

V4L2:

Drivers maintain an incoming and outgoing queue. VIDIOC_QBUF enqueues any
empty buffer into the incoming queue. Filled buffers are dequeued from the
outgoing queue with the VIDIOC_DQBUF ioctl. To wait until filled buffers
become available this function, select() or poll() can be used. The
VIDIOC_STREAMON ioctl must be called once after enqueuing one or more
buffers to start capturing. Its counterpart VIDIOC_STREAMOFF stops capturing
and dequeues all buffers from both queues. Applications can query the signal
status, if known, with the VIDIOC_ENUMINPUT ioctl.



BR
Sergio




More information about the asterisk-dev mailing list