valhalla.h File Reference

#include <inttypes.h>

Go to the source code of this file.

Data Structures

struct  valhalla_db_item_t
 Main structure to search in the DB. More...
struct  valhalla_db_metares_t
 Results for valhalla_db_metalist_get(). More...
struct  valhalla_db_fileres_t
 Results for valhalla_db_filelist_get(). More...
struct  valhalla_db_restrict_t
 Restriction. More...
struct  valhalla_db_filemeta_t
 Results for valhalla_db_file_get(). More...

Defines

List of common metadata.

#define VALHALLA_METADATA_CATEGORY   "category"
#define VALHALLA_METADATA_EPISODE   "episode"
#define VALHALLA_METADATA_GENRE   "genre"
#define VALHALLA_METADATA_MPAA   "mpaa"
#define VALHALLA_METADATA_RUNTIME   "runtime"
#define VALHALLA_METADATA_SEASON   "season"
#define VALHALLA_METADATA_SYNOPSIS   "synopsis"
#define VALHALLA_METADATA_SYNOPSIS_SHOW   "synopsis_show"
#define VALHALLA_METADATA_BUDGET   "budget"
#define VALHALLA_METADATA_COUNTRY   "country"
#define VALHALLA_METADATA_REVENUE   "revenue"
#define VALHALLA_METADATA_STUDIO   "studio"
#define VALHALLA_METADATA_ACTOR   "actor"
#define VALHALLA_METADATA_ARTIST   "artist"
#define VALHALLA_METADATA_AUTHOR   "author"
#define VALHALLA_METADATA_CASTING   "casting"
#define VALHALLA_METADATA_COMPOSER   "composer"
#define VALHALLA_METADATA_CREDITS   "credits"
#define VALHALLA_METADATA_DIRECTOR   "director"
#define VALHALLA_METADATA_DIRECTOR_PHOTO   "director_photo"
#define VALHALLA_METADATA_EDITOR   "editor"
#define VALHALLA_METADATA_PRODUCER   "producer"
#define VALHALLA_METADATA_COVER   "cover"
#define VALHALLA_METADATA_COVER_SEASON   "cover_season"
#define VALHALLA_METADATA_COVER_SHOW   "cover_show"
#define VALHALLA_METADATA_COVER_SHOW_HEADER   "cover_show_header"
#define VALHALLA_METADATA_FAN_ART   "fanart"
#define VALHALLA_METADATA_LYRICS   "lyrics"
#define VALHALLA_METADATA_THUMBNAIL   "thumbnail"
#define VALHALLA_METADATA_TRACK   "track"
#define VALHALLA_METADATA_PLAY_COUNT   "playcount"
#define VALHALLA_METADATA_RATING   "rating"
#define VALHALLA_METADATA_WATCHED   "watched"
#define VALHALLA_METADATA_AUDIO_BITRATE   "audio_bitrate"
#define VALHALLA_METADATA_AUDIO_CHANNELS   "audio_channels"
#define VALHALLA_METADATA_AUDIO_CODEC   "audio_codec"
#define VALHALLA_METADATA_AUDIO_LANG   "audio_lang"
#define VALHALLA_METADATA_AUDIO_STREAMS   "audio_streams"
#define VALHALLA_METADATA_DURATION   "duration"
#define VALHALLA_METADATA_HEIGHT   "height"
#define VALHALLA_METADATA_PICTURE_ORIENTATION   "picture_orientation"
#define VALHALLA_METADATA_SUB_LANG   "sub_lang"
#define VALHALLA_METADATA_SUB_STREAMS   "sub_streams"
#define VALHALLA_METADATA_VIDEO_ASPECT   "video_aspect"
#define VALHALLA_METADATA_VIDEO_BITRATE   "video_bitrate"
#define VALHALLA_METADATA_VIDEO_CODEC   "video_codec"
#define VALHALLA_METADATA_VIDEO_STREAMS   "video_streams"
#define VALHALLA_METADATA_WIDTH   "width"
#define VALHALLA_METADATA_DATE   "date"
#define VALHALLA_METADATA_PREMIERED   "premiered"
#define VALHALLA_METADATA_YEAR   "year"
#define VALHALLA_METADATA_ALBUM   "album"
#define VALHALLA_METADATA_TITLE   "title"
#define VALHALLA_METADATA_TITLE_ALTERNATIVE   "title_alternative"
#define VALHALLA_METADATA_TITLE_SHOW   "title_show"
Macros for selection functions handling.

#define VALHALLA_DB_SEARCH_ID(meta_id, group)   VALHALLA_DB_SEARCH (meta_id, NULL, group, ID)
 Set valhalla_db_item_t local variable for an id.
#define VALHALLA_DB_SEARCH_TEXT(meta_name, group)   VALHALLA_DB_SEARCH (0, meta_name, group, TEXT)
 Set valhalla_db_item_t local variable for a text.
#define VALHALLA_DB_SEARCH_GRP(group)   VALHALLA_DB_SEARCH (0, NULL, group, GROUP)
 Set valhalla_db_item_t local variable for a group.
#define VALHALLA_DB_RESTRICT_INT(op, meta, data)   VALHALLA_DB_RESTRICT (op, meta, data, NULL, NULL, ID, ID)
 Set valhalla_db_restrict_t local variable for meta.id, data.id.
#define VALHALLA_DB_RESTRICT_STR(op, meta, data)   VALHALLA_DB_RESTRICT (op, 0, 0, meta, data, TEXT, TEXT)
 Set valhalla_db_restrict_t local variable for meta.text, data.text.
#define VALHALLA_DB_RESTRICT_INTSTR(op, meta, data)   VALHALLA_DB_RESTRICT (op, meta, 0, NULL, data, ID, TEXT)
 Set valhalla_db_restrict_t local variable for meta.id, data.text.
#define VALHALLA_DB_RESTRICT_STRINT(op, meta, data)   VALHALLA_DB_RESTRICT (op, 0, data, meta, NULL, TEXT, ID)
 Set valhalla_db_restrict_t local variable for meta.text, data.id.
#define VALHALLA_DB_RESTRICT_LINK(from, to)   do {(to).next = &(from);} while (0)
 Link two valhalla_db_restrict_t variables together.
#define VALHALLA_DB_FILEMETA_FREE(meta)
 Free a valhalla_db_filemeta_t pointer.

Typedefs

typedef struct valhalla_s valhalla_t
 Scanner handle.

Enumerations

enum  valhalla_errno
 

Error code returned by valhalla_run().

More...
enum  valhalla_verb_t {
  VALHALLA_MSG_NONE, VALHALLA_MSG_VERBOSE, VALHALLA_MSG_INFO, VALHALLA_MSG_WARNING,
  VALHALLA_MSG_ERROR, VALHALLA_MSG_CRITICAL
}
 

Verbosity level.

More...
enum  valhalla_dl_t
 

Destinations for downloading.

More...
enum  valhalla_event_t { VALHALLA_EVENT_PARSED = 0, VALHALLA_EVENT_GRABBED, VALHALLA_EVENT_ENDED }
 

Events for valhalla_ondemand() callback.

More...
enum  valhalla_meta_grp_t {
  VALHALLA_META_GRP_NIL = 0, VALHALLA_META_GRP_CLASSIFICATION, VALHALLA_META_GRP_COMMERCIAL, VALHALLA_META_GRP_CONTACT,
  VALHALLA_META_GRP_ENTITIES, VALHALLA_META_GRP_IDENTIFIER, VALHALLA_META_GRP_LEGAL, VALHALLA_META_GRP_MISCELLANEOUS,
  VALHALLA_META_GRP_MUSICAL, VALHALLA_META_GRP_ORGANIZATIONAL, VALHALLA_META_GRP_PERSONAL, VALHALLA_META_GRP_SPACIAL,
  VALHALLA_META_GRP_TECHNICAL, VALHALLA_META_GRP_TEMPORAL, VALHALLA_META_GRP_TITLES
}
 

Groups for metadata.

More...

Functions

Valhalla Handling.

valhalla_tvalhalla_init (const char *db, unsigned int parser_nb, int decrapifier, unsigned int commit_int, void(*od_cb)(const char *file, valhalla_event_t e, const char *id, void *data), void *od_data)
 Init a scanner and the database.
void valhalla_uninit (valhalla_t *handle)
 Uninit an handle.
void valhalla_verbosity (valhalla_verb_t level)
 Change verbosity level.
void valhalla_path_add (valhalla_t *handle, const char *location, int recursive)
 Add a path to the scanner.
void valhalla_suffix_add (valhalla_t *handle, const char *suffix)
 Add a file suffix for the scanner.
void valhalla_bl_keyword_add (valhalla_t *handle, const char *keyword)
 Add a keyword in the blacklist for the decrapifier.
void valhalla_downloader_dest_set (valhalla_t *handle, valhalla_dl_t dl, const char *dst)
 Set a destination for the downloader.
void valhalla_grabber_state_set (valhalla_t *handle, const char *id, int enable)
 Set the state of a grabber.
const char * valhalla_grabber_list_get (valhalla_t *handle, const char *id)
 Retrieve the ID of all grabbers compiled in Valhalla.
int valhalla_run (valhalla_t *handle, int loop, uint16_t timeout, int priority)
 Run the scanner, the database manager and all parsers.
void valhalla_wait (valhalla_t *handle)
 Wait until the scanning is finished.
void valhalla_scanner_wakeup (valhalla_t *handle)
 Force to wake up the scanner.
void valhalla_ondemand (valhalla_t *handle, const char *file)
 Force Valhalla to retrieve metadata on-demand for a file.
Database selections.

int valhalla_db_metalist_get (valhalla_t *handle, valhalla_db_item_t *search, valhalla_db_restrict_t *restriction, int(*result_cb)(void *data, valhalla_db_metares_t *res), void *data)
 Retrieve a list of metadata according to a condition.
int valhalla_db_filelist_get (valhalla_t *handle, valhalla_file_type_t filetype, valhalla_db_restrict_t *restriction, int(*result_cb)(void *data, valhalla_db_fileres_t *res), void *data)
 Retrieve a list of files.
int valhalla_db_file_get (valhalla_t *handle, int64_t id, const char *path, valhalla_db_restrict_t *restriction, valhalla_db_filemeta_t **res)
 Retrieve all metadata of a file.
Database insertions/updates/deletions.

With these functions, you can insert/update and delete metadata for a particular file (path). They should not be used to provide grabbing functionalities with the front-end (implement a grabber in Valhalla is the better way); but in some exceptional cases it can be necessary.

For example, you can use this functionality to write data like "playcount" or "last_position" (to replay a file from the last position).

int valhalla_db_metadata_insert (valhalla_t *handle, const char *path, const char *meta, const char *data, valhalla_meta_grp_t group)
 Insert an external metadata in the database.
int valhalla_db_metadata_update (valhalla_t *handle, const char *path, const char *meta, const char *data, const char *ndata)
 Update an external metadata in the database.
int valhalla_db_metadata_delete (valhalla_t *handle, const char *path, const char *meta, const char *data)
 Delete an external metadata in the database.

Detailed Description

GeeXboX Valhalla public API header.

Definition in file valhalla.h.


Define Documentation

#define VALHALLA_DB_FILEMETA_FREE ( meta   ) 
Value:
do {                                                   \
    typeof (meta) tmp;                                   \
    while (meta) {                                       \
      if ((meta)->meta_name)  free ((meta)->meta_name);  \
      if ((meta)->data_value) free ((meta)->data_value); \
      tmp = (meta)->next; free (meta); meta = tmp;}      \
  } while (0)

Free a valhalla_db_filemeta_t pointer.

Definition at line 629 of file valhalla.h.

#define VALHALLA_DB_RESTRICT_INT ( op,
meta,
data   )     VALHALLA_DB_RESTRICT (op, meta, data, NULL, NULL, ID, ID)

Set valhalla_db_restrict_t local variable for meta.id, data.id.

Definition at line 613 of file valhalla.h.

#define VALHALLA_DB_RESTRICT_INTSTR ( op,
meta,
data   )     VALHALLA_DB_RESTRICT (op, meta, 0, NULL, data, ID, TEXT)

Set valhalla_db_restrict_t local variable for meta.id, data.text.

Definition at line 619 of file valhalla.h.

#define VALHALLA_DB_RESTRICT_LINK ( from,
to   )     do {(to).next = &(from);} while (0)

Link two valhalla_db_restrict_t variables together.

Definition at line 625 of file valhalla.h.

#define VALHALLA_DB_RESTRICT_STR ( op,
meta,
data   )     VALHALLA_DB_RESTRICT (op, 0, 0, meta, data, TEXT, TEXT)

Set valhalla_db_restrict_t local variable for meta.text, data.text.

Definition at line 616 of file valhalla.h.

#define VALHALLA_DB_RESTRICT_STRINT ( op,
meta,
data   )     VALHALLA_DB_RESTRICT (op, 0, data, meta, NULL, TEXT, ID)

Set valhalla_db_restrict_t local variable for meta.text, data.id.

Definition at line 622 of file valhalla.h.

#define VALHALLA_DB_SEARCH_GRP ( group   )     VALHALLA_DB_SEARCH (0, NULL, group, GROUP)

Set valhalla_db_item_t local variable for a group.

Definition at line 609 of file valhalla.h.

#define VALHALLA_DB_SEARCH_ID ( meta_id,
group   )     VALHALLA_DB_SEARCH (meta_id, NULL, group, ID)

Set valhalla_db_item_t local variable for an id.

Definition at line 603 of file valhalla.h.

#define VALHALLA_DB_SEARCH_TEXT ( meta_name,
group   )     VALHALLA_DB_SEARCH (0, meta_name, group, TEXT)

Set valhalla_db_item_t local variable for a text.

Definition at line 606 of file valhalla.h.


Typedef Documentation

typedef struct valhalla_s valhalla_t

Scanner handle.

Definition at line 67 of file valhalla.h.


Enumeration Type Documentation

Destinations for downloading.

Definition at line 89 of file valhalla.h.

Error code returned by valhalla_run().

Definition at line 70 of file valhalla.h.

Events for valhalla_ondemand() callback.

Enumerator:
VALHALLA_EVENT_PARSED 

Parsed data available in DB.

VALHALLA_EVENT_GRABBED 

Grabbed data available in DB.

VALHALLA_EVENT_ENDED 

Nothing more (downloading included).

Definition at line 98 of file valhalla.h.

Groups for metadata.

Enumerator:
VALHALLA_META_GRP_NIL 

NULL value for a group attribution.

VALHALLA_META_GRP_CLASSIFICATION 

genre, mood, subject, synopsis, summary, description, keywords, mediatype, period, ...

VALHALLA_META_GRP_COMMERCIAL 

commercial, payment, purchase info, purchase price, purchase item, purchase owner, purchase currency, file owner, ...

VALHALLA_META_GRP_CONTACT 

url, email, address, phone, fax, ...

VALHALLA_META_GRP_ENTITIES 

artist, url, performer, accompaniment, band, ensemble, composer, arranger, lyricist, conductor, actor, character, author, director, producer, coproducer, executive producer, costume designer, label, choregrapher, sound engineer, production studio, publisher, ...

VALHALLA_META_GRP_IDENTIFIER 

isrc, mcdi, isbn, barcode, lccn, cdid, ufid, ...

VALHALLA_META_GRP_LEGAL 

copyright, terms of use, url, ownership, license, rights, ...

VALHALLA_META_GRP_MISCELLANEOUS 

user text, orig filename, picture, lyrics, ...

VALHALLA_META_GRP_MUSICAL 

bmp, measure, tunning, initial key, ...

VALHALLA_META_GRP_ORGANIZATIONAL 

track, disk, part number, track number, disc number, total tracks, total parts, ...

VALHALLA_META_GRP_PERSONAL 

comment, rating, play count, ...

VALHALLA_META_GRP_SPACIAL 

composition location, recording location, composer nationality, ...

VALHALLA_META_GRP_TECHNICAL 

encoder, playlist delay, buffer size, ...

VALHALLA_META_GRP_TEMPORAL 

date written, date recorded, date released, date digitized, date encoded, date tagged, date purchased, year, ...

VALHALLA_META_GRP_TITLES 

title, album, subtitle, title sort order, album sort order, part ...

Definition at line 365 of file valhalla.h.

Verbosity level.

Enumerator:
VALHALLA_MSG_NONE 

No error messages.

VALHALLA_MSG_VERBOSE 

Super-verbose mode: mostly for debugging.

VALHALLA_MSG_INFO 

Working operations.

VALHALLA_MSG_WARNING 

Harmless failures.

VALHALLA_MSG_ERROR 

May result in hazardous behavior.

VALHALLA_MSG_CRITICAL 

Prevents lib from working.

Definition at line 79 of file valhalla.h.


Function Documentation

void valhalla_bl_keyword_add ( valhalla_t handle,
const char *  keyword 
)

Add a keyword in the blacklist for the decrapifier.

This function is useful only if the decrapifier is enabled with valhalla_init().

The keywords are case insensitive except when a pattern (NUM, SE or EP) is used.

Available patterns (unsigned int):

  • NUM to trim a number
  • SE to trim and retrieve a "season" number (at least >= 1)
  • EP to trim and retrieve an "episode" number (at least >= 1)

NUM can be used several time in the same keyword, like "NUMxNUM". But SE and EP must be used only one time by keyword. When a season or an episode is found, a new metadata is added for each one.

Examples:

  • Blacklist : "xvid", "foobar", "fileNUM", "sSEeEP", "divx", "SExEP", "NumEP"
  • Filename : "{XvID-Foobar}.file01.My_Movie.s02e10.avi"
  • Result : "My Movie", season=2 and episode=10
  • Filename : "My_Movie_2.s02e10_(5x3)_.mkv"
  • Result : "My Movie 2", season=2, episode=10, season=5, episode=3
  • Filename : "The-Episode.-.Pilot_DivX.(01x01)_FooBar.mkv"
  • Result : "The Episode Pilot", season=1 and episode=1
  • Filename : "_Name_of_the_episode_Num05.ogg"
  • Result : "Name of the episode", episode=5

If the same keyword is added several times, only one is saved in the decrapifier.

Warning:
This function must be called before valhalla_run()!
Parameters:
[in] handle Handle on the scanner.
[in] keyword Keyword to blacklist.
int valhalla_db_file_get ( valhalla_t handle,
int64_t  id,
const char *  path,
valhalla_db_restrict_t restriction,
valhalla_db_filemeta_t **  res 
)

Retrieve all metadata of a file.

Only one parameter (id or path) must be set in order to retrieve a file. If both parameters are not null, then the path is ignored.

*res must be freed by VALHALLA_DB_FILEMETA_FREE().

Example (to retrieve only the track and the title):

  restriction_1 = VALHALLA_DB_RESTRICT_STR (EQUAL, "track", NULL);
  restriction_2 = VALHALLA_DB_RESTRICT_STR (EQUAL, "title", NULL);
  VALHALLA_DB_RESTRICT_LINK (restriction_2, restriction_1);

If several tracks and(or) titles are returned, you must use the group id in the result, in order to know what metadata is the right.

Parameters:
[in] handle Handle on the scanner.
[in] id File ID or 0.
[in] path Path or NULL.
[in] restriction Restrictions on the list of meta.
[out] res Pointer on the linked list to populate.
Returns:
!=0 on error.
int valhalla_db_filelist_get ( valhalla_t handle,
valhalla_file_type_t  filetype,
valhalla_db_restrict_t restriction,
int(*)(void *data, valhalla_db_fileres_t *res)  result_cb,
void *  data 
)

Retrieve a list of files.

It is possible to retrieve a list of files according to restrictions on metadata and values.

Example (to list all files of an author, without album):

  restriction_1 = VALHALLA_DB_RESTRICT_STR (IN, "author", "John Doe");
  restriction_2 = VALHALLA_DB_RESTRICT_STR (NOTIN, "album", NULL);
  VALHALLA_DB_RESTRICT_LINK (restriction_2, restriction_1);
Parameters:
[in] handle Handle on the scanner.
[in] filetype File type.
[in] restriction Restrictions on the list.
[out] result_cb Result callback.
[in,out] data Data for the first callback argument.
Returns:
!=0 on error.
int valhalla_db_metadata_delete ( valhalla_t handle,
const char *  path,
const char *  meta,
const char *  data 
)

Delete an external metadata in the database.

Only a metadata inserted or updated with valhalla_db_metadata_insert(), and valhalla_db_metadata_update() can be deleted with this function.

Please, refer to External Metadata.

Parameters:
[in] handle Handle on the scanner.
[in] path Path on the file.
[in] meta Meta name.
[in] data Data value.
Returns:
!=0 on error.
int valhalla_db_metadata_insert ( valhalla_t handle,
const char *  path,
const char *  meta,
const char *  data,
valhalla_meta_grp_t  group 
)

Insert an external metadata in the database.

When a metadata is inserted with this function, you must use valhalla_db_metadata_update() to change the value, else two metadata will be available (for both values).

If the metadata is already available in the database and the group passed with this function is not the same, then the insertion is canceled and no error is returned, else the 'external' flag is set to 1.

See also:
valhalla_db_metares_t
valhalla_db_filemeta_t

Please, refer to External Metadata.

Parameters:
[in] handle Handle on the scanner.
[in] path Path on the file.
[in] meta Meta name.
[in] data Data value.
[in] group Group.
Returns:
!=0 on error.
int valhalla_db_metadata_update ( valhalla_t handle,
const char *  path,
const char *  meta,
const char *  data,
const char *  ndata 
)

Update an external metadata in the database.

The previous data is necessary for Valhalla to identify the association for the update.

Please, refer to External Metadata.

Parameters:
[in] handle Handle on the scanner.
[in] path Path on the file.
[in] meta Meta name.
[in] data Current data value.
[in] ndata New data value.
Returns:
!=0 on error.
int valhalla_db_metalist_get ( valhalla_t handle,
valhalla_db_item_t search,
valhalla_db_restrict_t restriction,
int(*)(void *data, valhalla_db_metares_t *res)  result_cb,
void *  data 
)

Retrieve a list of metadata according to a condition.

It is possible to retrieve a list of metadata according to restrictions on metadata and values.

Example (to list all albums of an author):

  search      = VALHALLA_DB_SEARCH_TEXT ("album", TITLES);
  restriction = VALHALLA_DB_RESTRICT_STR (IN, "author", "John Doe");
Parameters:
[in] handle Handle on the scanner.
[in] search Condition for the search.
[in] restriction Restrictions on the list.
[out] result_cb Result callback.
[in,out] data Data for the first callback argument.
Returns:
!=0 on error.
void valhalla_downloader_dest_set ( valhalla_t handle,
valhalla_dl_t  dl,
const char *  dst 
)

Set a destination for the downloader.

The default destination is used when a specific destination is NULL. VALHALLA_DL_LAST is only used for internal purposes.

Warning:
This function must be called before valhalla_run()! There is no effect if the grabber support is not compiled.
Parameters:
[in] handle Handle on the scanner.
[in] dl Type of destination to set.
[in] dst Path for the destination.
const char* valhalla_grabber_list_get ( valhalla_t handle,
const char *  id 
)

Retrieve the ID of all grabbers compiled in Valhalla.

The function returns the ID after id, or the first grabber ID if id is NULL.

Warning:
This function must be called before valhalla_run()! There is no effect if the grabber support is not compiled.
Parameters:
[in] handle Handle on the scanner.
[in] id Grabber ID or NULL to retrieve the first.
Returns:
the next ID or NULL if id is the last (or on error).
void valhalla_grabber_state_set ( valhalla_t handle,
const char *  id,
int  enable 
)

Set the state of a grabber.

By default, all grabbers are enabled.

Warning:
This function must be called before valhalla_run()! There is no effect if the grabber support is not compiled.
Parameters:
[in] handle Handle on the scanner.
[in] id Grabber ID.
[in] enable 0 to disable, !=0 to enable.
valhalla_t* valhalla_init ( const char *  db,
unsigned int  parser_nb,
int  decrapifier,
unsigned int  commit_int,
void(*)(const char *file, valhalla_event_t e, const char *id, void *data)  od_cb,
void *  od_data 
)

Init a scanner and the database.

If a database already exists, then it is used. Otherwise, a new database is created to db. If more than one handles are created, you can't use the same database. You must specify a different db for each handle.

Several parsers (parser_nb) for metadata can be created in parallel.

If the "title" metadata is not available with a file, the decrapifier can be used to create this metadata by using the filename. This feature is very useful when the grabber support is compiled because the title is used as keywords in a lot of grabbers.

The interval for commit_int is the number of data to be inserted or updated in one pass. A value between 100 and 200 is a good choice. If the value is <=0, then the default interval is used (128).

Events

When od_cb is defined, an event is sent for each step with an on demand query. If an event arrives, the data are really inserted in the DB. The order for the events is not determinative, VALHALLA_EVENT_GRABBED can be sent before VALHALLA_EVENT_PARSED. VALHALLA_EVENT_GRABBED is sent for each grabber and id is its textual identifier (for example: "amazon", "exif", etc, ...). Only VALHALLA_EVENT_ENDED is always sent at the end, but this one has not a high priority unlike other events. If the file is already (fully) inserted in the DB, only VALHALLA_EVENT_ENDED is sent to the callback.

Parameters:
[in] db Path on the database.
[in] parser_nb Number of parsers to create.
[in] decrapifier Use the decrapifier, !=0 to enable.
[in] commit_int File Interval between database commits.
[in] od_cb Callback for ondemand, NULL to ignore.
[in] od_data User data for ondemand callback.
Returns:
The handle.
void valhalla_ondemand ( valhalla_t handle,
const char *  file 
)

Force Valhalla to retrieve metadata on-demand for a file.

This functionality can be used on files in/out of paths defined for the scanner. This function is non-blocked and it has the top priority over the files retrieved by the scanner.

Warning:
This function can be used only after valhalla_run()!
Parameters:
[in] handle Handle on the scanner.
[in] file Target.
void valhalla_path_add ( valhalla_t handle,
const char *  location,
int  recursive 
)

Add a path to the scanner.

At least one path must be added to the scanner, otherwise an error is returned by valhalla_run(). If the same path is added several times, only one is saved in the scanner.

Warning:
This function must be called before valhalla_run()!
Parameters:
[in] handle Handle on the scanner.
[in] location The path to be scanned.
[in] recursive 1 to scan all folders recursively, 0 otherwise.
int valhalla_run ( valhalla_t handle,
int  loop,
uint16_t  timeout,
int  priority 
)

Run the scanner, the database manager and all parsers.

The priority can be set to all thread especially to run the system in background with less priority. In the case of a user, you can change only for a lower priority.

  • 0 : normal priority (default)
  • 1 to 19 : lower priorities
  • -1 to -20 : higher priorities
Parameters:
[in] handle Handle on the scanner.
[in] loop Number of loops (<=0 for infinite).
[in] timeout Timeout between loops, 0 to disable [seconds].
[in] priority Priority set to all threads.
Returns:
0 for success and <0 on error (
See also:
enum valhalla_errno).
void valhalla_scanner_wakeup ( valhalla_t handle  ) 

Force to wake up the scanner.

If the scanner is sleeping, this function will wake up this one independently of the time (timeout) set with valhalla_run(). If the number of loops is already reached or if the scanner is already working, this function has no effect.

Warning:
This function can be used only after valhalla_run()!
Parameters:
[in] handle Handle on the scanner.
void valhalla_suffix_add ( valhalla_t handle,
const char *  suffix 
)

Add a file suffix for the scanner.

If no suffix is added to the scanner, then all files will be parsed by FFmpeg without exception and it can be very slow. It is highly recommanded to always set at least one suffix (file extension)! If the same suffix is added several times, only one is saved in the scanner. The suffixes are case insensitive.

Warning:
This function must be called before valhalla_run()!
Parameters:
[in] handle Handle on the scanner.
[in] suffix File suffix to add.
void valhalla_uninit ( valhalla_t handle  ) 

Uninit an handle.

If a scanner is running, this function stops immediatly all tasks before releasing all elements.

Parameters:
[in] handle Handle on the scanner.
void valhalla_verbosity ( valhalla_verb_t  level  ) 

Change verbosity level.

Default value is VALHALLA_MSG_INFO.

Warning:
This function can be called in anytime.
Parameters:
[in] level Level provided by valhalla_verb_t.
void valhalla_wait ( valhalla_t handle  ) 

Wait until the scanning is finished.

This function wait until the scanning is finished for all loops. If the number of loops is infinite, then this function will wait forever. You must not break this function with valhalla_uninit(), that is not safe! If you prefer stop the scanner even if it is not finished. In this case you must use _only_ valhalla_uninit().

Warning:
This function can be used only after valhalla_run()!
Parameters:
[in] handle Handle on the scanner.

Generated by  doxygen 1.6.2