/*********************************************************************** * ICRemove [MSVFW32.@] */ BOOL VFWAPI ICRemove(DWORD fccType, DWORD fccHandler, UINT wFlags) { reg_driver** pdriver; reg_driver* drv; TRACE("(%s,%s,0x%08x)\n", wine_dbgstr_fcc(fccType), wine_dbgstr_fcc(fccHandler), wFlags); /* Check if a driver is already registered */ for (pdriver = ®_driver_list; *pdriver; pdriver = &(*pdriver)->next) { if (!compare_fourcc(fccType, (*pdriver)->fccType) && !compare_fourcc(fccHandler, (*pdriver)->fccHandler)) break; } if (!*pdriver) return FALSE; /* Remove the driver from the list */ drv = *pdriver; *pdriver = (*pdriver)->next; HeapFree(GetProcessHeap(), 0, drv->name); HeapFree(GetProcessHeap(), 0, drv); return TRUE; }
/*********************************************************************** * ICInstall [MSVFW32.@] */ BOOL VFWAPI ICInstall(DWORD fccType, DWORD fccHandler, LPARAM lParam, LPSTR szDesc, UINT wFlags) { reg_driver* driver; unsigned len; TRACE("(%s,%s,%p,%p,0x%08x)\n", wine_dbgstr_fcc(fccType), wine_dbgstr_fcc(fccHandler), (void*)lParam, szDesc, wFlags); /* Check if a driver is already registered */ for (driver = reg_driver_list; driver; driver = driver->next) { if (!compare_fourcc(fccType, driver->fccType) && !compare_fourcc(fccHandler, driver->fccHandler)) break; } if (driver) return FALSE; /* Register the driver */ driver = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(reg_driver)); if (!driver) goto oom; driver->fccType = fccType; driver->fccHandler = fccHandler; switch(wFlags) { case ICINSTALL_FUNCTION: driver->proc = (DRIVERPROC)lParam; driver->name = NULL; break; case ICINSTALL_DRIVER: driver->proc = NULL; len = MultiByteToWideChar(CP_ACP, 0, (char*)lParam, -1, NULL, 0); driver->name = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); if (!driver->name) goto oom; MultiByteToWideChar(CP_ACP, 0, (char*)lParam, -1, driver->name, len); break; default: ERR("Invalid flags!\n"); HeapFree(GetProcessHeap(), 0, driver); return FALSE; } /* Insert our driver in the list*/ driver->next = reg_driver_list; reg_driver_list = driver; return TRUE; oom: HeapFree(GetProcessHeap(), 0, driver); return FALSE; }
static BOOL ICInfo_enum_handler(const char *name, const char *driver, unsigned int nr, void *param) { ICINFO *lpicinfo = param; DWORD fccType = mmioStringToFOURCCA(name, 0); DWORD fccHandler = mmioStringToFOURCCA(name + 5, 0); if (lpicinfo->fccHandler != nr && compare_fourcc(lpicinfo->fccHandler, fccHandler)) return FALSE; lpicinfo->fccType = fccType; lpicinfo->fccHandler = fccHandler; lpicinfo->dwFlags = 0; lpicinfo->dwVersion = 0; lpicinfo->dwVersionICM = ICVERSION; lpicinfo->szName[0] = 0; lpicinfo->szDescription[0] = 0; MultiByteToWideChar(CP_ACP, 0, driver, -1, lpicinfo->szDriver, ARRAY_SIZE(lpicinfo->szDriver)); return TRUE; }
/*********************************************************************** * ICOpen [MSVFW32.@] * Opens an installable compressor. Return special handle. */ HIC VFWAPI ICOpen(DWORD fccType, DWORD fccHandler, UINT wMode) { WCHAR codecname[10]; ICOPEN icopen; HDRVR hdrv; WINE_HIC* whic; static const WCHAR drv32W[] = {'d','r','i','v','e','r','s','3','2','\0'}; reg_driver* driver; TRACE("(%s,%s,0x%08x)\n", wine_dbgstr_fcc(fccType), wine_dbgstr_fcc(fccHandler), wMode); /* Check if there is a registered driver that matches */ driver = reg_driver_list; while(driver) if (!compare_fourcc(fccType, driver->fccType) && !compare_fourcc(fccHandler, driver->fccHandler)) break; else driver = driver->next; if (driver && driver->proc) /* The driver has been registered at runtime with its driverproc */ return ICOpenFunction(fccType, fccHandler, wMode, driver->proc); /* Well, lParam2 is in fact a LPVIDEO_OPEN_PARMS, but it has the * same layout as ICOPEN */ icopen.dwSize = sizeof(ICOPEN); icopen.fccType = fccType; icopen.fccHandler = fccHandler; icopen.dwVersion = 0x00001000; /* FIXME */ icopen.dwFlags = wMode; icopen.dwError = 0; icopen.pV1Reserved = NULL; icopen.pV2Reserved = NULL; icopen.dnDevNode = 0; /* FIXME */ if (!driver) { /* The driver is registered in the registry */ fourcc_to_string(codecname, fccType); codecname[4] = '.'; fourcc_to_string(codecname + 5, fccHandler); codecname[9] = '\0'; hdrv = OpenDriver(codecname, drv32W, (LPARAM)&icopen); if (!hdrv) return 0; } else { /* The driver has been registered at runtime with its name */ hdrv = OpenDriver(driver->name, NULL, (LPARAM)&icopen); if (!hdrv) return 0; } whic = HeapAlloc(GetProcessHeap(), 0, sizeof(WINE_HIC)); if (!whic) { CloseDriver(hdrv, 0, 0); return FALSE; } whic->hdrv = hdrv; whic->driverproc = NULL; whic->type = fccType; whic->handler = fccHandler; while (MSVIDEO_GetHicPtr((HIC)(ULONG_PTR)IC_HandleRef) != NULL) IC_HandleRef++; whic->hic = (HIC)(ULONG_PTR)IC_HandleRef++; whic->next = MSVIDEO_FirstHic; MSVIDEO_FirstHic = whic; TRACE("=> %p\n", whic->hic); return whic->hic; }
/*********************************************************************** * ICOpen [MSVFW32.@] * Opens an installable compressor. Return special handle. */ HIC VFWAPI ICOpen(DWORD fccType, DWORD fccHandler, UINT wMode) { WCHAR codecname[10]; ICOPEN icopen; HDRVR hdrv; WINE_HIC* whic; static const WCHAR drv32W[] = {'d','r','i','v','e','r','s','3','2','\0'}; reg_driver* driver; TRACE("(%s,%s,0x%08x)\n", wine_dbgstr_fcc(fccType), wine_dbgstr_fcc(fccHandler), wMode); if (!fccHandler) /* No specific handler, return the first valid for wMode */ { HIC local; ICINFO info; DWORD loop = 0; info.dwSize = sizeof(info); while(ICInfo(fccType, loop++, &info)) { /* Ensure fccHandler is not 0x0 because we will recurse on ICOpen */ if(!info.fccHandler) continue; local = ICOpen(fccType, info.fccHandler, wMode); if (local != 0) { TRACE("Returning %s as default handler for %s\n", wine_dbgstr_fcc(info.fccHandler), wine_dbgstr_fcc(fccType)); return local; } } } /* Check if there is a registered driver that matches */ driver = reg_driver_list; while(driver) if (!compare_fourcc(fccType, driver->fccType) && !compare_fourcc(fccHandler, driver->fccHandler)) { fccType = driver->fccType; fccHandler = driver->fccHandler; break; } else driver = driver->next; if (driver && driver->proc) /* The driver has been registered at runtime with its driverproc */ return ICOpenFunction(fccType, fccHandler, wMode, driver->proc); /* Well, lParam2 is in fact a LPVIDEO_OPEN_PARMS, but it has the * same layout as ICOPEN */ icopen.dwSize = sizeof(ICOPEN); icopen.fccType = fccType; icopen.fccHandler = fccHandler; icopen.dwVersion = 0x00001000; /* FIXME */ icopen.dwFlags = wMode; icopen.dwError = 0; icopen.pV1Reserved = NULL; icopen.pV2Reserved = NULL; icopen.dnDevNode = 0; /* FIXME */ if (!driver) { /* normalize to lower case as in 'vidc' */ ((char*)&fccType)[0] = tolower(((char*)&fccType)[0]); ((char*)&fccType)[1] = tolower(((char*)&fccType)[1]); ((char*)&fccType)[2] = tolower(((char*)&fccType)[2]); ((char*)&fccType)[3] = tolower(((char*)&fccType)[3]); icopen.fccType = fccType; /* Seek the driver in the registry */ fourcc_to_string(codecname, fccType); codecname[4] = '.'; fourcc_to_string(codecname + 5, fccHandler); codecname[9] = '\0'; hdrv = OpenDriver(codecname, drv32W, (LPARAM)&icopen); if (!hdrv) return 0; } else { /* The driver has been registered at runtime with its name */ hdrv = OpenDriver(driver->name, NULL, (LPARAM)&icopen); if (!hdrv) return 0; } whic = HeapAlloc(GetProcessHeap(), 0, sizeof(WINE_HIC)); if (!whic) { CloseDriver(hdrv, 0, 0); return FALSE; } whic->hdrv = hdrv; whic->driverproc = NULL; whic->type = fccType; whic->handler = fccHandler; while (MSVIDEO_GetHicPtr((HIC)(ULONG_PTR)IC_HandleRef) != NULL) IC_HandleRef++; whic->hic = (HIC)(ULONG_PTR)IC_HandleRef++; whic->next = MSVIDEO_FirstHic; MSVIDEO_FirstHic = whic; TRACE("=> %p\n", whic->hic); return whic->hic; }