|
@@ -46,7 +46,7 @@ GstElement *g_streammux = NULL;
|
|
|
|
|
|
namespace MIVA{
|
|
|
std::shared_ptr<Inference> infer = NULL;
|
|
|
- ThreadPool pool(3,ThreadPool::PRIORITY_HIGHEST, false);
|
|
|
+ // ThreadPool pool(3,ThreadPool::PRIORITY_HIGHEST, false);
|
|
|
std::shared_ptr<Inference> Inference::CreateNew()
|
|
|
{
|
|
|
if(infer == NULL) infer = std::make_shared<Inference>();
|
|
@@ -215,37 +215,26 @@ namespace MIVA{
|
|
|
}
|
|
|
void Inference::StopTask()
|
|
|
{
|
|
|
- pool.async([&](){
|
|
|
- int sourceId = 0;
|
|
|
- g_mutex_lock (&eos_lock);
|
|
|
- std::vector<DataSource>::iterator iter;
|
|
|
- for (iter = this->m_DataList.begin(); iter != this->m_DataList.end(); iter++){
|
|
|
- if(iter->Play){
|
|
|
- this->stop_release_source(sourceId);
|
|
|
- iter->Play = false;
|
|
|
- }
|
|
|
- sourceId++;
|
|
|
+ int sourceId = 0;
|
|
|
+ std::vector<DataSource>::iterator iter;
|
|
|
+ for (iter = this->m_DataList.begin(); iter != this->m_DataList.end(); iter++){
|
|
|
+ if(iter->Play){
|
|
|
+ gst_element_set_state(iter->source_bin, GST_STATE_READY);
|
|
|
+ iter->Play = false;
|
|
|
}
|
|
|
- g_mutex_unlock (&eos_lock);
|
|
|
- NoticeCenter::Instance().emitEvent(NOTICE_RELEASE);
|
|
|
- });
|
|
|
- pool.start();
|
|
|
+ sourceId++;
|
|
|
+ }
|
|
|
+ NoticeCenter::Instance().emitEvent(NOTICE_RELEASE);
|
|
|
}
|
|
|
void Inference::RestartTask()
|
|
|
{
|
|
|
- pool.async([&](){
|
|
|
- int sourceId = 0;
|
|
|
- std::vector<DataSource>::iterator iter;
|
|
|
- for (iter = this->m_DataList.begin(); iter != this->m_DataList.end(); iter++){
|
|
|
- if(iter->Play == false){
|
|
|
- this->add_sources(sourceId, iter->uri);
|
|
|
- iter->Play = true;
|
|
|
- }
|
|
|
- sourceId++;
|
|
|
+ std::vector<DataSource>::iterator iter;
|
|
|
+ for (iter = this->m_DataList.begin(); iter != this->m_DataList.end(); iter++){
|
|
|
+ if(iter->Play == false){
|
|
|
+ gst_element_set_state(iter->source_bin, GST_STATE_PLAYING);
|
|
|
+ iter->Play = true;
|
|
|
}
|
|
|
- gst_element_set_state(this->pipeline, GST_STATE_PLAYING);
|
|
|
- });
|
|
|
- pool.start();
|
|
|
+ }
|
|
|
}
|
|
|
// 销毁对象
|
|
|
void Inference::Destory()
|
|
@@ -383,6 +372,7 @@ namespace MIVA{
|
|
|
gchar pad_name[16];
|
|
|
GstPad *sinkpad = NULL;
|
|
|
|
|
|
+ g_mutex_lock (&eos_lock);
|
|
|
state_return = gst_element_set_state (m_DataList[source_id].source_bin, GST_STATE_NULL);
|
|
|
switch (state_return) {
|
|
|
case GST_STATE_CHANGE_SUCCESS:
|
|
@@ -403,13 +393,13 @@ namespace MIVA{
|
|
|
state_return =
|
|
|
gst_element_get_state (m_DataList[source_id].source_bin, NULL, NULL,
|
|
|
GST_CLOCK_TIME_NONE);
|
|
|
- g_snprintf (pad_name, 15, "sink_%u", source_id);
|
|
|
- sinkpad = gst_element_get_static_pad (streammux, pad_name);
|
|
|
- gst_pad_send_event (sinkpad, gst_event_new_flush_stop (FALSE));
|
|
|
- gst_element_release_request_pad (streammux, sinkpad);
|
|
|
- g_print ("STATE CHANGE ASYNC %p\n\n", sinkpad);
|
|
|
- gst_object_unref (sinkpad);
|
|
|
- gst_bin_remove (GST_BIN (this->pipeline), m_DataList[source_id].source_bin);
|
|
|
+ g_snprintf (pad_name, 15, "sink_%u", source_id);
|
|
|
+ sinkpad = gst_element_get_static_pad (streammux, pad_name);
|
|
|
+ gst_pad_send_event (sinkpad, gst_event_new_flush_stop (FALSE));
|
|
|
+ gst_element_release_request_pad (streammux, sinkpad);
|
|
|
+ g_print ("STATE CHANGE ASYNC %p\n\n", sinkpad);
|
|
|
+ gst_object_unref (sinkpad);
|
|
|
+ gst_bin_remove (GST_BIN (this->pipeline), m_DataList[source_id].source_bin);
|
|
|
break;
|
|
|
case GST_STATE_CHANGE_NO_PREROLL:
|
|
|
InfoL << "STATE CHANGE NO PREROLL";
|
|
@@ -417,6 +407,7 @@ namespace MIVA{
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
+ g_mutex_unlock (&eos_lock);
|
|
|
}
|
|
|
void Inference::cb_newpad (GstElement * decodebin, GstPad * pad, gpointer data)
|
|
|
{
|