📄 control.h
字号:
//// Copyright (c) 2003 by Istv醤 V醨adi//// This file is part of dxr3Player, a DVD player written specifically // for the DXR3 (aka Hollywood+) decoder card.// This program is free software; you can redistribute it and/or modify// it under the terms of the GNU General Public License as published by// the Free Software Foundation; either version 2 of the License, or// (at your option) any later version.//// This program is distributed in the hope that it will be useful,// but WITHOUT ANY WARRANTY; without even the implied warranty of// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the// GNU General Public License for more details.//// You should have received a copy of the GNU General Public License// along with this program; if not, write to the Free Software// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA#ifndef DXR3PLAYER_DVD_READER_CONTROL_H#define DXR3PLAYER_DVD_READER_CONTROL_H//------------------------------------------------------------------------------#include "dvd/reader/Thread.h"#include "dvd/reader/Buffer.h"#include "dvd/reader/ProcessorHandler.h"#include "dvd/demux/DSI.h"#include "dvd/demux/PCI.h"#include "sched/Schedulable.h"#include <libmpdvdkit/nav_read.h>//------------------------------------------------------------------------------namespace dvd {class DVD;namespace demux {class Sector;}namespace packet {class PacketQueue;}}//------------------------------------------------------------------------------namespace dvd { namespace reader {//------------------------------------------------------------------------------class ReaderListener;//------------------------------------------------------------------------------/** * The controller of the DVD reader. */class Control : public sched::Schedulable{private: /** * The buffer to read DVD data into */ Buffer buffer; /** * The thread to handle the DVD. */ Thread thread; /** * The virtual machine processor handler. */ ProcessorHandler processorHandler; /** * The output queue. */ dvd::packet::PacketQueue& outputQueue; /** * The listener of the reader. It can be 0. */ ReaderListener* listener; /** * Indicate if the playback of a DVD is ongoing. */ bool playing; /** * The play mode. * * Notes: * 1. This can be changed only immediately before or after reading * a NAV packet. * 2. If it changes direction after (i.e. while) reading a NAV * packet, the VOBU the NAV packet belongs to will be read * nevertheless, only the next VOBU will be the preceding one. */ playMode_t playMode; /** * The PCI of the VOBU being processed. */ dvd::demux::PCI pci; /** * The DSI of the VOBU being processed. */ dvd::demux::DSI dsi; /** * The number of sectors read so far from the current VOBU */ size_t vobuSectorsRead; /** * Indicate if we should pause. */ bool toPause; /** * Indicate if we should branch. */ bool toBranch; /** * Indicate if the DVD should be ejected if possible. */ bool toEject; /** * Indicate if the state has changed. */ bool stateChanged; /** * The 2nd speed offset. */ dvd::demux::DSI::timeOffset_t fast2Offset; /** * The 3rd speed offset. */ dvd::demux::DSI::timeOffset_t fast3Offset;public: /** * Construct the controller. */ Control(DVD& dvd, dvd::vm::ProcessorCommandQueue& processorCommandQueue, dvd::packet::PacketQueue& outputQueue); /** * Get the play mode. */ playMode_t getPlayMode() const; /** * Set the listener. */ void setListener(ReaderListener* l); /** * @see sched::Schedulable::run */ virtual void run(); /** * @see sched::Schedulable::printStatus */ virtual void printStatus() const; /** * Quit. */ void quit(); /** * Set the given state and use that afterwards. */ void setState(const dvd::vm::State& vmState); /** * Execute a branch to the given state. */ void branch(const dvd::vm::State& vmState, playMode_t pm); /** * Start pausing to be resumed at the given state. */ void pause(const dvd::vm::State& vmState); /** * Resume playback if paused. */ void resume(); /** * Eject the DVD at the next possibility. */ void eject();private: /** * Try opening the DVD if it is not opened yet and handle * interrupts. */ void openDVD(); /** * Read the DVD. * * @return if we should continue running. */ bool readDVD(); /** * Insert the cell-related packets: demultiplexer parameters, * audio/video attributes and SPU palette. */ void insertCellPackets(); /** * Process the VOBU the processor points to. First reads the NAV * packet, updates the local PCI and DSI, outputs some packets * including the NAV packet and the processor updating packets, if * any. Then it reads the VOBU sectors. * * @param isFirst indicates if this VOBU is the first one on the * DVD to be processed. */ void processVOBU(bool isFirst); /** * Read the NAV sector. * * @return the sector, or 0 if it could not be read because of an * interrupt. */ dvd::demux::Sector* readNAV(); /** * Process the given NAV sector. */ void processNAV(const dvd::demux::Sector* sector); /** * Check if the current play mode is valid for the VOBU whose PCI * and DSI are the current ones. If not, reset play mode and * insert a playmode setting packet. */ bool checkPlayMode(); /** * Check if the current PCI changes the highlight, and if set * update the processor. */ void checkHighlight(); /** * Read sectors from the current VOBU with the given offset. * * @param numSectors the max. number of sectors to read, will * contain the actual number or exit * * @return the first sector read, or 0 if an interrupt occured. */ dvd::demux::Sector* readVOBU(size_t offset, size_t& numSectors); /** * Read sectors into the memory from the address of firstSector. * * @param sectorOffset the offset of the sectors from the position * pointed to currently. * * @return the first sector read, or 0 if an interrupt occured. In * this case the sectors have been given back to the buffer. */ dvd::demux::Sector* readSectors(dvd::demux::Sector* firstSector, size_t sectorOffset, size_t numSectors); //----------------------------------------------------------- /** * Get the VOBU length from the current DSI based on the play * mode. */ size_t getVOBULength() const; /** * Check if the next VOBU follows after the current one, i.e. we * can read in its first (NAV) sector as well. This depends on the * play mode. */ bool doesNextVOBUFollow() const; /** * Get the next VOBU sector. * * @param sectorNo reference to the variable that will contain the * sector number. * * @return if there is a next VOBU */ bool getNextVOBUSector(size_t& sectorNo) const; /** * Get the previous VOBU sector. * * @param sectorNo reference to the variable that will contain the * sector number. * * @return if there is a previous VOBU */ bool getPreviousVOBUSector(size_t& sectorNo) const; /** * Insert an A/V attributes packet into the output queue. */ void insertAVAttributesPacket(); /** * Insert an SPU palette packet into the output queue. */ void insertSPUPalettePacket(); /** * Insert a demultiplexer parameter packet into the output queue. */ void insertDemultiplexerParameterPacket(); /** * Insert a packet for updating the processor with the last * command executed. */ void insertProcessorUpdatingPacket(bool atEndPresentation = false); /** * Start next VOBU according to the play mode. * * @return if the next VOBU could be started (or an interrupt * occured). If it cannot, quit. */ bool startNextVOBU(); /** * Start the succeeding VOBU by setting up the processor to * point to its NAV sector. * * @return if the next VOBU could be started. */ bool startSucceedingVOBU(); /** * Start the preceding VOBU by setting up the processor to * point to its NAV sector. * * @return if the next VOBU could be started. */ bool startPrecedingVOBU(); /** * Discard all the read sectors */ void discardReadSectors(); /** * Make the given number of read sectors available. * * @param numSectors the number of sectors. If 0 (the default) all * sectors will be made available */ void makeReadSectorsAvailable(size_t numSectors = 0); friend class Buffer;};//------------------------------------------------------------------------------// Inline definitions//------------------------------------------------------------------------------inline void Control::setListener(ReaderListener* l){ listener = l;}//------------------------------------------------------------------------------inline playMode_t Control::getPlayMode() const{ return playMode;}//------------------------------------------------------------------------------} /* namespace dvd::reader */ } /* namespace dvd *///------------------------------------------------------------------------------#endif // DXR3PLAYER_DVD_READER_CONTROL_H// Local variables:// mode: c++// End:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -