title: gstreamer-1.0 stopping and starting recording pipeline via GUI
body: <p>I'm trying to write simple video recorder, based on gstreamer framework for my own customboard with ARM processor and Wayland+Qt as window subsystem.
  I've created class RecordBin with rec_start slot and rec_stop public method:</p>
  
  <pre><code>void RecordBin::rec_start ()
  {
    /* Set pipeline to the PLAYING state */
    gst_element_set_state (record_pipeline, GST_STATE_PLAYING);
    g_print ("setting playing state\n");
  
    /* Start main loop context */
    g_main_loop_run (rec_loop);
  }
  
  void RecordBin::rec_stop ()
  {
    /* Set pipeline to the NULL state */
    change_ret = gst_element_set_state (record_pipeline, GST_STATE_NULL);
  
    /* Quit from main loop context */
    g_main_loop_quit (rec_loop);
  }
  </code></pre>
  
  <p>This is my slot in mainwindow for play/stop button clicking:</p>
  
  <pre><code>void MainWindow::on_recordButton_clicked ()
  {
    if (!is_recording) {
      if (window_is_opened == false) {
        cout &lt;&lt; "start recording" &lt;&lt; endl;
  
        /* Start recording */
        window_is_opened = true;
        emit start_recording ();
      } else {
        cout &lt;&lt; "playing window already opened" &lt;&lt; endl;
      }
    } else {
      cout &lt;&lt; "recording reset" &lt;&lt; endl;
  
      /* Stop recording */
      record_bin-&gt;rec_stop ();
      window_is_opened = false;
    }
  }
  </code></pre>
  
  <p>RecordBin class is working in a separate thread (it's realized via QThread), so that glib mainloop context don't blocking Qt main window.
  I can't use rec_stop method as slot, because rec_loop blocks the message handling, and when recording starts, it can't be stopped via signal.
  But direct call rec_stop is thread unsafe. </p>
  
  <p>Can anybody help me with two questions:
   1. How I should change pipeline state from another thread?
   2. Is it correct to stop recording via changing pipeline state to NULL? Probably I should to send EOS signal on the bus and handling it?</p>