Data Structures | Defines | Typedefs | Enumerations | Functions

vlc_media_library.h File Reference

Include dependency graph for vlc_media_library.h:

Go to the source code of this file.

Data Structures

struct  ml_gc_object_t
struct  media_library_t
 Main structure of the media library. More...
struct  ml_media_t
 Structure to describe a media. More...
struct  ml_result_t
 Main communication struct between GUI and sql_media_library. More...
struct  ml_element_t
 Element of a query: criteria type/value pair Used for update and delete queries. More...
struct  ml_ftree_t
 Binary tree used to parse the WHERE condition for a search. More...
struct  ml_person_t
 Person class. More...

Defines

#define ML_PERSON_ARTIST   "Artist"
#define ML_PERSON_ALBUM_ARTIST   "Album Artist"
#define ML_PERSON_ENCODER   "Encoder"
#define ML_PERSON_PUBLISHER   "Publisher"
#define ml_priv(gc, t)   ((t *)(((char *)(gc)) - offsetof(t, ml_gc_data)))
#define ML_GC_MEMBERS   ml_gc_object_t ml_gc_data;
#define ml_Get(a)   ml_Get( VLC_OBJECT(a) )
#define ml_Control(a, b, args...)   __ml_Control( a, b, ## args )
 Control the Media Library.
#define ml_LockMedia(a)   vlc_mutex_lock( &a->lock )
 Helpers for locking and unlocking.
#define ml_UnlockMedia(a)   vlc_mutex_unlock( &a->lock )
#define ml_FreeFindTree(tree)   ml_GenericFreeFindTree( tree, true )
#define ml_ShallowFreeFindTree(tree)   ml_GenericFreeFindTree( tree, false )
#define ml_FtreeAnd(left, right)   ml_OpConnectChilds( ML_OP_AND, left, right )
#define ml_FtreeOr(left, right)   ml_OpConnectChilds( ML_OP_OR, left, right )
#define ml_FtreeNot(left)   ml_OpConnectChilds( ML_OP_NOT, left, NULL )
#define ml_FtreeSpecAsc(tree, str)   ml_FtreeSpec( tree, ML_SORT_ASC, 0, str )
#define ml_FtreeSpecDesc(tree, str)   ml_FtreeSpec( tree, ML_SORT_DESC, 0, str )
#define ml_FtreeSpecLimit(tree, limit)   ml_FtreeSpec( tree, ML_LIMIT, limit, NULL )
#define ml_FtreeSpecDistinct(tree)   ml_FtreeSpec( tree, ML_DISTINCT, 0, NULL )
#define ml_GetInt(ml,...)   __ml_GetInt( ml, __VA_ARGS__, ML_LIMIT, 1, ML_END )
 Search an INTEGER in the database This uses a Query but returns only one integer (>0), or an error code.
#define ml_FindPsz(ml,...)   __ml_GetPsz( ml, __VA_ARGS__, ML_LIMIT, 1, ML_END )
 Search a string (VARCHAR) in the database This uses a Query but returns only one integer (>0), or an error code.
#define ml_UpdateSimple(ml, sel, lval, id,...)   ml_UpdateSimple( ml, sel, lval, id, __VA_ARGS__, ML_END )
#define ml_GetAlbumArtistsFromMedia(a, b)   ml_GetPersonsFromMedia( a, b, ML_PERSON_ALBUM_ARTIST );
#define ml_GetArtistsFromMedia(a, b)   ml_GetPersonsFromMedia( a, b, ML_PERSON_ARTIST );
#define ml_GetEncodersFromMedia(a, b)   ml_GetPersonsFromMedia( a, b, ML_PERSON_ENCODER );
#define ml_GetPublishersFromMedia(a, b)   ml_GetPersonsFromMedia( a, b, ML_PERSON_PUBLISHER );
#define ml_GetAlbumById(a, id)   ml_GetPsz( a, ML_ALBUM, ML_ID, id )
 Convenience Macros.
#define ml_GetArtistById(a, id)   ml_GetPsz( a, ML_PEOPLE, ML_PERSON_ARTIST, ML_ID, id )
#define ml_GetCoverUriById(a, id)   ml_GetPsz( a, ML_COVER, ML_ID, id )
#define ml_GetEncoderById(a, id)   ml_GetPsz( a, ML_PEOPLE, ML_PERSON_ENCODER, ML_ID, id )
#define ml_GetExtraById(a, id)   ml_GetPsz( a, ML_EXTRA, ML_ID, id )
#define ml_GetGenreById(a, id)   ml_GetPsz( a, ML_GENRE, ML_ID, id )
#define ml_GetOriginalTitleById(a, id)   ml_GetPsz( a, ML_ORIGINAL_TITLE, ML_ID, id )
#define ml_GetPublisherById(a, id)   ml_GetPsz( a, ML_PEOPLE, ML_PERSON_PUBLISHER, ML_ID, id )
#define ml_GetTitleById(a, id)   ml_GetPsz( a, ML_TITLE, ML_ID, id )
#define ml_GetUriById(a, id)   ml_GetPsz( a, ML_URI, ML_ID, id )
#define ml_GetAlbumIdById(a, id)   ml_GetInt( a, ML_ALBUM_ID, ML_ID, id )
#define ml_GetArtistIdById(a, id)   ml_GetInt( a, ML_PEOPLE_ID, ML_PERSON_ARTIST, ML_ID, id )
#define ml_GetDurationById(a, id)   ml_GetInt( a, ML_DURATION, ML_ID, id )
#define ml_GetEncoderIdById(a, id)   ml_GetInt( a, ML_PEOPLE_ID, ML_PERSON_ENCODER, ML_ID, id )
#define ml_GetLastPlayedById(a, id)   ml_GetInt( a, ML_LAST_PLAYED, ML_ID, id )
#define ml_GetPlayedCountById(a, id)   ml_GetInt( a, ML_PLAYED_COUNT, ML_ID, id )
#define ml_GetPublisherIdById(a, id)   ml_GetInt( a, ML_PEOPLE_ID, ML_PERSON_PUBLISHER, ML_ID, id )
#define ml_GetScoreById(a, id)   ml_GetInt( a, ML_SCORE, ML_ID, id )
#define ml_GetTrackNumberById(a, id)   ml_GetInt( a, ML_TRACK_NUMBER, ML_ID, id )
#define ml_GetTypeById(a, id)   ml_GetInt( a, ML_TYPE, ML_ID, id )
#define ml_GetYearById(a, id)   ml_GetInt( a, ML_YEAR, ML_ID, id )
#define ml_GetVoteById(a, id)   ml_GetInt( a, ML_VOTE, ML_ID, id )
#define ml_GetAlbumId(a, b)   ml_GetInt( a, ML_ALBUM_ID, ML_ALBUM, b )
 Albums handling.
#define ml_GetArtistId(a, b)   ml_GetInt( a, ML_PERSON_ID, ML_PERSON_ARTIST, ML_PERSON, ML_PERSON_ARTIST, b )
 People handling.
#define ml_GetEncoderId(a, b)   ml_GetInt( a, ML_PERSON_ID, ML_PERSON_ENCODER, ML_PERSON, ML_PERSON_ENCODER, b )
#define ml_GetPublisherId(a, b)   ml_GetInt( a, ML_PERSON_ID, ML_PERSON_PUBLISHER, ML_PERSON, ML_PERSON_PUBLISHER, b )
#define ml_GetMediaCount(a,...)   __ml_GetInt( a, ML_COUNT_MEDIA, __VA_ARGS__, ML_END )
 Counts handling.
#define ml_GetAlbumCount(a,...)   __ml_GetInt( a, ML_COUNT_ALBUM, __VA_ARGS__, ML_END )
#define ml_GetPeopleCount(a,...)   __ml_GetInt( a, ML_COUNT_PEOPLE, __VA_ARGS__, ML_END )
#define ml_Find(a, b,...)   __ml_Find( a, b, __VA_ARGS__, ML_END )
#define ml_FindAlbum(a, b,...)   __ml_Find( a, b, ML_ALBUM, __VA_ARGS__, ML_END )
#define ml_FindArtist(a, b,...)   __ml_Find( a, b, ML_PERSON, ML_PERSON_ARTIST, __VA_ARGS__, ML_END )
#define ml_FindEncoder(a, b,...)   __ml_Find( a, b, ML_PERSON, ML_PERSON_ENCODER, __VA_ARGS__, ML_END )
#define ml_FindGenre(a, b,...)   __ml_Find( a, b, ML_GENRE, __VA_ARGS__, ML_END )
#define ml_FindMedia(a, b,...)   __ml_Find( a, b, ML_MEDIA, __VA_ARGS__, ML_END )
#define ml_FindOriginalTitle(a, b,...)   __ml_Find( a, b, ML_ORIGINAL_TITLE, __VA_ARGS__, ML_END )
#define ml_FindPublisher(a, b,...)   __ml_Find( a, b, ML_PERSON, ML_PERSON_PUBLISHER, __VA_ARGS__, ML_END )
#define ml_FindTitle(a, b,...)   __ml_Find( a, b, ML_TITLE, __VA_ARGS__, ML_END )
#define ml_FindType(a, b,...)   __ml_Find( a, b, ML_TYPE, __VA_ARGS__, ML_END )
#define ml_FindUri(a, b,...)   __ml_Find( a, b, ML_URI, __VA_ARGS__, ML_END )
#define ml_FindYear(a, b,...)   __ml_Find( a, b, ML_YEAR, __VA_ARGS__, ML_END )
#define ml_FindAllAlbums(a, b)   ml_FindAlbum( a, b, ML_DISTINCT )
#define ml_FindAllArtists(a, b)   ml_FindArtist( a, b, ML_DISTINCT )
#define ml_FindAllGenres(a, b)   ml_FindGenre( a, b, ML_DISTINCT )
#define ml_FindAllMedias(a, b)   ml_FindMedia( a, b, ML_DISTINCT )
#define ml_FindAllOriginalTitles(a, b)   ml_FindOriginalTitle( a, b, ML_DISTINCT )
#define ml_FindAllPublishers(a, b,...)   ml_FindPublisher( a, b, ML_DISTINCT )
#define ml_FindAllTitles(a, b)   ml_FindTitle( a, b, ML_DISTINCT )
#define ml_FindAllTypes(a, b)   ml_FindType( a, b, ML_DISTINCT )
#define ml_FindAllUris(a, b)   ml_FindUri( a, b, ML_DISTINCT )
#define ml_FindAllYears(a, b)   ml_FindYear( a, b, ML_DISTINCT )
#define ml_FindAlbumAdv(a, b, c)   ml_FindAdv( a, b, ML_ALBUM, NULL, c )
#define ml_FindArtistAdv(a, b, c)   ml_FindAdv( a, b, ML_PERSON, ML_PERSON_ARTIST, c )
#define ml_FindEncoderAdv(a, b, c)   ml_FindAdv( a, b, ML_PERSON, ML_PERSON_ENCODER, c )
#define ml_FindGenreAdv(a, b, c)   ml_FindAdv( a, b, ML_GENRE, NULL, c )
#define ml_FindMediaAdv(a, b, c)   ml_FindAdv( a, b, ML_MEDIA, NULL, c )
#define ml_FindOriginalTitleAdv(a, b, c)   ml_FindAdv( a, b, ML_ORIGINAL_TITLE,NULL, c )
#define ml_FindPublisherAdv(a, b, c)   ml_FindAdv( a, b, ML_PUBLISHER, ML_PERSON_PUBLISHER, c )
#define ml_FindTitleAdv(a, b, c)   ml_FindAdv( a, b, ML_TITLE, NULL, c )
#define ml_FindTypeAdv(a, b, c)   ml_FindAdv( a, b, ML_TYPE, NULL, c )
#define ml_FindUriAdv(a, b, c)   ml_FindAdv( a, b, ML_URI, NULL, c )
#define ml_FindYearAdv(a, b, c)   ml_FindAdv( a, b, ML_YEAR, NULL, c )

Typedefs

typedef struct media_library_t media_library_t
typedef struct media_library_sys_t media_library_sys_t
typedef struct ml_media_t ml_media_t
typedef struct ml_result_t ml_result_t
typedef struct ml_element_t ml_element_t
typedef struct ml_person_t ml_person_t
typedef struct ml_ftree_t ml_ftree_t
typedef struct ml_gc_object_t ml_gc_object_t

Enumerations

enum  ml_select_e {
  ML_ALBUM = 1, ML_ALBUM_ID, ML_ALBUM_COVER, ML_ARTIST,
  ML_ARTIST_ID, ML_COMMENT, ML_COUNT_MEDIA, ML_COUNT_ALBUM,
  ML_COUNT_PEOPLE, ML_COVER, ML_DURATION, ML_DISC_NUMBER,
  ML_EXTRA, ML_FIRST_PLAYED, ML_FILESIZE, ML_GENRE,
  ML_ID, ML_IMPORT_TIME, ML_LANGUAGE, ML_LAST_PLAYED,
  ML_LAST_SKIPPED, ML_ORIGINAL_TITLE, ML_PEOPLE, ML_PEOPLE_ID,
  ML_PEOPLE_ROLE, ML_PLAYED_COUNT, ML_PREVIEW, ML_SKIPPED_COUNT,
  ML_SCORE, ML_TITLE, ML_TRACK_NUMBER, ML_TYPE,
  ML_URI, ML_VOTE, ML_YEAR, ML_DIRECTORY,
  ML_MEDIA, ML_MEDIA_SPARSE, ML_MEDIA_EXTRA, ML_LIMIT = -1,
  ML_SORT_DESC = -2, ML_SORT_ASC = -3, ML_DISTINCT = -4, ML_END = -42
}
 

List of Query select types.

More...
enum  ml_type_e {
  ML_UNKNOWN = 0, ML_AUDIO = 1 << 0, ML_VIDEO = 1 << 1, ML_STREAM = 1 << 2,
  ML_NODE = 1 << 3, ML_REMOVABLE = 1 << 4
}
 

Media types (audio, video, etc...).

More...
enum  ml_result_type_e { ML_TYPE_INT, ML_TYPE_PSZ, ML_TYPE_TIME, ML_TYPE_MEDIA }
 

Query result item/list type: integers, strings, medias, timestamps.

More...
enum  ml_control_e {
  ML_SET_DATABASE, ML_INIT_DATABASE, ML_ADD_INPUT_ITEM, ML_ADD_PLAYLIST_ITEM,
  ML_ADD_MONITORED, ML_DEL_MONITORED, ML_GET_MONITORED
}
 

Arguments for VLC Control for the media library.

More...
enum  ml_op_e {
  ML_OP_NONE = 0, ML_OP_AND, ML_OP_OR, ML_OP_NOT,
  ML_OP_SPECIAL
}
enum  ml_comp_e {
  ML_COMP_NONE = 0, ML_COMP_LESSER, ML_COMP_LESSER_OR_EQUAL, ML_COMP_EQUAL,
  ML_COMP_GREATER_OR_EQUAL, ML_COMP_GREATER, ML_COMP_HAS, ML_COMP_STARTS_WITH,
  ML_COMP_ENDS_WITH
}

Functions

media_library_tml_Get (vlc_object_t *p_this)
 Acquire a reference to the media library singleton.
media_library_tml_Create (vlc_object_t *p_this, char *psz_name)
 Create a Media Library VLC object.
void ml_Destroy (vlc_object_t *p_this)
 Destructor for the Media library singleton.
static int ml_ControlVa (media_library_t *p_media_library, ml_control_e i_type, va_list args)
 Control the Media Library.
static int __ml_Control (media_library_t *p_media_library, ml_control_e i_type,...)
static int ml_AttributeIsString (ml_select_e meta)
 Determine an attribute's type (int or string).
static void ml_gc_incref (ml_media_t *p_media)
 Increment reference count of media.
static void ml_gc_decref (ml_media_t *p_media)
 Decrease reference count of media.
static void ml_FreePeople (ml_person_t *p_person)
 Free a person object.
static void ml_FreeMediaContent (ml_media_t *p_media)
 Free only the content of a media.
static void ml_FreeResult (ml_result_t *p_result)
 Free a result item.
static void ml_FreeElement (ml_element_t *p_elt)
 Free a ml_element_t item.
static void ml_DestroyResultArray (vlc_array_t *p_result_array)
 Destroy a vlc_array_t of ml_result_t.
ml_media_tmedia_New (media_library_t *p_ml, int id, ml_select_e select, bool reload)
 Object constructor for ml_media_t.
static int ml_CopyPersons (ml_person_t **a, ml_person_t *b)
 Copy one person list into another.
static int ml_CopyMedia (ml_media_t *b, ml_media_t *a)
 Copy all members of a ml_media_t to another.
static void ml_GenericFreeFindTree (ml_ftree_t *tree, bool freestrings)
 Free a find tree.
static int ml_FtreeHasOp (ml_ftree_t *tree)
 Checks if a given find tree has leaf nodes.
ml_ftree_tml_OpConnectChilds (ml_op_e op, ml_ftree_t *left, ml_ftree_t *right)
 Connect up a find tree.
ml_ftree_tml_FtreeSpec (ml_ftree_t *tree, ml_select_e crit, int limit, char *sort)
 Attaches a special node to a tree.
static ml_ftree_tml_FtreeFastAnd (ml_ftree_t *left, ml_ftree_t *right)
 This function gives quick sequential adding capability.
static input_item_tml_CreateInputItem (media_library_t *p_media_library, int i_media_id)
 Create input item from media.
static int __ml_Find (media_library_t *p_media_library, vlc_array_t *p_result_array,...)
 Search in the database according some criterias.
static int ml_FindAdv (media_library_t *p_media_library, vlc_array_t *p_result_array, ml_select_e result_type, char *psz_lvalue, ml_ftree_t *tree)
 Search in the database according some criterias (threaded).
static int __ml_GetValue (media_library_t *p_media_library, ml_result_t *p_result, va_list args)
 Find a value in the ML database, fill p_result with it.
static int __ml_GetInt (media_library_t *p_media_library,...)
static char * __ml_GetPsz (media_library_t *p_media_library,...)
static int ml_Update (media_library_t *p_media_library, ml_select_e selected_type, const char *psz_lvalue, ml_ftree_t *where, vlc_array_t *changes)
 Generic update in Media Library database.
int ml_UpdateSimple (media_library_t *p_media_library, ml_select_e selected_type, const char *psz_lvalue, int id,...)
 Update a given table.
static int ml_DeleteSimple (media_library_t *p_media_library, int id)
 Generic DELETE function Delete a media and all its references which don't point to anything else.
static int ml_Delete (media_library_t *p_media_library, vlc_array_t *p_array)
 Delete many medias in the media library.
static int ml_CreateAppendPersonAdv (ml_person_t **pp_person, const char *psz_role, const char *psz_name, int i_id)
 Create and append a person object to the given list.
static int ml_CreateAppendPerson (ml_person_t **pp_person, ml_person_t *p_personfrom)
 Create and append a person object to the given list.
ml_person_tml_GetPersonsFromMedia (media_library_t *p_ml, ml_media_t *p_media, const char *psz_role)
 Returns a person list of given type.
void ml_DeletePersonTypeFromMedia (ml_media_t *p_media, const char *psz_role)
 Delete a certain type of people from a media.
void ml_PlaySmartPlaylistBasedOn (media_library_t *p_ml, ml_ftree_t *p_tree)
 Creates and adds the playlist based on a given find tree.

Define Documentation

#define ml_Control (   a,
  b,
  args... 
)    __ml_Control( a, b, ## args )

Control the Media Library.

Parameters:
i_type one of ml_control_e values
See also:
ml_control_e. Variable arguments list equivalent
#define ml_Find (   a,
  b,
  ... 
)    __ml_Find( a, b, __VA_ARGS__, ML_END )
#define ml_FindAlbum (   a,
  b,
  ... 
)    __ml_Find( a, b, ML_ALBUM, __VA_ARGS__, ML_END )
#define ml_FindAlbumAdv (   a,
  b,
  c 
)    ml_FindAdv( a, b, ML_ALBUM, NULL, c )
#define ml_FindAllAlbums (   a,
  b 
)    ml_FindAlbum( a, b, ML_DISTINCT )
#define ml_FindAllArtists (   a,
  b 
)    ml_FindArtist( a, b, ML_DISTINCT )
#define ml_FindAllGenres (   a,
  b 
)    ml_FindGenre( a, b, ML_DISTINCT )
#define ml_FindAllMedias (   a,
  b 
)    ml_FindMedia( a, b, ML_DISTINCT )
#define ml_FindAllOriginalTitles (   a,
  b 
)    ml_FindOriginalTitle( a, b, ML_DISTINCT )
#define ml_FindAllPublishers (   a,
  b,
  ... 
)    ml_FindPublisher( a, b, ML_DISTINCT )
#define ml_FindAllTitles (   a,
  b 
)    ml_FindTitle( a, b, ML_DISTINCT )
#define ml_FindAllTypes (   a,
  b 
)    ml_FindType( a, b, ML_DISTINCT )
#define ml_FindAllUris (   a,
  b 
)    ml_FindUri( a, b, ML_DISTINCT )
#define ml_FindAllYears (   a,
  b 
)    ml_FindYear( a, b, ML_DISTINCT )
#define ml_FindArtist (   a,
  b,
  ... 
)    __ml_Find( a, b, ML_PERSON, ML_PERSON_ARTIST, __VA_ARGS__, ML_END )
#define ml_FindArtistAdv (   a,
  b,
  c 
)    ml_FindAdv( a, b, ML_PERSON, ML_PERSON_ARTIST, c )
#define ml_FindEncoder (   a,
  b,
  ... 
)    __ml_Find( a, b, ML_PERSON, ML_PERSON_ENCODER, __VA_ARGS__, ML_END )
#define ml_FindEncoderAdv (   a,
  b,
  c 
)    ml_FindAdv( a, b, ML_PERSON, ML_PERSON_ENCODER, c )
#define ml_FindGenre (   a,
  b,
  ... 
)    __ml_Find( a, b, ML_GENRE, __VA_ARGS__, ML_END )
#define ml_FindGenreAdv (   a,
  b,
  c 
)    ml_FindAdv( a, b, ML_GENRE, NULL, c )
#define ml_FindMedia (   a,
  b,
  ... 
)    __ml_Find( a, b, ML_MEDIA, __VA_ARGS__, ML_END )
#define ml_FindMediaAdv (   a,
  b,
  c 
)    ml_FindAdv( a, b, ML_MEDIA, NULL, c )
#define ml_FindOriginalTitle (   a,
  b,
  ... 
)    __ml_Find( a, b, ML_ORIGINAL_TITLE, __VA_ARGS__, ML_END )
#define ml_FindOriginalTitleAdv (   a,
  b,
  c 
)    ml_FindAdv( a, b, ML_ORIGINAL_TITLE,NULL, c )
#define ml_FindPsz (   ml,
  ... 
)    __ml_GetPsz( ml, __VA_ARGS__, ML_LIMIT, 1, ML_END )

Search a string (VARCHAR) in the database This uses a Query but returns only one integer (>0), or an error code.

Parameters:
p_media_library the media library object
va_args parameters to select the data
Returns:
Found string, or NULL if not found or in case of error
#define ml_FindPublisher (   a,
  b,
  ... 
)    __ml_Find( a, b, ML_PERSON, ML_PERSON_PUBLISHER, __VA_ARGS__, ML_END )
#define ml_FindPublisherAdv (   a,
  b,
  c 
)    ml_FindAdv( a, b, ML_PUBLISHER, ML_PERSON_PUBLISHER, c )
#define ml_FindTitle (   a,
  b,
  ... 
)    __ml_Find( a, b, ML_TITLE, __VA_ARGS__, ML_END )
#define ml_FindTitleAdv (   a,
  b,
  c 
)    ml_FindAdv( a, b, ML_TITLE, NULL, c )
#define ml_FindType (   a,
  b,
  ... 
)    __ml_Find( a, b, ML_TYPE, __VA_ARGS__, ML_END )
#define ml_FindTypeAdv (   a,
  b,
  c 
)    ml_FindAdv( a, b, ML_TYPE, NULL, c )
#define ml_FindUri (   a,
  b,
  ... 
)    __ml_Find( a, b, ML_URI, __VA_ARGS__, ML_END )
#define ml_FindUriAdv (   a,
  b,
  c 
)    ml_FindAdv( a, b, ML_URI, NULL, c )
#define ml_FindYear (   a,
  b,
  ... 
)    __ml_Find( a, b, ML_YEAR, __VA_ARGS__, ML_END )
#define ml_FindYearAdv (   a,
  b,
  c 
)    ml_FindAdv( a, b, ML_YEAR, NULL, c )
#define ml_FreeFindTree (   tree  )     ml_GenericFreeFindTree( tree, true )
#define ml_FtreeAnd (   left,
  right 
)    ml_OpConnectChilds( ML_OP_AND, left, right )
#define ml_FtreeNot (   left  )     ml_OpConnectChilds( ML_OP_NOT, left, NULL )
#define ml_FtreeOr (   left,
  right 
)    ml_OpConnectChilds( ML_OP_OR, left, right )
#define ml_FtreeSpecAsc (   tree,
  str 
)    ml_FtreeSpec( tree, ML_SORT_ASC, 0, str )
#define ml_FtreeSpecDesc (   tree,
  str 
)    ml_FtreeSpec( tree, ML_SORT_DESC, 0, str )
#define ml_FtreeSpecDistinct (   tree  )     ml_FtreeSpec( tree, ML_DISTINCT, 0, NULL )
#define ml_FtreeSpecLimit (   tree,
  limit 
)    ml_FtreeSpec( tree, ML_LIMIT, limit, NULL )
#define ML_GC_MEMBERS   ml_gc_object_t ml_gc_data;
#define ml_Get (   a  )     ml_Get( VLC_OBJECT(a) )
#define ml_GetAlbumArtistsFromMedia (   a,
  b 
)    ml_GetPersonsFromMedia( a, b, ML_PERSON_ALBUM_ARTIST );
#define ml_GetAlbumById (   a,
  id 
)    ml_GetPsz( a, ML_ALBUM, ML_ID, id )

Convenience Macros.

Get information using the *media* ID. This returns only 1 information.

Note:
You have to free the string returned (if that's a string!).
#define ml_GetAlbumCount (   a,
  ... 
)    __ml_GetInt( a, ML_COUNT_ALBUM, __VA_ARGS__, ML_END )
#define ml_GetAlbumId (   a,
  b 
)    ml_GetInt( a, ML_ALBUM_ID, ML_ALBUM, b )

Albums handling.

#define ml_GetAlbumIdById (   a,
  id 
)    ml_GetInt( a, ML_ALBUM_ID, ML_ID, id )
#define ml_GetArtistById (   a,
  id 
)    ml_GetPsz( a, ML_PEOPLE, ML_PERSON_ARTIST, ML_ID, id )
#define ml_GetArtistId (   a,
  b 
)    ml_GetInt( a, ML_PERSON_ID, ML_PERSON_ARTIST, ML_PERSON, ML_PERSON_ARTIST, b )

People handling.

#define ml_GetArtistIdById (   a,
  id 
)    ml_GetInt( a, ML_PEOPLE_ID, ML_PERSON_ARTIST, ML_ID, id )
#define ml_GetArtistsFromMedia (   a,
  b 
)    ml_GetPersonsFromMedia( a, b, ML_PERSON_ARTIST );
#define ml_GetCoverUriById (   a,
  id 
)    ml_GetPsz( a, ML_COVER, ML_ID, id )
#define ml_GetDurationById (   a,
  id 
)    ml_GetInt( a, ML_DURATION, ML_ID, id )
#define ml_GetEncoderById (   a,
  id 
)    ml_GetPsz( a, ML_PEOPLE, ML_PERSON_ENCODER, ML_ID, id )
#define ml_GetEncoderId (   a,
  b 
)    ml_GetInt( a, ML_PERSON_ID, ML_PERSON_ENCODER, ML_PERSON, ML_PERSON_ENCODER, b )
#define ml_GetEncoderIdById (   a,
  id 
)    ml_GetInt( a, ML_PEOPLE_ID, ML_PERSON_ENCODER, ML_ID, id )
#define ml_GetEncodersFromMedia (   a,
  b 
)    ml_GetPersonsFromMedia( a, b, ML_PERSON_ENCODER );
#define ml_GetExtraById (   a,
  id 
)    ml_GetPsz( a, ML_EXTRA, ML_ID, id )
#define ml_GetGenreById (   a,
  id 
)    ml_GetPsz( a, ML_GENRE, ML_ID, id )
#define ml_GetInt (   ml,
  ... 
)    __ml_GetInt( ml, __VA_ARGS__, ML_LIMIT, 1, ML_END )

Search an INTEGER in the database This uses a Query but returns only one integer (>0), or an error code.

Parameters:
p_media_library the media library object
va_args parameters to select the data
Returns:
Found INTEGER >= 0 or an error
#define ml_GetLastPlayedById (   a,
  id 
)    ml_GetInt( a, ML_LAST_PLAYED, ML_ID, id )
#define ml_GetMediaCount (   a,
  ... 
)    __ml_GetInt( a, ML_COUNT_MEDIA, __VA_ARGS__, ML_END )

Counts handling.

#define ml_GetOriginalTitleById (   a,
  id 
)    ml_GetPsz( a, ML_ORIGINAL_TITLE, ML_ID, id )
#define ml_GetPeopleCount (   a,
  ... 
)    __ml_GetInt( a, ML_COUNT_PEOPLE, __VA_ARGS__, ML_END )
#define ml_GetPlayedCountById (   a,
  id 
)    ml_GetInt( a, ML_PLAYED_COUNT, ML_ID, id )
#define ml_GetPublisherById (   a,
  id 
)    ml_GetPsz( a, ML_PEOPLE, ML_PERSON_PUBLISHER, ML_ID, id )
#define ml_GetPublisherId (   a,
  b 
)    ml_GetInt( a, ML_PERSON_ID, ML_PERSON_PUBLISHER, ML_PERSON, ML_PERSON_PUBLISHER, b )
#define ml_GetPublisherIdById (   a,
  id 
)    ml_GetInt( a, ML_PEOPLE_ID, ML_PERSON_PUBLISHER, ML_ID, id )
#define ml_GetPublishersFromMedia (   a,
  b 
)    ml_GetPersonsFromMedia( a, b, ML_PERSON_PUBLISHER );
#define ml_GetScoreById (   a,
  id 
)    ml_GetInt( a, ML_SCORE, ML_ID, id )
#define ml_GetTitleById (   a,
  id 
)    ml_GetPsz( a, ML_TITLE, ML_ID, id )
#define ml_GetTrackNumberById (   a,
  id 
)    ml_GetInt( a, ML_TRACK_NUMBER, ML_ID, id )
#define ml_GetTypeById (   a,
  id 
)    ml_GetInt( a, ML_TYPE, ML_ID, id )
#define ml_GetUriById (   a,
  id 
)    ml_GetPsz( a, ML_URI, ML_ID, id )
#define ml_GetVoteById (   a,
  id 
)    ml_GetInt( a, ML_VOTE, ML_ID, id )
#define ml_GetYearById (   a,
  id 
)    ml_GetInt( a, ML_YEAR, ML_ID, id )
#define ml_LockMedia (   a  )     vlc_mutex_lock( &a->lock )

Helpers for locking and unlocking.

Referenced by ml_CopyMedia().

#define ML_PERSON_ALBUM_ARTIST   "Album Artist"
#define ML_PERSON_ARTIST   "Artist"
#define ML_PERSON_ENCODER   "Encoder"
#define ML_PERSON_PUBLISHER   "Publisher"
#define ml_priv (   gc,
  t 
)    ((t *)(((char *)(gc)) - offsetof(t, ml_gc_data)))
#define ml_ShallowFreeFindTree (   tree  )     ml_GenericFreeFindTree( tree, false )
#define ml_UnlockMedia (   a  )     vlc_mutex_unlock( &a->lock )

Referenced by ml_CopyMedia().

#define ml_UpdateSimple (   ml,
  sel,
  lval,
  id,
  ... 
)    ml_UpdateSimple( ml, sel, lval, id, __VA_ARGS__, ML_END )

Typedef Documentation

typedef struct ml_element_t ml_element_t
typedef struct ml_ftree_t ml_ftree_t
typedef struct ml_media_t ml_media_t
typedef struct ml_person_t ml_person_t
typedef struct ml_result_t ml_result_t

Enumeration Type Documentation

enum ml_comp_e
Enumerator:
ML_COMP_NONE 
ML_COMP_LESSER 

<

ML_COMP_LESSER_OR_EQUAL 

<=

ML_COMP_EQUAL 

==

ML_COMP_GREATER_OR_EQUAL 

>=

ML_COMP_GREATER 

>

ML_COMP_HAS 

"Contains", equivalent to SQL "LIKE %x%"

ML_COMP_STARTS_WITH 

Equivalent to SQL "LIKE %x".

ML_COMP_ENDS_WITH 

Equivalent to SQL "LIKE x%".

Arguments for VLC Control for the media library.

Enumerator:
ML_SET_DATABASE 

arg1 = char *psz_host arg2 = int i_port arg3 = char *psz_user arg4 = char *psz_pass

ML_INIT_DATABASE 

No arg.

ML_ADD_INPUT_ITEM 

arg1 = input_item_t*

ML_ADD_PLAYLIST_ITEM 

arg1 = playlist_item_t *

ML_ADD_MONITORED 

arg1 = char*

ML_DEL_MONITORED 

arg1 = char*

ML_GET_MONITORED 

arg1 = vlc_array_t*

enum ml_op_e
Enumerator:
ML_OP_NONE 

This is to specify an actual condition.

ML_OP_AND 

AND condition.

ML_OP_OR 

OR condition.

ML_OP_NOT 

NOT condition.

ML_OP_SPECIAL 

This is for inclusion of special stuffs like LIMIT.

Query result item/list type: integers, strings, medias, timestamps.

Enumerator:
ML_TYPE_INT 

Object is an int.

ML_TYPE_PSZ 

A string char*.

ML_TYPE_TIME 

A timestamp mtime_t.

ML_TYPE_MEDIA 

A pointer to a media ml_media_t*.

List of Query select types.

In a query array or variable argument list, each select type is followed by an argument (X) of variable type (char* or int,

See also:
ml_element_t). These types can be used either in the query list or in the result array. Some types are reserved for the result array:
Enumerator:
ML_ALBUM 

Album Title.

ML_ALBUM_ID 

Album ID.

ML_ALBUM_COVER 

Album Cover art url.

ML_ARTIST 

Artist, interpreted as ML_PEOPLE && ML_PEOPLE_ROLE = ML_PERSON_ARTIST.

ML_ARTIST_ID 

Artist ID, interpreted as ML_PEOPLE_ID && ML_PEOPLE_ROLE = ML_PERSON_ARTIST.

ML_COMMENT 

Comment about media.

ML_COUNT_MEDIA 

Number of medias.

ML_COUNT_ALBUM 

Number of albums.

ML_COUNT_PEOPLE 

Number of people.

ML_COVER 

Cover art url.

ML_DURATION 

Duration in ms.

ML_DISC_NUMBER 

Disc number of the track.

ML_EXTRA 

Extra/comment (string) on the media.

ML_FIRST_PLAYED 

First time media was played.

ML_FILESIZE 

Size of the media file.

ML_GENRE 

Genre of the media (if any).

ML_ID 

Media ID.

ML_IMPORT_TIME 

Date when media was imported.

ML_LANGUAGE 

Language.

ML_LAST_PLAYED 

Last play UNIX timestamp.

ML_LAST_SKIPPED 

Time when media was last skipped.

ML_ORIGINAL_TITLE 

Media original title (if any).

ML_PEOPLE 

Any People associated with this media.

ML_PEOPLE_ID 

Id of a person.

ML_PEOPLE_ROLE 

Person role.

ML_PLAYED_COUNT 

Media play count.

ML_PREVIEW 

Url of the video preview.

ML_SKIPPED_COUNT 

Number of times skipped.

ML_SCORE 

Computed media score.

ML_TITLE 

Media title.

ML_TRACK_NUMBER 

Media track number (if any).

ML_TYPE 

Media type.

See also:
ml_type_e
ML_URI 

Media full URI.

ML_VOTE 

Media user vote value.

ML_YEAR 

Media publishing year.

ML_DIRECTORY 

Monitored directory.

ML_MEDIA 

Full media descriptor.

See also:
ml_media_t
ML_MEDIA_SPARSE 

Sparse media.

See also:
ml_media_t
ML_MEDIA_EXTRA 

Sparse + Extra = Full media.

ML_LIMIT 

Limit a query to X results.

ML_SORT_DESC 

Sort a query descending on argument X.

ML_SORT_ASC 

Sort a query ascending on argument X.

ML_DISTINCT 

Add DISTINCT to SELECT statements.

ML_END 

End of argument list.

enum ml_type_e

Media types (audio, video, etc...).

Enumerator:
ML_UNKNOWN 

Unknown media type.

ML_AUDIO 

Audio only media.

ML_VIDEO 

Video media.

May contain audio channels

ML_STREAM 

Streamed media = not a local file.

ML_NODE 

Nodes like simple nodes, directories, playlists, etc.

ML_REMOVABLE 

Removable media: CD/DVD/Card/...


Function Documentation

static int __ml_Control ( media_library_t p_media_library,
ml_control_e  i_type,
  ... 
) [inline, static]

References ml_ControlVa(), va_end(), and va_start().

static int __ml_Find ( media_library_t p_media_library,
vlc_array_t p_result_array,
  ... 
) [inline, static]

Search in the database according some criterias.

Parameters:
p_media_library the media library object
result a pointer to a result array
... parameters to select the data
Returns:
VLC_SUCCESS or an error

References media_library_t::functions, media_library_t::pf_Find, va_end(), and va_start().

static int __ml_GetInt ( media_library_t p_media_library,
  ... 
) [inline, static]
static char* __ml_GetPsz ( media_library_t p_media_library,
  ... 
) [inline, static]
static int __ml_GetValue ( media_library_t p_media_library,
ml_result_t p_result,
va_list  args 
) [inline, static]

Find a value in the ML database, fill p_result with it.

Parameters:
p_media_library Media library object
p_result Object to put result into
Args [ SelectType [ PersonType ] Value ] ... ML_END
Note:
Do not use this function directly.

References media_library_t::functions, media_library_t::pf_Find, vlc_array_count(), vlc_array_destroy(), vlc_array_item_at_index(), vlc_array_new(), and VLC_SUCCESS.

Referenced by __ml_GetInt(), and __ml_GetPsz().

ml_media_t* media_New ( media_library_t p_ml,
int  id,
ml_select_e  select,
bool  reload 
)

Object constructor for ml_media_t.

Parameters:
p_ml The media library object
id If 0, this item isn't in database. If non zero, it is and it will be a singleton
select Type of object
reload Whether to reload from database

References VLC_UNUSED.

static int ml_AttributeIsString ( ml_select_e  meta  )  [inline, static]
static int ml_ControlVa ( media_library_t p_media_library,
ml_control_e  i_type,
va_list  args 
) [inline, static]

Control the Media Library.

Parameters:
p_media_library the media library object
i_type one of ml_control_e values
See also:
ml_control_e.
Parameters:
... optional arguments.
Returns:
VLC_SUCCESS or an error

References media_library_t::functions, and media_library_t::pf_Control.

Referenced by __ml_Control().

static int ml_CopyMedia ( ml_media_t b,
ml_media_t a 
) [inline, static]
static int ml_CopyPersons ( ml_person_t **  a,
ml_person_t b 
) [inline, static]

Copy one person list into another.

Parameters:
a To list
b From list
Note:
On errors, you have to free any allocated persons yourself
This function is NOT threadsafe. Please ensure your medias are locked

References ml_CreateAppendPerson(), ml_person_t::p_next, and VLC_SUCCESS.

Referenced by ml_CopyMedia().

media_library_t* ml_Create ( vlc_object_t p_this,
char *  psz_name 
)

Create a Media Library VLC object.

Parameters:
p_this Parent to attach the ML object to.
psz_name Name for the module
Returns:
The ML object.

References VLC_UNUSED.

Referenced by libvlc_InternalInit().

static int ml_CreateAppendPerson ( ml_person_t **  pp_person,
ml_person_t p_personfrom 
) [inline, static]

Create and append a person object to the given list.

Parameters:
pp_person pointer to person list. Set the address to NULL to create a new list
personfrom Person object to copy from
Note:
Ignores the next variable and copies only the variables. Uses ml_CreateAppendPersonAdv
This function is NOT threadsafe

References ml_person_t::i_id, ml_CreateAppendPersonAdv(), ml_person_t::psz_name, and ml_person_t::psz_role.

Referenced by ml_CopyPersons().

static int ml_CreateAppendPersonAdv ( ml_person_t **  pp_person,
const char *  psz_role,
const char *  psz_name,
int  i_id 
) [inline, static]

Create and append a person object to the given list.

Parameters:
pp_person pointer to person list. Set the address to null to create new list
i_role The role of the person
psz_name The name string. Will be strdup'd
i_id The id in the database
Note:
This function is NOT thread safe. Please lock any associated media

References ml_person_t::psz_name, and strdup().

Referenced by ml_CreateAppendPerson().

static input_item_t* ml_CreateInputItem ( media_library_t p_media_library,
int  i_media_id 
) [inline, static]

Create input item from media.

Parameters:
p_media_library This ML instance.
i_media_id ID of the media to use to create an input_item.
Returns:
The media item.

References media_library_t::functions, and media_library_t::pf_InputItemFromMedia.

static int ml_Delete ( media_library_t p_media_library,
vlc_array_t p_array 
) [inline, static]

Delete many medias in the media library.

Parameters:
p_media_library Media library object
p_array Array of ids to delete
Returns:
VLC_SUCCESS or VLC_EGENERIC

References media_library_t::functions, and media_library_t::pf_Delete.

void ml_DeletePersonTypeFromMedia ( ml_media_t p_media,
const char *  psz_role 
)

Delete a certain type of people from a media.

Parameters:
p_media Media to delete from
i_type Type of person to delete
Note:
This function is threadsafe

References VLC_UNUSED.

static int ml_DeleteSimple ( media_library_t p_media_library,
int  id 
) [inline, static]

Generic DELETE function Delete a media and all its references which don't point to anything else.

Parameters:
p_media_library This media_library_t object
id the id of the media to delete
Returns:
VLC_SUCCESS or VLC_EGENERIC

References ml_element_t::criteria, media_library_t::functions, ml_element_t::i, media_library_t::pf_Delete, ml_element_t::value, vlc_array_append(), vlc_array_destroy(), and vlc_array_new().

void ml_Destroy ( vlc_object_t p_this  ) 

Destructor for the Media library singleton.

Parameters:
p_this Parent the ML object is attached to

References VLC_UNUSED.

Referenced by libvlc_InternalCleanup().

static void ml_DestroyResultArray ( vlc_array_t p_result_array  )  [inline, static]

Destroy a vlc_array_t of ml_result_t.

Parameters:
ml_result_array The result array to free
Note:
Frees all results and contents of the results

References ml_FreeResult(), vlc_array_count(), and vlc_array_item_at_index().

static int ml_FindAdv ( media_library_t p_media_library,
vlc_array_t p_result_array,
ml_select_e  result_type,
char *  psz_lvalue,
ml_ftree_t tree 
) [inline, static]

Search in the database according some criterias (threaded).

Parameters:
p_media_library the media library object
result_array a pointer to a result array
result_type type of data to retrieve
psz_lvalue This should contain any necessary lvalue/key for the given result_type. Used for ML_PEOPLE. Otherwise NULL
args parameters to select the data
Returns:
VLC_SUCCESS or an error

References media_library_t::functions, and media_library_t::pf_FindAdv.

static void ml_FreeElement ( ml_element_t p_elt  )  [inline, static]

Free a ml_element_t item.

Parameters:
p_find Find object to free
See also:
ml_element_t

References ml_element_t::criteria, ml_element_t::lvalue, ml_AttributeIsString(), ML_PEOPLE, ml_element_t::str, and ml_element_t::value.

static void ml_FreeMediaContent ( ml_media_t p_media  )  [inline, static]
static void ml_FreePeople ( ml_person_t p_person  )  [inline, static]

Free a person object.

Parameters:
p_media Person object to free
Note:
This function is NOT threadsafe

References ml_person_t::p_next, ml_person_t::psz_name, and ml_person_t::psz_role.

Referenced by ml_CopyMedia(), and ml_FreeMediaContent().

static void ml_FreeResult ( ml_result_t p_result  )  [inline, static]

Free a result item.

See also:
ml_result_t
Parameters:
p_result Result item to free
Note:
This will free any strings and decref medias.

References ml_gc_decref(), ML_TYPE_MEDIA, ML_TYPE_PSZ, ml_result_t::p_media, ml_result_t::psz, ml_result_t::type, and ml_result_t::value.

Referenced by ml_DestroyResultArray().

static ml_ftree_t* ml_FtreeFastAnd ( ml_ftree_t left,
ml_ftree_t right 
) [inline, static]

This function gives quick sequential adding capability.

Parameters:
left Tree to add to. This may be NULL
right Tree to append. May not be NULL
Returns:
Pointer to new tree.

References ml_FtreeHasOp(), ML_OP_AND, ML_OP_NONE, and ml_OpConnectChilds().

static int ml_FtreeHasOp ( ml_ftree_t tree  )  [inline, static]

Checks if a given find tree has leaf nodes.

Parameters:
Find tree
Returns:
Number of leaf nodes

References ml_ftree_t::criteria, ml_ftree_t::left, ML_OP_NONE, ml_ftree_t::op, and ml_ftree_t::right.

Referenced by ml_FtreeFastAnd().

ml_ftree_t* ml_FtreeSpec ( ml_ftree_t tree,
ml_select_e  crit,
int  limit,
char *  sort 
)

Attaches a special node to a tree.

Parameters:
tree Tree to attach special node to
crit Criteria may be SORT_ASC, SORT_DESC, LIMIT or DISTINCT
limit Limit used if LIMIT criteria used
Sort string used if SORT criteria is used
Returns:
Pointer to new tree
Note:
Use the helpers

References VLC_UNUSED.

static void ml_gc_decref ( ml_media_t p_media  )  [inline, static]

Decrease reference count of media.

Parameters:
p_media The media object

References ml_media_t::ml_gc_data, ml_gc_object_t::pf_destructor, ml_gc_object_t::pool, ml_gc_object_t::refs, ml_gc_object_t::spin, vlc_spin_destroy, vlc_spin_lock, and vlc_spin_unlock.

Referenced by ml_FreeResult().

static void ml_gc_incref ( ml_media_t p_media  )  [inline, static]

Increment reference count of media.

Parameters:
p_media The media object

References ml_media_t::ml_gc_data, ml_gc_object_t::refs, ml_gc_object_t::spin, vlc_spin_lock, and vlc_spin_unlock.

static void ml_GenericFreeFindTree ( ml_ftree_t tree,
bool  freestrings 
) [inline, static]

Free a find tree.

Parameters:
Find tree to free
true to free any associated strings, false to not free them

References ml_ftree_t::criteria, ml_ftree_t::left, ml_ftree_t::lvalue, ml_AttributeIsString(), ML_OP_NONE, ML_PEOPLE, ml_ftree_t::op, ml_ftree_t::right, ml_ftree_t::str, and ml_ftree_t::value.

media_library_t* ml_Get ( vlc_object_t p_this  ) 

Acquire a reference to the media library singleton.

Parameters:
p_this The object holding the media library
Returns:
The media library object. NULL if the media library object could not be loaded

References VLC_UNUSED.

ml_person_t* ml_GetPersonsFromMedia ( media_library_t p_ml,
ml_media_t p_media,
const char *  psz_role 
)

Returns a person list of given type.

Parameters:
p_ml The ML object
p_media The Media object
i_type The person type
Note:
This function is thread safe

References VLC_UNUSED.

ml_ftree_t* ml_OpConnectChilds ( ml_op_e  op,
ml_ftree_t left,
ml_ftree_t right 
)

Connect up a find tree.

Parameters:
op operator to connect with If op = ML_OP_NONE, then you are connecting to a tree consisting of only SPECIAL nodes. If op = ML_OP_NOT, then right MUST be NULL op must not be ML_OP_SPECIAL,
See also:
ml_FtreeSpec
Parameters:
left part of the tree
right part of the tree
Returns:
Pointer to new tree
Note:
Use the helpers!

References VLC_UNUSED.

Referenced by ml_FtreeFastAnd().

void ml_PlaySmartPlaylistBasedOn ( media_library_t p_ml,
ml_ftree_t p_tree 
)

Creates and adds the playlist based on a given find tree.

Parameters:
p_ml Media library object
p_tree Find tree to create SELECT

References VLC_UNUSED.

static int ml_Update ( media_library_t p_media_library,
ml_select_e  selected_type,
const char *  psz_lvalue,
ml_ftree_t where,
vlc_array_t changes 
) [inline, static]

Generic update in Media Library database.

Parameters:
p_media_library the media library object
selected_type the type of the element we're selecting
where list of ids/uris to be changed
changes list of changes to make in the entries
Returns:
VLC_SUCCESS or VLC_EGENERIC

References media_library_t::functions, and media_library_t::pf_Update.

int ml_UpdateSimple ( media_library_t p_media_library,
ml_select_e  selected_type,
const char *  psz_lvalue,
int  id,
  ... 
)

Update a given table.

Parameters:
p_media_library The media library object
selected_type The table to update
psz_lvalue The role of the person if selected_type = ML_PEOPLE
id The id of the row to update
... The update data. [SelectType [RoleType] Value]

References VLC_UNUSED.

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines