1 /*****************************************************************************
2 * tree.c: libvlc tags tree functions
3 * Create a tree of the 'tags' of a media_list's media_descriptors.
4 *****************************************************************************
5 * Copyright (C) 2007 the VideoLAN team
8 * Authors: Pierre d'Herbemont <pdherbemont # videolan.org>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
24 #include "libvlc_internal.h"
25 #include <vlc/libvlc.h>
26 #include "vlc_arrays.h"
33 * Public libvlc functions
36 /**************************************************************************
38 **************************************************************************/
39 libvlc_media_library_t *
40 libvlc_media_library_new( libvlc_instance_t * p_inst,
41 libvlc_exception_t * p_e )
44 libvlc_media_library_t * p_mlib;
46 p_mlib = malloc(sizeof(libvlc_media_library_t));
51 p_mlib->p_libvlc_instance = p_inst;
52 p_mlib->i_refcount = 1;
53 p_mlib->p_mlist = NULL;
55 p_mlib->p_event_manager = libvlc_event_manager_new( p_mlib, p_inst, p_e );
60 /**************************************************************************
62 **************************************************************************/
63 void libvlc_media_library_release( libvlc_media_library_t * p_mlib )
67 if( p_mlib->i_refcount > 0 )
70 libvlc_event_manager_release( p_mlib->p_event_manager );
74 /**************************************************************************
76 **************************************************************************/
77 void libvlc_media_library_retain( libvlc_media_library_t * p_mlib )
82 /**************************************************************************
85 * It doesn't yet load the playlists
86 **************************************************************************/
88 libvlc_media_library_load( libvlc_media_library_t * p_mlib,
89 libvlc_exception_t * p_e )
91 const char *psz_datadir = p_mlib->p_libvlc_instance->p_libvlc_int->psz_datadir;
94 if( !psz_datadir ) /* XXX: i doubt that this can ever happen */
96 libvlc_exception_raise( p_e, "Can't get data directory" );
100 if( asprintf( &psz_uri, "file/xspf-open://%s" DIR_SEP "ml.xsp",
101 psz_datadir ) == -1 )
103 libvlc_exception_raise( p_e, "Can't get create the path" );
106 if( p_mlib->p_mlist )
107 libvlc_media_list_release( p_mlib->p_mlist );
109 p_mlib->p_mlist = libvlc_media_list_new(
110 p_mlib->p_libvlc_instance,
113 libvlc_media_list_add_file_content( p_mlib->p_mlist, psz_uri, p_e );
118 /**************************************************************************
120 **************************************************************************/
122 libvlc_media_library_save( libvlc_media_library_t * p_mlib,
123 libvlc_exception_t * p_e )
125 libvlc_exception_raise( p_e, "Not supported" );
128 /**************************************************************************
129 * media_list (Public)
130 **************************************************************************/
131 libvlc_media_list_t *
132 libvlc_media_library_media_list( libvlc_media_library_t * p_mlib,
133 libvlc_exception_t * p_e )
136 if( p_mlib->p_mlist )
137 libvlc_media_list_retain( p_mlib->p_mlist );
138 return p_mlib->p_mlist;