CodeVis.com SourceForge.net Logo

CVVidCaptureDSWin32 Class Reference

#include <CVVidCaptureDSWin32.h>

Inheritance diagram for CVVidCaptureDSWin32:

CVVidCapture List of all members.

Detailed Description

CVVidCaptureDSWin32 provides the core interface to a DirectShow-based video capture device under Win32. It implements CVVidCapture and ISampleGrabberCB.

To use, first call Init() to initialize COM and set up the underlying capture graph.

After successful initialization, you can call GetNumDevices() and GetDeviceInfo() to enumerate the available video capture devices.

Once you've decided which capture device to use, call Connect() with the desired device index to connect to it. Now you can read and modify any of the camera properties and video modes.

When you're ready to receive images, either call Grab() for a single- shot grab, or setup a callback and call StartImageCap(). If you absolutely need speed over convenience and portability, you can use StartRawCap() and receive the video headers and bitmap information directly.

Always check the incoming status code in the callbacks prior to attempting to access the data. If the status code is a failed result, the data is not present!

Call Stop() to end a StartImageCap() continuous capture. Do NOT call Stop() from within a callback or it will deadlock. You still need to call Stop() when you're done to clean up even if you've aborted by returning false from the callback.

When you're done, call Disconnect(), then Uninit() to clean up.

COM Usage: CVVidCaptureDSWin32 currently calls CoInitializeEx in multithreaded mode. If you are already using COM, but need apartment model, change the Init() function as necessary.

Threading: Right now, it is recommended to use a single thread to access a single instantiation of the CVVidCaptureDSWin32 object. Otherwise, you should synchronize access via a mutex or critical section.

Callbacks will come from a DirectShow thread, so you'll need to synchronize on any resources you use from the callback. However, you shouldn't take too long inside a callback - I'd recommend just copying the data out and throwing it on a queue for later processing outside of the callback itself.

RCSfile
CVVidCaptureDSWin32.h,v
Date
2004/03/01 18:31:06
Revision
1.6
Author
mikeellison

Definition at line 108 of file CVVidCaptureDSWin32.h.

Public Types

  • typedef bool(* CVVIDCAP_ENUMDSWIN32CB )(const char *devName, IMoniker *moniker, void *userParam)
  • typedef bool(* CVVIDCAP_RAWCB )(CVRES status, const VIDEOINFOHEADER *vHeader, unsigned char *buffer, void *userParam)

Public Member Functions

Protected Member Functions

Private Member Functions

Static Private Member Functions

Private Attributes


Member Typedef Documentation

typedef bool(* CVVidCaptureDSWin32::CVVIDCAP_ENUMDSWIN32CB)( const char* devName, IMoniker* moniker, void* userParam )
 

CVVIDCAP_ENUMDSWIN32CB is a specialized callback definition for enumeration of video capture devices under DirectShow in win32. It allows us to pass the IMoniker* in addition to information passed by CVVIDCAP_ENUMCB

Parameters:
devName - ASCIIZ device name. Use this for calls to Connect()
moniker - DirectX device moniker.
userParam - user defined paramter, passed into EnumDevices()
Returns:
bool - true continues enumeration, false halts enumeration.
See also:
EnumDevices(), CVVidCap::CVVIDCAP_ENUMCB

Definition at line 125 of file CVVidCaptureDSWin32.h.

typedef bool(* CVVidCaptureDSWin32::CVVIDCAP_RAWCB)( CVRES status, const VIDEOINFOHEADER* vHeader, unsigned char* buffer, void* userParam )
 

CVVIDCAP_RAWCB is the specialized callback definition for continuous raw captures under DirectShow in win32.

It's faster than the standard image callback, but less convenient than the standard image capture callback since it doesn't set up a CVImage object for us. The header and buffer passed are only valid during the callback.

First, check the status code - if it's a successful status code, (e.g. if CVSUCCESS(status) returns true), then the imagePtr is valid. Otherwise, some sort of error has occurred - most likely, the camera has been disconnected.

Returning true continues the capture, returning false aborts it. You'll still have to call Stop() from another thread (e.g. outside the callback), but no more callbacks will be received after an abort and the processing will halt.

Do NOT call Stop() from within a callback or it will cause a deadlock. Instead, return false from the callback to cause an abort, then call Stop() from your main thread.

Parameters:
status - Status of the capture (CVRES_VIDCAP_OK, CVRES_VIDCAP_CAPTURE_ERROR)
vHeader - raw VIDEOINFOHEADER. See DirectShow docs.
buffer - raw bitmap buffer, matches format in vHeader
userParam - user defined parameter, passed into StartRawCap
Returns:
bool - true continues capture, false halts it.
See also:
StartRawCap(), StartImageCap(), CVVIDCAP_CALLBACK

Definition at line 159 of file CVVidCaptureDSWin32.h.


Constructor & Destructor Documentation

CVVidCaptureDSWin32::CVVidCaptureDSWin32  ) 
 

Constructor for DirectShow video capture

See also:
CVVidCapture::CVVidCapture

Definition at line 151 of file CVVidCaptureDSWin32.cpp.

References CVImage::CVIMAGE_RGB24, CVRES_SUCCESS, fAborted, fAbortEvent, fCallbackStatus, fCapMediaFilter, fCaptureAbortThread, fCaptureAbortThreadReady, fCaptureCallback, fCaptureControl, fCaptureEvent, fCaptureFilter, fCapturePin, fCaptureUserParam, fClock, fFiltersConnected, fGraph, fImageType, fMediaType, fProcAmpProps, fRawCallback, fRefCount, fRenderer, fSampleGrabber, fSampleGrabberFilter, fStreamConfig, fVideoHeader, and fVideoProcAmp.

CVVidCaptureDSWin32::~CVVidCaptureDSWin32  )  [virtual]
 

Destructor for DirectShow video capture

See also:
CVVidCapture::~CVVidCapture

Definition at line 192 of file CVVidCaptureDSWin32.cpp.

References CVAssert, and fRefCount.


Member Function Documentation

ULONG WINAPI CVVidCaptureDSWin32::AddRef  )  [private]
 

AddRef() increments the COM reference count for our ISampleGrabberCB interface.

Returns:
ULONG - new reference count.
See also:
QueryInterface(), Release()

Definition at line 1359 of file CVVidCaptureDSWin32.cpp.

References fRefCount.

Referenced by QueryInterface().

HRESULT WINAPI CVVidCaptureDSWin32::BufferCB double  sampleTimeSec,
BYTE *  bufferPtr,
long  bufferLength
[private]
 

BufferCB() COM buffer callback for video capture. It is derived from the ISampleGrabberCB interface. We do not currently implement this function - use SampleCB() instead.

See also:
SampleCB()

Definition at line 1469 of file CVVidCaptureDSWin32.cpp.

References CVAssert.

unsigned int WINAPI CVVidCaptureDSWin32::CaptureAbortThreadFunc void *  userParam  )  [static, private]
 

Definition at line 1707 of file CVVidCaptureDSWin32.cpp.

References CVAssert, CVRES, CVRES_SUCCESS, CVRES_VIDCAP_CAPTURE_DEVICE_DISCONNECTED, CVRES_VIDCAP_CAPTURE_ERROR, CVSUCCESS, fAborted, fAbortEvent, fCaptureAbortThreadReady, fCaptureCallback, fCaptureEvent, fCaptureUserParam, fRawCallback, SetCallbackStatus(), and StopCaptureGraph().

Referenced by StartAbortThread().

void CVVidCaptureDSWin32::ClearDeviceList  )  [virtual]
 

ClearDeviceList() clears the list of available devices, if any. Some platforms may need to override this for cleanup if they store extra info in the VIDCAP_DEVICE struct.

Reimplemented from CVVidCapture.

Definition at line 572 of file CVVidCaptureDSWin32.cpp.

References CVVidCapture::fDeviceList, and CVVidCapture::fNumDevices.

Referenced by RefreshDeviceList().

void CVVidCaptureDSWin32::ClearModes  )  [protected, virtual]
 

ClearModes() - clears the mode list. You must have called Connect() already to enumerate the available modes for the connected device before calling this function.

See also:
GetNumSupportedModes(), GetModeInfo(), AddMode()

Reimplemented from CVVidCapture.

Definition at line 1597 of file CVVidCaptureDSWin32.cpp.

References CVVidCapture::fModeList, and LocalDeleteMediaType().

Referenced by Disconnect().

CVRES CVVidCaptureDSWin32::Connect int  devIndex  )  [virtual]
 

Init() must be called prior to Connect(). Connect() must set fConnected to true on success.

Parameters:
devIndex - Index of device in device list.
Returns:
CVRES result code.
See also:
RefreshDeviceList(), GetNumDevices(), GetDeviceInfo()

Init(), Disconnect(), CVRes.h, CVResVidCap.h

Implements CVVidCapture.

Definition at line 601 of file CVVidCaptureDSWin32.cpp.

References CVVidCapture::CAMERAPROP_NUMPROPS, CVAssert, CVFAILED, CVRES, CVRES_SUCCESS, CVRES_VIDCAP_ADD_RENDER_ERR, CVRES_VIDCAP_CAPABILITY_CHECK_FAILED, CVRES_VIDCAP_CAPTURE_ADD_FAILED, CVRES_VIDCAP_CAPTURE_BIND_FAILED, CVRES_VIDCAP_CAPTURE_NO_AVAILABLE_PIN, CVRES_VIDCAP_CONNECT_ERR, CVRES_VIDCAP_INVALID_DEVICE_INDEX, CVRES_VIDCAP_MUST_INITIALIZE_ERR, CVRES_VIDCAP_NO_DEVICES, CVRES_VIDCAP_NO_NULL_RENDERER, CVTrace, fCapMediaFilter, fCaptureFilter, fCapturePin, CVVidCapture::fConnected, CVVidCapture::fDeviceList, CVVidCapture::fDeviceName, fGraph, CVVidCapture::fInitialized, CVVidCapture::fNumDevices, fProcAmpProps, fRenderer, fStreamConfig, fVideoProcAmp, GetUnconnectedPin(), GetVidCapFormat(), and LocalDeleteMediaType().

bool CVVidCaptureDSWin32::ConnectEnum const char *  devName,
IMoniker *  moniker,
void *  userParam
[static, private]
 

CVRES CVVidCaptureDSWin32::ConnectGraph  )  [private]
 

Definition at line 1988 of file CVVidCaptureDSWin32.cpp.

References ConnectFilters(), CVAssert, CVRES, CVRES_SUCCESS, CVRES_VIDCAP_CAPTURE_GRABBER_CONNECT_FAILED, CVRES_VIDCAP_GRABBER_CONNECT_FAILED, CVRES_VIDCAP_NOT_CONNECTED, CVRES_VIDCAP_VIDEO_FORMAT_NOT_SUPPORTED, CVTrace, DisconnectGraph(), DisconnectPins(), fCaptureFilter, fCapturePin, CVVidCapture::fConnected, CVVidCapture::fCurMode, fFiltersConnected, fGraph, fMediaType, fRenderer, fSampleGrabber, fSampleGrabberFilter, fVideoHeader, and LocalFreeMediaType().

CVRES CVVidCaptureDSWin32::Disconnect  )  [virtual]
 

Disconnect from a previously connected capture device. Should only be called if a previous CVVidCapture::Connect() was successful.

Must set fConnected to false on success. Must also set fLastState to VIDCAP_UNCONNECTED

Returns:
CVRES result code.
See also:
Connect(), CVRes.h, CVResVidCap.h

Reimplemented from CVVidCapture.

Definition at line 879 of file CVVidCaptureDSWin32.cpp.

References ClearModes(), CVAssert, CVFAILED, CVRES, CVRES_SUCCESS, CVRES_VIDCAP_MUST_INITIALIZE_ERR, CVRES_VIDCAP_NOT_CONNECTED, CVTrace, fCapMediaFilter, fCaptureFilter, fCapturePin, CVVidCapture::fConnected, CVVidCapture::fCurMode, CVVidCapture::fDeviceName, fGraph, CVVidCapture::fInitialized, CVVidCapture::fLastState, fRenderer, CVVidCapture::fStarted, fStreamConfig, fVideoHeader, fVideoProcAmp, LocalFreeMediaType(), and CVVidCapture::VIDCAP_UNCONNECTED.

CVRES CVVidCaptureDSWin32::DisconnectGraph  )  [private]
 

Definition at line 2062 of file CVVidCaptureDSWin32.cpp.

References CVAssert, CVRES, CVRES_SUCCESS, CVRES_VIDCAP_NOT_CONNECTED, CVTrace, DisconnectPins(), fCaptureFilter, CVVidCapture::fConnected, fFiltersConnected, fRenderer, and fSampleGrabberFilter.

Referenced by ConnectGraph(), Grab(), StartImageCap(), StartRawCap(), and Stop().

CVRES CVVidCaptureDSWin32::GetCallbackStatus  )  [private]
 

Definition at line 1895 of file CVVidCaptureDSWin32.cpp.

References CVAssert, CVRES, CVRES_VIDCAP_SYNC_TIMEOUT, fCallbackStatus, and fStatusLock.

Referenced by SampleCB().

const GUID * CVVidCaptureDSWin32::GetDirectXFormat VIDCAP_FORMAT  vidCapFormat  )  [static, private]
 

Definition at line 1975 of file CVVidCaptureDSWin32.cpp.

References CVAssert, VIDCAP_FORMAT_CONV::DirectShowFormat, kDSWin32VideoFormats, and VIDCAP_NUM_FORMATS.

CVRES CVVidCaptureDSWin32::GetPropertyInfo CAMERA_PROPERTY  property,
long *  curVal = 0,
long *  defVal = 0,
long *  minVal = 0,
long *  maxVal = 0,
long *  step = 0
[virtual]
 

GetPropertyInfo retrieves information about a specific camera property. It may return CVRES_VIDCAP_PROPERTY_NOT_SUPPORTED if the property is not support on the device or in the VidCapture framework.

All pointers may be NULL.

You must have a device connected from a successful call to Connect() to use this function.

Parameters:
property - ID of property (e.g. CAMERAPROP_BRIGHT)
curVal - ptr to receive current value of property.
defVal - ptr to receive default value of property.
minVal - ptr to receive minimum value of property.
maxVal - ptr to receive maximum value of property.
step - ptr to receive the minimum step distance between values.
Returns:
CVRES result code.
See also:
Init(), Connect(), SetProperty(), GetPropertyName()

CAMERA_PROPERTY, CVRes.h, CVResVidCap.h

Reimplemented from CVVidCapture.

Definition at line 1491 of file CVVidCaptureDSWin32.cpp.

References CVVidCapture::CAMERAPROP_NUMPROPS, CVRES, CVRES_INVALID_PARAMETER, CVRES_SUCCESS, CVRES_VIDCAP_PROPERTY_NOT_SUPPORTED, fProcAmpProps, and fVideoProcAmp.

VIDCAP_FORMAT CVVidCaptureDSWin32::GetVidCapFormat GUID *  directXFormat  )  [static, private]
 

Definition at line 1951 of file CVVidCaptureDSWin32.cpp.

References VIDCAP_FORMAT_CONV::DirectShowFormat, kDSWin32VideoFormats, VIDCAP_FORMAT, VIDCAP_FORMAT_UNKNOWN, VIDCAP_NUM_FORMATS, and VIDCAP_FORMAT_CONV::VidCapFormat.

Referenced by Connect().

CVRES CVVidCaptureDSWin32::Grab CVImage::CVIMAGE_TYPE  imageType,
CVImage *&  imagePtr
[virtual]
 

Grab() is a single shot synchronous grab.

Caller should pass an uninstantiated image ptr and the desired image type. imagePtr will be instantiated with the captured image on success.

Image must be deleted by caller when done by calling CVImage::ReleaseImage().

Parameters:
imageType - type of image to grab
imagePtr - uninstantiated image ptr. Set on return.
Returns:
CVRES result code.
See also:
StartImageCap(), StartRawCap(), Stop(), CVImage

CVRes.h, CVResVidCap.h

Implements CVVidCapture.

Definition at line 1206 of file CVVidCaptureDSWin32.cpp.

References CVImage::CreateFromWin32Bmp(), CVAssert, CVFAILED, CVImage::CVIMAGE_DEFAULT, CVRES, CVRES_OUT_OF_MEMORY, CVRES_SUCCESS, CVRES_VIDCAP_GET_BUFFER_ERR, CVRES_VIDCAP_MUST_CONNECT_ERR, CVRES_VIDCAP_MUST_INITIALIZE_ERR, CVRES_VIDCAP_START_ERR, CVRES_VIDCAP_STOP_BEFORE_GRABS_ERR, CVRES_VIDCAP_TIMEOUT, DisconnectGraph(), fCaptureControl, fCaptureEvent, CVVidCapture::fConnected, fImageType, CVVidCapture::fInitialized, CVVidCapture::fLastState, fSampleGrabber, CVVidCapture::fStarted, fVideoHeader, kCVVidCapture_Timeout, and CVVidCapture::VIDCAP_SINGLE_SHOT_MODE.

CVRES CVVidCaptureDSWin32::HaltAbortThread  )  [private]
 

Definition at line 1671 of file CVVidCaptureDSWin32.cpp.

References CVAssert, CVRES, CVRES_SUCCESS, CVRES_VIDCAP_MUST_CONNECT_ERR, fAborted, fAbortEvent, and fCaptureAbortThread.

Referenced by StartImageCap(), StartRawCap(), and Stop().

CVRES CVVidCaptureDSWin32::Init  )  [virtual]
 

Init must be called first before any other operations. Init() must set the fInitialized member to true on success.

Returns:
CVRES result code.
See also:
Uninit(), CVVidCapture::Init(), CVRes.h, CVResVidCap.h

Implements CVVidCapture.

Definition at line 201 of file CVVidCaptureDSWin32.cpp.

References CVRES, CVRES_OUT_OF_HANDLES, CVRES_SUCCESS, CVRES_VIDCAP_ADD_GRABBER_ERR, CVRES_VIDCAP_ALREADY_INITIALIZED, CVRES_VIDCAP_COM_ERR, CVRES_VIDCAP_MEDIATYPE_SET_ERR, CVRES_VIDCAP_NO_CAPTURE_CONTROL, CVRES_VIDCAP_NO_CAPTURE_EVENT, CVRES_VIDCAP_NO_FILTER_GRAPH, CVRES_VIDCAP_NO_ISAMPLEGRABBER, CVRES_VIDCAP_NO_SAMPLE_GRABBER, CVTrace, fAborted, fAbortEvent, fCaptureControl, fCaptureEvent, fGraph, CVVidCapture::fInitialized, fMediaType, fSampleGrabber, fSampleGrabberFilter, fStatusLock, fStopLock, RefreshDeviceList(), and UninitObjects().

HRESULT WINAPI CVVidCaptureDSWin32::QueryInterface REFIID  iid,
void **  ppvObject
[private]
 

COM QueryInterface - we support IUnknown and ISampleGrabberCB Retrieves the requested interface. Call Release() on the returned ppvObject when done.

Parameters:
iid - REFIID for the desired interface
ppvObject - ptr to object ptr to be set to interface ptr.
Returns:
HRESULT - S_OK on success
See also:
Release()

Definition at line 1330 of file CVVidCaptureDSWin32.cpp.

References AddRef().

CVRES CVVidCaptureDSWin32::RefreshDeviceList  )  [virtual]
 

RefreshDeviceList() refreshes the list of devices available to VidCapture.

Returns:
CVRES result code

Implements CVVidCapture.

Definition at line 351 of file CVVidCaptureDSWin32.cpp.

References ClearDeviceList(), CVAssert, CVRES, CVRES_SUCCESS, CVRES_VIDCAP_ENUM_ERR, CVRES_VIDCAP_MUST_INITIALIZE_ERR, CVRES_VIDCAP_NO_DEVICES, CVRES_VIDCAP_NO_ENUMERATOR, CVTrace, CVVidCapture::fDeviceList, CVVidCapture::fInitialized, and CVVidCapture::fNumDevices.

Referenced by Init().

ULONG WINAPI CVVidCaptureDSWin32::Release  )  [private]
 

Release() decrements the COM reference count for our ISampleGrabberCB interface. We don't actually free our object here. However, the value should never become 0 here either, since instantiating our class starts the reference count at 1.

Returns:
ULONG - new reference count.
See also:
QueryInterface(), AddRef()

Definition at line 1368 of file CVVidCaptureDSWin32.cpp.

References CVAssert, and fRefCount.

HRESULT WINAPI CVVidCaptureDSWin32::SampleCB double  sampleTimeSec,
IMediaSample *  mediaSample
[private]
 

SampleCB() COM Sample callback for video capture. This is called by DirectShow when we do capture runs. It is derived from the ISampleGrabberCB interface.

Parameters:
sampleTimeSec - time stamp of when image was taken
mediaSample* - IMediaSample interface containing sample
Returns:
HRESULT - S_OK on success.
See also:
StartImageCap(), StartRawCap(), CVVIDCAP_CALLBACK, CVVIDCAP_RAWCB

Definition at line 1381 of file CVVidCaptureDSWin32.cpp.

References CVImage::CreateFromWin32Bmp(), CVFAILED, CVRES, CVRES_VIDCAP_CAPTURE_ERROR, CVSUCCESS, fAborted, fCaptureCallback, fCaptureUserParam, fImageType, fRawCallback, fVideoHeader, GetCallbackStatus(), CVImage::ReleaseImage(), and SetCallbackStatus().

void CVVidCaptureDSWin32::SetCallbackStatus CVRES  newStatus  )  [private]
 

Definition at line 1870 of file CVVidCaptureDSWin32.cpp.

References CVAssert, fCallbackStatus, and fStatusLock.

Referenced by CaptureAbortThreadFunc(), and SampleCB().

CVRES CVVidCaptureDSWin32::SetMode VIDCAP_MODE &  newMode  )  [virtual]
 

SetMode - sets the video mode for a connected camera. This version must be overridden in child classes. You must have called Connect() already to enumerate the available modes for the connected device before calling this function.

Parameters:
newMode - new mode to use for connected device.
Returns:
CVRES result code
See also:
GetNumSupportedModes(), GetModeInfo(), GetCurrentMode()

VIDCAP_MODE, CVRes.h, CVResVidCap.h

Reimplemented from CVVidCapture.

Definition at line 1550 of file CVVidCaptureDSWin32.cpp.

References CVRES, CVRES_SUCCESS, CVRES_VIDCAP_MEDIATYPE_SET_ERR, CVRES_VIDCAP_MODE_NOT_SUPPORTED, CVTrace, CVVidCapture::fCurMode, fMediaType, fSampleGrabber, fStreamConfig, and fVideoHeader.

CVRES CVVidCaptureDSWin32::SetProperty CAMERA_PROPERTY  property,
long  value
[virtual]
 

SetProperty() sets the specified property to the given value. Use GetPropertyInfo() to get the supported range and resolution of the property in use. You must have a device connected from a successful call to Connect() to use this function.

Parameters:
property - ID of property.
value - new value to set property to. Must be within range.
Returns:
CVRES result code
See also:
Connect(), GetPropertyInfo(), GetPropertyName(), CAMERA_PROPERTY

CVRes.h, CVResVidCap.h

Reimplemented from CVVidCapture.

Definition at line 1528 of file CVVidCaptureDSWin32.cpp.

References CVVidCapture::CAMERAPROP_NUMPROPS, CVRES, CVRES_INVALID_PARAMETER, CVRES_SUCCESS, CVRES_VIDCAP_PROPERTY_NOT_SUPPORTED, fProcAmpProps, and fVideoProcAmp.

CVRES CVVidCaptureDSWin32::StartAbortThread  )  [private]
 

Definition at line 1617 of file CVVidCaptureDSWin32.cpp.

References CaptureAbortThreadFunc(), CVAssert, CVRES, CVRES_OUT_OF_HANDLES, CVRES_SUCCESS, CVRES_VIDCAP_MUST_CONNECT_ERR, CVRES_VIDCAP_RUNNING, fAborted, fAbortEvent, fCallbackStatus, fCaptureAbortThread, and fCaptureAbortThreadReady.

CVRES CVVidCaptureDSWin32::StartImageCap CVImage::CVIMAGE_TYPE  imageType,
CVVIDCAP_CALLBACK  callback,
void *  userParam
[virtual]
 

StartImageCap() starts continuous image capture until Stop() is called. Both Init() and Connect() must have been successfully called prior to calling StartImageCap().

imageType specifies the image type to return. callback must be a valid CVVIDCAP_CALLBACK callback, and is called for each image. Try not to do heavy processing within the callback.

Must set fStarted to true on success. Must also set fLastState to VIDCAP_CONTINUOUS_MODE

Parameters:
imageType - type of image to send to callback for each frame
callback - callback to be called on each frame
userParam - user defined value passed into callback
Returns:
CVRES result code.
See also:
StartRawCap(), Grab(), Stop(), CVImage

CVRes.h, CVResVidCap.h

Implements CVVidCapture.

Definition at line 983 of file CVVidCaptureDSWin32.cpp.

References CVAssert, CVFAILED, CVImage::CVIMAGE_DEFAULT, CVRES, CVRES_SUCCESS, CVRES_VIDCAP_MUST_CONNECT_ERR, CVRES_VIDCAP_MUST_INITIALIZE_ERR, CVRES_VIDCAP_START_ERR, CVTrace, DisconnectGraph(), fCaptureCallback, fCaptureUserParam, CVVidCapture::fConnected, fImageType, CVVidCapture::fInitialized, CVVidCapture::fLastState, fRawCallback, fSampleGrabber, CVVidCapture::fStarted, HaltAbortThread(), and CVVidCapture::VIDCAP_CONTINUOUS_MODE.

CVRES CVVidCaptureDSWin32::StartRawCap CVVIDCAP_RAWCB  callback,
void *  userParam
[virtual]
 

StartRawCap() starts a continuous grab sending raw data to callback. Call Stop() to stop the capture.

Buffers will currently always be 24-bit RGB bitmaps due to the ISampleGrabber configuration.

Both Init() and Connect() must have been successfully called prior to calling StartImageCap().

Must set fStarted to true on success. Must also set fLastState to VIDCAP_CONTINUOUS_MODE

Parameters:
callback - function to receive callbacks for each frame
userParam - user defined param to send to callback
Returns:
CVRES result code.
See also:
StartImageCap(), Grab(), Stop(), CVVIDCAP_RAWCB

CVRes.h, CVResVidCap.h

Definition at line 1079 of file CVVidCaptureDSWin32.cpp.

References CVAssert, CVFAILED, CVRES, CVRES_SUCCESS, CVRES_VIDCAP_MUST_CONNECT_ERR, CVRES_VIDCAP_MUST_INITIALIZE_ERR, CVRES_VIDCAP_START_ERR, CVTrace, DisconnectGraph(), fCaptureCallback, fCaptureUserParam, CVVidCapture::fConnected, CVVidCapture::fInitialized, CVVidCapture::fLastState, fRawCallback, fSampleGrabber, CVVidCapture::fStarted, HaltAbortThread(), and CVVidCapture::VIDCAP_CONTINUOUS_MODE.

CVRES CVVidCaptureDSWin32::Stop  )  [virtual]
 

Stop() stops an active image capture started with StartImageCap() or StartRawCap().

Do NOT call Stop() from within a callback or it will cause a deadlock. Instead, return false from the callback to cause an abort, then call Stop() from your main thread.

Must set fStarted to false on success.

Returns:
CVRES result code.
See also:
StartImageCapture(), StartRawCap(), CVRes.h, CVResVidCap.h

CVVIDCAP_CALLBACK, CVVIDCAL_RAWCB

Reimplemented from CVVidCapture.

Definition at line 1157 of file CVVidCaptureDSWin32.cpp.

References CVAssert, CVRES, CVRES_SUCCESS, CVRES_VIDCAP_ALREADY_STOPPED, CVRES_VIDCAP_MUST_CONNECT_ERR, CVRES_VIDCAP_MUST_INITIALIZE_ERR, CVTrace, DisconnectGraph(), CVVidCapture::fConnected, CVVidCapture::fInitialized, CVVidCapture::fStarted, HaltAbortThread(), and StopCaptureGraph().

CVRES CVVidCaptureDSWin32::StopCaptureGraph  )  [private]
 

Definition at line 1923 of file CVVidCaptureDSWin32.cpp.

References CVAssert, CVRES, CVRES_SUCCESS, CVRES_VIDCAP_CAPTURE_STOP_IN_USE, and fStopLock.

Referenced by CaptureAbortThreadFunc(), and Stop().

CVRES CVVidCaptureDSWin32::Uninit  )  [virtual]
 

Uninit object before deletion (matches with Init()). Must set fInitialized to false on success.

Returns:
CVRES result code.
See also:
Init(), CVVidCapture::Uninit(), CVRes.h, CVResVidCap.h

Reimplemented from CVVidCapture.

Definition at line 540 of file CVVidCaptureDSWin32.cpp.

References CVFAILED, CVRES, CVRES_SUCCESS, CVRES_VIDCAP_NOT_INITIALIZED, CVTrace, CVVidCapture::fConnected, CVVidCapture::fInitialized, and UninitObjects().

void CVVidCaptureDSWin32::UninitObjects  )  [private]
 

Definition at line 482 of file CVVidCaptureDSWin32.cpp.

References fAbortEvent, fCaptureControl, fCaptureEvent, fGraph, fSampleGrabber, fSampleGrabberFilter, fStatusLock, and fStopLock.

Referenced by Init(), and Uninit().


Member Data Documentation

bool CVVidCaptureDSWin32::fAborted [private]
 

Definition at line 545 of file CVVidCaptureDSWin32.h.

Referenced by CaptureAbortThreadFunc(), CVVidCaptureDSWin32(), HaltAbortThread(), Init(), SampleCB(), and StartAbortThread().

HANDLE CVVidCaptureDSWin32::fAbortEvent [private]
 

Definition at line 525 of file CVVidCaptureDSWin32.h.

Referenced by CaptureAbortThreadFunc(), CVVidCaptureDSWin32(), HaltAbortThread(), Init(), StartAbortThread(), and UninitObjects().

CVRES CVVidCaptureDSWin32::fCallbackStatus [private]
 

Definition at line 535 of file CVVidCaptureDSWin32.h.

Referenced by CVVidCaptureDSWin32(), GetCallbackStatus(), SetCallbackStatus(), and StartAbortThread().

IMediaFilter* CVVidCaptureDSWin32::fCapMediaFilter [private]
 

Definition at line 551 of file CVVidCaptureDSWin32.h.

Referenced by Connect(), CVVidCaptureDSWin32(), and Disconnect().

HANDLE CVVidCaptureDSWin32::fCaptureAbortThread [private]
 

Definition at line 519 of file CVVidCaptureDSWin32.h.

Referenced by CVVidCaptureDSWin32(), HaltAbortThread(), and StartAbortThread().

HANDLE CVVidCaptureDSWin32::fCaptureAbortThreadReady [private]
 

Definition at line 522 of file CVVidCaptureDSWin32.h.

Referenced by CaptureAbortThreadFunc(), CVVidCaptureDSWin32(), and StartAbortThread().

CVVIDCAP_CALLBACK CVVidCaptureDSWin32::fCaptureCallback [private]
 

Definition at line 563 of file CVVidCaptureDSWin32.h.

Referenced by CaptureAbortThreadFunc(), CVVidCaptureDSWin32(), SampleCB(), StartImageCap(), and StartRawCap().

IMediaControl* CVVidCaptureDSWin32::fCaptureControl [private]
 

Definition at line 510 of file CVVidCaptureDSWin32.h.

Referenced by CVVidCaptureDSWin32(), Grab(), Init(), and UninitObjects().

IMediaEvent* CVVidCaptureDSWin32::fCaptureEvent [private]
 

Definition at line 514 of file CVVidCaptureDSWin32.h.

Referenced by CaptureAbortThreadFunc(), CVVidCaptureDSWin32(), Grab(), Init(), and UninitObjects().

IBaseFilter* CVVidCaptureDSWin32::fCaptureFilter [private]
 

Definition at line 479 of file CVVidCaptureDSWin32.h.

Referenced by Connect(), ConnectGraph(), CVVidCaptureDSWin32(), Disconnect(), and DisconnectGraph().

IPin* CVVidCaptureDSWin32::fCapturePin [private]
 

Definition at line 483 of file CVVidCaptureDSWin32.h.

Referenced by Connect(), ConnectGraph(), CVVidCaptureDSWin32(), and Disconnect().

void* CVVidCaptureDSWin32::fCaptureUserParam [private]
 

Definition at line 569 of file CVVidCaptureDSWin32.h.

Referenced by CaptureAbortThreadFunc(), CVVidCaptureDSWin32(), SampleCB(), StartImageCap(), and StartRawCap().

IReferenceClock* CVVidCaptureDSWin32::fClock [private]
 

Definition at line 555 of file CVVidCaptureDSWin32.h.

Referenced by CVVidCaptureDSWin32().

bool CVVidCaptureDSWin32::fFiltersConnected [private]
 

Definition at line 548 of file CVVidCaptureDSWin32.h.

Referenced by ConnectGraph(), CVVidCaptureDSWin32(), and DisconnectGraph().

IGraphBuilder* CVVidCaptureDSWin32::fGraph [private]
 

Definition at line 471 of file CVVidCaptureDSWin32.h.

Referenced by Connect(), ConnectGraph(), CVVidCaptureDSWin32(), Disconnect(), Init(), and UninitObjects().

CVImage::CVIMAGE_TYPE CVVidCaptureDSWin32::fImageType [private]
 

Definition at line 572 of file CVVidCaptureDSWin32.h.

Referenced by CVVidCaptureDSWin32(), Grab(), SampleCB(), and StartImageCap().

AM_MEDIA_TYPE CVVidCaptureDSWin32::fMediaType [private]
 

Definition at line 503 of file CVVidCaptureDSWin32.h.

Referenced by ConnectGraph(), CVVidCaptureDSWin32(), Init(), and SetMode().

VIDCAP_PROCAMP_PROPS CVVidCaptureDSWin32::fProcAmpProps[CAMERAPROP_NUMPROPS] [private]
 

Definition at line 576 of file CVVidCaptureDSWin32.h.

Referenced by Connect(), CVVidCaptureDSWin32(), GetPropertyInfo(), and SetProperty().

CVVIDCAP_RAWCB CVVidCaptureDSWin32::fRawCallback [private]
 

Definition at line 566 of file CVVidCaptureDSWin32.h.

Referenced by CaptureAbortThreadFunc(), CVVidCaptureDSWin32(), SampleCB(), StartImageCap(), and StartRawCap().

unsigned long CVVidCaptureDSWin32::fRefCount [private]
 

Definition at line 463 of file CVVidCaptureDSWin32.h.

Referenced by AddRef(), CVVidCaptureDSWin32(), Release(), and ~CVVidCaptureDSWin32().

IBaseFilter* CVVidCaptureDSWin32::fRenderer [private]
 

Definition at line 489 of file CVVidCaptureDSWin32.h.

Referenced by Connect(), ConnectGraph(), CVVidCaptureDSWin32(), Disconnect(), and DisconnectGraph().

ISampleGrabber* CVVidCaptureDSWin32::fSampleGrabber [private]
 

Definition at line 492 of file CVVidCaptureDSWin32.h.

Referenced by ConnectGraph(), CVVidCaptureDSWin32(), Grab(), Init(), SetMode(), StartImageCap(), StartRawCap(), and UninitObjects().

IBaseFilter* CVVidCaptureDSWin32::fSampleGrabberFilter [private]
 

Definition at line 475 of file CVVidCaptureDSWin32.h.

Referenced by ConnectGraph(), CVVidCaptureDSWin32(), DisconnectGraph(), Init(), and UninitObjects().

HANDLE