VLC  2.1.0-git
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | 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...

Macros

#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.

Macro Definition Documentation

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

Control the Media Library.

Parameters
i_typeone 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,
 
)    ml_FindAdv( a, b, ML_ALBUM, NULL, c )
#define ml_FindAllAlbums (   a,
 
)    ml_FindAlbum( a, b, ML_DISTINCT )
#define ml_FindAllArtists (   a,
 
)    ml_FindArtist( a, b, ML_DISTINCT )
#define ml_FindAllGenres (   a,
 
)    ml_FindGenre( a, b, ML_DISTINCT )
#define ml_FindAllMedias (   a,
 
)    ml_FindMedia( a, b, ML_DISTINCT )
#define ml_FindAllOriginalTitles (   a,
 
)    ml_FindOriginalTitle( a, b, ML_DISTINCT )
#define ml_FindAllPublishers (   a,
  b,
  ... 
)    ml_FindPublisher( a, b, ML_DISTINCT )
#define ml_FindAllTitles (   a,
 
)    ml_FindTitle( a, b, ML_DISTINCT )
#define ml_FindAllTypes (   a,
 
)    ml_FindType( a, b, ML_DISTINCT )
#define ml_FindAllUris (   a,
 
)    ml_FindUri( a, b, ML_DISTINCT )
#define ml_FindAllYears (   a,
 
)    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,
 
)    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,
 
)    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,
 
)    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,
 
)    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,
 
)    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_librarythe media library object
va_argsparameters 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,
 
)    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,
 
)    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,
 
)    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,
 
)    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,
 
)    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,
 
)    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,
 
)    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,
 
)    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,
 
)    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,
 
)    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,
 
)    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_librarythe media library object
va_argsparameters 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,
 
)    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,
 
)    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 *)(((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,
  ... 
)
inlinestatic

References ml_ControlVa().

static int __ml_Find ( media_library_t p_media_library,
vlc_array_t p_result_array,
  ... 
)
inlinestatic

Search in the database according some criterias.

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

References media_library_t::functions, and media_library_t::pf_Find.

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

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

Parameters
p_media_libraryMedia library object
p_resultObject to put result into
Args[ SelectType [ PersonType ] Value ] ... ML_END
Note
Do not use this function directly.

< No error

< Unspecified error

References media_library_t::functions, media_library_t::pf_Find, vlc_array_count(), vlc_array_destroy(), vlc_array_item_at_index(), vlc_array_new(), VLC_EGENERIC, 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_mlThe media library object
idIf 0, this item isn't in database. If non zero, it is and it will be a singleton
selectType of object
reloadWhether to reload from database

References VLC_UNUSED.

static int ml_AttributeIsString ( ml_select_e  meta)
inlinestatic
static int ml_ControlVa ( media_library_t p_media_library,
ml_control_e  i_type,
va_list  args 
)
inlinestatic

Control the Media Library.

Parameters
p_media_librarythe media library object
i_typeone 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 
)
inlinestatic
static int ml_CopyPersons ( ml_person_t **  a,
ml_person_t b 
)
inlinestatic

Copy one person list into another.

Parameters
aTo list
bFrom list
Note
On errors, you have to free any allocated persons yourself
This function is NOT threadsafe. Please ensure your medias are locked

< No error

< No error

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_thisParent to attach the ML object to.
psz_nameName for the module
Returns
The ML object.

Referenced by libvlc_InternalInit().

static int ml_CreateAppendPerson ( ml_person_t **  pp_person,
ml_person_t p_personfrom 
)
inlinestatic

Create and append a person object to the given list.

Parameters
pp_personpointer to person list. Set the address to NULL to create a new list
personfromPerson 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 
)
inlinestatic

Create and append a person object to the given list.

Parameters
pp_personpointer to person list. Set the address to null to create new list
i_roleThe role of the person
psz_nameThe name string. Will be strdup'd
i_idThe id in the database
Note
This function is NOT thread safe. Please lock any associated media

< No error

< Unspecified error

< No error

References psz_name, ml_person_t::psz_name, strdup(), VLC_EGENERIC, and VLC_SUCCESS.

Referenced by ml_CreateAppendPerson().

static input_item_t* ml_CreateInputItem ( media_library_t p_media_library,
int  i_media_id 
)
inlinestatic

Create input item from media.

Parameters
p_media_libraryThis ML instance.
i_media_idID 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 
)
inlinestatic

Delete many medias in the media library.

Parameters
p_media_libraryMedia library object
p_arrayArray 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_mediaMedia to delete from
i_typeType of person to delete
Note
This function is threadsafe

References VLC_UNUSED.

static int ml_DeleteSimple ( media_library_t p_media_library,
int  id 
)
inlinestatic

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

Parameters
p_media_libraryThis media_library_t object
idthe 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, ML_ID, 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_thisParent the ML object is attached to

Referenced by libvlc_InternalCleanup().

static void ml_DestroyResultArray ( vlc_array_t p_result_array)
inlinestatic

Destroy a vlc_array_t of ml_result_t.

Parameters
ml_result_arrayThe 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 
)
inlinestatic

Search in the database according some criterias (threaded)

Parameters
p_media_librarythe media library object
result_arraya pointer to a result array
result_typetype of data to retrieve
psz_lvalueThis should contain any necessary lvalue/key for the given result_type. Used for ML_PEOPLE. Otherwise NULL
argsparameters 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)
inlinestatic
static void ml_FreeMediaContent ( ml_media_t p_media)
inlinestatic
static void ml_FreePeople ( ml_person_t p_person)
inlinestatic

Free a person object.

Parameters
p_mediaPerson 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)
inlinestatic

Free a result item.

See Also
ml_result_t
Parameters
p_resultResult 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 
)
inlinestatic

This function gives quick sequential adding capability.

Parameters
leftTree to add to. This may be NULL
rightTree 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)
inlinestatic

Checks if a given find tree has leaf nodes.

Parameters
Findtree
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
treeTree to attach special node to
critCriteria may be SORT_ASC, SORT_DESC, LIMIT or DISTINCT
limitLimit used if LIMIT criteria used
Sortstring 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)
inlinestatic

Decrease reference count of media.

Parameters
p_mediaThe media object

References ml_media_t::ml_gc_data, ml_gc_object_t::pf_destructor, ml_gc_object_t::pool, and ml_gc_object_t::refs.

Referenced by ml_FreeResult().

static void ml_gc_incref ( ml_media_t p_media)
inlinestatic

Increment reference count of media.

Parameters
p_mediaThe media object

References ml_media_t::ml_gc_data, and ml_gc_object_t::refs.

static void ml_GenericFreeFindTree ( ml_ftree_t tree,
bool  freestrings 
)
inlinestatic

Free a find tree.

Parameters
Findtree to free
trueto 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_thisThe object holding the media library
Returns
The media library object. NULL if the media library object could not be loaded
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_mlThe ML object
p_mediaThe Media object
i_typeThe 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
opoperator 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
leftpart of the tree
rightpart of the tree
Returns
Pointer to new tree
Note
Use the helpers!

References VLC_UNUSED.

Referenced by ml_FtreeFastAnd().

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 
)
inlinestatic

Generic update in Media Library database.

Parameters
p_media_librarythe media library object
selected_typethe type of the element we're selecting
wherelist of ids/uris to be changed
changeslist 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_libraryThe media library object
selected_typeThe table to update
psz_lvalueThe role of the person if selected_type = ML_PEOPLE
idThe id of the row to update
...The update data. [SelectType [RoleType] Value]