<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <p><font size="+1"><tt>Hello,</tt></font></p>
    <p><font size="+1"><tt><br>
        </tt></font></p>
    <p><font size="+1"><tt>I have been playing with the "basic tutorial"
          C API a bit, and can create a stream in c code. However, when
          the strea is running, how can I quit/terminate that stream?</tt></font></p>
    <p><font size="+1"><tt><br>
        </tt></font></p>
    <p><font size="+1"><tt>For example,  basic tutorial 3:</tt></font></p>
    <p><font size="+1"><tt><br>
        </tt></font></p>
    <p><font size="+1"><tt>After creating a pipeline, one can start it.
          Then there's a loop that listens for msgs from the 'bus', in a
          loop. Whenever there is a msg, the loop runs through a switch,
          and and listens for a new msg again.</tt></font></p>
    <p><font size="+1"><tt>I want to create "some sort of event"  that
          terminates that loop (for example existence (or not) of a lock
          file.).</tt></font></p>
    <p><font size="+1"><tt>(or can I create a handler, set an option,
          that will make </tt></font><font size="+1"><tt><font
            size="+1"><tt>gst_element_get_bus(..)  return, even if there
              isn't a msg, with an empty msg or so?  (I am fairly sure,
            </tt></font></tt></font><font size="+1"><tt><font size="+1"><tt><font
                size="+1"><tt><font size="+1"><tt>gst_element_get_bus,
                      is not returning and only will if there is a msg
                      waiting.)<br>
                    </tt></font></tt></font></tt></font></tt></font></p>
    <p><font size="+1"><tt><br>
        </tt></font></p>
    <p><font size="+1"><tt>Here's a/the code snippet from the basic
          tutorial 3 example:</tt></font></p>
    <p><font size="+1"><tt>  /* Start playing */<br>
            ret = gst_element_set_state (data.pipeline,
          GST_STATE_PLAYING);<br>
            if (ret == GST_STATE_CHANGE_FAILURE) {<br>
              g_printerr ("Unable to set the pipeline to the playing
          state.\n");<br>
              gst_object_unref (data.pipeline);<br>
              return -1;<br>
            }<br>
          <br>
            /* Listen to the bus */<br>
            bus = gst_element_get_bus (data.pipeline);<br>
            do {<br>
              msg = gst_bus_timed_pop_filtered (bus,
          GST_CLOCK_TIME_NONE,<br>
                  GST_MESSAGE_STATE_CHANGED | GST_MESSAGE_ERROR |
          GST_MESSAGE_EOS);<br>
          <br>
              /* Parse message */<br>
              if (msg != NULL) {<br>
                GError *err;<br>
                gchar *debug_info;<br>
          <br>
                switch (GST_MESSAGE_TYPE (msg)) {<br>
                  case GST_MESSAGE_ERROR:<br>
                    gst_message_parse_error (msg, &err,
          &debug_info);<br>
                    g_printerr ("Error received from element %s: %s\n",
          GST_OBJECT_NAME (msg->src), err->message);<br>
                    g_printerr ("Debugging information: %s\n",
          debug_info ? debug_info : "none");<br>
                    g_clear_error (&err);<br>
                    g_free (debug_info);<br>
                    terminate = TRUE;<br>
                    break;<br>
                  case GST_MESSAGE_EOS:<br>
                    g_print ("End-Of-Stream reached.\n");<br>
                    terminate = TRUE;<br>
                    break;<br>
                  case GST_MESSAGE_STATE_CHANGED:<br>
                    /* We are only interested in state-changed messages
          from the pipeline */<br>
                    if (GST_MESSAGE_SRC (msg) == GST_OBJECT
          (data.pipeline)) {<br>
                      GstState old_state, new_state, pending_state;<br>
                      gst_message_parse_state_changed (msg,
          &old_state, &new_state, &pending_state);<br>
                      g_print ("Pipeline state changed from %s to
          %s:\n",<br>
                          gst_element_state_get_name (old_state),
          gst_element_state_get_name (new_state));<br>
                    }<br>
                    break;<br>
                  default:<br>
                    /* We should not reach here */<br>
                    g_printerr ("Unexpected message received.\n");<br>
                    break;<br>
                }<br>
                gst_message_unref (msg);<br>
              }<br>
            } while (!terminate);<br>
          <br>
        </tt></font></p>
    <p><font size="+1"><tt><br>
        </tt></font></p>
    <p><font size="+1"><tt><br>
        </tt></font></p>
    <p><font size="+1"><tt><br>
        </tt></font></p>
    <p><font size="+1"><tt><br>
        </tt></font></p>
    <p><font size="+1"><tt><br>
        </tt></font></p>
    <p><font size="+1"><tt><br>
        </tt></font></p>
    <p><font size="+1"><tt><br>
        </tt></font></p>
    <p><font size="+1"><tt><br>
        </tt></font></p>
    <p><font size="+1"><tt><br>
        </tt></font></p>
    <p><font size="+1"><tt><br>
        </tt></font></p>
    <p><font size="+1"><tt><br>
        </tt></font></p>
    <p><font size="+1"><tt><br>
        </tt></font></p>
    <p><font size="+1"><tt><br>
        </tt></font></p>
    <p><font size="+1"><tt><br>
        </tt></font></p>
    <p><font size="+1"><tt></tt></font><br>
    </p>
  </body>
</html>