nchannon
asked on
How Do I access a pointer from one class to another class
In my MFC project I have two classes first class is called LoadDrivers and the second class is called OvrControl. In the class LoadDrivers I have a pointer assigned called IOvr5* m_OvrApi; when the driver loads the pointer m_OvrApi is loaded into memory and allows access to functions in IOvr5 API. What I want to be able to do is access this pointer m_OvrApi after it has loaded from within the class LoadDrivers by the other class called OvrControl
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Can I just augment and state that given out a pointer from the inner workings of a class is seriously against the principle of encapsulation, since this pointer might allow something external to the class make changes that inadvertently affect the inner workings of the class. To this end I would strongly suggest you return a const pointer so that you can then only use the pointer in a non-mutable way.
IOvr5 const * OvrControl::GetOvrControl( ) const
{
  return m_loaddrivers.GetIOvr5();
}
This will, of course, necessitate you ensure all your code is const correct, but you should be doing this away.
http://www.parashift.com/c++-faq-lite/const-correctness.html
IOvr5 const * OvrControl::GetOvrControl(
{
  return m_loaddrivers.GetIOvr5();
}
This will, of course, necessitate you ensure all your code is const correct, but you should be doing this away.
http://www.parashift.com/c++-faq-lite/const-correctness.html
ASKER
Hi I am not to sure how to code both classes for this to work for the class LoadDriver how would i code a helper function GetIOvr5()  I have uploaded my project source at http://80.249.255.6:8080/PythonDVR.zip would it be posibile if you add the code functions to both LoadDriver and OvrControl so I can see how it is done once I see it I then will understand how it works thanks in advanced
>> how would i code a helper function GetIOvr5() Â
Did you not look at the example given by DeepuAbrahamK? It seemed pretty clear to me. What don't you understand about this? If you can clarify we can explain better if necessary. I, for one, am reluctant to download and unzip unknown files to then add code (but then I do work for an anti-virus company so I am paranoid :) ).
Did you not look at the example given by DeepuAbrahamK? It seemed pretty clear to me. What don't you understand about this? If you can clarify we can explain better if necessary. I, for one, am reluctant to download and unzip unknown files to then add code (but then I do work for an anti-virus company so I am paranoid :) ).
ASKER
Hi Yes i tried the sample but I didnt get it to work so im doing something wrong I understand your issues downloading unknowen files so ill attach my code as a snipit if you could have a look and make the changes I would be very greatfull and then I will understand what has been explained to me.
You can see in the snipit OvrControl.cpp the function CreateOverlay() I am trying to access the pointer m_OvrApi that has been loaded from LoadDriver.cpp from function DriverSelect() but I get Unhandeled exception 0xC0000005: Access violation reading location 0x00000000 error in OvrControl line rs = Â m_LoadDriver.m_OvrApi->Ovr 5Setup();
You can see in the snipit OvrControl.cpp the function CreateOverlay() I am trying to access the pointer m_OvrApi that has been loaded from LoadDriver.cpp from function DriverSelect() but I get Unhandeled exception 0xC0000005: Access violation reading location 0x00000000 error in OvrControl line rs = Â m_LoadDriver.m_OvrApi->Ovr
//LoadDriver.h
#pragma once
struct UDA5GlobAPI{
BOOL (__stdcall *Cmn5CreateInstance)(IUnknown **pCaptureCard);
};
class CLoadDrivers
{
public:
CLoadDrivers();
virtual ~CLoadDrivers();
CMN5_SYSTEM_INFO m_SysInfo;
UDA5GlobAPI m_Uda5Api;
HMODULE hModuleMP;
HRESULT hr;
IOvr5* m_OvrApi;
OVR5_BOARD_INFO* m_pOvrBoardInfo;
void DriverSelect();
};
//LoadDriver.cpp
void CLoadDrivers::DriverSelect()
{
BOOL rs;
hModuleMP = LoadLibrary("ECPSV.dll"); //ECRP Capture board Driver
*(FARPROC*)&m_Uda5Api.Cmn5CreateInstance = GetProcAddress(hModuleMP,"Cmn5CreateInstance");
IUnknown * pCaptureCard;
m_Uda5Api.Cmn5CreateInstance(&pCaptureCard);
hr = pCaptureCard->QueryInterface (IID_IOvr5,(void**)&m_OvrApi);
rs = m_OvrApi->Ovr5GetSystemInfo(&m_SysInfo);
if(!rs)TRACE("No Capture Cards Drivers Installed!\n\r");
if(rs)TRACE("Capture Cards Drivers Installed!\n\r");
m_pOvrBoardInfo = new OVR5_BOARD_INFO[m_SysInfo.uNumOfBoard];
CMN5_BOARD_INFO_DESC desc = {sizeof(OVR5_BOARD_INFO),1,0,};
for(int i=0;i<(signed)m_SysInfo.uNumOfBoard;i++) {
m_OvrApi->Ovr5GetBoardInfo(i,&desc,&m_pOvrBoardInfo [i]);
getSN.GetActCodefromModelID(m_pOvrBoardInfo[i].uModelID,actual);
rs = m_OvrApi->Ovr5Activate(0,actual);
if(!rs) TRACE("Activation Failed %d\r",i);
if(rs) TRACE("Activation Passed %d\r",i);
}
TRACE("Number of Boards %d\r",m_SysInfo.uNumOfBoard);
pCaptureCard->Release();
}
//OvrControl.h
#pragma once
// COvrControl
class COvrControl : public CWnd
{
DECLARE_DYNAMIC(COvrControl)
public:
COvrControl();
virtual ~COvrControl();
void CreateOverlay();
protected:
DECLARE_MESSAGE_MAP()
};
//OvrControl.cpp
#include "stdafx.h"
#include "PythonDVR.h"
#include "OvrControl.h"
#include "LoadDrivers.h"
// COvrControl
CLoadDrivers m_LoadDriver;
IMPLEMENT_DYNAMIC(COvrControl, CWnd)
COvrControl::COvrControl()
{
}
COvrControl::~COvrControl()
{
}
BEGIN_MESSAGE_MAP(COvrControl, CWnd)
END_MESSAGE_MAP()
// COvrControl message handlers
void COvrControl::CreateOverlay()
{
BOOL rs;
TRACE("Overlay Started\r");
rs = m_LoadDriver.m_OvrApi->Ovr5Setup(); // want to access the pointer m_OvrApi loaded from LoadDrivers here
if(!rs) TRACE("OvrSetup Failed\n\r");
if(rs) TRACE("OvrSetup Passed\n\r");
}
>> Â Access violation reading location 0x00000000 error in Â
>>Â OvrControl line rs = Â m_LoadDriver.m_OvrApi->Ovr 5Setup();
This suggests that the pointer m_LoadDriver.m_OvrApi is not valid at the time of your call.
>>Â OvrControl line rs = Â m_LoadDriver.m_OvrApi->Ovr
This suggests that the pointer m_LoadDriver.m_OvrApi is not valid at the time of your call.
^^^ I can see nothing in the code snippet that ever initializes m_OvrApi. Where and when is this done?
ASKER
yes I know that so how do I make it valid when I call it this is what i am unsure onhow to do
>> yes I know that so how do I make it valid when I call it this is what i am unsure onhow to do
Well, you need to make sure that what ever code initializes this pointer is executed before it's used (I assume you know what code this is?). If you cannot guarantee this you need to add protection to your code to ensure you don't try and dereference it -- a NULL pointer check.
Well, you need to make sure that what ever code initializes this pointer is executed before it's used (I assume you know what code this is?). If you cannot guarantee this you need to add protection to your code to ensure you don't try and dereference it -- a NULL pointer check.
ASKER
m_OvrApi is nitialized in LoadDriver.cpp function DriverSelect() this works fine but when I want to also access m_OvrApi from the class OvrControl function CreateOverlay() this is were my problem is I need to know how to access m_OvrApi from OvrControl can you show how to do this from my snipit
The problem isn't accessing since you are now doing that -- the problem is that you trying to access it when it's not initialized. You need to ensure that DriverSelect() is called before you try to dereference m_OvrApi otherwise it'll point to invalid memory and that is exactly what's happening here. Part of the problem is that of poor encapsulation. Since m_OvrApi is a data member of LoadDriver it should be private and only accessible by friends of LoadDriver or via an accessor (as you were shown above). The accessor can then check m_OvrApi and either throw an exception if it isn't initialized or explicitly initialize it before returning it.
IOvr5 const * LoadDriver::GetOvrControl( ) const
{
  // Throw an exception
  if(!m_OvrApi ) { throw std::runtime_error("not initialized"); }
  -- or --
  // Explicitly initialize if it's not already been done (this might be dangerous though!)
  if(!m_OvrApi ) { DriverSelect(); }
  return m_OvrApi;
}
http://www.parashift.com/c++-faq-lite/friends.html
IOvr5 const * LoadDriver::GetOvrControl(
{
  // Throw an exception
  if(!m_OvrApi ) { throw std::runtime_error("not initialized"); }
  -- or --
  // Explicitly initialize if it's not already been done (this might be dangerous though!)
  if(!m_OvrApi ) { DriverSelect(); }
  return m_OvrApi;
}
http://www.parashift.com/c++-faq-lite/friends.html
ASKER
Sorry tim really not getting this could you please add the addtional code to the snipit I sent then I can see what im doing wrong
>> Sorry tim really not getting this
What don't you get?
>>Â could you please add the addtional code to the snipit I sent
All you have to do is add this code... it's pretty simple, if you are skilled enough to be able to work with this code I'm suprised you are not able to do this. Can you clarify, is this some kind of assignment?
>>Â then I can see what im doing wrong
I'm pretty certain I've explained this to you quite clearly and adding code to yours isn't going to make it any clearer. EE isn't a code writing service, we will help you to solve problems but in th end you have to understand otherwise you'll just be back again in a short time.. it also doesn't help the PAQ database if I just fix your code without explaining what's wrong.
Please tell us what you don't get and I'll be happy to explain more if necessary.
What don't you get?
>>Â could you please add the addtional code to the snipit I sent
All you have to do is add this code... it's pretty simple, if you are skilled enough to be able to work with this code I'm suprised you are not able to do this. Can you clarify, is this some kind of assignment?
>>Â then I can see what im doing wrong
I'm pretty certain I've explained this to you quite clearly and adding code to yours isn't going to make it any clearer. EE isn't a code writing service, we will help you to solve problems but in th end you have to understand otherwise you'll just be back again in a short time.. it also doesn't help the PAQ database if I just fix your code without explaining what's wrong.
Please tell us what you don't get and I'll be happy to explain more if necessary.
Take a look at the example code below... it models your problem. See if you can understand it -- if you can then you should be able to modify your own code to suit.
class CBar
{
public:
void doit() const {}; // Just do anything :)
};
class CFoo
{
public:
CFoo(): m_pBar(0){} // To start m_pBar is set to point to NULL (0)
~CFoo() { delete m_pBar; } // Clean up after outselves
// Return a const pointer to prevent tampering (doesn't have to be but advisable)
CBar const * get()
{
if(!m_pBar) { init(); } // Init m_pBar if it's not already
return m_pBar;
}
void init()
{
delete m_pBar; // Ensure we don't overwrite any previous allocation
m_pBar = new CBar;
}
private:
CBar * m_pBar;
};
int main()
{
CFoo foo;
foo.get()->doit();}
ASKER
Ok I try to work though the CBar sample so Class CBar would be same as my class CLoadDrivers() and void doit() same as void DriverSelect()
>> Ok I try to work though the CBar sample
Good plan :)
>>Â Class CBar would be same as my class CLoadDrivers() and void doit() same as void DriverSelect()
No :)
CFoo == CLoadDrivers
CBar == COvrApi
foo.get() == m_LoadDriver.m_OvrApi
doit() == m_LoadDriver.m_OvrApi->Ovr 5Setup();
Compare...
foo.get()->doit();
m_LoadDriver.m_OvrApi->Ovr 5Setup();
Make sense?
Good plan :)
>>Â Class CBar would be same as my class CLoadDrivers() and void doit() same as void DriverSelect()
No :)
CFoo == CLoadDrivers
CBar == COvrApi
foo.get() == m_LoadDriver.m_OvrApi
doit() == m_LoadDriver.m_OvrApi->Ovr
Compare...
foo.get()->doit();
m_LoadDriver.m_OvrApi->Ovr
Make sense?
If you are having any Construction Order Issues, then use the following process
class ObjectConstructionFactory
{
public:
      virtual void Create( ) = 0 ;
}
class OvrControl : public ObjectConstructionFactory
{ Â Â Â Â Â //Constructors Omitted
      public:
      void Create( ) //Customized Construction
      {
      }
}
class LoadDrivers : public ObjectConstructionFactory
{ Â Â Â Â Â //Constructors Omitted
      private:
      IOvr5 * m_OvrApi ;
      public:
      void Create( ) //Customized Construction
      {
           m_OvrApi = new IOvr5 ;
      }
} ;
void main( )
{
      int nObjects = 2 ; //Number of Objects
      OvrControl *pOvr = new OvrControl ;
      LoadDrivers *pDrvr = new LoadDrivers ;
      ObjectConstructionFactory *pObjects[ ] = { pOvr, pDrvr } ;
      for ( int i = 0 ; i < nObjects ; i++ )
      {
           pObjects ->Create( ) ;     Â
      }
}
class ObjectConstructionFactory
{
public:
      virtual void Create( ) = 0 ;
}
class OvrControl : public ObjectConstructionFactory
{ Â Â Â Â Â //Constructors Omitted
      public:
      void Create( ) //Customized Construction
      {
      }
}
class LoadDrivers : public ObjectConstructionFactory
{ Â Â Â Â Â //Constructors Omitted
      private:
      IOvr5 * m_OvrApi ;
      public:
      void Create( ) //Customized Construction
      {
           m_OvrApi = new IOvr5 ;
      }
} ;
void main( )
{
      int nObjects = 2 ; //Number of Objects
      OvrControl *pOvr = new OvrControl ;
      LoadDrivers *pDrvr = new LoadDrivers ;
      ObjectConstructionFactory *pObjects[ ] = { pOvr, pDrvr } ;
      for ( int i = 0 ; i < nObjects ; i++ )
      {
           pObjects ->Create( ) ;     Â
      }
}
ASKER
Ok Cbar == COvrControl
void doit() == void COvrControl::CreateOverlay ()
foo.get() == m_LoadDriver.m_OvrApi  ** This needs to get called from the function CreateOverlay()**
but the problem I think is OvrSetup() is not a function decleared in CloadDrivers but a API call that is part of IOvr5* m_OvrApi; decleared in CLoadDrivers what you have written abouve makes total sense if I was trying to call a function decleared in CLoadDrivers from CreateOverlay()
void doit() == void COvrControl::CreateOverlay
foo.get() == m_LoadDriver.m_OvrApi  ** This needs to get called from the function CreateOverlay()**
but the problem I think is OvrSetup() is not a function decleared in CloadDrivers but a API call that is part of IOvr5* m_OvrApi; decleared in CLoadDrivers what you have written abouve makes total sense if I was trying to call a function decleared in CLoadDrivers from CreateOverlay()
@NKR6 it isn't very helpful posting speculative code to a thread, especially when it contains no explanation. If you read through this thread I'm sure you can gauge that this code is unlikely to be very helpful to the OP without, at the very least, some explanation of what it does and why you think it'll help.
Can I also point out that I have asked if this might be a homework assignment... I'm not saying it is but since the OP is struggling with some very basic principles here I think we should at least try to ascertain that before just posting coded solutions. It codes against EE's rules on academic integrity.
Can I also point out that I have asked if this might be a homework assignment... I'm not saying it is but since the OP is struggling with some very basic principles here I think we should at least try to ascertain that before just posting coded solutions. It codes against EE's rules on academic integrity.
ASKER
No it is not a homework assignment it is a project im working on for my self
>> No it is not a homework assignment it is a project im working on for my self
Thank you for clarifying that point.
>>Â OvrSetup() is not a function decleared in CloadDrivers but a API call that is part of IOvr5* m_OvrApi;
Ok, I've changed the name of the objects and functions to what yours are -- does that make more sense? Do you still disagree that this models your problem?
Compare: -
m_LoadDriver.m_OvrApi->Ovr 5Setup();
loadDrivers.getOvrApi()->O vr5Setup() ;
The getOvrApi() function is returning a pointer to COvrControl , this is the function you need to implement to return m_OvrApi.
Thank you for clarifying that point.
>>Â OvrSetup() is not a function decleared in CloadDrivers but a API call that is part of IOvr5* m_OvrApi;
Ok, I've changed the name of the objects and functions to what yours are -- does that make more sense? Do you still disagree that this models your problem?
Compare: -
m_LoadDriver.m_OvrApi->Ovr
loadDrivers.getOvrApi()->O
The getOvrApi() function is returning a pointer to COvrControl , this is the function you need to implement to return m_OvrApi.
class COvrControl
{
public:
void Ovr5Setup() const {}; // Just do anything :)
};
class CLoadDrivers
{
public:
CLoadDrivers(): m_OvrApi(0){} // To start m_pBar is set to point to NULL (0)
~CLoadDrivers() { delete m_OvrApi; } // Clean up after outselves
// Return a const pointer to prevent tampering (doesn't have to be but advisable)
COvrControl const * getOvrApi()
{
if(!m_OvrApi) { init(); } // Init m_pBar if it's not already
return m_OvrApi;
}
void init()
{
delete m_OvrApi; // Ensure we don't overwrite any previous allocation
m_OvrApi = new COvrControl ;
}
private:
COvrControl * m_OvrApi;
};
int main()
{
CLoadDrivers loadDrivers;
loadDrivers.getOvrApi()->Ovr5Setup();
}
ASKER
Hi this creates errors error C2440: 'return' : cannot convert from 'IOvr5 *' to 'const COvrControl *'
          error C2440: '=' : cannot convert from 'COvrControl *' to 'IOvr5 *'
error C2248: 'CLoadDrivers::getOvrApi' : cannot access private member declared in class 'CLoadDrivers'
          error C2440: '=' : cannot convert from 'COvrControl *' to 'IOvr5 *'
error C2248: 'CLoadDrivers::getOvrApi' : cannot access private member declared in class 'CLoadDrivers'
>> error C2440: 'return' : cannot convert from 'IOvr5 *' to 'const COvrControl *'
See my point(s) about const correctness above Also, the return types appear to be different, is there a super/sub class relation ship between these two types?
>>Â 'CLoadDrivers::getOvrApi' : cannot access private member declared in class 'CLoadDrivers'
Eh? That doesn't make sense a class can always access its own private members!
See my point(s) about const correctness above Also, the return types appear to be different, is there a super/sub class relation ship between these two types?
>>Â 'CLoadDrivers::getOvrApi' : cannot access private member declared in class 'CLoadDrivers'
Eh? That doesn't make sense a class can always access its own private members!
ASKER
IOvr5 is a API used to access functions within a driver one of these functions being Ovr5Setup()
>> IOvr5 is a API used to access functions within a driver one of these functions being Ovr5Setup()
Ok, but what does it have to do with COvrControl ? You are trying to assign it to a pointer of that type.
Can you post your code so far back here so I can take a look please? Please include all code if you can, not just a snippet.
Ok, but what does it have to do with COvrControl ? You are trying to assign it to a pointer of that type.
Can you post your code so far back here so I can take a look please? Please include all code if you can, not just a snippet.
ASKER
the link i sent you it is save as it is my own server and contains no virus or would you prefer if i just post all code here
>> or would you prefer if i just post all code here
I'd prefer you repost the code here please.
I'd prefer you repost the code here please.
ASKER
the API IOvr5 handles overlay from the video capture card driver so what i am trying to do is from LoadDrivers class, this class loads all relevent drivers depending on what capture card in installed I have this fully working on all hardware cards the OvrControl class just handles the overlay of live video I want to keep each API within is own class for read ability reasons. there are more APIs usesd but once i work out how to pass each API pointer from LoadDriver I can do the rest. Each API must be initilized first via the class LoadDriver first
Ok, but I don't currently understand the relationship between the return type and the pointer you are trying to assign it to (in terms of class hierarchy) so I really need to see your code.
ASKER
Im sending all code to you now starting with all *.h files then *.c++
ASKER
These are the header files I did not add the XML header as it is not needed for this problem
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently,
// but are changed infrequently
#pragma once
#ifndef _SECURE_ATL
#define _SECURE_ATL 1
#endif
#ifndef VC_EXTRALEAN
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#endif
// Modify the following defines if you have to target a platform prior to the ones specified below.
// Refer to MSDN for the latest info on corresponding values for different platforms.
#ifndef WINVER // Allow use of features specific to Windows XP or later.
#define WINVER 0x0501 // Change this to the appropriate value to target other versions of Windows.
#endif
#ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later.
#define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows.
#endif
#ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later.
#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later.
#endif
#ifndef _WIN32_IE // Allow use of features specific to IE 6.0 or later.
#define _WIN32_IE 0x0600 // Change this to the appropriate value to target other versions of IE.
#endif
#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit
// turns off MFC's hiding of some common and often safely ignored warning messages
#define _AFX_ALL_WARNINGS
#include <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions
#include <afxdisp.h> // MFC Automation classes
#ifndef _AFX_NO_OLE_SUPPORT
#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls
#endif
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h> // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT
#include <afxsock.h> // MFC socket extensions
#include "windows.h"
#include <process.h>
#include "initguid.h"
//#include <Prof-UIS.h>
//#include <../ProfSkin/ProfSkin.h>
#include "lib/Cmn5BoardLibEx.h"
#include "lib/Ovr5BoardLibEx.h"
#ifdef _UNICODE
#if defined _M_IX86
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"")
#elif defined _M_IA64
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='ia64' publicKeyToken='6595b64144ccf1df' language='*'\"")
#elif defined _M_X64
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"")
#else
#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
#endif
#endif
//resourch.h
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by PythonDVR.rc
//
#define IDD_PYTHONDVR_DIALOG 102
#define IDP_SOCKETS_INIT_FAILED 103
#define IDR_MAINFRAME 128
#define IDI_DVRCARD 129
#define IDI_VIDEOSERVER 130
#define IDI_CAMERA 131
#define IDI_ICON1 132
#define IDI_TEXT 132
#define IDC_TREE_DEVICES 1000
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 133
#define _APS_NEXT_COMMAND_VALUE 32771
#define _APS_NEXT_CONTROL_VALUE 1001
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
// PythonDVRDlg.h : header file
//
#pragma once
#include "LoadDrivers.h"
#include "XmlNodeWrapper.h"
#include "OvrControl.h"
#include "afxcmn.h"
#define MAX_APP_BOARD 8
#define MAX_APP_CHANNEL 64
struct CHANNELSETTING{
//Cap Video
DWORD dwImageSize;//imagesize;
//Audio..
WORD wSampFreq;//freq;
WORD wSample;//sample;
//Cod
DWORD dwCodImageSize;
DWORD dwBitrateMode;
DWORD dwBitrate;
DWORD dwPeakrate;
DWORD dwGopSize;
DWORD dwNumOfBPic;
DWORD dwSkipFrame;
DWORD dwCodAudioSampFreq;
DWORD dwCodAudioBitrate;
DWORD dwStreamType;
DWORD dwMotionSensitivity;
DWORD dwMotionEnabled;
};
struct BOARDSETTING{
DWORD videoformat;
DWORD colorformat;
DWORD property;
DWORD imageSizeLimit; // image selector use its, This value is prism imagesize index.
CHANNELSETTING ch_prop[MAX_APP_CHANNEL];
DWORD f_use_userseq;
DWORD f_use_divisor;
BYTE framerates[MAX_APP_CHANNEL];
DWORD view_index;
DWORD defaultImageSize;
};
struct APPSETTING{
DWORD dwSize;
TCHAR store_path[MAX_PATH];
TCHAR comport_testfile[MAX_PATH];
DWORD comportNo;
DWORD bLogFile;
DWORD bFpsLog;
UCHAR bBeVideo,bBeAudio,bBeCodec,bBeRealTime;
UCHAR bMEVideo,bMEAudio,bMECodec,bMERealTime;
DWORD audCallbackInterval;
BOARDSETTING bd_prop[MAX_APP_BOARD];
};
//Realtime Driver Setting
struct CHANNELSETTING_RT{
// CAP
DWORD dwContrast;
DWORD dwBrightness;
DWORD dwSaturationu;
DWORD dwSaturationv;
DWORD dwHue;
DWORD bCapEnable;//captureenable;
DWORD dwAGCLevel;//agclevel;
// AUD
DWORD bAudEnable;
DWORD dwAudGain;//audgain;
// COD
DWORD bCodEnable;
// OVR
DWORD bOvrEnable;
};
struct BOARDSETTING_RT{
DWORD bDIChanged;
DWORD bVSDChanged;
DWORD d_i;// current status
DWORD d_o;
DWORD video;
DWORD bWDEnable;
DWORD bWDTrigEnable;
DWORD dwWDTrigTime;
DWORD dwBZTimeOut;
DWORD dwWDTimeOut;
CHANNELSETTING_RT ch_prop[MAX_APP_CHANNEL];
};
#define MAX_OVRVIEW_CONF 9
struct APPSETTING_RT{
DWORD dwSize;
BOARDSETTING_RT bd_prop[MAX_APP_BOARD];
DWORD agcmode;
OVR5_SPLIT_INFO split[MAX_OVRVIEW_CONF];
DWORD split_cfg_index[MAX_OVRVIEW_CONF];
DWORD cur_split;
DWORD ovr_video_format;
DWORD ovr_color_format;
DWORD ovr_tx_mode;
DWORD ovr_show_border;
DWORD ovr_show_channel_name;
DWORD ovr_show_osd_border;
DWORD ovr_enable;
RECT ovr_win_rect;
DWORD ovr_multi_ovr_mode;
};
// CPythonDVRDlg dialog
class CPythonDVRDlg : public CDialog
{
// Construction
public:
CPythonDVRDlg(CWnd* pParent = NULL); // standard constructor
// Dialog Data
enum { IDD = IDD_PYTHONDVR_DIALOG };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
private:
void ParseNode(IDispatch* pNode,HTREEITEM hParent);
CXmlDocumentWrapper m_xmlDoc;
int bd,ch,imgHeight,imgWidth;
CLoadDrivers m_loadDrivers;
COvrControl m_OvrControl;
// Implementation
protected:
HICON m_hIcon;
// Generated message map functions
virtual BOOL OnInitDialog();
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
DECLARE_MESSAGE_MAP()
public:
CTreeCtrl m_tree;
};
extern APPSETTING_RT g_setting_rt;
extern APPSETTING g_setting;
// PythonDVR.h : main header file for the PROJECT_NAME application
//
#pragma once
#ifndef __AFXWIN_H__
#error "include 'stdafx.h' before including this file for PCH"
#endif
#include "resource.h" // main symbols
// CPythonDVRApp:
// See PythonDVR.cpp for the implementation of this class
//
class CPythonDVRApp : public CWinApp
{
public:
CPythonDVRApp();
// Overrides
public:
virtual BOOL InitInstance();
virtual int ExitInstance();
// Implementation
DECLARE_MESSAGE_MAP()
};
extern CPythonDVRApp theApp;
#pragma once
struct UDA5GlobAPI{
BOOL (__stdcall *Cmn5CreateInstance)(IUnknown **pCaptureCard);
};
class CLoadDrivers
{
public:
CLoadDrivers();
virtual ~CLoadDrivers();
private:
CMN5_SYSTEM_INFO m_SysInfo;
UDA5GlobAPI m_Uda5Api;
HMODULE hModuleMP;
HRESULT hr;
IOvr5* m_OvrApi;
OVR5_BOARD_INFO* m_pOvrBoardInfo;
public:
void DriverSelect();
};
#pragma once
// GetSN.h
class GetSN : public CWnd
{
DECLARE_DYNAMIC(GetSN)
public:
GetSN();
virtual ~GetSN();
protected:
DECLARE_MESSAGE_MAP()
public:
BOOL GetActCodefromModelID(DWORD hwid, UCHAR * actCode);
};
#pragma once
// COvrControl
//CLoadDrivers m_LoadDriver;
class COvrControl : public CWnd
{
DECLARE_DYNAMIC(COvrControl)
public:
COvrControl();
virtual ~COvrControl();
BOOL CreateOverlay();
private:
//CLoadDrivers m_loaddrivers;
protected:
DECLARE_MESSAGE_MAP()
};
ASKER
these are the two driver APIs this is what IOvr5* m_OvrApi are all about
#ifndef CMN5BOARDLIB_EX_H
#define CMN5BOARDLIB_EX_H
#pragma pack( push, Cmn5BoardLib_EX_H )
#pragma pack(8)
# if defined(DVRDLL_EXPORTS)
# define CMN5_API __declspec(dllexport) __stdcall
# else
# define CMN5_API __declspec(dllimport) __stdcall
# endif
#if defined(KERNEL_MODE_CODE)
typedef unsigned long DWORD;
typedef int BOOL;
#endif
#define CMN5_SYSTEM_MAX_BOARD 8
#define CMN5_BOARD_MAX_VP 256
#define CMN5_BOARD_MAX_CHANNEL 256
#define CMN5_BOARD_MAX_DIO 256
#define CMN5_BOARD_MAX_CHANNEL_ARRAY_SIZE 8
#define CMN5_BOARD_MAX_DIO_ARRAY_SIZE 8
#define CMN5_INVALID_CHANNEL 0xFFFFFFFF //jb
#define CMN5_ALL_BOARD 0xFF //jb
// Media type //jb
#define CMN5_MEDIA_RAW_VIDEO 0x01
#define CMN5_MEDIA_RAW_AUDIO 0x02
#define CMN5_MEDIA_OVERLAY 0x04
#define CMN5_MEDIA_CODEC 0x08
//////////////////////////////////////////////////////////////////////////
// System Infomation
#define CMN5_MAX_RESERVED_SYSTEM_INFO 8
#define CMN5_MAX_RESERVED_BOARD_INFO_DESC 4
#define CMN5_MAX_RESERVED_BOARD_INFO 16
#define CMN5_BOARD_INFO_VERSION 1
#if _MSC_VER >= 1300
typedef union _LARGE_INTEGER_CAP {
struct {
DWORD LowPart;
LONG HighPart;
};
struct {
DWORD LowPart;
LONG HighPart;
} u;
LONGLONG QuadPart;
} LARGE_INTEGER_CAP;
#endif
typedef struct _CMN5_SYSTEM_INFO {
ULONG uNumOfBoard;
ULONG uDllVersion;
ULONG uSysVersion;
ULONG reserved[CMN5_MAX_RESERVED_SYSTEM_INFO - 3];
} CMN5_SYSTEM_INFO;
typedef struct _CMN5_BOARD_INFO_DESC {
ULONG uInfoSize;
ULONG uInfoVersion;
ULONG reserved[CMN5_MAX_RESERVED_BOARD_INFO_DESC - 2];
} CMN5_BOARD_INFO_DESC;
//////////////////////////////////////////////////////////////////////////
// Error Code
#define CMN5_MAX_ERROR_CODE_MSG_LENGTH 128 //jb
#define CMN5_MAX_SESSION_LENGTH 64 //jb
typedef struct _CMN5_ERROR_CODE_ITEM {
ULONG ErrorCode; // code
#if _MSC_VER >= 1300
LARGE_INTEGER_CAP TimeStamp; // time-stamp
#else
LARGE_INTEGER TimeStamp; // time-stamp
#endif
ULONG Reserved; // reserved
char AuxMsg[CMN5_MAX_ERROR_CODE_MSG_LENGTH]; // aux message
char SessionName[CMN5_MAX_SESSION_LENGTH]; // session name
} CMN5_ERROR_CODE_ITEM;
//////////////////////////////////////////////////////////////////////////
// Video Format
#define CMN5_VIDEO_FORMAT_NONE 0 //jb
#define CMN5_VIDEO_FORMAT_NTSC_M 1
#define CMN5_VIDEO_FORMAT_PAL_B 2
#define CMN5_DEFAULT_VIDEO_FORMAT CMN5_VIDEO_FORMAT_NTSC_M
//////////////////////////////////////////////////////////////////////////
// Image Size
/* ImageSize define
DWORD I;
I[31..28] : reserved....
I[27 ] : Interace Frame(1)/weave Frame(0)
I[26 ] : W double
I[25 ] : H double
I[24 ] : VFLIP
I[23..12] : H
I[11.. 0] : W
ex) 640x480
0000 xxxxx 640 480
I = (480<<12) | (640);
*/
union CMN5_IMAGESIZE {
ULONG uAll;
struct {
ULONG nWidth : 12; //[0..11]
ULONG nHeight : 12; //[12..23]
ULONG bInvert : 1; //[24]
ULONG bHDouble : 1; //[25]
ULONG bVDouble : 1; //[26]
ULONG bInteracedFrame : 1; //[27]
ULONG nScaledDown : 2; //[29..28]
ULONG reserved : 2; //[30..31]
};
};
#define CMN5_MAKEIMGSIZE(w, h) ((w & 0xFFF) | ((h &0xFFF) << 12))
#define CMN5_GETIMGWIDTH(is) (is & 0xFFF)
#define CMN5_GETIMGHEIGHT(is) ((is >> 12) & 0xFFF)
#define CMN5_IMAGESIZE_WDOUBLE (1<<26)
#define CMN5_IMAGESIZE_HDOUBLE (1<<25)
#define CMN5_IMAGESIZE_VFLIP (1<<24)
#define CMN5_IMAGESIZE_SEP_FIELD (1<<27)
#define CMN5_IMAGESIZE_SCALED_DOWN_CIF (1<<28)
#define CMN5_IMAGESIZE_SCALED_DOWN_QCIF (2<<28)
#define CMN5_IMAGESIZE_768X576 CMN5_MAKEIMGSIZE(768, 576)
#define CMN5_IMAGESIZE_768X288 CMN5_MAKEIMGSIZE(768, 288)
#define CMN5_IMAGESIZE_384X288 CMN5_MAKEIMGSIZE(384, 288)
#define CMN5_IMAGESIZE_192X144 CMN5_MAKEIMGSIZE(192, 144)
#define CMN5_IMAGESIZE_720X576 CMN5_MAKEIMGSIZE(720, 576)
#define CMN5_IMAGESIZE_720X288 CMN5_MAKEIMGSIZE(720, 288)
#define CMN5_IMAGESIZE_360X288 CMN5_MAKEIMGSIZE(360, 288)
#define CMN5_IMAGESIZE_180X144 CMN5_MAKEIMGSIZE(180, 144)
#define CMN5_IMAGESIZE_720X480 CMN5_MAKEIMGSIZE(720, 480)
#define CMN5_IMAGESIZE_720X240 CMN5_MAKEIMGSIZE(720, 240)
#define CMN5_IMAGESIZE_360X240 CMN5_MAKEIMGSIZE(360, 240)
#define CMN5_IMAGESIZE_180X120 CMN5_MAKEIMGSIZE(180, 120)
#define CMN5_IMAGESIZE_640X480 CMN5_MAKEIMGSIZE(640, 480)
#define CMN5_IMAGESIZE_640X240 CMN5_MAKEIMGSIZE(640, 240)
#define CMN5_IMAGESIZE_320X240 CMN5_MAKEIMGSIZE(320, 240)
#define CMN5_IMAGESIZE_160X120 CMN5_MAKEIMGSIZE(160, 120)
#define CMN5_IMAGESIZE_704X576 CMN5_MAKEIMGSIZE(704, 576)
#define CMN5_IMAGESIZE_704X288 CMN5_MAKEIMGSIZE(704, 288)
#define CMN5_IMAGESIZE_352X288 CMN5_MAKEIMGSIZE(352, 288)
#define CMN5_IMAGESIZE_176X144 CMN5_MAKEIMGSIZE(176, 144)
#define CMN5_IMAGESIZE_704X480 CMN5_MAKEIMGSIZE(704, 480)
#define CMN5_IMAGESIZE_704X240 CMN5_MAKEIMGSIZE(704, 240)
#define CMN5_IMAGESIZE_352X240 CMN5_MAKEIMGSIZE(352, 240)
#define CMN5_IMAGESIZE_176X120 CMN5_MAKEIMGSIZE(176, 120)
#define CMN5_IMAGESIZE_672X544 CMN5_MAKEIMGSIZE(672, 544)
#define CMN5_IMAGESIZE_672X272 CMN5_MAKEIMGSIZE(672, 272)
#define CMN5_IMAGESIZE_336X272 CMN5_MAKEIMGSIZE(336, 272)
#define CMN5_IMAGESIZE_168X136 CMN5_MAKEIMGSIZE(168, 136)
#define CMN5_MAX_RESOLUTION_COUNT (1<<6) //6bit... 64...
#define CMN5_MAX_RESOLUTION_VALUE (CMN5_MAX_RESOLUTION_COUNT-1)
/* Image Size Description
ULONG ISD
ISD[23..16] Supported Video Format
ISD[15..8] Subimage, Each bit represent.
ISD[7..0 ] Current Image, Only one bit is available.
*/
/* Image Size Description
ULONG ISD
ISD[9..8 ] Group /sub/sep id...
ISD[7..0 ] Supported Video Format
*/
#define CMN5_IMAGESIZE_IS_GROUP 0x000
#define CMN5_IMAGESIZE_IS_SUB 0x100
#define CMN5_IMAGESIZE_IS_SEP 0x200
#define CMN5_IMAGESIZE_SUPPORT_NTSC_M (0x01<<CMN5_VIDEO_FORMAT_NTSC_M)
#define CMN5_IMAGESIZE_SUPPORT_PAL_B (0x01<<CMN5_VIDEO_FORMAT_PAL_B)
#define CMN5_IMAGESIZE_SUPPORT_BOTH (CMN5_IMAGESIZE_SUPPORT_NTSC_M | CMN5_IMAGESIZE_SUPPORT_PAL_B)
typedef struct _CMN5_IMAGESIZE_DESC{
ULONG uImageSize;
ULONG uSizeDesc;
} CMN5_IMAGESIZE_DESC;
typedef struct _CMN5_RESOLUTION_INFO{
BOOL fSameGroupOnly;
ULONG uSizeCount;
ULONG uDefaultNTSCSize;
ULONG uDefaultPALSize;
CMN5_IMAGESIZE_DESC aImgDesc[CMN5_MAX_RESOLUTION_COUNT];
} CMN5_RESOLUTION_INFO;
//////////////////////////////////////////////////////////////////////////////////
//
#define CMN5_ACTIVATION_CODE_SIZE 16
//////////////////////////////////////////////////////////////////////////////////
// I2C & EEPROM
#define CMN5_I2C_CMD_READ 1
#define CMN5_I2C_CMD_WRITE 2
#define CMN5_I2C_CMD_RANDOM_READ 3
#define CMN5_I2C_CMD_RANDOM_WRITE 4
#define CMN5_I2C_CMD_RANDOM_WRITE_WAIT 5
#define CMN5_USER_EEPROM_SIZE 16
#define CMN5_UID_ADDR 0x10000
//////////////////////////////////////////////////////////////////////////////////
// process state
//enum Cmn5ProcessState
#define CMN5_PS_INIT 1
#define CMN5_PS_SETUP 2
#define CMN5_PS_RUN 3
//enum WatchdogCmd {
#define CMN5_WC_ENABLE 1
#define CMN5_WC_DISABLE 2
#define CMN5_WC_SET_TIMEOUT_VALUE 3
#define CMN5_WC_TRIGGER 4
#define CMN5_WC_SET_BUZZER_TIMEOUT_VALUE 5
//};
//enum QueryInfoCmd {
#define CMN5_QIC_GET_PROCESS_STATE 0x1
#define CMN5_QIC_GET_EIOINFO 0x1006 //0x2 for compatibility old define CAP5_QIC_GET_EIOINFO
#define CMN5_QIC_GET_HWINFO_STR 0x1002
//};
typedef struct _CMN5_MULTI_COMMAND {
ULONG uCommand;
ULONG uBoard;
ULONG uChannel;
union {
ULONG uParam[4];
struct {
ULONG uParam0;
ULONG uParam1;
ULONG uParam2;
ULONG uParam3;
};
};
BOOL bRet;
} CMN5_MULTI_COMMAND;
//////////////////////////////////////////////////////////////////////////////////
// DataType
//enum DataType {
#define CMN5_DT_VIDEO 1
#define CMN5_DT_AUDIO 2
#define CMN5_DT_COD 3
#define CMN5_DT_SENSOR 4
#define CMN5_DT_VSTATUS 5
#define CMN5_DT_NET 6
#define CMN5_DT_OVERLAY 7
#define CMN5_DT_VIDEO_EX 0x11
#define CMN5_DT_AUDIO_EX 0x12
#define CMN5_DT_COD_EX 0x13
//#define CMN5_DT_SENSOR_EX 0x14 // Reserved for future use
//#define CMN5_DT_VSTATUS_EX 0x15 // Reserved for future use
#define CMN5_DT_NET_EX 0x16
// Error code
//enum ErrorCode {
#define CMN5_EC_NO_ERROR 0
#define CMN5_EC_NO_DATA 1
#define CMN5_EC_OVERFLOW 2
#define CMN5_EC_ERROR 3
#define CMN5_EC_FIRMWARE_ERROR 4
#define CMN5_EC_FIRMWARE_DEAD 5
//////////////////////////////////////////////////////////////////////////////////
//enum CommonAdjustCmd {
#define CMN5_CAC_EIO_ENABLE 0x00030010
#define CMN5_CAC_DIO_DO 0x00030020
#define CMN5_CAC_DIO_DI 0x00030040
#define CMN5_CAC_EIO_DITYPE 0x00030080
//};
//////////////////////////////////////////////////////////////////////////////////
// EIO constats
#define CMN5_DIO_DITYPE_RELAY 1
#define CMN5_DIO_DITYPE_VOLTAGE 2
//////////////////////////////////////////////////////////////////////////////////
// EIO structure
typedef struct _CMN5_EIOBOARD_INFO {
ULONG uStructSize;
ULONG uEIOBoardCount;
ULONG uRev[CMN5_BOARD_MAX_DIO_ARRAY_SIZE];
ULONG uMaxDI[CMN5_BOARD_MAX_DIO_ARRAY_SIZE];
ULONG uMaxDO[CMN5_BOARD_MAX_DIO_ARRAY_SIZE];
ULONG reserved[CMN5_BOARD_MAX_DIO_ARRAY_SIZE*5];
} CMN5_EIOBOARD_INFO;
/*
#define struct {
\ ULONG uDataType;
\ ULONG uSize;
\ ULONG uErrCode;
\ ULONG uBoardNum; // Board ID
} DATA_INFO_HEADER
*/
// Abstract structure
typedef struct _CMN5_DATA_INFO_HEADER {
ULONG uDataType;
ULONG uSize;
ULONG uErrCode;
ULONG uBoardNum; // Board ID
} CMN5_DATA_INFO_HEADER;
typedef struct _CMN5_QUERY_DATA_INFO{
ULONG uDataType;
ULONG uSize;
ULONG uErrCode;
ULONG uBoardNum; // Board ID
ULONG reserved[16];
} CMN5_QUERY_DATA_INFO;
// Abstract structure
typedef struct _CMN5_DATA_INFO_DATA{
ULONG uDataType;
ULONG uStructSize;
ULONG uErrCode;
ULONG uBoardNum; // Board ID
ULONG uChannelNum; // Channel ID of the Board
ULONG uHasNextData;
UCHAR *pDataBuffer; // data buffer address
#if _MSC_VER >= 1300
LARGE_INTEGER_CAP TimeTag; // KeQuerySystemTime()
#else
LARGE_INTEGER TimeTag; // KeQuerySystemTime()
#endif
ULONG uBufferIdx; // internal use! do not touch!
} CMN5_DATA_INFO_DATA;
#if _MSC_VER >= 1300
#define _CMN5_DATA_INFO_DATA_EX_CMM_BODY \
union { \
ULONG reservedCmn[32]; \
struct { \
ULONG uDataType; \
ULONG uStructSize; \
ULONG uErrCode; \
\
ULONG uBoardNum; /* Board ID */ \
ULONG uChannelNum; /* Channel ID of the Board */ \
ULONG uHasNextData; \
UCHAR *pDataBuffer; /* data buffer address */ \
LARGE_INTEGER_CAP TimeTag; /* KeQuerySystemTime() */ \
ULONG uBufferIdx; /* internal use! do not touch! */ \
}; \
}
#else
#define _CMN5_DATA_INFO_DATA_EX_CMM_BODY \
union { \
ULONG reservedCmn[32]; \
struct { \
ULONG uDataType; \
ULONG uStructSize; \
ULONG uErrCode; \
\
ULONG uBoardNum; /* Board ID */ \
ULONG uChannelNum; /* Channel ID of the Board */ \
ULONG uHasNextData; \
UCHAR *pDataBuffer; /* data buffer address */ \
LARGE_INTEGER TimeTag; /* KeQuerySystemTime() */ \
ULONG uBufferIdx; /* internal use! do not touch! */ \
}; \
}
#endif
typedef struct _CMN5_DATA_INFO_DATA_EX {
_CMN5_DATA_INFO_DATA_EX_CMM_BODY;
} CMN5_DATA_INFO_DATA_EX;
typedef struct _CMN5_VIDEO_STATUS_INFO {
ULONG uDataType;
ULONG uStructSize;
ULONG uErrCode;
ULONG uBoardNum;
ULONG VideoStatus[CMN5_BOARD_MAX_CHANNEL_ARRAY_SIZE];
ULONG VideoStatusMask[CMN5_BOARD_MAX_CHANNEL_ARRAY_SIZE];
} CMN5_VIDEO_STATUS_INFO;
typedef struct _CMN5_SENSOR_STATUS_INFO{
ULONG uDataType;
ULONG uStructSize;
ULONG uErrCode;
ULONG uBoardNum; // Board ID // CMN5_MAKEEIOBOARDID for EIO
ULONG SensorStatus[CMN5_BOARD_MAX_DIO_ARRAY_SIZE]; //for sensor detect event..
ULONG SensorStatusMask[CMN5_BOARD_MAX_DIO_ARRAY_SIZE];
} CMN5_SENSOR_STATUS_INFO;
#define CMN5_MAKEEIOBOARDID(bdid, eiobdid) ((bdid & 0xFF) | ((eiobdid & 0xFF) << 16))
#define CMN5_GETBOARDID(bdid) (bdid & 0xFF)
#define CMN5_GETEIOBOARDID(bdid) ((bdid >> 16) & 0xFF)
// Callback Prototype
//enum {
// method
#define CMN5_CAPTURE_METHOD_CALLBACK 0
//#define CMN5_CAPTURE_METHOD_LOCK_AND_WAIT 1 // obsolete
#define CMN5_CAPTURE_METHOD_QUERY 2
// capture data type (We do not recommend that you use following names.)
#define CMN5_CAPTURE_CALLBACK_ONCAPTURE 0x10 // legacy type
#define CMN5_CAPTURE_CALLBACK_ONVIDEO 0x11 // legacy type
#define CMN5_CAPTURE_CALLBACK_ONSENSOR 0x12 // legacy type
// renamed (Use following names instead.)
#define CMN5_CAPTURE_TYPE_ON_DATA CMN5_CAPTURE_CALLBACK_ONCAPTURE // Primary data of all 'Media'.
#define CMN5_CAPTURE_TYPE_ON_CHANNEL CMN5_CAPTURE_CALLBACK_ONVIDEO
#define CMN5_CAPTURE_TYPE_ON_SENSOR CMN5_CAPTURE_CALLBACK_ONSENSOR
// In case of EIO Board sensor callback you should be careful to 'ULONG uBoardID' in first parameter
// which is means uBoardID at bit31 to bit24 and uEIOBoardID at bit23 to bit16.
//};
#define CMN5_CAPTURE_TYPE_ON_DATA_EX 0x00010010
//#define CMN5_CAPTURE_TYPE_ON_CHANNEL_EX 0x00010011 // Reserved for future use
//#define CMN5_CAPTURE_TYPE_ON_SENSOR_EX 0x00010012 // Reserved for future use
#ifdef __cplusplus
extern "C"
{
#endif
BOOL CMN5_API Cmn5CreateInstance(void **pUnknown);
typedef BOOL (__stdcall *CMN5_CALLBACK_ONE_PARAM)(ULONG A);
typedef BOOL (__stdcall *CMN5_CALLBACK_TWO_PARAM)(ULONG A, ULONG B);
typedef BOOL (__stdcall *CMN5_CALLBACK_THREE_PARAM)(ULONG A, ULONG B, ULONG C);
#ifdef __cplusplus
}
#endif
#pragma pack( pop, Cmn5BoardLib_EX_H )
#endif // CMN5BOARDLIB_EX_H
#ifndef OVR5BOARDLIB_EX_H
#define OVR5BOARDLIB_EX_H
#include "Cmn5BoardLibEx.h"
#pragma pack( push, Ovr5BaordLibEx_H )
#pragma pack(8)
extern "C" const IID IID_IOvr5 ;
//IID for Ovr5
// {3710E024-27D3-4421-B173-7CDB57B60424}
DEFINE_GUID(IID_IOvr5, 0x3710e024, 0x27d3, 0x4421, 0xb1, 0x73, 0x7c, 0xdb, 0x57, 0xb6, 0x4, 0x24);
#ifndef KERNEL_MODE_CODE
#include <ddraw.h>
#endif
typedef struct _OVR5_BOARD_INFO{
ULONG uBoardID;
ULONG uModelID;
ULONG uSlotNumber;
ULONG uMaxChannel;
ULONG uMaxPip;
ULONG uVideoDecoderType;
ULONG uMuxType;
const CMN5_RESOLUTION_INFO* pResInfo; //132*sizeof(ULONG)
ULONG reserved[CMN5_MAX_RESERVED_BOARD_INFO - 8];
} OVR5_BOARD_INFO;
//enum OvrPropertyCmd {
#define OVR5_OPC_MULTI_OVR_MODE 0x03000001
#define OVR5_OPC_MULTI_PIC_MODE OVR5_OPC_MULTI_OVR_MODE
#define OVR5_OPC_BG_COLOR 0x03000002
#define OVR5_OPC_TX_MODE 0x03000008
#define OVR5_OPC_SET_BASIS_SIZE 0x03040001 //DMP200 ONLY //uParam0:width, //uParam1:height
//};
//enum OvrAdjustCmd {
#define OVR5_OAC_BRIGHTNESS 0x02000001
#define OVR5_OAC_CONTRAST 0x02000002
#define OVR5_OAC_SATURATION_U 0x02000004
#define OVR5_OAC_SATURATION_V 0x02000008
#define OVR5_OAC_HUE 0x02000010
#define OVR5_OAC_SHARPNESS 0x02000020
#define OVR5_OAC_BORDER 0x02010001
#define OVR5_OAC_OSD_ENABLE 0x02010002 //uParam0 : OSD type (OVR5_OSD_TVOUT, OVR5_OSD_OVERLAY, OVR5_OSD_RAW_IMAGE), uParam1 : bEnable
#define OVR5_OAC_OSD_PALETTE 0x02010004 //uParam0 : Palette size, uParam1 : DWORD type array pointer,
#define OVR5_OAC_OSD_UPDATE 0x02010008 //uParam0 : tDestination, uParam1 : pData, uParam2 : pRect, uParam3 : bDelayUpdate
#define OVR5_OAC_TRANSFER_MODE 0x02010010 //uParam0 : OvrTransferMode
#define OVR5_OAC_TX_FIELD_SINGLEVIEW 0x02010020 //uParam0 : TRUE : Field, FALSE : Frame
#define OVR5_OAC_EXT_MON_SEL 0x03000001
#define OVR5_OAC_IMP_VIEW_BOARD 0x03000002
#define OVR5_OAC_FREEZE 0x03000004 //uParam0 : Freeze On/Off
#define OVR5_OAC_SET_OSD 0x03040001 //DMP200 ONLY //uParam0 : OSDbitmap
//};
//enum OvrTransferMode
#define OVR5_TRANSFER_FRAME 1
#define OVR5_TRANSFER_FIELD 2
#define OVR5_TRANSFER_HALF_FRAME 3
//};
//enum OvrScreenMode {
#define OVR5_OSM_SCREEN_MODE_M720 1
#define OVR5_OSM_SCREEN_MODE_H648 2
//};
//enum OvrMultOvrMode {
#define OVR5_OMM_SPLIT 1
#define OVR5_OMM_CASCADE 2
#define OVR5_OMM_COMBINATION 3
// renamed
#define OVR5_OMM_SPLIT_MULTI_PIC OVR5_OMM_SPLIT // split multi-picture mode
#define OVR5_OMM_CASCADE_MULTI_PIC OVR5_OMM_CASCADE // casecade multi-picture mode
#define OVR5_OMM_COMB_MULTI_PIC OVR5_OMM_COMBINATION // combination multi-picture mode
#define OVR5_OMM_INDIV_MULTI_PIC 4 // individual multi-picture mode
#define OVR5_TX_DIRECT_GRAPHICS 0
#define OVR5_TX_INDIRECT_GRAPHICS_EVENT 1
#define OVR5_TX_DIRECT_GRAPHICS_EVENT 2
//}
//////////////////////////////////////////////////////////////////////////////////
// OVR_SPLIT_INFO
#define OVR5_MAX_RECT 64
#define OVR5_MAX_CHANNEL 64
#define OVR5_MAX_PIP 16 // Actual number of PIP channel should be extracted from OVR5_BOARD_INFO
typedef struct _OVR5_SPLIT_CONF{
ULONG uNumRects;
SIZE szBoundSize;
RECT rcRect[OVR5_MAX_RECT];
ULONG aChannel[OVR5_MAX_CHANNEL];
} OVR5_SPLIT_CONF;
typedef struct _OVR5_PIP_INFO{
ULONG uNumPip;
RECT rcRect[OVR5_MAX_PIP];
ULONG aChannel[OVR5_MAX_PIP];
} OVR5_PIP_INFO;
typedef struct _OVR5_SPLIT_INFO{
OVR5_SPLIT_CONF scSplitConf;
OVR5_PIP_INFO piPipInfo;
RECT rcOverlaySrcRect;
} OVR5_SPLIT_INFO;
// OVR_SPLIT_INFO
//////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////
// OVR_OSD_INFO
#define OVR5_OSD_TVOUT 0x00000001
#define OVR5_OSD_OVERLAY 0x00000002
#define OVR5_OSD_RAW_IMAGE 0x00000004
#define OVR5_QR_OSD_INFO 0x2000 //
typedef struct {
DWORD bSupport; //bitwise OVR_OSD_type
SIZE szNTSC;
SIZE szPAL;
DWORD PaletteSize;
BYTE ClearByte;
DWORD Reserved[4];
} OVR5_OSD_INFO;
//////////////////////////////////////////////////////////////////////////////////
#ifndef KERNEL_MODE_CODE
typedef struct _OVR5_OVERLAY_OBJ_INFO{
LPDIRECTDRAW7 pDD;
LPDIRECTDRAWSURFACE7 pDDSOverlay;
LPDIRECTDRAWSURFACE7 pDDSOverlayBack;
ULONG reserved[13];
} OVR5_OVERLAY_OBJ_INFO;
extern "C"
{
//////////////////////////////////////////////////////////////////////////////////
// APIs
// Control
BOOL CMN5_API Ovr5Activate(ULONG uBdID,const UCHAR ActivationCode[CMN5_ACTIVATION_CODE_SIZE]);
BOOL CMN5_API Ovr5Setup(void);
BOOL CMN5_API Ovr5Endup(void);
BOOL CMN5_API Ovr5Run(void);
BOOL CMN5_API Ovr5Stop(void);
BOOL CMN5_API Ovr5CaptureEnable(ULONG uBdID, BOOL bEnable);
// Video format
BOOL CMN5_API Ovr5SetScreenMode(ULONG uBdID, ULONG uScreenMode);
BOOL CMN5_API Ovr5SetVideoFormat(ULONG uBdID, ULONG uFormat);
// Image Processor
BOOL CMN5_API Ovr5Split(ULONG uBdID, OVR5_SPLIT_INFO* pSplitInfo);
BOOL CMN5_API Ovr5EnableChannel(ULONG uBdID, ULONG uCh, BOOL bEnable);
// Video Decoder
BOOL CMN5_API Ovr5SetOvrProperty(ULONG uBdID, ULONG uCh, ULONG uOvrPropertyCmd, ULONG uParam0, ULONG uParam1, ULONG uParam2, ULONG uParam3);
BOOL CMN5_API Ovr5GetOvrProperty(ULONG uBdID, ULONG uCh, ULONG uOvrPropertyCmd, ULONG *puParam0, ULONG *puParam1, ULONG *puParam2, ULONG *puParam3);
BOOL CMN5_API Ovr5SetOvrAdjust(ULONG uBdID, ULONG uCh, ULONG uOvrAdjustCmd, ULONG uParam0, ULONG uParam1, ULONG uParam2, ULONG uParam3);
BOOL CMN5_API Ovr5GetOvrAdjust(ULONG uBdID, ULONG uCh, ULONG uOvrAdjustCmd, ULONG *puParam0, ULONG *puParam1, ULONG *puParam2, ULONG *puParam3);
BOOL CMN5_API Ovr5SetMultiOvrProperty(ULONG uNumCmd, CMN5_MULTI_COMMAND *pCmds);
BOOL CMN5_API Ovr5GetMultiOvrProperty(ULONG uNumCmd, CMN5_MULTI_COMMAND *pCmds);
BOOL CMN5_API Ovr5SetMultiOvrAdjust(ULONG uNumCmd, CMN5_MULTI_COMMAND *pCmds);
BOOL CMN5_API Ovr5GetMultiOvrAdjust(ULONG uNumCmd, CMN5_MULTI_COMMAND *pCmds);
// DirectDraw
BOOL CMN5_API Ovr5SetOverlayObjectInfo(OVR5_OVERLAY_OBJ_INFO* pInfo);
// Error code
BOOL CMN5_API Ovr5GetErrorCode(CMN5_ERROR_CODE_ITEM* item);
// User EEPROM
BOOL CMN5_API Ovr5ReadUserEEPROM(ULONG uBdID, ULONG uVPID, UCHAR *pData);
BOOL CMN5_API Ovr5WriteUserEEPROM(ULONG uBdID, ULONG uVPID,const UCHAR *pData);
// Information
BOOL CMN5_API Ovr5GetLastErrorCode(CMN5_ERROR_CODE_ITEM *pEcode);
BOOL CMN5_API Ovr5QueryInfo(ULONG uQueryInfoCmd, ULONG uIn, void *pOut);
BOOL CMN5_API Ovr5GetSystemInfo(CMN5_SYSTEM_INFO *pInfo);
BOOL CMN5_API Ovr5GetBoardInfo(ULONG uBdID,const CMN5_BOARD_INFO_DESC *pDesc, OVR5_BOARD_INFO *pInfo);
BOOL CMN5_API Ovr5SetOvrProperty(ULONG uBdID, ULONG uCh, ULONG uOvrPropertyCmd, ULONG uParam0, ULONG uParam1, ULONG uParam2, ULONG uParam3);
BOOL CMN5_API Ovr5GetOvrProperty(ULONG uBdID, ULONG uCh, ULONG uOvrPropertyCmd, ULONG *puParam0, ULONG *puParam1, ULONG *puParam2, ULONG *puParam3);
BOOL CMN5_API Ovr5SetMultiOvrProperty(ULONG uNumCmd, CMN5_MULTI_COMMAND *pCmds);
BOOL CMN5_API Ovr5GetMultiOvrProperty(ULONG uNumCmd, CMN5_MULTI_COMMAND *pCmds);
} // extern "C"
// Interface definition for IOvr5
interface IOvr5 : IUnknown
{
// Control
STDMETHOD_(BOOL, Ovr5Activate)(ULONG uBdID,const UCHAR ActivationCode[CMN5_ACTIVATION_CODE_SIZE]) PURE ;
STDMETHOD_(BOOL, Ovr5Setup)(void) PURE;
STDMETHOD_(BOOL, Ovr5Endup)(void) PURE;
STDMETHOD_(BOOL, Ovr5Run)(void) PURE;
STDMETHOD_(BOOL, Ovr5Stop)(void) PURE;
STDMETHOD_(BOOL, Ovr5CaptureEnable)(ULONG uBdID, BOOL bEnable) PURE;
// Video format
STDMETHOD_(BOOL, Ovr5SetScreenMode)(ULONG uBdID, ULONG uScreenMode) PURE;
STDMETHOD_(BOOL, Ovr5SetVideoFormat)(ULONG uBdID, ULONG uFormat) PURE;
// Image Processor
STDMETHOD_(BOOL, Ovr5Split)(ULONG uBdID, OVR5_SPLIT_INFO* pSplitInfo) PURE;
STDMETHOD_(BOOL, Ovr5EnableChannel)(ULONG uBdID, ULONG uCh, BOOL bEnable) PURE;
// Video Decoder
STDMETHOD_(BOOL, Ovr5SetOvrAdjust)(ULONG uBdID, ULONG uCh, ULONG uOvrAdjustCmd, ULONG uParam0, ULONG uParam1, ULONG uParam2, ULONG uParam3) PURE;
STDMETHOD_(BOOL, Ovr5GetOvrAdjust)(ULONG uBdID, ULONG uCh, ULONG uOvrAdjustCmd, ULONG *puParam0, ULONG *puParam1, ULONG *puParam2, ULONG *puParam3) PURE;
STDMETHOD_(BOOL, Ovr5SetMultiOvrAdjust)(ULONG uNumCmd, CMN5_MULTI_COMMAND *pCmds) PURE;
STDMETHOD_(BOOL, Ovr5GetMultiOvrAdjust)(ULONG uNumCmd, CMN5_MULTI_COMMAND *pCmds) PURE;
// DirectDraw
STDMETHOD_(BOOL, Ovr5SetOverlayObjectInfo)(OVR5_OVERLAY_OBJ_INFO* pInfo) PURE;
// Error code
STDMETHOD_(BOOL, Ovr5GetErrorCode)(CMN5_ERROR_CODE_ITEM* item) PURE;
// User EEPROM
STDMETHOD_(BOOL, Ovr5ReadUserEEPROM)(ULONG uBdID, ULONG uVPID, UCHAR *pData) PURE;
STDMETHOD_(BOOL, Ovr5WriteUserEEPROM)(ULONG uBdID, ULONG uVPID,const UCHAR *pData) PURE;
// Information
STDMETHOD_(BOOL, Ovr5GetLastErrorCode)(CMN5_ERROR_CODE_ITEM *pEcode) PURE;
STDMETHOD_(BOOL, Ovr5QueryInfo)(ULONG uQueryInfoCmd, ULONG uIn, void *pOut) PURE;
STDMETHOD_(BOOL, Ovr5GetSystemInfo)(CMN5_SYSTEM_INFO *pInfo) PURE;
STDMETHOD_(BOOL, Ovr5GetBoardInfo)(ULONG uBdID,const CMN5_BOARD_INFO_DESC *pDesc, OVR5_BOARD_INFO *pInfo) PURE;
STDMETHOD_(BOOL, Ovr5SetOvrProperty)(ULONG uBdID, ULONG uCh, ULONG uOvrPropertyCmd, ULONG uParam0, ULONG uParam1, ULONG uParam2, ULONG uParam3) PURE;
STDMETHOD_(BOOL, Ovr5GetOvrProperty)(ULONG uBdID, ULONG uCh, ULONG uOvrPropertyCmd, ULONG *puParam0, ULONG *puParam1, ULONG *puParam2, ULONG *puParam3) PURE;
STDMETHOD_(BOOL, Ovr5SetMultiOvrProperty)(ULONG uNumCmd, CMN5_MULTI_COMMAND *pCmds) PURE;
STDMETHOD_(BOOL, Ovr5GetMultiOvrProperty)(ULONG uNumCmd, CMN5_MULTI_COMMAND *pCmds) PURE;
};
#endif
#pragma pack( pop, Ovr5BaordLibEx_H )
#endif // OVR5BOARDLIB_EX_H
ASKER
in LoadDrivers im only calling one driver for this at the moment. YOu should be able to run and compile your self from this just remove the XML function you wont need this
// PythonDVRDlg.cpp : implementation file
//
#include "stdafx.h"
#include "PythonDVR.h"
#include "PythonDVRDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
//Icons for List Tree to show assigned devices
#define GETICONRESOURCE16(i) (HICON)LoadImage(AfxGetResourceHandle( ),MAKEINTRESOURCE(i),IMAGE_ICON,24,24,0)
APPSETTING_RT g_setting_rt;
APPSETTING g_setting;
// CPythonDVRDlg dialog
CPythonDVRDlg::CPythonDVRDlg(CWnd* pParent /*=NULL*/)
: CDialog(CPythonDVRDlg::IDD, pParent)
{
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CPythonDVRDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_TREE_DEVICES, m_tree);
}
BEGIN_MESSAGE_MAP(CPythonDVRDlg, CDialog)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
// CPythonDVRDlg message handlers
BOOL CPythonDVRDlg::OnInitDialog()
{
CDialog::OnInitDialog();
BOOL rs;
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
ShowWindow(SW_MAXIMIZE);
CImageList iml;
iml.Create(24,24,ILC_COLOR32|ILC_MASK,4,1);
iml.Add(GETICONRESOURCE16(IDI_DVRCARD));
iml.Add(GETICONRESOURCE16(IDI_VIDEOSERVER));
iml.Add(GETICONRESOURCE16(IDI_TEXT));
iml.Add(GETICONRESOURCE16(IDI_CAMERA));
m_tree.SetImageList(&iml,TVSIL_NORMAL);
iml.Detach();
rs = m_xmlDoc.Load("./MainConfig.xml");
if(!rs) {
TRACE("Failed to load XML file\n\r");
}else{
TRACE("loaded XML file\n\r");
ParseNode(m_xmlDoc.AsNode(),TVI_ROOT);
}
m_loadDrivers.DriverSelect();
m_OvrControl.CreateOverlay();
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CPythonDVRDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// The system calls this function to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CPythonDVRDlg::OnQueryDragIcon()
{
return static_cast<HCURSOR>(m_hIcon);
}
void CPythonDVRDlg::ParseNode(IDispatch *pNode,HTREEITEM hParent)
{
CXmlNodeWrapper node(pNode);
g_setting.dwSize=sizeof(g_setting);
g_setting_rt.dwSize=sizeof(g_setting_rt);
int img,imgSel;
CString str,nodeConvert;
if (node.NodeType() == "element")
{
img = 0;
imgSel = 1;
str = node.Name();
}
else
{
img = imgSel = 2;
str = node.GetText();
}
HTREEITEM hItem = m_tree.InsertItem(str,img,imgSel,hParent);
m_tree.SetItemData(hItem,(DWORD)pNode);
for (int i = 0; i < node.NumAttributes(); i++)
{
HTREEITEM hAttribItem = m_tree.InsertItem(node.GetAttribName(i) + " = " + node.GetAttribVal(i),3,4,hItem);
if(node.GetAttribName(i)=="BOARDID"){
bd = atoi(node.GetAttribVal(i));
} //BOARDID
if(node.GetAttribName(i)=="channel"){
ch = atoi(node.GetAttribVal(i));
} //channel
if(node.GetAttribName(i)=="fps"){
nodeConvert = node.GetAttribVal(i);
g_setting.bd_prop[bd].framerates[ch] = (BYTE)(LPCTSTR)nodeConvert;
}//fps
if(node.GetAttribName(i)=="height"){
//nodeConvert = node.GetAttribVal(i);
imgHeight= atoi(node.GetAttribVal(i));//(BYTE)(LPCTSTR)nodeConvert;
}//height
if(node.GetAttribName(i)=="width"){
//nodeConvert = node.GetAttribVal(i);
imgWidth= atoi(node.GetAttribVal(i));//(BYTE)(LPCTSTR)nodeConvert;
g_setting.bd_prop[bd].ch_prop[ch].dwImageSize = CMN5_MAKEIMGSIZE(imgWidth, imgHeight);
}//width
if(node.GetAttribName(i)=="videoformat"){
nodeConvert = node.GetAttribVal(i);
g_setting.bd_prop[bd].videoformat = atol((char*)(LPCTSTR)nodeConvert);
}//videoformat
if(node.GetAttribName(i)=="colorformat"){
nodeConvert = node.GetAttribVal(i);
g_setting.bd_prop[bd].colorformat = atol((char*)(LPCTSTR)nodeConvert);
}//colorformat
if(node.GetAttribName(i)=="sensitivity"){
nodeConvert = node.GetAttribVal(i);
g_setting.bd_prop[bd].ch_prop[ch].dwMotionSensitivity = atol((char*)(LPCTSTR)nodeConvert);
}//sensitivity
if(node.GetAttribName(i)=="hue"){
nodeConvert = node.GetAttribVal(i);
g_setting_rt.bd_prop[bd].ch_prop[ch].dwHue = atol((char*)(LPCTSTR)nodeConvert);
}//hue
if(node.GetAttribName(i)=="saturationV"){
nodeConvert = node.GetAttribVal(i);
g_setting_rt.bd_prop[bd].ch_prop[ch].dwSaturationv = atol((char*)(LPCTSTR)nodeConvert);
}//saturationV
if(node.GetAttribName(i)=="saturationU"){
nodeConvert = node.GetAttribVal(i);
g_setting_rt.bd_prop[bd].ch_prop[ch].dwSaturationu = atol((char*)(LPCTSTR)nodeConvert);
}//saturationU
if(node.GetAttribName(i)=="contrast"){
nodeConvert = node.GetAttribVal(i);
g_setting_rt.bd_prop[bd].ch_prop[ch].dwContrast = atol((char*)(LPCTSTR)nodeConvert);
}//contrast
if(node.GetAttribName(i)=="brightness"){
nodeConvert = node.GetAttribVal(i);
g_setting_rt.bd_prop[bd].ch_prop[ch].dwBrightness = atol((char*)(LPCTSTR)nodeConvert);
}//brightness
if(node.GetAttribName(i)=="enabled"){
nodeConvert = node.GetAttribVal(i);
g_setting_rt.bd_prop[bd].ch_prop[ch].bOvrEnable = atol((char*)(LPCTSTR)nodeConvert);
g_setting_rt.bd_prop[bd].ch_prop[ch].bCodEnable = atol((char*)(LPCTSTR)nodeConvert);
g_setting_rt.bd_prop[bd].ch_prop[ch].bCapEnable = atol((char*)(LPCTSTR)nodeConvert);
}//enabled
if(node.GetAttribName(i)=="di"){
nodeConvert = node.GetAttribVal(i);
g_setting_rt.bd_prop[bd].d_i = atol((char*)(LPCTSTR)nodeConvert);
}//di
if(node.GetAttribName(i)=="do"){
nodeConvert = node.GetAttribVal(i);
g_setting_rt.bd_prop[bd].d_o = atol((char*)(LPCTSTR)nodeConvert);
}//di
}
for (int i = 0; i < node.NumNodes(); i++)
{
ParseNode(node.GetNode(i),hItem);
}
}
#include "stdafx.h"
#include "LoadDrivers.h"
#include "GetSN.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
GetSN getSN;
BYTE actual[16] = {0, };
CLoadDrivers::CLoadDrivers()
{
hModuleMP = NULL;
hr = NULL;
m_OvrApi = NULL;
}
CLoadDrivers::~CLoadDrivers()
{
delete m_pOvrBoardInfo;
}
void CLoadDrivers::DriverSelect()
{
BOOL rs;
hModuleMP = LoadLibrary("ECPSV.dll"); //ECRP Capture board Driver
*(FARPROC*)&m_Uda5Api.Cmn5CreateInstance = GetProcAddress(hModuleMP,"Cmn5CreateInstance");
IUnknown * pCaptureCard;
m_Uda5Api.Cmn5CreateInstance(&pCaptureCard);
hr = pCaptureCard->QueryInterface (IID_IOvr5,(void**)&m_OvrApi);
rs = m_OvrApi->Ovr5GetSystemInfo(&m_SysInfo);
if(!rs)TRACE("No Capture Cards Drivers Installed!\n\r");
if(rs)TRACE("Capture Cards Drivers Installed!\n\r");
m_pOvrBoardInfo = new OVR5_BOARD_INFO[m_SysInfo.uNumOfBoard];
CMN5_BOARD_INFO_DESC desc = {sizeof(OVR5_BOARD_INFO),1,0,};
for(int i=0;i<(signed)m_SysInfo.uNumOfBoard;i++) {
m_OvrApi->Ovr5GetBoardInfo(i,&desc,&m_pOvrBoardInfo [i]);
getSN.GetActCodefromModelID(m_pOvrBoardInfo[i].uModelID,actual);
rs = m_OvrApi->Ovr5Activate(0,actual);
if(!rs) TRACE("Activation Failed %d\r",i);
if(rs) TRACE("Activation Passed %d\r",i);
}
TRACE("Number of Boards %d\r",m_SysInfo.uNumOfBoard);
pCaptureCard->Release();
}
// GetSN.cpp : implementation file
//
#include "stdafx.h"
#include "GetSN.h"
// GetSN
IMPLEMENT_DYNAMIC(GetSN, CWnd)
GetSN::GetSN()
{
}
GetSN::~GetSN()
{
}
BEGIN_MESSAGE_MAP(GetSN, CWnd)
END_MESSAGE_MAP()
// GetSN message handlers
struct CMN_MODELID_ACTCODE {
//DWORD hwid;
DWORD ModelID;
BYTE ActCode[16];
};
/*
########################################################
# Company Details and serial Number and board ID Check #
########################################################
*/
CMN_MODELID_ACTCODE g_IDnCode[] = {
{0x181, {0x2a,0x96,0x75,0x56,0xc8,0x9e,0x6b,0x1d,0xcd,0x76,0x99,0x3e,0x2f,0x8a,0xb8,0x29}},//Video Server NVS
{0xfff, {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff}},//NVE
{0x104, {0x88,0x2f,0x9c,0x24,0xb1,0xaf,0x1d,0x73,0x96,0x6c,0x58,0x74,0x53,0x2e,0x82,0x19}},//NCP100V2
{0x112, {0x7c,0x21,0x4b,0xec,0xc2,0xfe,0x7b,0x00,0xe7,0xfe,0xc6,0x46,0xa9,0x57,0xf2,0x62}},//NCP1000
{0x113, {0x20,0x04,0x9f,0x3f,0xd5,0xfb,0xd2,0x75,0x20,0x9f,0xc6,0xd3,0x49,0xdc,0x3f,0xef}},//NCP1200V2
{0x102, {0x58,0x76,0xc3,0x6b,0x71,0x65,0xd7,0x85,0x0b,0x43,0x83,0x4e,0x8d,0xee,0x0a,0x75}},//NCP2000V2
{0x121, {0x51,0x36,0x76,0xc7,0xc6,0x59,0x5d,0xab,0x4d,0xe4,0x99,0x23,0x12,0x41,0x41,0x28}},//NCP3000V2
{0x116, {0x12,0x1b,0xe5,0xb0,0x64,0x47,0xf9,0x74,0x62,0x09,0xbc,0x81,0xf5,0xdf,0x85,0xfa}},//NCP3100V2
{0x114, {0x64,0xfc,0xeb,0x49,0xf3,0xc6,0xb8,0xf3,0x40,0x87,0xff,0x7f,0x32,0xca,0xca,0xd5}},//NCP3200V2
{0x117, {0xaf,0x23,0xf5,0x22,0xce,0xe3,0x46,0x13,0xee,0x7a,0x8e,0xe9,0xf8,0x53,0xc5,0xe3}},//NCP3100V4
{0x118, {0x32,0xac,0x55,0x40,0xa7,0x50,0xdd,0x33,0xdc,0x21,0x05,0xcd,0x89,0xbb,0x0e,0x2a}},//NCP3000V4
{0x119, {0xdb,0x34,0x20,0xb7,0xc5,0xbb,0x7a,0x8f,0x94,0x6d,0xb8,0x6c,0xcc,0x53,0x77,0x9a}},//NCP100V4
{0x11A, {0x72,0x13,0x3c,0xe6,0xc3,0x47,0x7e,0xfe,0x08,0x46,0xd8,0x31,0xa2,0x2f,0xe5,0x92}},//NCP1000V4
{0x11B, {0xc1,0x08,0x99,0xca,0x65,0xe7,0x1c,0x96,0xed,0xca,0x27,0xdb,0xc5,0x21,0x9d,0x0a}},//NCP1200V4
{0x11C, {0x3b,0x69,0xc3,0xe7,0x90,0xe7,0x1b,0x52,0xeb,0xba,0xb1,0xf9,0x09,0x1c,0xfc,0x2e}},//NCP2000V4
{0x11D, {0x22,0x63,0x27,0xd9,0x64,0xbd,0x49,0xcd,0x9c,0x9d,0x8e,0xa0,0xba,0xd7,0x2c,0x78}},//NCP3200V4
{0x103, {0x63,0x6a,0xdb,0x9e,0xd6,0xa9,0x5d,0x2c,0x4e,0x60,0x94,0xd0,0x7f,0x75,0x94,0xc1}},//CAP1000
{0x110, {0x20,0x04,0x9f,0x3f,0xd5,0xfb,0xd2,0x75,0x20,0x9f,0xc6,0xd3,0x49,0xdc,0x3f,0xef}},//NCP1200
{0x101, {0xb8,0x76,0xa3,0xeb,0xd1,0x65,0x77,0x05,0xab,0x43,0x26,0xd6,0x8a,0xf1,0x39,0x05}},//CAP3000
{0x0120, {0x73,0xe2,0xec,0x47,0x4f,0xe7,0x82,0xcd,0x09,0x18,0xad,0xaa,0x48,0xc0,0x07,0xff}},//NCP4000
{0x0040, {0x2b,0x54,0xf6,0xc5,0xf2,0x09,0x8d,0xe4,0x58,0x7c,0x6b,0xf4,0x98,0xb2,0x8f,0xd6}},//CAPA16
{0x01A0, { 0x78, 0x76, 0x1b, 0x53, 0x5f, 0x33, 0x02, 0xe0, 0x68, 0x39, 0x2d, 0xfa, 0x34, 0x05, 0xa5, 0x04}}, //RCP120
{0x01A1, { 0x30, 0xcd, 0xc0, 0x37, 0xce, 0x53, 0x21, 0x8d, 0xd6, 0x73, 0xba, 0x60, 0xdc, 0xa8, 0x4a, 0x0d}}, //RCP240
{0x01A2, { 0x68, 0x73, 0x30, 0xf2, 0xd8, 0x74, 0x9f, 0xaf, 0xac, 0xa6, 0xc4, 0x93, 0xa7, 0x68, 0xc9, 0xe4}}, //RCP480
{0x01AA, { 0xcb, 0xab, 0xac, 0x73, 0xbd, 0xaa, 0xcb, 0x5b, 0x3b, 0x8a, 0xa0, 0xa9, 0x80, 0x28, 0x25, 0xa5}}, //ECPR120-4
{0x01AB, { 0xb6, 0x79, 0xb2, 0x37, 0x85, 0x43, 0xda, 0x14, 0x32, 0x05, 0x8b, 0x84, 0xb1, 0x12, 0x5f, 0x27}}, //ECPR240-16
{0x01AC, { 0x7f, 0x29, 0x6d, 0x41, 0xd9, 0x14, 0x8f, 0x8a, 0xa0, 0x1b, 0xfb, 0x3c, 0x5f, 0x5f, 0x81, 0xfb}}, //ECPR480-16
{0x01A6, { 0xd6, 0x5f, 0xb2, 0x80, 0x2c, 0xd1, 0xc7, 0x96, 0xc5, 0xfc, 0x4b, 0x64, 0x04, 0x46, 0xc3, 0x8d}}, //MP2000
{0x01A7, { 0x3b, 0x79, 0xd5, 0x7c, 0x51, 0xe1, 0x18, 0xca, 0xd9, 0x9f, 0xad, 0x7e, 0xc4, 0xbc, 0x40, 0x25}}, //MP3000
{0x01A8, { 0x2e, 0x79, 0xfb, 0x57, 0x72, 0x08, 0x09, 0x76, 0x52, 0x68, 0x3e, 0xaf, 0x66, 0x5d, 0x56, 0x9b}}, //MP4000
{0x013A, { 0xba, 0x1d, 0xe6, 0xc2, 0x0d, 0xfe, 0x4a, 0xad, 0xb1, 0x6d, 0xfb, 0xeb, 0xd3, 0x20, 0xb6, 0x5c}}, //ECP32
};
BOOL GetSN::GetActCodefromModelID(DWORD hwid, UCHAR * actCode)
{
for(int i=0;i<sizeof(g_IDnCode)/sizeof(CMN_MODELID_ACTCODE);i++){
if(g_IDnCode[i].ModelID == hwid){
CopyMemory(actCode,g_IDnCode[i].ActCode,16);
return TRUE;
}
}
return FALSE;
}
//###################################################
//# END OF SERIAL KEY ACTIVATION ################
//###################################################
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Hi Thanks very much for your help it works fine now and I understand what is going on with this function, It is a cool function that will help me alot in the rest of the project, The time you have spent with me is worth more points than originally specified so I have increased them
Thanks again
Thanks again
ASKER
Thanks very much for your help and understanding
Regards
Nigel
Regards
Nigel
That is very kind of you ... many thanks. I'm just pleased to have been able to help you.
Take care my friend.
-Rx.
Take care my friend.
-Rx.
If m_OvrApi is declared public, you should be able to access from the LoadDrivers object.
If not, create a method that returns the pointer. Â Then you can access the returned value.
Good Luck,
Kent