大佬教程收集整理的这篇文章主要介绍了c – g_main_loop_run阻止Qthread,不允许停止视频,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
有人能告诉我如何解决这个问题?我可以用其他命令替换g_main_loop_run,或者可以使用g_main_loop_quit(gloop);用另一种方式.
void StreamingVideo::slotStartStream() // this slot called on start of thread from main thread { if( !iSELER_83_11845@entsLinked() ) { qDebug() << " we are emitTing in dummy server "; //emit sigFailed( "elementsFailed" ); // WILL CONNECT IT WITH MAIN GUI ONXCE CODE IS FINISHED return; } gsT_Bus_add_watch( bus,busCall,gloop ); gst_object_unref( bus ); //proper adding to pipe gsT_Bin_add_many( GST_BIN( pipeline ),source,capsFilter,conv,videoRate,capsFilterRate,clockDisplay,videoEnc,udpSink,NULL ); //proper linking: gst_element_link_many( source,NULL ); g_print("Linked all the Elements together\n"); gst_element_set_state( pipeline,GST_STATE_PLAYING ); // Iterate g_print ("Running...\n"); emit sigStartStream(); // signal to main thread to issue success command . works fine g_main_loop_run( gloop ); g_print ("Returned,stopping playBACk\n"); //gst_element_set_state (pipeline,GST_STATE_null); if( g_main_loop_is_running( gloop ) ) { qDebug() << " in g_main_loop_is_runnung emiTing signal "; emit sigStartStream(); } if( !g_main_loop_is_running( gloop) ) { qDebug() << "in not gmain running thread id"; qDebug() << QThread::currentThreadId(); } } void StreamingVideo::slotStopStream() // THIS SLOT IS NOT CALLED WHEN VIDEO RUNNING { qDebug() << " we are plAnning to stop streaming stramingVideo::slotStopStream "; g_print ("Returned,stopping playBACk\n"); g_main_loop_quit( gloop ); gst_element_set_state (pipeline,GST_STATE_null); // g_main_loop_quit( gloop ); releaseMemory(); emit sigStopStream(); // signal to main thread to issue message saying video has stopped. }
//主线程的某处
threadStreaming = new QThread(); streamVideo = new StreamingVideo( "127.0.0.1"); // we will automate this ip address later on streamVideo->moveToThread( threadStreaming ); connect( threadStreaming,SIGNAL( started() ),streamVideo,SLOT( slotStartStream() ) ); connect( streamVideo,SIGNAL( sigStopStream() ),threadStreaming,SLOT( quit() ) ); connect( streamVideo,SLOT(deleteLater() ) ); connect( threadStreaming,SIGNAL( finished() ),SLOT(deleteLater() ) ); connect( streamVideo,SIGNAL( sigStartStream() ),this,SLOT( slotTrueStreamRun() ) ); connect( streamVideo,SLOT( slotfalseStreamRun() ) ); connect( this,SIGNAL( sigMopsCamStopCmd() ),SLOT(slotStopStream() ) ); threadStreaming->start();
以上是大佬教程为你收集整理的c – g_main_loop_run阻止Qthread,不允许停止视频全部内容,希望文章能够帮你解决c – g_main_loop_run阻止Qthread,不允许停止视频所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。