]> git.sesse.net Git - vlc/blobdiff - modules/codec/realvideo.c
[Qt] Add an icon when dragging.
[vlc] / modules / codec / realvideo.c
old mode 100755 (executable)
new mode 100644 (file)
index 3ae9501..60e43fb
@@ -107,11 +107,6 @@ struct decoder_sys_t
 };
 
 int dll_type = 1;
-#ifdef WIN32
-const char *g_decode_path="plugins\\drv43260.dll";
-#else
-const char *g_decode_path="../lib/vlc/codec/drv4.so.6.0";
-#endif
 
 static unsigned long (*rvyuv_custom_message)(cmsg_data_t* ,void*);
 static unsigned long (*rvyuv_free)(void*);
@@ -123,6 +118,7 @@ static unsigned long WINAPI (*wrvyuv_free)(void*);
 static unsigned long WINAPI (*wrvyuv_init)(void*, void*); // initdata,context
 static unsigned long WINAPI (*wrvyuv_transform)(char*, char*,transform_in_t*,unsigned int*,void*);
 #endif
+
 /*****************************************************************************
  * Module descriptor
  *****************************************************************************/
@@ -132,13 +128,13 @@ static void Close( vlc_object_t * );
 //static int  OpenPacketizer( vlc_object_t * );
 static picture_t *DecodeVideo( decoder_t *, block_t ** );
 
-vlc_module_begin();
-    set_description( N_("RealVideo library decoder") );
-    set_capability( "decoder", 10 );
-    set_category( CAT_INPUT );
-    set_subcategory( SUBCAT_INPUT_VCODEC );
-    set_callbacks( Open, Close );
-vlc_module_end();
+vlc_module_begin ()
+    set_description( N_("RealVideo library decoder") )
+    set_capability( "decoder", 10 )
+    set_category( CAT_INPUT )
+    set_subcategory( SUBCAT_INPUT_VCODEC )
+    set_callbacks( Open, Close )
+vlc_module_end ()
 
 
 /*****************************************************************************
@@ -207,12 +203,15 @@ static void * load_syms_linux(decoder_t *p_dec, const char *path)
 }
 #endif
 
+static vlc_mutex_t rm_mutex = VLC_STATIC_MUTEX;
+
 static int InitVideo(decoder_t *p_dec)
 {
     int result;
     struct rv_init_t init_data;
     char fcc[4];
-    vlc_mutex_t  *lock;
+    char *g_decode_path;
+
     int  i_vide = p_dec->fmt_in.i_extra;
     unsigned int *p_vide = p_dec->fmt_in.p_extra;
     decoder_sys_t *p_sys = malloc( sizeof( decoder_sys_t ) );
@@ -245,23 +244,73 @@ static int InitVideo(decoder_t *p_dec)
     init_data.subformat = (unsigned int*)p_vide[0];
     init_data.unk5 = 1;
     init_data.format = (unsigned int*)p_vide[1];
-    
+
     /* first try to load linux dlls, if failed and we're supporting win32 dlls,
        then try to load the windows ones */
+    bool b_so_opened = false;
+
 #ifdef WIN32
-    if ( NULL== (p_sys->rv_handle = load_syms(p_dec, g_decode_path)) )
+    g_decode_path="plugins\\drv43260.dll";
+
+    if( (p_sys->rv_handle = load_syms(p_dec, g_decode_path)) )
+        b_so_opened = true;
 #else
-    if ( NULL== (p_sys->rv_handle = load_syms_linux(p_dec, g_decode_path)) )
+    static const char psz_paths[] =
+    {
+        "/usr/lib/win32\0"
+        "/usr/lib/codecs\0"
+        "/usr/local/RealPlayer8/Codecs\0"
+        "/usr/RealPlayer8/Codecs\0"
+        "/usr/lib/RealPlayer8/Codecs\0"
+        "/opt/RealPlayer8/Codecs\0"
+        "/usr/lib/RealPlayer9/users/Real/Codecs\0"
+        "/usr/lib/RealPlayer10/codecs\0"
+        "/usr/lib/RealPlayer10GOLD/codecs\0"
+        "/usr/lib/helix/player/codecs\0"
+        "/usr/lib64/RealPlayer8/Codecs\0"
+        "/usr/lib64/RealPlayer9/users/Real/Codecs\0"
+        "/usr/lib64/RealPlayer10/codecs\0"
+        "/usr/lib64/RealPlayer10GOLD/codecs\0"
+        "/usr/local/lib/codecs\0"
+        "\0"
+    };
+
+    for( size_t i = 0; psz_paths[i]; i += strlen( psz_paths + i ) + 1 )
+    {
+        if( asprintf( &g_decode_path, "%s/drv4.so.6.0", psz_paths + i ) != -1 )
+        {
+            p_sys->rv_handle = load_syms_linux(p_dec, g_decode_path);
+            free( g_decode_path );
+        }
+        if( p_sys->rv_handle )
+        {
+            b_so_opened = true;
+            break;
+        }
+
+        if( asprintf( &g_decode_path, "%s/drv3.so.6.0", psz_paths + i ) != -1 )
+        {
+            p_sys->rv_handle = load_syms_linux(p_dec, g_decode_path);
+            free( g_decode_path );
+        }
+        if( p_sys->rv_handle )
+        {
+            b_so_opened = true;
+            break;
+        }
+
+        msg_Dbg( p_dec, "Cannot load real decoder library: %s", g_decode_path);
+    }
 #endif
+
+    if(!b_so_opened )
     {
-        msg_Err( p_dec, "Cannot load real decoder library: %s",  g_decode_path);
+        msg_Err( p_dec, "Cannot any real decoder library" );
         free( p_sys );
         return VLC_EGENERIC;
     }
 
-    lock = var_AcquireMutex( "rm_mutex" );
-    if ( lock == NULL )
-        return VLC_EGENERIC;
+    vlc_mutex_lock( &rm_mutex );
 
     p_sys->handle=NULL;
     #ifdef WIN32
@@ -308,7 +357,7 @@ static int InitVideo(decoder_t *p_dec)
     p_dec->fmt_out.video.i_aspect = VOUT_ASPECT_FACTOR * p_dec->fmt_in.video.i_width / p_dec->fmt_in.video.i_height;
     p_sys->inited = 0;
 
-    vlc_mutex_unlock( lock );
+    vlc_mutex_unlock( &rm_mutex );
     return VLC_SUCCESS;
 }
 
@@ -347,10 +396,9 @@ static void Close( vlc_object_t *p_this )
 {
     decoder_t     *p_dec = (decoder_t*)p_this;
     decoder_sys_t *p_sys = p_dec->p_sys;
-    vlc_mutex_t   *lock;
 
     /* get lock, avoid segfault */
-    lock = var_AcquireMutex( "rm_mutex" );
+    vlc_mutex_lock( &rm_mutex );
 
     #ifdef WIN32
     if (dll_type == 1)
@@ -385,8 +433,7 @@ static void Close( vlc_object_t *p_this )
 #endif
     p_sys->inited = 0;
 
-    if ( lock )
-    vlc_mutex_unlock( lock );
+    vlc_mutex_unlock( &rm_mutex );
 
     if ( p_sys )
         free( p_sys );
@@ -398,7 +445,6 @@ static void Close( vlc_object_t *p_this )
 static picture_t *DecodeVideo( decoder_t *p_dec, block_t **pp_block )
 {
     decoder_sys_t *p_sys = p_dec->p_sys;
-    vlc_mutex_t   *lock;
     block_t       *p_block;
     picture_t     *p_pic;
     mtime_t       i_pts;
@@ -415,11 +461,9 @@ static picture_t *DecodeVideo( decoder_t *p_dec, block_t **pp_block )
 
     i_pts = p_block->i_pts ? p_block->i_pts : p_block->i_dts;
 
-    lock = var_AcquireMutex( "rm_mutex" );
-    if ( lock == NULL )
-        return NULL;
+    vlc_mutex_lock( &rm_mutex );
 
-    p_pic = p_dec->pf_vout_buffer_new( p_dec );
+    p_pic = decoder_NewPicture( p_dec );
 
     if ( p_pic )
     {
@@ -509,7 +553,7 @@ static picture_t *DecodeVideo( decoder_t *p_dec, block_t **pp_block )
         p_pic->b_force = 1;
     }
 
-    vlc_mutex_unlock( lock );
+    vlc_mutex_unlock( &rm_mutex );
 
     block_Release( p_block );
     return p_pic;