trying to make correct video
authorvlad <vlad@vlanout.(none)>
Mon, 2 Aug 2010 20:15:10 +0000 (23:15 +0300)
committervlad <vlad@vlanout.(none)>
Mon, 2 Aug 2010 20:15:10 +0000 (23:15 +0300)
applet/src/livewp-common.h
applet/src/livewp-dbus.c
applet/src/livewp-home-widget.c
applet/src/livewp-main.c
applet/src/livewp-scene.c

index 31d2699..0675404 100644 (file)
@@ -53,7 +53,7 @@
 #define THEME_PATH "/usr/share/livewp/theme"
 #define SHORT_TIMER 75 /* 100 milisecond */
 //#define LONG_TIMER 5*60*1000 /* 10 minutes */
-#define LONG_TIMER  20*1000 /* 10 minutes */
+#define LONG_TIMER  20*1000 /* 20 seconds */
 enum { SHORT_TIMER_TYPE, LONG_TIMER_TYPE };
 #define SKY_LEVEL 0 
 #define SUN_LEVEL 0 
@@ -104,6 +104,7 @@ struct _Animation_WallpaperPrivate
     guint alive_timer;
     time_t last_alive_event;
     gchar *theme_string_parametr1;
+    gint theme_int_parametr1;
     GstElement *pipeline;
     gboolean running;
 };
index 06d9584..a1d0a14 100644 (file)
@@ -186,6 +186,7 @@ fprintf(stderr, "ddddasddddddddddddddddddddddda!!!!!!!!!!!!!!!\n");
         (priv->view == 2 && dbus_message_is_signal(msg, LIVEWP_SIGNAL_INTERFACE, LIVEWP_PLAY_LIVEBG_ON_VIEW2))||   
         (priv->view == 3 && dbus_message_is_signal(msg, LIVEWP_SIGNAL_INTERFACE, LIVEWP_PLAY_LIVEBG_ON_VIEW3))||   
         (priv->view == 4 && dbus_message_is_signal(msg, LIVEWP_SIGNAL_INTERFACE, LIVEWP_PLAY_LIVEBG_ON_VIEW4))){
+        fprintf(stderr, "Play scene visible %i\n", priv->visible);
         if (priv->visible != TRUE){
             priv->visible = TRUE;
             view_state_changed(priv);
@@ -196,6 +197,7 @@ fprintf(stderr, "ddddasddddddddddddddddddddddda!!!!!!!!!!!!!!!\n");
         (priv->view == 2 && dbus_message_is_signal(msg, LIVEWP_SIGNAL_INTERFACE, LIVEWP_PAUSE_LIVEBG_ON_VIEW2))||   
         (priv->view == 3 && dbus_message_is_signal(msg, LIVEWP_SIGNAL_INTERFACE, LIVEWP_PAUSE_LIVEBG_ON_VIEW3))||   
         (priv->view == 4 && dbus_message_is_signal(msg, LIVEWP_SIGNAL_INTERFACE, LIVEWP_PAUSE_LIVEBG_ON_VIEW4))){
+        fprintf(stderr, "Pause scene visible %i\n", priv->visible);
          if (priv->visible != FALSE){
             priv->visible = FALSE;
             view_state_changed(priv);
index 4bcb1c9..809d8c5 100644 (file)
@@ -337,7 +337,7 @@ short_timeout (AWallpaperPlugin *desktop_plugin)
     Actor *actor;
     gboolean stop_flag = TRUE;
 
-if (!desktop_plugin->priv->visible || !desktop_plugin->priv->rich_animation){
+    if (!desktop_plugin->priv->visible || !desktop_plugin->priv->rich_animation){
         desktop_plugin->priv->short_timer = 0;
         return FALSE;
     }
@@ -417,7 +417,21 @@ run_long_timeout(AWallpaperPlugin *desktop_plugin)
 gboolean
 long_timeout (AWallpaperPlugin *desktop_plugin)
 {
-    /* fprintf(stderr, "long_timeout %i\n", desktop_plugin->priv->long_timer); */
+    GstFormat fmt = GST_FORMAT_TIME;
+    gint64 p;
+    fprintf(stderr, "long_timeout %i\n", desktop_plugin->priv->long_timer); 
+    if (desktop_plugin->priv->pipeline){
+        fprintf(stderr, " gst play in run long timeout \n");
+       if (!desktop_plugin->priv->visible){
+               gst_element_query_position(desktop_plugin->priv->pipeline, &fmt, &p);
+               desktop_plugin->priv->theme_int_parametr1 = p / 1000000;
+               gst_element_set_state (desktop_plugin->priv->pipeline, GST_STATE_NULL);
+               gst_object_unref (GST_OBJECT (desktop_plugin->priv->pipeline));
+               desktop_plugin->priv->pipeline = NULL;
+       }
+       return TRUE;  
+    }
+
     if (desktop_plugin->priv->long_timer == 0 )
         return FALSE;
     if (!desktop_plugin->priv->visible){
index 8ecfc6b..23b9271 100644 (file)
 #include "livewp-home-widget.h"
 /*******************************************************************************/
 
-void 
-btn_setting_clicked(HildonButton *btn, gpointer data)
-{
-    Animation_WallpaperPrivate *priv = data;
-    // open settings dialog
-    fprintf(stderr, "btn setting clicked, %s\n", priv->theme);
-    lw_main_settings(priv, NULL);
-    fprintf(stderr, "btn setting clicked, %s\n", priv->theme);
-}
-/*******************************************************************************/
-void
-btn_power_clicked(HildonButton *btn, gpointer data)
-{
-    const gchar *value; 
-    value = hildon_button_get_value(btn);
-    fprintf(stderr, "applet must be %s\n", value);
-    if (!strcmp(value, "stop"))
-        hildon_button_set_text(HILDON_BUTTON(btn), _("Start"), "start");
-    else 
-        hildon_button_set_text(HILDON_BUTTON(btn), _("Stop"), "stop");
-}
-/*******************************************************************************/
 static void set_live_bg (Display *display, Window xwindow, int mode);
 static 
 void set_live_bg (Display *display, Window xwindow, int mode)
@@ -66,6 +44,7 @@ void set_live_bg (Display *display, Window xwindow, int mode)
                        (unsigned char *) &mode, 1);
 }
 /*******************************************************************************/
+
 void
 view_state_changed (Animation_WallpaperPrivate *priv)
 {
@@ -76,15 +55,23 @@ view_state_changed (Animation_WallpaperPrivate *priv)
                 init_scene_Xsnow(priv->desktop_plugin);
             }
        }
-       if (priv->pipeline)
-            gst_element_set_state (priv->pipeline, GST_STATE_PLAYING);
+       if (!strcmp(priv->theme,"Video")){
+           if (priv->pipeline){
+               fprintf(stderr, " gst play \n");
+               gst_element_set_state (priv->pipeline, GST_STATE_PLAYING);
+           }else{
+               init_scene_Video(priv->desktop_plugin);
+           }
+       }
        if (priv->long_timer == 0 ){
             priv->long_timer = g_timeout_add(LONG_TIMER, (GtkFunction)long_timeout, priv->desktop_plugin);
             run_long_timeout(priv->desktop_plugin);
        }
    }else{
         if (priv->pipeline){
-            gst_element_set_state (priv->pipeline, GST_STATE_PAUSED);
+           fprintf(stderr, " gst stop %i\n", priv->long_timer);
+           gst_element_set_state (priv->pipeline, GST_STATE_PAUSED);
+           return;
         }
         if (priv->long_timer != 0 ){
             g_source_remove(priv->long_timer);
@@ -229,6 +216,10 @@ main(int argc, char *argv[])
     priv->view_notify = gconf_client_notify_add(gconf_client_get_default (),"/apps/osso/hildon-desktop/views/current",
                                                 (GConfClientNotifyFunc)view_changed, priv, NULL, NULL);
 
+    /* Set start position of Video to zero */
+    if (!strcmp(priv->theme,"Video"))
+        priv->theme_int_parametr1 = 0;
+
     init_scene_theme(desktop_plugin);
         
     priv->long_timer = g_timeout_add(LONG_TIMER, (GtkFunction)long_timeout, desktop_plugin);
index e4a2c9c..bf48535 100644 (file)
@@ -44,7 +44,7 @@ destroy_scene(AWallpaperPlugin *desktop_plugin)
     if (desktop_plugin->priv->pipeline){
         gst_element_set_state (desktop_plugin->priv->pipeline, GST_STATE_NULL);
         gst_object_unref (GST_OBJECT (desktop_plugin->priv->pipeline));
-
+        desktop_plugin->priv->pipeline = NULL;
     }
     if (desktop_plugin->priv->podpid > 1){
         kill (desktop_plugin->priv->podpid, SIGTERM);
@@ -202,6 +202,7 @@ init_scene_Video(AWallpaperPlugin *desktop_plugin)
     gchar *file_plus_uri;
 
 
+    fprintf(stderr, "init scene Video \n");
     desktop_plugin->priv->pipeline = gst_pipeline_new("gst-player");
     bin = gst_element_factory_make ("playbin2", "bin");
     videosink = gst_element_factory_make ("ximagesink", "videosink");
@@ -217,10 +218,20 @@ init_scene_Video(AWallpaperPlugin *desktop_plugin)
     file_plus_uri = g_strdup_printf("file://%s",desktop_plugin->priv->theme_string_parametr1);
     g_object_set (G_OBJECT (bin), "uri", file_plus_uri, NULL );
     g_object_set (G_OBJECT (videosink), "force-aspect-ratio", TRUE, NULL  );
+
     if (GST_IS_X_OVERLAY (videosink))
            gst_x_overlay_set_xwindow_id (GST_X_OVERLAY (videosink), GDK_DRAWABLE_XID(desktop_plugin->priv->window->window));
     if (desktop_plugin->priv->visible)
         gst_element_set_state (desktop_plugin->priv->pipeline, GST_STATE_PLAYING);
+    
+    fprintf(stderr,"     desktop_plugin->priv->theme_int_parametr1 %i\n",    desktop_plugin->priv->theme_int_parametr1);
+    GstClockTime nach   = (GstClockTime)(desktop_plugin->priv->theme_int_parametr1 * GST_MSECOND);
+    if (!gst_element_seek(desktop_plugin->priv->pipeline, 1.0, GST_FORMAT_TIME,
+                   (GstSeekFlags) (GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_KEY_UNIT), GST_SEEK_TYPE_SET, 
+                   nach, GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE))
+        fprintf(stderr,"Error in seek\n");
+
+
 }
 /*******************************************************************************/
 void