📄 localinput.cpp
字号:
throw E_Exception(GEN_ERR, "Module mpegreader:" + strConverterType + " not present"); } C_MpegConverter* pConverter; // Create the converter C_MpegConverterModule* pConverterModule = (C_MpegConverterModule*) C_Application::GetModuleManager() ->GetModule("mpegconverter", strConverterType); if(pConverterModule) { C_MpegConverterConfig cConfig; cConfig.m_hLog = m_hLog; cConfig.m_pBroadcast = pBroadcast; cConfig.m_pReader = pReader; cConfig.m_pTsProvider = pTsProvider; cConfig.m_pHandler = pBuffer; cConfig.m_iInitFill = pBuffer->Capacity(); cConfig.m_pEventHandler = m_pEventHandler; pConverter = pConverterModule->NewMpegConverter(cConfig); ASSERT(pConverter); } else { throw E_Exception(GEN_ERR, "Module mpegconverter:" + strConverterType + " not present"); } pReader->SetConverter(pConverter); // Create the streamer C_TsStreamer* pStreamer = new C_TsStreamer(m_hLog, pBroadcast, pTsProvider, pBuffer, m_pEventHandler, true, true); ASSERT(pStreamer); m_cConverters.Add(pBroadcast, pConverter); m_cStreamers.Add(pBroadcast, pStreamer); try { pConverter->Create(); pStreamer->Create(); } catch(E_Exception e) { pConverter->Stop(); pStreamer->Stop(); // Unregister the 2 thread and delete them m_cConverters.Delete(pBroadcast); m_cStreamers.Delete(pBroadcast); throw E_Exception(GEN_ERR, "unable to start streaming of program "+ pBroadcast->GetProgram()->GetName(), e); }}//------------------------------------------------------------------------------// Resume the reception of the given program//------------------------------------------------------------------------------void C_LocalInput::OnResumeStreaming(C_Broadcast* pBroadcast){ ASSERT(pBroadcast); // Find the converter that receive the pgrm C_MpegConverter* pConverter = m_cConverters.Get(pBroadcast); ASSERT(pConverter); // Resume the thread try { pConverter->Resume(); } catch(E_Exception e) { throw E_Exception(GEN_ERR, "Unable to resume streaming of program "+ pBroadcast->GetProgram()->GetName(), e); }}//------------------------------------------------------------------------------// Suspend the reception of the given program//------------------------------------------------------------------------------void C_LocalInput::OnSuspendStreaming(C_Broadcast* pBroadcast){ ASSERT(pBroadcast); // Find the converter that receive the pgrm C_MpegConverter* pConverter = m_cConverters.Get(pBroadcast); ASSERT(pConverter); C_String strPgrmName = pBroadcast->GetProgram()->GetName(); // Suspend the thread try { pConverter->Suspend(); } catch(E_Exception e) { throw E_Exception(GEN_ERR, "Unable to resume streaming of program "+ pBroadcast->GetProgram()->GetName(), e); }}//------------------------------------------------------------------------------// Stop the reception of the given program//------------------------------------------------------------------------------void C_LocalInput::OnStopStreaming(C_Broadcast* pBroadcast){ ASSERT(pBroadcast); // Find the reader and the streamer that receive the pgrm C_MpegConverter* pConverter = m_cConverters.Remove(pBroadcast); ASSERT(pConverter); C_TsStreamer* pStreamer = m_cStreamers.Remove(pBroadcast); ASSERT(pStreamer); // Stop the threads try { pConverter->Stop(); delete pConverter; pStreamer->Stop(); delete pStreamer; } catch(E_Exception e) { throw E_Exception(GEN_ERR, "Unable to stop streaming of program "+ pBroadcast->GetProgram()->GetName(), e); }}//------------------------------------------------------------------------------////------------------------------------------------------------------------------void C_LocalInput::OnUpdateProgram(C_String strProgram, C_String strFileName, C_String strType){ C_String strPgrmCount = m_cSettings.GetSetting("Input.ProgramCount", "0"); unsigned int uiPgrmCount = strPgrmCount.ToInt(); unsigned int uiId = m_vProgramNames.Find(strProgram) + 1; if (uiId>0) { Log(m_hLog, LOG_WARN, "The program already exists in the list for this input"); } if(uiPgrmCount) { uiPgrmCount++; C_String strKey = C_String(uiPgrmCount)+ ".Name"; m_cSettings.Update(strKey.ToLower(),strProgram); strKey = C_String(uiPgrmCount)+ ".FileName"; m_cSettings.Update(strKey.ToLower(), strFileName); strKey = C_String(uiPgrmCount)+ ".Type"; m_cSettings.Update(strKey.ToLower(), strType); strKey = C_String("Input.ProgramCount"); m_cSettings.Update(strKey.ToLower(), C_String(uiPgrmCount)); // add to m_vProgramNames C_String strName = m_cSettings.GetSetting(C_String(uiPgrmCount) + ".Name", C_String("Pgrm") + uiPgrmCount); C_String* pStr = new C_String(strName); m_vProgramNames.Add(pStr); } else { throw E_Exception(GEN_ERR, "The \"ProgramCount\" variable isn't specified in the file \"" + m_strConfigPath + "/input.cfg\""); }}//------------------------------------------------------------------------------////------------------------------------------------------------------------------void C_LocalInput::OnDeleteProgram(C_String strProgram){ // Get the type of the program unsigned int uiId = m_vProgramNames.Find(strProgram) + 1; if (uiId>0) { // Delete settings from m_cSettings C_String strPgrmCount = m_cSettings.GetSetting("Input.ProgramCount", "0"); unsigned int uiPgrmCount = strPgrmCount.ToInt(); if(uiPgrmCount) { C_String strDelKey = C_String(uiId)+ ".Name"; m_cSettings.Delete(strDelKey.ToLower()); if (m_cSettings.GetSetting(C_String(uiId)+".FileName", "") != "" ) { strDelKey = C_String(uiId)+ ".FileName"; m_cSettings.Delete(strDelKey.ToLower()); } if (m_cSettings.GetSetting(C_String(uiId)+".Device", "") != "" ) { strDelKey = C_String(uiId)+ ".Device"; m_cSettings.Delete(strDelKey.ToLower()); } strDelKey = C_String(uiId)+ ".Type"; m_cSettings.Delete(strDelKey.ToLower()); // Move all other settings one item down for(unsigned int ui = uiId; ui <= uiPgrmCount; ui++) { C_String strProgram = m_cSettings.GetSetting(C_String(ui+1) + ".Name",C_String("Pgrm") + ui+1); C_String strFileName = m_cSettings.GetSetting(C_String(ui+1)+".FileName", ""); C_String strType = m_cSettings.GetSetting(C_String(ui+1) + ".Type", "Mpeg2-TS"); C_String strDevice = m_cSettings.GetSetting(C_String(ui+1)+".Device", ""); // update settings C_String strKey = C_String(ui)+ ".Name"; m_cSettings.Update(strKey.ToLower(),strProgram); strKey = C_String(ui)+ ".FileName"; if (strFileName != "") { m_cSettings.Update(strKey.ToLower(), strFileName); } else m_cSettings.Update(strKey.ToLower(), ""); strKey = C_String(ui)+ ".Device"; if (strDevice != "") { m_cSettings.Update(strKey.ToLower(), strDevice); } else m_cSettings.Update(strKey.ToLower(), ""); strKey = C_String(ui)+ ".Type"; m_cSettings.Update(strKey.ToLower(), strType); } // Lower program count uiPgrmCount--; strDelKey = C_String("Input.ProgramCount"); m_cSettings.Update(strDelKey.ToLower(), C_String(uiPgrmCount)); m_vProgramNames.Delete(uiId); // ** DEBUG ** Log(m_hLog, LOG_NOTE, "Debugging inputs m_cSettings list."); C_String strPgrmCount = m_cSettings.GetSetting("Input.ProgramCount", "0"); unsigned int uiPgrmCount = strPgrmCount.ToInt(); for(unsigned int ui = 1; ui <= uiPgrmCount; ui++) { C_String strProgram = m_cSettings.GetSetting(C_String(ui) + ".Name",C_String("Pgrm") + ui); C_String strFileName = m_cSettings.GetSetting(C_String(ui)+".FileName", ""); C_String strDevice = m_cSettings.GetSetting(C_String(ui)+".Device", ""); C_String strType = m_cSettings.GetSetting(C_String(ui) + ".Type", "Mpeg2-TS").ToLower(); Log(m_hLog, LOG_NOTE, "Program: \"" + strProgram +"\""); Log(m_hLog, LOG_NOTE, " FileName: \"" + strFileName+"\""); Log(m_hLog, LOG_NOTE, " Device: \"" + strDevice+"\""); Log(m_hLog, LOG_NOTE, " Type: \"" + strType+"\""); } } else { throw E_Exception(GEN_ERR,"Deleting program information from input failed"); } } else { throw E_Exception(GEN_ERR, "The program is not known by this input."); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -