* hb_bd_init *********************************************************************** * **********************************************************************/
| 40 | * |
| 41 | **********************************************************************/ |
| 42 | hb_bd_t * hb_bd_init( hb_handle_t *h, const char * path, int keep_duplicate_titles ) |
| 43 | { |
| 44 | hb_bd_t * d; |
| 45 | int ii; |
| 46 | |
| 47 | d = calloc( sizeof( hb_bd_t ), 1 ); |
| 48 | d->h = h; |
| 49 | d->keep_duplicate_titles = keep_duplicate_titles; |
| 50 | |
| 51 | /* Open device */ |
| 52 | d->bd = bd_open( path, NULL ); |
| 53 | if( d->bd == NULL ) |
| 54 | { |
| 55 | /* |
| 56 | * Not an error, may be a stream - which we'll try in a moment. |
| 57 | */ |
| 58 | hb_log( "bd: not a bd - trying as a stream/file instead" ); |
| 59 | goto fail; |
| 60 | } |
| 61 | |
| 62 | uint8_t flags = TITLES_FILTER_DUP_CLIP; |
| 63 | if (!keep_duplicate_titles) |
| 64 | { |
| 65 | flags |= TITLES_FILTER_DUP_TITLE; |
| 66 | } |
| 67 | d->title_count = bd_get_titles( d->bd, flags, 0 ); |
| 68 | if ( d->title_count == 0 ) |
| 69 | { |
| 70 | hb_log( "bd: not a bd - trying as a stream/file instead" ); |
| 71 | goto fail; |
| 72 | } |
| 73 | d->title_info = calloc( sizeof( BLURAY_TITLE_INFO* ) , d->title_count ); |
| 74 | for ( ii = 0; ii < d->title_count; ii++ ) |
| 75 | { |
| 76 | d->title_info[ii] = bd_get_title_info( d->bd, ii, 0 ); |
| 77 | } |
| 78 | qsort(d->title_info, d->title_count, sizeof( BLURAY_TITLE_INFO* ), title_info_compare_mpls ); |
| 79 | d->disc_info = bd_get_disc_info(d->bd); |
| 80 | d->path = strdup( path ); |
| 81 | |
| 82 | return d; |
| 83 | |
| 84 | fail: |
| 85 | if( d->bd ) bd_close( d->bd ); |
| 86 | free( d ); |
| 87 | return NULL; |
| 88 | } |
| 89 | |
| 90 | /*********************************************************************** |
| 91 | * hb_bd_title_count |
no test coverage detected