summaryrefslogtreecommitdiffstats
path: root/libmpcodecs/dec_video.c
diff options
context:
space:
mode:
authoralex <alex@b3059339-0415-0410-9bf9-f77b7e298cf2>2002-11-11 17:28:41 +0000
committeralex <alex@b3059339-0415-0410-9bf9-f77b7e298cf2>2002-11-11 17:28:41 +0000
commit7ea0933b9e76b41e1063cfd702252f209ed7bea1 (patch)
treedeb7bd2c4f1ac56564a9262ae618c6b8c300ad79 /libmpcodecs/dec_video.c
parent3bc5ffa8f8fa58052343ee147ecd0871c51a5b8d (diff)
downloadmpv-7ea0933b9e76b41e1063cfd702252f209ed7bea1.tar.bz2
mpv-7ea0933b9e76b41e1063cfd702252f209ed7bea1.tar.xz
dlopen() support for ad and vd
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@8153 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libmpcodecs/dec_video.c')
-rw-r--r--libmpcodecs/dec_video.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/libmpcodecs/dec_video.c b/libmpcodecs/dec_video.c
index fd93031494..78758b2085 100644
--- a/libmpcodecs/dec_video.c
+++ b/libmpcodecs/dec_video.c
@@ -28,6 +28,10 @@
#include "dec_video.h"
+#ifdef DYNAMIC_PLUGINS
+#include <dlfcn.h>
+#endif
+
// ===================================================================
extern double video_time_usage;
@@ -134,6 +138,10 @@ void uninit_video(sh_video_t *sh_video){
if(!sh_video->inited) return;
mp_msg(MSGT_DECVIDEO,MSGL_V,MSGTR_UninitVideoStr,sh_video->codec->drv);
mpvdec->uninit(sh_video);
+#ifdef DYNAMIC_PLUGINS
+ if (sh_video->dec_handle)
+ dlclose(sh_video->dec_handle);
+#endif
vf_uninit_filter_chain(sh_video->vfilter);
sh_video->inited=0;
}
@@ -172,6 +180,38 @@ int init_video(sh_video_t *sh_video,char* codecname,char* vfm,int status){
// if(mpcodecs_vd_drivers[i]->info->id==sh_video->codec->driver) break;
if(!strcmp(mpcodecs_vd_drivers[i]->info->short_name,sh_video->codec->drv)) break;
mpvdec=mpcodecs_vd_drivers[i];
+#ifdef DYNAMIC_PLUGINS
+ if (!mpvdec)
+ {
+ /* try to open shared decoder plugin */
+ int buf_len;
+ char *buf;
+ vd_functions_t *funcs_sym;
+ vd_info_t *info_sym;
+
+ buf_len = strlen(LIBDIR)+strlen(sh_video->codec->drv)+16;
+ buf = malloc(buf_len);
+ if (!buf)
+ break;
+ snprintf(buf, buf_len, "%s/mplayer/vd_%s.so", LIBDIR, sh_video->codec->drv);
+ mp_msg(MSGT_DECVIDEO, MSGL_DBG2, "Trying to open external plugin: %s\n", buf);
+ sh_video->dec_handle = dlopen(buf, RTLD_LAZY);
+ if (!sh_video->dec_handle)
+ break;
+ snprintf(buf, buf_len, "mpcodecs_vd_%s", sh_video->codec->drv);
+ funcs_sym = dlsym(sh_video->dec_handle, buf);
+ if (!funcs_sym || !funcs_sym->info || !funcs_sym->init ||
+ !funcs_sym->uninit || !funcs_sym->control || !funcs_sym->decode)
+ break;
+ info_sym = funcs_sym->info;
+ if (strcmp(info_sym->short_name, sh_video->codec->drv))
+ break;
+ free(buf);
+ mpvdec = funcs_sym;
+ mp_msg(MSGT_DECVIDEO, MSGL_V, "Using external decoder plugin (%s/mplayer/vd_%s.so)!\n",
+ LIBDIR, sh_video->codec->drv);
+ }
+#endif
if(!mpvdec){ // driver not available (==compiled in)
mp_msg(MSGT_DECVIDEO,MSGL_WARN,MSGTR_VideoCodecFamilyNotAvailableStr,
sh_video->codec->name, sh_video->codec->drv);