NAV_CLIP* nav_set_angle(NAV_TITLE *title, NAV_CLIP *clip, unsigned angle) { int ii; uint32_t pos = 0; uint32_t time = 0; if (title == NULL) { return clip; } if (angle > 8) { // invalid angle return clip; } if (angle == title->angle) { // no change return clip; } title->angle = angle; // Find length in packets and end_pkt for each clip title->packets = 0; for (ii = 0; ii < title->pl->list_count; ii++) { MPLS_PI *pi; NAV_CLIP *cl; pi = &title->pl->play_item[ii]; cl = &title->clip_list.clip[ii]; _fill_clip(title, pi->clip, pi->connection_condition, pi->in_time, pi->out_time, pi->angle_count, cl, ii, &pos, &time); } _extrapolate_title(title); return clip; }
NAV_TITLE* nav_title_open(const char *root, const char *playlist) { NAV_TITLE *title = NULL; char *path; unsigned ii, ss, chapters = 0; uint32_t pos = 0; uint32_t time = 0; title = calloc(1, sizeof(NAV_TITLE)); if (title == NULL) { return NULL; } title->root = (char*)malloc(strlen(root) + 1); strcpy(title->root, root); strncpy(title->name, playlist, 11); title->name[10] = '\0'; path = str_printf("%s" DIR_SEP "BDMV" DIR_SEP "PLAYLIST" DIR_SEP "%s", root, playlist); title->angle_count = 0; title->angle = 0; title->pl = mpls_parse(path, 0); if (title->pl == NULL) { BD_DEBUG(DBG_NAV, "Fail: Playlist parse %s\n", path); X_FREE(title); X_FREE(path); return NULL; } X_FREE(path); // Find length in packets and end_pkt for each clip title->clip_list.count = title->pl->list_count; title->clip_list.clip = calloc(title->pl->list_count, sizeof(NAV_CLIP)); title->packets = 0; for (ii = 0; ii < title->pl->list_count; ii++) { MPLS_PI *pi; NAV_CLIP *clip; pi = &title->pl->play_item[ii]; clip = &title->clip_list.clip[ii]; _fill_clip(title, pi->clip, pi->connection_condition, pi->in_time, pi->out_time, clip, ii, &pos, &time); } // sub paths // Find length in packets and end_pkt for each clip if (title->pl->sub_count > 0) { title->sub_path_count = title->pl->sub_count; title->sub_path = calloc(title->sub_path_count, sizeof(NAV_SUB_PATH)); for (ss = 0; ss < title->sub_path_count; ss++) { NAV_SUB_PATH *sub_path = &title->sub_path[ss]; sub_path->type = title->pl->sub_path[ss].type; sub_path->clip_list.count = title->pl->sub_path[ss].sub_playitem_count; sub_path->clip_list.clip = calloc(sub_path->clip_list.count, sizeof(NAV_CLIP)); pos = time = 0; for (ii = 0; ii < sub_path->clip_list.count; ii++) { MPLS_SUB_PI *pi = &title->pl->sub_path[ss].sub_play_item[ii]; NAV_CLIP *clip = &sub_path->clip_list.clip[ii]; _fill_clip(title, pi->clip, pi->connection_condition, pi->in_time, pi->out_time, clip, ii, &pos, &time); } } } // Count the number of "entry" marks (skipping "link" marks) // This is the the number of chapters for (ii = 0; ii < title->pl->mark_count; ii++) { if (title->pl->play_mark[ii].mark_type == BD_MARK_ENTRY) { chapters++; } } title->chap_list.count = chapters; title->chap_list.mark = calloc(chapters, sizeof(NAV_MARK)); title->mark_list.count = title->pl->mark_count; title->mark_list.mark = calloc(title->pl->mark_count, sizeof(NAV_MARK)); _extrapolate_title(title); return title; }
NAV_TITLE* nav_title_open(BD_DISC *disc, const char *playlist, unsigned angle) { NAV_TITLE *title = NULL; unsigned ii, ss; uint32_t pos = 0; uint32_t time = 0; title = calloc(1, sizeof(NAV_TITLE)); if (title == NULL) { return NULL; } title->disc = disc; strncpy(title->name, playlist, 11); title->name[10] = '\0'; title->angle_count = 0; title->angle = angle; title->pl = mpls_get(disc, playlist); if (title->pl == NULL) { BD_DEBUG(DBG_NAV, "Fail: Playlist parse %s\n", playlist); X_FREE(title); return NULL; } // Find length in packets and end_pkt for each clip title->clip_list.count = title->pl->list_count; title->clip_list.clip = calloc(title->pl->list_count, sizeof(NAV_CLIP)); title->packets = 0; for (ii = 0; ii < title->pl->list_count; ii++) { MPLS_PI *pi; NAV_CLIP *clip; pi = &title->pl->play_item[ii]; clip = &title->clip_list.clip[ii]; _fill_clip(title, pi->clip, pi->connection_condition, pi->in_time, pi->out_time, pi->angle_count, clip, ii, &pos, &time); } // sub paths // Find length in packets and end_pkt for each clip if (title->pl->sub_count > 0) { title->sub_path_count = title->pl->sub_count; title->sub_path = calloc(title->sub_path_count, sizeof(NAV_SUB_PATH)); for (ss = 0; ss < title->sub_path_count; ss++) { NAV_SUB_PATH *sub_path = &title->sub_path[ss]; sub_path->type = title->pl->sub_path[ss].type; sub_path->clip_list.count = title->pl->sub_path[ss].sub_playitem_count; sub_path->clip_list.clip = calloc(sub_path->clip_list.count, sizeof(NAV_CLIP)); pos = time = 0; for (ii = 0; ii < sub_path->clip_list.count; ii++) { MPLS_SUB_PI *pi = &title->pl->sub_path[ss].sub_play_item[ii]; NAV_CLIP *clip = &sub_path->clip_list.clip[ii]; _fill_clip(title, pi->clip, pi->connection_condition, pi->in_time, pi->out_time, 0, clip, ii, &pos, &time); } } } title->chap_list.count = _pl_chapter_count(title->pl); title->chap_list.mark = calloc(title->chap_list.count, sizeof(NAV_MARK)); title->mark_list.count = title->pl->mark_count; title->mark_list.mark = calloc(title->pl->mark_count, sizeof(NAV_MARK)); _extrapolate_title(title); if (title->angle >= title->angle_count) { title->angle = 0; } return title; }