void IPTVFeederRTP::Close(void) { LOG(VB_RECORD, LOG_INFO, LOC + "Close() -- begin"); Stop(); QMutexLocker locker(&_lock); if (_sink) { Medium::close(_sink); _sink = NULL; } if (_source) { Groupsock *socket = _source->RTPgs(); Medium::close(_source); _source = NULL; if (socket) delete socket; } FreeEnv(); LOG(VB_RECORD, LOG_INFO, LOC + "Close() -- end"); }
bool IPTVFeederRTP::Open(const QString &url) { LOG(VB_RECORD, LOG_INFO, LOC + QString("Open(%1) -- begin").arg(url)); QMutexLocker locker(&_lock); if (_source) { LOG(VB_RECORD, LOG_INFO, LOC + "Open() -- end 1"); return true; } QUrl parse(url); if (!parse.isValid() || parse.host().isEmpty() || (-1 == parse.port())) { LOG(VB_RECORD, LOG_INFO, LOC + "Open() -- end 2"); return false; } struct in_addr addr; QByteArray host = parse.host().toLatin1(); addr.s_addr = our_inet_addr(host.constData()); // Begin by setting up our usage environment: if (!InitEnv()) return false; ReceivingSocketAddr = our_inet_addr(parse.host().toLatin1()); Groupsock *socket = new Groupsock(*_live_env, addr, parse.port(), 0); if (!socket) { LOG(VB_GENERAL, LOG_ERR, LOC + "Failed to create Live RTP Socket."); FreeEnv(); return false; } _source = SimpleRTPSource::createNew(*_live_env, socket, 33, 90000, "video/MP2T", 0, False); if (!_source) { LOG(VB_GENERAL, LOG_ERR, LOC + "Failed to create Live RTP Source."); if (socket) delete socket; FreeEnv(); return false; } _sink = IPTVMediaSink::CreateNew(*_live_env, TSPacket::kSize * 128*1024); if (!_sink) { LOG(VB_GENERAL, LOG_ERR, QString("IPTV # Failed to create sink: %1") .arg(_live_env->getResultMsg())); Medium::close(_source); _source = NULL; if (socket) delete socket; FreeEnv(); return false; } _sink->startPlaying(*_source, NULL, NULL); vector<TSDataListener*>::iterator it = _listeners.begin(); for (; it != _listeners.end(); ++it) _sink->AddListener(*it); LOG(VB_RECORD, LOG_INFO, LOC + "Open() -- end"); return true; }
DWORD CALLBACK DosWindowThread(void *xx) { struct _varData *vdata = (struct _varData *)xx; char *xcmd = GetCmd(); if (xcmd) { BOOL bSeenInitialBP = FALSE; BOOL bContinue = TRUE; DWORD dwContinueStatus; BOOL bShownExitCode = FALSE; DEBUG_EVENT stDE; LPTCH env = GetEnv(); BOOL bRet; STARTUPINFO stStartInfo; PROCESS_INFORMATION stProcessInfo; DWORD exitCode; char wd[MAX_PATH], *p, cmd[MAX_PATH]; if (vdata->path) { strcpy(wd, vdata->path); p = strrchr(wd, '\\'); if (p) if (p[-1] == ':') p[1] = 0; else p[0] = 0; else wd[0] = 0; } else GetCurrentDirectory(sizeof(wd), wd); if (vdata->exec) { sprintf(cmd,"\"%s\" %s", vdata->exec, vdata->args); } else { sprintf(cmd, "\"%s\"", xcmd); } memset(&stStartInfo, 0, sizeof(STARTUPINFO)); memset(&stProcessInfo, 0, sizeof(PROCESS_INFORMATION)); stStartInfo.cb = sizeof(STARTUPINFO); bRet = CreateProcess(NULL, cmd, NULL, NULL, TRUE, DEBUG_PROCESS | DEBUG_ONLY_THIS_PROCESS | CREATE_NEW_CONSOLE, env, wd, &stStartInfo, &stProcessInfo); if (!bRet) { FreeEnv(env); ExtendedMessageBox("Command Execution", MB_SETFOREGROUND | MB_SYSTEMMODAL, "Could not execute %s.", cmd); return 0; } ProcessToTop(stProcessInfo.dwProcessId); while (TRUE == bContinue) { // Pause until a debug event notification happens. bContinue = WaitForDebugEvent(&stDE, 500); if (bContinue) { switch (stDE.dwDebugEventCode) { case CREATE_PROCESS_DEBUG_EVENT: CloseHandle(stDE.u.CreateProcessInfo.hFile); dwContinueStatus = DBG_CONTINUE; break; case CREATE_THREAD_DEBUG_EVENT: case LOAD_DLL_DEBUG_EVENT: case UNLOAD_DLL_DEBUG_EVENT: case OUTPUT_DEBUG_STRING_EVENT: case RIP_EVENT: dwContinueStatus = DBG_CONTINUE; break; case EXIT_THREAD_DEBUG_EVENT: // this catches the X button at the top right of the window. // if it was pressed we do the dialog here to prevent the original window // from auto-closing before we show it. if (stDE.u.ExitThread.dwExitCode == STATUS_CONTROL_C_EXIT) { if (!bShownExitCode) { if (vdata->rvTitle) { ProcessToTop(stProcessInfo.dwProcessId); ExtendedMessageBox(vdata->rvTitle, MB_SETFOREGROUND | MB_SYSTEMMODAL, vdata->rvBody, stDE.u.ExitProcess.dwExitCode); bShownExitCode = TRUE; } } } dwContinueStatus = DBG_CONTINUE; break; case EXIT_PROCESS_DEBUG_EVENT: if (!bShownExitCode) { if (vdata->rvTitle) { ProcessToTop(stProcessInfo.dwProcessId); ExtendedMessageBox(vdata->rvTitle, MB_SETFOREGROUND | MB_SYSTEMMODAL, vdata->rvBody, stDE.u.ExitProcess.dwExitCode); bShownExitCode = TRUE; } } dwContinueStatus = DBG_CONTINUE; bContinue = FALSE; break; case EXCEPTION_DEBUG_EVENT: switch (stDE.u.Exception.ExceptionRecord.ExceptionCode) { default: dwContinueStatus = DBG_EXCEPTION_NOT_HANDLED; break; case EXCEPTION_BREAKPOINT: if (!bSeenInitialBP) { bSeenInitialBP = TRUE; dwContinueStatus = DBG_CONTINUE; } else { dwContinueStatus = DBG_EXCEPTION_NOT_HANDLED; } break; } break; // For any other events, just continue on. default: dwContinueStatus = DBG_EXCEPTION_NOT_HANDLED; break; } } else { dwContinueStatus = DBG_CONTINUE; bContinue = TRUE; } // Pass on to the operating system. ContinueDebugEvent(stDE.dwProcessId, stDE.dwThreadId, dwContinueStatus); } CloseHandle(stProcessInfo.hProcess); CloseHandle(stProcessInfo.hThread); FreeEnv(env); } free(vdata->rvTitle); free(vdata->rvBody); free(vdata->path); free(vdata->exec); free(vdata->args); free(vdata); return 0; }