[gst-devel] how to make gstreamer run in separate thread

wl2776 wl2776 at gmail.com
Fri Apr 16 09:53:38 CEST 2010



Bugzilla from 4ernov at gmail.com wrote:
> 
> I try to make whole gstreamer pipeline live in a separate thread. 
> ...
> Is there any way to make message dispatching process run in different
> thread other than main? Or somehow bind GStreamer event loop to Qt's
> event loop of some QThread object?
> 

Two variants.
1. Poll a message bus in your application's main loop
http://n4.nabble.com/How-can-I-have-two-main-loops-in-my-program-tt1594663.html#a1594734
http://n4.nabble.com/running-g-main-loop-run-in-separate-thread-question-tt1680629.html#a1680629

2. Run a GThread. GStreamer uses glib, so it's anyway included.

I do this way.

class gst_player{
  public:
....
    void  main_loop_thread(void) ///< функция для запуска g_main_loop_run в
отдельном потоке
      g_main_loop_run(m_loop); 
      g_thread_exit(0);
    };			
    void  open(char *filename) ;
 ....
  protected:
    GMainLoop *m_loop;	 ///< экземпляр mainloop
    GThread *m_loop_thread; ///< Поток, в котором будет работать mainloop
  ...  
};

....

static void main_loop_run(gpointer data)
{
  if(!data)
    return;
  gst_player *player = (gst_player *)data;
  player->main_loop_thread();
}

... 
void gst_player::open(char * filename)
{
  close();
  m_loop = g_main_loop_new(NULL,FALSE);
 ... 
 
if((m_loop_thread=g_thread_create((GThreadFunc)main_loop_run,this,FALSE,NULL))==NULL){
    close();
    report_error();
  }
  ...
}


-- 
View this message in context: http://n4.nabble.com/how-to-make-gstreamer-run-in-separate-thread-tp1960435p1963116.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.




More information about the gstreamer-devel mailing list