Mercurial > libdvdnav.hg
comparison searching.c @ 313:152e19b2b6a1 src
added dvdnav_describe_title_chapters(title)
author | nicodvb |
---|---|
date | Wed, 28 Nov 2007 23:19:00 +0000 |
parents | 8615160a0521 |
children | ba9c3555e92f |
comparison
equal
deleted
inserted
replaced
312:fdbfb58d2735 | 313:152e19b2b6a1 |
---|---|
28 #include <assert.h> | 28 #include <assert.h> |
29 #include <inttypes.h> | 29 #include <inttypes.h> |
30 #include <limits.h> | 30 #include <limits.h> |
31 #include <stdio.h> | 31 #include <stdio.h> |
32 #include <string.h> | 32 #include <string.h> |
33 #include <stdlib.h> | |
33 #include <sys/time.h> | 34 #include <sys/time.h> |
34 #include "dvd_types.h" | 35 #include "dvd_types.h" |
35 #include "nav_types.h" | 36 #include "nav_types.h" |
36 #include "ifo_types.h" | 37 #include "ifo_types.h" |
37 #include "remap.h" | 38 #include "remap.h" |
547 *pos = cur_sector - first_cell->first_sector; | 548 *pos = cur_sector - first_cell->first_sector; |
548 *len = last_cell->last_sector - first_cell->first_sector; | 549 *len = last_cell->last_sector - first_cell->first_sector; |
549 | 550 |
550 return DVDNAV_STATUS_OK; | 551 return DVDNAV_STATUS_OK; |
551 } | 552 } |
553 | |
554 uint32_t dvdnav_describe_title_chapters(dvdnav_t *this, int32_t title, uint64_t **times) { | |
555 int32_t retval=0; | |
556 uint16_t parts, i; | |
557 title_info_t *ptitle = NULL; | |
558 ptt_info_t *ptt = NULL; | |
559 ifo_handle_t *ifo; | |
560 pgc_t *pgc; | |
561 cell_playback_t *cell; | |
562 uint64_t length, *tmp=NULL; | |
563 | |
564 pthread_mutex_lock(&this->vm_lock); | |
565 if(!this->vm->vmgi) { | |
566 printerr("Bad VM state or missing VTSI."); | |
567 goto fail; | |
568 } | |
569 if(!this->started) { | |
570 /* don't report an error but be nice */ | |
571 vm_start(this->vm); | |
572 this->started = 1; | |
573 } | |
574 ifo = vm_get_title_ifo(this->vm, title); | |
575 if(!ifo || !ifo->vts_pgcit) { | |
576 printerr("Couldn't open IFO for chosen title, exit."); | |
577 goto fail; | |
578 } | |
579 | |
580 ptitle = &this->vm->vmgi->tt_srpt->title[title-1]; | |
581 parts = ptitle->nr_of_ptts; | |
582 ptt = ifo->vts_ptt_srpt->title[ptitle->vts_ttn-1].ptt; | |
583 | |
584 tmp = calloc(1, sizeof(uint64_t)*parts); | |
585 if(!tmp) | |
586 goto fail; | |
587 | |
588 length = 0; | |
589 for(i=0; i<parts; i++) { | |
590 uint32_t cellnr, endcellnr; | |
591 pgc = ifo->vts_pgcit->pgci_srp[ptt[i].pgcn-1].pgc; | |
592 if(ptt[i].pgn > pgc->nr_of_programs) { | |
593 printerr("WRONG part number."); | |
594 goto fail; | |
595 } | |
596 | |
597 cellnr = pgc->program_map[ptt[i].pgn-1]; | |
598 if(ptt[i].pgn < pgc->nr_of_programs) | |
599 endcellnr = pgc->program_map[ptt[i].pgn]; | |
600 else | |
601 endcellnr = 0; | |
602 | |
603 do { | |
604 cell = &pgc->cell_playback[cellnr-1]; | |
605 if(!(cell->block_type == BLOCK_TYPE_ANGLE_BLOCK && | |
606 cell->block_mode != BLOCK_MODE_FIRST_CELL | |
607 )) | |
608 { | |
609 tmp[i] = length + dvdnav_convert_time(&cell->playback_time); | |
610 length = tmp[i]; | |
611 } | |
612 cellnr++; | |
613 } while(cellnr < endcellnr); | |
614 } | |
615 vm_ifo_close(ifo); | |
616 retval = parts; | |
617 *times = tmp; | |
618 | |
619 fail: | |
620 pthread_mutex_unlock(&this->vm_lock); | |
621 if(!retval && tmp) | |
622 free(tmp); | |
623 return retval; | |
624 } |