Solved

Create managed DLL wrapper in C# for unmanaged DLL

Posted on 2010-09-20
4
999 Views
Last Modified: 2013-12-16
I am trying to write a wrapper DLL for a manufacturers unmanaged C++ DLL. They have provided the DLL file, a header file which looks to have all of the functions to reference that DLL, and a VC6 C++ example. I program primarily in C# and have never written a wrapper class before.  I have little to no experience in C++. I have been looking at documents online to find out how to write a wrapper class for this DLL and have successfully gotten myself confused even more. I know I have all I need to get the job done, I just can't seem to wrap my head around it. I'll go ahead and put in some example code below to maybe help you understand what it is I am battling.

Let's say the unmanaged DLL is "Manufacturer.dll"
Manufacturer Header file is "IManufacturer.h"

The header file is for a video capture card, and I am not looking for anyone to actually write the wrapper completely, just help me get started with it. I really appreciate any help.
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "Capture.h"

#ifdef ENCSDK_EXPORTS
#define ENCSDK_API __declspec(dllexport)
#else
#define ENCSDK_API __declspec(dllimport)
#endif

typedef enum
{
	ENC_SUCCEEDED		= 1,
	ENC_FAILED			= 0,
	ENC_SDKINITFAILED	= -1,
	ENC_DEVINITFAILED	= -2,
	ENC_INITADFAILED	= -3,
	ENC_PARAMERROR		= -4,
	ENC_CHNUMERROR		= -5
} EncRes;

enum FrameType
{
    I_FRAME = 1,
	P_FRAME,
	B_FRAME
};

enum GpioDirection
{
    GPIO_OUTPUT,
	GPIO_INPUT
};

typedef struct
{
	unsigned int picture_type;	///< Specifies the type of picture, I-Frame=1, P-Frame=2 and B-Frame=3.
	unsigned int byte_offset;	///< Specifies the number of bytes used since encoding. When this value is greater than 32 bits (i.e. 4 Giga bytes), it will be recalculated by the formula new_offset = offset % 4G.
	unsigned int ptsh;			///< Specifies the higher bit 33 of picture PTS in 1/90KHz unit.
	unsigned int ptsl;			///< Specifies the lower 32 bits of picture PTS.
} STREAM_INFO;

/**
 * The Stream Read Callback function structure
 */
typedef struct
{
	void (*PSTREAMREADOPEN)(int nChNum);	///< The pointer of the Stream Read Open Callback function. This callback function is called when the stream read process starts.
	void (*PSTREAMREADPROC)(int nChNum, BYTE *pStreamBuf, UINT32 nBufSize);	///< The pointer of the Stream Read Process Callback function. This callback function is called when the stream is read.
	void (*PSTREAMREADCLOSE)(int nChNum);	///< The pointer of the Stream Read Close Callback function. This callback function is called when the stream read process finishes.
} STREAMREAD_STRUCT;

typedef void (*PMOTIONDETECTPROC)(int nChNum, int nRegionNum, unsigned short mbCount);	///< The Motion Detect Process Callback function. This callback function is called when there are the motions being detected in the specified video region.
typedef void (*PENCFAILPROC)(int nChNum);	///< The Encoding Failed Process Callback function. This callback function is called when encoding process fails.

/**
 * The region structure of the motion detect.
 */
typedef struct
{
	int enable;	///< Used to enable/disable motion detection.
	int left;	///< Define the left most macroblock number of the horizontal coordinates of the region.
	int right;	///< Define the right most macroblock number of the horizontal coordinates of the region.
	int top;	///< Define the top most macroblock number of the horizontal coordinates of the region.
	int bottom;	///< Define the bottom most macroblock number of the horizontal coordinates of the region.
} MDRegion;

/**
 * @brief IEncSDK declaration
 *
 * IEncSDK : About the implement, please refelence EncSDK.cpp.
 *
 */
class ENCSDK_API IEncSDK
{
public:

	/**
	* @brief This function creates SDK instance.
	*
	* @param pp A pointer to the SDK instance.
	*
	* @return If function succeeded, function returns ENC_SUCCEEDED.
	*/
	virtual int CreateEncSDKInstence(void **pp);

	/**
	* @brief This function releases SDK instance.
	*
	* @param p Specifies the SDK instance.
	*
	* @return If function succeeded, function returns ENC_SUCCEEDED.
	*/
	virtual int ReleaseEncSDKInstence(void *p);

	/**
	 * @brief This function initializes the SDK. This function must be called before other functions of the SDK.
	 *
	 * @param pVideoCap Specifies the array of the Ph7134 source filters to initialize the ADC.
	 *
	 * @return If function succeeded, function returns ENC_SUCCEEDED.
     */
	virtual int InitSDK(IBaseFilter *pVideoCap[]) PURE;

	/**
	 * @brief This function closes up the SDK.
	 *
	 * @return If function succeeded, function returns ENC_SUCCEEDED.
     */
	virtual int CloseSDK() PURE;

	/**
	 * @brief This function initializes the chip on a specified channel.
	 *
	 * @param nChNum Specifies the channel ID number.
	 *
	 * @return If function succeeded, function returns ENC_SUCCEEDED.
     */
	virtual int InitChips(int nChNum) PURE;

	/**
	 * @brief This function releases the chip on a specified channel.
	 *
	 * @param nChNum Specifies the channel ID number.
	 *
	 * @return If function succeeded, function returns ENC_SUCCEEDED.
     */
	virtual int ReleaseChips(int nChNum) PURE;

	/**
	 * @brief This function gets the number of the chips. Two firmware files boot.sre and pscodec.sre will be used 
	 *		  by the library. Notes: Don't download the firmware into the chip when the decoding process is running in the chip.
	 *
	 * @param nChNum Specifies the channel ID number.
	 *
	 * @return If function succeeded, function returns ENC_SUCCEEDED.
     */
	virtual int DownloadFW(int nChNum) PURE;

	/**
	 * @brief This function gets the number of the chips.
	 *
	 * @param pChipCnt An integer pointer to store the returned number of the chips.
	 *
	 * @return If function succeeded, function returns ENC_SUCCEEDED.
     */
	virtual int	GetChipCount(int *pChipCnt) PURE;

	/**
	 * @brief This function sets the board ID of the each board. The first codec device of the board is used to 
	 *		  set the board ID of the board. Thus, the user must call InitChips and DownloadFW 
	 *		  functions to initialize and download the firmware into the first codec device before calling this 
	 *		  function. And, call ReleaseChips function to release chip resources after calling this function.
	 *
	 * @param nChNum Specifies the channel ID number. The channel must be the first channel of the board.
	 *
	 * @return If function succeeded, function returns ENC_SUCCEEDED.
     */
	virtual int SetBoardID(int nChNum) PURE;

	/**
	 * @brief This function uses the video capture device to get the board ID. According to this board ID, 
	 *		  the user can known which board the video capture device belongs. The board ID is set by calling 
	 *		  SetBoardID function. Thus, before calling this function the SetBoardID function must 
	 *		  be called to setting correct board ID.
	 *
	 * @param pVideoCap Specifies the video capture filter to get the board ID it belongs.
	 * @param nBoardID An integer pointer to store the returned board ID.
	 *
	 * @return If function succeeded, function returns ENC_SUCCEEDED.
     */
	virtual int GetBoardID(IBaseFilter *pVideoCap, int *nBoardID) PURE;
	
	/**
	 * @brief This function gets the version of the SDK. 
	 *		  Major.Minor == 0-255.0-255 (e.g. 1.0). 
	 *		  Rev == 0-26, where 0 means no rev letter, 1-26 are revision a-z.
	 *
	 * @param pMaj Specifies the major munber of the SDK version.
	 * @param pMin Specifies the minor munber of the SDK version.
	 * @param pRev Specifies the revision letter of the SDK version.
	 * 
	 * @return If function succeeded, function returns ENC_SUCCEEDED.
	 */
	virtual int GetSDKVersion(BYTE *pMaj, BYTE *pMin, BYTE *pRev) PURE;

	/**
	 * @brief This function starts to encode the video on a specified channel.
	 *
	 * @param nChNum Specifies the channel ID number.
	 *
	 * @return If function succeeded, function returns ENC_SUCCEEDED.
     */
	virtual int StartEncode(int nChNum) PURE;

	/**
	 * @brief This function stops to encode the video on a specified channel.
	 *
	 * @param nChNum Specifies the channel ID number.
	 *
	 * @return If function succeeded, function returns ENC_SUCCEEDED.
     */
	virtual int StopEncode(int nChNum) PURE;

	/**
	 * @brief This function starts the motion detection on a specified channel.
	 *
	 * @param nChNum Specifies the channel ID number.
	 *
	 * @return If function succeeded, function returns ENC_SUCCEEDED.
     */
	virtual int StartMotionDetect(int nChNum) PURE;

	/**
	 * @brief This function stops the motion detection on a specified channel.
	 *
	 * @param nChNum Specifies the channel ID number.
	 *
	 * @return If function succeeded, function returns ENC_SUCCEEDED.
     */
	virtual int StopMotionDetect(int nChNum) PURE;

	/**
	 * @brief This function detects the video loss on a specified channel. 
	 *
	 * @param pVideoCap Specifies the correspounding video capture filter to get the result of the video loss detection.
	 * @param nChNum Specifies the channel ID number.
	 * @param pVideoLoss A point to to store the returned result of the video loss detection.
	 *
	 * @return If function succeeded, function returns ENC_SUCCEEDED.
     */
	virtual int DetectVideoLoss(IBaseFilter *pVideoCap, int nChNum, BOOL *pVideoLoss) PURE;
	
	/**
	 * @brief This function setups the video controller on a specified board.
	 *
	 * @param nBoardNum Specifies the board ID number.
	 * @param pVideoCap Specifies the video capture filter to setup the video controller.
	 * @param nMuxNum Specifies the mux ID number.
	 *					0 -- MUX0	1 -- MUX1	2 -- MUX2	3 -- MUX3	4 -- QUAD
	 *
	 * @return If function succeeded, function returns ENC_SUCCEEDED.
     */
	virtual int SetupVideoController(int nBoardNum, IBaseFilter *pVideoCap, int nMuxNum) PURE;

	/**
	 * @brief This function setups QUAD configuration of the video controller. 
	 *		  User can indicate which region displays which mux input and preview or playback mode of each mux input.
	 *
	 * @param nBoardNum Specifies the board ID number.
	 * @param pVideoCap Specifies the video capture filter to setup the video controller.
	 * @param Config Specifies the QUAD configuration. 
	 *
	 * @return If function succeeded, function returns ENC_SUCCEEDED.
     */
	virtual int SetupVideoControllerEx(int nBoardNum, IBaseFilter *pVideoCap, QuadConfig Config) PURE;
	
	/**
	 * @brief This function selects the audio input to preview. 
	 *
	 * @param pVideoCap Specifies the correspounding video capture filter to switch the audio input.
	 * @param nChNum Specifies the channel ID number.
	 *
	 * @return If function succeeded, function returns ENC_SUCCEEDED.
     */
	virtual int SelPreviewAudioInput(IBaseFilter *pVideoCap, int nChNum) PURE;
	
	/**
	 * @brief This function sets the video signal type for encoding.
	 *
	 * @param nChNum Specifies the channel ID number.
	 * @param pVideoCap Specifies the pointer of the Ph7134 source filter to setup the ADC.
	 * @param nSignalType A value to set the video signal type. (1: PAL, 2: NTSC)
	 *
	 * @return If function succeeded, function returns ENC_SUCCEEDED.
     */
	virtual int SetSignalType(int nChNum, IBaseFilter *pVideoCap, int nSignalType) PURE;

	/**
	 * @brief  This function sets the video MPEG standard for encoding.
	 *		   The sopported resolution are listed in the manual.
	 *
	 * @param nChNum Specifies the channel ID number.
	 * @param nMPEGType A value to set the video MPEG standard. (1: MPEG1, 2: MPEG2, 4: MPEG4)
	 * @param nVideoSize A value to set the video resolution.
	 *			  0 --  D1		1 -- VGA	2 -- QVGA	3 -- SIF	4 -- QCIF
	 *
	 * @return If function succeeded, function returns ENC_SUCCEEDED.
     */
	virtual int SetMPEGType(int nChNum, int nMPEGType, int nVideoSize) PURE;

	/**
	 * @brief This function sets the video brightness on a specified video input of the board.
	 *
	 * @param pVideoCap Specifies the video capture filter on the board to set the video brightness.
	 * @param nVInNum Specifies the video input ID number. The range is 0~3.
	 * @param nBrightness A value to set the video brightness on a specified video input of the board. The range is 0~255. (Default value is 128)
	 *
	 * @return If function succeeded, function returns ENC_SUCCEEDED.
	 */
	virtual int SetBrightness(IBaseFilter *pVideoCap, int nVInNum, int nBrightness) PURE;

	/**
	 * @brief This function gets the video brightness on a specified video input of the board.
	 *
	 * @param pVideoCap Specifies the video capture filter on the board to get the video brightness.
	 * @param nVInNum Specifies the video input ID number. The range is 0~3.
	 * @param pBrightness An integer pointer to store the returned video brightness on a specified video input of the board.
	 *
	 * @return If function succeeded, function returns ENC_SUCCEEDED.
	 */
	virtual int GetBrightness(IBaseFilter *pVideoCap, int nVInNum, int *pBrightness) PURE;

	/**
	 * @brief This function sets the video contrast on a specified video input of the board.
	 *
	 * @param pVideoCap Specifies the video capture filter on the board to set the video contrast.
	 * @param nVInNum Specifies the video input ID number. The range is 0~3.
	 * @param nContrast A value to set the video contrast on a specified video input of the board. The range is 0~255. (Default value is 128)
	 *
	 * @return If function succeeded, function returns ENC_SUCCEEDED.
	 */
	virtual int SetContrast(IBaseFilter *pVideoCap, int nVInNum, int nContrast) PURE;

	/**
	 * @brief This function gets the video contrast on a specified video input of the board.
	 *
	 * @param pVideoCap Specifies the video capture filter on the board to get the video contrast.
	 * @param nVInNum Specifies the video input ID number. The range is 0~3.
	 * @param pContrast An integer pointer to store the returned video contrast on a specified video input of the board.
	 *
	 * @return If function succeeded, function returns ENC_SUCCEEDED.
	 */
	virtual int GetContrast(IBaseFilter *pVideoCap, int nVInNum, int *pContrast) PURE;

	/**
	 * @brief This function sets the video color saturation on a specified video input of the board.
	 *
	 * @param pVideoCap Specifies the video capture filter on the board to set the video color saturation.
	 * @param nVInNum Specifies the video input ID number. The range is 0~3.
	 * @param nSaturation A value to set the video color saturation on a specified video input of the board. The range is 0~255. (Default value is 128)
	 *
	 * @return If function succeeded, function returns ENC_SUCCEEDED.
	 */
	virtual int SetSaturation(IBaseFilter *pVideoCap, int nVInNum, int nSaturation) PURE;

	/**
	 * @brief This function gets the video color saturation on a specified video input of the board.
	 *
	 * @param pVideoCap Specifies the video capture filter on the board to get the video color saturation.
	 * @param nVInNum Specifies the video input ID number. The range is 0~3.
	 * @param pSaturation An integer pointer to store the returned video color saturation on a specified video input of the board.
	 *
	 * @return If function succeeded, function returns ENC_SUCCEEDED.
	 */
	virtual int GetSaturation(IBaseFilter *pVideoCap, int nVInNum, int *pSaturation) PURE;

	/**
	 * @brief This function sets the video hue value on a specified video input of the board.
	 *
	 * @param pVideoCap Specifies the video capture filter on the board to set the video hue value.
	 * @param nVInNum Specifies the video input ID number. The range is 0~3.
	 * @param nHue A value to set the video hue value on a specified video input of the board. The range is 0~255. (Default value is 128)
	 *
	 * @return If function succeeded, function returns ENC_SUCCEEDED.
	 */
	virtual int SetHue(IBaseFilter *pVideoCap, int nVInNum, int nHue) PURE;

	/**
	 * @brief This function gets the video hue value on a specified video input of the board.
	 *
	 * @param pVideoCap Specifies the video capture filter on the board to get the video hue value.
	 * @param nVInNum Specifies the video input ID number. The range is 0~3.
	 * @param pHue An integer pointer to store the returned video hue value on a specified video input of the board.
	 *
	 * @return If function succeeded, function returns ENC_SUCCEEDED.
	 */
	virtual int GetHue(IBaseFilter *pVideoCap, int nVInNum, int *pHue) PURE;

	/**
	 * @brief This function sets the number of frames in a GOP and the frame distance between the reference frames on a specified channel.
	 *
	 * @param nChNum Specifies the channel ID number.
	 * @param nKeyFrameIntervals  A value to set the number of frames in a GOP. The range is 1~256. (Default value is 15)
	 * @param nRefFramesDistance A value to set the frame distance between the reference frames. The range is 0~3. (Default value is 3 for MPEG1 and MPEG2, is 1 for MPEG4) (MPEG4 does not support B-Frame)
	 *								0 -- The GOP structure is I (encoder will generate I frames only).
	 *								1 -- The GOP structure is IP.
	 *								2 -- The GOP structure is IBP.
	 *								3 -- The GOP structure is IBBP.
	 *
	 * @return If function succeeded, function returns ENC_SUCCEEDED.
	 */
	virtual int SetGOPType(int nChNum, int nKeyFrameIntervals, int nRefFramesDistance) PURE;

	/**
	 * @brief This function gets the number of frames in GOP and  the frame distance between the reference frames on a specified channel.
	 *
	 * @param nChNum Specifies the channel ID number.
	 * @param pKeyFrameIntervals  An integer pointer to store the returned number of frames in a GOP.
	 * @param pRefFramesDistance An integer pointer to store the returned frame distance.
	 *								0 -- The GOP structure is I (encoder will generate I frames only).
	 *								1 -- The GOP structure is IP.
	 *								2 -- The GOP structure is IBP.
	 *								3 -- The GOP structure is IBBP.
	 *
	 * @return If function succeeded, function returns ENC_SUCCEEDED.
	 */
	virtual int GetGOPType(int nChNum, int *pKeyFrameIntervals, int *pRefFramesDistance) PURE;

	/**
	 * @brief This function sets the frame rate and the minimum number of frames to skip on a specified channel.
	 *
	 * @param nChNum Specifies the channel ID number.
	 * @param nFrameRate A value to set the encoding frame rate. The range is 0~7. (Default value is 0)
	 *								0 -- NTSC2997fps
	 *								1 -- NTSC15fps
	 *								2 -- NTSC10fps
	 *								3 -- NTSC5fps
	 *								4 -- PAL25fps
	 *								5 -- PAL12fps
	 *								6 -- PAL8fps
	 *								7 -- PAL5fps
	 *
	 * @return If function succeeded, function returns ENC_SUCCEEDED.
	 */
	virtual int SetFrameRate(int nChNum, int nFrameRate) PURE;

	/**
	 * @brief This function gets the frame rate and the minimum number of frames to skip on a specified channel.
	 *
	 * @param nChNum Specifies the channel ID number.
	 * @param pFrameRate An integer pointer to store the returned encoding frame rate.
	 *								0 -- NTSC2997fps
	 *								1 -- NTSC15fps
	 *								2 -- NTSC10fps
	 *								3 -- NTSC5fps
	 *								4 -- PAL25fps
	 *								5 -- PAL12fps
	 *								6 -- PAL8fps
	 *								7 -- PAL5fps
	 *
	 * @return If function succeeded, function returns ENC_SUCCEEDED.
	 */
	virtual int GetFrameRate(int nChNum, int *pFrameRate) PURE;

	/**
	 * @brief This function sets the motion detect regions and the thresholds on a specified channel.
	 *
	 * @param nChNum Specifies the channel ID number.
	 * @param md_regions A value to set the regions of the motion detection of a specified channel.
	 * @param nThresholds A value to set the motion vector thresholds of corresponding regions of a specified channel.
	 *
	 * @return If function succeeded, function returns ENC_SUCCEEDED.
     */
	virtual int InsertMotionDetectMask(int nChNum, MDRegion md_regions[], int nThresholds[]) PURE;

	/**
	 * @brief This function gets the motion detect regions and thresholds on a specified channel.
	 *
	 * @param nChNum Specifies the channel ID number.
	 * @param md_regions A structure pointer to store the returned regions of the motion detection of a specified channel.
	 * @param nThresholds A structure pointer to store the returned motion vector thresholds of corresponding regions of a specified channel.
	 *
	 * @return If function succeeded, function returns ENC_SUCCEEDED.
     */
	virtual int GetMotionDetectMask(int nChNum, MDRegion md_regions[], int nThresholds[]) PURE;

	/**
	 * @brief This function sets the bit rate of the video stream on a specified channel.
	 *		  The constant bit rate is used when nBitRate equals nAvgBitRate.
	 *
	 * @param nChNum Specifies the channel ID number.
	 * @param nBitRate A value to set maximum bit rate of specified channel. The range is 128 kbps~15 Mbps. (Default value is 4 Mbps)
	 *				  The suggested video bit rate is from 1.5 Mbps to 15 Mbps for 1/2 D1 and above.
	 *				  The suggested video bit rate is from 512 kbps to 15 Mbps for SIF.
	 *				  The suggested video bit rate is from 128 kbps to 15 Mbps for QCIF.
	 * @param nAvgBitRate A value to set average bit rate of specified channel. The range is 128 kbps~9 Mbps. (Default value is 3.5 Mbps for PS, 3Mbps for TS)
	 *
	 * @return If function succeeded, function returns ENC_SUCCEEDED.
     */
	virtual int SetVideoBitrate(int nChNum, int nBitRate, int nAvgBitRate) PURE;

	/**
	 * @brief This function gets the bit rate of the video stream on a specified channel.
	 *
	 * @param nChNum Specifies the channel ID number.
	 * @param pBitRate An integer pointer to store the returned maximum bit rate of specified channel.
	 * @param pAvgBitRate An integer pointer to store the returned average bit rate of specified channel.
	 *
	 * @return If function succeeded, function returns ENC_SUCCEEDED.
     */
	virtual int GetVideoBitrate(int nChNum, int *pBitRate, int *pAvgBitRate) PURE;

	/**
	 * @brief This function sets the bit rate of the audio stream on a specified channel.
	 *
	 * @param nChNum Specifies the channel ID number.
	 * @param nBitRate A value to set bit rate of the audio stream on a specified channel. The range is 0 ~ 13. (Default value is 7 (128 kbps))
	 *					  0 --  0 kbps		1 --  32 kbps	2  -- 48 kbps	3  -- 56 kbps	4  -- 64 kbps
	 *					  5 --  80 kbps		6  -- 96 kbps	7  -- 112 kbps	8  -- 128 kbps
	 *					  9 --  160 kbps	10  -- 192 kbps	11 -- 224 kbps	12 -- 256 kbps
	 *					  13 -- 320 kbps	14 -- 384 kbps
	 *
	 * @return If function succeeded, function returns ENC_SUCCEEDED.
     */
	virtual int SetAudioBitrate(int nChNum, int nBitRate) PURE;

	/**
	 * @brief This function gets the bit rate of the audio stream on a specified channel.
	 *
	 * @param nChNum Specifies the channel ID number.
	 * @param pBitRate An integer pointer to store the returned bit rate of the audio stream on a specified channel.
	 *					  0 --  0 kbps		1 --  32 kbps	2  -- 48 kbps	3  -- 56 kbps	4  -- 64 kbps
	 *					  5 --  80 kbps		6  -- 96 kbps	7  -- 112 kbps	8  -- 128 kbps
	 *					  9 --  160 kbps	10  -- 192 kbps	11 -- 224 kbps	12 -- 256 kbps
	 *					  13 -- 320 kbps	14 -- 384 kbps
	 *
	 * @return If function succeeded, function returns ENC_SUCCEEDED.
     */
	virtual int GetAudioBitrate(int nChNum, int *pBitRate) PURE;

	/**
	 * @brief This function sets the sampling rate of the audio stream on a specified channel.
	 *
	 * @param nChNum Specifies the channel ID number.
	 * @param nSamplingRate A value to set sampling rate of the audio stream on a specified channel. The range is 0 ~ 2. (Default value is 2 (48 KHz))
	 *					  0 --  32 KHz		1 --  44.1 KHz	2  -- 48 KHz
	 *
	 * @return If function succeeded, function returns ENC_SUCCEEDED.
     */
	virtual int SetAudioSamplingRate(int nChNum, int nSamplingRate) PURE;

	/**
	 * @brief This function gets the sampling rate of the audio stream on a specified channel.
	 *
	 * @param nChNum Specifies the channel ID number.
	 * @param pSamplingRate An integer pointer to store the returned sampling rate of the audio stream on a specified channel.
	 *					  0 --  32 KHz		1 --  44.1 KHz	2  -- 48 KHz
	 *
	 * @return If function succeeded, function returns ENC_SUCCEEDED.
     */
	virtual int GetAudioSamplingRate(int nChNum, int *pSamplingRate) PURE;
	
	/**
	 * @brief This function gets the reporting of video multiplexing status.
	 *
	 * @param nChNum Specifies the video channel ID number.
	 * @param StreamInfo A STREAM_INFO array stores the information of the encoded video stream.
	 * @param nFrameCnt Specifies the number of frames in the stream buffer.
	 *
	 * @return If function succeeded, function returns ENC_SUCCEEDED.
	 */
	virtual int GetVideoMuxStatus(int nChNum, STREAM_INFO StreamInfo[], int *npFrameCnt) PURE;
	
	/**
	 * @brief This function sets the value of the specified digital output. The second chip of the board controls the GPIO, 
	 *		  thus must to initialize the chip and download the firmware into the chip before controlling GIPO.
	 *
	 * @param nBoardNum Specifies the baord ID number.
	 * @param nDONum Specifies the digital output number.
	 * @param bValue A value to set the value of the specified digital output.
	 *
	 * @return If function succeeded, function returns ENC_SUCCEEDED.
     */
	virtual int GPIOSetData(int nBoardNum, int nDONum, BOOL bValue) PURE;

	/**
	 * @brief This function gets the value of the specified digital input. The second chip of the board controls the GPIO, 
	 *		  thus must to initialize the chip and download the firmware into the chip before controlling GIPO.
	 *
	 * @param nBoardNum Specifies the baord ID number.
	 * @param nDINum Specifies the digital input number.
	 * @param pValue A point to get the value of the specified digital input.
	 *
	 * @return If function succeeded, function returns ENC_SUCCEEDED.
     */
	virtual int GPIOGetData(int nBoardNum, int nDINum, BOOL* pValue) PURE;

	/**
	 * @brief  This function writes the value at a specified address to EEPRom. 
	 *
	 * @param pVideoCap Specifies the video capture filter to write the value to EEPRom.
	 * @param nAddr Address to write a value from EEPRom ranging from 0 to 127.
	 * @param nData  A BYTE value being written to EEPRom.
	 *
	 * @return If function succeeded, function returns ENC_SUCCEEDED.
     */
	virtual int SetEEData(IBaseFilter *pVideoCap, BYTE nAddr, BYTE nData) PURE;

	/**
	 * @brief  This function reads the value at a specified address from EEPRom. 
	 *
	 * @param pVideoCap Specifies the video capture filter to read the value from EEPRom.
	 * @param nAddr Address to read a value from EEPRom ranging from 0 to 127.
	 * @param nData  A BYTE pointer to the byte value stored in EEPRom.
	 *
	 * @return If function succeeded, function returns ENC_SUCCEEDED.
     */
	virtual int GetEEData(IBaseFilter *pVideoCap, BYTE nAddr, BYTE *npData) PURE;

	/**
	 * @brief This function registers the StreamRead callback functions.
	 *
	 * @param pStreamRead A STREAMREAD_STRUCT structure pointer to set the StreamRead callback functions.
	 *
	 * @return If function succeeded, function returns ENC_SUCCEEDED.
     */
	virtual int RegStreamReadCB(STREAMREAD_STRUCT *pStreamRead) PURE;

	/**
	 * @brief This function registers the MotionDetect callback function.
	 *
	 * @param pMotionDetect A function pointer of the MotionDetect callback function.
	 *
	 * @return If function succeeded, function returns ENC_SUCCEEDED.
     */
	virtual int RegMotionDetectCB(PMOTIONDETECTPROC pMotionDetect) PURE;

	/**
	 * @brief This function registers the EncFail callback function.
	 *
	 * @param pEncFail A function pointer of the EncFail callback function.
	 *
	 * @return If function succeeded, function returns ENC_SUCCEEDED.
     */
	virtual int RegEncFailCB(PENCFAILPROC pEncFail) PURE;

	/**
	 * @brief This function converts the MPEG4 video file to the divx format video file.
	 *
	 * @param src_filename A string for the MPEG4 video file name.
	 * @param des_filename A string for the divx format file name.
	 *
	 * @return If function succeeded, function returns ENC_SUCCEEDED.
     */
	virtual int PSMPEG4ToDivx(char *src_filename, char *des_filename) PURE;

	/**
	 * @brief This function detects if the specified video file is MPEG4 video type.
	 *
	 * @param mpegfilename A NULL-terminated string for the MPEG video file name.
	 *
	 * @return If the specified video file is MPEG4 video type, the function returns TRUE. Otherwise. it returns FALSE.
     */
	virtual BOOL IsPSMPEG4Type(char *mpegfilename) PURE;
};

Open in new window

0
Comment
Question by:rickyp123
  • 2
  • 2
4 Comments
 
LVL 8

Accepted Solution

by:
cubaman_24 earned 500 total points
Comment Utility
Hello:
Well, you can start reading about PINvoke.
http://msdn.microsoft.com/en-us/magazine/cc164123.aspx
Here are some useful tools too:
http://www.paulyao.com/res/pinvoke/pinvoke.aspx
http://www.codeproject.com/KB/dotnet/SimplifyNativeDLLDocument.aspx
And many examples of native win functions:
http://pinvoke.net/index.aspx

Good luck!
0
 
LVL 8

Expert Comment

by:cubaman_24
Comment Utility
What the heck, here you have it!  Have a beer in my name ;)

Happy coding!
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;

namespace PInvoke
{
    class MyInteropClass
    {
        public const int ENCSDK_API = dllexport;
        public const int ENCSDK_API = dllimport;
        public enum EncRes
        {
            ENC_SUCCEEDED		= 1,
            ENC_FAILED			= 0,
            ENC_SDKINITFAILED	= -1,
            ENC_DEVINITFAILED	= -2,
            ENC_INITADFAILED	= -3,
            ENC_PARAMERROR		= -4,
            ENC_CHNUMERROR		= -5,
        };

        [StructLayout(LayoutKind.Sequential,Pack=4)]
        public struct STREAM_INFO
        {
            public uint picture_type;
            public uint byte_offset;
            public uint ptsh;
            public uint ptsl;
        };

        [StructLayout(LayoutKind.Sequential,Pack=4)]
        public struct STREAMREAD_STRUCT
        {
            public void (*PSTREAMREADOPEN)(int nChNum);
            public void (*PSTREAMREADPROC)(int nChNum, BYTE pStreamBuf, UINT32 nBufSize);
            public void (*PSTREAMREADCLOSE)(int nChNum);
        };

        [StructLayout(LayoutKind.Sequential,Pack=4)]
        public struct MDRegion
        {
            public int enable;
            public int left;
            public int right;
            public int top;
            public int bottom;
        };

        [DllImport("imanufacturer.dll")]
        public static extern {public: CreateEncSDKInstence (ref IntPtr pp);

        [DllImport("imanufacturer.dll")]
        public static extern virtual ReleaseEncSDKInstence (ref IntPtr p);

        [DllImport("imanufacturer.dll")]
        public static extern virtual InitSDK (ref IBaseFilter [] pVideoCap);

        [DllImport("imanufacturer.dll")]
        public static extern virtual CloseSDK ();

        [DllImport("imanufacturer.dll")]
        public static extern virtual InitChips (int nChNum);

        [DllImport("imanufacturer.dll")]
        public static extern virtual ReleaseChips (int nChNum);

        [DllImport("imanufacturer.dll")]
        public static extern virtual DownloadFW (int nChNum);

        [DllImport("imanufacturer.dll")]
        public static extern virtual GetChipCount (ref int pChipCnt);

        [DllImport("imanufacturer.dll")]
        public static extern virtual SetBoardID (int nChNum);

        [DllImport("imanufacturer.dll")]
        public static extern virtual GetBoardID (ref IBaseFilter pVideoCap, ref int nBoardID);

        [DllImport("imanufacturer.dll")]
        public static extern virtual GetSDKVersion (ref byte pMaj, ref byte pMin, ref byte pRev);

        [DllImport("imanufacturer.dll")]
        public static extern virtual StartEncode (int nChNum);

        [DllImport("imanufacturer.dll")]
        public static extern virtual StopEncode (int nChNum);

        [DllImport("imanufacturer.dll")]
        public static extern virtual StartMotionDetect (int nChNum);

        [DllImport("imanufacturer.dll")]
        public static extern virtual StopMotionDetect (int nChNum);

        [DllImport("imanufacturer.dll")]
        public static extern virtual DetectVideoLoss (ref IBaseFilter pVideoCap, int nChNum, ref int pVideoLoss);

        [DllImport("imanufacturer.dll")]
        public static extern virtual SetupVideoController (int nBoardNum, ref IBaseFilter pVideoCap, int nMuxNum);

        [DllImport("imanufacturer.dll")]
        public static extern virtual SetupVideoControllerEx (int nBoardNum, ref IBaseFilter pVideoCap, QuadConfig Config);

        [DllImport("imanufacturer.dll")]
        public static extern virtual SelPreviewAudioInput (ref IBaseFilter pVideoCap, int nChNum);

        [DllImport("imanufacturer.dll")]
        public static extern virtual SetSignalType (int nChNum, ref IBaseFilter pVideoCap, int nSignalType);

        [DllImport("imanufacturer.dll")]
        public static extern virtual SetMPEGType (int nChNum, int nMPEGType, int nVideoSize);

        [DllImport("imanufacturer.dll")]
        public static extern virtual SetBrightness (ref IBaseFilter pVideoCap, int nVInNum, int nBrightness);

        [DllImport("imanufacturer.dll")]
        public static extern virtual GetBrightness (ref IBaseFilter pVideoCap, int nVInNum, ref int pBrightness);

        [DllImport("imanufacturer.dll")]
        public static extern virtual SetContrast (ref IBaseFilter pVideoCap, int nVInNum, int nContrast);

        [DllImport("imanufacturer.dll")]
        public static extern virtual GetContrast (ref IBaseFilter pVideoCap, int nVInNum, ref int pContrast);

        [DllImport("imanufacturer.dll")]
        public static extern virtual SetSaturation (ref IBaseFilter pVideoCap, int nVInNum, int nSaturation);

        [DllImport("imanufacturer.dll")]
        public static extern virtual GetSaturation (ref IBaseFilter pVideoCap, int nVInNum, ref int pSaturation);

        [DllImport("imanufacturer.dll")]
        public static extern virtual SetHue (ref IBaseFilter pVideoCap, int nVInNum, int nHue);

        [DllImport("imanufacturer.dll")]
        public static extern virtual GetHue (ref IBaseFilter pVideoCap, int nVInNum, ref int pHue);

        [DllImport("imanufacturer.dll")]
        public static extern virtual SetGOPType (int nChNum, int nKeyFrameIntervals, int nRefFramesDistance);

        [DllImport("imanufacturer.dll")]
        public static extern virtual GetGOPType (int nChNum, ref int pKeyFrameIntervals, ref int pRefFramesDistance);

        [DllImport("imanufacturer.dll")]
        public static extern virtual SetFrameRate (int nChNum, int nFrameRate);

        [DllImport("imanufacturer.dll")]
        public static extern virtual GetFrameRate (int nChNum, ref int pFrameRate);

        [DllImport("imanufacturer.dll")]
        public static extern virtual InsertMotionDetectMask (int nChNum, MDRegion [] md_regions, int [] nThresholds);

        [DllImport("imanufacturer.dll")]
        public static extern virtual GetMotionDetectMask (int nChNum, MDRegion [] md_regions, int [] nThresholds);

        [DllImport("imanufacturer.dll")]
        public static extern virtual SetVideoBitrate (int nChNum, int nBitRate, int nAvgBitRate);

        [DllImport("imanufacturer.dll")]
        public static extern virtual GetVideoBitrate (int nChNum, ref int pBitRate, ref int pAvgBitRate);

        [DllImport("imanufacturer.dll")]
        public static extern virtual SetAudioBitrate (int nChNum, int nBitRate);

        [DllImport("imanufacturer.dll")]
        public static extern virtual GetAudioBitrate (int nChNum, ref int pBitRate);

        [DllImport("imanufacturer.dll")]
        public static extern virtual SetAudioSamplingRate (int nChNum, int nSamplingRate);

        [DllImport("imanufacturer.dll")]
        public static extern virtual GetAudioSamplingRate (int nChNum, ref int pSamplingRate);

        [DllImport("imanufacturer.dll")]
        public static extern virtual GetVideoMuxStatus (int nChNum, STREAM_INFO [] StreamInfo, ref int npFrameCnt);

        [DllImport("imanufacturer.dll")]
        public static extern virtual GPIOSetData (int nBoardNum, int nDONum, int bValue);

        [DllImport("imanufacturer.dll")]
        public static extern virtual GPIOGetData (int nBoardNum, int nDINum, ref int pValue);

        [DllImport("imanufacturer.dll")]
        public static extern virtual SetEEData (ref IBaseFilter pVideoCap, byte nAddr, byte nData);

        [DllImport("imanufacturer.dll")]
        public static extern virtual GetEEData (ref IBaseFilter pVideoCap, byte nAddr, ref byte npData);

        [DllImport("imanufacturer.dll")]
        public static extern virtual RegStreamReadCB (ref STREAMREAD_STRUCT pStreamRead);

        [DllImport("imanufacturer.dll")]
        public static extern virtual RegMotionDetectCB (PMOTIONDETECTPROC pMotionDetect);

        [DllImport("imanufacturer.dll")]
        public static extern virtual RegEncFailCB (PENCFAILPROC pEncFail);

        [DllImport("imanufacturer.dll")]
        public static extern virtual PSMPEG4ToDivx (ref sbyte src_filename, ref sbyte des_filename);

        [DllImport("imanufacturer.dll")]
        public static extern virtual IsPSMPEG4Type (ref sbyte mpegfilename);

    }
}

Open in new window

0
 

Author Comment

by:rickyp123
Comment Utility
WOW! Thank you for the awesome reply! I am going to test this in my machine and see what I can do with it.
0
 

Author Closing Comment

by:rickyp123
Comment Utility
This was able to get me on the right path.
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now