#ifndef WEBCAM_FUNC_LIBRARY_H
#define WEBCAM_FUNC_LIBRARY_H

// structure containing info about captured data
typedef struct CamData
{
	// image width
	int Width;
	// image height
	int Height;
	// image stride
	int Stride;
	// pointer to first pixel data in memory
	BYTE *Buffer;
};

// managed c++/cli class compatible with garbage collector
// class contains functions for camera initialization and frame capture
ref class CamCapture
{
public:
	// constructor
	CamCapture();

	// destructor
	~CamCapture() { ; }

	// enumerates devices, same result as constructor
	HRESULT CountDevices();

	// returns capture device count
	int GetCamCount() { return devCount; }
	
	// returns last Error in CamCapture
	HRESULT GetLastError() { return hr; }

	// returns friendly name of capture devices
	HRESULT GetCamName(int id, char *name, int length);

	// TODO:
	// initialize capture device 
	HRESULT InitCam(int id, CamData *Capture);

	// deinitialiye capture device
	HRESULT DeInitCam(CamData *Capture);

	// get one frame
	HRESULT GrabFrame(int id);
	
	HRESULT CreateCaptureSource(int id);

private:
	HRESULT hr;			// HRESULT, contains last error of CamCapture object
	int devCount;		// capture device count

	IMFSourceReader *ppReader;
	IMFMediaSource **ppSource;
};

#endif // WEBCAM_FUNC_LIBRARY_H