onnx: Also implement stop to clean up session
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/9176>
This commit is contained in:
parent
f48ad0fde6
commit
1fa4d154d8
@ -419,6 +419,15 @@ GstOnnxClient::GstOnnxClient (GstElement *debug_parent):debug_parent(debug_paren
|
||||
return true;
|
||||
}
|
||||
|
||||
void GstOnnxClient::destroySession (void)
|
||||
{
|
||||
if (session == NULL)
|
||||
return;
|
||||
|
||||
delete session;
|
||||
session = NULL;
|
||||
}
|
||||
|
||||
void GstOnnxClient::parseDimensions (GstVideoInfo vinfo)
|
||||
{
|
||||
int32_t newWidth = fixedInputImageSize ? width : vinfo.width;
|
||||
|
@ -67,6 +67,7 @@ namespace GstOnnxNamespace {
|
||||
GstOnnxExecutionProvider provider, GstStructure *
|
||||
tensors);
|
||||
bool hasSession(void);
|
||||
void destroySession(void);
|
||||
void setInputImageFormat(GstMlInputImageFormat format);
|
||||
GstMlInputImageFormat getInputImageFormat(void);
|
||||
GstTensorDataType getInputImageDatatype(void);
|
||||
|
@ -136,6 +136,7 @@ static gboolean
|
||||
gst_onnx_inference_set_caps (GstBaseTransform * trans, GstCaps * incaps,
|
||||
GstCaps * outcaps);
|
||||
static gboolean gst_onnx_inference_start (GstBaseTransform * trans);
|
||||
static gboolean gst_onnx_inference_stop (GstBaseTransform * trans);
|
||||
|
||||
G_DEFINE_TYPE (GstOnnxInference, gst_onnx_inference, GST_TYPE_BASE_TRANSFORM);
|
||||
|
||||
@ -332,6 +333,8 @@ gst_onnx_inference_class_init (GstOnnxInferenceClass * klass)
|
||||
GST_DEBUG_FUNCPTR (gst_onnx_inference_set_caps);
|
||||
basetransform_class->start =
|
||||
GST_DEBUG_FUNCPTR(gst_onnx_inference_start);
|
||||
basetransform_class->stop =
|
||||
GST_DEBUG_FUNCPTR(gst_onnx_inference_stop);
|
||||
|
||||
gst_type_mark_as_plugin_api (GST_TYPE_ONNX_OPTIMIZATION_LEVEL,
|
||||
(GstPluginAPIFlags) 0);
|
||||
@ -567,6 +570,19 @@ gst_onnx_inference_start (GstBaseTransform * trans)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_onnx_inference_stop (GstBaseTransform * trans)
|
||||
{
|
||||
GstOnnxInference *self = GST_ONNX_INFERENCE (trans);
|
||||
auto onnxClient = GST_ONNX_CLIENT_MEMBER (self);
|
||||
|
||||
GST_OBJECT_LOCK (self);
|
||||
if (onnxClient->hasSession ())
|
||||
GST_ONNX_CLIENT_MEMBER (self)->destroySession ();
|
||||
GST_OBJECT_UNLOCK (self);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_onnx_inference_set_caps (GstBaseTransform * trans, GstCaps * incaps,
|
||||
|
Loading…
x
Reference in New Issue
Block a user