www.pudn.com > VOBSUB.rar > Main.cpp


#include "stdafx.h" 
 
#include "resource.h" 
 
#include  
 
#include "DirectVobSubUIDs.h" 
 
#include "DirectVobSubFilter.h" 
#include "TextInputPin.h" 
#include "DirectVobSubInputPin.h" 
#include "DirectVobSubOutputPin.h" 
#include "DirectVobSubPropPage.h" 
 
#include "SubtitleSource.h" 
 
#include "misc.h" 
 
extern "C" BOOL WINAPI DllEntryPoint(HINSTANCE, ULONG, LPVOID); 
 
extern void ColorConvInit(); 
 
#include "Main.h" 
 
///////////////////////////////////////////////////////////////////////////// 
// CDVobSubApp  
 
BEGIN_MESSAGE_MAP(CDVobSubApp, CVSApp) 
	//{{AFX_MSG_MAP(CDVobSubApp) 
	//}}AFX_MSG_MAP 
END_MESSAGE_MAP() 
 
CDVobSubApp::CDVobSubApp() 
{ 
} 
 
BOOL CDVobSubApp::InitInstance() 
{ 
	if(!CVSApp::InitInstance()) 
		return FALSE; 
 
	SetRegistryKey(_T("Gabest")); 
 
	DllEntryPoint(AfxGetInstanceHandle(), DLL_PROCESS_ATTACH, 0); // "DllMain" of the dshow baseclasses 
 
	ColorConvInit(); 
 
	STARTUPINFO si; 
	GetStartupInfo(&si); 
	m_AppName = CString(si.lpTitle); 
	m_AppName.Replace('\\', '/'); 
	m_AppName = m_AppName.Mid(m_AppName.ReverseFind('/')+1); 
	m_AppName.MakeLower(); 
 
	return TRUE; 
} 
 
int CDVobSubApp::ExitInstance() 
{ 
	DllEntryPoint(AfxGetInstanceHandle(), DLL_PROCESS_DETACH, 0); // "DllMain" of the dshow baseclasses 
 
	return CVSApp::ExitInstance(); 
} 
 
CDVobSubApp theApp; 
 
////////////////////////////////////////////////////////////////////////// 
 
const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] = 
{ 
	{ 
		&MEDIATYPE_NULL,			// Major type 
		&MEDIASUBTYPE_NULL,     // Minor type 
	}, 
	{ 
		&MEDIATYPE_Video,			// Major type 
		&MEDIASUBTYPE_YUY2,     // Minor type 
	}, 
	{ 
		&MEDIATYPE_Video,			// Major type 
		&MEDIASUBTYPE_YV12,     // Minor type 
	}, 
	{ 
		&MEDIATYPE_Video,			// Major type 
		&MEDIASUBTYPE_RGB32,     // Minor type 
	}, 
	{ 
		&MEDIATYPE_Video,			// Major type 
		&MEDIASUBTYPE_RGB565,     // Minor type 
	}, 
	{ 
		&MEDIATYPE_Video,			// Major type 
		&MEDIASUBTYPE_RGB555,     // Minor type 
	}, 
	{ 
		&MEDIATYPE_Video,			// Major type 
		&MEDIASUBTYPE_RGB24,     // Minor type 
	}, 
}; 
 
const AMOVIESETUP_MEDIATYPE sudPinTypesIn2 = 
{ 
	&MEDIATYPE_Text,        // Major type 
    &MEDIASUBTYPE_None,     // Minor type 
}; 
 
const AMOVIESETUP_MEDIATYPE sudPinTypesOut = 
{ 
    &MEDIATYPE_Video,       // Major type 
    &MEDIASUBTYPE_None,     // Minor type 
}; 
 
 
const AMOVIESETUP_PIN sudpPins[] = 
{ 
    { L"Input",             // Pins string name 
      FALSE,                // Is it rendered 
      FALSE,                // Is it an output 
      FALSE,                // Are we allowed none 
      FALSE,                // And allowed many 
      &CLSID_NULL,          // Connects to filter 
      NULL,                 // Connects to pin 
      sizeof(sudPinTypesIn)/sizeof(sudPinTypesIn[0]), // Number of types 
      sudPinTypesIn         // Pin information 
    }, 
    { L"Output",            // Pins string name 
      FALSE,                // Is it rendered 
      TRUE,                 // Is it an output 
      FALSE,                // Are we allowed none 
      FALSE,                // And allowed many 
      &CLSID_NULL,          // Connects to filter 
      NULL,                 // Connects to pin 
      1,                    // Number of types 
      &sudPinTypesOut       // Pin information 
    }, 
    { L"Input2",            // Pins string name 
      TRUE,                 // Is it rendered 
      FALSE,                // Is it an output 
      FALSE,                // Are we allowed none 
      TRUE,                 // And allowed many 
      &CLSID_NULL,          // Connects to filter 
      NULL,                 // Connects to pin 
      1,                    // Number of types 
      &sudPinTypesIn2       // Pin information 
    } 
}; 
 
const AMOVIESETUP_PIN sudOpPin2 = 
{ 
    L"Output",              // Pin string name 
    FALSE,                  // Is it rendered 
    TRUE,                   // Is it an output 
    FALSE,                  // Can we have none 
    FALSE,                  // Can we have many 
    &CLSID_NULL,            // Connects to filter 
    NULL,                   // Connects to pin 
    1,                      // Number of types 
    &sudPinTypesIn2         // Pin details 
}; 
 
const AMOVIESETUP_FILTER sudDirectVobSubFilter = 
{ 
    &CLSID_DirectVobSubFilter,    // Filter CLSID 
    L"DirectVobSub",        // String name 
    MERIT_DO_NOT_USE,       // Filter merit 
    3,                      // Number of pins 
    sudpPins                // Pin information 
}; 
 
const AMOVIESETUP_FILTER sudDirectVobSubFilter2 = 
{ 
    &CLSID_DirectVobSubFilter2,    // Filter CLSID 
    L"DirectVobSub (auto-loading version)", // String name 
    MERIT_PREFERRED+2,      // Filter merit 
    3,                      // Number of pins 
    sudpPins                // Pin information 
}; 
 
const AMOVIESETUP_FILTER sudSubtitleSource = 
{ 
    &CLSID_SubtitleSource,    // Filter CLSID 
    L"Subtitle Source", // String name 
    MERIT_DO_NOT_USE,       // Filter merit 
    1,                      // Number of pins 
    &sudOpPin2               // Pin information 
}; 
 
CFactoryTemplate g_Templates[] = 
{ 
    { L"DirectVobSub" 
    , &CLSID_DirectVobSubFilter 
    , CDirectVobSubFilter::CreateInstance 
    , NULL 
    , &sudDirectVobSubFilter } 
  , 
    { L"DirectVobSub (auto-loading version)" 
    , &CLSID_DirectVobSubFilter2 
    , CDirectVobSubFilter2::CreateInstance 
    , NULL 
    , &sudDirectVobSubFilter2 } 
  , 
    { L"DVSMainPPage" 
    , &CLSID_DVSMainPPage 
    , CDVSMainPPage::CreateInstance } 
  , 
    { L"DVSGeneralPPage" 
    , &CLSID_DVSGeneralPPage 
    , CDVSGeneralPPage::CreateInstance } 
  , 
    { L"DVSMiscPPage" 
    , &CLSID_DVSMiscPPage 
    , CDVSMiscPPage::CreateInstance } 
  , 
    { L"DVSTimingPPage" 
    , &CLSID_DVSTimingPPage 
    , CDVSTimingPPage::CreateInstance } 
  , 
    { L"DVSZoomPPage" 
    , &CLSID_DVSZoomPPage 
    , CDVSZoomPPage::CreateInstance } 
  , 
    { L"DVSColorPPage" 
    , &CLSID_DVSColorPPage 
    , CDVSColorPPage::CreateInstance } 
  , 
    { L"DVSPathsPPage" 
    , &CLSID_DVSPathsPPage 
    , CDVSPathsPPage::CreateInstance } 
  , 
    { L"DVSAboutPPage" 
    , &CLSID_DVSAboutPPage 
    , CDVSAboutPPage::CreateInstance } 
  , 
	{ L"Subtitle Source" 
	, &CLSID_SubtitleSource 
	, CSubtitleSource::CreateInstance 
	, NULL 
	, &sudSubtitleSource} 
}; 
 
int g_cTemplates = sizeof(g_Templates) / sizeof(g_Templates[0]); 
 
////////////////////////////// 
 
STDAPI DllRegisterServer() 
{ 
	AFX_MANAGE_STATE(AfxGetStaticModuleState()); 
 
	if(theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_SEENDIVXWARNING), 0) != 1) 
		theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_SEENDIVXWARNING), 0); 
 
	if(theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_VMRZOOMENABLED), -1) == -1) 
		theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_VMRZOOMENABLED), 0); 
 
	if(theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_ENABLEZPICON), -1) == -1) 
		theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_ENABLEZPICON), 0); 
 
	return AMovieDllRegisterServer2(TRUE); 
} 
 
STDAPI DllUnregisterServer() 
{ 
//	DVS_WriteProfileInt2(IDS_R_GENERAL, IDS_RG_SEENDIVXWARNING, 0); 
 
	return AMovieDllRegisterServer2(FALSE); 
} 
 
void CALLBACK Configure(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow) 
{ 
	if(FAILED(::CoInitialize(0))) return; 
 
    CComPtr pFilter; 
	CComQIPtr pSpecify; 
 
	if(SUCCEEDED(pFilter.CoCreateInstance(CLSID_DirectVobSubFilter)) && (pSpecify = pFilter)) 
	{ 
		CAUUID caGUID; 
		caGUID.pElems = NULL; 
 
		if(SUCCEEDED(pSpecify->GetPages(&caGUID))) 
		{ 
			IUnknown* lpUnk = NULL; 
			pFilter.QueryInterface(&lpUnk); 
			OleCreatePropertyFrame( 
				NULL, 0, 0, L"DirectVobSub",  
				1, &lpUnk,  
				caGUID.cElems, caGUID.pElems,  
				0, 0, NULL); 
			lpUnk->Release(); 
 
			if(caGUID.pElems) CoTaskMemFree(caGUID.pElems); 
		} 
	} 
 
	::CoUninitialize(); 
}