mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-23 08:46:40 +00:00
omx: Some minor refactoring and cleanup
This commit is contained in:
parent
4399c0b96b
commit
219a93bbaf
8 changed files with 20 additions and 17 deletions
20
omx/gstomx.c
20
omx/gstomx.c
|
@ -554,13 +554,14 @@ static OMX_CALLBACKTYPE callbacks =
|
||||||
|
|
||||||
/* NOTE: Uses comp->lock and comp->messages_lock */
|
/* NOTE: Uses comp->lock and comp->messages_lock */
|
||||||
GstOMXComponent *
|
GstOMXComponent *
|
||||||
gst_omx_component_new (GstObject * parent, const GstOMXClassData * cdata)
|
gst_omx_component_new (GstObject * parent, const gchar * core_name,
|
||||||
|
const gchar * component_name, const gchar * component_role, guint64 hacks)
|
||||||
{
|
{
|
||||||
OMX_ERRORTYPE err;
|
OMX_ERRORTYPE err;
|
||||||
GstOMXCore *core;
|
GstOMXCore *core;
|
||||||
GstOMXComponent *comp;
|
GstOMXComponent *comp;
|
||||||
|
|
||||||
core = gst_omx_core_acquire (cdata->core_name);
|
core = gst_omx_core_acquire (core_name);
|
||||||
if (!core)
|
if (!core)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
@ -568,21 +569,21 @@ gst_omx_component_new (GstObject * parent, const GstOMXClassData * cdata)
|
||||||
comp->core = core;
|
comp->core = core;
|
||||||
|
|
||||||
err =
|
err =
|
||||||
core->get_handle (&comp->handle, (OMX_STRING) cdata->component_name, comp,
|
core->get_handle (&comp->handle, (OMX_STRING) component_name, comp,
|
||||||
&callbacks);
|
&callbacks);
|
||||||
if (err != OMX_ErrorNone) {
|
if (err != OMX_ErrorNone) {
|
||||||
GST_ERROR_OBJECT (parent,
|
GST_ERROR_OBJECT (parent,
|
||||||
"Failed to get component handle '%s' from core '%s': 0x%08x",
|
"Failed to get component handle '%s' from core '%s': 0x%08x",
|
||||||
cdata->component_name, cdata->core_name, err);
|
component_name, core_name, err);
|
||||||
gst_omx_core_release (core);
|
gst_omx_core_release (core);
|
||||||
g_slice_free (GstOMXComponent, comp);
|
g_slice_free (GstOMXComponent, comp);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
GST_DEBUG_OBJECT (parent,
|
GST_DEBUG_OBJECT (parent,
|
||||||
"Successfully got component handle %p (%s) from core '%s'", comp->handle,
|
"Successfully got component handle %p (%s) from core '%s'", comp->handle,
|
||||||
cdata->component_name, cdata->core_name);
|
component_name, core_name);
|
||||||
comp->parent = gst_object_ref (parent);
|
comp->parent = gst_object_ref (parent);
|
||||||
comp->hacks = cdata->hacks;
|
comp->hacks = hacks;
|
||||||
|
|
||||||
comp->ports = g_ptr_array_new ();
|
comp->ports = g_ptr_array_new ();
|
||||||
comp->n_in_ports = 0;
|
comp->n_in_ports = 0;
|
||||||
|
@ -597,19 +598,18 @@ gst_omx_component_new (GstObject * parent, const GstOMXClassData * cdata)
|
||||||
comp->last_error = OMX_ErrorNone;
|
comp->last_error = OMX_ErrorNone;
|
||||||
|
|
||||||
/* Set component role if any */
|
/* Set component role if any */
|
||||||
if (cdata->component_role && !(cdata->hacks & GST_OMX_HACK_NO_COMPONENT_ROLE)) {
|
if (component_role && !(hacks & GST_OMX_HACK_NO_COMPONENT_ROLE)) {
|
||||||
OMX_PARAM_COMPONENTROLETYPE param;
|
OMX_PARAM_COMPONENTROLETYPE param;
|
||||||
|
|
||||||
GST_OMX_INIT_STRUCT (¶m);
|
GST_OMX_INIT_STRUCT (¶m);
|
||||||
|
|
||||||
g_strlcpy ((gchar *) param.cRole, cdata->component_role,
|
g_strlcpy ((gchar *) param.cRole, component_role, sizeof (param.cRole));
|
||||||
sizeof (param.cRole));
|
|
||||||
err =
|
err =
|
||||||
gst_omx_component_set_parameter (comp,
|
gst_omx_component_set_parameter (comp,
|
||||||
OMX_IndexParamStandardComponentRole, ¶m);
|
OMX_IndexParamStandardComponentRole, ¶m);
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (parent, "Setting component role to '%s': %s (0x%08x)",
|
GST_DEBUG_OBJECT (parent, "Setting component role to '%s': %s (0x%08x)",
|
||||||
cdata->component_role, gst_omx_error_to_string (err), err);
|
component_role, gst_omx_error_to_string (err), err);
|
||||||
|
|
||||||
/* If setting the role failed this component is unusable */
|
/* If setting the role failed this component is unusable */
|
||||||
if (err != OMX_ErrorNone) {
|
if (err != OMX_ErrorNone) {
|
||||||
|
|
|
@ -268,7 +268,7 @@ GstOMXCore * gst_omx_core_acquire (const gchar * filename);
|
||||||
void gst_omx_core_release (GstOMXCore * core);
|
void gst_omx_core_release (GstOMXCore * core);
|
||||||
|
|
||||||
|
|
||||||
GstOMXComponent * gst_omx_component_new (GstObject * parent, const GstOMXClassData *cdata);
|
GstOMXComponent * gst_omx_component_new (GstObject * parent, const gchar *core_name, const gchar *component_name, const gchar * component_role, guint64 hacks);
|
||||||
void gst_omx_component_free (GstOMXComponent * comp);
|
void gst_omx_component_free (GstOMXComponent * comp);
|
||||||
|
|
||||||
OMX_ERRORTYPE gst_omx_component_set_state (GstOMXComponent * comp, OMX_STATETYPE state);
|
OMX_ERRORTYPE gst_omx_component_set_state (GstOMXComponent * comp, OMX_STATETYPE state);
|
||||||
|
|
|
@ -105,7 +105,9 @@ gst_omx_audio_enc_open (GstOMXAudioEnc * self)
|
||||||
GstOMXAudioEncClass *klass = GST_OMX_AUDIO_ENC_GET_CLASS (self);
|
GstOMXAudioEncClass *klass = GST_OMX_AUDIO_ENC_GET_CLASS (self);
|
||||||
|
|
||||||
self->component =
|
self->component =
|
||||||
gst_omx_component_new (GST_OBJECT_CAST (self), &klass->cdata);
|
gst_omx_component_new (GST_OBJECT_CAST (self), klass->cdata.core_name,
|
||||||
|
klass->cdata.component_name, klass->cdata.component_role,
|
||||||
|
klass->cdata.hacks);
|
||||||
self->started = FALSE;
|
self->started = FALSE;
|
||||||
|
|
||||||
if (!self->component)
|
if (!self->component)
|
||||||
|
|
|
@ -50,7 +50,6 @@ struct _GstOMXAudioEnc
|
||||||
GstAudioEncoder parent;
|
GstAudioEncoder parent;
|
||||||
|
|
||||||
/* < protected > */
|
/* < protected > */
|
||||||
GstOMXCore *core;
|
|
||||||
GstOMXComponent *component;
|
GstOMXComponent *component;
|
||||||
GstOMXPort *in_port, *out_port;
|
GstOMXPort *in_port, *out_port;
|
||||||
|
|
||||||
|
|
|
@ -131,7 +131,9 @@ gst_omx_video_dec_open (GstVideoDecoder * decoder)
|
||||||
GST_DEBUG_OBJECT (self, "Opening decoder");
|
GST_DEBUG_OBJECT (self, "Opening decoder");
|
||||||
|
|
||||||
self->component =
|
self->component =
|
||||||
gst_omx_component_new (GST_OBJECT_CAST (self), &klass->cdata);
|
gst_omx_component_new (GST_OBJECT_CAST (self), klass->cdata.core_name,
|
||||||
|
klass->cdata.component_name, klass->cdata.component_role,
|
||||||
|
klass->cdata.hacks);
|
||||||
self->started = FALSE;
|
self->started = FALSE;
|
||||||
|
|
||||||
if (!self->component)
|
if (!self->component)
|
||||||
|
|
|
@ -50,7 +50,6 @@ struct _GstOMXVideoDec
|
||||||
GstVideoDecoder parent;
|
GstVideoDecoder parent;
|
||||||
|
|
||||||
/* < protected > */
|
/* < protected > */
|
||||||
GstOMXCore *core;
|
|
||||||
GstOMXComponent *component;
|
GstOMXComponent *component;
|
||||||
GstOMXPort *in_port, *out_port;
|
GstOMXPort *in_port, *out_port;
|
||||||
|
|
||||||
|
|
|
@ -220,7 +220,9 @@ gst_omx_video_enc_open (GstVideoEncoder * encoder)
|
||||||
GstOMXVideoEncClass *klass = GST_OMX_VIDEO_ENC_GET_CLASS (self);
|
GstOMXVideoEncClass *klass = GST_OMX_VIDEO_ENC_GET_CLASS (self);
|
||||||
|
|
||||||
self->component =
|
self->component =
|
||||||
gst_omx_component_new (GST_OBJECT_CAST (self), &klass->cdata);
|
gst_omx_component_new (GST_OBJECT_CAST (self), klass->cdata.core_name,
|
||||||
|
klass->cdata.component_name, klass->cdata.component_role,
|
||||||
|
klass->cdata.hacks);
|
||||||
self->started = FALSE;
|
self->started = FALSE;
|
||||||
|
|
||||||
if (!self->component)
|
if (!self->component)
|
||||||
|
|
|
@ -53,7 +53,6 @@ struct _GstOMXVideoEnc
|
||||||
|
|
||||||
GstOMXClassData cdata;
|
GstOMXClassData cdata;
|
||||||
|
|
||||||
GstOMXCore *core;
|
|
||||||
GstOMXComponent *component;
|
GstOMXComponent *component;
|
||||||
GstOMXPort *in_port, *out_port;
|
GstOMXPort *in_port, *out_port;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue