home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 October / CMCD1004.ISO / Software / Shareware / Utilitare / pec / pec2setup.exe / sdk / codec / template / pec2codec_template_host.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2004-07-15  |  2.5 KB  |  105 lines

  1. ////////////////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // This source file handles the CODEC HOST (which can host any number of CODECs withink it)
  4. // interface. It has two functions used to determine the number of CODECs, and to get entry
  5. // points to specific CODEC based on their index number.
  6. //
  7. // There are two functions exposed by the CODEC host:
  8. //
  9. //    GetNumberOfCodecs        - retrieves number of CODECs in this host
  10. //      CodecGetProcAddress   - retrieve the entry point for a specific CODEC API.
  11. //
  12. //
  13. //    PEC2CODEC_HOST_API FARPROC WINAPI CodecGetProcAddress(DWORD dwCodecIndex, LPCTSTR ptszApiName);
  14. //    PEC2CODEC_HOST_API DWORD WINAPI GetNumberOfCodecs();
  15. //
  16. //
  17. #include "stdafx.h"
  18. #include "..\pec2codecsdk.h"
  19. #include "pec2codec_template.h"
  20. #include "Codec_0_EntryPoints.h"
  21.  
  22. PEC2CODEC_TEMPLATE_API DWORD WINAPI GetNumberOfCodecs()
  23. {
  24.     return PEC2_CODECS_IN_HOST;
  25. }
  26.  
  27.  
  28. ///////////////////////////////////////////////
  29. //
  30. // Names of entry points for each CODEC.
  31. //
  32. // names must be lowercase for compare
  33. //
  34. TCHAR *ptszApiNames[]=
  35. {
  36.     _T("decodefast"),
  37.     _T("decodesmall"),
  38.     _T("getdecodesmallfuncsize"),
  39.     _T("getdecodefastfuncsize"),
  40.     _T("encode"),
  41.     _T("getcodecauthor"),
  42.     _T("getcodecname"),
  43.     _T("getcodecversion"),
  44.     NULL
  45. };
  46.  
  47. //
  48. // entry points for CODEC index #0
  49. //
  50. FARPROC Codec_0_pApiAddress[]=
  51. {
  52.     (FARPROC)NULL,
  53.     (FARPROC)&Decode_Small,
  54.     (FARPROC)&GetDecodeSmallFuncSize,
  55.     (FARPROC)NULL,
  56.     (FARPROC)&Encode,
  57.     (FARPROC)&GetCodecAuthor,
  58.     (FARPROC)&GetCodecName,
  59.     (FARPROC)&GetCodecVersion
  60. };
  61.  
  62. //
  63. // more arrary entry point are needed for additional CODEC(s)
  64. //
  65.  
  66. PEC2CODEC_TEMPLATE_API FARPROC WINAPI CodecGetProcAddress(DWORD dwCodecIndex, LPCTSTR ptszApiName)
  67. {
  68.     TCHAR *ptszCompare=new TCHAR[_tcslen(ptszApiName)+1];
  69.     _tcscpy(ptszCompare,ptszApiName);
  70.     _tcslwr(ptszCompare);
  71.     for(int nN=0;ptszApiNames[nN];nN++)
  72.     {
  73.         if(_tcscmp(ptszCompare,ptszApiNames[nN])==0)
  74.         {
  75.             switch(dwCodecIndex)
  76.             {
  77.             case 0:    // CDODEC index #0
  78.                 return Codec_0_pApiAddress[nN];
  79.             //case 1:  // CODEC index #1
  80.                 //return Codec_1_pApiAddress[nN];
  81.             default:
  82.                 return NULL;        // unknown index number, return NULL
  83.             }
  84.         }
  85.     }
  86.     return NULL;        
  87. }
  88.  
  89. BOOL APIENTRY DllMain( HANDLE hModule, 
  90.                        DWORD  ul_reason_for_call, 
  91.                        LPVOID lpReserved
  92.                      )
  93. {
  94.     switch (ul_reason_for_call)
  95.     {
  96.     case DLL_PROCESS_ATTACH:
  97.     case DLL_THREAD_ATTACH:
  98.     case DLL_THREAD_DETACH:
  99.     case DLL_PROCESS_DETACH:
  100.         break;
  101.     }
  102.     return TRUE;
  103. }
  104.  
  105.