Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members
DVDContainerFile.cpp
00001 /*********************************************************************** 00002 * * 00003 * ViTooKi * 00004 * * 00005 * title: DVDContianerFile.cpp * 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 "DVDContainerFile.hpp" 00047 #include "ContainerInfo.hpp" 00048 #include "ESInfo.hpp" 00049 #include "debug.hpp" 00050 #include "VideoESInfo.hpp" 00051 #include "AudioESInfo.hpp" 00052 00053 #include <stdio.h> 00054 #include <string.h> 00055 00056 00057 00058 00059 /* handles info for one vts */ 00060 struct vts_info_s { 00061 u32 nr_audio_streams; 00062 u32 nr_sub_streams; 00063 ifo_handle_t *ifo_handle; 00064 }; 00065 00066 /* open dvd */ 00067 dvd_handle_t * DVDContainerFile::openDVD(const char *file){ 00068 assert(file); 00069 if(!file) 00070 return NULL; 00071 /* create new instance to handle a dvd */ 00072 dvd_handle_t *dvd_handle = new dvd_handle_t(); 00073 00074 /* set filename */ 00075 dprintf_full("============================================================\n"); 00076 dprintf_full("DVDContainerFile::openDVD:\n"); 00077 dprintf_full("Checking filename\n"); 00078 strcpy(dvd_handle->filename,file); 00079 00080 /* open dvd */ 00081 dprintf_full("Using libdvdread to open DVD\n"); 00082 if(!(dvd_handle->dvd_reader = DVDOpen(file))) { 00083 delete dvd_handle; 00084 return NULL; 00085 } 00086 /* get number of video title sets */ 00087 ifo_handle_t *ifo_handle=NULL; 00088 ifo_handle = ifoOpenVMGI(dvd_handle->dvd_reader); 00089 if(ifo_handle==NULL) { 00090 delete dvd_handle; 00091 return NULL; 00092 } 00093 dprintf_full("Setting number of VTS\n"); 00094 dvd_handle->nr_vts = ifo_handle->vmgi_mat->vmg_nr_of_title_sets; 00095 ifoClose(ifo_handle); 00096 00097 /* check main title */ 00098 u32 i; 00099 u32 mainsize = 0; 00100 dvd_handle->main_title_no = 0; 00101 dvd_file_t *dvd_file=NULL; 00102 dprintf_full("Checking for main title\n"); 00103 for(i = 1; i <= dvd_handle->nr_vts; i++){ 00104 dvd_file = DVDOpenFile( dvd_handle->dvd_reader, i, DVD_READ_TITLE_VOBS ); 00105 u32 actsize = DVDFileSize( dvd_file ); 00106 DVDCloseFile( dvd_file ); 00107 if(mainsize < actsize){ 00108 dvd_handle->main_title_no = i; 00109 mainsize = actsize; 00110 } 00111 }; 00112 00113 return dvd_handle; 00114 }; 00115 00116 /* close dvd */ 00117 void DVDContainerFile::closeDVD(dvd_handle_t *dvd_handle){ 00118 00119 dprintf_full("============================================================\n"); 00120 dprintf_full("DVDContainerFile::closeDVD:\n"); 00121 dprintf_full("Using libdvdread to close DVD and clean up\n"); 00122 00123 /* close dvd_reader */ 00124 if(dvd_handle->dvd_reader) 00125 DVDClose(dvd_handle->dvd_reader); 00126 00127 /* free the handle */ 00128 delete dvd_handle; 00129 }; 00130 00131 /* get number of video title sets */ 00132 u32 DVDContainerFile::getNrOfVTS(dvd_handle_t *dvd_handle){ 00133 00134 return dvd_handle->nr_vts; 00135 }; 00136 00137 /* get filename of selected dvd */ 00138 char * DVDContainerFile::getFileName(dvd_handle_t *dvd_handle){ 00139 00140 return dvd_handle->filename; 00141 } 00142 00143 /* get suggested main title number */ 00144 u32 DVDContainerFile::getMainTitleNo(dvd_handle_t *dvd_handle){ 00145 00146 return dvd_handle->main_title_no; 00147 } 00148 00149 /* set custom main title */ 00150 void DVDContainerFile::setMainTileNo(dvd_handle_t *dvd_handle, u32 main_title_no){ 00151 dvd_handle->main_title_no = main_title_no; 00152 } 00153 00154 /* set target name */ 00155 void DVDContainerFile::setTargetName(dvd_handle_t *dvd_handle, char *target){ 00156 00157 dvd_handle->target = target; 00158 } 00159 00160 /* get target name */ 00161 char * DVDContainerFile::getTargetName(dvd_handle_t *dvd_handle){ 00162 00163 return dvd_handle->target; 00164 } 00165 00166 /* load container information for selected vts */ 00167 ContainerInfo * DVDContainerFile::loadContainerInfo(dvd_handle_t *dvd_handle, u32 vts_nr){ 00168 00169 /* url is set to NULL */ 00170 const char *nourl = NULL; 00171 00172 /* create new containerinfo (filename will be deep-copied) */ 00173 ContainerInfo *container = new ContainerInfo(nourl, dvd_handle->filename, ContainerInfo::DVD); 00174 00175 /* get basic vts information */ 00176 dprintf_full("============================================================\n"); 00177 dprintf_full("DVDContainerFile::loadContainerInfo:\n"); 00178 dprintf_full("Getting VTS information\n"); 00179 vts_info_t *vts_info = DVDContainerFile::getVTSInfo(dvd_handle, vts_nr); 00180 00181 /* get video stream info and add to container */ 00182 dprintf_full("\nDVDContainerFile::loadContainerInfo:\n"); 00183 dprintf_full("Getting video information\n"); 00184 ESInfo *es_info = DVDContainerFile::getVideoInfo(vts_info, container); 00185 container->addESInfo(es_info); 00186 00187 u32 i; 00188 /* get audio streams and add to container */ 00189 for(i = 0; i < vts_info->nr_audio_streams; i++){ 00190 dprintf_full("\nDVDContainerFile::loadContainerInfo:\n"); 00191 dprintf_full("Getting audio information for stream %i\n",i); 00192 es_info = DVDContainerFile::getAudioInfo(vts_info, i, container); 00193 container->addESInfo(es_info); 00194 } 00195 00196 /* get subpicture streams and add to container */ 00197 for(i = 0; i < vts_info->nr_sub_streams; i++){ 00198 dprintf_full("\nDVDContainerFile::loadContainerInfo:\n"); 00199 dprintf_full("Getting subpicture information for stream %i\n",i); 00200 es_info = DVDContainerFile::getSubInfo(vts_info, i, container); 00201 container->addESInfo(es_info); 00202 } 00203 00204 dprintf_full("\nDVDContainerFile::loadContainerInfo:\n"); 00205 dprintf_full("All information added to ContainerInfo\n\n"); 00206 return container; 00207 }; 00208 00209 /* get basic vts information */ 00210 vts_info_t * DVDContainerFile::getVTSInfo(dvd_handle_t *dvd_handle, u32 vts_nr){ 00211 00212 vts_info_t *vts_info = new vts_info_t(); 00213 00214 /* open ifo file for selected vts and get handle*/ 00215 dprintf_full("============================================================\n"); 00216 dprintf_full("DVDContainerFile::getVTSInfo:\n"); 00217 dprintf_full("Using libdvdread to open IFO file\n"); 00218 vts_info->ifo_handle = ifoOpen(dvd_handle->dvd_reader,vts_nr); 00219 00220 /* get number of audio streams */ 00221 vts_info->nr_audio_streams = vts_info->ifo_handle->vtsi_mat->nr_of_vts_audio_streams; 00222 dprintf_full("VTS %i has %i audio streams\n",vts_nr, vts_info->nr_audio_streams); 00223 00224 /* get number of subpicture streams */ 00225 vts_info->nr_sub_streams = vts_info->ifo_handle->vtsi_mat->nr_of_vts_subp_streams; 00226 dprintf_full("VTS %i has %i subpicture streams\n",vts_nr, vts_info->nr_sub_streams); 00227 00228 return vts_info; 00229 } 00230 00231 /* get video stream esinfo */ 00232 ESInfo * DVDContainerFile::getVideoInfo(vts_info_t *vts_info, ContainerInfo *container){ 00233 00234 dprintf_full("========================================\n"); 00235 dprintf_full("DVDContainerFile::getVideoInfo:\n"); 00236 /* beautifier */ 00237 vtsi_mat_t *vtsi_mat = vts_info->ifo_handle->vtsi_mat; 00238 //pgcit_t *pgcit = vts_info->ifo_handle->vts_pgcit; 00239 00240 /* get dvd values */ 00241 /* mpeg version */ 00242 u32 mpeg_version = (vtsi_mat->vts_video_attr.mpeg_version) ? MPEG2 : MPEG1; 00243 /* print value (currently for devolpment and presentation) */ 00244 if (mpeg_version) { 00245 dprintf_full("Videoinfo - MPEGversion = MPEG2\n"); 00246 } 00247 else { 00248 dprintf_full("Videoinfo - MPEGversion = MPEG1\n"); 00249 } 00250 00251 /* video format */ 00252 u32 video_format = (vtsi_mat->vts_video_attr.video_format) ? PAL : NTSC; 00253 /* print value (currently for devolpment and presentation) */ 00254 if (video_format) { 00255 dprintf_full("Videoinfo - Videoformat = PAL\n"); 00256 } 00257 else { 00258 dprintf_full("Videoinfo - Videoformat = NTSC\n"); 00259 } 00260 00261 // frame rate, needed for time_increment 00262 u32 fps = (video_format == PAL) ? 25 : 30; 00263 00264 /* display aspect ratio */ 00265 u32 dar = (vtsi_mat->vts_video_attr.display_aspect_ratio) ? WIDE : NORM; 00266 /* print value (currently for devolpment and presentation) */ 00267 if (dar) { 00268 dprintf_full("Videoinfo - Aspect ratio = 16:9\n"); 00269 } 00270 else { 00271 dprintf_full("Videoinfo - Aspect ratio = 4:3\n"); 00272 } 00273 00274 /* letterboxed flag */ 00275 u32 letterboxed = (vtsi_mat->vts_video_attr.letterboxed) ? LETTERBOXED : NOTLETTERBOXED; 00276 /* print value (currently for devolpment and presentation) */ 00277 if (letterboxed) { 00278 dprintf_full("Videoinfo - Letterboxed = yes\n") 00279 } 00280 else { 00281 dprintf_full("Videoinfo - Letterboxed = no\n"); 00282 } 00283 00284 /* bit rate */ 00285 u32 bitrate = (vtsi_mat->vts_video_attr.bit_rate) ? CBR : VBR; 00286 /* print value (currently for devolpment and presentation) */ 00287 if (bitrate) { 00288 dprintf_full("Videoinfo - Bitrate = CBR\n"); 00289 } 00290 else { 00291 dprintf_full("Videoinfo - Bitrate = VBR\n"); 00292 } 00293 00294 /* vertical resolution */ 00295 u32 vres = (vtsi_mat->vts_video_attr.video_format) ? 576 : 480; 00296 /* print value (currently for devolpment and presentation) */ 00297 dprintf_full("Videoinfo - Vertical resolution = %i\n", vres); 00298 00299 /* horizontal resolution */ 00300 u32 hres; 00301 switch(vtsi_mat->vts_video_attr.picture_size) { 00302 case 0: 00303 hres = 720; 00304 break; 00305 case 1: 00306 hres = 704; 00307 break; 00308 case 2: 00309 hres = 352; 00310 break; 00311 case 3: 00312 hres = 352; 00313 vres /= 2; // half format 00314 break; 00315 default: 00316 return 0; 00317 } 00318 /* print value (currently for devolpment and presentation) */ 00319 dprintf_full("Videoinfo - Horizontal resolution = %i\n", hres); 00320 00321 /* set vitooki values */ // not finished yet 00322 u32 stream_id = 480; // always the id of first videostream on a dvd video!! 00323 u32 stream_type = 0; // check for universal or dvd video stream type 00324 u32 time_increment = 90000/fps; // not yet set 00325 u32 obj_type = 0; // not yet set - unimportant? 00326 u32 buffer_size = 0; // not yet set 00327 u32 avg_bw = 0; // not yet set 00328 u32 max_bw = 0; // not yet set 00329 u32 time_scale = 90000; // FAKED VALUE ??!!!!! 00330 u32 size = 0; // not yet set 00331 u32 height = vres; 00332 u32 width = hres; 00333 u64 duration = 972000000; // FIXME: 3 hours hard-coded 00334 bool color_video = true; // check if possible to get real value from ifo 00335 bool complete = true; // check this value 00336 float quality = 1.0; 00337 float aspect_ratio = (dar) ? ( 16.0/9.0 ) : ( 4.0/3.0 ); 00338 CodecID codec_id = (video_format) ? CODEC_ID_MPEG2VIDEO : CODEC_ID_MPEG1VIDEO; // check values reagarding avcodec.h 00339 00340 VideoESInfo *video_info = new VideoESInfo(stream_id, stream_type, container, time_increment, 0, obj_type, buffer_size, avg_bw, max_bw, time_scale, duration, size, width, height, color_video, complete, codec_id, quality, aspect_ratio, 0, 0); 00341 00342 return video_info; 00343 } 00344 00345 /* get audio stream esinfo */ 00346 ESInfo * DVDContainerFile::getAudioInfo(vts_info_t *vts_info, u32 stream_nr, ContainerInfo *container){ 00347 00348 dprintf_full("========================================\n"); 00349 dprintf_full("DVDContainerFile::getAudioInfo:\n"); 00350 00351 /* check if stream exists */ 00352 if(stream_nr < 0 || stream_nr >= vts_info->nr_audio_streams) 00353 return 0; 00354 00355 /* beautifier */ 00356 vtsi_mat_t *vtsi_mat = vts_info->ifo_handle->vtsi_mat; 00357 pgcit_t *pgcit = vts_info->ifo_handle->vts_pgcit; 00358 u32 i = stream_nr; 00359 00360 /* get dvd values */ 00361 /* audio format */ 00362 u32 audio_format; 00363 switch(vtsi_mat->vts_audio_attr[i].audio_format){ 00364 case 0: 00365 audio_format = AC3; 00366 /* print value (currently for devolpment and presentation) */ 00367 dprintf_full("Audioinfo - Audioformat = Dolby Digital AC3\n"); 00368 break; 00369 case 2: 00370 audio_format = MPEG1A; 00371 /* print value (currently for devolpment and presentation) */ 00372 dprintf_full("Audioinfo - Audioformat = MPEG1 audio\n"); 00373 break; 00374 case 3: 00375 audio_format = MPEG2EXT; 00376 /* print value (currently for devolpment and presentation) */ 00377 dprintf_full("Audioinfo - Audioformat = MPEG2 extended audio\n"); 00378 break; 00379 case 4: 00380 audio_format = LPCM; 00381 /* print value (currently for devolpment and presentation) */ 00382 dprintf_full("Audioinfo - Audioformat = Linear Pulse Code Modulation LPCM\n"); 00383 break; 00384 case 6: 00385 audio_format = DTS_AUDIO; 00386 /* print value (currently for devolpment and presentation) */ 00387 dprintf_full("Audioinfo - Audioformat = Digital Theater System DTS\n"); 00388 break; 00389 default: 00390 return 0; 00391 } 00392 00393 /* multichannel extension */ 00394 u32 multichannel_extension = (vtsi_mat->vts_audio_attr[i].multichannel_extension) ? MULTI : NOMULTI; 00395 /* print value (currently for devolpment and presentation) */ 00396 if (multichannel_extension) { 00397 dprintf_full("Audioinfo - Multichannel extension = yes\n"); 00398 } 00399 else { 00400 dprintf_full("Audioinfo - Multichannel extension = no\n"); 00401 } 00402 00403 /* application mode */ 00404 u32 application_mode; 00405 switch(vtsi_mat->vts_audio_attr[i].application_mode){ 00406 case 0: 00407 application_mode = NOSPECAM; 00408 /* print value (currently for devolpment and presentation) */ 00409 dprintf_full("Audioinfo - Application mode = none\n"); 00410 break; 00411 case 1: 00412 application_mode = KARAOKE; 00413 /* print value (currently for devolpment and presentation) */ 00414 dprintf_full("Audioinfo - Application mode = Karaoke\n"); 00415 break; 00416 case 2: 00417 application_mode = SURROUND; 00418 /* print value (currently for devolpment and presentation) */ 00419 dprintf_full("Audioinfo - Application mode = Surround\n"); 00420 break; 00421 default: 00422 return 0; 00423 } 00424 00425 /* quantization */ 00426 u32 quantization; 00427 switch(vtsi_mat->vts_audio_attr[i].quantization){ 00428 case 0: 00429 quantization = BIT16; 00430 /* print value (currently for devolpment and presentation) */ 00431 dprintf_full("Audioinfo - Quantization = 16Bit\n"); 00432 break; 00433 case 1: 00434 quantization = BIT20; 00435 /* print value (currently for devolpment and presentation) */ 00436 dprintf_full("Audioinfo - Quantization = 20Bit\n"); 00437 break; 00438 case 2: 00439 quantization = BIT24; 00440 /* print value (currently for devolpment and presentation) */ 00441 dprintf_full("Audioinfo - Quantization = 24Bit\n"); 00442 break; 00443 case 3: 00444 quantization = DRC; 00445 /* print value (currently for devolpment and presentation) */ 00446 dprintf_full("Audioinfo - Quantization = Dynamic Range Control DRC\n"); 00447 break; 00448 default: 00449 return 0; 00450 } 00451 00452 /* sample frequency */ 00453 u32 sample_frequency = (vtsi_mat->vts_audio_attr[i].sample_frequency) ? UNKNOWNSF : KHZ48; 00454 if (sample_frequency) { 00455 dprintf_full("Audioinfo - Sample frequency = unknown\n"); 00456 } 00457 else { 00458 dprintf_full("Audioinfo - Sample frequency = 48KHz\n"); 00459 } 00460 00461 /* code extension */ 00462 u32 code_extension; 00463 switch(vtsi_mat->vts_audio_attr[i].code_extension){ 00464 case 0: 00465 code_extension = NOSPECCE; 00466 break; 00467 case 1: 00468 code_extension = NORMCAP; 00469 break; 00470 case 2: 00471 code_extension = VIMP; 00472 break; 00473 case 3: 00474 code_extension = DIRCOMM1; 00475 break; 00476 case 4: 00477 code_extension = DIRCOMM2; 00478 break; 00479 default: 00480 return 0; 00481 } 00482 00483 /* dolby encoded flag */ 00484 u32 dolby_encoded = (application_mode == SURROUND && vtsi_mat->vts_audio_attr[i].app_info.surround.dolby_encoded) ? DOLBY : NODOLBY; 00485 if (dolby_encoded) { 00486 dprintf_full("Audioinfo - Dolby encoded = yes\n"); 00487 } 00488 else { 00489 dprintf_full("Audioinfo - Dolby encoded = no\n"); 00490 } 00491 00492 /* number of audio channels */ 00493 u32 channels = vtsi_mat->vts_audio_attr[i].channels +1; 00494 /* print value (currently for devolpment and presentation) */ 00495 dprintf_full("Audioinfo - Number of audio channels = %i\n",channels); 00496 00497 /* language */ 00498 char language[2]; 00499 language[0] = vtsi_mat->vts_audio_attr[i].lang_code>>8; 00500 language[1] = vtsi_mat->vts_audio_attr[i].lang_code & 0xff; 00501 /* print value (currently for devolpment and presentation) */ 00502 dprintf_full("Audioinfo - Language = %s\n",language); 00503 00504 /* 00505 HACK FROM OGLE PLAYER! to get streamid 00506 file: ogle/vmg/vm.c: 00507 function: int vm_get_audio_stream(int audioN): 00508 code: if(state.pgc->audio_control[audioN] & (1<<15)) { 00509 streamN = (state.pgc->audio_control[audioN] >> 8) & 0x07;} 00510 ... modified to work for vitooki 00511 currently only dd and dts are supported by this ugly hack!! 00512 */ 00513 u32 si = pgcit->pgci_srp->pgc->audio_control[i] >> 8; 00514 if (audio_format == DTS_AUDIO) 00515 si += 8; 00516 dprintf_full("Audioinfo - StreamID = %i\n", si); 00517 00518 /* set vitooki values */ // not finished yet 00519 u32 stream_id = si; 00520 u32 stream_type = 0; // check for universal or dvd audio stream type 00521 u32 time_increment = 0; // not yet set 00522 u32 obj_type = 0; // not yet set - unimportant? 00523 u32 buffer_size = 0; // not yet set 00524 u32 avg_bw = 0; // not yet set 00525 u32 max_bw = 0; // not yet set 00526 u32 time_scale = 90000; // FAKED VALUE ??!!! 00527 u32 size = 0; // not yet set 00528 u32 sample_rate = (sample_frequency) ? 0 : 48000; // 0 means unknown 00529 u32 num_audio_channels = channels; 00530 u64 duration = 0; // not yet set 00531 bool complete = true; // check this value 00532 float quality = 1.0; 00533 CodecID codec_id; 00534 switch(audio_format){ 00535 case 0: 00536 codec_id = CODEC_ID_AC3; 00537 break; 00538 case 2: 00539 codec_id = CODEC_ID_NONE; // check for mpeg1audio ?? 00540 break; 00541 case 3: 00542 codec_id = CODEC_ID_NONE; // check for mpeg2extendedaudio ?? 00543 break; 00544 case 4: 00545 codec_id = CODEC_ID_NONE; // check for correct lpcm codek ?? 00546 break; 00547 case 6: 00548 codec_id = CODEC_ID_NONE; //check for dts codec ?? 00549 break; 00550 default: 00551 return 0; // error that should never happen!! 00552 } 00553 00554 AudioESInfo *audio_info = new AudioESInfo(stream_id, stream_type, container, time_increment, NULL, obj_type, buffer_size, avg_bw, max_bw, time_scale, duration, size, sample_rate, num_audio_channels, complete, codec_id, quality); 00555 00556 return audio_info; 00557 } 00558 00559 /* get subpicture stream esinfo */ 00560 ESInfo * DVDContainerFile::getSubInfo(vts_info_t *vts_info, u32 stream_nr, ContainerInfo *container){ 00561 00562 dprintf_full("========================================\n"); 00563 dprintf_full("DVDContainerFile::getSubInfo:\n"); 00564 00565 /* check if stream exists */ 00566 if(stream_nr < 0 || stream_nr >= vts_info->nr_sub_streams) 00567 return 0; 00568 00569 /* beautifier */ 00570 vtsi_mat_t *vtsi_mat = vts_info->ifo_handle->vtsi_mat; 00571 // pgcit_t *pgcit = vts_info->ifo_handle->vts_pgcit; 00572 u32 i = stream_nr; 00573 00574 /* get dvd values */ 00575 /* coding mode */ 00576 u32 code_mode = (vtsi_mat->vts_subp_attr[i].code_mode) ? CMEXT : RLE; 00577 if (code_mode) { 00578 dprintf_full("Subpictureinfo - Code mode = Code mode extended\n"); 00579 } 00580 else { 00581 dprintf_full("Subpictureinfo - Code mode = Run-Length encoded\n"); 00582 } 00583 /* language */ 00584 char language[2]; 00585 if(vtsi_mat->vts_subp_attr[i].type == 1){ 00586 if(isalpha((int)(vtsi_mat->vts_subp_attr[i].lang_code>>8)) && isalpha((int)(vtsi_mat->vts_subp_attr[i].lang_code & 0xff))){ 00587 language[0] = vtsi_mat->vts_subp_attr[i].lang_code>>8; 00588 language[1] = vtsi_mat->vts_subp_attr[i].lang_code & 0xff; 00589 } 00590 else { 00591 language[0] = '1'; // check mysterious hex stuff from dvdread 00592 language[1] = '1'; // and adapt here (TODO) 00593 } 00594 } 00595 else { 00596 language[0] = '0'; // no language 00597 language[1] = '0'; // --"-- 00598 } 00599 /* print value (currently for devolpment and presentation) */ 00600 dprintf_full("Subpictureinfo - Language = %s\n",language); 00601 00602 /* set vitooki values */ // not finished yet 00603 u32 stream_id = stream_nr + vts_info->nr_audio_streams + 2; 00604 u32 stream_type = 0; // check for universal or dvd subpicture stream type 00605 u32 time_increment = 0; // not yet set 00606 u32 obj_type = 0; // not yet set - unimportant? 00607 u32 buffer_size = 0; // not yet set 00608 u32 avg_bw = 0; // not yet set 00609 u32 max_bw = 0; // not yet set 00610 u32 time_scale = 1; // not yet set - FAKED VALUE!!! 00611 u32 size = 0; // not yet set 00612 u32 sample_rate = 0; //not yet set (n/a for subpicture) 00613 u32 num_audio_channels = 0; // not yet set (n/a for subpicture) 00614 u64 duration = 0; // not yet set 00615 bool complete = true; // check this value 00616 float quality = 1.0; 00617 CodecID codec_id = CODEC_ID_NONE; // check for subpicture codec ?? 00618 00619 // THIS IS CURRENTLY A FAKE BECAUSE NO SUB_INFO EXISTS 00620 AudioESInfo *sub_info = new AudioESInfo(stream_id, stream_type, container, time_increment, NULL, obj_type, buffer_size, avg_bw, max_bw, time_scale, duration, size, sample_rate, num_audio_channels, complete, codec_id, quality); 00621 00622 return sub_info; 00623 } 00624 00625 u32 DVDContainerFile::copyMain(dvd_handle_t *dvd_handle, u32 percentage){ 00626 00627 dprintf_full("============================================================\n"); 00628 dprintf_full("DVDContainerFile::copyMain:\n"); 00629 00630 /* buffer */ 00631 unsigned char *buffer; 00632 unsigned char charbuf; 00633 u32 buffersize = 512; 00634 00635 /* File Handler */ 00636 int streamout; 00637 char * target = dvd_handle->target; 00638 00639 /* open dvdfile */ 00640 dvd_file_t *dvd_file; 00641 dvd_file = DVDOpenFile( dvd_handle->dvd_reader, dvd_handle->main_title_no, DVD_READ_TITLE_VOBS); 00642 00643 /* get mem for buffer */ 00644 buffer = (unsigned char *)malloc(buffersize * 2048 * sizeof(charbuf)); 00645 00646 /* open output file */ 00647 if( (streamout = open(target, O_WRONLY | O_CREAT, 0644)) == -1){ 00648 dprintf_full("Error opening outputfile!\n"); 00649 return 1; 00650 } 00651 00652 /* rip maintitle */ 00653 int offset = 0; 00654 u32 ripsize = DVDFileSize(dvd_file); 00655 if (percentage > 0 && percentage < 100){ 00656 dprintf_full("Ripping %i%% of main title...\n", percentage); 00657 ripsize *= (int)round(percentage/100.00); 00658 } 00659 else{ 00660 dprintf_full("Ripping main title...\n"); 00661 } 00662 int size = ripsize; 00663 00664 while (ripsize > 0) { 00665 00666 dprintf_full("Ripping Blocks: %.2f %%",(100.00-((float)ripsize/(float)size)*100.00)); 00667 dprintf_full("\r"); 00668 00669 if (buffersize > ripsize) 00670 buffersize = ripsize; 00671 00672 /* read blocks from dvd */ 00673 if( (DVDReadBlocks(dvd_file,offset,buffersize, buffer)) == -1){ 00674 dprintf_full("\nError reading blocks!!\n"); 00675 return 1; 00676 } 00677 00678 /* write to outputfile */ 00679 if (write(streamout,buffer,buffersize * 2048) == -1){ 00680 dprintf_full("\nError writing blocks!!\n"); 00681 return 1; 00682 } 00683 00684 ripsize -= buffersize; 00685 offset += buffersize; 00686 } 00687 dprintf_full("Ripping Blocks: 100%% complete\n"); 00688 free(buffer); 00689 close(streamout); 00690 00691 return 0; 00692 } 00693 00694 00695 #endif /* WIN32 */ 00696