| 983 | } |
| 984 | |
| 985 | static int try_button( dvdnav_t * dvdnav, int button, hb_list_t * list_title ) |
| 986 | { |
| 987 | int result, event, len; |
| 988 | uint8_t buf[HB_DVD_READ_BUFFER_SIZE]; |
| 989 | int ii, jj; |
| 990 | int32_t cur_title = 0, title, part; |
| 991 | uint64_t longest_duration = 0; |
| 992 | int longest = -1; |
| 993 | |
| 994 | pci_t *pci = dvdnav_get_current_nav_pci( dvdnav ); |
| 995 | |
| 996 | result = dvdnav_button_select_and_activate( dvdnav, pci, button + 1 ); |
| 997 | if (result != DVDNAV_STATUS_OK) |
| 998 | { |
| 999 | hb_log("dvdnav_button_select_and_activate: %s", dvdnav_err_to_string(dvdnav)); |
| 1000 | } |
| 1001 | |
| 1002 | result = dvdnav_current_title_info( dvdnav, &title, &part ); |
| 1003 | if (result != DVDNAV_STATUS_OK) |
| 1004 | hb_log("dvdnav cur title info: %s", dvdnav_err_to_string(dvdnav)); |
| 1005 | |
| 1006 | cur_title = title; |
| 1007 | |
| 1008 | for (jj = 0; jj < 10; jj++) |
| 1009 | { |
| 1010 | for (ii = 0; ii < 2000; ii++) |
| 1011 | { |
| 1012 | result = dvdnav_get_next_block( dvdnav, buf, &event, &len ); |
| 1013 | if ( result == DVDNAV_STATUS_ERR ) |
| 1014 | { |
| 1015 | hb_error("dvdnav: Read Error, %s", dvdnav_err_to_string(dvdnav)); |
| 1016 | goto done; |
| 1017 | } |
| 1018 | switch ( event ) |
| 1019 | { |
| 1020 | case DVDNAV_BLOCK_OK: |
| 1021 | break; |
| 1022 | |
| 1023 | case DVDNAV_CELL_CHANGE: |
| 1024 | { |
| 1025 | result = dvdnav_current_title_info( dvdnav, &title, &part ); |
| 1026 | if (result != DVDNAV_STATUS_OK) |
| 1027 | hb_log("dvdnav title info: %s", dvdnav_err_to_string(dvdnav)); |
| 1028 | |
| 1029 | cur_title = title; |
| 1030 | // Note, some "fake" titles have long advertised durations |
| 1031 | // but then jump to the real title early in playback. |
| 1032 | // So keep reading after finding a long title to detect |
| 1033 | // such cases. |
| 1034 | } break; |
| 1035 | |
| 1036 | case DVDNAV_STILL_FRAME: |
| 1037 | { |
| 1038 | dvdnav_still_event_t *event; |
| 1039 | event = (dvdnav_still_event_t*)buf; |
| 1040 | dvdnav_still_skip( dvdnav ); |
| 1041 | if ( event->length == 255 ) |
| 1042 | { |
no test coverage detected