VSFilter.cpp
上传用户:xjjlds
上传日期:2015-12-05
资源大小:22823k
文件大小:6k
源码类别:

多媒体编程

开发平台:

Visual C++

  1. /* 
  2.  * Copyright (C) 2003-2005 Gabest
  3.  * http://www.gabest.org
  4.  *
  5.  *  This Program is free software; you can redistribute it and/or modify
  6.  *  it under the terms of the GNU General Public License as published by
  7.  *  the Free Software Foundation; either version 2, or (at your option)
  8.  *  any later version.
  9.  *   
  10.  *  This Program is distributed in the hope that it will be useful,
  11.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13.  *  GNU General Public License for more details.
  14.  *   
  15.  *  You should have received a copy of the GNU General Public License
  16.  *  along with GNU Make; see the file COPYING.  If not, write to
  17.  *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 
  18.  *  http://www.gnu.org/copyleft/gpl.html
  19.  *
  20.  */
  21. #include "stdafx.h"
  22. #include "DirectVobSubFilter.h"
  23. #include "DirectVobSubPropPage.h"
  24. #include "VSFilter.h"
  25. #include "......DSUtilMediaTypes.h"
  26. #include <initguid.h>
  27. #include "........includemoreuuids.h"
  28. /////////////////////////////////////////////////////////////////////////////
  29. // CVSFilterApp 
  30. BEGIN_MESSAGE_MAP(CVSFilterApp, CWinApp)
  31. END_MESSAGE_MAP()
  32. CVSFilterApp::CVSFilterApp()
  33. {
  34. }
  35. extern "C" BOOL WINAPI DllEntryPoint(HINSTANCE, ULONG, LPVOID);
  36. BOOL CVSFilterApp::InitInstance()
  37. {
  38. if(!CWinApp::InitInstance())
  39. return FALSE;
  40. SetRegistryKey(_T("Gabest"));
  41. DllEntryPoint(AfxGetInstanceHandle(), DLL_PROCESS_ATTACH, 0); // "DllMain" of the dshow baseclasses
  42. STARTUPINFO si;
  43. GetStartupInfo(&si);
  44. m_AppName = CString(si.lpTitle);
  45. m_AppName.Replace('\', '/');
  46. m_AppName = m_AppName.Mid(m_AppName.ReverseFind('/')+1);
  47. m_AppName.MakeLower();
  48. return TRUE;
  49. }
  50. int CVSFilterApp::ExitInstance()
  51. {
  52. DllEntryPoint(AfxGetInstanceHandle(), DLL_PROCESS_DETACH, 0); // "DllMain" of the dshow baseclasses
  53. return CWinApp::ExitInstance();
  54. }
  55. HINSTANCE CVSFilterApp::LoadAppLangResourceDLL()
  56. {
  57. CString fn;
  58. fn.ReleaseBufferSetLength(::GetModuleFileName(m_hInstance, fn.GetBuffer(MAX_PATH), MAX_PATH));
  59. fn = fn.Mid(fn.ReverseFind('\')+1);
  60. fn = fn.Left(fn.ReverseFind('.')+1);
  61. fn = fn + _T("lang");
  62. return ::LoadLibrary(fn);
  63. }
  64. CVSFilterApp theApp;
  65. //////////////////////////////////////////////////////////////////////////
  66. const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] =
  67. {
  68. {&MEDIATYPE_NULL, &MEDIASUBTYPE_NULL},
  69. {&MEDIATYPE_Video, &MEDIASUBTYPE_YUY2},
  70. {&MEDIATYPE_Video, &MEDIASUBTYPE_YV12},
  71. {&MEDIATYPE_Video, &MEDIASUBTYPE_I420},
  72. {&MEDIATYPE_Video, &MEDIASUBTYPE_IYUV},
  73. {&MEDIATYPE_Video, &MEDIASUBTYPE_RGB32},
  74. {&MEDIATYPE_Video, &MEDIASUBTYPE_RGB565},
  75. {&MEDIATYPE_Video, &MEDIASUBTYPE_RGB555},
  76. {&MEDIATYPE_Video, &MEDIASUBTYPE_RGB24},
  77. };
  78. const AMOVIESETUP_MEDIATYPE sudPinTypesIn2[] =
  79. {
  80. {&MEDIATYPE_Text, &MEDIASUBTYPE_None},
  81. };
  82. const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] =
  83. {
  84. {&MEDIATYPE_Video, &MEDIASUBTYPE_None},
  85. };
  86. const AMOVIESETUP_PIN sudpPins[] =
  87. {
  88.     {L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesIn), sudPinTypesIn},
  89.     {L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesOut), sudPinTypesOut},
  90.     {L"Input2", TRUE, FALSE, FALSE, TRUE, &CLSID_NULL, NULL, countof(sudPinTypesIn2), sudPinTypesIn2}
  91. };
  92. /*const*/ AMOVIESETUP_FILTER sudFilter[] =
  93. {
  94. {&__uuidof(CDirectVobSubFilter), L"DirectVobSub", MERIT_DO_NOT_USE, countof(sudpPins), sudpPins},
  95. {&__uuidof(CDirectVobSubFilter2), L"DirectVobSub (auto-loading version)", MERIT_PREFERRED+2, countof(sudpPins), sudpPins},
  96. };
  97. CFactoryTemplate g_Templates[] =
  98. {
  99. {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CDirectVobSubFilter>, NULL, &sudFilter[0]},
  100.     {sudFilter[1].strName, sudFilter[1].clsID, CreateInstance<CDirectVobSubFilter2>, NULL, &sudFilter[1]},
  101.     {L"DVSMainPPage", &__uuidof(CDVSMainPPage), CreateInstance<CDVSMainPPage>},
  102.     {L"DVSGeneralPPage", &__uuidof(CDVSGeneralPPage), CreateInstance<CDVSGeneralPPage>},
  103.     {L"DVSMiscPPage", &__uuidof(CDVSMiscPPage), CreateInstance<CDVSMiscPPage>},
  104.     {L"DVSTimingPPage", &__uuidof(CDVSTimingPPage), CreateInstance<CDVSTimingPPage>},
  105. {L"DVSZoomPPage", &__uuidof(CDVSZoomPPage), CreateInstance<CDVSZoomPPage>},
  106.     {L"DVSColorPPage", &__uuidof(CDVSColorPPage), CreateInstance<CDVSColorPPage>},
  107.     {L"DVSPathsPPage", &__uuidof(CDVSPathsPPage), CreateInstance<CDVSPathsPPage>},
  108. {L"DVSAboutPPage", &__uuidof(CDVSAboutPPage), CreateInstance<CDVSAboutPPage>},
  109. };
  110. int g_cTemplates = countof(g_Templates);
  111. //////////////////////////////
  112. /*removeme*/
  113. extern void JajDeGonoszVagyok();
  114. STDAPI DllRegisterServer()
  115. {
  116. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  117. if(theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_SEENDIVXWARNING), 0) != 1)
  118. theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_SEENDIVXWARNING), 0);
  119. if(theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_VMRZOOMENABLED), -1) == -1)
  120. theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_VMRZOOMENABLED), 0);
  121. if(theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_ENABLEZPICON), -1) == -1)
  122. theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_ENABLEZPICON), 0);
  123. /*removeme*/
  124. JajDeGonoszVagyok();
  125. return AMovieDllRegisterServer2(TRUE);
  126. }
  127. STDAPI DllUnregisterServer()
  128. {
  129. // DVS_WriteProfileInt2(IDS_R_GENERAL, IDS_RG_SEENDIVXWARNING, 0);
  130. return AMovieDllRegisterServer2(FALSE);
  131. }
  132. void CALLBACK DirectVobSub(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow)
  133. {
  134. if(FAILED(::CoInitialize(0))) return;
  135.     CComPtr<IBaseFilter> pFilter;
  136. CComQIPtr<ISpecifyPropertyPages> pSpecify;
  137. if(SUCCEEDED(pFilter.CoCreateInstance(__uuidof(CDirectVobSubFilter))) && (pSpecify = pFilter))
  138. {
  139. ShowPPage(pFilter, hwnd);
  140. }
  141. ::CoUninitialize();
  142. }