1 /// \file CVVidCapture.h
2 /// \brief Video capture interface class
3 // Written by Michael Ellison
4 //-------------------------------------------------------------------------
5 //                      CodeVis's Free License
6 //                         www.codevis.com
7 //
8 // Copyright (c) 2003 by Michael Ellison (mike@codevis.com)
9 // All rights reserved.
10 //
11 // You may use this software in source and/or binary form, with or without
12 // modification, for commercial or non-commercial purposes, provided that
13 // you comply with the following conditions:
14 //
15 // * Redistributions of source code must retain the above copyright notice,
16 //   this list of conditions and the following disclaimer.
17 //
18 // * Redistributions of modified source must be clearly marked as modified,
19 //   and due notice must be placed in the modified source indicating the
20 //   type of modification(s) and the name(s) of the person(s) f
21 //   said modification(s).
22 //
23 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
29 // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
30 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
31 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
32 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 //
35 //---------------------------------------------------------------------------
36 // Modifications:
37 //
38 //---------------------------------------------------------------------------
39 //
40 /// \class CVVidCapture CVVidCapture.h
41 /// CVVidCapture provides the pure interface for derived video capture
42 /// classses, and also provides some basic functionality for all video
43 /// capture classes.
44 ///
45 /// You *must* derive a class from it, and cannot simply instantiate it.
46 ///
47 /// To use any CVVidCapture object, instantiated the desired derived type.
48 /// The ideal way to do this is to go through CVPlatform, like this:<BR>
49 /// <CODE>
50 ///   CVVidCapture* vidCap = CVPlatform::GetPlatform()->AcquireVideoCapture();
51 /// </CODE>
52 ///
53 /// Call Init() to to initialize the capture library as needed.
54 ///
55 /// Successful initialization, you can call EnumDevices() to enumerate
56 /// the available video capture devices.
57 ///
58 /// Once you've decided which capture device to use, call
59 /// Connect() with the desired device name to connect to it.  Now
60 /// you can read and modify any of the camera properties and
61 /// video modes.
62 ///
63 /// When you're ready to receive images, either call Grab() for a single-
64 /// shot grab, or setup a callback and call StartImageCap().
65 ///
66 /// If you are using Grab(), be sure to call CVImage::ReleaseImage()
67 /// on the grabbed image when done.
68 ///
69 /// If you are doing a continuous capture, then the images are automatically
70 /// released after the callback returns. However, if you want to keep the
71 /// image around (for example, to place it on a queue for later processing
72 /// outside of the callback), you may call CVImage::AddRef() on the image
73 /// and it will not be deleted. Just make sure to call CVImage::ReleaseImage()
74 /// later when done with that image.
75 ///
76 /// <i>Always check the incoming status code in the callbacks prior to
77 ///    attempting to access the data.  If the status code is a failed result,
78 ///    the data is not present!</i>
79 ///
80 /// Call Stop() to end a continuous capture. Do NOT call
81 /// Stop() from within a callback or it will deadlock.  You still need to
82 /// call Stop() when you're done to clean up even if you've aborted by
83 /// returning false from the callback.
84 ///
85 /// To clean up, call Disconnect() to disconnect from the device,
86 /// then Uninit().
87 ///
88 /// Make sure to delete the CVVidCapture object when done.  If you
89 /// used CVPlatform to create it, just call CVPlatform::Release() on the
90 /// CVVidCapture*, like this:
91 ///
92 /// <CODE>
93 ///    CVPlatform::GetPlatform()->Release(vidCap);
94 /// </CODE>
95 ///
96 /// $RCSfile: CVVidCapture.h,v $
97 /// $Date: 2004/03/01 18:31:06 $
98 /// $Revision: 1.7 $
99 /// $Author: mikeellison $
100 
101 #ifndef _CVVIDCAPTURE_H_
102 #define _CVVIDCAPTURE_H_
103 
104 #include "CVResVidCap.h"      // Result codes
105 #include "CVImage.h"          // Image base class
106 
107 /// Capture timeout for grabs in miliseconds (10000 = 10 sec)
108 const int kCVVidCapture_Timeout           = 10000;
109 const int kVIDCAP_MAX_DEV_NAME_LEN = 128;
110 
111 class CVVidCapture
112 {
113    //-------------------------------------------------------------------------
114    // Public definitions and callbacks
115    //
116    public:
117       /// CVVIDCAP_CALLBACK is the callback definition for continuous captures
118       /// using the image class.
119       ///
120       /// First, check the status code - if it's a successful status code,
121       /// (e.g. if CVSUCCESS(status) returns true), then the imagePtr is
122       /// valid. Otherwise, some sort of error has occurred -
123       /// most likely, the camera has been disconnected.
124       ///
125       /// imagePtr will be the captured image in the format type requested
126       /// when the capture was started.  It will be released by CVVidCapture
127       /// when the callback returns - however, you may call AddRef() to
128       /// add a reference to the image and keep it around outside of the
129       /// callback if you want - just make sure to free it when done and
130       /// be aware of memory limitations vs. number of frames captured.
131       ///
132       /// Returning true continues the capture, returning false aborts it.
133       /// You'll still have to call CVVidCapture::Stop() from another
134       /// thread (e.g. outside the callback), but no more callbacks will
135       /// be received after an abort and the processing will halt.
136       ///
137       /// Do NOT call Stop() from within a callback or it will cause
138       /// a deadlock. Instead, return false from the callback to
139       /// cause an abort, then call Stop() from your main thread.
140       ///
141       /// \param status - Status of the capture
142       ///                (CVRES_VIDCAP_OK, CVRES_VIDCAP_CAPTURE_ERROR)
143       /// \param imagePtr - ptr to image containing current frame of status
144       ///                   is CVRES_VIDCAP_OK
145       /// \param userParam - user defined value (suggested: this*)
146       ///
147       /// \return bool - true continues capture, false halts it.
148       /// \sa StartImageCap()
149       typedef bool (*CVVIDCAP_CALLBACK)(  CVRES          status,
150                                           CVImage*       imagePtr,
151                                           void*          userParam   );
152 
153       /// CAMERA_PROPERTY contains the identifiers for camera settings
154       /// that we can control.
155       /// These match up with DirectShow's VideoProcAmpProperty enum.
156       ///
157       /// Used with CVVidCapture::GetPropertyInfo(),
158       /// CVVidCapture::SetProperty(), and CVVidCapture::GetPropertyName().
159       ///
160       /// Later we may want to use these on other platforms,
161       /// so duplicating it here for now. If you add or remove properties,
162       /// look for usage of CAMERAPROP_NUMPROPS in child classes and modify
163       /// as needed.
164       ///
165       /// Also make sure to update kCVVidCapture_Prop_Names at the end
166       /// of the file when changing this.
167       /// \sa GetPropertyInfo(), SetProperty(), GetPropertyName()
168       ///
169       enum CAMERA_PROPERTY
170       {
171          CAMERAPROP_BRIGHT       = 0,
172          CAMERAPROP_CONTRAST,
173          CAMERAPROP_HUE,
174          CAMERAPROP_SAT,
175          CAMERAPROP_SHARP,
176          CAMERAPROP_GAMMA,
177          CAMERAPROP_COLOR,
178          CAMERAPROP_WHITEBALANCE,
179          CAMERAPROP_BACKLIGHT,
180          CAMERAPROP_GAIN,
181          CAMERAPROP_NUMPROPS
182       };
183 
184       /// VIDCAP_MODE contains the video mode information for selecting
185       /// with CVVidCapture::SetMode(), CVVidCapture::GetModeInfo(), etc.
186       ///
187       /// Available video modes are stored as a linked list.  The InternalRef
188       /// void* is implementation specific - under DirectShow it's used to
189       /// store an AM_MEDIA_TYPE*.
190       ///
191       /// \sa GetNumSupportedModes(), GetModeInfo(), GetCurrentMode(), SetMode()
192       ///
193       struct VIDCAP_MODE
194       {
195          /// X resolution in pixels.
196          int      XRes;
197          /// Y resolution in pixels.
198          int      YRes;
199 
200          /// Estimated frame rate - may not be accurate!
201          int      EstFrameRate;
202 
203          /// Video format (unimportant to us, really, but differentiates between various types)
204          VIDCAP_FORMAT  InputFormat;
205 
206          /// Internal reference information used by child classes.
207          void*    InternalRef;
208 
209          /// Pointer to next mode in list.
210          struct VIDCAP_MODE*  NextMode;
211       };
212 
213       struct VIDCAP_DEVICE
214       {
215          char*    DeviceString;              // Device string
216          void*    DeviceExtra;               // Used for IMoniker's on DSWin32
217          struct   VIDCAP_DEVICE* NextDevice; // Ptr to next device, or null
218       };
219 
220    //-------------------------------------------------------------------------
221    // Internal definitions - protected
222    //
223    protected:
224       /// VIDCAP_STATES enumerates the states the video capture may be in or
225       /// was previously in before being stopped.
226       ///
227       /// Right now this is used to know when we need to reconfigure
228       /// the capture driver for buffering.
229       ///
230       enum VIDCAP_STATES
231       {
232          VIDCAP_UNCONNECTED,
233          VIDCAP_SINGLE_SHOT_MODE,
234          VIDCAP_CONTINUOUS_MODE
235       };
236 
237       /// VIDCAP_PROCAMP_PROPS contains the camera property information
238       /// for a specific property (e.g. Brightness, Contrast, etc).
239       ///
240       /// This mostly mirrors the info returned by DirectShow's
241       /// IAMVideoProcAmp::GetRange for controllable camera properties.
242       /// We'll use the same model on other platforms later though.
243       ///
244       /// \sa GetPropertyInfo(), SetProperty(), GetPropertyName(),
245       /// \sa CAMERA_PROPERTY
246       ///
247       struct VIDCAP_PROCAMP_PROPS
248       {
249          /// Is this property supported?
250          bool Supported;
251          /// Property ID
252          long Property;
253          /// Min value of property
254          long Min;
255          /// Max value of property
256          long Max;
257          /// Minimum Step size between values
258          long SteppingDelta;
259          /// Default value of property
260          long Default;
261          /// 1 = automatically controlled by driver, 2 = manually controlled
262          long CapsFlags;
263       };
264 
265    //-------------------------------------------------------------------------
266    // Public interface - overrideables
267    //
268    public:
269       CVVidCapture               (     );
270       virtual ~CVVidCapture      (     );
271 
272       //---------------------------------------------------------------------
273       // Override functions - you *must* implement these in child classes!
274       //---------------------------------------------------------------------
275 
276       /// Init must be called first before any other operations.
277       /// Init() must set the fInitialized member to true on success.
278       ///
279       /// \return CVRES result code.
280       /// \sa CVRes.h, CVResVidCap.h, CVVidCapture::Uninit()
281       virtual CVRES Init         (     )  =  0;
282 
283 
284       /// ClearDeviceList() clears the list of available devices, if any.
285       /// Some platforms may need to override this for cleanup if they
286       /// store extra info in the VIDCAP_DEVICE struct.
287       virtual void ClearDeviceList();
288 
289       /// RefreshDeviceList() refreshes the list of devices
290       /// available to VidCapture.
291       ///
292       /// \return CVRES result code
293       virtual CVRES RefreshDeviceList() = 0;
294 
295       /// GetNumDevices() returns the number of devices available.
296       ///
297       /// The device list is build on Init(), and can be refreshed
298       /// by calling RefreshDeviceList().  It is recommended that
299       /// RefreshDeviceList() be called each time you enumerate
300       /// through the devices, as devices may be added or removed.
301       ///
302       /// \param numDevices - set to total number of available devices
303       ///
304       /// \return CVRES result code
305       /// \sa RefreshDeviceList()
306       /// \sa CVRes.h, CVResVidCap.h
307       virtual CVRES  GetNumDevices( int& numDevices);
308 
309       /// GetDeviceInfo() retrieves the video capture device info for a specified
310       /// index from the enumeration.
311       ///
312       /// You must have called Init() previously. If it has been some time since
313       /// calling init, refresh the device list with RefreshDeviceList() prior
314       /// to getting the number of devices and device info.
315       ///
316       /// \param index - index into device list to retrieve information on.
317       /// \param deviceInfo - video capture device information. Set on return.
318       ///
319       /// \return CVRES result code
320       /// \sa VIDCAP_DEVICE, GetNumDevices(), RefreshDeviceList(), Connect()
321       /// \sa CVRes.h, CVResVidCap.h
322       virtual CVRES  GetDeviceInfo        (  int                  index,
323                                              VIDCAP_DEVICE&       deviceInfo);
324 
325       /// Connect() connects to a specific video capture device.
326       ///
327       /// Use the index given by GetNumDevices() and GetDeviceInfo().
328       //
329       /// Init() must be called prior to Connect().
330       /// Connect() must set fConnected to true on success.
331       ///
332       /// \param devIndex - Index of device in device list.
333       ///
334       /// \return CVRES result code.
335       /// \sa RefreshDeviceList(), GetNumDevices(), GetDeviceInfo()
336       /// \sa Init(), Disconnect(), CVRes.h, CVResVidCap.h
337       virtual CVRES Connect      (  int   devIndex ) = 0;
338 
339       /// StartImageCap() starts continuous image capture until Stop()
340       /// is called.
341       /// Both Init() and Connect() must have been successfully called prior
342       /// to calling StartImageCap().
343       ///
344       /// imageType specifies the image type to return.
345       /// callback must be a valid CVVIDCAP_CALLBACK callback, and is called
346       /// for each image.  Try not to do heavy processing within the callback.
347       ///
348       /// Must set fStarted to true on success.
349       /// Must also set fLastState to VIDCAP_CONTINUOUS_MODE
350       ///
351       /// \param imageType - type of image to send to callback for each frame
352       /// \param callback  - callback to be called on each frame
353       /// \param userParam - user defined value passed into callback
354       ///
355       /// \return CVRES result code.
356       /// \sa StartRawCap(), Grab(), Stop(), CVImage
357       /// \sa CVRes.h, CVResVidCap.h
358       virtual CVRES StartImageCap(  CVImage::CVIMAGE_TYPE   imageType,
359                                     CVVIDCAP_CALLBACK       callback,
360                                     void*                   userParam)  = 0;
361 
362 
363       /// Grab() is a single shot synchronous grab.
364       ///
365       /// Caller should pass an uninstantiated image ptr and the desired
366       /// image type.  imagePtr will be instantiated with the captured
367       /// image on success.
368       ///
369       /// Image must be deleted by caller when done by
370       /// calling CVImage::ReleaseImage().
371       ///
372       /// \param imageType - type of image to grab
373       /// \param imagePtr - uninstantiated image ptr. Set on return.
374       ///
375       /// \return CVRES result code.
376       /// \sa StartImageCap(), StartRawCap(), Stop(), CVImage
377       /// \sa CVRes.h, CVResVidCap.h
378       virtual CVRES Grab         (  CVImage::CVIMAGE_TYPE   imageType,
379                                     CVImage*&               imagePtr)   = 0;
380 
381       //---------------------------------------------------------------------
382       // Release functions - these should also be overridden by child classes
383       //---------------------------------------------------------------------
384 
385       /// Uninit object before deletion (matches with CVVidCapture::Init()).
386       /// Must set fInitialized to false on success.
387       ///
388       /// \return CVRES result code.
389       /// \sa Init(), CVRes.h, CVResVidCap.h
390       virtual CVRES Uninit       (     );
391 
392       /// Disconnect from a previously connected capture device.
393       /// Should only be called if a previous CVVidCapture::Connect() was
394       /// successful.
395       ///
396       /// Must set fConnected to false on success.
397       /// Must also set fLastState to VIDCAP_UNCONNECTED
398       ///
399       /// \return CVRES result code.
400       /// \sa Connect(), CVRes.h, CVResVidCap.h
401       virtual CVRES Disconnect   (     );
402 
403 
404       /// Stop() stops an active image capture started with StartImageCap().
405       /// (In derived classes, must stop other forms of continuous capture
406       ///  as well such as CVVidCaptureDSWin32::StartRawCap()).
407       ///
408       /// Do NOT call Stop() from within a callback or it will cause
409       /// a deadlock. Instead, return false from the callback to
410       /// cause an abort, then call Stop() from your main thread.
411       ///
412       /// Must set fStarted to false on success.
413       ///
414       /// \return CVRES result code.
415       /// \sa StartImageCapture(), CVVIDCAP_CALLBACK, CVRes.h, CVResVidCap.h
416       virtual CVRES Stop         (     );
417 
418       //---------------------------------------------------------------------
419       // Property settings for cameras.
420       //
421 
422 	  // David C. Partridge October 2016 - reinstate Show Property Dialog method.
423 	  virtual void ShowPropertyDialog(HWND parent) = 0;
424 
425 	  //
426       // These may or may not be supported on any given camera or capture
427       // implementation.
428       //
429       // If you receive CVRES_VIDCAP_PROPERTY_NOT_SUPPORTED, then your camera
430       // doesn't support the specified property.
431 
432       /// GetPropertyInfo retrieves information about a specific camera
433       /// property.
434       /// It may return CVRES_VIDCAP_PROPERTY_NOT_SUPPORTED if the
435       /// property is not support on the device or in the VidCapture
436       /// framework.
437       ///
438       /// All pointers may be NULL.
439       ///
440       /// You must have a device connected from a successful call to
441       /// Connect() to use this function.
442       ///
443       /// \param property - ID of property (e.g. CAMERAPROP_BRIGHT)
444       /// \param curVal   - ptr to receive current value of property.
445       /// \param defVal   - ptr to receive default value of property.
446       /// \param minVal   - ptr to receive minimum value of property.
447       /// \param maxVal   - ptr to receive maximum value of property.
448       /// \param step     - ptr to receive the minimum step distance
449       ///                   between values.
450       /// \return CVRES result code.
451       /// \sa Init(), Connect(), SetProperty(), GetPropertyName()
452       /// \sa CAMERA_PROPERTY, CVRes.h, CVResVidCap.h
453       virtual CVRES  GetPropertyInfo   (  CAMERA_PROPERTY         property,
454                                           long*                   curVal = 0,
455                                           long*                   defVal = 0,
456                                           long*                   minVal = 0,
457                                           long*                   maxVal = 0,
458                                           long*                   step   = 0);
459 
460       /// SetProperty() sets the specified property to the given value.
461       /// Use GetPropertyInfo() to get the supported range and resolution
462       /// of the property in use.
463       /// You must have a device connected from a successful call to
464       /// Connect() to use this function.
465       ///
466       /// \param property - ID of property.
467       /// \param value - new value to set property to. Must be within range.
468       /// \return CVRES result code
469       /// \sa Connect(), GetPropertyInfo(), GetPropertyName(), CAMERA_PROPERTY
470       /// \sa CVRes.h, CVResVidCap.h
471       virtual CVRES  SetProperty    (  CAMERA_PROPERTY            property,
472                                        long                       value);
473 
474 
475       /// GetPropertyName() retrieves the name of the specified property.
476       /// maxLength should be the maximum buffer length including a space for
477       /// a null - use kCVVidCapture_MaxPropNameLen+1 for your buffer size.
478       /// Name will be truncated to fit if necessary.
479       /// You must have a device connected from a successful call to
480       /// Connect() to use this function.
481       ///
482       /// \param property - ID of property to retrieve the name of.
483       /// \param nameBuffer - preallocated buffer to hold property name
484       /// \param maxLength - length of the buffer, sans the terminating null.
485       ///
486       /// \return CVRES result code
487       /// \sa GetPropertInfo(), SetProperty(), CAMERA_PROPERTY, Connect()
488       /// \sa CVRes.h, CVResVidCap.h
489       virtual CVRES  GetPropertyName(  CAMERA_PROPERTY            property,
490                                        char*                      nameBuffer,
491                                        int                        maxLength);
492 
493 
494       //---------------------------------------------------------------------
495       // Mode settings for cameras.
496       //
497       // These may or may not be supported on any given camera or capture
498       // implementation. During a Connect(), you enumerate the supported
499       // modes into fModeList.  Disconnect() should free this list.
500       //
501       // You'll should only need to override SetMode(VIDCAP_MODE&) and
502       // possibly the ClearModes() functions when supporting this feature.
503       //
504       // If you receive CVRES_VIDCAP_MODE_NOT_SUPPORTED, then your camera
505       // doesn't support the specified mode or modes at all.
506 
507       /// GetNumSupportedModes() retrieves the number of modes available
508       /// on the currently connected image capture device.
509       ///
510       /// You must have called Connect() already to enumerate the available
511       /// modes for the connected device before calling this function.
512       ///
513       /// \param numModes - set to total number of available modes on return
514       ///
515       /// \return CVRES result code
516       /// \sa VIDCAP_MODE, GetModeInfo(), SetMode(), GetCurrentMode()
517       /// \sa CVRes.h, CVResVidCap.h
518       virtual CVRES  GetNumSupportedModes (  int&                 numModes);
519 
520       /// GetModeInfo() retrieves the video capture mode for a specified
521       /// index from the enumeration.
522       /// You must have called Connect() already to enumerate the available
523       /// modes for the connected device before calling this function.
524       ///
525       /// \param index - index into mode list to retrieve information on.
526       /// \param modeInfo - video mode information. Set on return.
527       ///
528       /// \return CVRES result code
529       /// \sa VIDCAP_MODE, GetNumSupportedModes(), SetMode(), GetCurrentMode()
530       /// \sa CVRes.h, CVResVidCap.h
531       virtual CVRES  GetModeInfo          (  int                  index,
532                                              VIDCAP_MODE&         modeInfo);
533 
534       /// SetMode() sets the current capture mode to the one in the
535       /// mode list that matches the specified index.
536       /// You must have called Connect() already to enumerate the available
537       /// modes for the connected device before calling this function.
538       ///
539       /// \param index - index into mode list
540       /// \param rawYUY2 - PHD2 hack, do not convert to RGB
541       /// \return CVRES result code
542       /// \sa GetNumSupportedModes(), GetModeInfo(), GetCurrentMode()
543       /// \sa VIDCAP_MODE, CVRes.h, CVResVidCap.h
544       virtual CVRES  SetMode              (  int                  index,
545                                              bool                 rawYUY2 );
546 
547       /// GetCurrentMode() retrieves the current or last-used video
548       /// capture mode.
549       ///
550       /// You must have called Connect() already to enumerate the available
551       /// modes for the connected device before calling this function.
552       ///
553       /// \param curMode - set to current mode on return
554       /// \return CVRES result code
555       /// \sa GetNumSupportedModes(), GetModeInfo(), SetMode()
556       /// \sa VIDCAP_MODE, CVRes.h, CVResVidCap.h
557       virtual CVRES  GetCurrentMode       (  VIDCAP_MODE&         curMode );
558 
559 
560       /// GetFormatModeName() retrieves the video format mode name
561       /// from the enumeration value.
562       ///
563       /// \param format - video format of camera
564       /// \return const char* - ptr to const string describing video format
565       const char* GetFormatModeName( VIDCAP_FORMAT format);
566 
567       /// AddMode adds a video mode to the list
568       /// \param addMode - Video capture mode to add to internal list
569       /// \return CVRES result code
570       /// \sa GetNumSupportedModes(), GetModeInfo(), VIDCAP_MODE
571       /// \sa CVRes.h, CVResVidCap.h
572       virtual CVRES  AddMode              (  VIDCAP_MODE&         addMode );
573 
574       // ----------------------------------
575       // Override these in child classes!
576 
577       /// SetMode - sets the video mode for a connected camera.
578       ///           This version must be overridden in child classes.
579       /// You must have called Connect() already to enumerate the available
580       /// modes for the connected device before calling this function.
581       ///
582       /// \param newMode - new mode to use for connected device.
583       /// \param rawYUY2 - PHD2 hack, do not convert to RGB
584       /// \return CVRES result code
585       /// \sa GetNumSupportedModes(), GetModeInfo(), GetCurrentMode()
586       /// \sa VIDCAP_MODE, CVRes.h, CVResVidCap.h
587       virtual CVRES  SetMode              (  VIDCAP_MODE&         newMode,
588                                              bool                 rawYUY2 );
589 
590    //-------------------------------------------------------------------------
591    // Protected interface - overrideables
592    //
593    protected:
594       /// ClearModes() - clears the mode list.
595       /// You must have called Connect() already to enumerate the available
596       /// modes for the connected device before calling this function.
597       /// \sa GetNumSupportedModes(), GetModeInfo(), AddMode()
598       virtual void   ClearModes           (  );
599 
600    //---------------------------------------------------------------------
601    // Public status information functions
602    // These should not need to be overridden
603    //
604    public:
605 
606       /// GetDeviceName() retrieve the device name into a buffer/
607       /// The buffer must already be created.
608       ///
609       /// \param nameBuffer - buffer to copy device name into
610       /// \param maxLength - maximum length of the nameBuffer, set to
611       ///                    the length of the device name on return.
612       /// \return CVRES result code
613       /// \sa Connect(), EnumDevices(), CVRes.h, CVResVidCap.h
614       CVRES          GetDeviceName  (  char*                   nameBuffer,
615                                        int&                    maxLength );
616 
617       /// IsInitialized() returns true of the vidCapture class has been initialized.
618       /// \return bool - true if initialized, false if not.
619       /// \sa Init(), Uninit()
620       bool           IsInitialized();
621 
622       /// IsConnected() returns true if we've connected to a DirectShow
623       /// compatible capture device.
624       /// \return bool - true if connected, false if not.
625       /// \sa Connect(), Disconnect()
626       bool           IsConnected();
627 
628       /// IsStarted() returns true if we're currently doing a continuous grab.
629       /// \return bool - true if continuous capture has been started
630       /// \sa StartImageCap(), Stop()
631       bool           IsStarted();
632 
633    //---------------------------------------------------------------------
634    // Protected members
635    protected:
636       // Has the class been initialized?
637       bool           fInitialized;
638 
639       // Has a specific device been connected?
640       bool           fConnected;
641 
642       // Are we currently capturing?
643       bool           fStarted;
644 
645       // Device name of connected device (if fConnected == true)
646       char*          fDeviceName;
647 
648       // Current video mode
649       VIDCAP_MODE    fCurMode;
650       VIDCAP_MODE*   fModeList;
651       VIDCAP_DEVICE* fDeviceList;
652       int            fNumDevices;
653       // Previous video capture state
654       VIDCAP_STATES  fLastState;
655 };
656 
657 
658 /// Max property name table string length
659 extern const int kCVVidCapture_MaxPropNameLen;
660 /// Max length of a format name
661 extern const int kCVVidCapture_MaxFormatNameLen;
662 // Capture library version
663 extern const int kVIDCAPTURE_VERSION;
664 // Capture library copyright string
665 extern const char* kVIDCAPTURE_STRING;
666 
667 #endif // _CVVIDCAPTURE_H_
668 
669