Beispiel #1
0
play_tree_t*
play_tree_cleanup(play_tree_t* pt) {
  play_tree_t* iter, *tmp, *first;

#ifdef MP_DEBUG
  assert(pt != NULL);
#endif

  if( ! play_tree_is_valid(pt)) {
    play_tree_remove(pt,1,1);
    return NULL;
  }

  first = pt->child;

  for(iter = pt->child ; iter != NULL ; ) {
    tmp = iter;
    iter = iter->next;
    if(! play_tree_is_valid(tmp)) {
      play_tree_remove(tmp,1,1);
      if(tmp == first) first = iter;
    }
  }

  for(iter = first ; iter != NULL ; ) {
    tmp = iter;
    iter = iter->next;
    play_tree_cleanup(tmp);
  }

  return pt;

}
play_tree_t*
play_tree_parser_get_play_tree(play_tree_parser_t* p, int forced) {
    play_tree_t* tree = NULL;

#ifdef MP_DEBUG
    assert(p != NULL);
#endif


    while(play_tree_parser_get_line(p) != NULL) {
        play_tree_parser_reset(p);

        tree = parse_asx(p);
        if(tree) break;
        play_tree_parser_reset(p);

        tree = parse_pls(p);
        if(tree) break;
        play_tree_parser_reset(p);

        tree = parse_m3u(p);
        if(tree) break;
        play_tree_parser_reset(p);

        tree = parse_ref_ini(p);
        if(tree) break;
        play_tree_parser_reset(p);

        tree = parse_smil(p);
        if(tree) break;
        play_tree_parser_reset(p);

        // Here come the others formats ( textplain must stay the last one )
        if (forced)
        {
            tree = parse_textplain(p);
            if(tree) break;
        }
        break;
    }

    if(tree)
        mp_msg(MSGT_PLAYTREE,MSGL_V,"Playlist successfully parsed\n");
    else
        mp_msg(MSGT_PLAYTREE,((forced==1)?MSGL_ERR:MSGL_V),"Error while parsing playlist\n");

    if(tree)
        tree = play_tree_cleanup(tree);

    if(!tree) mp_msg(MSGT_PLAYTREE,((forced==1)?MSGL_WARN:MSGL_V),"Warning: empty playlist\n");

    return tree;
}
Beispiel #3
0
// HIGH Level API, by Fabian Franz ([email protected])
//
play_tree_iter_t* pt_iter_create(play_tree_t** ppt, m_config_t* config)
{
  play_tree_iter_t* r=NULL;
#ifdef MP_DEBUG
  assert(*ppt!=NULL);
#endif

  *ppt=play_tree_cleanup(*ppt);

  if(*ppt) {
    r = play_tree_iter_new(*ppt,config);
    if (r && play_tree_iter_step(r,0,0) != PLAY_TREE_ITER_ENTRY)
    {
      play_tree_iter_free(r);
      r = NULL;
    }
  }

  return r;
}