1 /*****************************************************************************
2 * rss.c : rss/atom feed display video plugin for vlc
3 *****************************************************************************
4 * Copyright (C) 2003-2006 the VideoLAN team
7 * Authors: Antoine Cellerier <dionoea -at- videolan -dot- org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
24 /*****************************************************************************
26 *****************************************************************************/
27 #include <stdlib.h> /* malloc(), free() */
33 #include "vlc_filter.h"
34 #include "vlc_block.h"
37 #include "vlc_block.h"
38 #include "vlc_stream.h"
42 #include "vlc_image.h"
44 /*****************************************************************************
46 *****************************************************************************/
47 static int CreateFilter ( vlc_object_t * );
48 static void DestroyFilter( vlc_object_t * );
49 static subpicture_t *Filter( filter_t *, mtime_t );
51 static int FetchRSS( filter_t * );
52 static void FreeRSS( filter_t * );
54 static int pi_color_values[] = { 0xf0000000, 0x00000000, 0x00808080, 0x00C0C0C0,
55 0x00FFFFFF, 0x00800000, 0x00FF0000, 0x00FF00FF, 0x00FFFF00,
56 0x00808000, 0x00008000, 0x00008080, 0x0000FF00, 0x00800080,
57 0x00000080, 0x000000FF, 0x0000FFFF};
58 static char *ppsz_color_descriptions[] = { N_("Default"), N_("Black"),
59 N_("Gray"), N_("Silver"), N_("White"), N_("Maroon"), N_("Red"),
60 N_("Fuchsia"), N_("Yellow"), N_("Olive"), N_("Green"),
61 N_("Teal"), N_("Lime"), N_("Purple"), N_("Navy"), N_("Blue"),
64 /*****************************************************************************
65 * filter_sys_t: rss filter descriptor
66 *****************************************************************************/
71 char *psz_description;
78 char *psz_description;
84 struct rss_item_t *p_items;
92 int i_xoff, i_yoff; /* offsets for the display string in the video window */
93 int i_pos; /* permit relative positioning (top, bottom, left, right, center) */
97 char *psz_marquee; /* marquee string */
99 text_style_t *p_style; /* font control */
105 struct rss_feed_t *p_feeds;
108 time_t t_last_update;
116 #define MSG_TEXT N_("RSS/Atom feed URLs")
117 #define MSG_LONGTEXT N_("RSS/Atom feed '|' (pipe) seperated URLs")
118 #define SPEED_TEXT N_("RSS/Atom feed speed")
119 #define SPEED_LONGTEXT N_("RSS/Atom feed speed (bigger is slower)")
120 #define LENGTH_TEXT N_("RSS/Atom feed max number of chars displayed")
121 #define LENGTH_LONGTEXT N_("RSS/Atom feed max number of chars displayed")
122 #define TTL_TEXT N_("Number of seconds between each forced refresh of the feeds")
123 #define TTL_LONGTEXT N_("Number of seconds between each forced refresh of the feeds. If 0, the feeds will never be updated.")
124 #define IMAGE_TEXT N_("Display feed images if available")
125 #define IMAGE_LONGTEXT N_("Display feed images if available")
127 #define POSX_TEXT N_("X offset, from left")
128 #define POSX_LONGTEXT N_("X offset, from the left screen edge" )
129 #define POSY_TEXT N_("Y offset, from the top")
130 #define POSY_LONGTEXT N_("Y offset, down from the top" )
131 #define OPACITY_TEXT N_("Opacity")
132 #define OPACITY_LONGTEXT N_("The opacity (inverse of transparency) of " \
133 "overlay text. 0 = transparent, 255 = totally opaque. " )
134 #define SIZE_TEXT N_("Font size, pixels")
135 #define SIZE_LONGTEXT N_("Specify the font size, in pixels, " \
136 "with -1 = use freetype-fontsize" )
138 #define COLOR_TEXT N_("Text Default Color")
139 #define COLOR_LONGTEXT N_("The color of overlay text. 1 byte for each color, hexadecimal. " \
140 "#000000 = all colors off, " \
141 "0xFF0000 = just Red, 0xFFFFFF = all color on [White]" )
143 #define POS_TEXT N_("Marquee position")
144 #define POS_LONGTEXT N_( \
145 "You can enforce the marquee position on the video " \
146 "(0=center, 1=left, 2=right, 4=top, 8=bottom, you can " \
147 "also use combinations of these values by adding them).")
149 static int pi_pos_values[] = { 0, 1, 2, 4, 8, 5, 6, 9, 10 };
150 static char *ppsz_pos_descriptions[] =
151 { N_("Center"), N_("Left"), N_("Right"), N_("Top"), N_("Bottom"),
152 N_("Top-Left"), N_("Top-Right"), N_("Bottom-Left"), N_("Bottom-Right") };
154 /*****************************************************************************
156 *****************************************************************************/
158 set_capability( "sub filter", 0 );
159 set_shortname( "RSS / Atom" );
160 set_callbacks( CreateFilter, DestroyFilter );
161 set_category( CAT_VIDEO );
162 set_subcategory( SUBCAT_VIDEO_SUBPIC );
163 add_string( "rss-urls", "rss", NULL, MSG_TEXT, MSG_LONGTEXT, VLC_FALSE );
165 set_section( N_("Position"), NULL );
166 add_integer( "rss-x", -1, NULL, POSX_TEXT, POSX_LONGTEXT, VLC_TRUE );
167 add_integer( "rss-y", 0, NULL, POSY_TEXT, POSY_LONGTEXT, VLC_TRUE );
168 add_integer( "rss-position", 5, NULL, POS_TEXT, POS_LONGTEXT, VLC_FALSE );
169 change_integer_list( pi_pos_values, ppsz_pos_descriptions, 0 );
171 set_section( N_("Font"), NULL );
172 /* 5 sets the default to top [1] left [4] */
173 add_integer_with_range( "rss-opacity", 255, 0, 255, NULL,
174 OPACITY_TEXT, OPACITY_LONGTEXT, VLC_FALSE );
175 add_integer( "rss-color", 0xFFFFFF, NULL, COLOR_TEXT, COLOR_LONGTEXT,
177 change_integer_list( pi_color_values, ppsz_color_descriptions, 0 );
178 add_integer( "rss-size", -1, NULL, SIZE_TEXT, SIZE_LONGTEXT, VLC_FALSE );
180 set_section( N_("Misc"), NULL );
181 add_integer( "rss-speed", 100000, NULL, SPEED_TEXT, SPEED_LONGTEXT,
183 add_integer( "rss-length", 60, NULL, LENGTH_TEXT, LENGTH_LONGTEXT,
185 add_integer( "rss-ttl", 1800, NULL, TTL_TEXT, TTL_LONGTEXT, VLC_FALSE );
186 add_bool( "rss-images", 1, NULL, IMAGE_TEXT, IMAGE_LONGTEXT, VLC_FALSE );
188 set_description( _("RSS and Atom feed display") );
189 add_shortcut( "rss" );
190 add_shortcut( "atom" );
193 /*****************************************************************************
194 * CreateFilter: allocates RSS video filter
195 *****************************************************************************/
196 static int CreateFilter( vlc_object_t *p_this )
198 filter_t *p_filter = (filter_t *)p_this;
202 /* Allocate structure */
203 p_sys = p_filter->p_sys = malloc( sizeof( filter_sys_t ) );
206 msg_Err( p_filter, "out of memory" );
210 vlc_mutex_init( p_filter, &p_sys->lock );
211 vlc_mutex_lock( &p_sys->lock );
213 p_sys->psz_urls = var_CreateGetString( p_filter, "rss-urls" );
214 p_sys->i_cur_feed = 0;
215 p_sys->i_cur_item = 0;
216 p_sys->i_cur_char = 0;
218 p_sys->p_feeds = NULL;
219 p_sys->i_speed = var_CreateGetInteger( p_filter, "rss-speed" );
220 p_sys->i_length = var_CreateGetInteger( p_filter, "rss-length" );
221 p_sys->i_ttl = __MAX( 0, var_CreateGetInteger( p_filter, "rss-ttl" ) );
222 p_sys->b_images = var_CreateGetBool( p_filter, "rss-images" );
223 p_sys->psz_marquee = (char *)malloc( p_sys->i_length );
225 p_sys->p_style = malloc( sizeof( text_style_t ));
226 memcpy( p_sys->p_style, &default_text_style, sizeof( text_style_t ));
228 p_sys->i_xoff = var_CreateGetInteger( p_filter, "rss-x" );
229 p_sys->i_yoff = var_CreateGetInteger( p_filter, "rss-y" );
230 p_sys->i_pos = var_CreateGetInteger( p_filter, "rss-position" );
231 p_sys->p_style->i_font_alpha = 255 - var_CreateGetInteger( p_filter, "rss-opacity" );
232 p_sys->p_style->i_font_color = var_CreateGetInteger( p_filter, "rss-color" );
233 p_sys->p_style->i_font_size = var_CreateGetInteger( p_filter, "rss-size" );
235 if( p_sys->b_images == VLC_TRUE && p_sys->p_style->i_font_size == -1 )
237 msg_Warn( p_filter, "rrs-size wasn't specified. Feed images will thus be displayed without being resized" );
240 if( FetchRSS( p_filter ) )
242 msg_Err( p_filter, "failed while fetching RSS ... too bad" );
243 vlc_mutex_unlock( &p_sys->lock );
246 p_sys->t_last_update = time( NULL );
248 if( p_sys->i_feeds == 0 )
250 vlc_mutex_unlock( &p_sys->lock );
253 for( i_feed=0; i_feed < p_sys->i_feeds; i_feed ++ )
254 if( p_sys->p_feeds[i_feed].i_items == 0 )
256 vlc_mutex_unlock( &p_sys->lock );
261 p_filter->pf_sub_filter = Filter;
262 p_sys->last_date = (mtime_t)0;
264 vlc_mutex_unlock( &p_sys->lock );
268 /*****************************************************************************
269 * DestroyFilter: destroy RSS video filter
270 *****************************************************************************/
271 static void DestroyFilter( vlc_object_t *p_this )
273 filter_t *p_filter = (filter_t *)p_this;
274 filter_sys_t *p_sys = p_filter->p_sys;
276 vlc_mutex_lock( &p_sys->lock );
278 if( p_sys->p_style ) free( p_sys->p_style );
279 if( p_sys->psz_marquee ) free( p_sys->psz_marquee );
280 free( p_sys->psz_urls );
282 vlc_mutex_unlock( &p_sys->lock );
283 vlc_mutex_destroy( &p_sys->lock );
286 /* Delete the RSS variables */
287 var_Destroy( p_filter, "rss-urls" );
288 var_Destroy( p_filter, "rss-speed" );
289 var_Destroy( p_filter, "rss-length" );
290 var_Destroy( p_filter, "rss-ttl" );
291 var_Destroy( p_filter, "rss-images" );
292 var_Destroy( p_filter, "rss-x" );
293 var_Destroy( p_filter, "rss-y" );
294 var_Destroy( p_filter, "rss-position" );
295 var_Destroy( p_filter, "rss-color");
296 var_Destroy( p_filter, "rss-opacity");
297 var_Destroy( p_filter, "rss-size");
300 /****************************************************************************
301 * Filter: the whole thing
302 ****************************************************************************
303 * This function outputs subpictures at regular time intervals.
304 ****************************************************************************/
305 static subpicture_t *Filter( filter_t *p_filter, mtime_t date )
307 filter_sys_t *p_sys = p_filter->p_sys;
309 video_format_t fmt = {0};
311 subpicture_region_t *p_region;
315 struct rss_feed_t *p_feed;
317 vlc_mutex_lock( &p_sys->lock );
320 + ( p_sys->i_cur_char == 0 && p_sys->i_cur_item == 0 ? 5 : 1 )
321 /* ( ... ? 5 : 1 ) means "wait more for the 1st char" */
322 * p_sys->i_speed > date )
324 vlc_mutex_unlock( &p_sys->lock );
328 /* Do we need to update the feeds ? */
330 && time( NULL ) > p_sys->t_last_update + (time_t)p_sys->i_ttl )
332 msg_Dbg( p_filter, "Forcing update of all the RSS feeds" );
333 if( FetchRSS( p_filter ) )
335 msg_Err( p_filter, "failed while fetching RSS ... too bad" );
336 vlc_mutex_unlock( &p_sys->lock );
337 return NULL; /* FIXME : we most likely messed up all the data,
338 * so we might need to do something about it */
340 p_sys->t_last_update = time( NULL );
343 p_sys->last_date = date;
345 if( p_sys->p_feeds[p_sys->i_cur_feed].p_items[p_sys->i_cur_item].psz_title[p_sys->i_cur_char] == 0 )
347 p_sys->i_cur_char = 0;
349 if( p_sys->i_cur_item >= p_sys->p_feeds[p_sys->i_cur_feed].i_items )
351 p_sys->i_cur_item = 0;
352 p_sys->i_cur_feed = (p_sys->i_cur_feed + 1)%p_sys->i_feeds;
356 p_spu = p_filter->pf_sub_buffer_new( p_filter );
359 vlc_mutex_unlock( &p_sys->lock );
363 fmt.i_chroma = VLC_FOURCC('T','E','X','T');
365 p_spu->p_region = p_spu->pf_create_region( VLC_OBJECT(p_filter), &fmt );
366 if( !p_spu->p_region )
368 p_filter->pf_sub_buffer_del( p_filter, p_spu );
369 vlc_mutex_unlock( &p_sys->lock );
373 /* Generate the string that will be displayed. This string is supposed to
374 be p_sys->i_length characters long. */
375 i_item = p_sys->i_cur_item;
376 i_feed = p_sys->i_cur_feed;
377 p_feed = &p_sys->p_feeds[p_sys->i_cur_feed];
381 /* Don't display the feed's title if we have an image */
382 snprintf( p_sys->psz_marquee, p_sys->i_length, "%s",
383 p_sys->p_feeds[i_feed].p_items[i_item].psz_title
384 +p_sys->i_cur_char );
388 snprintf( p_sys->psz_marquee, p_sys->i_length, "%s : %s",
389 p_sys->p_feeds[i_feed].psz_title,
390 p_sys->p_feeds[i_feed].p_items[i_item].psz_title
391 +p_sys->i_cur_char );
394 while( strlen( p_sys->psz_marquee ) < (unsigned int)p_sys->i_length )
397 if( i_item == p_sys->p_feeds[i_feed].i_items ) break;
398 snprintf( strchr( p_sys->psz_marquee, 0 ),
399 p_sys->i_length - strlen( p_sys->psz_marquee ),
401 p_sys->p_feeds[i_feed].p_items[i_item].psz_title );
404 /* Calls to snprintf might split multibyte UTF8 chars ...
405 * which freetype doesn't like. */
407 char *a = strdup( p_sys->psz_marquee );
409 char *b = p_sys->psz_marquee;
410 EnsureUTF8( p_sys->psz_marquee );
411 /* we want to use ' ' instead of '?' for erroneous chars */
414 if( *b != *a ) *b = ' ';
420 p_spu->p_region->psz_text = strdup(p_sys->psz_marquee);
421 p_spu->i_start = date;
423 p_spu->b_ephemer = VLC_TRUE;
425 /* where to locate the string: */
426 if( p_sys->i_xoff < 0 || p_sys->i_yoff < 0 )
427 { /* set to one of the 9 relative locations */
428 p_spu->i_flags = p_sys->i_pos;
431 p_spu->b_absolute = VLC_FALSE;
434 { /* set to an absolute xy, referenced to upper left corner */
435 p_spu->i_flags = OSD_ALIGN_LEFT | OSD_ALIGN_TOP;
436 p_spu->i_x = p_sys->i_xoff;
437 p_spu->i_y = p_sys->i_yoff;
438 p_spu->b_absolute = VLC_TRUE;
442 p_spu->p_region->p_style = p_sys->p_style;
446 /* Display the feed's image */
447 picture_t *p_pic = p_feed->p_pic;
448 video_format_t fmt_out = {0};
450 fmt_out.i_chroma = VLC_FOURCC('Y','U','V','A');
451 fmt_out.i_aspect = VOUT_ASPECT_FACTOR;
452 fmt_out.i_sar_num = fmt_out.i_sar_den = 1;
454 fmt_out.i_visible_width = p_pic->p[Y_PLANE].i_visible_pitch;
456 fmt_out.i_visible_height = p_pic->p[Y_PLANE].i_visible_lines;
458 p_region = p_spu->pf_create_region( VLC_OBJECT( p_filter ), &fmt_out );
461 msg_Err( p_filter, "cannot allocate SPU region" );
465 vout_CopyPicture( p_filter, &p_region->picture, p_pic );
466 p_spu->p_region->p_next = p_region;
469 /* Offset text to display right next to the image */
470 p_spu->p_region->i_x = p_pic->p[Y_PLANE].i_visible_pitch;
473 vlc_mutex_unlock( &p_sys->lock );
477 /****************************************************************************
478 * RSS related functions
479 ****************************************************************************
480 * You should always lock the p_filter mutex before using any of these
482 ***************************************************************************/
484 #undef LoadImage /* do not conflict with Win32 API */
486 /****************************************************************************
487 * download and resize image located at psz_url
488 ***************************************************************************/
489 picture_t *LoadImage( filter_t *p_filter, const char *psz_url )
491 filter_sys_t *p_sys = p_filter->p_sys;
493 video_format_t fmt_in={0}, fmt_out={0};
494 picture_t *p_orig, *p_pic=NULL;
495 image_handler_t *p_handler = image_HandlerCreate( p_filter );
499 psz_local = ToLocale( psz_url );
500 fmt_out.i_chroma = VLC_FOURCC('Y','U','V','A');
501 p_orig = image_ReadUrl( p_handler, psz_local, &fmt_in, &fmt_out );
502 LocaleFree( psz_local );
506 msg_Warn( p_filter, "Unable to read image %s", psz_url );
508 else if( p_sys->p_style->i_font_size > 0 )
511 fmt_in.i_chroma = VLC_FOURCC('Y','U','V','A');
512 fmt_in.i_height = p_orig->p[Y_PLANE].i_visible_lines;
513 fmt_in.i_width = p_orig->p[Y_PLANE].i_visible_pitch;
514 fmt_out.i_width = p_orig->p[Y_PLANE].i_visible_pitch
515 *p_sys->p_style->i_font_size/p_orig->p[Y_PLANE].i_visible_lines;
516 fmt_out.i_height = p_sys->p_style->i_font_size;
518 p_pic = image_Convert( p_handler, p_orig, &fmt_in, &fmt_out );
519 p_orig->pf_release( p_orig );
522 msg_Warn( p_filter, "Error while converting %s", psz_url );
530 image_HandlerDelete( p_handler );
535 /****************************************************************************
536 * remove all ' ' '\t' '\n' '\r' characters from the begining and end of the
538 ***************************************************************************/
539 char *removeWhiteChars( char *psz_src )
541 char *psz_src2 = strdup( psz_src );
542 char *psz_clean = strdup( psz_src2 );
545 while( ( *psz_clean == ' ' || *psz_clean == '\t'
546 || *psz_clean == '\n' || *psz_clean == '\r' )
547 && *psz_clean != '\0' )
551 i = strlen( psz_clean );
553 ( psz_clean[i] == ' ' || psz_clean[i] == '\t'
554 || psz_clean[i] == '\n' || psz_clean[i] == '\r' ) );
555 psz_clean[i+1] = '\0';
556 psz_clean2 = strdup( psz_clean );
561 /****************************************************************************
563 ***************************************************************************/
564 static int FetchRSS( filter_t *p_filter)
566 filter_sys_t *p_sys = p_filter->p_sys;
568 stream_t *p_stream = NULL;
570 xml_reader_t *p_xml_reader = NULL;
572 char *psz_eltname = NULL;
573 char *psz_eltvalue = NULL;
574 char *psz_feed = NULL;
575 char *psz_buffer = NULL;
576 char *psz_buffer_2 = NULL;
580 vlc_bool_t b_is_item;
581 vlc_bool_t b_is_image;
587 while( p_sys->psz_urls[i_int] != 0 )
588 if( p_sys->psz_urls[i_int++] == '|' )
590 p_sys->p_feeds = (struct rss_feed_t *)malloc( p_sys->i_feeds
591 * sizeof( struct rss_feed_t ) );
593 p_xml = xml_Create( p_filter );
596 msg_Err( p_filter, "Failed to open XML parser" );
600 psz_buffer = strdup( p_sys->psz_urls );
601 psz_buffer_2 = psz_buffer; /* keep track so we can free it */
602 for( i_feed = 0; i_feed < p_sys->i_feeds; i_feed++ )
604 struct rss_feed_t *p_feed = p_sys->p_feeds+i_feed;
606 if( psz_buffer == NULL ) break;
607 if( psz_buffer[0] == 0 ) psz_buffer++;
608 psz_feed = psz_buffer;
609 psz_buffer = strchr( psz_buffer, '|' );
610 if( psz_buffer != NULL ) psz_buffer[0] = 0;
612 p_feed->psz_title = NULL;
613 p_feed->psz_description = NULL;
614 p_feed->psz_link = NULL;
615 p_feed->psz_image = NULL;
616 p_feed->p_pic = NULL;
618 p_feed->p_items = NULL;
620 msg_Dbg( p_filter, "Opening %s RSS feed ...", psz_feed );
622 p_stream = stream_UrlNew( p_filter, psz_feed );
625 msg_Err( p_filter, "Failed to open %s for reading", psz_feed );
629 p_xml_reader = xml_ReaderCreate( p_xml, p_stream );
632 msg_Err( p_filter, "Failed to open %s for parsing", psz_feed );
637 b_is_item = VLC_FALSE;
638 b_is_image = VLC_FALSE;
640 while( xml_ReaderRead( p_xml_reader ) == 1 )
642 switch( xml_ReaderNodeType( p_xml_reader ) )
648 case XML_READER_STARTELEM:
654 psz_eltname = xml_ReaderName( p_xml_reader );
661 msg_Dbg( p_filter, "element name : %s", psz_eltname );
663 if( !strcmp( psz_eltname, "item" )
664 || !strcmp( psz_eltname, "entry" ) )
666 b_is_item = VLC_TRUE;
668 p_feed->p_items = (struct rss_item_t *)realloc( p_feed->p_items, p_feed->i_items * sizeof( struct rss_item_t ) );
669 p_feed->p_items[p_feed->i_items-1].psz_title = NULL;
670 p_feed->p_items[p_feed->i_items-1].psz_description
672 p_feed->p_items[p_feed->i_items-1].psz_link = NULL;
674 else if( !strcmp( psz_eltname, "image" ) )
676 b_is_image = VLC_TRUE;
680 case XML_READER_ENDELEM:
686 psz_eltname = xml_ReaderName( p_xml_reader );
692 msg_Dbg( p_filter, "element end : %s", psz_eltname );
694 if( !strcmp( psz_eltname, "item" )
695 || !strcmp( psz_eltname, "entry" ) )
697 b_is_item = VLC_FALSE;
700 else if( !strcmp( psz_eltname, "image" ) )
702 b_is_image = VLC_FALSE;
708 case XML_READER_TEXT:
709 if( !psz_eltname ) break;
710 psz_eltvalue = xml_ReaderValue( p_xml_reader );
718 psz_clean = removeWhiteChars( psz_eltvalue );
719 free( psz_eltvalue ); psz_eltvalue = psz_clean;
722 msg_Dbg( p_filter, " text : <%s>", psz_eltvalue );
724 if( b_is_item == VLC_TRUE )
726 struct rss_item_t *p_item;
727 p_item = p_feed->p_items+i_item;
728 if( !strcmp( psz_eltname, "title" ) )
730 p_item->psz_title = psz_eltvalue;
732 else if( !strcmp( psz_eltname, "link" ) )
734 p_item->psz_link = psz_eltvalue;
736 else if( !strcmp( psz_eltname, "description" ) )
738 p_item->psz_description = psz_eltvalue;
742 free( psz_eltvalue );
746 else if( b_is_image == VLC_TRUE )
748 if( !strcmp( psz_eltname, "url" ) )
750 p_feed->psz_image = psz_eltvalue;
751 if( p_sys->b_images == VLC_TRUE )
752 p_feed->p_pic = LoadImage( p_filter,
757 free( psz_eltvalue );
763 if( !strcmp( psz_eltname, "title" ) )
765 p_feed->psz_title = psz_eltvalue;
767 else if( !strcmp( psz_eltname, "link" ) )
769 p_feed->psz_link = psz_eltvalue;
771 else if( !strcmp( psz_eltname, "description" )
772 || !strcmp( psz_eltname, "subtitle" ) )
774 p_feed->psz_description = psz_eltvalue;
778 free( psz_eltvalue );
786 if( p_xml_reader && p_xml ) xml_ReaderDelete( p_xml, p_xml_reader );
787 if( p_stream ) stream_Delete( p_stream );
788 msg_Dbg( p_filter, "Done with %s RSS feed.", psz_feed );
790 free( psz_buffer_2 );
791 if( p_xml ) xml_Delete( p_xml );
796 /****************************************************************************
798 ***************************************************************************/
799 static void FreeRSS( filter_t *p_filter)
801 filter_sys_t *p_sys = p_filter->p_sys;
803 struct rss_item_t *p_item;
804 struct rss_feed_t *p_feed;
809 for( i_feed = 0; i_feed < p_sys->i_feeds; i_feed++ )
811 p_feed = p_sys->p_feeds+i_feed;
812 for( i_item = 0; i_item < p_feed->i_items; i_item++ )
814 p_item = p_feed->p_items+i_item;
815 free( p_item->psz_title );
816 free( p_item->psz_link );
817 free( p_item->psz_description );
819 free( p_feed->p_items );
820 free( p_feed->psz_title);
821 free( p_feed->psz_link );
822 free( p_feed->psz_description );
823 free( p_feed->psz_image );
824 if( p_feed->p_pic != NULL )
825 p_feed->p_pic->pf_release( p_feed->p_pic );
827 free( p_sys->p_feeds );