X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fvideo_filter%2Frss.c;h=244c871cf0110f2fb5c9d2c9a682dbd5e8e69b36;hb=51cb4767dcf03ccb235862ca39c49305b4d75605;hp=0465a2cb30b7166245d3381f1b9e75e1f36753f0;hpb=4b00ff6ec805784d3b136591f0a4cf460ac36af9;p=vlc diff --git a/modules/video_filter/rss.c b/modules/video_filter/rss.c index 0465a2cb30..244c871cf0 100644 --- a/modules/video_filter/rss.c +++ b/modules/video_filter/rss.c @@ -36,15 +36,14 @@ #include #include -#include -#include "vlc_filter.h" -#include "vlc_block.h" -#include "vlc_osd.h" +#include +#include +#include -#include "vlc_block.h" -#include "vlc_stream.h" -#include "vlc_xml.h" +#include +#include +#include #include #include "vlc_image.h" @@ -186,43 +185,43 @@ static const char *const ppsz_title_modes[] = /***************************************************************************** * Module descriptor *****************************************************************************/ -vlc_module_begin(); - set_capability( "sub filter", 1 ); - set_shortname( "RSS / Atom" ); - 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 ); - - set_section( N_("Position"), NULL ); - add_integer( CFG_PREFIX "x", 0, NULL, POSX_TEXT, POSX_LONGTEXT, true ); - add_integer( CFG_PREFIX "y", 0, NULL, POSY_TEXT, POSY_LONGTEXT, true ); - add_integer( CFG_PREFIX "position", -1, NULL, POS_TEXT, POS_LONGTEXT, false ); - change_integer_list( pi_pos_values, ppsz_pos_descriptions, 0 ); - - set_section( N_("Font"), NULL ); +vlc_module_begin () + set_capability( "sub filter", 1 ) + set_shortname( "RSS / Atom" ) + 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 ) + + set_section( N_("Position"), NULL ) + add_integer( CFG_PREFIX "x", 0, NULL, POSX_TEXT, POSX_LONGTEXT, true ) + add_integer( CFG_PREFIX "y", 0, NULL, POSY_TEXT, POSY_LONGTEXT, true ) + add_integer( CFG_PREFIX "position", -1, NULL, POS_TEXT, POS_LONGTEXT, false ) + change_integer_list( pi_pos_values, ppsz_pos_descriptions, NULL ) + + set_section( N_("Font"), NULL ) /* 5 sets the default to top [1] left [4] */ add_integer_with_range( CFG_PREFIX "opacity", 255, 0, 255, NULL, - OPACITY_TEXT, OPACITY_LONGTEXT, false ); + OPACITY_TEXT, OPACITY_LONGTEXT, false ) add_integer( CFG_PREFIX "color", 0xFFFFFF, NULL, COLOR_TEXT, COLOR_LONGTEXT, - false ); - change_integer_list( pi_color_values, ppsz_color_descriptions, 0 ); - add_integer( CFG_PREFIX "size", -1, NULL, SIZE_TEXT, SIZE_LONGTEXT, false ); + false ) + change_integer_list( pi_color_values, ppsz_color_descriptions, NULL ) + add_integer( CFG_PREFIX "size", -1, NULL, SIZE_TEXT, SIZE_LONGTEXT, false ) - set_section( N_("Misc"), NULL ); + set_section( N_("Misc"), NULL ) add_integer( CFG_PREFIX "speed", 100000, NULL, SPEED_TEXT, SPEED_LONGTEXT, - false ); + false ) add_integer( CFG_PREFIX "length", 60, NULL, LENGTH_TEXT, LENGTH_LONGTEXT, - false ); - add_integer( CFG_PREFIX "ttl", 1800, NULL, TTL_TEXT, TTL_LONGTEXT, false ); - add_bool( CFG_PREFIX "images", 1, NULL, IMAGE_TEXT, IMAGE_LONGTEXT, false ); - add_integer( CFG_PREFIX "title", default_title, NULL, TITLE_TEXT, TITLE_LONGTEXT, false ); - change_integer_list( pi_title_modes, ppsz_title_modes, 0 ); + false ) + add_integer( CFG_PREFIX "ttl", 1800, NULL, TTL_TEXT, TTL_LONGTEXT, false ) + add_bool( CFG_PREFIX "images", 1, NULL, IMAGE_TEXT, IMAGE_LONGTEXT, false ) + add_integer( CFG_PREFIX "title", default_title, NULL, TITLE_TEXT, TITLE_LONGTEXT, false ) + change_integer_list( pi_title_modes, ppsz_title_modes, NULL ) - set_description( N_("RSS and Atom feed display") ); - add_shortcut( "rss" ); - add_shortcut( "atom" ); -vlc_module_end(); + set_description( N_("RSS and Atom feed display") ) + add_shortcut( "rss" ) + add_shortcut( "atom" ) +vlc_module_end () static const char *const ppsz_filter_options[] = { "urls", "x", "y", "position", "color", "size", "speed", "length", @@ -266,21 +265,22 @@ static int CreateFilter( vlc_object_t *p_this ) { vlc_mutex_unlock( &p_sys->lock ); vlc_mutex_destroy( &p_sys->lock ); + free( p_sys->psz_urls ); free( p_sys ); return VLC_ENOMEM; } p_sys->psz_marquee[p_sys->i_length] = '\0'; - p_sys->p_style = malloc( sizeof( text_style_t )); + p_sys->p_style = text_style_New(); if( p_sys->p_style == NULL ) { free( p_sys->psz_marquee ); vlc_mutex_unlock( &p_sys->lock ); vlc_mutex_destroy( &p_sys->lock ); + free( p_sys->psz_urls ); 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" ); p_sys->i_yoff = var_CreateGetInteger( p_filter, CFG_PREFIX "y" ); @@ -297,10 +297,11 @@ 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 ); + text_style_Delete( p_sys->p_style ); free( p_sys->psz_marquee ); vlc_mutex_unlock( &p_sys->lock ); vlc_mutex_destroy( &p_sys->lock ); + free( p_sys->psz_urls ); free( p_sys ); return VLC_EGENERIC; } @@ -308,10 +309,11 @@ static int CreateFilter( vlc_object_t *p_this ) if( p_sys->i_feeds == 0 ) { - free( p_sys->p_style ); + text_style_Delete( p_sys->p_style ); free( p_sys->psz_marquee ); vlc_mutex_unlock( &p_sys->lock ); vlc_mutex_destroy( &p_sys->lock ); + free( p_sys->psz_urls ); free( p_sys ); return VLC_EGENERIC; } @@ -319,11 +321,12 @@ static int CreateFilter( vlc_object_t *p_this ) { if( p_sys->p_feeds[i_feed].i_items == 0 ) { - free( p_sys->p_style ); + text_style_Delete( 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->psz_urls ); free( p_sys ); return VLC_EGENERIC; } @@ -346,7 +349,7 @@ static void DestroyFilter( vlc_object_t *p_this ) vlc_mutex_lock( &p_sys->lock ); - free( p_sys->p_style ); + text_style_Delete( p_sys->p_style ); free( p_sys->psz_marquee ); free( p_sys->psz_urls ); FreeRSS( p_filter ); @@ -436,9 +439,9 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t date ) return NULL; } - fmt.i_chroma = VLC_FOURCC('T','E','X','T'); + fmt.i_chroma = VLC_CODEC_TEXT; - p_spu->p_region = p_spu->pf_create_region( VLC_OBJECT(p_filter), &fmt ); + p_spu->p_region = subpicture_region_New( &fmt ); if( !p_spu->p_region ) { p_filter->pf_sub_buffer_del( p_filter, p_spu ); @@ -525,11 +528,7 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t date ) p_spu->b_absolute = false; } - 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; + p_spu->p_region->p_style = text_style_Duplicate( p_sys->p_style ); if( p_feed->p_pic ) { @@ -539,7 +538,7 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t date ) memset( &fmt_out, 0, sizeof(video_format_t) ); - fmt_out.i_chroma = VLC_FOURCC('Y','U','V','A'); + 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 = @@ -547,14 +546,17 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t date ) fmt_out.i_height = fmt_out.i_visible_height = p_pic->p[Y_PLANE].i_visible_lines; - p_region = p_spu->pf_create_region( VLC_OBJECT( p_filter ), &fmt_out ); + p_region = subpicture_region_New( &fmt_out ); if( !p_region ) { msg_Err( p_filter, "cannot allocate SPU region" ); } else { - vout_CopyPicture( p_filter, &p_region->picture, p_pic ); + p_region->i_x = p_sys->i_xoff; + p_region->i_y = p_sys->i_yoff; + /* FIXME the copy is probably not needed anymore */ + picture_Copy( p_region->p_picture, p_pic ); p_spu->p_region->p_next = p_region; } @@ -590,7 +592,7 @@ static picture_t *LoadImage( filter_t *p_filter, const char *psz_url ) memset( &fmt_in, 0, sizeof(video_format_t) ); memset( &fmt_out, 0, sizeof(video_format_t) ); - fmt_out.i_chroma = VLC_FOURCC('Y','U','V','A'); + fmt_out.i_chroma = VLC_CODEC_YUVA; p_orig = image_ReadUrl( p_handler, psz_url, &fmt_in, &fmt_out ); if( !p_orig ) @@ -600,7 +602,7 @@ static picture_t *LoadImage( filter_t *p_filter, const char *psz_url ) else if( p_sys->p_style->i_font_size > 0 ) { - fmt_in.i_chroma = VLC_FOURCC('Y','U','V','A'); + fmt_in.i_chroma = VLC_CODEC_YUVA; fmt_in.i_height = p_orig->p[Y_PLANE].i_visible_lines; fmt_in.i_width = p_orig->p[Y_PLANE].i_visible_pitch; fmt_out.i_width = p_orig->p[Y_PLANE].i_visible_pitch @@ -739,7 +741,6 @@ static int FetchRSS( filter_t *p_filter) case XML_READER_STARTELEM: free( psz_eltname ); - psz_eltname = NULL; psz_eltname = xml_ReaderName( p_xml_reader ); if( !psz_eltname ) { @@ -774,10 +775,20 @@ static int FetchRSS( filter_t *p_filter) char *psz_value = xml_ReaderValue( p_xml_reader ); if( !strcmp( psz_name, "rel" ) ) { + if( psz_rel ) + { + msg_Dbg( p_filter, "\"rel\" attribute of link atom duplicated (last value: %s)", psz_value ); + free( psz_rel ); + } psz_rel = psz_value; } else if( !strcmp( psz_name, "href" ) ) { + if( psz_href ) + { + msg_Dbg( p_filter, "\"href\" attribute of link atom duplicated (last value: %s)", psz_href ); + free( psz_href ); + } psz_href = psz_value; } else