STDAPI DllRegisterServer() { assert(g_hModule != NULL); HRESULT hr = S_OK; // Register the CLSID for CoCreateInstance. hr = RegisterObject(g_hModule, CLSID_GrayscaleMFT, TEXT("Grayscale Video Effect"), TEXT("Both")); // Register the MFT for MFT enumeration. if (SUCCEEDED(hr)) { hr = MFTRegister( CLSID_GrayscaleMFT, // CLSID MFT_CATEGORY_VIDEO_EFFECT, // Category L"Grayscale Video Effect", // Friendly name 0, // Reserved, must be zero. 0, NULL, 0, NULL, NULL ); } return hr; }
static void test_register(void) { static WCHAR name[] = {'W','i','n','e',' ','t','e','s','t',0}; MFT_REGISTER_TYPE_INFO input[] = { { DUMMY_CLSID, DUMMY_GUID1 } }; MFT_REGISTER_TYPE_INFO output[] = { { DUMMY_CLSID, DUMMY_GUID2 } }; CLSID *clsids; UINT32 count; HRESULT ret; ret = MFTRegister(DUMMY_CLSID, MFT_CATEGORY_OTHER, name, 0, 1, input, 1, output, NULL); if (ret == E_ACCESSDENIED) { win_skip("Not enough permissions to register a filter\n"); return; } ok(ret == S_OK, "Failed to register dummy filter: %x\n", ret); if(0) { /* NULL name crashes on windows */ ret = MFTRegister(DUMMY_CLSID, MFT_CATEGORY_OTHER, NULL, 0, 1, input, 1, output, NULL); ok(ret == E_INVALIDARG, "got %x\n", ret); } ret = MFTRegister(DUMMY_CLSID, MFT_CATEGORY_OTHER, name, 0, 0, NULL, 0, NULL, NULL); ok(ret == S_OK, "Failed to register dummy filter: %x\n", ret); ret = MFTRegister(DUMMY_CLSID, MFT_CATEGORY_OTHER, name, 0, 1, NULL, 0, NULL, NULL); ok(ret == S_OK, "Failed to register dummy filter: %x\n", ret); ret = MFTRegister(DUMMY_CLSID, MFT_CATEGORY_OTHER, name, 0, 0, NULL, 1, NULL, NULL); ok(ret == S_OK, "Failed to register dummy filter: %x\n", ret); if(0) { /* NULL clsids/count crashes on windows (vista) */ count = 0; ret = MFTEnum(MFT_CATEGORY_OTHER, 0, NULL, NULL, NULL, NULL, &count); ok(ret == E_POINTER, "Failed to enumerate filters: %x\n", ret); ok(count == 0, "Expected count > 0\n"); clsids = NULL; ret = MFTEnum(MFT_CATEGORY_OTHER, 0, NULL, NULL, NULL, &clsids, NULL); ok(ret == E_POINTER, "Failed to enumerate filters: %x\n", ret); ok(count == 0, "Expected count > 0\n"); } count = 0; clsids = NULL; ret = MFTEnum(MFT_CATEGORY_OTHER, 0, NULL, NULL, NULL, &clsids, &count); ok(ret == S_OK, "Failed to enumerate filters: %x\n", ret); ok(count > 0, "Expected count > 0\n"); ok(clsids != NULL, "Expected clsids != NULL\n"); ok(check_clsid(clsids, count), "Filter was not part of enumeration\n"); CoTaskMemFree(clsids); count = 0; clsids = NULL; ret = MFTEnum(MFT_CATEGORY_OTHER, 0, input, NULL, NULL, &clsids, &count); ok(ret == S_OK, "Failed to enumerate filters: %x\n", ret); ok(count > 0, "Expected count > 0\n"); ok(clsids != NULL, "Expected clsids != NULL\n"); ok(check_clsid(clsids, count), "Filter was not part of enumeration\n"); CoTaskMemFree(clsids); count = 0; clsids = NULL; ret = MFTEnum(MFT_CATEGORY_OTHER, 0, NULL, output, NULL, &clsids, &count); ok(ret == S_OK, "Failed to enumerate filters: %x\n", ret); ok(count > 0, "Expected count > 0\n"); ok(clsids != NULL, "Expected clsids != NULL\n"); ok(check_clsid(clsids, count), "Filter was not part of enumeration\n"); CoTaskMemFree(clsids); count = 0; clsids = NULL; ret = MFTEnum(MFT_CATEGORY_OTHER, 0, input, output, NULL, &clsids, &count); ok(ret == S_OK, "Failed to enumerate filters: %x\n", ret); ok(count > 0, "Expected count > 0\n"); ok(clsids != NULL, "Expected clsids != NULL\n"); ok(check_clsid(clsids, count), "Filter was not part of enumeration\n"); CoTaskMemFree(clsids); /* exchange input and output */ count = 0; clsids = NULL; ret = MFTEnum(MFT_CATEGORY_OTHER, 0, output, input, NULL, &clsids, &count); ok(ret == S_OK, "Failed to enumerate filters: %x\n", ret); ok(!count, "got %d\n", count); ok(clsids == NULL, "Expected clsids == NULL\n"); ret = MFTUnregister(DUMMY_CLSID); ok(ret == S_OK || /* w7pro64 */ broken(ret == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND)), "got %x\n", ret); ret = MFTUnregister(DUMMY_CLSID); ok(ret == S_OK || broken(ret == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND)), "got %x\n", ret); }
STDAPI DllRegisterServer() { HRESULT hr = DllUnregisterServer(); assert(SUCCEEDED(hr)); std::wstring filename_; hr = ComReg::ComRegGetModuleFileName(g_hModule, filename_); assert(SUCCEEDED(hr)); assert(!filename_.empty()); const wchar_t* const filename = filename_.c_str(); #if _DEBUG const wchar_t friendly_name[] = L"WebM MF VP8 Decoder Transform (Debug)"; #else const wchar_t friendly_name[] = L"WebM MF VP8 Decoder Transform"; #endif hr = ComReg::RegisterCoclass( WebmTypes::CLSID_WebmMfVp8Dec, friendly_name, filename, L"Webm.MfVp8Dec", //TODO: do we really need ProgIDs? L"Webm.MfVp8Dec.1", false, //not insertable false, //not a control ComReg::kBoth, //DShow filters must support "both" GUID_NULL, //typelib 0, //no version specified 0); //no toolbox bitmap if (FAILED(hr)) return hr; enum { cInputTypes = 1 }; MFT_REGISTER_TYPE_INFO pInputTypes[cInputTypes] = { { MFMediaType_Video, WebmTypes::MEDIASUBTYPE_VP80 } }; enum { cOutputTypes = 3 }; MFT_REGISTER_TYPE_INFO pOutputTypes[cOutputTypes] = { { MFMediaType_Video, MFVideoFormat_NV12 }, { MFMediaType_Video, MFVideoFormat_YV12 }, { MFMediaType_Video, MFVideoFormat_IYUV } }; wchar_t* const friendly_name_ = const_cast<wchar_t*>(friendly_name); hr = MFTRegister( WebmTypes::CLSID_WebmMfVp8Dec, MFT_CATEGORY_VIDEO_DECODER, friendly_name_, MFT_ENUM_FLAG_SYNCMFT, //TODO: for now, just support sync cInputTypes, pInputTypes, cOutputTypes, pOutputTypes, 0); //no attributes return hr; }