]> git.sesse.net Git - vlc/commitdiff
Created input_item_SetEpg function.
authorLaurent Aimar <fenrir@videolan.org>
Sat, 21 Mar 2009 19:21:51 +0000 (20:21 +0100)
committerLaurent Aimar <fenrir@videolan.org>
Sun, 22 Mar 2009 11:26:47 +0000 (12:26 +0100)
src/input/es_out.c
src/input/input_interface.h
src/input/item.c

index f3c5fe56c402a24941393708cf0c510b1f96ebee..0c8c1d902ea4bf241489dc737305fc3d0f8dceac 100644 (file)
@@ -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;
index 6a70209d0860760257085e0bb4c44cb5fa2ab218..dc43bb1b51d7dc7afb227eea7753fec989112853 100644 (file)
@@ -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 * );
 
index c07554aa465f8573fe76755937a392b116d53cd1..57bc56118a53a08e177f77234cad290b7700d969 100644 (file)
@@ -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,