Changeset 2401b66298e2d714223c9d5f32aa23376a0afc4c
- Timestamp:
- 06/11/02 16:41:29 (6 years ago)
- git-parent:
- Files:
-
- modules/access/vcd/vcd.c (modified) (17 diffs)
- modules/access/vcd/vcd.h (modified) (3 diffs)
- modules/gui/gtk/gtk_callbacks.c (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
modules/access/vcd/vcd.c
r09cbae7 r2401b66 3 3 ***************************************************************************** 4 4 * Copyright (C) 2000 VideoLAN 5 * $Id: vcd.c,v 1. 9 2002/10/26 15:24:19 gbazinExp $5 * $Id: vcd.c,v 1.10 2002/11/06 15:41:29 jobi Exp $ 6 6 * 7 7 * Author: Johan Bilien <jobi@via.ecp.fr> … … 11 11 * the Free Software Foundation; either version 2 of the License, or 12 12 * (at your option) any later version. 13 * 13 * 14 14 * This program is distributed in the hope that it will be useful, 15 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of … … 51 51 { 52 52 vcddev_t *vcddev; /* vcd device descriptor */ 53 int nb_tracks;/* Nb of tracks (titles) */53 int i_nb_tracks; /* Nb of tracks (titles) */ 54 54 int i_track; /* Current track */ 55 55 int i_sector; /* Current Sector */ 56 56 int * p_sectors; /* Track sectors */ 57 int i_entries_nb; /* Number of entry points */ 58 int * p_entries; /* Entry points */ 59 vlc_bool_t b_valid_ep; /* Valid entry points flag */ 57 60 vlc_bool_t b_end_of_track; /* If the end of track was reached */ 58 61 … … 68 71 static int VCDSetArea ( input_thread_t *, input_area_t * ); 69 72 static int VCDSetProgram ( input_thread_t *, pgrm_descriptor_t * ); 73 static int VCDEntryPoints ( input_thread_t * ); 70 74 71 75 /***************************************************************************** … … 112 116 /* parse the options passed in command line : */ 113 117 psz_orig = psz_parser = psz_source = strdup( p_input->psz_name ); 114 118 115 119 if( !psz_orig ) 116 120 { 117 121 return( -1 ); 118 122 } 119 123 120 124 while( *psz_parser && *psz_parser != '@' ) 121 125 { … … 159 163 return -1; 160 164 } 161 165 162 166 p_input->p_access_data = (void *)p_vcd; 163 167 164 168 p_input->i_mtu = VCD_DATA_ONCE; 165 169 166 170 vlc_mutex_lock( &p_input->stream.stream_lock ); 167 171 … … 183 187 184 188 /* We read the Table Of Content information */ 185 p_vcd-> nb_tracks = ioctl_GetTracksMap( VLC_OBJECT(p_input),189 p_vcd->i_nb_tracks = ioctl_GetTracksMap( VLC_OBJECT(p_input), 186 190 p_vcd->vcddev, &p_vcd->p_sectors ); 187 191 free( psz_source ); 188 if( p_vcd-> nb_tracks < 0 )192 if( p_vcd->i_nb_tracks < 0 ) 189 193 msg_Err( p_input, "unable to count tracks" ); 190 else if( p_vcd-> nb_tracks <= 1 )194 else if( p_vcd->i_nb_tracks <= 1 ) 191 195 msg_Err( p_input, "no movie tracks found" ); 192 if( p_vcd->nb_tracks <= 1) 193 { 194 //input_BuffersEnd( p_input, p_input->p_method_data ); /* ??? */ 196 if( p_vcd->i_nb_tracks <= 1) 197 { 195 198 ioctl_Close( p_this, p_vcd->vcddev ); 196 199 free( p_vcd ); … … 198 201 } 199 202 203 /* Allocate the entry points table */ 204 p_vcd->p_entries = malloc( p_vcd->i_nb_tracks * sizeof( int ) ); 205 206 if( p_vcd->p_entries == NULL ) 207 { 208 msg_Err( p_input, "not enough memory" ); 209 ioctl_Close( p_this, p_vcd->vcddev ); 210 free( p_vcd ); 211 } 212 200 213 /* Set stream and area data */ 201 214 vlc_mutex_lock( &p_input->stream.stream_lock ); … … 207 220 p_input->stream.i_method = INPUT_METHOD_VCD; 208 221 222 p_input->stream.i_area_nb = 1; 223 209 224 #define area p_input->stream.pp_areas 210 for( i = 1 ; i <= p_vcd-> nb_tracks - 1 ; i++ )225 for( i = 1 ; i <= p_vcd->i_nb_tracks - 1 ; i++ ) 211 226 { 212 227 input_AddArea( p_input ); … … 224 239 area[i]->i_part = 1; 225 240 226 area[i]->i_plugin_data = p_vcd->p_sectors[i]; 241 /* i_plugin_data is used to store which entry point is the first 242 * of the track (area) */ 243 area[i]->i_plugin_data = 0; 227 244 } 228 245 #undef area 229 246 230 247 p_area = p_input->stream.pp_areas[i_title]; 248 249 p_vcd->b_valid_ep = 1; 250 if( VCDEntryPoints( p_input ) < 0 ) 251 { 252 msg_Warn( p_input, "could read entry points, will not use them" ); 253 p_vcd->b_valid_ep = 0; 254 } 231 255 232 256 VCDSetArea( p_input, p_area ); … … 257 281 * bytes. 258 282 *****************************************************************************/ 259 static int VCDRead( input_thread_t * p_input, byte_t * p_buffer, 283 static int VCDRead( input_thread_t * p_input, byte_t * p_buffer, 260 284 size_t i_len ) 261 285 { … … 274 298 i_blocks = i_len / VCD_DATA_SIZE; 275 299 276 for ( i_index = 0 ; i_index < i_blocks ; i_index++ ) 300 for ( i_index = 0 ; i_index < i_blocks ; i_index++ ) 277 301 { 278 302 if ( ioctl_ReadSector( VLC_OBJECT(p_input), p_vcd->vcddev, … … 287 311 { 288 312 input_area_t *p_area; 289 290 if ( p_vcd->i_track >= p_vcd-> nb_tracks - 1 )313 314 if ( p_vcd->i_track >= p_vcd->i_nb_tracks - 1 ) 291 315 return 0; /* EOF */ 292 316 317 vlc_mutex_lock( &p_input->stream.stream_lock ); 293 318 p_area = p_input->stream.pp_areas[ 294 319 p_input->stream.p_selected_area->i_id + 1 ]; 295 320 296 321 msg_Dbg( p_input, "new title" ); 297 322 298 323 p_area->i_part = 1; 299 324 VCDSetArea( p_input, p_area ); 300 301 } 325 vlc_mutex_unlock( &p_input->stream.stream_lock ); 326 } 327 328 /* Update chapter */ 329 else if( p_vcd->b_valid_ep && 330 /* FIXME kludge so that read does not update chapter 331 * when a manual chapter change was requested and not 332 * yet accomplished */ 333 !p_input->stream.p_new_area ) 334 { 335 int i_entry; 336 337 vlc_mutex_lock( &p_input->stream.stream_lock ); 338 i_entry = p_input->stream.p_selected_area->i_plugin_data 339 /* 1st entry point of the track (area)*/ 340 + p_input->stream.p_selected_area->i_part - 1; 341 if( i_entry + 1 < p_vcd->i_entries_nb && 342 p_vcd->i_sector >= p_vcd->p_entries[i_entry + 1] ) 343 { 344 msg_Dbg( p_input, "new chapter" ); 345 p_input->stream.p_selected_area->i_part ++; 346 } 347 vlc_mutex_unlock( &p_input->stream.stream_lock ); 348 } 349 302 350 i_read += VCD_DATA_SIZE; 303 351 } 304 352 305 353 if ( i_len % VCD_DATA_SIZE ) /* this should not happen */ 306 { 354 { 307 355 if ( ioctl_ReadSector( VLC_OBJECT(p_input), p_vcd->vcddev, 308 356 p_vcd->i_sector, p_last_sector ) < 0 ) … … 311 359 return -1; 312 360 } 313 361 314 362 p_input->p_vlc->pf_memcpy( p_buffer + i_blocks * VCD_DATA_SIZE, 315 363 p_last_sector, i_len % VCD_DATA_SIZE ); … … 359 407 } 360 408 409 if( p_vcd->b_valid_ep ) 410 { 411 int i_entry = p_area->i_plugin_data /* 1st entry point of 412 the track (area)*/ 413 + p_area->i_part - 1; 414 p_vcd->i_sector = p_vcd->p_entries[i_entry]; 415 } 416 else 417 p_vcd->i_sector = p_vcd->p_sectors[p_vcd->i_track]; 418 419 p_input->stream.p_selected_area->i_tell = 420 (off_t)p_vcd->i_sector * (off_t)VCD_DATA_SIZE 421 - p_input->stream.p_selected_area->i_start; 422 361 423 /* warn interface that something has changed */ 362 424 p_input->stream.b_seekable = 1; … … 373 435 { 374 436 thread_vcd_data_t * p_vcd; 437 int i_index; 375 438 376 439 p_vcd = (thread_vcd_data_t *) p_input->p_access_data; … … 379 442 + i_off / (off_t)VCD_DATA_SIZE; 380 443 381 p_input->stream.p_selected_area->i_tell = 444 vlc_mutex_lock( &p_input->stream.stream_lock ); 445 #define p_area p_input->stream.p_selected_area 446 /* Find chapter */ 447 if( p_vcd->b_valid_ep ) 448 { 449 for( i_index = 0 ; i_index < p_area->i_part_nb - 1 ; i_index ++ ) 450 { 451 if( p_vcd->i_sector < p_vcd->p_entries[p_area->i_plugin_data 452 + i_index + 1] ) 453 { 454 p_area->i_part = i_index; 455 break; 456 } 457 } 458 } 459 #undef p_area 460 461 p_input->stream.p_selected_area->i_tell = 382 462 (off_t)p_vcd->i_sector * (off_t)VCD_DATA_SIZE 383 463 - p_input->stream.p_selected_area->i_start; 384 } 464 vlc_mutex_unlock( &p_input->stream.stream_lock ); 465 } 466 467 /***************************************************************************** 468 * VCDEntryPoints: Reads the information about the entry points on the disc. 469 *****************************************************************************/ 470 static int VCDEntryPoints( input_thread_t * p_input ) 471 { 472 thread_vcd_data_t * p_vcd; 473 byte_t * p_sector; 474 entries_sect_t entries; 475 uint16_t i_nb; 476 int i, i_entry_index = 0; 477 int i_previous_track = -1; 478 479 p_vcd = (thread_vcd_data_t *) p_input->p_access_data; 480 481 p_sector = malloc( VCD_DATA_SIZE * sizeof( byte_t ) ); 482 if( p_sector == NULL ) 483 { 484 msg_Err( p_input, "not enough memory for entry points treatment" ); 485 return -1; 486 } 487 488 if( ioctl_ReadSector( VLC_OBJECT(p_input), p_vcd->vcddev, 489 VCD_ENTRIES_SECTOR, p_sector ) < 0 ) 490 { 491 msg_Err( p_input, "could not read entry points sector" ); 492 free( p_sector ); 493 return( -1 ); 494 } 495 496 memcpy( &entries, p_sector, CD_SECTOR_SIZE ); 497 free( p_sector ); 498 499 if( (i_nb = U16_AT( &entries.i_entries_nb )) > 500 ) 500 { 501 msg_Err( p_input, "invalid entry points number" ); 502 return( -1 ); 503 } 504 505 p_vcd->p_entries = malloc( sizeof( int ) * i_nb ); 506 if( p_vcd->p_entries == NULL ) 507 { 508 msg_Err( p_input, "not enough memory for entry points treatment" ); 509 return -1; 510 } 511 512 if( strncmp( entries.psz_id, "ENTRYVCD", sizeof( entries.psz_id ) ) 513 && strncmp( entries.psz_id, "ENTRYSVD", sizeof( entries.psz_id ) )) 514 { 515 msg_Err( p_input, "unrecognized entry points format" ); 516 free( p_vcd->p_entries ); 517 return -1; 518 } 519 520 p_vcd->i_entries_nb = 0; 521 522 #define i_track entries.entry[i].i_track 523 for( i = 0 ; i < i_nb ; i++ ) 524 { 525 if( i_track <= p_input->stream.i_area_nb ) 526 { 527 p_vcd->p_entries[i_entry_index] = 528 (MSF_TO_LBA2( BCD_TO_BIN( entries.entry[i].msf.minute ), 529 BCD_TO_BIN( entries.entry[i].msf.second ), 530 BCD_TO_BIN( entries.entry[i].msf.frame ) )); 531 p_input->stream.pp_areas[i_track-1]->i_part_nb ++; 532 /* if this entry belongs to a new track */ 533 if( i_track != i_previous_track ) 534 { 535 /* i_plugin_data is used to store the first entry of the area*/ 536 p_input->stream.pp_areas[i_track-1]->i_plugin_data = 537 i_entry_index; 538 i_previous_track = i_track; 539 } 540 i_entry_index ++; 541 p_vcd->i_entries_nb ++; 542 } 543 else 544 msg_Warn( p_input, "wrong track number found in entry points" ); 545 } 546 #undef i_track 547 return 0; 548 } modules/access/vcd/vcd.h
r235dfe2 r2401b66 3 3 ***************************************************************************** 4 4 * Copyright (C) 1999-2001 VideoLAN 5 * $Id: vcd.h,v 1. 2 2002/10/15 19:56:59 gbazinExp $5 * $Id: vcd.h,v 1.3 2002/11/06 15:41:29 jobi Exp $ 6 6 * 7 7 * Author: Johan Bilien <jobi@via.ecp.fr> … … 30 30 /* size of a CD sector */ 31 31 #define CD_SECTOR_SIZE 2048 32 /* sector containing the entry points */ 33 #define VCD_ENTRIES_SECTOR 151 34 35 /***************************************************************************** 36 * Misc. Macros 37 *****************************************************************************/ 38 /* LBA = msf.frame + 75 * ( msf.second + 60 * msf.minute ) */ 39 #define MSF_TO_LBA(min, sec, frame) ((int)frame + 75 * (sec + 60 * min)) 40 /* LBA = msf.frame + 75 * ( msf.second - 2 + 60 * msf.minute ) */ 41 #define MSF_TO_LBA2(min, sec, frame) ((int)frame + 75 * (sec -2 + 60 * min)) 42 /* Converts BCD to Binary data */ 43 #define BCD_TO_BIN(i) \ 44 ((uint8_t)(0xf & (uint8_t)i)+((uint8_t)10*((uint8_t)i >> 4))) 32 45 33 46 #ifndef VCDDEV_T 34 47 typedef struct vcddev_s vcddev_t; 35 48 #endif 49 50 /***************************************************************************** 51 * structure to store minute/second/frame locations 52 *****************************************************************************/ 53 typedef struct msf_s 54 { 55 uint8_t minute; 56 uint8_t second; 57 uint8_t frame; 58 } msf_t; 59 60 61 /***************************************************************************** 62 * entries_sect structure: the sector containing entry points 63 *****************************************************************************/ 64 typedef struct entries_sect_s 65 { 66 uint8_t psz_id[8]; /* "ENTRYVCD" */ 67 uint8_t i_version; /* 0x02 VCD2.0 68 0x01 SVCD */ 69 uint8_t i_sys_prof_tag; /* 0x01 if VCD1.1 70 0x00 else */ 71 uint16_t i_entries_nb; /* entries number <= 500 */ 72 73 struct 74 { 75 uint8_t i_track; /* track number */ 76 msf_t msf; /* msf location 77 (in BCD format) */ 78 } entry[500]; 79 uint8_t zeros[36]; /* should be 0x00 */ 80 } entries_sect_t; 36 81 37 82 /***************************************************************************** … … 42 87 int ioctl_GetTracksMap ( vlc_object_t *, const vcddev_t *, int ** ); 43 88 int ioctl_ReadSector ( vlc_object_t *, const vcddev_t *, 44 int, byte_t * );89 int, byte_t * ); modules/gui/gtk/gtk_callbacks.c
r2799d36 r2401b66 3 3 ***************************************************************************** 4 4 * Copyright (C) 2000, 2001 VideoLAN 5 * $Id: gtk_callbacks.c,v 1. 3 2002/09/30 11:05:39 samExp $5 * $Id: gtk_callbacks.c,v 1.4 2002/11/06 15:41:29 jobi Exp $ 6 6 * 7 7 * Authors: Samuel Hocevar <sam@zoy.org> … … 218 218 p_intf = GtkGetIntf( button ); 219 219 220 vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock ); 220 221 i_id = p_intf->p_sys->p_input->stream.p_selected_area->i_id - 1; 221 222 … … 223 224 { 224 225 p_area = p_intf->p_sys->p_input->stream.pp_areas[i_id]; 226 vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock ); 225 227 input_ChangeArea( p_intf->p_sys->p_input, (input_area_t*)p_area ); 226 228 … … 230 232 vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock ); 231 233 GtkSetupMenus( p_intf ); 232 vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );233 }234 } 235 vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock ); 234 236 } 235 237 … … 242 244 243 245 p_intf = GtkGetIntf( button ); 246 vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock ); 244 247 i_id = p_intf->p_sys->p_input->stream.p_selected_area->i_id + 1; 245 248 … … 247 250 { 248 251 p_area = p_intf->p_sys->p_input->stream.pp_areas[i_id]; 252 vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock ); 249 253 input_ChangeArea( p_intf->p_sys->p_input, (input_area_t*)p_area ); 250 254 … … 254 258 vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock ); 255 259 GtkSetupMenus( p_intf ); 256 vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );257 }260 } 261 vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock ); 258 262 } 259 263 … … 265 269 266 270 p_intf = GtkGetIntf( button ); 271 vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock ); 267 272 p_area = p_intf->p_sys->p_input->stream.p_selected_area; 268 273 … … 270 275 { 271 276 p_area->i_part--; 277 vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock ); 272 278 input_ChangeArea( p_intf->p_sys->p_input, (input_area_t*)p_area ); 279 vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock ); 280 281 input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_PLAY ); 282 283 p_intf->p_sys->b_chapter_update = 1; 284 GtkSetupMenus( p_intf ); 285 } 286 vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock ); 287 } 288 289 290 void GtkChapterNext( GtkButton * button, gpointer user_data ) 291 { 292 intf_thread_t * p_intf; 293 input_area_t * p_area; 294 295 p_intf = GtkGetIntf( button ); 296 vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock ); 297 p_area = p_intf->p_sys->p_input->stream.p_selected_area; 298 299 if( p_area->i_part < p_area->i_part_nb ) 300 { 301 p_area->i_part++; 302 vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock ); 303 input_ChangeArea( p_intf->p_sys->p_input, (input_area_t*)p_area ); 304 vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock ); 273 305 274 306 input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_PLAY ); … … 277 309 vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock ); 278 310 GtkSetupMenus( p_intf ); 279 vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock ); 280 } 281 } 282 283 284 void GtkChapterNext( GtkButton * button, gpointer user_data ) 285 { 286 intf_thread_t * p_intf; 287 input_area_t * p_area; 288 289 p_intf = GtkGetIntf( button ); 290 p_area = p_intf->p_sys->p_input->stream.p_selected_area; 291 292 if( p_area->i_part < p_area->i_part_nb ) 293 { 294 p_area->i_part++; 295 input_ChangeArea( p_intf->p_sys->p_input, (input_area_t*)p_area ); 296 297 input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_PLAY ); 298 299 p_intf->p_sys->b_chapter_update = 1; 300 vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock ); 301 GtkSetupMenus( p_intf ); 302 vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock ); 303 } 311 } 312 vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock ); 304 313 } 305 314
