dmuVideo
Inherits from: dmuObj
#include "dmuVideo.h"
Overview
The dmuVideo class acts as a base class for video I/O in libdmu. This class handles functions that are associated with the
VL video server and a single VL video path. The path has one
source node and one drain node (man vlintro for more
information on VL nodes and paths). This object also maintains VL
control values such as frame size, zoom factor, packing mode,
etc.. Most of these controls can be set and queried using methods
outlined below. In the current implementation, these controls
values must be set before the video transfer begins. Later
versions should allow run-time control over these variables
This object handles the starting and stopping of the video transfer
along the path. The start method begins the transfer, and
destruction of the object ends the transfer. Later implementations
will allow the transfer to be interrupted and restarted while it is
running
Video objects should be created and used in the following manner:
Construct a video object - dmuVideo should never be
instantiated directly. Use a subclass like dmuVideoIn
Create the video path using the setup() method
Set any non-default control values (using set methods). For
example, the video size should be set to crop and/or zoom to a
texture-compatible size if the video will be used as a texture map.
Note - There are known problems with capturing video into
graphics-mode dmbuffers that are non-square in size. The best
parameters for texture mapping are: 512x512, with the video origin
set to 32.
Wire into standard dmu object chain (see Overview for details)
Start the video transfer using the start() method.
Handle events as discussed in the Overview section.
The dmuVideo object also maintains an open connection to the
video server. This connection is a static method for dmuVideo, and
is opened upon the first construction of a dmuVideo object (or any
object that inherits from the dmuVideo), and closed when all
dmuVideo objects are destroyed. The server is shared by all
dmuVideo objects in the same process. Users of any dmuVideo class do
not need to worry about opening or closing video server
connections.
See the source code for more info and implementation details.
Public Methods
- static int getTypeByName(const char *deviceName)
- dmuVideo()
Construct a dmuVideo object. The constructor initializes member
variables. If this is the first dmuVideo object opened, the
constructor opens a connection the video server for all dmuVideo
objects to use.
- ~dmuVideo()
Destructor. Cleans up the video path. If this is the last
dmuVideo object in the process, then it closes the connection to
the video server.
- int setup()
Create the video source and drain nodes, and a path connecting them.
this is a pure virtual function that is implemented by any class that
inherits from dmuVideo.
- virtual int init(dmuParams *params = NULL)
Setup the path - The method is purely virtual. It will set up
the video path for so the transfer can begin. This method also
allocates any DMbuffer pool which may be needed for the the video
transfer. The params variable is currently ignored.
Note that a calling init() will result in init() being called on
all of this object's children as well
- virtual int addSrcConstraints(DMparams *params)
If this class is acting as a destination for another object in a
chain, this method is used to notify the parent object (i.e. the
source object) of any constraints which the video path may have
on its source. These constraints are added to the params
parameter structure. This method is used to ensure that the
DMbuffers that the parent object sends to this object are in a
format that can be received and used propperly.
addSrcConstraints() is ususally called internally in the library
during the init() method, and is rarely, if ever, used by user
programs.
- int addDstConstraints(DMparams *params)
This method adds to the params structure, any constraints
that may be associated with the output of this object. Normally,
this method is called internal to the object to set up the
parameters of a DMbuffer pool which the object will use as a
drain. This can be useful for child objects (or dmu programs) to
obtain information about the constraints used in the creation of
the DMbuffer pool associated with an object that drains into
DMbuffers
- int start(int propagate = DMU_PROPAGATE)
Starts the video transfer and prepare to handle video events
and/or receive buffers. This must be called after the video
object is set up (setup()), initialized (init()),
and had all of it's control values set. In the current
implementation, once the transfer is started, the only way to
stop the transfer it to destroy the object.
- int getFD()
Gets the file descriptor associated with the video path. This
allows the user to use select(2) or poll(2) to
block on this file descriptor until there is a video event that
should be handled. See the Overview for details on the event
loop and handle events
- virtual int receive(DMbuffer inBuffer)
This is a purely virtual method that is called when the parent
object passes us a new DMbuffer. See the Overview section and
dmuObj pages for more information on how receive works.
- virtual int handleEvents(fd_set fdSet)
This method is called by a user program when it's ready for us to
handle an event associated with our video path. This is purely
virtual, and should be implemented by the inheriting class.
- int getBufferBytes(int *returnSize)
Return the size of a buffer which would be used for a single
video transfer (either a full frame, or a field, depending on the
capture mode). This is measured in bytes, not pixels as in
buffer dimensions.
Overview Object List Object Hierarchy
Sample Apps