Plugins-API

Plugins should implement the following call that provides required callbacks (see lightmediascanner_plugin.h):

    struct lms_plugin *lms_plugin_open(void)

where:

    struct lms_plugin {
       const char *name;
       lms_plugin_match_fn_t match;
       lms_plugin_parse_fn_t parse;
       lms_plugin_close_fn_t close;
       lms_plugin_setup_fn_t setup;
       lms_plugin_start_fn_t start;
       lms_plugin_finish_fn_t finish;
    };

Users can add their own data to the end of this data structure. Callbacks and their meanings are:

    void *match(lms_plugin_t *p,
                const char *path,
                int len,
                int base)

Given the file 'path' of 'len' bytes, with base name starting at 'base' bytes offset inside 'path', return a match. Non-NULL values means it matched, and this return will be given to parse() function so any match-time analysis can be reused. This function will be used in the slave process.

    int parse(lms_plugin_t *p,
              struct lms_context *ctxt,
              const struct lms_file_info *finfo,
              void *match)

Given the parsing context 'ctxt' (contains DB connection, charset conversion pointers and possible more), parse the file information 'finfo' using the previously matched data 'match'. This should return 0 on success or other value for errors. This will be used in the slave process.

    int close(lms_plugin_t *p)

Closes the plugin returned by lms_plugin_open(), this will run on the master process.

    int setup(lms_plugin_t *p, struct lms_context *ctxt)

Prepare parser to be executed. This is the first phase of plugin initialization on the slave process, it should create database tables and like, after this function is called, no database schema changes are allowed!

    int start(lms_plugin_t *p, struct lms_context *ctxt)

This is the second phase of plugin initialization on the slave process. At this point, all database tables should exist and database schema will not be changed anymore, so one can use this phase to compile SQL statements for future use.

    int finish(lms_plugin_t *p, struct lms_context *ctxt)

Finishes the plugin on slave process.

Although LMS doesn't place any restrictions on what plugins can do and how they store information, it's good to have standard tables and easy way to store data on them. For this task we provide lightmediascanner_db.h with functions to add audios, images, videos, playlists and possible more. Use should be pretty straightforward, see existing plugins to see usage examples.


Generated on Thu Dec 13 02:04:05 2007 for Light Media Scanner by  doxygen 1.5.2