videoio.h

Go to the documentation of this file.
00001 /*
00002  * videoio.h
00003  *
00004  * Classes to support streaming video input (grabbing) and output.
00005  *
00006  * Portable Windows Library
00007  *
00008  * Copyright (c) 1993-2000 Equivalence Pty. Ltd.
00009  *
00010  * The contents of this file are subject to the Mozilla Public License
00011  * Version 1.0 (the "License"); you may not use this file except in
00012  * compliance with the License. You may obtain a copy of the License at
00013  * http://www.mozilla.org/MPL/
00014  *
00015  * Software distributed under the License is distributed on an "AS IS"
00016  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
00017  * the License for the specific language governing rights and limitations
00018  * under the License.
00019  *
00020  * The Original Code is Portable Windows Library.
00021  *
00022  * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
00023  *
00024  * Contributor(s): Mark Cooke (mpc@star.sr.bham.ac.uk)
00025  *
00026  * $Log: videoio.h,v $
00027  * Revision 1.59  2007/09/26 03:43:09  rjongbloed
00028  * Added ability to get last position of window video output device.
00029  *
00030  * Revision 1.58  2007/05/19 09:33:29  rjongbloed
00031  * Fixed compiler warnings.
00032  *
00033  * Revision 1.57  2007/05/16 07:54:21  csoutheren
00034  * Fix problems created by gcc 4.2.0
00035  *
00036  * Revision 1.56  2007/05/01 21:13:46  dsandras
00037  * Added extra variables to store the number of frames received.
00038  *
00039  * Revision 1.55  2007/04/20 06:53:06  csoutheren
00040  * Fix problem with precompiled headers
00041  *
00042  * Revision 1.54  2007/04/20 06:47:02  csoutheren
00043  * Really disable video code when video is turned off
00044  *
00045  * Revision 1.53  2007/04/16 01:59:48  rjongbloed
00046  * Added function to video info class to parse standard size strings
00047  *   to width/height, eg "CIF", "QCIF", "VGA" etc
00048  *
00049  * Revision 1.52  2007/04/13 23:15:19  shorne
00050  * added backward compatible SetFrameSizeConverter
00051  *
00052  * Revision 1.51  2007/04/13 07:13:13  rjongbloed
00053  * Major update of video subsystem:
00054  *   Abstracted video frame info (width, height etc) into separate class.
00055  *   Changed devices, converter and video file to use above.
00056  *   Enhanced video file hint detection for frame rate and more
00057  *     flexible formats.
00058  *   Fixed issue if need to convert both colour format and size, had to do
00059  *     colour format first or it didn't convert size.
00060  *   Win32 video output device can be selected by "MSWIN" alone.
00061  *
00062  * Revision 1.50  2007/04/05 01:53:00  rjongbloed
00063  * Changed PVideoOutputDevice::CreateDeviceByName() to include driverName parameter so symmetric with PVideoInputDevice.
00064  *
00065  * Revision 1.49  2007/04/03 12:09:38  rjongbloed
00066  * Fixed various "file video device" issues:
00067  *   Remove filename from PVideoDevice::OpenArgs (use deviceName)
00068  *   Added driverName to PVideoDevice::OpenArgs (so can select YUVFile)
00069  *   Added new statics to create correct video input/output device object
00070  *     given a PVideoDevice::OpenArgs structure.
00071  *   Fixed begin able to write to YUVFile when YUV420P colour format
00072  *     is not actually selected.
00073  *   Fixed truncating output video file if overwriting.
00074  *
00075  * Revision 1.48  2006/10/31 04:10:40  csoutheren
00076  * Make sure PVidFileDev class is loaded, and make it work with OPAL
00077  *
00078  * Revision 1.47  2006/10/25 11:04:38  shorne
00079  * fix for devices having same name for different drivers.
00080  *
00081  * Revision 1.46  2006/06/21 05:38:58  csoutheren
00082  * Fixed plugin compile for latest pwlib
00083  *
00084  * Revision 1.45  2006/06/21 03:28:41  csoutheren
00085  * Various cleanups thanks for Frederic Heem
00086  *
00087  * Revision 1.44  2006/03/17 06:56:22  csoutheren
00088  * Exposed video fonts to external access
00089  *
00090  * Revision 1.43  2005/11/25 03:43:47  csoutheren
00091  * Fixed function argument comments to be compatible with Doxygen
00092  *
00093  * Revision 1.42  2005/08/09 09:08:09  rjongbloed
00094  * Merged new video code from branch back to the trunk.
00095  *
00096  * Revision 1.41.4.1  2005/07/17 09:27:04  rjongbloed
00097  * Major revisions of the PWLib video subsystem including:
00098  *   removal of F suffix on colour formats for vertical flipping, all done with existing bool
00099  *   working through use of RGB and BGR formats so now consistent
00100  *   cleaning up the plug in system to use virtuals instead of pointers to functions.
00101  *   rewrite of SDL to be a plug in compatible video output device.
00102  *   extensive enhancement of video test program
00103  *
00104  * Revision 1.41  2005/01/04 07:44:03  csoutheren
00105  * More changes to implement the new configuration methodology, and also to
00106  * attack the global static problem
00107  *
00108  * Revision 1.40  2004/04/18 12:49:22  csoutheren
00109  * Patches to video code thanks to Guilhem Tardy (hope I get it right this time :)
00110  *
00111  * Revision 1.39  2004/01/18 14:23:30  dereksmithies
00112  * Add new function to make opening of video input devices easier.
00113  *
00114  * Revision 1.38  2004/01/02 23:30:18  rjongbloed
00115  * Removed extraneous static function for getting input device names that has been deprecated during the plug ins addition.
00116  *
00117  * Revision 1.37  2003/12/14 10:01:02  rjongbloed
00118  * Resolved issue with name space conflict os static and virtual forms of GetDeviceNames() function.
00119  *
00120  * Revision 1.36  2003/12/03 03:47:56  dereksmithies
00121  * Add fix so video output devices compile and run correctly.
00122  * Thanks to Craig Southeren.
00123  *
00124  * Revision 1.35  2003/11/19 04:29:02  csoutheren
00125  * Changed to support video output plugins
00126  *
00127  * Revision 1.34  2003/11/18 10:39:06  csoutheren
00128  * Fixed warnings regarding calling virtual Close in destructors
00129  *
00130  * Revision 1.33  2003/11/18 06:46:15  csoutheren
00131  * Changed to support video input plugins
00132  *
00133  * Revision 1.32  2003/09/17 05:41:59  csoutheren
00134  * Removed recursive includes
00135  *
00136  * Revision 1.31  2003/09/17 01:18:02  csoutheren
00137  * Removed recursive include file system and removed all references
00138  * to deprecated coooperative threading support
00139  *
00140  * Revision 1.30  2003/03/17 08:10:00  robertj
00141  * Fixed GNU warning
00142  *
00143  * Revision 1.29  2003/03/17 07:51:07  robertj
00144  * Added OpenFull() function to open with all video parameters in one go.
00145  * Made sure vflip variable is set in converter even if converter has not
00146  *   been set yet, should not depend on the order of functions!
00147  * Removed canCaptureVideo variable as this is really a virtual function to
00148  *   distinguish PVideoOutputDevice from PVideoInputDevice, it is not dynamic.
00149  * Made significant enhancements to PVideoOutputDevice class.
00150  * Added PVideoOutputDevice descendants for NULL and PPM files.
00151  *
00152  * Revision 1.28  2002/09/16 01:08:59  robertj
00153  * Added #define so can select if #pragma interface/implementation is used on
00154  *   platform basis (eg MacOS) rather than compiler, thanks Robert Monaghan.
00155  *
00156  * Revision 1.27  2002/04/12 08:25:12  robertj
00157  * Added text string output for tracing video format.
00158  *
00159  * Revision 1.26  2002/04/05 06:41:54  rogerh
00160  * Apply video changes from Damien Sandras <dsandras@seconix.com>.
00161  * The Video Channel and Format are no longer set in Open(). Instead
00162  * call the new SetVideoChannelFormat() method. This makes video capture
00163  * and GnomeMeeting more stable with certain Linux video capture devices.
00164  *
00165  * Revision 1.25  2002/02/20 02:37:26  dereks
00166  * Initial release of Firewire camera support for linux.
00167  * Many thanks to Ryutaroh Matsumoto <ryutaroh@rmatsumoto.org>.
00168  *
00169  * Revision 1.24  2002/01/16 07:51:06  robertj
00170  * MSVC compatibilty changes
00171  *
00172  * Revision 1.23  2002/01/16 03:51:20  dereks
00173  * Move flip methods in PVideoInputDevice  to  PVideoDevice
00174  *
00175  * Revision 1.22  2002/01/14 02:59:54  robertj
00176  * Added preferred colour format selection, thanks Walter Whitlock
00177  *
00178  * Revision 1.21  2002/01/04 04:11:45  dereks
00179  * Add video flip code from Walter Whitlock, which flips code at the grabber.
00180  *
00181  * Revision 1.20  2001/11/28 00:07:32  dereks
00182  * Locking added to PVideoChannel, allowing reader/writer to be changed mid call
00183  * Enabled adjustment of the video frame rate
00184  * New fictitous image, a blank grey area
00185  *
00186  * Revision 1.19  2001/08/06 06:12:45  rogerh
00187  * Fix comments
00188  *
00189  * Revision 1.18  2001/08/03 04:21:51  dereks
00190  * Add colour/size conversion for YUV422->YUV411P
00191  * Add Get/Set Brightness,Contrast,Hue,Colour for PVideoDevice,  and
00192  * Linux PVideoInputDevice.
00193  * Add lots of PTRACE statement for debugging colour conversion.
00194  * Add support for Sony Vaio laptop under linux. Requires 2.4.7 kernel.
00195  *
00196  * Revision 1.17  2001/05/22 23:38:45  robertj
00197  * Fixed bug in PVideoOutputDevice, removed redundent SetFrameSize.
00198  *
00199  * Revision 1.16  2001/05/22 12:49:32  robertj
00200  * Did some seriously wierd rewrite of platform headers to eliminate the
00201  *   stupid GNU compiler warning about braces not matching.
00202  *
00203  * Revision 1.15  2001/03/20 02:21:57  robertj
00204  * More enhancements from Mark Cooke
00205  *
00206  * Revision 1.14  2001/03/08 23:04:19  robertj
00207  * Fixed up some documentation.
00208  *
00209  * Revision 1.13  2001/03/08 08:31:34  robertj
00210  * Numerous enhancements to the video grabbing code including resizing
00211  *   infrastructure to converters. Thanks a LOT, Mark Cooke.
00212  *
00213  * Revision 1.12  2001/03/07 01:42:59  dereks
00214  * miscellaneous video fixes. Works on linux now. Add debug statements
00215  * (at PTRACE level of 1)
00216  *
00217  * Revision 1.11  2001/03/06 23:34:20  robertj
00218  * Added static function to get input device names.
00219  * Moved some inline virtuals to non-inline.
00220  *
00221  * Revision 1.10  2001/03/03 05:06:31  robertj
00222  * Major upgrade of video conversion and grabbing classes.
00223  *
00224  * Revision 1.9  2001/02/28 01:47:14  robertj
00225  * Removed function from ancestor and is not very useful, thanks Thorsten Westheider.
00226  *
00227  * Revision 1.8  2000/12/19 22:20:26  dereks
00228  * Add video channel classes to connect to the PwLib PVideoInputDevice class.
00229  * Add PFakeVideoInput class to generate test images for video.
00230  *
00231  * Revision 1.7  2000/11/09 00:20:38  robertj
00232  * Added qcif size constants
00233  *
00234  * Revision 1.6  2000/07/30 03:41:31  robertj
00235  * Added more colour formats to video device enum.
00236  *
00237  * Revision 1.5  2000/07/26 03:50:49  robertj
00238  * Added last error variable to video device.
00239  *
00240  * Revision 1.4  2000/07/26 02:13:46  robertj
00241  * Added some more "common" bounds checking to video device.
00242  *
00243  * Revision 1.3  2000/07/25 13:38:25  robertj
00244  * Added frame rate parameter to video frame grabber.
00245  *
00246  * Revision 1.2  2000/07/25 13:14:05  robertj
00247  * Got the video capture stuff going!
00248  *
00249  * Revision 1.1  2000/07/15 09:47:34  robertj
00250  * Added video I/O device classes.
00251  *
00252  */
00253 
00254 
00255 #ifndef _PVIDEOIO
00256 #define _PVIDEOIO
00257 
00258 #ifdef P_USE_PRAGMA
00259 #pragma interface
00260 #endif
00261 
00262 #ifndef _PTLIB_H
00263 #include <ptlib.h>
00264 #endif
00265 
00266 #if P_VIDEO
00267 
00268 #include <ptlib/plugin.h>
00269 #include <ptlib/pluginmgr.h>
00270 
00271 class PColourConverter;
00272 
00273 
00274 class PVideoFrameInfo : public PObject
00275 {
00276   PCLASSINFO(PVideoFrameInfo, PObject);
00277 
00278   public:
00279       PVideoFrameInfo();
00280 
00281     enum ResizeMode
00282     {
00283         eScale,
00284         eCropCentre,
00285         eCropTopLeft,
00286         eMaxResizeMode
00287     };
00288 
00289     enum StandardSizes {
00290       CIF16Width = 1408, CIF16Height = 1152,
00291       CIF4Width  = 704,  CIF4Height  = 576,
00292       CIFWidth   = 352,  CIFHeight   = 288,
00293       QCIFWidth  = 176,  QCIFHeight  = 144,
00294       SQCIFWidth = 144,  SQCIFHeight = 96,
00295     };
00296 
00302     virtual BOOL SetFrameSize(
00303       unsigned width,   
00304       unsigned height   
00305     );
00306 
00312     virtual BOOL GetFrameSize(
00313       unsigned & width,
00314       unsigned & height
00315     ) const;
00316 
00321     virtual unsigned GetFrameWidth() const;
00322 
00327     virtual unsigned GetFrameHeight() const;
00328 
00334     virtual BOOL SetFrameRate(
00335       unsigned rate  
00336     );
00337 
00342     virtual unsigned GetFrameRate() const;
00343 
00349     virtual BOOL SetColourFormat(
00350       const PString & colourFormat // New colour format for device.
00351     );
00352 
00357     virtual const PString & GetColourFormat() const;
00358 
00361     void SetResizeMode(
00362       ResizeMode mode
00363     ) { if (resizeMode < eMaxResizeMode) resizeMode = mode; }
00364 
00367     ResizeMode GetResizeMode() const { return resizeMode; }
00368 
00371     PINDEX CalculateFrameBytes() const { return CalculateFrameBytes(frameWidth, frameHeight, colourFormat); }
00372     static PINDEX CalculateFrameBytes(
00373       unsigned width,               
00374       unsigned height,              
00375       const PString & colourFormat  
00376     );
00377 
00380     static BOOL ParseSize(
00381       const PString & str,  
00382       unsigned & width,     
00383       unsigned & height     
00384     );
00385 
00386   protected:
00387     unsigned   frameWidth;
00388     unsigned   frameHeight;
00389     unsigned   frameRate;
00390     PString    colourFormat;
00391     ResizeMode resizeMode;
00392 };
00393 
00394 
00423 class PVideoDevice : public PVideoFrameInfo
00424 {
00425   PCLASSINFO(PVideoDevice, PVideoFrameInfo);
00426 
00427   protected:
00430     PVideoDevice();
00431 
00432 
00433   public:
00436     virtual ~PVideoDevice();
00437 
00438     enum VideoFormat {
00439       PAL,
00440       NTSC,
00441       SECAM,
00442       Auto,
00443       NumVideoFormats
00444     };
00445 
00448     const PString & GetDeviceName() const
00449       { return deviceName; }
00450 
00453     virtual PStringList GetDeviceNames() const = 0;
00454 
00455     struct OpenArgs {
00456       OpenArgs();
00457 
00458       PPluginManager * pluginMgr;
00459       PString     driverName;
00460       PString     deviceName;
00461       VideoFormat videoFormat;
00462       int         channelNumber;
00463       PString     colourFormat;
00464       bool        convertFormat;
00465       unsigned    rate;
00466       unsigned    width;
00467       unsigned    height;
00468       bool        convertSize;
00469       ResizeMode  resizeMode;
00470       bool        flip;
00471       int         brightness;
00472       int         whiteness;
00473       int         contrast;
00474       int         colour;
00475       int         hue;
00476     };
00477 
00480     virtual BOOL OpenFull(
00481       const OpenArgs & args,      
00482       BOOL startImmediate = TRUE  
00483     );
00484 
00487     virtual BOOL Open(
00488       const PString & deviceName,   
00489       BOOL startImmediate = TRUE    
00490     ) = 0;
00491 
00494     virtual BOOL IsOpen() = 0;
00495 
00498     virtual BOOL Close() = 0;
00499 
00502     virtual BOOL Start() = 0;
00503 
00506     virtual BOOL Stop() = 0;
00507 
00508 
00509 #if PTRACING
00510     friend ostream & operator<<(ostream &, VideoFormat);
00511 #endif
00512 
00518     virtual BOOL SetVideoFormat(
00519       VideoFormat videoFormat   
00520     );
00521 
00526     virtual VideoFormat GetVideoFormat() const;
00527 
00532     virtual int GetNumChannels();
00533 
00541     virtual BOOL SetChannel(
00542       int channelNumber  
00543     );
00544 
00549     virtual int GetChannel() const;
00550 
00557     virtual BOOL SetColourFormatConverter(
00558       const PString & colourFormat // New colour format for device.
00559     );
00560 
00564     virtual BOOL GetVFlipState();
00565 
00569     virtual BOOL SetVFlipState(
00570       BOOL newVFlipState    
00571     );
00572 
00578     virtual BOOL GetFrameSizeLimits(
00579       unsigned & minWidth,   
00580       unsigned & minHeight,  
00581       unsigned & maxWidth,   
00582       unsigned & maxHeight   
00583     ) ;
00584 
00585 
00591     virtual BOOL SetFrameSizeConverter(
00592       unsigned width,  
00593       unsigned height, 
00594       ResizeMode resizeMode = eMaxResizeMode 
00595     );
00596 
00602     virtual BOOL SetFrameSizeConverter(
00603       unsigned width,                   
00604       unsigned height,                  
00605           BOOL  /*bScaleNotCrop*/           
00606           )  { return SetFrameSizeConverter(width,height,eScale); }
00607 
00608 
00617     virtual BOOL SetFrameSize(
00618       unsigned width,   
00619       unsigned height   
00620     );
00621 
00627     virtual BOOL GetFrameSize(
00628       unsigned & width,
00629       unsigned & height
00630     ) const;
00631 
00637     virtual PINDEX GetMaxFrameBytes() = 0;
00638 
00639     
00642     int GetLastError() const { return lastError; }
00643 
00644 
00647     virtual BOOL CanCaptureVideo() const = 0;
00648 
00651     virtual int GetBrightness();
00652 
00655     virtual BOOL SetBrightness(unsigned newBrightness);
00656 
00657 
00660     virtual int GetWhiteness();
00661 
00664     virtual BOOL SetWhiteness(unsigned newWhiteness);
00665 
00666 
00669     virtual int GetColour();
00670 
00673     virtual BOOL SetColour(unsigned newColour);
00674 
00675 
00678     virtual int GetContrast();
00679 
00682     virtual BOOL SetContrast(unsigned newContrast);
00683 
00684 
00687     virtual int GetHue();
00688 
00691     virtual BOOL SetHue(unsigned newHue);
00692     
00693     
00696     virtual BOOL GetParameters(
00697       int *whiteness,
00698       int *brightness,
00699       int *colour,
00700       int *contrast,
00701       int *hue
00702     );
00703 
00704     
00707     virtual BOOL SetVideoChannelFormat (
00708       int channelNumber, 
00709       VideoFormat videoFormat
00710     );
00711 
00712 
00716     void SetPreferredColourFormat(const PString & colourFmt) { preferredColourFormat = colourFmt; }
00717 
00721     const PString & GetPreferredColourFormat() { return preferredColourFormat; }
00722     
00723     int GetNumberOfFrames () { return numberOfFrames; }
00724     
00725   protected:
00726     PINDEX GetMaxFrameBytesConverted(PINDEX rawFrameBytes) const;
00727 
00728     PString      deviceName;
00729     int          lastError;
00730     VideoFormat  videoFormat;
00731     int          channelNumber;
00732     // Preferred native colour format from video input device, empty == no preference
00733     PString      preferredColourFormat;
00734     BOOL         nativeVerticalFlip;
00735 
00736     PColourConverter * converter;
00737     PBYTEArray         frameStore;
00738 
00739     int          frameBrightness; // 16 bit entity, -1 is no value
00740     int          frameWhiteness;
00741     int          frameContrast;
00742     int          frameColour;
00743     int          frameHue;
00744     int          numberOfFrames;
00745 };
00746 
00747 
00750 class PVideoOutputDevice : public PVideoDevice
00751 {
00752   PCLASSINFO(PVideoOutputDevice, PVideoDevice);
00753 
00754   public:
00757     PVideoOutputDevice();
00758     
00761     virtual ~PVideoOutputDevice() { Close(); };      
00762 
00765     static PStringList GetDriverNames(
00766       PPluginManager * pluginMgr = NULL   
00767     );
00768 
00775     static PStringList GetDriversDeviceNames(
00776       const PString & driverName,         
00777       PPluginManager * pluginMgr = NULL   
00778     );
00779 
00782     static PVideoOutputDevice * CreateDevice(
00783       const PString & driverName,         
00784       PPluginManager * pluginMgr = NULL   
00785     );
00786 
00787     /* Create the matching video output device that corresponds to the device name.
00788 
00789        This is typically used with the return values from GetDriversDeviceNames().
00790      */
00791     static PVideoOutputDevice *CreateDeviceByName(
00792       const PString & deviceName,         
00793       const PString & driverName = PString::Empty(),  
00794       PPluginManager * pluginMgr = NULL   
00795     );
00796 
00802     static PVideoOutputDevice *CreateOpenedDevice(
00803       const PString & driverName,         
00804       const PString & deviceName,         
00805       BOOL startImmediate = TRUE,         
00806       PPluginManager * pluginMgr = NULL   
00807     );
00808 
00811     static PVideoOutputDevice *CreateOpenedDevice(
00812       const OpenArgs & args,              
00813       BOOL startImmediate = TRUE          
00814     );
00815 
00818     virtual BOOL Close() { return TRUE; }
00819 
00822     virtual BOOL Start() { return TRUE; }
00823 
00826     virtual BOOL Stop() { return TRUE; }
00827 
00830     virtual BOOL CanCaptureVideo() const;
00831 
00834     virtual BOOL SetFrameData(
00835       unsigned x,
00836       unsigned y,
00837       unsigned width,
00838       unsigned height,
00839       const BYTE * data,
00840       BOOL endFrame = TRUE
00841     ) = 0;
00842 
00849     virtual BOOL GetPosition(
00850       int & x,  // X position of device surface
00851       int & y   // Y position of device surface
00852     ) const;
00853 };
00854 
00855 
00858 class PVideoOutputDeviceRGB : public PVideoOutputDevice
00859 {
00860   PCLASSINFO(PVideoOutputDeviceRGB, PVideoOutputDevice);
00861 
00862   public:
00865     PVideoOutputDeviceRGB();
00866 
00877     virtual BOOL SetColourFormat(
00878       const PString & colourFormat // New colour format for device.
00879     );
00880 
00889     virtual BOOL SetFrameSize(
00890       unsigned width,   
00891       unsigned height   
00892     );
00893 
00899     virtual PINDEX GetMaxFrameBytes();
00900 
00903     virtual BOOL SetFrameData(
00904       unsigned x,
00905       unsigned y,
00906       unsigned width,
00907       unsigned height,
00908       const BYTE * data,
00909       BOOL endFrame = TRUE
00910     );
00911 
00914     virtual BOOL FrameComplete() = 0;
00915 
00916   protected:
00917     PMutex     mutex;
00918     PINDEX     bytesPerPixel;
00919     PINDEX     scanLineWidth;
00920     bool       swappedRedAndBlue;
00921 };
00922 
00923 
00924 #ifdef SHOULD_BE_MOVED_TO_PLUGIN
00925 
00928 class PVideoOutputDevicePPM : public PVideoOutputDeviceRGB
00929 {
00930   PCLASSINFO(PVideoOutputDevicePPM, PVideoOutputDeviceRGB);
00931 
00932   public:
00935     PVideoOutputDevicePPM();
00936 
00939     virtual BOOL Open(
00940       const PString & deviceName,   
00941       BOOL startImmediate = TRUE    
00942     );
00943 
00946     virtual BOOL IsOpen();
00947 
00950     virtual BOOL Close();
00951 
00954     virtual PStringList GetDeviceNames() const;
00955 
00958     virtual BOOL EndFrame();
00959 
00960   protected:
00961     unsigned   frameNumber;
00962 };
00963 
00964 #endif // SHOULD_BE_MOVED_TO_PLUGIN
00965 
00966 
00969 class PVideoInputDevice : public PVideoDevice
00970 {
00971   PCLASSINFO(PVideoInputDevice, PVideoDevice);
00972 
00973   public:
00976     //PVideoInputDevice();
00977 
00980     ~PVideoInputDevice() { Close(); }
00981 
00984     static PStringList GetDriverNames(
00985       PPluginManager * pluginMgr = NULL   
00986     );
00987 
00994     static PStringList GetDriversDeviceNames(
00995       const PString & driverName,         
00996       PPluginManager * pluginMgr = NULL   
00997     );
00998 
01001     static PVideoInputDevice *CreateDevice(
01002       const PString & driverName,         
01003       PPluginManager * pluginMgr = NULL   
01004     );
01005 
01006     /* Create the matching video input device that corresponds to the device name.
01007        So, for "fake" return a device that will generate fake video.
01008        For "Phillips 680 webcam" (eg) will return appropriate grabber.
01009        Note that Phillips will return the appropriate grabber also.
01010 
01011        This is typically used with the return values from GetDriversDeviceNames().
01012      */
01013     static PVideoInputDevice *CreateDeviceByName(
01014       const PString & deviceName,         
01015       const PString & driverName = PString::Empty(),  
01016       PPluginManager * pluginMgr = NULL   
01017     );
01018 
01024     static PVideoInputDevice *CreateOpenedDevice(
01025       const PString & driverName,         
01026       const PString & deviceName,         
01027       BOOL startImmediate = TRUE,         
01028       PPluginManager * pluginMgr = NULL   
01029     );
01030 
01033     static PVideoInputDevice *CreateOpenedDevice(
01034       const OpenArgs & args,              
01035       BOOL startImmediate = TRUE          
01036     );
01037 
01040     virtual BOOL Open(
01041       const PString & deviceName,   
01042       BOOL startImmediate = TRUE    
01043     ) = 0;
01044 
01045     virtual BOOL Close(
01046     ) { return TRUE; }
01047 
01050     virtual BOOL CanCaptureVideo() const;
01051  
01054     virtual BOOL IsCapturing() = 0;
01055 
01058     virtual BOOL GetFrame(
01059       PBYTEArray & frame
01060     );
01061 
01064     virtual BOOL GetFrameData(
01065       BYTE * buffer,                 
01066       PINDEX * bytesReturned = NULL  
01067     ) = 0;
01068 
01071     virtual BOOL GetFrameDataNoDelay(
01072       BYTE * buffer,                 
01073       PINDEX * bytesReturned = NULL  
01074     ) = 0;
01075 
01078     virtual BOOL TestAllFormats() = 0;
01079 };
01080 
01081 
01083 //
01084 // declare macros and structures needed for video input plugins
01085 //
01086 
01087 template <class className> class PVideoInputPluginServiceDescriptor : public PDevicePluginServiceDescriptor
01088 {
01089   public:
01090     virtual PObject *   CreateInstance(int /*userData*/) const { return new className; }
01091     virtual PStringList GetDeviceNames(int /*userData*/) const { return className::GetInputDeviceNames(); }
01092 };
01093 
01094 #define PCREATE_VIDINPUT_PLUGIN(name) \
01095   static PVideoInputPluginServiceDescriptor<PVideoInputDevice_##name> PVideoInputDevice_##name##_descriptor; \
01096   PCREATE_PLUGIN(name, PVideoInputDevice, &PVideoInputDevice_##name##_descriptor)
01097 
01099 //
01100 // declare macros and structures needed for video output plugins
01101 //
01102 
01103 template <class className> class PVideoOutputPluginServiceDescriptor : public PDevicePluginServiceDescriptor
01104 {
01105   public:
01106     virtual PObject *   CreateInstance(int /*userData*/) const { return new className; }
01107     virtual PStringList GetDeviceNames(int /*userData*/) const { return className::GetOutputDeviceNames(); }
01108 };
01109 
01110 #define PCREATE_VIDOUTPUT_PLUGIN(name) \
01111   static PVideoOutputPluginServiceDescriptor<PVideoOutputDevice_##name> PVideoOutputDevice_##name##_descriptor; \
01112   PCREATE_PLUGIN(name, PVideoOutputDevice, &PVideoOutputDevice_##name##_descriptor)
01113 
01115 //
01116 // declare classes needed for access to simple video font
01117 //
01118 
01119 class PVideoFont : public PObject
01120 {
01121   PCLASSINFO(PVideoFont, PObject);
01122   public:
01123     enum {
01124       MAX_L_HEIGHT = 11
01125     };
01126     struct LetterData {
01127       char ascii;
01128       const char *line[MAX_L_HEIGHT];
01129     };
01130 
01131     static const LetterData * GetLetterData(char ascii);
01132 };
01133 
01134 #endif // P_VIDEO
01135 
01136 #endif   // _PVIDEOIO
01137 
01138 // End Of File ///////////////////////////////////////////////////////////////

Generated on Fri Mar 7 06:25:03 2008 for PTLib by  doxygen 1.5.1