Exemplo n.º 1
0
static gboolean
plugin_init (GstPlugin *plugin)
{
    GQuark library_name_quark;
    GQuark component_name_quark;
    GQuark component_role_quark;
    GST_DEBUG_CATEGORY_INIT (gstomx_debug, "omx", 0, "gst-openmax");
    GST_DEBUG_CATEGORY_INIT (gstomx_util_debug, "omx_util", 0, "gst-openmax utility");
    GST_DEBUG_CATEGORY_INIT (gstomx_ppm, "omx_ppm", 0,
                             "gst-openmax performance");

    library_name_quark = g_quark_from_static_string ("library-name");
    component_name_quark = g_quark_from_static_string ("component-name");
    component_role_quark = g_quark_from_static_string ("component-role");

    g_omx_init ();

    {
        guint i;
        for (i = 0; element_table[i].name; i++)
        {
            TableItem *element;
            GType type;

            element = &element_table[i];
            type = element->get_type ();
            g_type_set_qdata (type, library_name_quark, (gpointer) element->library_name);
            g_type_set_qdata (type, component_name_quark, (gpointer) element->component_name);
            g_type_set_qdata (type, component_role_quark, (gpointer) element->component_role);

            if (!gst_element_register (plugin, element->name, element->rank, type))
            {
                g_warning ("failed registering '%s'", element->name);
                return FALSE;
            }
        }
    }

    return TRUE;
}
static gboolean
plugin_init (GstPlugin * plugin)
{
  guint i, cnt;

  GST_DEBUG_CATEGORY_INIT (gstomx_debug, "omx", 0, "gst-openmax");
  GST_DEBUG_CATEGORY_INIT (gstomx_util_debug, "omx_util", 0,
      "gst-openmax utility");

  element_name_quark = g_quark_from_static_string ("element-name");

  /*
   * First, call all the _get_type() functions to ensure the types are
   * registered.
   */
  for (i = 0; i < G_N_ELEMENTS (get_type); i++)
    get_type[i] ();

  fetch_element_table (plugin);

  g_omx_init ();

  cnt = gst_structure_n_fields (element_table);
  for (i = 0; i < cnt; i++) {
    const gchar *element_name = gst_structure_nth_field_name (element_table, i);
    GstStructure *element = get_element_entry (element_name);
    const gchar *type_name, *parent_type_name;
    const gchar *component_name, *library_name;
    GType type;
    gint rank;

    GST_DEBUG ("element_name=%s, element=%" GST_PTR_FORMAT, element_name,
        element);

    parent_type_name = gst_structure_get_string (element, "parent-type");
    type_name = gst_structure_get_string (element, "type");
    component_name = gst_structure_get_string (element, "component-name");
    library_name = gst_structure_get_string (element, "library-name");

    if (!type_name || !component_name || !library_name) {
      g_warning ("malformed config file: missing required fields for %s",
          element_name);
      return FALSE;
    }

    if (parent_type_name) {
      type = g_type_from_name (parent_type_name);
      if (type) {
        type = create_subtype (type, type_name);
      } else {
        g_warning ("malformed config file: invalid parent-type '%s' for %s",
            parent_type_name, element_name);
        return FALSE;
      }
    } else {
      type = g_type_from_name (type_name);
    }

    if (!type) {
      g_warning ("malformed config file: invalid type '%s' for %s",
          type_name, element_name);
      return FALSE;
    }

    g_type_set_qdata (type, element_name_quark, (gpointer) element_name);

    if (!gst_structure_get_int (element, "rank", &rank)) {
      /* use default rank: */
      rank = GST_RANK_NONE;
    }

    if (!gst_element_register (plugin, element_name, rank, type)) {
      g_warning ("failed registering '%s'", element_name);
      return FALSE;
    }
  }

  return TRUE;
}