static int dshow_check_file(demuxer_t *demuxer) { if (!demuxer->filename) return 0; mp_msg(MSGT_DEMUX, MSGL_V, "dshow demuxer: Checking for DirectShow media\n"); if(!init_dshow()) return 0; return DEMUXER_TYPE_DSHOW; }
static int dshow_check_file_preferred(demuxer_t *demuxer) { if(!force_dshow_demux && !open_with_dshow_demux) return 0; open_with_dshow_demux = 0; if (!demuxer->filename) return 0; mp_msg(MSGT_DEMUX, MSGL_V, "dshow pref demuxer: Checking for DirectShow media\n"); if(!init_dshow()) return 0; return DEMUXER_TYPE_DSHOW_PREFERRED; }
//--------------------------------------------------------------------------------------- // WinMain //--------------------------------------------------------------------------------------- int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { WNDCLASSEX clas; MSG msg; int style; RECT rect; //need COM for DirectShow CoInitializeEx(NULL, COINIT_MULTITHREADED); //Here we create the Class we named above clas.cbSize = sizeof(WNDCLASSEX); clas.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; clas.lpfnWndProc = WindowProc;//<- tell it where the WindowProc is clas.cbClsExtra = 0; clas.cbWndExtra = 0; clas.hInstance = hInstance; clas.hIcon = NULL; clas.hCursor = NULL; clas.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);//<- background colour of window clas.lpszMenuName = NULL; clas.lpszClassName = game_class;//<- the class name clas.hIconSm = 0; //do it! RegisterClassEx(&clas); //style of the window - what boxes do we need (close minimised etc) style = WS_CAPTION|WS_SYSMENU|WS_MAXIMIZEBOX|WS_MINIMIZEBOX; //create the window game_window = CreateWindowEx(0, game_class, "DirectShow", style, CW_USEDEFAULT, CW_USEDEFAULT, 1,1, NULL, NULL, hInstance, 0); //adjust the window size so that a SCREEN_X x SCREEN_Y window will fit inside its frame rect.left = rect.top = 0; rect.right = SCREEN_X; rect.bottom = SCREEN_Y; AdjustWindowRectEx(&rect, style , FALSE, 0); SetWindowPos(game_window, NULL, 0,0, rect.right - rect.left, rect.bottom - rect.top, SWP_NOMOVE|SWP_NOZORDER); //show the window on the desktop ShowWindow(game_window, nCmdShow); char filename[_MAX_PATH]; OPENFILENAME ofn; BOOL res; filename[0] = '\0'; ofn.lStructSize = sizeof(OPENFILENAME); ofn.hwndOwner = NULL; ofn.hInstance = NULL; ofn.lpstrFilter = "AVI Files\0*.avi\0"; ofn.lpstrCustomFilter = NULL; ofn.nMaxCustFilter = 0; ofn.nFilterIndex = 0; ofn.lpstrFile = filename; ofn.nMaxFile = _MAX_PATH; ofn.lpstrFileTitle = NULL; ofn.nMaxFileTitle = 0; ofn.lpstrInitialDir = NULL; ofn.lpstrTitle = "Select Video File"; ofn.Flags = OFN_FILEMUSTEXIST|OFN_EXPLORER; ofn.nFileOffset=0; ofn.nFileExtension=0; ofn.lpstrDefExt="bin"; ofn.lCustData=0; ofn.lpfnHook=NULL; ofn.lpTemplateName=""; res = GetOpenFileName(&ofn); if (res == 0) return 0; if (init_dshow(ctowc(filename), IN_OWN_WINDOW)==0) { MessageBox(NULL, "A problem occurred creating the DirectShow FilterGraph.\nCheck your video CODECs and " "DirectX version.\nThis demo requires DirectX9.0 or better.", "DirectX Initialisation Error", MB_ICONWARNING|MB_OK); shutdown_dshow(); return 0; } //message processing loop //all Windows programs have one of these. It receives the messages Windows sends to the program and //passes them to the WindowProc in the Class we registered for the window. quit = 0; do { //Are there any messages waiting? while (PeekMessage(&msg, game_window, 0, 0, PM_NOREMOVE)) { //yes! read it. if (GetMessage(&msg, game_window, 0,0) < 0) break; //pass the message to WindowProc TranslateMessage(&msg); DispatchMessage(&msg); } } while (!quit); shutdown_dshow(); CoUninitialize(); return 0; }