示例#1
0
static MPLS_PL*
_process_file(char *name, MPLS_PL *pl_list[], int pl_count)
{
    MPLS_PL *pl;

    pl = mpls_parse(name);
    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 %4u:%02u",
                    basename(name),
                    pl->list_count,
                    _pl_duration(pl) / (45000 * 60),
                    (_pl_duration(pl) / 45000) % 60);
    } 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;
}
示例#2
0
void ldp_nexthop_delete(ldp_global *g, ldp_nexthop *nh)
{
  fprintf(stderr, "nexthop delete: %p\n", nh);
  MPLS_REFCNT_ASSERT(nh, 0);
  _ldp_global_del_nexthop(g, nh);
  mpls_free(nh);
}
示例#3
0
void nav_title_close(NAV_TITLE *title)
{
    unsigned ii, ss;

    if (!title)
        return;

    if (title->sub_path) {
        for (ss = 0; ss < title->sub_path_count; ss++) {
            if (title->sub_path[ss].clip_list.clip) {
                for (ii = 0; ii < title->sub_path[ss].clip_list.count; ii++) {
                    clpi_free(title->sub_path[ss].clip_list.clip[ii].cl);
                }
                X_FREE(title->sub_path[ss].clip_list.clip);
            }
        }
        X_FREE(title->sub_path);
    }

    if (title->clip_list.clip) {
        for (ii = 0; ii < title->clip_list.count; ii++) {
            clpi_free(title->clip_list.clip[ii].cl);
        }
        X_FREE(title->clip_list.clip);
    }

    mpls_free(title->pl);
    X_FREE(title->chap_list.mark);
    X_FREE(title->mark_list.mark);
    X_FREE(title);
}
void mpls_socket_close(mpls_socket_mgr_handle handle, mpls_socket_handle socket)
{
	if(socket) {
		close(socket->fd);
		mpls_free(socket);
	}
}
示例#5
0
void ldp_fec_delete(ldp_global *g, ldp_fec * fec)
{
  fprintf(stderr, "fec delete: %08x/%d\n", fec->info.u.prefix.network.u.ipv4,
    fec->info.u.prefix.length);
  ldp_fec_remove(g, &fec->info);
  _ldp_global_del_fec(g, fec);
  mpls_free(fec);
}
示例#6
0
void ldp_attr_delete(ldp_global *g, ldp_attr * a)
{
  LDP_PRINT(g->user_data, "attr delete: %p", a);
  MPLS_REFCNT_ASSERT(a, 0);
  MPLS_ASSERT(a->in_tree == MPLS_BOOL_FALSE);
  _ldp_global_del_attr(g, a);
  mpls_free(a);
}
示例#7
0
mpls_return_enum mpls_tree_remove(mpls_tree_handle tree, uint32_t key, int length, void **info)
{
	struct mpls_tree_node *node;

	node = mpls_tree_find(tree, key, length);
	if(!node)
		return MPLS_FAILURE;
	*info = node->info;
	RB_REMOVE(mpls_tree, tree, node);
	mpls_free(node);
	
	return MPLS_SUCCESS;
}
示例#8
0
mpls_socket_handle mpls_socket_create_udp(mpls_socket_mgr_handle handle)
{
  struct mpls_socket *sock;
  u_char one = 1;

  sock = mpls_malloc(sizeof(struct mpls_socket));
  memset(sock,0,sizeof(struct mpls_socket));
  sock->fd = socket(AF_INET, SOCK_DGRAM, 0);
  MPLS_ASSERT(sock->fd > -1);
  if (setsockopt(sock->fd,SOL_IP,IP_PKTINFO,&one,sizeof(one)) < 0) {
    perror("PKTINFO");
    mpls_free(sock);
    return NULL;
  }
  return sock;
}
mpls_socket_handle mpls_socket_tcp_accept(mpls_socket_mgr_handle handle, mpls_socket_handle socket, mpls_dest *from)
{
	struct mpls_socket *sock;
	struct sockaddr addr;
	unsigned int size;

	sock = mpls_malloc(sizeof(struct mpls_socket));
	size = sizeof(addr);
	if((sock->fd = accept(socket->fd, &addr, &size)) < 0) {
		mpls_free(sock);
		return NULL;
	}

	_sockaddr2mpls_dest(&addr, from);

	return sock;
}
示例#10
0
mpls_socket_handle mpls_socket_create_raw(mpls_socket_mgr_handle handle, int proto)
{
	struct mpls_socket *sock;
	u_char opt;
	size_t optlen;

	sock = mpls_malloc(sizeof(struct mpls_socket));
	memset(sock, 0, sizeof(struct mpls_socket));
	sock->fd = socket(AF_INET, SOCK_RAW, proto);
	MPLS_ASSERT(sock->fd > -1);

	opt = 1;
	optlen = sizeof(opt);
	if(setsockopt(sock->fd, IPPROTO_IP, IP_RECVDSTADDR, &opt, optlen) < 0) {
		perror("PKTINFO");
		mpls_free(sock);
		return NULL;
	}

	return sock;
}
示例#11
0
mpls_socket_handle mpls_socket_create_udp(mpls_socket_mgr_handle handle)
{
	struct mpls_socket *sock;
	ssize_t opt;
	size_t optlen;

	sock = mpls_malloc(sizeof(struct mpls_socket));
	if(!sock)
		return NULL;

	memset(sock, 0, sizeof(struct mpls_socket));
	sock->fd = socket(AF_INET, SOCK_DGRAM, 0);
	MPLS_ASSERT(sock->fd > -1);

	opt = 1;
	optlen = sizeof(opt);
	if(setsockopt(sock->fd, IPPROTO_IP, IP_RECVIF, &opt, optlen) < 0) {
		perror("IP_RECVIF");
		mpls_free(sock);
		return NULL;
	}

	return sock;
}
示例#12
0
int
main(int argc, char *argv[])
{
    MPLS_PL *pl;
    int opt;
    int ii, pl_ii;
    MPLS_PL *pl_list[1000];
    struct stat st;
    char *path = NULL;
    DIR *dir = NULL;

    do {
        opt = getopt(argc, argv, OPTS);
        switch (opt) {
            case -1: 
                break;

            case 'v':
                verbose = 1;
                break;

            case 'l':
                clip_list = 1;
                break;

            case 'i':
                playlist_info = 1;
                break;

            case 'c':
                chapter_marks = 1;
                break;

            case 'p':
                sub_paths = 1;
                break;

            case 'd':
                dups = 1;
                break;

            case 'r':
                repeats = atoi(optarg);
                break;

            case 'f':
                repeats = 2;
                dups = 1;
                seconds = 900;
                break;

            case 's':
                seconds = atoi(optarg);
                break;

            default:
                _usage(argv[0]);
                break;
        }
    } while (opt != -1);

    if (optind >= argc) {
        _usage(argv[0]);
    }

    for (pl_ii = 0, ii = optind; pl_ii < 1000 && ii < argc; ii++) {

        if (stat(argv[ii], &st)) {
            continue;
        }
        dir = NULL;
        if (S_ISDIR(st.st_mode)) {

            char *main_title = NULL;

            printf("Directory: %s:\n", argv[ii]);
            path = str_printf("%s/BDMV/PLAYLIST", argv[ii]);
            if (path == NULL) {
                fprintf(stderr, "Failed to find playlist path: %s\n", argv[ii]);
                continue;
            }
            dir = opendir(path);
            if (dir == NULL) {
                fprintf(stderr, "Failed to open dir: %s\n", path);
                free(path);
                continue;
            }
            main_title = nav_find_main_title(argv[ii]);
            if (main_title != NULL) {
                printf("Main Title: %s\n", main_title);
                free(main_title);
            } else {
                fprintf(stderr, "Main title search failed\n");
            }
        }
        if (dir != NULL) {
            char **dirlist = calloc(10001, sizeof(char*));
            struct dirent *ent;
            int jj = 0;
            for (ent = readdir(dir); ent != NULL; ent = readdir(dir)) {
                if (ent->d_name != NULL) {
                    dirlist[jj] = (char*)malloc(strlen(ent->d_name) + 1);
                    strcpy(dirlist[jj], ent->d_name);
                    jj++;
                }
            }
            qsort(dirlist, jj, sizeof(char*), _qsort_str_cmp);
            for (jj = 0; dirlist[jj] != NULL; jj++) {
                char *name = NULL;
                name = str_printf("%s/%s", path, dirlist[jj]);
                free(dirlist[jj]);
                if (stat(name, &st)) {
                    free(name);
                    continue;
                }
                if (!S_ISREG(st.st_mode)) {
                    free(name);
                    continue;
                }
                pl = _process_file(name, pl_list, pl_ii);
                free(name);
                if (pl != NULL) {
                    pl_list[pl_ii++] = pl;
                }
            } while (ent != NULL);
            free(dirlist);
            free(path);
        } else {
            pl = _process_file(argv[ii], pl_list, pl_ii);
            if (pl != NULL) {
                pl_list[pl_ii++] = pl;
            }
        }
    }
    // Cleanup
    for (ii = 0; ii < pl_ii; ii++) {
        mpls_free(pl_list[ii]);
    }
    return 0;
}
示例#13
0
int
main(int argc, char *argv[])
{
    MPLS_PL *pl;
    int opt;
    int ii, pl_ii;
    MPLS_PL *pl_list[1000];
    struct stat st;
    str_t path = {0,};
    DIR *dir = NULL;

    do {
        opt = getopt(argc, argv, OPTS);
        switch (opt) {
            case -1: 
                break;

            case 'v':
                verbose = 1;
                break;

            case 'l':
                clip_list = 1;
                break;

            case 'i':
                playlist_info = 1;
                break;

            case 'c':
                chapter_marks = 1;
                break;

            case 'd':
                dups = 1;
                break;

            case 'r':
                repeats = atoi(optarg);
                break;

            case 'f':
                repeats = 2;
                dups = 1;
                seconds = 120;
                break;

            case 's':
                seconds = atoi(optarg);
                break;

            default:
                _usage(argv[0]);
                break;
        }
    } while (opt != -1);

    if (optind >= argc) {
        _usage(argv[0]);
    }

    for (pl_ii = 0, ii = optind; pl_ii < 1000 && ii < argc; ii++) {
        if (stat(argv[ii], &st)) {
            continue;
        }
        dir = NULL;
        if (S_ISDIR(st.st_mode)) {
            printf("Directory: %s:\n", argv[ii]);
            _make_path(&path, argv[ii], "PLAYLIST");
            if (path.buf == NULL) {
                fprintf(stderr, "Failed to find playlist path: %s\n", argv[ii]);
                continue;
            }
            dir = opendir(path.buf);
            if (dir == NULL) {
                fprintf(stderr, "Failed to open dir: %s\n", path.buf);
                str_free(&path);
                continue;
            }
        }
        if (dir != NULL) {
            char **dirlist = calloc(10001, sizeof(char*));
            struct dirent *ent;
            int jj = 0;
            for (ent = readdir(dir); ent != NULL; ent = readdir(dir)) {
                if (ent->d_name != NULL) {
                    dirlist[jj++] = strdup(ent->d_name);
                }
            }
            qsort(dirlist, jj, sizeof(char*), _qsort_str_cmp);
            for (jj = 0; dirlist[jj] != NULL; jj++) {
                str_t name = {0,};
                str_printf(&name, "%s/%s", path.buf, dirlist[jj]);
                free(dirlist[jj]);
                if (stat(name.buf, &st)) {
                    str_free(&name);
                    continue;
                }
                if (!S_ISREG(st.st_mode)) {
                    str_free(&name);
                    continue;
                }
                pl = _process_file(name.buf, pl_list, pl_ii);
                str_free(&name);
                if (pl != NULL) {
                    pl_list[pl_ii++] = pl;
                }
            } while (ent != NULL);
            free(dirlist);
            str_free(&path);
        } else {
            pl = _process_file(argv[ii], pl_list, pl_ii);
            if (pl != NULL) {
                pl_list[pl_ii++] = pl;
            }
        }
    }
    // Cleanup
    for (ii = 0; ii < pl_ii; ii++) {
        mpls_free(&pl_list[ii]);
    }
    return 0;
}
示例#14
0
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;
}
示例#15
0
void ldp_mesg_delete(ldp_mesg * msg)
{
    MPLS_ASSERT(msg);
    mpls_free(msg);
}
示例#16
0
void mpls_lock_delete(mpls_lock_handle handle)
{
	mpls_free(handle);
}
示例#17
0
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;
}
示例#18
0
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;
    }
}
static MPLS_PL * bd_title_filter(BLURAY *bd, uint32_t count, BLURAY_TITLE_MPLS_ID *title, int is_dir, char *filepath, int *title_id, int *mpls_id)
{
	MPLS_PL *pl = NULL, *pl_tmp = NULL;
	MPLS_PI *pi = NULL, *pi_tmp = NULL;
	int chapter_count, chapter_count_tmp;
	char *path = NULL;
	int ii;

	for (ii = 0; ii < count; ii++)
	{
		if (is_dir == 1) {
			path = str_printf("%s/BDMV/PLAYLIST/%05d.mpls", filepath, title[ii].mpls_id);
		} else {
			path = str_printf("/BDMV/PLAYLIST/%05d.mpls", title[ii].mpls_id);
		}
		if (pl == NULL)
		{
			pl = mpls_parse(path, 0, bd_get_udfdata(bd));
			if (pl != NULL)
			{
				pi = &pl->play_item[0];
				*title_id = (int)title[ii].title_id;
				*mpls_id = (int)title[ii].mpls_id;
				chapter_count = bd_get_chapters(pl);
			}
		} else {
			pl_tmp = mpls_parse(path, 0, bd_get_udfdata(bd));
			if (pl_tmp != NULL)
			{
				pi_tmp = &pl_tmp->play_item[0];
				chapter_count_tmp = bd_get_chapters(pl_tmp); 
				mp_msg("filter playlist 1: c: %d, v: %d, a: %d, s: %d, d: %d\n", chapter_count,
						pi->stn.num_video, pi->stn.num_audio, pi->stn.num_pg, _pl_duration(pl)/45000);
				mp_msg("filter playlist 2: c: %d, v: %d, a: %d, s: %d, d: %d\n", chapter_count_tmp,
						pi_tmp->stn.num_video, pi_tmp->stn.num_audio, pi_tmp->stn.num_pg, _pl_duration(pl_tmp)/45000);
				if ( ((pi_tmp->stn.num_pg > 0) && (pi->stn.num_pg > pi_tmp->stn.num_pg)) && \
						((pi_tmp->stn.num_audio > 0) && (pi_tmp->stn.num_audio >= pi->stn.num_audio - 1)) && \
						(chapter_count_tmp >= chapter_count)
						)
				{
					mpls_free(pl);
					pl = pl_tmp;
					pi = &pl->play_item[0];
					chapter_count = chapter_count_tmp;
					*title_id = (int)title[ii].title_id;
					*mpls_id = (int)title[ii].mpls_id;
				} else {
#if 1	//Barry 2011-07-13 fix mantis: 5192
					if ((_pl_duration(pl)/45000) > 60000)
					{
						mpls_free(pl);
						pl = pl_tmp;
						pi = &pl->play_item[0];
						chapter_count = chapter_count_tmp;
						*title_id = (int)title[ii].title_id;
						*mpls_id = (int)title[ii].mpls_id;
					}
					else
#endif
						mpls_free(pl_tmp);
				}
			}
		}
		if (path != NULL) free(path);
	}

	return pl;
}
示例#20
0
void ldp_resource_delete(ldp_resource * r)
{
  // LDP_PRINT(g->user_data,"resource delete\n");
  MPLS_REFCNT_ASSERT(r, 0);
  mpls_free(r);
}
int BD_Parser(FILE *fp, FileInfo *finfo, int is_dir)
{
	int nRet = 0;
	int ii;
	int title_guess, title_count;
	uint64_t max_duration = 0;
	uint64_t max_duration2 = 0;
	MPLS_PL * pl = NULL, * pl2 = NULL, * def_pl;
	BLURAY  *bd = NULL;
	parse_priv * par_priv = NULL;
	BLURAY_TITLE_MAX_DUR *title_max = NULL;
	int title_id[2] = {-1};
	int mpls_id[2] = {-1};

	mp_msg("BD_Parser\n");
	if (finfo->priv != NULL)
	{
		par_priv = (parse_priv *)finfo->priv;
		bd = par_priv->bd;
		title_count = par_priv->title_num;
		free(par_priv);
		finfo->priv = NULL;
	} else {
		bd = bd_open(finfo->filepath, NULL);
		if (bd)
			title_count = bd_get_titles(bd, TITLES_RELEVANT);
	}
	//goto error_end;

	if (bd)
	{
		title_max = bd_get_title_max2_dur(bd);
		if (title_max != NULL)
		{
			pl = bd_title_filter(bd, title_max->dur_first_count, title_max->dur_first, is_dir, finfo->filepath, &title_id[0], &mpls_id[0]);
			if (title_max->dur_second_count > 0)
			{
				pl2 = bd_title_filter(bd, title_max->dur_second_count, title_max->dur_second, is_dir, finfo->filepath, &title_id[1], &mpls_id[1]);
			}
			mp_msg("title_id: %d %d, mpls_id: %d %d\n", title_id[0], title_id[1],
					mpls_id[0], mpls_id[1]);
			title_guess = title_id[0];

			bd_free_title_max2_dur(title_max);
		}

		def_pl = pl;
		//if (pl2 != NULL)
		if (pl2 != NULL && pl != NULL)
		{
			MPLS_PI *pi, *pi2;
			pi = &pl->play_item[0];
			pi2 = &pl2->play_item[0];
			mp_msg("playlist 1: c: %d, v: %d, a: %d, s: %d, d: %d\n", bd_get_chapters(pl),
					pi->stn.num_video, pi->stn.num_audio, pi->stn.num_pg, _pl_duration(pl)/45000);
			mp_msg("playlist 2: c: %d, v: %d, a: %d, s: %d, d: %d\n", bd_get_chapters(pl2),
					pi2->stn.num_video, pi2->stn.num_audio, pi2->stn.num_pg, _pl_duration(pl2)/45000);
			if ((bd_get_chapters(pl) < bd_get_chapters(pl2)) &&
					(pi->stn.num_audio <= pi2->stn.num_audio) )
			{
				// playlist 2 have more chapters and audio use it.
				def_pl = pl2;
				title_guess = title_id[1];
			} else {
				if ((pl->list_count > 0) && (pl2->list_count > 0))
				{
					if ( (pi2->stn.num_audio >= pi->stn.num_audio) &&
							(pi2->stn.num_pg > pi->stn.num_pg) &&
							(bd_get_chapters(pl2) >= bd_get_chapters(pl)) )	//Barry 2011-07-29 fix mantis: 5605
					{
						def_pl = pl2;
						title_guess = title_id[1];
					}
#if 1	//Barry 2011-07-13 fix mantis: 5192
					if ((_pl_duration(pl)/45000) > 60000)
					{
						def_pl = pl2;
						title_guess = title_id[1];
					}
#endif
				}
			}
		}
		else if (pl2 != NULL && pl == NULL)
		{
			// playlist 2 have more chapters and audio use it.
			def_pl = pl2;
			title_guess = title_id[1];
			//printf("***********  Switch to playlist 2 **********\n");
		}

		nRet = set_mpls_info(def_pl, finfo);
		if (nRet == 1)
		{
			MPLS_PI *pi;
			int chapters = bd_get_chapters(def_pl);
			((bd_priv_t *)finfo->priv)->chapter_num = chapters;
			((bd_priv_t *)finfo->priv)->title = title_guess;
			pi = &def_pl->play_item[0];
			if (pi != NULL)
				((bd_priv_t *)finfo->priv)->file_id = atoi(pi->clip[0].clip_id);
		}

error_end:
		if (pl != NULL) mpls_free(pl);
		if (pl2 != NULL) mpls_free(pl2);
		if (bd != NULL) bd_close(bd);
	}

	return nRet;
}
示例#22
0
void ldp_adj_delete(ldp_adj * a)
{
    LDP_PRINT(NULL,"adj delete %p", a);
    MPLS_REFCNT_ASSERT(a, 0);
    mpls_free(a);
}
示例#23
0
void ldp_inlabel_delete(ldp_inlabel * i)
{
  LDP_PRINT(g->user_data,"inlabel delete\n");
  MPLS_REFCNT_ASSERT(i, 0);
  mpls_free(i);
}