static MPLS_PL* _process_file(char *name, MPLS_PL *pl_list[], int pl_count) { MPLS_PL *pl; pl = bd_read_mpls(name); if (pl == NULL) { fprintf(stderr, "Parse failed: %s\n", name); return NULL; } if (seconds) { if (!_filter_short(pl, seconds)) { bd_free_mpls(pl); return NULL; } } if (repeats) { if (!_filter_repeats(pl, repeats)) { bd_free_mpls(pl); return NULL; } } if (dups) { if (!_filter_dup(pl_list, pl_count, pl)) { bd_free_mpls(pl); return NULL; } } if (verbose) { indent_printf(0, "%s -- Num Clips: %3d , Duration: minutes %4u:%02u", basename(name), pl->list_count, _pl_duration(pl) / (45000 * 60), (_pl_duration(pl) / 45000) % 60); _show_ai(pl, 1); } else { indent_printf(0, "%s -- Duration: minutes %4u:%02u", basename(name), _pl_duration(pl) / (45000 * 60), (_pl_duration(pl) / 45000) % 60); } if (playlist_info) { _show_details(pl, 1); } if (chapter_marks) { _show_marks(pl, 1); } if (pip_metadata) { _show_pip_metadata(pl, 1); } if (clip_list) { _show_clip_list(pl, 1); } if (sub_paths) { _show_sub_paths(pl, 1); _show_sub_paths_ss(pl, 1); } return pl; }
static MPLS_PL* _process_file(char *name, MPLS_PL *pl_list[], int pl_count) { MPLS_PL *pl; pl = calloc(1, sizeof(MPLS_PL)); pl = mpls_parse(name, verbose); if (pl == NULL) { fprintf(stderr, "Parse failed: %s\n", name); return NULL; } if (seconds) { if (!_filter_short(pl, seconds)) { mpls_free(&pl); return NULL; } } if (repeats) { if (!_filter_repeats(pl, repeats)) { mpls_free(&pl); return NULL; } } if (dups) { if (!_filter_dup(pl_list, pl_count, pl)) { mpls_free(&pl); return NULL; } } if (verbose) { indent_printf(0, "%s -- Num Clips: %3d , Duration: minutes %4lu:%02lu", basename(name), pl->list_count, pl->duration / (45000 * 60), (pl->duration / 45000) % 60); } else { indent_printf(0, "%s -- Duration: minutes %4lu:%02lu", basename(name), pl->duration / (45000 * 60), (pl->duration / 45000) % 60); } if (playlist_info) { _show_details(pl, 1); } if (chapter_marks) { _show_marks(pl, 1); } if (clip_list) { _show_clip_list(pl, 1); } return pl; }
char* nav_find_main_title(const char *root) { BD_DIR_H *dir; BD_DIRENT ent; char *path = NULL; MPLS_PL **pl_list = NULL; MPLS_PL **tmp = NULL; MPLS_PL *pl = NULL; unsigned count, ii, jj, pl_list_size = 0; int res; char longest[11]; BD_DEBUG(DBG_NAV, "Root: %s:\n", root); path = str_printf("%s" DIR_SEP "BDMV" DIR_SEP "PLAYLIST", root); dir = dir_open(path); if (dir == NULL) { fprintf(stderr, "Failed to open dir: %s\n", path); X_FREE(path); return NULL; } X_FREE(path); ii = jj = 0; for (res = dir_read(dir, &ent); !res; res = dir_read(dir, &ent)) { if (ent.d_name[0] == '.') { continue; } path = str_printf("%s" DIR_SEP "BDMV" DIR_SEP "PLAYLIST" DIR_SEP "%s", root, ent.d_name); if (ii >= pl_list_size) { pl_list_size += 100; tmp = realloc(pl_list, pl_list_size * sizeof(MPLS_PL*)); if (tmp == NULL) { X_FREE(path); break; } pl_list = tmp; } pl = mpls_parse(path, 0); X_FREE(path); if (pl != NULL) { if (_filter_dup(pl_list, ii, pl) && _filter_repeats(pl, 2)) { pl_list[ii] = pl; if (_pl_duration(pl_list[ii]) >= _pl_duration(pl_list[jj])) { strncpy(longest, ent.d_name, 11); longest[10] = '\0'; jj = ii; } ii++; } else { mpls_free(pl); } } } dir_close(dir); count = ii; for (ii = 0; ii < count; ii++) { mpls_free(pl_list[ii]); } if (count > 0) { char *str = (char*)malloc(strlen(longest) + 1); strcpy(str, longest); return str; } else { return NULL; } }
NAV_TITLE_LIST* nav_get_title_list(const char *root, uint32_t flags) { BD_DIR_H *dir; BD_DIRENT ent; char *path = NULL; MPLS_PL **pl_list = NULL; MPLS_PL *pl = NULL; unsigned int ii, pl_list_size = 0; int res; NAV_TITLE_LIST *title_list; unsigned int title_info_alloc = 100; title_list = calloc(1, sizeof(NAV_TITLE_LIST)); title_list->title_info = calloc(title_info_alloc, sizeof(NAV_TITLE_INFO)); BD_DEBUG(DBG_NAV, "Root: %s:\n", root); path = str_printf("%s" DIR_SEP "BDMV" DIR_SEP "PLAYLIST", root); dir = dir_open(path); if (dir == NULL) { BD_DEBUG(DBG_NAV, "Failed to open dir: %s\n", path); X_FREE(path); X_FREE(title_list); return NULL; } X_FREE(path); ii = 0; for (res = dir_read(dir, &ent); !res; res = dir_read(dir, &ent)) { if (ent.d_name[0] == '.') { continue; } path = str_printf("%s" DIR_SEP "BDMV" DIR_SEP "PLAYLIST" DIR_SEP "%s", root, ent.d_name); if (ii >= pl_list_size) { MPLS_PL **tmp = NULL; pl_list_size += 100; tmp = realloc(pl_list, pl_list_size * sizeof(MPLS_PL*)); if (tmp == NULL) { X_FREE(path); break; } pl_list = tmp; } pl = mpls_parse(path, 0); X_FREE(path); if (pl != NULL) { if ((flags & TITLES_FILTER_DUP_TITLE) && !_filter_dup(pl_list, ii, pl)) { mpls_free(pl); continue; } if ((flags & TITLES_FILTER_DUP_CLIP) && !_filter_repeats(pl, 2)) { mpls_free(pl); continue; } if (ii >= title_info_alloc) { NAV_TITLE_INFO *tmp = NULL; title_info_alloc += 100; tmp = realloc(title_list->title_info, title_info_alloc * sizeof(NAV_TITLE_INFO)); if (tmp == NULL) { break; } title_list->title_info = tmp; } pl_list[ii] = pl; strncpy(title_list->title_info[ii].name, ent.d_name, 11); title_list->title_info[ii].name[10] = '\0'; title_list->title_info[ii].ref = ii; title_list->title_info[ii].mpls_id = atoi(ent.d_name); title_list->title_info[ii].duration = _pl_duration(pl_list[ii]); ii++; } } dir_close(dir); title_list->count = ii; for (ii = 0; ii < title_list->count; ii++) { mpls_free(pl_list[ii]); } return title_list; }
NAV_TITLE_LIST* nav_get_title_list(BD_DISC *disc, uint32_t flags, uint32_t min_title_length) { BD_DIR_H *dir; BD_DIRENT ent; MPLS_PL **pl_list = NULL; MPLS_PL *pl = NULL; unsigned int ii, pl_list_size = 0; int res; NAV_TITLE_LIST *title_list; unsigned int title_info_alloc = 100; dir = disc_open_dir(disc, "BDMV" DIR_SEP "PLAYLIST"); if (dir == NULL) { return NULL; } title_list = calloc(1, sizeof(NAV_TITLE_LIST)); title_list->title_info = calloc(title_info_alloc, sizeof(NAV_TITLE_INFO)); ii = 0; for (res = dir_read(dir, &ent); !res; res = dir_read(dir, &ent)) { if (ent.d_name[0] == '.') { continue; } if (ii >= pl_list_size) { MPLS_PL **tmp = NULL; pl_list_size += 100; tmp = realloc(pl_list, pl_list_size * sizeof(MPLS_PL*)); if (tmp == NULL) { break; } pl_list = tmp; } pl = mpls_get(disc, ent.d_name); if (pl != NULL) { if ((flags & TITLES_FILTER_DUP_TITLE) && !_filter_dup(pl_list, ii, pl)) { mpls_free(pl); continue; } if ((flags & TITLES_FILTER_DUP_CLIP) && !_filter_repeats(pl, 2)) { mpls_free(pl); continue; } if (min_title_length > 0 && _pl_duration(pl) < min_title_length*45000) { mpls_free(pl); continue; } if (ii >= title_info_alloc) { NAV_TITLE_INFO *tmp = NULL; title_info_alloc += 100; tmp = realloc(title_list->title_info, title_info_alloc * sizeof(NAV_TITLE_INFO)); if (tmp == NULL) { break; } title_list->title_info = tmp; } pl_list[ii] = pl; /* main title guessing */ if (_filter_dup(pl_list, ii, pl) && _filter_repeats(pl, 2)) { if (_pl_guess_main_title(pl_list[ii], pl_list[title_list->main_title_idx]) <= 0) { title_list->main_title_idx = ii; } } strncpy(title_list->title_info[ii].name, ent.d_name, 11); title_list->title_info[ii].name[10] = '\0'; title_list->title_info[ii].ref = ii; title_list->title_info[ii].mpls_id = atoi(ent.d_name); title_list->title_info[ii].duration = _pl_duration(pl_list[ii]); ii++; } } dir_close(dir); title_list->count = ii; for (ii = 0; ii < title_list->count; ii++) { mpls_free(pl_list[ii]); } X_FREE(pl_list); return title_list; }