void CALLBACK CTsPacketCounter::OnPatUpdated(const WORD wPID, CTsPidMapTarget *pMapTarget, CTsPidMapManager *pMapManager, const PVOID pParam) { // PATが更新された CTsPacketCounter *pThis = static_cast<CTsPacketCounter *>(pParam); CPatTable *pPatTable = dynamic_cast<CPatTable *>(pMapTarget); if (pPatTable == nullptr) return; for (size_t i = 0; i < pThis->m_ServiceList.size(); i++) { pThis->UnmapServiceESs(i); pMapManager->UnmapTarget(pThis->m_ServiceList[i].PmtPID); } const WORD ProgramNum = pPatTable->GetProgramNum(); pThis->m_ServiceList.clear(); pThis->m_ServiceList.reserve(ProgramNum); for (WORD i = 0; i < ProgramNum; i++) { ServiceInfo Info; Info.ServiceID = pPatTable->GetProgramID(i); Info.PmtPID = pPatTable->GetPmtPID(i); pThis->m_ServiceList.push_back(Info); pMapManager->MapTarget(Info.PmtPID, new CPmtTable, OnPmtUpdated, pParam); } }
void CALLBACK CProgManager::CProgDatabase::OnPatUpdated(const WORD wPID, CTsPidMapTarget *pMapTarget, CTsPidMapManager *pMapManager, const PVOID pParam) { // PATが更新された CProgDatabase *pThis = static_cast<CProgDatabase *>(pParam); CPatTable *pPatTable = dynamic_cast<CPatTable *>(pMapTarget); // トランスポートストリームID更新 pThis->m_wTransportStreamID = pPatTable->m_CurSection.GetTableIdExtension(); // 現PMTのPIDをアンマップする for(WORD wIndex = 0U ; wIndex < pThis->m_ServiceList.size() ; wIndex++){ pMapManager->UnmapTarget(pThis->m_ServiceList[wIndex].wPmtTablePID); } // 新PMTをストアする pThis->m_ServiceList.resize(pPatTable->GetProgramNum()); for(WORD wIndex = 0U ; wIndex < pThis->m_ServiceList.size() ; wIndex++){ // サービスリスト更新 pThis->m_ServiceList[wIndex].bIsUpdated = false; pThis->m_ServiceList[wIndex].wServiceID = pPatTable->GetProgramID(wIndex); pThis->m_ServiceList[wIndex].wPmtTablePID = pPatTable->GetPmtPID(wIndex); pThis->m_ServiceList[wIndex].wVideoEsPID = 0xFFFFU; pThis->m_ServiceList[wIndex].wAudioEsPID = 0xFFFFU; pThis->m_ServiceList[wIndex].byVideoComponentTag = 0xFFU; pThis->m_ServiceList[wIndex].byAudioComponentTag = 0xFFU; pThis->m_ServiceList[wIndex].byServiceType = 0xFFU; pThis->m_ServiceList[wIndex].byRunningStatus = 0xFFU; pThis->m_ServiceList[wIndex].bIsCaService = false; pThis->m_ServiceList[wIndex].szServiceName[0] = TEXT('\0'); // PMTのPIDをマップ pMapManager->MapTarget(pPatTable->GetPmtPID(wIndex), new CPmtTable, CProgDatabase::OnPmtUpdated, pParam); } }