static void asx_parse_entryref(ASX_Parser_t* parser,char* buffer,char** _attribs) { char *href; stream_t* stream; if(parser->deep > 0) return; href = asx_get_attrib("HREF",_attribs); if(href == NULL) { asx_warning_attrib_required(parser,"ENTRYREF" ,"HREF" ); return; } stream=stream_open(href, NULL); if(!stream) { mp_msg(MSGT_PLAYTREE,MSGL_WARN,"Can't open playlist %s\n",href); free(href); return; } mp_msg(MSGT_PLAYTREE,MSGL_ERR,"Not recursively loading playlist %s\n",href); free_stream(stream); free(href); //mp_msg(MSGT_PLAYTREE,MSGL_INFO,"Need to implement entryref\n"); }
static void asx_parse_repeat(ASX_Parser_t* parser,char* buffer,char** _attribs) { char *element,*body,**attribs; int r; asx_get_attrib("COUNT",_attribs); mp_msg(MSGT_PLAYTREE,MSGL_ERR,"Ignoring repeated playlist entries\n"); while(buffer && buffer[0] != '\0') { r = asx_get_element(parser,&buffer,&element,&body,&attribs); if(r < 0) { asx_warning_body_parse_error(parser,"REPEAT"); return; } else if (r == 0) { // No more element break; } if(strcasecmp(element,"ENTRY") == 0) { asx_parse_entry(parser,body,attribs); } else if(strcasecmp(element,"ENTRYREF") == 0) { asx_parse_entryref(parser,body,attribs); } else if(strcasecmp(element,"REPEAT") == 0) { asx_parse_repeat(parser,body,attribs); } else mp_msg(MSGT_PLAYTREE,MSGL_DBG2,"Ignoring element %s\n",element); free(body); asx_free_attribs(attribs); } }
static void asx_parse_ref(ASX_Parser_t* parser, char** attribs) { char *href; href = asx_get_attrib("HREF",attribs); if(href == NULL) { asx_warning_attrib_required(parser,"REF" ,"HREF" ); return; } #if 0 // replace http my mmshttp to avoid infinite loops // disabled since some playlists for e.g. WinAMP use asx as well // "-user-agent NSPlayer/4.1.0.3856" is a possible workaround if (strncmp(href, "http://", 7) == 0) { char *newref = malloc(3 + strlen(href) + 1); strcpy(newref, "mms"); strcpy(newref + 3, href); free(href); href = newref; } #endif playlist_add_file(parser->pl, href); mp_msg(MSGT_PLAYTREE,MSGL_V,"Adding file %s to element entry\n",href); free(href); }
static void asx_parse_param(ASX_Parser_t* parser, char** attribs, play_tree_t* pt) { char *name,*val; name = asx_get_attrib("NAME",attribs); if(!name) { asx_warning_attrib_required(parser,"PARAM" ,"NAME" ); return; } val = asx_get_attrib("VALUE",attribs); if(m_config_get_option(mconfig,name) == NULL) { mp_msg(MSGT_PLAYTREE,MSGL_WARN,"Found unknown param in asx: %s",name); if(val) mp_msg(MSGT_PLAYTREE,MSGL_WARN,"=%s\n",val); else mp_msg(MSGT_PLAYTREE,MSGL_WARN,"\n"); return; } play_tree_set_param(pt,name,val); free(name); if(val) free(val); }
static void asx_parse_param(ASX_Parser_t* parser, char** attribs, play_tree_t* pt) { char *name = NULL,*val = NULL; name = asx_get_attrib("NAME",attribs); if(!name) { asx_warning_attrib_required(parser,"PARAM" ,"NAME" ); return; } val = asx_get_attrib("VALUE",attribs); if(m_config_get_option(mconfig,name) == NULL) { mp_msg(MSGT_PLAYTREE,MSGL_WARN,"Found unknown param in asx: %s",name); if(val) mp_msg(MSGT_PLAYTREE,MSGL_WARN,"=%s\n",val); else mp_msg(MSGT_PLAYTREE,MSGL_WARN,"\n"); goto err_out; } mp_msg(MSGT_PLAYTREE, MSGL_ERR, "Support for specifying parameters in playlists has been disabled.\n"); // play_tree_set_param(pt,name,val); err_out: free(name); free(val); }
static void asx_parse_ref(ASX_Parser_t* parser, char** attribs, play_tree_t* pt) { char *href; href = asx_get_attrib("HREF",attribs); if(href == NULL) { asx_warning_attrib_required(parser,"REF" ,"HREF" ); return; } play_tree_add_file(pt,href); mp_msg(MSGT_PLAYTREE,MSGL_V,"Adding file %s to element entry\n",href); free(href); }
static int asx_get_yes_no_attrib(ASX_Parser_t* parser, char* element, char* attrib,char** attribs,int def) { char* val = asx_get_attrib(attrib,attribs); char* valids[] = { "NO", "YES", NULL }; int r; if(val == NULL) return def; r = asx_attrib_to_enum(val,valids); if(r < 0) { asx_warning_attrib_invalid(parser,element,attrib,valids,val); r = def; } free(val); return r; }
static play_tree_t* asx_parse_entryref(ASX_Parser_t* parser,char* buffer,char** _attribs) { play_tree_t* pt; char *href; stream_t* stream; play_tree_parser_t* ptp; int f=DEMUXER_TYPE_UNKNOWN; if(parser->deep > 0) return NULL; href = asx_get_attrib("HREF",_attribs); if(href == NULL) { asx_warning_attrib_required(parser,"ENTRYREF" ,"HREF" ); return NULL; } stream=open_stream(href,0,&f); if(!stream) { mp_msg(MSGT_PLAYTREE,MSGL_WARN,"Can't open playlist %s\n",href); free(href); return NULL; } mp_msg(MSGT_PLAYTREE,MSGL_V,"Adding playlist %s to element entryref\n",href); ptp = play_tree_parser_new(stream,parser->deep+1); pt = play_tree_parser_get_play_tree(ptp, 1); play_tree_parser_free(ptp); free_stream(stream); free(href); //mp_msg(MSGT_PLAYTREE,MSGL_INFO,"Need to implement entryref\n"); return pt; }
static play_tree_t* asx_parse_repeat(ASX_Parser_t* parser,char* buffer,char** _attribs) { char *element,*body,**attribs; play_tree_t *repeat, *list=NULL, *entry; char* count; int r; repeat = play_tree_new(); count = asx_get_attrib("COUNT",_attribs); if(count == NULL) { mp_msg(MSGT_PLAYTREE,MSGL_DBG2,"Setting element repeat loop to infinit\n"); repeat->loop = -1; // Infinit } else { repeat->loop = atoi(count); free(count); if(repeat->loop == 0) repeat->loop = 1; mp_msg(MSGT_PLAYTREE,MSGL_DBG2,"Setting element repeat loop to %d\n",repeat->loop); } while(buffer && buffer[0] != '\0') { r = asx_get_element(parser,&buffer,&element,&body,&attribs); if(r < 0) { asx_warning_body_parse_error(parser,"REPEAT"); return NULL; } else if (r == 0) { // No more element break; } if(strcasecmp(element,"ENTRY") == 0) { entry = asx_parse_entry(parser,body,attribs); if(entry) { if(!list) list = entry; else play_tree_append_entry(list,entry); mp_msg(MSGT_PLAYTREE,MSGL_DBG2,"Adding element %s to repeat\n",element); } } else if(strcasecmp(element,"ENTRYREF") == 0) { entry = asx_parse_entryref(parser,body,attribs); if(entry) { if(!list) list = entry; else play_tree_append_entry(list,entry); mp_msg(MSGT_PLAYTREE,MSGL_DBG2,"Adding element %s to repeat\n",element); } } else if(strcasecmp(element,"REPEAT") == 0) { entry = asx_parse_repeat(parser,body,attribs); if(entry) { if(!list) list = entry; else play_tree_append_entry(list,entry); mp_msg(MSGT_PLAYTREE,MSGL_DBG2,"Adding element %s to repeat\n",element); } } else if(strcasecmp(element,"PARAM") == 0) { asx_parse_param(parser,attribs,repeat); } else mp_msg(MSGT_PLAYTREE,MSGL_DBG2,"Ignoring element %s\n",element); if(body) free(body); asx_free_attribs(attribs); } if(!list) { play_tree_free(repeat,1); return NULL; } play_tree_set_child(repeat,list); return repeat; }