⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 position.cc

📁 Linux下比较早的基于命令行的DVD播放器
💻 CC
字号:
//// 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//------------------------------------------------------------------------------#include "Position.h"#include "State.h"#include "dvd/DVD.h"#include "util/Log.h"#include <cassert>//------------------------------------------------------------------------------using dvd::vm::Position;using dvd::CellPlaybackInfo;using dvd::PGC;using dvd::PGCTable;using dvd::IFO;using dvd::VMG;using dvd::VTS;//------------------------------------------------------------------------------void Position::reset(){    SectorPosition::reset();    pgcNumber = 0;     cellNumber = 0;}//------------------------------------------------------------------------------void Position::copy(const Position& from, unsigned cellNo){    assert(state.getDVD() == from.state.getDVD());    SectorPosition::copy(from);    pgcNumber = from.pgcNumber;        if (cellNo==0) {        cellNumber  = from.cellNumber;    } else {        cellNumber  = cellNo;        setSectorNumber(0);    }}//------------------------------------------------------------------------------bool Position::equals(const Position& other) const{    return         SectorPosition::equals(other) &&        pgcNumber == other.pgcNumber &&        cellNumber == other.cellNumber;}//------------------------------------------------------------------------------const IFO* Position::findIFO() const{    return isInVideoManager() ? (const IFO*)getVMG() : (const IFO*)findVTS();}//------------------------------------------------------------------------------const VMG* Position::getVMG() const{    return state.getDVD()->getVMG();}//------------------------------------------------------------------------------const VTS* Position::findVTS() const{    unsigned vtsNumber = getVTSNumber();    if (isInVideoManager() || vtsNumber>DVD::maxNumberOfVTSs) return 0;    else return state.getDVD()->getVTS(vtsNumber);}//------------------------------------------------------------------------------PGC Position::getPGC() const{    if (isInVideoManager() && !isInMenu()) {        return getVMG()->getFirstPlayPGC();    } else {        PGCTable pgcTable = getPGCTable();        return pgcTable ? pgcTable.getPGC(pgcNumber) : PGC(0);    }}//------------------------------------------------------------------------------PGCTable Position::getPGCTable() const{    if (isInMenu()) {        const IFO* ifo = findIFO();        return (ifo==0) ? PGCTable(0) :             ifo->getMenuPGCTable(state.getSPRValue(SPRM::preferredMenuLanguage));    } else if (!isInVideoManager()) {        const VTS* vts = findVTS();        return (vts==0) ? PGCTable(0) : vts->getPGCTable();    } else {        return PGCTable(0);    }}//------------------------------------------------------------------------------CellPlaybackInfo Position::getCellPlaybackInfo() const{    PGC pgc = getPGC();    if (!pgc) {        Log::fatal("dvd::vm::Position::getCellPlaybackInfo: Cannot get cell playback info from invalid PGC\n");        return CellPlaybackInfo(0);    }    if (cellNumber<1 || cellNumber>pgc.getNumberOfCells()) {        Log::error("dvd::vm::Position::getCellPlaybackInfo: Invalid cell number: %u\n", cellNumber);        return CellPlaybackInfo(0);    }    return pgc.getCellPlaybackInfo(cellNumber);}//------------------------------------------------------------------------------unsigned long long Position::getUserPosition(unsigned& titleNo,                                              unsigned& partNo,                                             unsigned long long& playbackTime,                                             unsigned& fps) const{    playbackTime = 0;    titleNo = 0;    partNo = 0;    fps = 0;    PGC pgc = getPGC();    if (!pgc) return 0;    playbackTime = pgc.getPlaybackTime(fps);    unsigned long long time = pgc.getCellStartingTime(cellNumber, fps);    if (isInMenu() || isInVideoManager()) return time;    const VTS* vts = findVTS();    if (vts==0) return time;    unsigned vtsTitleNumber =         vts->getTitleTable().findTitleAndPart(pgcNumber,                                              pgc.getProgramNumber(cellNumber),                                              partNo);    titleNo = getVMG()->getTitleInfoTable().        getTitleNumber(getVTSNumber(), vtsTitleNumber);    return time;}//------------------------------------------------------------------------------bool Position::isPlayModeAllowed(playMode_t playMode) const{    PGC pgc = getPGC();    if (!pgc) return playMode==FORWARD || playMode==PAUSED;    UserOperations prohibitedOperations = pgc.getProhibitedOperations();    switch(playMode) {      case FAST_FORWARD_1:      case FAST_FORWARD_2:      case FAST_FORWARD_3:        return !prohibitedOperations.isAnySet(UserOperations::FORWARD_SCAN);      case FAST_BACKWARD_1:      case FAST_BACKWARD_2:      case FAST_BACKWARD_3:        return !prohibitedOperations.isAnySet(UserOperations::BACKWARD_SCAN);      case FORWARD:        return true;      case PAUSED:        return true;      default:        break;    }        return false;}//------------------------------------------------------------------------------bool Position::save(FILE* f) const{    bool ok = true;    ok = ok && SectorPosition::save(f);    ok = ok && (fwrite(&pgcNumber, sizeof(pgcNumber), 1, f)==1);    ok = ok && (fwrite(&cellNumber, sizeof(cellNumber), 1, f)==1);    return ok;}//------------------------------------------------------------------------------bool Position::load(FILE* f){    bool ok = true;    ok = ok && SectorPosition::load(f);    ok = ok && (fread(&pgcNumber, sizeof(pgcNumber), 1, f)==1);    ok = ok && (fread(&cellNumber, sizeof(cellNumber), 1, f)==1);    return ok;}//------------------------------------------------------------------------------//------------------------------------------------------------------------------

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -