<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    When I said "works OK", I meant "does not crash" - but you cannot
    change the image size.  As is, the program fails because it cannot
    negotiate.<br>
    I am running version 1.0.10<br>
    <br>
    Ian<br>
    <br>
    <div class="moz-cite-prefix">On 02/02/2014 14:45, Ian Davidson
      wrote:<br>
    </div>
    <blockquote cite="mid:52EE59EF.6040307@blueyonder.co.uk" type="cite">
      <meta content="text/html; charset=ISO-8859-1"
        http-equiv="Content-Type">
      Here is my program.  It creates 3 buttons - one to launch
      Camerabin, one to take snapshots, and one to close the camerabin.<br>
      <br>
      The program works OK if you exclude the 4 lines from 104 to 107.<br>
      <br>
      /* JustTheCamera.c */<br>
      <br>
      #include <gtk/gtk.h><br>
      #include <gst/gst.h><br>
      #include <glib.h><br>
      <br>
      <br>
      <br>
      <br>
          GtkWidget *startsnapbutton;<br>
          GtkWidget *snapbutton;<br>
          GtkWidget *stopsnapbutton;<br>
      <br>
          <br>
      static  GstElement *camPipeline;<br>
        GstElement *cambin;<br>
        GstBus *cambus;<br>
        GMainLoop *camloop;<br>
        guint cam_bus_watch_id;<br>
      <br>
      <br>
      <br>
      static gboolean<br>
      bus_call (GstBus     *bus,<br>
                GstMessage *msg,<br>
                gpointer    data)<br>
      {<br>
        GMainLoop *loop = (GMainLoop *) data;<br>
        switch (GST_MESSAGE_TYPE (msg)) {<br>
      <br>
          case GST_MESSAGE_EOS:<br>
            g_print ("End of stream\n");<br>
            g_main_loop_quit (loop);<br>
            break;<br>
      <br>
          case GST_MESSAGE_ERROR: {<br>
            gchar  *debug;<br>
            GError *error;<br>
      <br>
            gst_message_parse_error (msg, &error, &debug);<br>
            g_free (debug);<br>
      <br>
            g_printerr ("Error: %s\n", error->message);<br>
            g_error_free (error);<br>
      <br>
            g_main_loop_quit (loop);<br>
            break;<br>
          }<br>
      <br>
            case GST_MESSAGE_APPLICATION:{<br>
              const GstStructure *s;<br>
      <br>
              s = gst_message_get_structure (msg);<br>
      <br>
              if (gst_structure_has_name (s, "GstLaunchInterrupt")) {<br>
                /* this application message is posted when we caught an
      interrupt and<br>
                 * we need to stop the pipeline. */<br>
                g_print ("Interrupt: Stopping pipeline ...\n");<br>
      /*          gst_element_send_event (camPipeline, gst_event_new_eos
      ()); */<br>
                gst_element_set_state (camPipeline, GST_STATE_NULL);<br>
                g_main_loop_quit (loop);<br>
              }<br>
              break;<br>
            }<br>
      <br>
      <br>
          default:<br>
            break;<br>
        }<br>
      <br>
        return TRUE;<br>
      }<br>
      <br>
      gint delete_event( GtkWidget *widget,<br>
                         GdkEvent  *event,<br>
                         gpointer   data )<br>
      {<br>
        g_print ("Delete_Event called\n");<br>
            return(FALSE);<br>
      }<br>
      <br>
      /* Start the Camera - Set up camerabin.  */<br>
      void snapButtonPressed( GtkWidget *widget,<br>
                     gpointer   data )<br>
      {<br>
      <br>
       GstCaps *caps;<br>
      <br>
        gtk_widget_set_sensitive(startsnapbutton, FALSE);<br>
        gtk_widget_set_sensitive(snapbutton, TRUE);<br>
        gtk_widget_set_sensitive(stopsnapbutton, TRUE);<br>
        <br>
        camPipeline     = gst_pipeline_new ("camera");<br>
        cambin          = gst_element_factory_make ("camerabin",      
      "cambin1");<br>
       <br>
        camloop = g_main_loop_new (NULL, FALSE);<br>
        if (!camPipeline || !cambin ) {<br>
          g_printerr ("One element could not be created. Exiting.\n");<br>
          return;<br>
        }<br>
        /* Set up the pipeline */<br>
       <br>
        g_print ("Watch for the bus\n");<br>
        cambus = gst_pipeline_get_bus (GST_PIPELINE (camPipeline));<br>
        cam_bus_watch_id =  gst_bus_add_watch (cambus, bus_call,
      camloop);<br>
      <br>
        g_print ("Set the picture size\n");<br>
        caps = gst_caps_from_string("video/x-raw, width=(int)800,
      height=(int)600");<br>
        g_object_set (G_OBJECT (cambin), "image-capture-caps", caps,
      NULL);<br>
        gst_caps_unref (caps);    /*  This unref seems to cause problems
      and may need to be commented out */<br>
      <br>
        g_print ("Add the element to the pipeline\n");<br>
        gst_bin_add_many (GST_BIN (camPipeline), cambin, NULL);<br>
      <br>
      <br>
        gst_element_set_state (camPipeline, GST_STATE_PLAYING);<br>
      <br>
        /* Iterate */<br>
        g_main_loop_run (camloop);<br>
      <br>
      <br>
        /* Out of the main loop, clean up nicely */<br>
        g_print ("Returned, Camera Off\n");<br>
        gst_element_set_state (camPipeline, GST_STATE_NULL);<br>
      <br>
        gst_object_unref (GST_OBJECT (camPipeline));<br>
        g_source_remove (cam_bus_watch_id);<br>
        g_main_loop_unref (camloop);<br>
        <br>
        gtk_main_quit();<br>
      <br>
        return;<br>
      <br>
      }<br>
      <br>
      void snapNow( GtkWidget *widget,<br>
                     gpointer   data )<br>
      {<br>
        guint lbIdle;<br>
        <br>
        g_print ("Take a picture\n");<br>
        <br>
        g_object_get(cambin, "idle", &lbIdle, NULL);<br>
        if (lbIdle) {<br>
          g_print("Camera is Idle\n");<br>
        } else {<br>
          g_print("Camera is Busy\n");<br>
        }<br>
        <br>
        g_signal_emit_by_name (cambin, "start-capture", NULL);<br>
      }<br>
      <br>
      <br>
      void snapOff( GtkWidget *widget,<br>
                     gpointer   data )<br>
      {<br>
        g_print ("We want to stop\n");<br>
      <br>
        gst_element_post_message (GST_ELEMENT (camPipeline),<br>
            gst_message_new_application (GST_OBJECT (camPipeline),<br>
                gst_structure_new ("GstLaunchInterrupt",<br>
                    "message", G_TYPE_STRING, "Pipeline interrupted",
      NULL)));     <br>
      }<br>
      <br>
      <br>
      int main( int   argc,<br>
                char *argv[] )<br>
      {<br>
          /* GtkWidget is the storage type for widgets */<br>
          GtkWidget *window;<br>
          GtkWidget *grid;<br>
          <br>
      <br>
          /* This is called in all GTK applications. Arguments are
      parsed<br>
           * from the command line and are returned to the application.
      */<br>
          gtk_init (&argc, &argv);<br>
          gst_init (&argc, &argv);<br>
      <br>
          /* Create a new window */<br>
          window = gtk_window_new (GTK_WINDOW_TOPLEVEL);<br>
      <br>
          gtk_window_set_title (GTK_WINDOW (window), "Camera");<br>
      <br>
          /* Here we just set a handler for delete_event that
      immediately<br>
           * exits GTK. */<br>
          g_signal_connect (window, "destroy",<br>
                              G_CALLBACK (delete_event), NULL);<br>
      <br>
          /* Sets the border width of the window. */<br>
          gtk_container_set_border_width (GTK_CONTAINER (window), 10);<br>
      <br>
          /* Use a grid for the buttons */<br>
          grid = gtk_grid_new();<br>
      <br>
          /* Put the grid into the main window. */<br>
          gtk_container_add (GTK_CONTAINER (window), grid);<br>
          <br>
           /* Snapshot Buttons. */<br>
          startsnapbutton = gtk_button_new_with_label ("Start Camera");<br>
          g_signal_connect (startsnapbutton, "clicked",<br>
                              G_CALLBACK (snapButtonPressed),
      "Snapshot");<br>
          gtk_grid_attach(GTK_GRID(grid), startsnapbutton, 0, 1, 1, 1);<br>
          gtk_widget_show(startsnapbutton);<br>
      <br>
          snapbutton = gtk_button_new_with_label ("Take Snap");<br>
          g_signal_connect (snapbutton, "clicked",<br>
                              G_CALLBACK (snapNow), "Snapshot");<br>
          gtk_grid_attach(GTK_GRID(grid), snapbutton, 0, 2, 1, 1);<br>
          gtk_widget_show(snapbutton);<br>
          gtk_widget_set_sensitive(snapbutton, FALSE);<br>
      <br>
      <br>
          stopsnapbutton = gtk_button_new_with_label ("Stop Camera");<br>
          g_signal_connect (stopsnapbutton, "clicked",<br>
                              G_CALLBACK (snapOff), "Snapshot");<br>
          gtk_grid_attach(GTK_GRID(grid), stopsnapbutton, 0, 3, 1, 1);<br>
          gtk_widget_show(stopsnapbutton);<br>
          gtk_widget_set_sensitive(stopsnapbutton, FALSE);<br>
      <br>
      <br>
          gtk_widget_show(grid);<br>
      <br>
      <br>
      <br>
          gtk_widget_show (window);<br>
      <br>
          /* Rest in gtk_main and wait for the fun to begin! */<br>
          gtk_main ();<br>
      <br>
          return(0);<br>
      }<br>
      /* JustTheCamera-end */<br>
      <br>
      <br>
      <br>
      <div class="moz-cite-prefix">On 31/01/2014 14:51, Thiago Santos
        wrote:<br>
      </div>
      <blockquote cite="mid:52EBB881.5060405@collabora.com" type="cite">
        <meta content="text/html; charset=ISO-8859-1"
          http-equiv="Content-Type">
        <br>
        <br>
        If you have a sample application/script that shows the problem,
        you can send it to the list for other devels to look if it is
        correctly using camerabin.<br>
        <br>
        --<br>
        Thiago<br>
      </blockquote>
      <br>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
gstreamer-devel mailing list
<a class="moz-txt-link-abbreviated" href="mailto:gstreamer-devel@lists.freedesktop.org">gstreamer-devel@lists.freedesktop.org</a>
<a class="moz-txt-link-freetext" href="http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel">http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel</a>
</pre>
    </blockquote>
    <br>
    <br>
  </body>
</html>