2004-05-30 22:25:08 +02:00
|
|
|
#include "inputPlugin.h"
|
|
|
|
|
|
|
|
#include "list.h"
|
2004-05-30 21:13:57 +02:00
|
|
|
|
|
|
|
#include <stdlib.h>
|
2004-05-30 22:25:08 +02:00
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
static List * inputPlugin_list = NULL;
|
2004-05-30 21:13:57 +02:00
|
|
|
|
2004-05-30 22:25:08 +02:00
|
|
|
void loadInputPlugin(InputPlugin * inputPlugin) {
|
2004-05-31 03:21:17 +02:00
|
|
|
if(!inputPlugin) return;
|
|
|
|
if(!inputPlugin->name) return;
|
|
|
|
|
2004-05-30 22:25:08 +02:00
|
|
|
insertInList(inputPlugin_list, inputPlugin->name, (void *)inputPlugin);
|
|
|
|
}
|
|
|
|
|
|
|
|
void unloadInputPlugin(InputPlugin * inputPlugin) {
|
|
|
|
deleteFromList(inputPlugin_list, inputPlugin->name);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int stringFoundInStringArray(char ** array, char * suffix) {
|
|
|
|
while(array && *array) {
|
|
|
|
if(strcmp(*array, suffix) == 0) return 1;
|
|
|
|
array++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
InputPlugin * getInputPluginFromSuffix(char * suffix) {
|
|
|
|
ListNode * node = inputPlugin_list->firstNode;
|
|
|
|
InputPlugin * plugin = NULL;
|
|
|
|
|
2004-05-31 03:21:17 +02:00
|
|
|
if(suffix == NULL) return NULL;
|
|
|
|
|
2004-05-30 22:25:08 +02:00
|
|
|
while(node != NULL) {
|
|
|
|
plugin = node->data;
|
|
|
|
if(stringFoundInStringArray(plugin->suffixes, suffix)) {
|
|
|
|
return plugin;
|
|
|
|
}
|
2004-05-31 03:21:17 +02:00
|
|
|
node = node->nextNode;
|
2004-05-30 22:25:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
InputPlugin * getInputPluginFromMimeType(char * mimeType) {
|
|
|
|
ListNode * node = inputPlugin_list->firstNode;
|
|
|
|
InputPlugin * plugin = NULL;
|
|
|
|
|
|
|
|
while(node != NULL) {
|
|
|
|
plugin = node->data;
|
|
|
|
if(stringFoundInStringArray(plugin->mimeTypes, mimeType)) {
|
|
|
|
return plugin;
|
|
|
|
}
|
2004-05-31 03:21:17 +02:00
|
|
|
node = node->nextNode;
|
2004-05-30 22:25:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
InputPlugin * getInputPluginFromName(char * name) {
|
|
|
|
void * plugin = NULL;
|
|
|
|
|
|
|
|
findInList(inputPlugin_list, name, &plugin);
|
|
|
|
|
|
|
|
return (InputPlugin *)plugin;
|
|
|
|
}
|
|
|
|
|
2004-05-31 03:21:17 +02:00
|
|
|
extern InputPlugin mp3Plugin;
|
|
|
|
extern InputPlugin oggPlugin;
|
2004-05-31 03:54:10 +02:00
|
|
|
extern InputPlugin flacPlugin;
|
2004-05-31 04:31:55 +02:00
|
|
|
extern InputPlugin audiofilePlugin;
|
2004-05-31 04:42:22 +02:00
|
|
|
extern InputPlugin mp4Plugin;
|
2004-05-31 05:30:09 +02:00
|
|
|
extern InputPlugin aacPlugin;
|
2004-05-31 03:21:17 +02:00
|
|
|
|
2004-05-30 22:25:08 +02:00
|
|
|
void initInputPlugins() {
|
2004-05-31 03:21:17 +02:00
|
|
|
inputPlugin_list = makeList(NULL);
|
2004-05-30 22:25:08 +02:00
|
|
|
|
|
|
|
/* load plugins here */
|
2004-05-31 03:21:17 +02:00
|
|
|
loadInputPlugin(&mp3Plugin);
|
|
|
|
loadInputPlugin(&oggPlugin);
|
2004-05-31 03:54:10 +02:00
|
|
|
loadInputPlugin(&flacPlugin);
|
2004-05-31 04:31:55 +02:00
|
|
|
loadInputPlugin(&audiofilePlugin);
|
2004-05-31 04:42:22 +02:00
|
|
|
loadInputPlugin(&mp4Plugin);
|
2004-05-31 05:30:09 +02:00
|
|
|
loadInputPlugin(&aacPlugin);
|
2004-05-30 22:25:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void finishInputPlugins() {
|
|
|
|
freeList(inputPlugin_list);
|
|
|
|
}
|