gstreamer: disconnect callbacks, avoid gst_discoverer_stop
This commit is contained in:
parent
bdc089290d
commit
4a9c9f8cd4
|
@ -105,7 +105,13 @@ GstEnginePipeline::GstEnginePipeline(GstEngine *engine)
|
||||||
equalizer_(nullptr),
|
equalizer_(nullptr),
|
||||||
rgvolume_(nullptr),
|
rgvolume_(nullptr),
|
||||||
rglimiter_(nullptr),
|
rglimiter_(nullptr),
|
||||||
discoverer_(nullptr)
|
discoverer_(nullptr),
|
||||||
|
about_to_finish_cb_id_(-1),
|
||||||
|
pad_added_cb_id_(-1),
|
||||||
|
notify_source_cb_id_(-1),
|
||||||
|
bus_cb_id_(-1),
|
||||||
|
discovery_finished_cb_id_(-1),
|
||||||
|
discovery_discovered_cb_id_(-1)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!sElementDeleter) {
|
if (!sElementDeleter) {
|
||||||
|
@ -118,18 +124,33 @@ GstEnginePipeline::GstEnginePipeline(GstEngine *engine)
|
||||||
|
|
||||||
GstEnginePipeline::~GstEnginePipeline() {
|
GstEnginePipeline::~GstEnginePipeline() {
|
||||||
|
|
||||||
if (pipeline_) {
|
if (discoverer_) {
|
||||||
gst_bus_set_sync_handler(gst_pipeline_get_bus(GST_PIPELINE(pipeline_)), nullptr, nullptr, nullptr);
|
|
||||||
g_source_remove(bus_cb_id_);
|
if (discovery_discovered_cb_id_ != -1)
|
||||||
gst_element_set_state(pipeline_, GST_STATE_NULL);
|
g_signal_handler_disconnect(G_OBJECT(discoverer_), discovery_discovered_cb_id_);
|
||||||
gst_object_unref(GST_OBJECT(pipeline_));
|
if (discovery_finished_cb_id_ != -1)
|
||||||
|
g_signal_handler_disconnect(G_OBJECT(discoverer_), discovery_finished_cb_id_);
|
||||||
|
|
||||||
|
g_object_unref(discoverer_);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (discoverer_) {
|
if (pipeline_) {
|
||||||
#ifdef Q_OS_LINUX
|
|
||||||
gst_discoverer_stop(discoverer_);
|
if (about_to_finish_cb_id_ != -1)
|
||||||
#endif
|
g_signal_handler_disconnect(G_OBJECT(pipeline_), about_to_finish_cb_id_);
|
||||||
g_object_unref(discoverer_);
|
|
||||||
|
if (pad_added_cb_id_ != -1)
|
||||||
|
g_signal_handler_disconnect(G_OBJECT(pipeline_), pad_added_cb_id_);
|
||||||
|
|
||||||
|
if (notify_source_cb_id_ != -1)
|
||||||
|
g_signal_handler_disconnect(G_OBJECT(pipeline_), notify_source_cb_id_);
|
||||||
|
|
||||||
|
gst_bus_set_sync_handler(gst_pipeline_get_bus(GST_PIPELINE(pipeline_)), nullptr, nullptr, nullptr);
|
||||||
|
if (bus_cb_id_ != -1)
|
||||||
|
g_source_remove(bus_cb_id_);
|
||||||
|
gst_element_set_state(pipeline_, GST_STATE_NULL);
|
||||||
|
|
||||||
|
gst_object_unref(GST_OBJECT(pipeline_));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -449,16 +470,15 @@ bool GstEnginePipeline::InitFromUrl(const QByteArray &stream_url, const QUrl ori
|
||||||
flags &= ~0x00000001;
|
flags &= ~0x00000001;
|
||||||
g_object_set(G_OBJECT(pipeline_), "flags", flags, nullptr);
|
g_object_set(G_OBJECT(pipeline_), "flags", flags, nullptr);
|
||||||
|
|
||||||
CHECKED_GCONNECT(G_OBJECT(pipeline_), "about-to-finish", &AboutToFinishCallback, this);
|
about_to_finish_cb_id_ = CHECKED_GCONNECT(G_OBJECT(pipeline_), "about-to-finish", &AboutToFinishCallback, this);
|
||||||
|
pad_added_cb_id_ = CHECKED_GCONNECT(G_OBJECT(pipeline_), "pad-added", &NewPadCallback, this);
|
||||||
CHECKED_GCONNECT(G_OBJECT(pipeline_), "pad-added", &NewPadCallback, this);
|
notify_source_cb_id_ = CHECKED_GCONNECT(G_OBJECT(pipeline_), "notify::source", &SourceSetupCallback, this);
|
||||||
CHECKED_GCONNECT(G_OBJECT(pipeline_), "notify::source", &SourceSetupCallback, this);
|
|
||||||
|
|
||||||
// Setting up a discoverer
|
// Setting up a discoverer
|
||||||
discoverer_ = gst_discoverer_new(kDiscoveryTimeoutS * GST_SECOND, nullptr);
|
discoverer_ = gst_discoverer_new(kDiscoveryTimeoutS * GST_SECOND, nullptr);
|
||||||
if (discoverer_) {
|
if (discoverer_) {
|
||||||
CHECKED_GCONNECT(G_OBJECT(discoverer_), "discovered", &StreamDiscovered, this);
|
discovery_discovered_cb_id_ = CHECKED_GCONNECT(G_OBJECT(discoverer_), "discovered", &StreamDiscovered, this);
|
||||||
CHECKED_GCONNECT(G_OBJECT(discoverer_), "finished", &StreamDiscoveryFinished, this);
|
discovery_finished_cb_id_ = CHECKED_GCONNECT(G_OBJECT(discoverer_), "finished", &StreamDiscoveryFinished, this);
|
||||||
gst_discoverer_start(discoverer_);
|
gst_discoverer_start(discoverer_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1230,9 +1250,10 @@ void GstEnginePipeline::StreamDiscovered(GstDiscoverer *discoverer, GstDiscovere
|
||||||
}
|
}
|
||||||
|
|
||||||
void GstEnginePipeline::StreamDiscoveryFinished(GstDiscoverer *discoverer, gpointer self) {
|
void GstEnginePipeline::StreamDiscoveryFinished(GstDiscoverer *discoverer, gpointer self) {
|
||||||
|
|
||||||
Q_UNUSED(discoverer);
|
Q_UNUSED(discoverer);
|
||||||
Q_UNUSED(self);
|
Q_UNUSED(self);
|
||||||
//GstEnginePipeline *instance = reinterpret_cast<GstEnginePipeline*>(self);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString GstEnginePipeline::GSTdiscovererErrorMessage(GstDiscovererResult result) {
|
QString GstEnginePipeline::GSTdiscovererErrorMessage(GstDiscovererResult result) {
|
||||||
|
|
|
@ -286,11 +286,17 @@ signals:
|
||||||
GstElement *rglimiter_;
|
GstElement *rglimiter_;
|
||||||
GstDiscoverer *discoverer_;
|
GstDiscoverer *discoverer_;
|
||||||
|
|
||||||
uint bus_cb_id_;
|
int about_to_finish_cb_id_;
|
||||||
|
int pad_added_cb_id_;
|
||||||
|
int notify_source_cb_id_;
|
||||||
|
int bus_cb_id_;
|
||||||
|
int discovery_finished_cb_id_;
|
||||||
|
int discovery_discovered_cb_id_;
|
||||||
|
|
||||||
QThreadPool set_state_threadpool_;
|
QThreadPool set_state_threadpool_;
|
||||||
|
|
||||||
GstSegment last_decodebin_segment_;
|
GstSegment last_decodebin_segment_;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // GSTENGINEPIPELINE_H
|
#endif // GSTENGINEPIPELINE_H
|
||||||
|
|
Loading…
Reference in New Issue