123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- #pragma once
- #include "SpBase.h"
- #pragma comment(lib,"Strmiids.lib")
- #include "EventRevWnd.h"
- #include <vector>
- #include <algorithm>
- #define SAFE_RELEASE_IDEV(hd) \
- do { \
- if(hd != NULL) { \
- hd->Release(); \
- hd = NULL; \
- } \
- } while (false)
- typedef struct _CAMERA_INFOR_ITEM
- {
- char szDevName[MAX_PATH];
- char szCLSID[MAX_PATH];
- char szDevPath[MAX_PATH];
- LONG uWaveInID;
- void Cleanup() {
- uWaveInID = 0;
- memset(szDevName, 0, sizeof(szDevName));
- memset(szCLSID, 0, sizeof(szCLSID));
- memset(szDevPath, 0, sizeof(szDevPath));
- }
- void Copy(struct _CAMERA_INFOR_ITEM* prhs) {
- if(prhs != NULL) {
- uWaveInID = prhs->uWaveInID;
- strcpy_s(szDevPath, MAX_PATH, prhs->szDevPath);
- strcpy_s(szDevName, MAX_PATH, prhs->szDevName);
- strcpy_s(szCLSID, MAX_PATH, prhs->szCLSID);
- }
- }
- void Display() {
- Dbg("[%ld]%s(%s)",uWaveInID, szDevName, szDevPath);
- Dbg("CLSID:%s", szCLSID);
- }
- } CAMERA_INFOR_ITEM, *PCAMERA_INFOR_ITEM;
- static int WrapW2A(VARIANT& varirant, char* szDst, const size_t maxLen) {
- int count = 0;
- while (varirant.bstrVal[count] != 0x00 && count < maxLen) {
- szDst[count] = (char)varirant.bstrVal[count];
- count++;
- }
- return count;
- /*
- USES_CONVERSION;
- lptstrValue = W2T(Value.bstrVal);
- */
- }
- typedef std::vector<PCAMERA_INFOR_ITEM> CAMERA_BUCKET;
- typedef CAMERA_BUCKET::const_iterator CAMERA_BUCKET_CITER;
- typedef CAMERA_BUCKET::iterator CAMERA_BUCKET_ITER;
- static void DestoryCamereBuckets(CAMERA_BUCKET& vtCameras)
- {
- if(!vtCameras.empty()) {
- for(CAMERA_BUCKET_ITER it=vtCameras.begin(); it!=vtCameras.end(); ++it) {
- if(*it) {
- delete (*it);
- (*it) = NULL;
- }
- }
- vtCameras.clear();
- }
- }
- // return the origin old count of video devices.
- int UpdateCameraInfors(CAMERA_BUCKET& vtCameraList);
- // return the count of video devices existed for now.
- int GetCameraInfors(CAMERA_BUCKET& vtCameraList);
- void DisplayCameraInfos(const CAMERA_BUCKET& vtCameraList);
- int GetCameraCount();
- // returned value:
- // -2:inner error; -1:not founed; 0:idle; 1:busy
- int IsDeviceBusy(const char* lpcszDeviceName);
- // Copy from 35's libvideoframework interface,
- // return -1 means failed or no existed.
- // param lpDevCombinedName indicated video identifier from root.ini which contains ';' character.
- int GetVideoDeviceID(LPCTSTR lpDevCombinedName);
- // condition: lhs contains rhs or rhs contains lhs, use size() to judge which is more wider
- // return the diff elements
- int ExclusiveCameraBuckes(const CAMERA_BUCKET& lhs, const CAMERA_BUCKET& rhs, CAMERA_BUCKET& diff);
|