vlc_epg.h

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * vlc_epg.h: Electronic Program Guide
00003  *****************************************************************************
00004  * Copyright (C) 2007 the VideoLAN team
00005  * $Id$
00006  *
00007  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
00008  *
00009  * This program is free software; you can redistribute it and/or modify
00010  * it under the terms of the GNU General Public License as published by
00011  * the Free Software Foundation; either version 2 of the License, or
00012  * (at your option) any later version.
00013  *
00014  * This program is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  * GNU General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU General Public License
00020  * along with this program; if not, write to the Free Software
00021  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
00022  *****************************************************************************/
00023 
00024 #ifndef VLC_EPG_H
00025 #define VLC_EPG_H 1
00026 
00027 typedef struct
00028 {
00029     int64_t i_start;    /* Interpreted as a value return by time() */
00030     int     i_duration;    /* Duration of the event in second */
00031 
00032     char    *psz_name;
00033     char    *psz_short_description;
00034     char    *psz_description;
00035 
00036 } vlc_epg_event_t;
00037 
00038 typedef struct
00039 {
00040     char            *psz_name;
00041     vlc_epg_event_t *p_current; /* Can be null or should be the same than one of pp_event entry */
00042 
00043     int             i_event;
00044     vlc_epg_event_t **pp_event;
00045 } vlc_epg_t;
00046 
00047 static inline void vlc_epg_Init( vlc_epg_t *p_epg, const char *psz_name )
00048 {
00049     p_epg->psz_name = psz_name ? strdup( psz_name ) : NULL;
00050     p_epg->p_current = NULL;
00051     TAB_INIT( p_epg->i_event, p_epg->pp_event );
00052 }
00053 static inline void vlc_epg_Clean( vlc_epg_t *p_epg )
00054 {
00055     int i;
00056     for( i = 0; i < p_epg->i_event; i++ )
00057     {
00058         vlc_epg_event_t *p_evt = p_epg->pp_event[i];
00059         free( p_evt->psz_name );
00060         free( p_evt->psz_short_description );
00061         free( p_evt->psz_description );
00062         free( p_evt );
00063     }
00064     TAB_CLEAN( p_epg->i_event, p_epg->pp_event );
00065     free( p_epg->psz_name );
00066 }
00067 static inline void vlc_epg_AddEvent( vlc_epg_t *p_epg, int64_t i_start, int i_duration,
00068                                 const char *psz_name, const char *psz_short_description, const char *psz_description )
00069 {
00070     vlc_epg_event_t *p_evt = (vlc_epg_event_t*)malloc( sizeof(vlc_epg_event_t) );
00071     if( !p_evt )
00072         return;
00073     p_evt->i_start = i_start;
00074     p_evt->i_duration = i_duration;
00075     p_evt->psz_name = psz_name ? strdup( psz_name ) : NULL;
00076     p_evt->psz_short_description = psz_short_description ? strdup( psz_short_description ) : NULL;
00077     p_evt->psz_description = psz_description ? strdup( psz_description ) : NULL;
00078     TAB_APPEND_CPP( vlc_epg_event_t, p_epg->i_event, p_epg->pp_event, p_evt );
00079 }
00080 
00081 static inline vlc_epg_t *vlc_epg_New( const char *psz_name )
00082 {
00083     vlc_epg_t *p_epg = (vlc_epg_t*)malloc( sizeof(vlc_epg_t) );
00084     if( p_epg )
00085         vlc_epg_Init( p_epg, psz_name );
00086     return p_epg;
00087 }
00088 static inline void vlc_epg_Delete( vlc_epg_t *p_epg )
00089 {
00090     vlc_epg_Clean( p_epg );
00091     free( p_epg );
00092 }
00093 static inline void vlc_epg_SetCurrent( vlc_epg_t *p_epg, int64_t i_start )
00094 {
00095     int i;
00096     p_epg->p_current = NULL;
00097     if( i_start < 0 )
00098         return;
00099 
00100     for( i = 0; i < p_epg->i_event; i++ )
00101     {
00102         if( p_epg->pp_event[i]->i_start == i_start )
00103         {
00104             p_epg->p_current = p_epg->pp_event[i];
00105             break;
00106         }
00107     }
00108 }
00109 
00110 #endif
00111 

Generated on Wed Aug 13 08:02:37 2008 for VLC by  doxygen 1.5.1