/******************************Public*Routine******************************\ * VcdPlayerOpenCmd * \**************************************************************************/ BOOL VcdPlayerOpenCmd( int strmID ) { static BOOL fFirstTime = TRUE; BOOL fRet; TCHAR achFileName[MAX_PATH]; TCHAR achFilter[MAX_PATH]; LPTSTR lp; if(fFirstTime) { ofn.lStructSize = sizeof(ofn); ofn.hwndOwner = hwndApp; ofn.Flags = OFN_HIDEREADONLY | OFN_FILEMUSTEXIST | OFN_SHAREAWARE | OFN_PATHMUSTEXIST; } lstrcpy(achFilter, IdStr(STR_FILE_FILTER)); ofn.lpstrFilter = achFilter; /* ** Convert the resource string into to something suitable for ** GetOpenFileName ie. replace '#' characters with '\0' characters. */ for(lp = achFilter; *lp; lp++) { if(*lp == TEXT('#')) { *lp = TEXT('\0'); } } ofn.lpstrFile = achFileName; ofn.nMaxFile = sizeof(achFileName) / sizeof(TCHAR); ZeroMemory(achFileName, sizeof(achFileName)); fRet = GetOpenFileName(&ofn); if(fRet) { if(strmID == 0) { fFirstTime = FALSE; ProcessOpen(achFileName); } else { if(pMpegMovie) { pMpegMovie->RenderSecondFile(achFileName); } } InitStreamParams(strmID); } return fRet; }
bool InboundHTTP4RTMP::SignalInputData(IOBuffer &buffer) { //1. Get the HTTP far protool and test to see if it has ContentLength InboundHTTPProtocol *pHTTP = (InboundHTTPProtocol *) _pFarProtocol; if (pHTTP == NULL || pHTTP->GetContentLength() == 0) { FATAL("Invalid HTTP request"); return false; } //2. Test it and see if all the data was transfered if (!pHTTP->TransferCompleted()) { return true; } //3. Get the HTTP request Variant request = pHTTP->GetHeaders(); //4. Is this a keep-alive? pHTTP->SetDisconnectAfterTransfer( request[HTTP_HEADERS][HTTP_HEADERS_CONNECTION] != HTTP_HEADERS_CONNECTION_KEEP_ALIVE); DeleteNearProtocol(false); //4. Get the URL string url = request[HTTP_FIRST_LINE][HTTP_URL]; //5. split it in meaningful parts vector<string> parts; split(url, "/", parts); if (parts.size() < 2) { FATAL("Invalid request:\n%s", STR(request.ToString())); return false; } //7. Do the dammage bool result; if (parts[1] == "fcs") { result = ProcessFcs(parts); buffer.Ignore(pHTTP->GetContentLength()); } else if (parts[1] == "open") { result = ProcessOpen(parts); buffer.Ignore(pHTTP->GetContentLength()); } else if (parts[1] == "idle") { result = ProcessIdle(parts); buffer.Ignore(pHTTP->GetContentLength()); } else if (parts[1] == "send") { if (GETAVAILABLEBYTESCOUNT(buffer) < 1) return false; _inputBuffer.ReadFromBuffer(GETIBPOINTER(buffer), pHTTP->GetContentLength()); buffer.Ignore(pHTTP->GetContentLength()); result = ProcessSend(parts); } else { FATAL("Invalid command: %s", STR(parts[1])); result = false; } //8. Cleanup if (!result) { DeleteNearProtocol(true); EnqueueForDelete(); } //9. Done return result; }
/******************************Public*Routine******************************\ * VcdPlayerOpenCmd * \**************************************************************************/ BOOL VcdPlayerOpenCmd( void ) { static OPENFILENAME ofn; static BOOL fFirstTime = TRUE; BOOL fRet = FALSE; TCHAR achFileName[MAXSTREAMS][MAX_PATH]; TCHAR achFilter[MAX_PATH]; LPTSTR lp; DWORD dwNumFiles = 0; if(fFirstTime) { ofn.lStructSize = sizeof(ofn); ofn.hwndOwner = hwndApp; ofn.Flags = OFN_HIDEREADONLY | OFN_FILEMUSTEXIST | OFN_SHAREAWARE | OFN_PATHMUSTEXIST; } lstrcpy(achFilter, IdStr(STR_FILE_FILTER)); ofn.lpstrFilter = achFilter; /* ** Convert the resource string into to something suitable for ** GetOpenFileName ie. replace '#' characters with '\0' characters. */ for(lp = achFilter; *lp; lp++) { if(*lp == TEXT('#')) { *lp = TEXT('\0'); } } for (DWORD i = 0; i < MAXSTREAMS; i++) { ofn.lpstrFile = achFileName[i]; ofn.nMaxFile = sizeof(achFileName[i]) / sizeof(TCHAR); ZeroMemory(achFileName[i], sizeof(achFileName[i])); switch (i) { case 0: // load first file ofn.lpstrTitle = TEXT("Select First Media File"); break; case 1: // load first file ofn.lpstrTitle = TEXT("Select Second Media File"); break; case 2: // load first file ofn.lpstrTitle = TEXT("Select Third Media File"); break; } fRet = GetOpenFileName(&ofn); if(!fRet) { break; } dwNumFiles++; } // for i fFirstTime = FALSE; if (0 == dwNumFiles) { return fRet; } ProcessOpen(achFileName, dwNumFiles); return fRet; }
/*****************************Private*Routine******************************\ * VideoCd_OnCommand * \**************************************************************************/ void VideoCd_OnCommand( HWND hwnd, int id, HWND hwndCtl, UINT codeNotify ) { switch(id) { case IDM_FILE_OPEN: if(VcdPlayerOpenCmd()) VcdPlayerPlayCmd(); break; case IDM_FILE_CLOSE: VcdPlayerCloseCmd(); QzFreeUnusedLibraries(); break; case IDM_FILE_EXIT: PostMessage(hwnd, WM_CLOSE, 0, 0L); break; case IDM_MOVIE_PLAY: VcdPlayerPlayCmd(); break; case IDM_MOVIE_STOP: VcdPlayerStopCmd(); VcdPlayerRewindCmd(); break; case IDM_MOVIE_PAUSE: VcdPlayerPauseCmd(); break; case IDM_MOVIE_SKIP_FORE: VcdPlayerSeekCmd(1.0); break; case IDM_MOVIE_SKIP_BACK: VcdPlayerSeekCmd(-1.0); break; case IDM_MOVIE_PREVTRACK: if(pMovie) { VcdPlayerSeekCmd(-pMovie->GetCurrentPosition()); } break; case IDM_MOVIE_STEP: VcdPlayerPauseCmd(); VcdPlayerStepCmd(); break; case IDM_TIME: case IDM_FRAME: case IDM_FIELD: case IDM_SAMPLE: case IDM_BYTES: if(pMovie) { g_TimeFormat = VcdPlayerChangeTimeFormat(id); } break; case IDM_HELP_ABOUT: DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hwnd, (DLGPROC) AboutDlgProc); break; default: if(id > ID_RECENT_FILE_BASE && id <= (ID_RECENT_FILE_BASE + MAX_RECENT_FILES + 1)) { ProcessOpen(aRecentFiles[id - ID_RECENT_FILE_BASE - 1]); VcdPlayerPlayCmd(); } break; } SetPlayButtonsEnableState(); }
/******************************Public*Routine******************************\ * WinMain * * * Windows recognizes this function by name as the initial entry point * for the program. This function calls the application initialization * routine, if no other instance of the program is running, and always * calls the instance initialization routine. It then executes a message * retrieval and dispatch loop that is the top-level control structure * for the remainder of execution. The loop is terminated when a WM_QUIT * message is received, at which time this function exits the application * instance by returning the value passed by PostQuitMessage(). * * If this function must abort before entering the message loop, it * returns the conventional value NULL. * \**************************************************************************/ int PASCAL WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLineOld, int nCmdShow ) { USES_CONVERSION; LPTSTR lpCmdLine = A2T(lpCmdLineOld); HRESULT hres = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); if(hres == S_FALSE) { CoUninitialize(); return FALSE; } if(!hPrevInstance) { if(!InitApplication(hInstance)) { return FALSE; } } /* ** Perform initializations that apply to a specific instance */ if(!InitInstance(hInstance, nCmdShow)) { return FALSE; } /* Verify that the VMR is present on this system */ if(!VerifyVMR()) return FALSE; /* Look for options */ while(lpCmdLine && (*lpCmdLine == '-' || *lpCmdLine == '/')) { if ((lpCmdLine[1] == 'P') || (lpCmdLine[1] == 'p')) { g_bPlay = TRUE; lpCmdLine += 2; } else { break; } while(lpCmdLine[0] == ' ') { lpCmdLine++; } } if(lpCmdLine != NULL && lstrlen(lpCmdLine) > 0) { ProcessOpen(lpCmdLine, g_bPlay); SetPlayButtonsEnableState(); } /* ** Acquire and dispatch messages until a WM_QUIT message is received. */ return DoMainLoop(); }