#include <vlc_filter.h>
#include <vlc_block.h>
-#include <vlc_osd.h>
#include <vlc_stream.h>
#include <vlc_xml.h>
#define TITLE_TEXT N_("Title display mode")
#define TITLE_LONGTEXT N_("Title display mode. Default is 0 (hidden) if the feed has an image and feed images are enabled, 1 otherwise.")
+#define RSS_HELP N_("Display a RSS or ATOM Feed on your video")
+
static const int pi_pos_values[] = { 0, 1, 2, 4, 8, 5, 6, 9, 10 };
static const char *const ppsz_pos_descriptions[] =
{ N_("Center"), N_("Left"), N_("Right"), N_("Top"), N_("Bottom"),
*****************************************************************************/
vlc_module_begin ()
set_capability( "sub filter", 1 )
- set_shortname( "RSS / Atom" )
+ set_shortname( N_("RSS / Atom") )
+ set_help(RSS_HELP)
set_callbacks( CreateFilter, DestroyFilter )
set_category( CAT_VIDEO )
set_subcategory( SUBCAT_VIDEO_SUBPIC )
- add_string( CFG_PREFIX "urls", "rss", NULL, MSG_TEXT, MSG_LONGTEXT, false )
+ add_string( CFG_PREFIX "urls", NULL, NULL, MSG_TEXT, MSG_LONGTEXT, false )
set_section( N_("Position"), NULL )
add_integer( CFG_PREFIX "x", 0, NULL, POSX_TEXT, POSX_LONGTEXT, true )
change_integer_list( pi_title_modes, ppsz_title_modes, NULL )
set_description( N_("RSS and Atom feed display") )
- add_shortcut( "rss" )
- add_shortcut( "atom" )
+ add_shortcut( "rss", "atom" )
vlc_module_end ()
static const char *const ppsz_filter_options[] = {
{
filter_t *p_filter = (filter_t *)p_this;
filter_sys_t *p_sys;
- int i_ret = VLC_ENOMEM;
char *psz_urls;
int i_ttl;
config_ChainParse( p_filter, CFG_PREFIX, ppsz_filter_options,
p_filter->p_cfg );
+ /* Get the urls to parse: must be non empty */
+ psz_urls = var_CreateGetNonEmptyString( p_filter, CFG_PREFIX "urls" );
+ if( !psz_urls )
+ {
+ msg_Err( p_filter, "The list of urls must not be empty" );
+ free( p_sys );
+ return VLC_EGENERIC;
+ }
+
/* Fill the p_sys structure with the configuration */
p_sys->i_title = var_CreateGetInteger( p_filter, CFG_PREFIX "title" );
p_sys->i_cur_feed = 0;
p_sys->b_images = var_CreateGetBool( p_filter, CFG_PREFIX "images" );
i_ttl = __MAX( 0, var_CreateGetInteger( p_filter, CFG_PREFIX "ttl" ) );
- psz_urls = var_CreateGetString( p_filter, CFG_PREFIX "urls" );
p_sys->psz_marquee = malloc( p_sys->i_length + 1 );
if( p_sys->psz_marquee == NULL )
- goto error;
+ {
+ free( psz_urls );
+ free( p_sys );
+ return VLC_ENOMEM;
+ }
p_sys->psz_marquee[p_sys->i_length] = '\0';
p_sys->p_style = text_style_New();
/* Parse the urls */
if( ParseUrls( p_filter, psz_urls ) )
- {
- free( psz_urls );
goto error;
- }
- free( psz_urls );
/* Misc init */
vlc_mutex_init( &p_sys->lock );
vlc_timer_schedule( p_sys->timer, false, 1,
(mtime_t)(i_ttl)*1000000 );
+ free( psz_urls );
return VLC_SUCCESS;
error:
+ if( p_sys->p_style )
+ text_style_Delete( p_sys->p_style );
free( p_sys->psz_marquee );
+ free( psz_urls );
free( p_sys );
- return i_ret;
+ return VLC_ENOMEM;
}
/*****************************************************************************
* DestroyFilter: destroy RSS video filter
/* where to locate the string: */
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->p_region->i_align = SUBPICTURE_ALIGN_LEFT | SUBPICTURE_ALIGN_TOP;
p_spu->b_absolute = true;
}
else
p_spu->p_region->i_align = p_sys->i_pos;
p_spu->b_absolute = false;
}
+ p_spu->p_region->i_x = p_sys->i_xoff;
+ p_spu->p_region->i_y = p_sys->i_yoff;
p_spu->p_region->p_style = text_style_Duplicate( p_sys->p_style );
memset( &fmt_out, 0, sizeof(video_format_t) );
fmt_out.i_chroma = VLC_CODEC_YUVA;
- fmt_out.i_aspect = VOUT_ASPECT_FACTOR;
fmt_out.i_sar_num = fmt_out.i_sar_den = 1;
fmt_out.i_width =
fmt_out.i_visible_width = p_pic->p[Y_PLANE].i_visible_pitch;
}
else
{
- p_region->i_x = p_sys->i_xoff;
- p_region->i_y = p_sys->i_yoff;
+ p_region->i_x = p_spu->p_region->i_x;
+ p_region->i_y = p_spu->p_region->i_y;
/* FIXME the copy is probably not needed anymore */
picture_Copy( p_region->p_picture, p_pic );
p_spu->p_region->p_next = p_region;
- }
- /* Offset text to display right next to the image */
- p_spu->p_region->i_x = p_pic->p[Y_PLANE].i_visible_pitch;
+ /* Offset text to display right next to the image */
+ p_spu->p_region->i_x += fmt_out.i_visible_width;
+ }
}
vlc_mutex_unlock( &p_sys->lock );
{
b_is_item = true;
p_feed->i_items++;
- p_feed->p_items = realloc( p_feed->p_items,
- p_feed->i_items * sizeof( rss_item_t ) );
+ p_feed->p_items = xrealloc( p_feed->p_items,
+ p_feed->i_items * sizeof( rss_item_t ) );
p_feed->p_items[p_feed->i_items-1].psz_title = NULL;
p_feed->p_items[p_feed->i_items-1].psz_description = NULL;
p_feed->p_items[p_feed->i_items-1].psz_link = NULL;
stream_t *p_stream;
xml_t *p_xml;
xml_reader_t *p_xml_reader;
+ int i_feed;
/* These data are not modified after the creation of the module so we don't
need to hold the lock */
}
/* Fetch all feeds and parse them */
- for( int i_feed = 0; i_feed < i_feeds; i_feed++ )
+ for( i_feed = 0; i_feed < i_feeds; i_feed++ )
{
rss_feed_t *p_feed = p_feeds + i_feed;
rss_feed_t *p_old_feed = p_sys->p_feeds + i_feed;
}
msg_Dbg( p_filter, "done with %s RSS/Atom feed", p_feed->psz_url );
- xml_ReaderDelete( p_xml, p_xml_reader );
+ xml_ReaderDelete( p_xml_reader );
stream_Delete( p_stream );
}
return p_feeds;
error:
-
- /*TODO: still a memleak */
+ FreeRSS( p_feeds, i_feed + 1 );
if( p_xml_reader )
- xml_ReaderDelete( p_xml, p_xml_reader );
+ xml_ReaderDelete( p_xml_reader );
if( p_stream )
stream_Delete( p_stream );
if( p_xml )
filter_t *p_filter = p_data;
filter_sys_t *p_sys = p_filter->p_sys;
+ msg_Dbg( p_filter, "Updating the rss feeds" );
rss_feed_t *p_feeds = FetchRSS( p_filter );
- rss_feed_t *p_old_feeds = p_sys->p_feeds;
-
if( !p_feeds )
+ {
+ msg_Err( p_filter, "Unable to fetch the feeds" );
return;
+ }
+
+ rss_feed_t *p_old_feeds = p_sys->p_feeds;
vlc_mutex_lock( &p_sys->lock );
+ /* Update the feeds */
p_sys->p_feeds = p_feeds;
p_sys->b_fetched = true;
+ /* Set all current info to the original values */
+ p_sys->i_cur_feed = 0;
+ p_sys->i_cur_item = p_sys->i_title == scroll_title ? -1 : 0;
+ p_sys->i_cur_char = 0;
vlc_mutex_unlock( &p_sys->lock );
if( p_old_feeds )