📄 statetracker.cc
字号:
updateHighlight(); updateUserPosition(); updateLanguages(); }}//------------------------------------------------------------------------------bool StateTracker::updateHighlight(){ Reference<PCI> pci = currentPCI; HighlightInformation highlightInfo = pci->getHighlightInformation(); switch(highlightInfo.getGeneral().getStatus()) { case GeneralHighlightInformation::USE_PREVIOUS: case GeneralHighlightInformation::ONLY_COMMANDS: pci = previousPCI; highlightInfo = pci->getHighlightInformation(); break; default: hideButtons = false; break; } unsigned highlightedButtonNumber = processor.getSPRM().getHighlightedButtonNumber();// Log::debug("output::StateTracker::updateHighlight: highlighting button #%u\n", highlightedButtonNumber); if (!hideButtons && highlightInfo.getGeneral().isValidButton(highlightedButtonNumber)) { highlightButton(highlightInfo, highlightedButtonNumber); } else { buttonHandler.clearButton(); } return false;}//------------------------------------------------------------------------------void StateTracker::highlightButton(HighlightInformation highlightInfo, unsigned buttonNo){ ButtonInformation buttonInfo = highlightInfo.getButtonInformation(buttonNo, currentDisplayFormat); unsigned colour = 0; unsigned contrast = 0; size_t colourNumber = buttonInfo.getColourNumber(); if (colourNumber>=1 && colourNumber<=ButtonColourTable::numberOfColours) { colour = highlightInfo.getButtonColourTable().getSelectionColour(colourNumber); contrast = highlightInfo.getButtonColourTable().getSelectionContrast(colourNumber); } buttonHandler.highlightButton(colour, contrast, buttonInfo.getStartingY(), buttonInfo.getEndingY(), buttonInfo.getStartingX(), buttonInfo.getEndingX());}//------------------------------------------------------------------------------OutputProcessor::processorChange_tStateTracker::handleButton(InputListener::operation_t operation){ if (!currentPCI.isValid()) return OutputProcessor::NONE; HighlightInformation highlightInfo = currentPCI->getHighlightInformation(); GeneralHighlightInformation generalHighlightInfo = highlightInfo.getGeneral(); unsigned highlightedButtonNumber = processor.getSPRM().getHighlightedButtonNumber(); if (!generalHighlightInfo.isValidButton(highlightedButtonNumber)) return OutputProcessor::NONE; ButtonInformation buttonInfo = highlightInfo.getButtonInformation(highlightedButtonNumber, currentDisplayFormat); if (operation!=InputListener::ACTIVATE) { unsigned buttonNumber = 0; switch(operation) { case InputListener::UP: buttonNumber = buttonInfo.getUpButton(); break; case InputListener::DOWN: buttonNumber = buttonInfo.getDownButton(); break; case InputListener::LEFT: buttonNumber = buttonInfo.getLeftButton(); break; case InputListener::RIGHT: buttonNumber = buttonInfo.getRightButton(); break; default: assert(0); } if (!generalHighlightInfo.isValidButton(buttonNumber)) return OutputProcessor::NONE; processor.setHighlightedButtonNumber(buttonNumber); highlightButton(highlightInfo, buttonNumber); buttonInfo = highlightInfo.getButtonInformation(buttonNumber, currentDisplayFormat); if (buttonInfo.isAutoAction()) { operation = InputListener::ACTIVATE; } } if (operation==InputListener::ACTIVATE) { buttonHandler.clearButton(); hideButtons = true; processor.execute(buttonInfo.getInstruction()); if (processor.hasBranched()) { return OutputProcessor::BRANCH; } } return OutputProcessor::STATE;}//------------------------------------------------------------------------------OutputProcessor::processorChange_t StateTracker::handleMenu(InputListener::operation_t operation){ unsigned menuID = 0; bool forced = false; switch(operation) { case InputListener::MENU_TITLE: menuID = PGCInfo::MENUID_TITLE; break; case InputListener::MENU_ROOT_FORCED: forced = true; case InputListener::MENU_ROOT: menuID = PGCInfo::MENUID_ROOT; break; case InputListener::MENU_SUBPICTURE: menuID = PGCInfo::MENUID_SUBPICTURE; break; case InputListener::MENU_AUDIO: menuID = PGCInfo::MENUID_AUDIO; break; case InputListener::MENU_ANGLE: menuID = PGCInfo::MENUID_ANGLE; break; case InputListener::MENU_PART: menuID = PGCInfo::MENUID_PART; break; default: assert(0); } return processor.enterMenu(menuID, forced) ? OutputProcessor::BRANCH : OutputProcessor::NONE;}//------------------------------------------------------------------------------void StateTracker::updateUserPosition() const{ unsigned titleNumber; unsigned partNumber; unsigned long long playbackTime; unsigned fps = 0; unsigned long long time = processor.getPosition().getUserPosition(titleNumber, partNumber, playbackTime, fps); if (currentPCI.isValid()) { time += currentPCI->getCellElapsedTime(fps); } // Log::debug("title: %u, part: %u, time: %llu of %llu\n",// titleNumber, partNumber, // time/fps, (playbackTime+(fps/2))/fps); osdHandler.updateDVDPosition(DVDPosition(titleNumber, partNumber, time, playbackTime, fps));}//------------------------------------------------------------------------------void StateTracker::updateLanguages() const{ // FIXME: perhaps we could just use the processor state? unsigned audioLanguageCode = 0xffff; unsigned spuLanguageCode = 0xffff; const State& state = processor.getState(); const Position& position = state.getPosition(); bool inMenu = position.isInMenu(); const IFO* ifo = position.findIFO(); if (ifo!=0) { PGC pgc = position.getPGC(); unsigned logicalAudioStreamNumber = pgc.getLogicalAudioStreamNumber(audioStreamNumber); if (logicalAudioStreamNumber<ifo->getNumberOfAudioStreams(inMenu)) { audioLanguageCode = ifo->getAudioStreamAttributes(inMenu, logicalAudioStreamNumber).getLanguageCode(); } VideoStreamAttributes videoStreamAttributes = ifo->getVideoStreamAttributes(inMenu); unsigned logicalSPUStreamNumber = pgc.getLogicalSPUStreamNumber(spuStreamNumber, videoStreamAttributes.getDisplayAspectRatio(), videoStreamAttributes.getDisplayFormat()); if (logicalSPUStreamNumber<ifo->getNumberOfSPUStreams(inMenu)) { spuLanguageCode = ifo->getSPUStreamAttributes(inMenu, logicalSPUStreamNumber).getLanguageCode(); } } osdHandler.updateDVDLanguages(audioLanguageCode, spuLanguageCode);}//------------------------------------------------------------------------------bool StateTracker::hasCellElapsed(size_t numSeconds) const{ if (!currentPCI.isValid()) return true; unsigned fps = 0; unsigned long long time = currentPCI->getCellElapsedTime(fps); time += fps/2; time /= fps; return ((unsigned long long)numSeconds) >= time;}//------------------------------------------------------------------------------// Local Variables:// mode: C++// c-basic-offset: 4// indent-tabs-mode: nil// End:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -