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

📄 dvdimage.cc

📁 Linux下比较早的基于命令行的DVD播放器
💻 CC
字号:
//// Copyright (c) 2004 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 "DVDImage.h"#include "util/Log.h"#include <libmpdvdkit/dvd_reader.h>#include <libmpdvdkit/ifo_read.h>#include <cstring>//------------------------------------------------------------------------------using dvd::DVDImage;using dvd::FileHandler;//------------------------------------------------------------------------------//------------------------------------------------------------------------------inline DVDImage::FileHandler::FileHandler(dvd_file_t* file) :    file(file){    assert(file!=0);}//------------------------------------------------------------------------------DVDImage::FileHandler::~FileHandler(){    DVDCloseFile(file);}//------------------------------------------------------------------------------size_t DVDImage::FileHandler::getLength(){    return static_cast<size_t>(DVDFileSize(file));}//------------------------------------------------------------------------------void DVDImage::FileHandler::readSectors(void* dest, size_t offset,                                         size_t numSectors){    ssize_t numRead = DVDReadBlocks(file,                                    static_cast<int>(offset),                                    numSectors,                                    reinterpret_cast<unsigned char*>(dest));    if (numRead!=(ssize_t)numSectors) abort();}//------------------------------------------------------------------------------//------------------------------------------------------------------------------bool DVDImage::isDVDImage(const char* path){    dvd_reader_t* reader = DVDOpen(path);    if (reader!=0) {        bool isImage = true;        ifo_handle_t* ifoHandle = ifoOpen(reader, 0);        if (ifoHandle==0) {            isImage = false;        } else {            ifoClose(ifoHandle);        }                DVDClose(reader);                return isImage;    } else {        return false;    }}//------------------------------------------------------------------------------//------------------------------------------------------------------------------DVDImage::DVDImage(const char* p) :    path(strdup(p)),    reader(0){    for(size_t i = 0; i<sizeof(ifoHandles)/sizeof(ifoHandles[0]); ++i) {        ifoHandles[i] = 0;    }}//------------------------------------------------------------------------------DVDImage::~DVDImage(){    assert(!isOpen());    free(path);}//------------------------------------------------------------------------------bool DVDImage::hasDisk(){    return true;}//------------------------------------------------------------------------------bool DVDImage::isOpen() const{    return reader!=0;}    //------------------------------------------------------------------------------bool DVDImage::open(){    reader = DVDOpen(path);    if (!readIFOHandles()) {        close();    }    return reader!=0;}//------------------------------------------------------------------------------void DVDImage::getID(unsigned char* dest) const{    memset(dest, 0, 16);}//------------------------------------------------------------------------------const ifo_handle_t* DVDImage::getIFOHandle(unsigned titleNo) const{    assert(ifoHandles[titleNo]!=0);    return ifoHandles[titleNo];}    //------------------------------------------------------------------------------dvd::FileHandler* DVDImage::openFile(unsigned titleNo, bool isMenu) const{    assert(isOpen());    assert(ifoHandles[titleNo]!=0);    dvd_file_t* file =         DVDOpenFile(reader, (int)titleNo,                     isMenu ? DVD_READ_MENU_VOBS : DVD_READ_TITLE_VOBS);    return (file==0) ? 0 : new FileHandler(file);}//------------------------------------------------------------------------------void DVDImage::close(){    assert(isOpen());    closeIFOHandles();        DVDClose(reader);    reader = 0;}//------------------------------------------------------------------------------void DVDImage::eject(){}//------------------------------------------------------------------------------bool DVDImage::readIFOHandles(){    if (!isOpen()) return false;    ifo_handle_t* ifoHandle = ifoOpen(reader, 0);    if (ifoHandle==0) return false;    ifoHandles[0] = ifoHandle;    size_t numVTSs = ifoHandle->vmgi_mat->vmg_nr_of_title_sets;        Log::debug("dvd::DVD::readIFOHandles: number of VTSs: %u\n",               numVTSs);    for(size_t i = 1; i<=numVTSs; i++) {        ifoHandle = ifoOpen(reader, (int)i);        if (ifoHandle==0) return false;        ifoHandles[i] = ifoHandle;    }    return true;}//------------------------------------------------------------------------------void DVDImage::closeIFOHandles(){    for(size_t i = 0; i<sizeof(ifoHandles)/sizeof(ifoHandles[0]); ++i) {        ifoClose(ifoHandles[i]);        ifoHandles[i] = 0;    }}//------------------------------------------------------------------------------

⌨️ 快捷键说明

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