static int Demux( demux_t *p_demux ) { input_item_t *p_input = input_GetItem( p_demux->p_input ); input_item_node_t *p_node = input_item_node_Create( p_input ); if( vlc_stream_ReadDir( p_demux->s, p_node ) ) { msg_Warn( p_demux, "unable to read directory" ); input_item_node_Delete( p_node ); return VLC_EGENERIC; } if (es_out_Control(p_demux->out, ES_OUT_POST_SUBNODE, p_node)) input_item_node_Delete(p_node); return VLC_SUCCESS; }
static void vlc_media_tree_ClearChildren(input_item_node_t *root) { for (int i = 0; i < root->i_children; ++i) input_item_node_Delete(root->pp_children[i]); free(root->pp_children); root->pp_children = NULL; root->i_children = 0; }
static int Demux( demux_t *p_demux ) { xml_reader_t *p_xml_reader = NULL; const char *node; int i_ret = -1; input_item_t *p_current_input = GetCurrentItem(p_demux); input_item_node_t *p_input_node = NULL; p_xml_reader = xml_ReaderCreate( p_demux, p_demux->s ); if( !p_xml_reader ) goto error; /* check root node */ if( xml_ReaderNextNode( p_xml_reader, &node ) != XML_READER_STARTELEM ) { msg_Err( p_demux, "invalid file (no root node)" ); goto error; } if( strcmp( node, "genrelist" ) && strcmp( node, "stationlist" ) ) { msg_Err( p_demux, "invalid root node <%s>", node ); goto error; } p_input_node = input_item_node_Create( p_current_input ); if( !strcmp( node, "genrelist" ) ) { /* we're reading a genre list */ if( DemuxGenre( p_demux, p_xml_reader, p_input_node ) ) goto error; } else { /* we're reading a station list */ if( DemuxStation( p_demux, p_xml_reader, p_input_node, var_InheritBool( p_demux, "shoutcast-show-adult" ) ) ) goto error; } input_item_node_PostAndDelete( p_input_node ); p_input_node = NULL; i_ret = 0; /* Needed for correct operation of go back */ error: if( p_xml_reader ) xml_ReaderDelete( p_xml_reader ); if( p_input_node ) input_item_node_Delete( p_input_node ); vlc_gc_decref(p_current_input); return i_ret; }
bool vlc_media_tree_Remove(vlc_media_tree_t *tree, input_item_t *media) { vlc_media_tree_AssertLocked(tree); input_item_node_t *node; input_item_node_t *parent; if (!vlc_media_tree_FindNodeByMedia(&tree->root, media, &node, &parent)) return false; input_item_node_RemoveNode(parent, node); vlc_media_tree_Notify(tree, on_children_removed, parent, &node, 1); input_item_node_Delete(node); return true; }
static void fsdir_attach_slaves(struct access_fsdir *p_fsdir) { if (p_fsdir->i_sub_autodetect_fuzzy == 0) return; /* Try to match slaves for each items of the node */ for (int i = 0; i < p_fsdir->p_node->i_children; i++) { input_item_node_t *p_node = p_fsdir->p_node->pp_children[i]; input_item_t *p_item = p_node->p_item; for (unsigned int j = 0; j < p_fsdir->i_slaves; j++) { struct fsdir_slave *p_fsdir_slave = p_fsdir->pp_slaves[j]; if (p_fsdir_slave == NULL || p_fsdir_slave->p_node == p_node) continue; uint8_t i_priority = fsdir_get_slave_priority(p_item, p_fsdir_slave->p_slave, p_fsdir_slave->psz_filename); if (i_priority < p_fsdir->i_sub_autodetect_fuzzy) continue; /* Drop the ".sub" slave if a ".idx" slave matches */ if (p_fsdir_slave->p_slave->i_type == SLAVE_TYPE_SPU && fsdir_should_match_idx(p_fsdir, p_fsdir_slave)) continue; p_fsdir_slave->p_slave->i_priority = i_priority; input_item_AddSlave(p_item, p_fsdir_slave->p_slave); /* Remove the corresponding node if any: This slave won't be * added in the parent node */ if (p_fsdir_slave->p_node != NULL) input_item_node_Delete(p_fsdir_slave->p_node); /* Remove this slave from the list: we don't want to match * other items */ free(p_fsdir_slave->psz_filename); free(p_fsdir_slave); p_fsdir->pp_slaves[j] = NULL; } } }
int __vlclua_playlist_add_internal( vlc_object_t *p_this, lua_State *L, playlist_t *p_playlist, input_item_t *p_parent, bool b_play ) { int i_count = 0; input_item_node_t *p_parent_node = NULL; assert( p_parent || p_playlist ); /* playlist */ if( lua_istable( L, -1 ) ) { if( p_parent ) p_parent_node = input_item_node_Create( p_parent ); lua_pushnil( L ); /* playlist nil */ while( lua_next( L, -2 ) ) { /* playlist key item */ /* <Parse playlist item> */ if( lua_istable( L, -1 ) ) { lua_getfield( L, -1, "path" ); /* playlist key item path */ if( lua_isstring( L, -1 ) ) { const char *psz_path = NULL; const char *psz_name = NULL; char **ppsz_options = NULL; int i_options = 0; mtime_t i_duration = -1; input_item_t *p_input; /* Read path and name */ psz_path = lua_tostring( L, -1 ); msg_Dbg( p_this, "Path: %s", psz_path ); lua_getfield( L, -2, "name" ); /* playlist key item path name */ if( lua_isstring( L, -1 ) ) { psz_name = lua_tostring( L, -1 ); msg_Dbg( p_this, "Name: %s", psz_name ); } else { if( !lua_isnil( L, -1 ) ) msg_Warn( p_this, "Playlist item name should be a string." ); psz_name = psz_path; } /* Read duration */ lua_getfield( L, -3, "duration" ); /* playlist key item path name duration */ if( lua_isnumber( L, -1 ) ) { i_duration = (mtime_t)(lua_tonumber( L, -1 )*1e6); } else if( !lua_isnil( L, -1 ) ) { msg_Warn( p_this, "Playlist item duration should be a number (in seconds)." ); } lua_pop( L, 1 ); /* pop "duration" */ /* playlist key item path name */ /* Read options: item must be on top of stack */ lua_pushvalue( L, -3 ); /* playlist key item path name item */ vlclua_read_options( p_this, L, &i_options, &ppsz_options ); /* Create input item */ p_input = input_item_NewExt( p_playlist, psz_path, psz_name, i_options, (const char **)ppsz_options, VLC_INPUT_OPTION_TRUSTED, i_duration ); lua_pop( L, 3 ); /* pop "path name item" */ /* playlist key item */ /* Read meta data: item must be on top of stack */ vlclua_read_meta_data( p_this, L, p_input ); /* Read custom meta data: item must be on top of stack*/ vlclua_read_custom_meta_data( p_this, L, p_input ); /* Append item to playlist */ if( p_parent ) /* Add to node */ { input_item_CopyOptions( p_parent, p_input ); input_item_node_AppendItem( p_parent_node, p_input ); } else /* Play or Enqueue (preparse) */ /* FIXME: playlist_AddInput() can fail */ playlist_AddInput( p_playlist, p_input, PLAYLIST_APPEND | ( b_play ? PLAYLIST_GO : PLAYLIST_PREPARSE ), PLAYLIST_END, true, false ); i_count ++; /* increment counter */ vlc_gc_decref( p_input ); while( i_options > 0 ) free( ppsz_options[--i_options] ); free( ppsz_options ); } else { lua_pop( L, 1 ); /* pop "path" */ msg_Warn( p_this, "Playlist item's path should be a string" ); } /* playlist key item */ } else { msg_Warn( p_this, "Playlist item should be a table" ); } /* <Parse playlist item> */ lua_pop( L, 1 ); /* pop the value, keep the key for * the next lua_next() call */ /* playlist key */ } /* playlist */ if( p_parent ) { if( i_count ) input_item_node_PostAndDelete( p_parent_node ); else input_item_node_Delete( p_parent_node ); } } else { msg_Warn( p_this, "Playlist should be a table." ); } return i_count; }
static int Demux( demux_t *p_demux ) { const char *psz_node = NULL; char *psz_txt = NULL; char *psz_base = FindPrefix( p_demux ); char *psz_title_asx = NULL; char *psz_entryref = NULL; xml_reader_t *p_xml_reader = NULL; input_item_t *p_current_input = GetCurrentItem( p_demux ); input_item_node_t *p_subitems = NULL; bool b_first_node = false; int i_type; int i_n_entry = 0; p_xml_reader = xml_ReaderCreate( p_demux, p_demux->s ); if( !p_xml_reader ) { msg_Err( p_demux, "Cannot parse ASX input file as XML"); goto error; } p_subitems = input_item_node_Create( p_current_input ); do { i_type = xml_ReaderNextNode( p_xml_reader, &psz_node ); if( i_type == XML_READER_STARTELEM ) { if( !b_first_node ) { if(!strncasecmp( psz_node, "ASX", 3 ) ) b_first_node = true; else { msg_Err( p_demux, "invalid root node" ); goto error; } } /* Metadata Node Handler */ if( !strncasecmp( psz_node, "TITLE", 5 ) ) { ReadElement( p_xml_reader, &psz_title_asx ); input_item_SetTitle( p_current_input, psz_title_asx ); } else if( !strncasecmp( psz_node, "AUTHOR", 6 ) ) { ReadElement( p_xml_reader, &psz_txt ); input_item_SetArtist( p_current_input, psz_txt ); } else if( !strncasecmp( psz_node, "COPYRIGHT", 9 ) ) { ReadElement( p_xml_reader, &psz_txt ); input_item_SetCopyright( p_current_input, psz_txt ); } else if( !strncasecmp( psz_node, "MOREINFO", 8 ) ) { const char *psz_tmp; do { psz_tmp = xml_ReaderNextAttr( p_xml_reader, &psz_node ); } while( psz_tmp && strncasecmp( psz_tmp, "HREF", 4 ) ); if( !psz_tmp ) // If HREF attribute doesn't exist ReadElement( p_xml_reader, &psz_txt ); else psz_txt = strdup( psz_node ); resolve_xml_special_chars( psz_txt ); input_item_SetURL( p_current_input, psz_txt ); } else if( !strncasecmp( psz_node, "ABSTRACT", 8 ) ) { ReadElement( p_xml_reader, &psz_txt ); input_item_SetDescription( p_current_input, psz_txt ); } else /* Base Node handler */ if( !strncasecmp( psz_node, "BASE", 4 ) ) ReadElement( p_xml_reader, &psz_base ); else /* Entry Ref Handler */ if( !strncasecmp( psz_node, "ENTRYREF", 7 ) ) { const char *psz_tmp; do { psz_tmp = xml_ReaderNextAttr( p_xml_reader, &psz_node ); } while( psz_tmp && !strncasecmp( psz_tmp, "HREF", 4 ) ); /* Create new input item */ input_item_t *p_input; psz_txt = strdup( psz_node ); resolve_xml_special_chars( psz_txt ); p_input = input_item_New( psz_txt, psz_title_asx ); input_item_CopyOptions( p_current_input, p_input ); input_item_node_AppendItem( p_subitems, p_input ); vlc_gc_decref( p_input ); } else /* Entry Handler */ if( !strncasecmp( psz_node, "ENTRY", 5 ) ) { ProcessEntry( &i_n_entry, p_xml_reader, p_subitems, p_current_input, psz_base); } /* FIXME Unsupported elements PARAM EVENT REPEAT ENDMARK STARTMARK */ } } while( i_type != XML_READER_ENDELEM || strncasecmp( psz_node, "ASX", 3 ) ); input_item_node_PostAndDelete( p_subitems ); p_subitems = NULL; error: free( psz_base ); free( psz_title_asx ); free( psz_entryref ); free( psz_txt ); if( p_xml_reader) xml_ReaderDelete( p_xml_reader ); if( p_subitems ) input_item_node_Delete( p_subitems ); vlc_gc_decref( p_current_input ); return 0; }