[vlc-devel] commit: Created input_item_SetEpg function. (Laurent Aimar )
git version control
git at videolan.org
Sun Mar 22 15:31:16 CET 2009
vlc | branch: master | Laurent Aimar <fenrir at videolan.org> | Sat Mar 21 20:21:51 2009 +0100| [feab3bbb8cad4f000b40b523fb3f55fea482dcbf] | committer: Laurent Aimar
Created input_item_SetEpg function.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=feab3bbb8cad4f000b40b523fb3f55fea482dcbf
---
src/input/es_out.c | 35 +++++++----------------------------
src/input/input_interface.h | 2 ++
src/input/item.c | 31 +++++++++++++++++++++++++++++++
3 files changed, 40 insertions(+), 28 deletions(-)
diff --git a/src/input/es_out.c b/src/input/es_out.c
index f3c5fe5..0c8c1d9 100644
--- a/src/input/es_out.c
+++ b/src/input/es_out.c
@@ -1266,7 +1266,6 @@ static void EsOutProgramEpg( es_out_t *out, int i_group, vlc_epg_t *p_epg )
input_thread_t *p_input = p_sys->p_input;
es_out_pgrm_t *p_pgrm;
char *psz_cat;
- int i;
/* Find program */
p_pgrm = EsOutProgramFind( out, i_group );
@@ -1279,37 +1278,17 @@ static void EsOutProgramEpg( es_out_t *out, int i_group, vlc_epg_t *p_epg )
vlc_epg_Merge( p_pgrm->p_epg, p_epg );
/* Update info */
+ msg_Dbg( p_input, "EsOutProgramEpg: number=%d name=%s", i_group, p_pgrm->p_epg->psz_name );
+
psz_cat = EsOutProgramGetMetaName( p_pgrm );
-#ifdef HAVE_LOCALTIME_R
+
char *psz_epg;
- if( asprintf( &psz_epg, "EPG %s", psz_cat ) == -1 )
- psz_epg = NULL;
- input_Control( p_input, INPUT_DEL_INFO, psz_epg, NULL );
- msg_Dbg( p_input, "EsOutProgramEpg: number=%d name=%s", i_group, p_pgrm->p_epg->psz_name );
- for( i = 0; i < p_pgrm->p_epg->i_event; i++ )
- {
- const vlc_epg_event_t *p_evt = p_pgrm->p_epg->pp_event[i];
- time_t t_start = (time_t)p_evt->i_start;
- struct tm tm_start;
- char psz_start[128];
-
- localtime_r( &t_start, &tm_start );
-
- snprintf( psz_start, sizeof(psz_start), "%4.4d-%2.2d-%2.2d %2.2d:%2.2d:%2.2d",
- 1900 + tm_start.tm_year, 1 + tm_start.tm_mon, tm_start.tm_mday,
- tm_start.tm_hour, tm_start.tm_min, tm_start.tm_sec );
- if( p_evt->psz_short_description || p_evt->psz_description )
- input_Control( p_input, INPUT_ADD_INFO, psz_epg, psz_start, "%s (%2.2d:%2.2d) - %s",
- p_evt->psz_name,
- p_evt->i_duration/60/60, (p_evt->i_duration/60)%60,
- p_evt->psz_short_description ? p_evt->psz_short_description : p_evt->psz_description );
- else
- input_Control( p_input, INPUT_ADD_INFO, psz_epg, psz_start, "%s (%2.2d:%2.2d)",
- p_evt->psz_name,
- p_evt->i_duration/60/60, (p_evt->i_duration/60)%60 );
+ if( asprintf( &psz_epg, "EPG %s", psz_cat ) >= 0 )
+ {
+ input_item_SetEpg( p_input->p->p_item, psz_epg, p_pgrm->p_epg );
+ free( psz_epg );
}
- free( psz_epg );
-#endif
+
/* Update now playing */
free( p_pgrm->psz_now_playing );
p_pgrm->psz_now_playing = NULL;
diff --git a/src/input/input_interface.h b/src/input/input_interface.h
index 6a70209..dc43bb1 100644
--- a/src/input/input_interface.h
+++ b/src/input/input_interface.h
@@ -37,6 +37,8 @@
void input_item_SetPreparsed( input_item_t *p_i, bool b_preparsed );
void input_item_SetArtNotFound( input_item_t *p_i, bool b_not_found );
void input_item_SetArtFetched( input_item_t *p_i, bool b_art_fetched );
+void input_item_SetEpg( input_item_t *p_item,
+ const char *psz_epg, const vlc_epg_t *p_epg );
int input_Preparse( vlc_object_t *, input_item_t * );
diff --git a/src/input/item.c b/src/input/item.c
index c07554a..57bc561 100644
--- a/src/input/item.c
+++ b/src/input/item.c
@@ -622,6 +622,37 @@ int input_item_DelInfo( input_item_t *p_i,
return VLC_SUCCESS;
}
+void input_item_SetEpg( input_item_t *p_item,
+ const char *psz_epg, const vlc_epg_t *p_epg )
+{
+ input_item_DelInfo( p_item, psz_epg, NULL );
+
+#ifdef HAVE_LOCALTIME_R
+ for( int i = 0; i < p_epg->i_event; i++ )
+ {
+ const vlc_epg_event_t *p_evt = p_epg->pp_event[i];
+ time_t t_start = (time_t)p_evt->i_start;
+ struct tm tm_start;
+ char psz_start[128];
+
+ localtime_r( &t_start, &tm_start );
+
+ snprintf( psz_start, sizeof(psz_start), "%4.4d-%2.2d-%2.2d %2.2d:%2.2d:%2.2d",
+ 1900 + tm_start.tm_year, 1 + tm_start.tm_mon, tm_start.tm_mday,
+ tm_start.tm_hour, tm_start.tm_min, tm_start.tm_sec );
+ if( p_evt->psz_short_description || p_evt->psz_description )
+ input_item_AddInfo( p_item, psz_epg, psz_start, "%s (%2.2d:%2.2d) - %s",
+ p_evt->psz_name,
+ p_evt->i_duration/60/60, (p_evt->i_duration/60)%60,
+ p_evt->psz_short_description ? p_evt->psz_short_description : p_evt->psz_description );
+ else
+ input_item_AddInfo( p_item, psz_epg, psz_start, "%s (%2.2d:%2.2d)",
+ p_evt->psz_name,
+ p_evt->i_duration/60/60, (p_evt->i_duration/60)%60 );
+ }
+#endif
+}
+
input_item_t *__input_item_NewExt( vlc_object_t *p_obj, const char *psz_uri,
const char *psz_name,
More information about the vlc-devel
mailing list