]> git.sesse.net Git - vlc/blobdiff - modules/video_filter/rss.c
Qt4 - Basic implementation of the extensions. Seem to work :D Just .avi now, because...
[vlc] / modules / video_filter / rss.c
index 02a97fdba6fdb551d7d8d838fdbafabd4e2cb0c8..c7874672e9ce5426e51c36e701513148b5a62382 100644 (file)
  * Preamble
  *****************************************************************************/
 
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
 #include <vlc/vlc.h>
 #include <vlc_vout.h>
 
@@ -178,7 +182,7 @@ static const char *ppsz_title_modes[] =
  * Module descriptor
  *****************************************************************************/
 vlc_module_begin();
-    set_capability( "sub filter", 0 );
+    set_capability( "sub filter", 1 );
     set_shortname( "RSS / Atom" );
     set_callbacks( CreateFilter, DestroyFilter );
     set_category( CAT_VIDEO );
@@ -186,9 +190,9 @@ vlc_module_begin();
     add_string( CFG_PREFIX "urls", "rss", NULL, MSG_TEXT, MSG_LONGTEXT, VLC_FALSE );
 
     set_section( N_("Position"), NULL );
-    add_integer( CFG_PREFIX "x", -1, NULL, POSX_TEXT, POSX_LONGTEXT, VLC_TRUE );
+    add_integer( CFG_PREFIX "x", 0, NULL, POSX_TEXT, POSX_LONGTEXT, VLC_TRUE );
     add_integer( CFG_PREFIX "y", 0, NULL, POSY_TEXT, POSY_LONGTEXT, VLC_TRUE );
-    add_integer( CFG_PREFIX "position", 5, NULL, POS_TEXT, POS_LONGTEXT, VLC_FALSE );
+    add_integer( CFG_PREFIX "position", -1, NULL, POS_TEXT, POS_LONGTEXT, VLC_FALSE );
         change_integer_list( pi_pos_values, ppsz_pos_descriptions, 0 );
 
     set_section( N_("Font"), NULL );
@@ -254,10 +258,28 @@ static int CreateFilter( vlc_object_t *p_this )
     p_sys->i_length = var_CreateGetInteger( p_filter, CFG_PREFIX "length" );
     p_sys->i_ttl = __MAX( 0, var_CreateGetInteger( p_filter, CFG_PREFIX "ttl" ) );
     p_sys->b_images = var_CreateGetBool( p_filter, CFG_PREFIX "images" );
+
     p_sys->psz_marquee = (char *)malloc( p_sys->i_length + 1 );
+    if( p_sys->psz_marquee == NULL )
+    {
+        msg_Err( p_filter, "out of memory" );
+        vlc_mutex_unlock( &p_sys->lock );
+        vlc_mutex_destroy( &p_sys->lock );
+        free( p_sys );
+        return VLC_ENOMEM;
+    }
     p_sys->psz_marquee[p_sys->i_length] = '\0';
 
     p_sys->p_style = malloc( sizeof( text_style_t ));
+    if( p_sys->p_style == NULL )
+    {
+        msg_Err( p_filter, "out of memory" );
+        free( p_sys->psz_marquee );
+        vlc_mutex_unlock( &p_sys->lock );
+        vlc_mutex_destroy( &p_sys->lock );
+        free( p_sys );
+        return VLC_ENOMEM;
+    }
     memcpy( p_sys->p_style, &default_text_style, sizeof( text_style_t ));
 
     p_sys->i_xoff = var_CreateGetInteger( p_filter, CFG_PREFIX "x" );
@@ -275,23 +297,37 @@ static int CreateFilter( vlc_object_t *p_this )
     if( FetchRSS( p_filter ) )
     {
         msg_Err( p_filter, "failed while fetching RSS ... too bad" );
+        free( p_sys->p_style );
+        free( p_sys->psz_marquee );
         vlc_mutex_unlock( &p_sys->lock );
+        vlc_mutex_destroy( &p_sys->lock );
+        free( p_sys );
         return VLC_EGENERIC;
     }
     p_sys->t_last_update = time( NULL );
 
     if( p_sys->i_feeds == 0 )
     {
+        free( p_sys->p_style );
+        free( p_sys->psz_marquee );
         vlc_mutex_unlock( &p_sys->lock );
+        vlc_mutex_destroy( &p_sys->lock );
+        free( p_sys );
         return VLC_EGENERIC;
     }
     for( i_feed=0; i_feed < p_sys->i_feeds; i_feed ++ )
+    {
         if( p_sys->p_feeds[i_feed].i_items == 0 )
         {
+            free( p_sys->p_style );
+            free( p_sys->psz_marquee );
+            FreeRSS( p_filter );
             vlc_mutex_unlock( &p_sys->lock );
+            vlc_mutex_destroy( &p_sys->lock );
+            free( p_sys );
             return VLC_EGENERIC;
         }
-
+    }
     /* Misc init */
     p_filter->pf_sub_filter = Filter;
     p_sys->last_date = (mtime_t)0;
@@ -478,20 +514,19 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t date )
     p_spu->b_ephemer = VLC_TRUE;
 
     /*  where to locate the string: */
-    if( p_sys->i_xoff < 0 || p_sys->i_yoff < 0 )
+    if( p_sys->i_pos < 0 )
+    {   /*  set to an absolute xy */
+        p_spu->p_region->i_align = OSD_ALIGN_LEFT | OSD_ALIGN_TOP;
+        p_spu->b_absolute = VLC_TRUE;
+    }
+    else
     {   /* set to one of the 9 relative locations */
         p_spu->p_region->i_align = p_sys->i_pos;
-        p_spu->i_x = 0;
-        p_spu->i_y = 0;
         p_spu->b_absolute = VLC_FALSE;
     }
-    else
-    {   /*  set to an absolute xy, referenced to upper left corner */
-        p_spu->p_region->i_align = OSD_ALIGN_LEFT | OSD_ALIGN_TOP;
-        p_spu->i_x = p_sys->i_xoff;
-        p_spu->i_y = p_sys->i_yoff;
-        p_spu->b_absolute = VLC_TRUE;
-    }
+
+    p_spu->i_x = p_sys->i_xoff;
+    p_spu->i_y = p_sys->i_yoff;
 
     p_spu->i_height = 1;
     p_spu->p_region->p_style = p_sys->p_style;