Skip to content

Commit

Permalink
Plugin auto installer
Browse files Browse the repository at this point in the history
This add support for plugins to register URI-prefixes and file magic matching
that will make Movian automatically install plugins if needed.

Can be turned off in settings
  • Loading branch information
andoma committed Aug 16, 2016
1 parent 4aa5607 commit 1bbd75f
Show file tree
Hide file tree
Showing 6 changed files with 385 additions and 14 deletions.
25 changes: 17 additions & 8 deletions src/backend/backend.c
Expand Up @@ -36,6 +36,9 @@
#include "media/media.h"
#include "misc/minmax.h"

#if ENABLE_PLUGINS
#include "plugins.h"
#endif

prop_t *global_sources; // Move someplace else

Expand Down Expand Up @@ -550,6 +553,7 @@ static backend_t be_videoparams = {
BE_REGISTER(videoparams);



/**
*
*/
Expand All @@ -559,6 +563,10 @@ backend_open(prop_t *page, const char *url, int sync)
backend_t *be;
char urlbuf[URL_MAX];

#if ENABLE_PLUGINS
plugin_check_prefix_for_autoinstall(url);
#endif

hts_lwmutex_lock(&dyanamic_backends_mutex);
LIST_FOREACH(be, &dynamic_backends, be_global_link) {
if(mystrbegins(url, be->be_prefix)) {
Expand Down Expand Up @@ -591,17 +599,18 @@ backend_open(prop_t *page, const char *url, int sync)

be = backend_canhandle(url);

if(be == NULL)
return 1;
if(be != NULL) {
if(be->be_normalize != NULL &&
!be->be_normalize(url, urlbuf, sizeof(urlbuf)))
url = urlbuf;

if(be->be_normalize != NULL &&
!be->be_normalize(url, urlbuf, sizeof(urlbuf)))
url = urlbuf;
prop_set(page, "url", PROP_SET_STRING, url);

prop_set(page, "url", PROP_SET_STRING, url);
be->be_open(page, url, sync);
return 0;
}

be->be_open(page, url, sync);
return 0;
return 1;
}


Expand Down
12 changes: 10 additions & 2 deletions src/fileaccess/fa_audio.c
Expand Up @@ -40,6 +40,10 @@
#include "usage.h"
#include "backend/backend.h"

#if ENABLE_PLUGINS
#include "plugins.h"
#endif

#if ENABLE_VMIR
#include "np/np.h"
#endif
Expand Down Expand Up @@ -131,7 +135,7 @@ be_file_playaudio(const char *url, media_pipe_t *mp,
media_codec_t *cw;
event_t *e;
int registered_play = 0;
uint8_t pb[128];
uint8_t pb[4096];
size_t psiz;

mp->mp_seek_base = 0;
Expand All @@ -142,7 +146,7 @@ be_file_playaudio(const char *url, media_pipe_t *mp,


psiz = fa_read(fh, pb, sizeof(pb));
if(psiz < sizeof(pb)) {
if(psiz < 128) {
fa_close(fh);
snprintf(errbuf, errlen, "File too small");
return NULL;
Expand All @@ -152,6 +156,10 @@ be_file_playaudio(const char *url, media_pipe_t *mp,
// ZIP File
return audio_play_zipfile(fh, mp, errbuf, errlen, hold);

#if ENABLE_PLUGINS
plugin_probe_for_autoinstall(fh, pb, psiz, url);
#endif

#if ENABLE_VMIR
metadata_t *md = metadata_create();
if(np_fa_probe(fh, pb, psiz, md, url) == 0) {
Expand Down
14 changes: 11 additions & 3 deletions src/fileaccess/fa_probe.c
Expand Up @@ -47,6 +47,10 @@
#include "np/np.h"
#endif

#if ENABLE_PLUGINS
#include "plugins.h"
#endif

/**
*
*/
Expand Down Expand Up @@ -560,17 +564,21 @@ fa_probe_metadata(const char *url, char *errbuf, size_t errsize,

metadata_t *md = metadata_create();

uint8_t buf[1025];

uint8_t buf[4097];
int l = fa_read(fh, buf, sizeof(buf) - 1);
if(l > 0) {
buf[l] = 0;

#if ENABLE_PLUGINS
plugin_probe_for_autoinstall(fh, buf, l, url);
#endif

#if ENABLE_VMIR
if(np_fa_probe(fh, buf, l, md, url) == 0) {
fa_close_with_park(fh, park);
return md;
}
#endif
buf[l] = 0;
if(fa_probe_header(md, url, fh, filename, buf, l)) {
fa_close_with_park(fh, park);
return md;
Expand Down
2 changes: 2 additions & 0 deletions src/np/np_fs.c
Expand Up @@ -103,6 +103,8 @@ np_fs_open(void *opaque, const char *path,
if(flags & VMIR_FS_OPEN_APPEND) {
myflags |= FA_APPEND;
}
} else {
myflags |= FA_BUFFERED_BIG;
}

fa_handle_t *f = fa_open_ex(path, NULL, 0, myflags, NULL);
Expand Down

0 comments on commit 1bbd75f

Please sign in to comment.