DVDContainerFile.hpp

00001 /*********************************************************************** 00002 * * 00003 * ViTooKi * 00004 * * 00005 * title: DVDContianerFile.hpp * 00006 * * 00007 * * 00008 * * 00009 * ITEC institute of the University of Klagenfurt (Austria) * 00010 * http://www.itec.uni-klu.ac.at * 00011 * * 00012 * * 00013 * For more information visit the ViTooKi homepage: * 00014 * http://ViTooKi.sourceforge.net * 00015 * vitooki-user@lists.sourceforge.net * 00016 * vitooki-devel@lists.sourceforge.net * 00017 * * 00018 * This file is part of ViTooKi, a free video toolkit. * 00019 * ViTooKi is free software; you can redistribute it and/or * 00020 * modify it under the terms of the GNU General Public License * 00021 * as published by the Free Software Foundation; either version 2 * 00022 * of the License, or (at your option) any later version. * 00023 * * 00024 * This program is distributed in the hope that it will be useful, * 00025 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00026 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00027 * GNU General Public License for more details. * 00028 * * 00029 * You should have received a copy of the GNU General Public License * 00030 * along with this program; if not, write to the Free Software * 00031 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, * 00032 * MA 02111-1307, USA. * 00033 * * 00034 ***********************************************************************/ 00035 00036 /*********************************************************************** 00037 * * 00038 * REVISION HISTORY: * 00039 * * 00040 * * 00041 * * 00042 ***********************************************************************/ 00043 00044 #ifndef WIN32 00045 00046 #include "global.hpp" 00047 00048 class ContainerInfo; 00049 class ESInfo; 00050 00057 /* mpeg version */ 00058 #define MPEG1 0 // mpeg1 video 00059 #define MPEG2 1 // mpeg2 video 00060 00061 /* video format */ 00062 #define NTSC 0 // ntsc format 00063 #define PAL 1 // pal fomrat 00064 00065 /* display aspect ratio*/ 00066 #define NORM 0 // 4:3 00067 #define WIDE 1 // 16:9 00068 00069 /* letterboxed */ 00070 #define NOTLETTERBOXED 0 // normal 00071 #define LETTERBOXED 1 // already letterboxed 00072 00073 /* bit rate */ 00074 #define VBR 0 // variable bit rate 00075 #define CBR 1 // constant bitrate 00076 00077 00080 /* audio format */ 00081 #define AC3 0 // dolby digital 00082 #define MPEG1A 2 // mpeg1 audio 00083 #define MPEG2EXT 3 // extended mpeg2 audio 00084 #define LPCM 4 // lpcm audio 00085 #define DTS_AUDIO 6 // dts audio 00086 00087 /* has multichannel extension */ 00088 #define NOMULTI 0 // no multichannel extension 00089 #define MULTI 1 // multichannel extension 00090 00091 /* application mode */ 00092 #define NOSPECAM 0 // not specified 00093 #define KARAOKE 1 // karaoke mode 00094 #define SURROUND 2 // surround mode 00095 00096 /* quantization */ 00097 #define BIT16 0 // 16 bit 00098 #define BIT20 1 // 20 bit 00099 #define BIT24 2 // 24 bit 00100 #define DRC 3 // drc 00101 00102 /* sample frequency */ 00103 #define KHZ48 0 // 48Khz 00104 #define UNKNOWNSF 1 // unknown frequency 00105 00106 /* code extension */ 00107 #define NOSPECCE 0 // not specified 00108 #define NORMCAP 1 // normal caption 00109 #define VIMP 2 // audio for visually impaired 00110 #define DIRCOMM1 3 // directors comment 1 00111 #define DIRCOMM2 4 // directors comment 2 00112 00113 /* dolby surround */ 00114 #define NODOLBY 0 // no dolby surround 00115 #define DOLBY 1 // dolby surround 00116 00117 00120 /* coding mode */ 00121 #define RLE 0 // rle 00122 #define CMEXT 1 // extended coding mode 00123 /* including libdvdread stuff */ 00124 #include <dvdread/dvd_reader.h> 00125 #include <dvdread/ifo_read.h> 00126 #include <dvdread/ifo_types.h> 00127 00128 00132 /* handles one instance of a dvd */ 00133 struct dvd_handle_s { 00134 char filename[MAX_STR_LEN]; 00135 dvd_reader_t *dvd_reader; 00136 u32 nr_vts; 00137 u32 main_title_no; 00138 char *target; 00139 }; 00140 00141 /* opaque type for one dvd instance */ 00142 typedef struct dvd_handle_s dvd_handle_t; 00143 00144 /* used internal for one video title set */ 00145 typedef struct vts_info_s vts_info_t; 00146 00147 00153 /* Container for DVDs */ 00154 class DVDContainerFile { 00155 public: 00156 00157 /* opens a dvd 00158 * @param file (device or image) 00159 * @return handle for one instance of a dvd or 0 on fail 00160 */ 00161 static dvd_handle_t * openDVD(const char *file); 00162 00163 /* close dvd 00164 * @param dvd handle 00165 * @return void 00166 */ 00167 static void closeDVD(dvd_handle_t *dvd_handle); 00168 00169 /* get number of video title sets 00170 * @param dvd handle 00171 * @return number of video title sets 00172 */ 00173 static u32 getNrOfVTS(dvd_handle_t *dvd_handle); 00174 00175 /* get the filename of the current dvd 00176 * @param dvd_handle 00177 * @return filename 00178 */ 00179 static char * getFileName(dvd_handle_t *dvd_handle); 00180 00181 /* get suggested main title number 00182 * @param dvd_handle 00183 * @return suggested main title 00184 */ 00185 static u32 getMainTitleNo(dvd_handle_t *dvd_handle); 00186 00187 /* set main title to a custom VTS number 00188 * @param dvd_handle 00189 * @param vts number 00190 * @return void_function 00191 */ 00192 static void setMainTileNo(dvd_handle_t *dvd_handle, u32 main_title_no); 00193 00194 /* set temporary target for storing the vob 00195 * @param path+filename e.g. /home/foo/myvob.vob 00196 */ 00197 static void setTargetName(dvd_handle_t *dvd_handle,char *target); 00198 00199 /* get temporary target name 00200 * @param dvdhandle 00201 * @return path+filename 00202 */ 00203 static char * getTargetName(dvd_handle_t *dvd_handle); 00204 00205 /* load container information for one video title set 00206 * @param dvd_handle, video title set number 00207 * @return container information 00208 */ 00209 static ContainerInfo * loadContainerInfo(dvd_handle_t *dvd_handle, u32 vts_nr); 00210 00211 /* rip video title 00212 * @param dvd_handle 00213 * @param percentage to rip (1-100 in %), 0 means 100% 00214 * @return u32 error code 00215 */ 00216 static u32 copyMain(dvd_handle_t *dvd_handle, u32 percentage); 00217 00218 private: 00219 00220 /* get basic video title set information 00221 * (number of audio and subpicture streams + ifo handle 00222 * @param dvd handle, video title set number 00223 * @return basic vts info 00224 */ 00225 static vts_info_t * getVTSInfo(dvd_handle_t *dvd_handle, u32 vts_nr); 00226 00227 /* get video ESInfo 00228 * @param vts info 00229 * @return video ESInfo 00230 */ 00231 static ESInfo * getVideoInfo(vts_info_t *vts_info, ContainerInfo *container); 00232 00233 /* get audio ESInfo 00234 * @param vts info, audio stream number 00235 * @return audio ESInfo, 0 on fail 00236 */ 00237 static ESInfo * getAudioInfo(vts_info_t *vts_info, u32 stream_nr, ContainerInfo *container); 00238 00239 /* get subpicture ESInfo 00240 * @param vts_info, subpicture stream number 00241 * @return subpicture ESInfo, 0 on fail 00242 */ 00243 static ESInfo * getSubInfo(vts_info_t *vts_info, u32 stream_nr, ContainerInfo *container); 00244 }; 00245 00246 #endif /* WIN32 */ 00247