/*
 * preset_get_paths:
 * @preset: a #GObject that implements #GstPreset
 * @preset_user_path: location for path or %NULL
 * @preset_system_path: location for path or %NULL
 *
 * Fetch the preset_path for user local and system wide settings. Don't free
 * after use.
 *
 * Returns: %FALSE if no paths could be found.
 */
static gboolean
preset_get_paths (GstPreset * preset, const gchar ** preset_user_path,
    const gchar ** preset_system_path)
{
  GType type = G_TYPE_FROM_INSTANCE (preset);
  gchar *preset_path;
  const gchar *element_name;

  /* we use the element name when we must contruct the paths */
  element_name = G_OBJECT_TYPE_NAME (preset);
  GST_INFO_OBJECT (preset, "element_name: '%s'", element_name);

  if (preset_user_path) {
    /* preset user path requested, see if we have it cached in the qdata */
    if (!(preset_path = g_type_get_qdata (type, preset_user_path_quark))) {
      gchar *preset_dir;

      /* user presets go in '$HOME/.gstreamer-0.10/presets/GstSimSyn.prs' */
      preset_dir = g_build_filename (g_get_home_dir (),
          ".gstreamer-" GST_MAJORMINOR, "presets", NULL);
      GST_INFO_OBJECT (preset, "user_preset_dir: '%s'", preset_dir);
      preset_path =
          g_strdup_printf ("%s" G_DIR_SEPARATOR_S "%s.prs", preset_dir,
          element_name);
      GST_INFO_OBJECT (preset, "user_preset_path: '%s'", preset_path);
      /* create dirs */
      g_mkdir_with_parents (preset_dir, 0755);
      g_free (preset_dir);

      /* cache the preset path to the type */
      g_type_set_qdata (type, preset_user_path_quark, preset_path);
    }
    *preset_user_path = preset_path;
  }

  if (preset_system_path) {
    /* preset system path requested, see if we have it cached in the qdata */
    if (!(preset_path = g_type_get_qdata (type, preset_system_path_quark))) {
      gchar *preset_dir;

      /* system presets in '$GST_DATADIR/gstreamer-0.10/presets/GstAudioPanorama.prs' */
      preset_dir = g_build_filename (GST_DATADIR, "gstreamer-" GST_MAJORMINOR,
          "presets", NULL);
      GST_INFO_OBJECT (preset, "system_preset_dir: '%s'", preset_dir);
      preset_path = g_strdup_printf ("%s" G_DIR_SEPARATOR_S "%s.prs",
          preset_dir, element_name);
      GST_INFO_OBJECT (preset, "system_preset_path: '%s'", preset_path);
      /* create dirs */
      g_mkdir_with_parents (preset_dir, 0755);
      g_free (preset_dir);

      /* cache the preset path to the type */
      g_type_set_qdata (type, preset_system_path_quark, preset_path);
    }
    *preset_system_path = preset_path;
  }
  return TRUE;
}
static void
type_instance_init (GTypeInstance *instance,
                    gpointer g_class)
{
    GstOmxBaseFilter *self;
    GstElementClass *element_class;

    element_class = GST_ELEMENT_CLASS (g_class);

    self = GST_OMX_BASE_FILTER (instance);

    GST_LOG_OBJECT (self, "begin");

    self->use_timestamps = TRUE;

    /* GOmx */
    {
        GOmxCore *gomx;
        self->gomx = gomx = g_omx_core_new ();
        gomx->object = self;
    }

    self->ready_lock = g_mutex_new ();

    self->sinkpad =
        gst_pad_new_from_template (gst_element_class_get_pad_template (element_class, "sink"), "sink");

    gst_pad_set_chain_function (self->sinkpad, pad_chain);
    gst_pad_set_event_function (self->sinkpad, pad_event);

    self->srcpad =
        gst_pad_new_from_template (gst_element_class_get_pad_template (element_class, "src"), "src");

    gst_pad_set_activatepush_function (self->srcpad, activate_push);

    gst_pad_use_fixed_caps (self->srcpad);

    gst_element_add_pad (GST_ELEMENT (self), self->sinkpad);
    gst_element_add_pad (GST_ELEMENT (self), self->srcpad);

    {
        const char *tmp;
        tmp = g_type_get_qdata (G_OBJECT_CLASS_TYPE (g_class),
                                g_quark_from_static_string ("library-name"));
        self->omx_library = g_strdup (tmp);
        tmp = g_type_get_qdata (G_OBJECT_CLASS_TYPE (g_class),
                                g_quark_from_static_string ("component-name"));
        self->omx_component = g_strdup (tmp);
    }

    GST_LOG_OBJECT (self, "end");
}
void
mcd_dbus_get_interfaces (TpSvcDBusProperties *self, const gchar *name,
			 GValue *value)
{
    McdInterfaceData *iface_data, *id;
    GPtrArray *a_ifaces;
    GType type;

    DEBUG ("called");

    a_ifaces = g_ptr_array_new ();

    for (type = G_OBJECT_TYPE (self); type != 0; type = g_type_parent (type))
    {
	iface_data = g_type_get_qdata (type, MCD_INTERFACES_QUARK);
	if (!iface_data) continue;

	for (id = iface_data; id->get_type; id++)
        {
            if (id->optional &&
                !mcd_dbus_is_active_optional_interface (self,
                                                        id->get_type ()))
            {
                DEBUG ("skipping inactive optional iface %s", id->interface);
                continue;
            }

	    g_ptr_array_add (a_ifaces, g_strdup (id->interface));
        }
    }
    g_ptr_array_add (a_ifaces, NULL);

    g_value_init (value, G_TYPE_STRV);
    g_value_take_boxed (value, g_ptr_array_free (a_ifaces, FALSE));
}
Exemple #4
0
static MooPlugin *
moo_plugin_get (GType type)
{
    g_return_val_if_fail (g_type_is_a (type, MOO_TYPE_PLUGIN), NULL);
    plugin_store_init ();
    return g_type_get_qdata (type, MOO_PLUGIN_QUARK);
}
gboolean
gstomx_get_component_info (void *core, GType type)
{
  GOmxCore *rcore = core;
  const gchar *element_name;
  GstStructure *element;
  const gchar *str;

  element_name = g_type_get_qdata (type, element_name_quark);
  element = get_element_entry (element_name);

  if (!element)
    return FALSE;

  str = gst_structure_get_string (element, "library-name");
  rcore->library_name = g_strdup (str);

  str = gst_structure_get_string (element, "component-name");
  rcore->component_name = g_strdup (str);

  str = gst_structure_get_string (element, "component-role");
  rcore->component_role = g_strdup (str);

  return TRUE;
}
PyObject*
pyg_enum_from_gtype (GType gtype, int value)
{
    PyObject *pyclass, *values, *retval, *intvalue;

    g_return_val_if_fail(gtype != G_TYPE_INVALID, NULL);

    /* Get a wrapper class by:
     * 1. check for one attached to the gtype
     * 2. lookup one in a typelib
     * 3. creating a new one
     */
    pyclass = (PyObject*)g_type_get_qdata(gtype, pygenum_class_key);
//     if (!pyclass)
//         pyclass = pygi_type_import_by_g_type(gtype);
    if (!pyclass)
        pyclass = pyg_enum_add(NULL, g_type_name(gtype), NULL, gtype);
    if (!pyclass)
	return PYGLIB_PyLong_FromLong(value);

    values = PyDict_GetItemString(((PyTypeObject *)pyclass)->tp_dict,
				  "__enum_values__");
    intvalue = PYGLIB_PyLong_FromLong(value);
    retval = PyDict_GetItem(values, intvalue);
    if (retval) {
	Py_INCREF(retval);
    }
    else {
	PyErr_Clear();
	retval = pyg_enum_val_new(pyclass, gtype, intvalue);
    }
    Py_DECREF(intvalue);

    return retval;
}
GstCaps *
gstomx_template_caps (GType type, const gchar * pad_name)
{
  const gchar *element_name;
  GstStructure *element;
  const gchar *caps_str;

  element_name = g_type_get_qdata (type, element_name_quark);
  element = get_element_entry (element_name);


  /* this shouldn't really happen.. */
  if (!element)
    return GST_CAPS_ANY;

  caps_str = gst_structure_get_string (element, pad_name);

  GST_DEBUG ("%s: %s", element_name, caps_str);

  /* default to ANY.. at least for now.. maybe when everything is converted
   * over, we should treat missing caps as a more serious condition?
   */
  if (!caps_str) {
    g_warning ("%s is missing required field: %s", element_name, pad_name);
    return GST_CAPS_ANY;
  }

  return gst_caps_from_string (caps_str);
}
Exemple #8
0
JSObject *
gjs_gtype_create_gtype_wrapper (JSContext *context,
                                GType      gtype)
{
    JSObject *object;
    JSObject *global;

    JS_BeginRequest(context);

    /* put constructor for GIRepositoryGType() in the global namespace */
    global = gjs_get_import_global(context);
    gjs_gtype_create_proto(context, global, "GIRepositoryGType", NULL);

    object = g_type_get_qdata(gtype, gjs_get_gtype_wrapper_quark());
    if (object != NULL)
        goto out;

    object = JS_NewObject(context, &gjs_gtype_class, NULL, NULL);
    if (object == NULL)
        goto out;

    JS_SetPrivate(context, object, GSIZE_TO_POINTER(gtype));
    g_type_set_qdata(gtype, gjs_get_gtype_wrapper_quark(), object);

 out:
    JS_EndRequest(context);
    return object;
}
void
nm_properties_changed_signal_add_property (GType       type,
                                           const char *dbus_property_name,
                                           const char *gobject_property_name)
{
	NMPropertiesChangedClassInfo *classinfo;
	char *hyphen_name, *p;

	classinfo = g_type_get_qdata (type, nm_properties_changed_signal_quark ());
	if (!classinfo)
		classinfo = nm_properties_changed_signal_setup_type (type);

	g_assert (!g_hash_table_contains (classinfo->exported_props, (char *) gobject_property_name));
	g_hash_table_insert (classinfo->exported_props,
	                     (char *) gobject_property_name,
	                     (char *) dbus_property_name);

	if (!strchr (gobject_property_name, '_'))
		return;
	hyphen_name = g_strdup (gobject_property_name);
	for (p = hyphen_name; *p; p++) {
		if (*p == '_')
			*p = '-';
	}
	g_assert (!g_hash_table_contains (classinfo->exported_props, hyphen_name));
	g_hash_table_insert (classinfo->exported_props,
	                     (char *) g_intern_string (hyphen_name),
	                     (char *) dbus_property_name);
	g_free (hyphen_name);
}
static void
gst_ffmpegenc_base_init (GstFFMpegEncClass * klass)
{
  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
  AVCodec *in_plugin;
  GstElementDetails details;
  GstPadTemplate *srctempl = NULL, *sinktempl = NULL;
  GstCaps *srccaps = NULL, *sinkcaps = NULL;

  in_plugin =
      (AVCodec *) g_type_get_qdata (G_OBJECT_CLASS_TYPE (klass),
      GST_FFENC_PARAMS_QDATA);
  g_assert (in_plugin != NULL);

  /* construct the element details struct */
  details.longname = g_strdup_printf ("FFmpeg %s encoder",
      in_plugin->long_name);
  details.klass = g_strdup_printf ("Codec/Encoder/%s",
      (in_plugin->type == CODEC_TYPE_VIDEO) ? "Video" : "Audio");
  details.description = g_strdup_printf ("FFmpeg %s encoder", in_plugin->name);
  details.author = "Wim Taymans <*****@*****.**>, "
      "Ronald Bultje <*****@*****.**>";
  gst_element_class_set_details (element_class, &details);
  g_free (details.longname);
  g_free (details.klass);
  g_free (details.description);

  if (!(srccaps = gst_ffmpeg_codecid_to_caps (in_plugin->id, NULL, TRUE))) {
    GST_DEBUG ("Couldn't get source caps for encoder '%s'", in_plugin->name);
    srccaps = gst_caps_new_simple ("unknown/unknown", NULL);
  }

  if (in_plugin->type == CODEC_TYPE_VIDEO) {
    sinkcaps = gst_caps_from_string
        ("video/x-raw-rgb; video/x-raw-yuv; video/x-raw-gray");
  } else {
    sinkcaps = gst_ffmpeg_codectype_to_audio_caps (NULL,
        in_plugin->id, TRUE, in_plugin);
  }
  if (!sinkcaps) {
    GST_DEBUG ("Couldn't get sink caps for encoder '%s'", in_plugin->name);
    sinkcaps = gst_caps_new_simple ("unknown/unknown", NULL);
  }

  /* pad templates */
  sinktempl = gst_pad_template_new ("sink", GST_PAD_SINK,
      GST_PAD_ALWAYS, sinkcaps);
  srctempl = gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS, srccaps);

  gst_element_class_add_pad_template (element_class, srctempl);
  gst_element_class_add_pad_template (element_class, sinktempl);

  klass->in_plugin = in_plugin;
  klass->srctempl = srctempl;
  klass->sinktempl = sinktempl;
  klass->sinkcaps = NULL;

  return;
}
Exemple #11
0
/**
 * gst_meta_api_type_has_tag:
 * @api: an API
 * @tag: the tag to check
 *
 * Check if @api was registered with @tag.
 *
 * Returns: %TRUE if @api was registered with @tag.
 */
gboolean
gst_meta_api_type_has_tag (GType api, GQuark tag)
{
  g_return_val_if_fail (api != 0, FALSE);
  g_return_val_if_fail (tag != 0, FALSE);

  return g_type_get_qdata (api, tag) != NULL;
}
/**
 * Construct new core
 *
 * @object: the GstOmx object (ie. GstOmxBaseFilter, GstOmxBaseSrc, or
 *    GstOmxBaseSink).  The GstOmx object should have "component-role",
 *    "component-name", and "library-name" properties.
 */
GOmxCore *
g_omx_core_new (gpointer object, gpointer klass)
{
    GOmxCore *core;

    core = g_new0 (GOmxCore, 1);

    core->object = object;

    core->ports = g_ptr_array_new ();

    core->omx_state_condition = g_cond_new ();
    core->omx_state_mutex = g_mutex_new ();

    core->done_sem = g_sem_new ();
    core->flush_sem = g_sem_new ();
    core->port_sem = g_sem_new ();

    core->omx_state = OMX_StateInvalid;

    core->use_timestamps = TRUE;

    {
        gchar *library_name, *component_name, *component_role;

        library_name = g_type_get_qdata (G_OBJECT_CLASS_TYPE (klass),
                g_quark_from_static_string ("library-name"));

        component_name = g_type_get_qdata (G_OBJECT_CLASS_TYPE (klass),
                g_quark_from_static_string ("component-name"));

        component_role = g_type_get_qdata (G_OBJECT_CLASS_TYPE (klass),
                g_quark_from_static_string ("component-role"));

        g_object_set (core->object,
            "component-role", component_role,
            "component-name", component_name,
            "library-name", library_name,
            NULL);
    }

    return core;
}
Exemple #13
0
static void
gst_ffmpegauddec_base_init (GstFFMpegAudDecClass * klass)
{
  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
  GstPadTemplate *sinktempl, *srctempl;
  GstCaps *sinkcaps, *srccaps;
  AVCodec *in_plugin;
  gchar *longname, *description;

  in_plugin =
      (AVCodec *) g_type_get_qdata (G_OBJECT_CLASS_TYPE (klass),
      GST_FFDEC_PARAMS_QDATA);
  g_assert (in_plugin != NULL);

  /* construct the element details struct */
  longname = g_strdup_printf ("libav %s decoder", in_plugin->long_name);
  description = g_strdup_printf ("libav %s decoder", in_plugin->name);
  gst_element_class_set_metadata (element_class, longname,
      "Codec/Decoder/Audio", description,
      "Wim Taymans <*****@*****.**>, "
      "Ronald Bultje <*****@*****.**>, "
      "Edward Hervey <*****@*****.**>");
  g_free (longname);
  g_free (description);

  /* get the caps */
  sinkcaps = gst_ffmpeg_codecid_to_caps (in_plugin->id, NULL, FALSE);
  if (!sinkcaps) {
    GST_DEBUG ("Couldn't get sink caps for decoder '%s'", in_plugin->name);
    sinkcaps = gst_caps_from_string ("unknown/unknown");
  }
  srccaps = gst_ffmpeg_codectype_to_audio_caps (NULL,
      in_plugin->id, FALSE, in_plugin);
  if (!srccaps) {
    GST_DEBUG ("Couldn't get source caps for decoder '%s'", in_plugin->name);
    srccaps = gst_caps_from_string ("audio/x-raw");
  }

  /* pad templates */
  sinktempl = gst_pad_template_new ("sink", GST_PAD_SINK,
      GST_PAD_ALWAYS, sinkcaps);
  srctempl = gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS, srccaps);

  gst_element_class_add_pad_template (element_class, srctempl);
  gst_element_class_add_pad_template (element_class, sinktempl);

  gst_caps_unref (sinkcaps);
  gst_caps_unref (srccaps);

  klass->in_plugin = in_plugin;
  klass->srctempl = srctempl;
  klass->sinktempl = sinktempl;
}
void
mcd_dbus_init_interfaces_instances (gpointer self)
{
    McdInterfaceData *iface_data;

    iface_data = g_type_get_qdata (G_OBJECT_TYPE (self), MCD_INTERFACES_QUARK);

    while (iface_data->get_type)
    {
	if (iface_data->instance_init)
	    iface_data->instance_init (self);
	iface_data++;
    }
}
Exemple #15
0
static PyGTypeMarshal *
pyg_type_lookup(GType type)
{
    GType	ptype = type;
    PyGTypeMarshal	*tm = NULL;

    /* recursively lookup types */
    while (ptype) {
	if ((tm = g_type_get_qdata(ptype, pyg_type_marshal_key)) != NULL)
	    break;
	ptype = g_type_parent(ptype);
    }
    return tm;
}
Exemple #16
0
static void
gst_ffmpegaudenc_base_init (GstFFMpegAudEncClass * klass)
{
  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
  AVCodec *in_plugin;
  GstPadTemplate *srctempl = NULL, *sinktempl = NULL;
  GstCaps *srccaps = NULL, *sinkcaps = NULL;
  gchar *longname, *description;

  in_plugin =
      (AVCodec *) g_type_get_qdata (G_OBJECT_CLASS_TYPE (klass),
      GST_FFENC_PARAMS_QDATA);
  g_assert (in_plugin != NULL);

  /* construct the element details struct */
  longname = g_strdup_printf ("libav %s encoder", in_plugin->long_name);
  description = g_strdup_printf ("libav %s encoder", in_plugin->name);
  gst_element_class_set_metadata (element_class, longname,
      "Codec/Encoder/Audio", description,
      "Wim Taymans <*****@*****.**>, "
      "Ronald Bultje <*****@*****.**>");
  g_free (longname);
  g_free (description);

  if (!(srccaps = gst_ffmpeg_codecid_to_caps (in_plugin->id, NULL, TRUE))) {
    GST_DEBUG ("Couldn't get source caps for encoder '%s'", in_plugin->name);
    srccaps = gst_caps_new_empty_simple ("unknown/unknown");
  }

  sinkcaps = gst_ffmpeg_codectype_to_audio_caps (NULL,
      in_plugin->id, TRUE, in_plugin);
  if (!sinkcaps) {
    GST_DEBUG ("Couldn't get sink caps for encoder '%s'", in_plugin->name);
    sinkcaps = gst_caps_new_empty_simple ("unknown/unknown");
  }

  /* pad templates */
  sinktempl = gst_pad_template_new ("sink", GST_PAD_SINK,
      GST_PAD_ALWAYS, sinkcaps);
  srctempl = gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS, srccaps);

  gst_element_class_add_pad_template (element_class, srctempl);
  gst_element_class_add_pad_template (element_class, sinktempl);

  klass->in_plugin = in_plugin;
  klass->srctempl = srctempl;
  klass->sinktempl = sinktempl;

  return;
}
Exemple #17
0
void
moo_plugin_method_newv (const char     *name,
                        GType           ptype,
                        GClosure       *closure,
                        GClosureMarshal c_marshaller,
                        GType           return_type,
                        guint           n_params,
                        const GType    *param_types)
{
    MooPluginMeth *m;
    GHashTable *meths;
    char *norm_name;

    g_return_if_fail (g_type_is_a (ptype, MOO_TYPE_PLUGIN));
    g_return_if_fail (name != NULL);
    g_return_if_fail (closure != NULL);
    g_return_if_fail (c_marshaller != NULL);
    g_return_if_fail (!n_params || param_types);

    norm_name = g_strdelimit (g_strdup (name), "_", '-');
    meths = g_type_get_qdata (ptype, MOO_PLUGIN_METHS_QUARK);

    if (meths)
    {
        if (g_hash_table_lookup (meths, norm_name) != NULL)
        {
            g_warning ("method '%s' is already registered for type '%s'",
                       name, g_type_name (ptype));
            g_free (norm_name);
            return;
        }
    }
    else
    {
        meths = g_hash_table_new_full (g_str_hash, g_str_equal, g_free,
                                       (GDestroyNotify) meth_free);
        g_type_set_qdata (ptype, MOO_PLUGIN_METHS_QUARK, meths);
    }

    m = g_new0 (MooPluginMeth, 1);
    m->ptype = ptype;
    m->return_type = return_type;
    m->n_params = n_params;
    m->param_types = n_params ? g_memdup (param_types, n_params * sizeof (GType)) : NULL;
    m->closure = g_closure_ref (closure);
    g_closure_sink (closure);
    g_closure_set_marshal (closure, c_marshaller);

    g_hash_table_insert (meths, norm_name, m);
}
static void
type_instance_init (GTypeInstance *instance,
                    gpointer g_class)
{
    GstOmxBaseSink *self;

    self = GST_OMX_BASE_SINK (instance);

    GST_LOG_OBJECT (self, "begin");

    /* GOmx */
    {
        GOmxCore *gomx;
        self->gomx = gomx = g_omx_core_new ();
        gomx->object = self;
    }

    {
        const char *tmp;
        tmp = g_type_get_qdata (G_OBJECT_CLASS_TYPE (g_class),
                                g_quark_from_static_string ("library-name"));
        self->omx_library = g_strdup (tmp);
        tmp = g_type_get_qdata (G_OBJECT_CLASS_TYPE (g_class),
                                g_quark_from_static_string ("component-name"));
        self->omx_component = g_strdup (tmp);
    }

    {
        GstPad *sinkpad;
        self->sinkpad = sinkpad = GST_BASE_SINK_PAD (self);
        self->base_activatepush = GST_PAD_ACTIVATEPUSHFUNC (sinkpad);
        gst_pad_set_activatepush_function (sinkpad, activate_push);
        gst_pad_set_link_function (sinkpad, pad_sink_link);
    }

    GST_LOG_OBJECT (self, "end");
}
Exemple #19
0
static PyObject *
_wrap_g_type_wrapper__get_pytype(PyGTypeWrapper *self, void *closure)
{
    GQuark key;
    PyObject *py_type;

    key = _pyg_type_key(self->type);

    py_type = g_type_get_qdata(self->type, key);
    if (!py_type)
      py_type = Py_None;

    Py_INCREF(py_type);
    return py_type;
}
Exemple #20
0
static void
plugin_type_cleanup (GType type)
{
    gpointer meths_table;

    g_assert (g_type_is_a (type, MOO_TYPE_PLUGIN));

    meths_table = g_type_get_qdata (type, MOO_PLUGIN_METHS_QUARK);

    if (meths_table)
    {
        g_hash_table_destroy (meths_table);
        g_type_set_qdata (type, MOO_PLUGIN_METHS_QUARK, NULL);
    }
}
Exemple #21
0
GSList *
moo_plugin_list_methods (gpointer plugin)
{
    GHashTable *meths;
    GSList *list = NULL;

    g_return_val_if_fail (MOO_IS_PLUGIN (plugin), NULL);

    meths = g_type_get_qdata (G_OBJECT_TYPE (plugin), MOO_PLUGIN_METHS_QUARK);

    if (!meths)
        return NULL;

    g_hash_table_foreach (meths, (GHFunc) prepend_meth_name, &list);
    return list;
}
Exemple #22
0
static void
dmo_audiodec_base_init (DMOAudioDecClass * klass)
{
  GstElementClass *eklass = GST_ELEMENT_CLASS (klass);
  GstElementDetails details;
  GstPadTemplate *src, *snk;
  GstCaps *srccaps, *sinkcaps;
  const CodecEntry *tmp;

  /* element details */
  tmp = klass->entry = (CodecEntry *) g_type_get_qdata (G_OBJECT_CLASS_TYPE (klass),
                                           PITFDLL_CODEC_QDATA);
  details.longname = g_strdup_printf ("DMO %s decoder version %d", tmp->dll,
                                      tmp->version);
  details.klass = "Codec/Decoder/Audio";
  details.description = g_strdup_printf ("DMO %s decoder version %d",
                                         tmp->friendly_name, tmp->version);;
  details.author = "Ronald Bultje <*****@*****.**>";
  gst_element_class_set_details (eklass, &details);
  g_free (details.description);
  g_free (details.longname);

  /* sink caps */
  sinkcaps = gst_caps_from_string (tmp->sinkcaps);
  gst_caps_set_simple (sinkcaps,
      "block_align", GST_TYPE_INT_RANGE, 0, G_MAXINT,
      "bitrate", GST_TYPE_INT_RANGE, 0, G_MAXINT,
      NULL);
  snk = gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, sinkcaps);

  /* source, simple */
  if (tmp->srccaps) {
    srccaps = gst_caps_from_string (tmp->srccaps);
  }
  else {
    srccaps = gst_caps_from_string ("audio/x-raw-int, " \
                                    "width = (int) { 1, 8, 16, 24, 32 }, " \
                                    "depth = (int) { 1, 8, 16, 24, 32 }, " \
                                    "signed = (boolean) true, " \
                                    "endianness = (int) 1234");
  }
  src = gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS, srccaps);

  /* register */
  gst_element_class_add_pad_template (eklass, src);
  gst_element_class_add_pad_template (eklass, snk);
}
Exemple #23
0
static gboolean gstti_viddec_process(GstTIDmaidec *dmaidec, GstBuffer *encData,
                    Buffer_Handle hDstBuf,gboolean codecFlushed){
    GstTIDmaidecData *decoder;
    Buffer_Handle   hEncData = NULL;
    Int32           encDataConsumed, originalBufferSize;
    Int             ret;

    decoder = (GstTIDmaidecData *)
       g_type_get_qdata(G_OBJECT_CLASS_TYPE(G_OBJECT_GET_CLASS(dmaidec)),
       GST_TIDMAIDEC_PARAMS_QDATA);

    hEncData = GST_TIDMAIBUFFERTRANSPORT_DMAIBUF(encData);
    g_assert(hEncData != NULL);

    /* Make sure the whole buffer is used for output */
    BufferGfx_resetDimensions(hDstBuf);

    /* Invoke the video decoder */
    originalBufferSize = Buffer_getNumBytesUsed(hEncData);
    GST_DEBUG("invoking the video decoder, with %ld bytes (%p, %p)\n",originalBufferSize,
        Buffer_getUserPtr(hEncData),Buffer_getUserPtr(hDstBuf));
    ret = Vdec_process(dmaidec->hCodec, hEncData, hDstBuf);
    encDataConsumed = (codecFlushed) ? 0 :
        Buffer_getNumBytesUsed(hEncData);

    if (ret < 0) {
        GST_ELEMENT_ERROR(dmaidec,STREAM,DECODE,(NULL),
            ("failed to decode video buffer"));
        return FALSE;
    }

    if (ret == Dmai_EBITERROR){
        GST_ELEMENT_WARNING(dmaidec,STREAM,DECODE,(NULL),
            ("Unable to decode frame with timestamp %"GST_TIME_FORMAT,
                GST_TIME_ARGS(GST_BUFFER_TIMESTAMP(encData))));
        /* We failed to process this buffer, so we need to release it
               because the codec won't do it.
         */
        GST_DEBUG("Freeing buffer because of bit error on the stream");
        Buffer_freeUseMask(hDstBuf, gst_tidmaibuffertransport_GST_FREE |
           decoder->dops->outputUseMask);
        return FALSE;
    }

    return TRUE;
}
static void
gst_dshowaudiodec_base_init (gpointer klass)
{
  GstDshowAudioDecClass *audiodec_class = (GstDshowAudioDecClass *) klass;
  GstPadTemplate *src, *sink;
  GstCaps *srccaps, *sinkcaps;
  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
  GstElementDetails details;
  const AudioCodecEntry *tmp;
  gpointer qdata;

  qdata = g_type_get_qdata (G_OBJECT_CLASS_TYPE (klass), DSHOW_CODEC_QDATA);

  /* element details */
  tmp = audiodec_class->entry = (AudioCodecEntry *) qdata;

  details.longname = g_strdup_printf ("DirectShow %s Decoder Wrapper",
      tmp->element_longname);
  details.klass = g_strdup ("Codec/Decoder/Audio");
  details.description = g_strdup_printf ("DirectShow %s Decoder Wrapper",
      tmp->element_longname);
  details.author = "Sebastien Moutte <*****@*****.**>";
  gst_element_class_set_details (element_class, &details);
  g_free (details.longname);
  g_free (details.klass);
  g_free (details.description);

  sinkcaps = gst_caps_from_string (tmp->sinkcaps);

  srccaps = gst_caps_from_string (
      "audio/x-raw-int,"
      "width = (int)[1, 32],"
      "depth = (int)[1, 32],"
      "rate = (int)[1, MAX],"
      "channels = (int)[1, MAX],"
      "signed = (boolean)true,"
      "endianness = (int)" G_STRINGIFY(G_LITTLE_ENDIAN));

  sink = gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, sinkcaps);
  src = gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS, srccaps);

  /* register */
  gst_element_class_add_pad_template (element_class, src);
  gst_element_class_add_pad_template (element_class, sink);
}
Exemple #25
0
/**
 * tp_mixin_class_get_offset:
 * @klass: A pointer to a GObjectClass-derived class structure
 * @quark: A quark that was used to store the offset with g_type_set_qdata()
 *
 * If the type of @klass, or any of its ancestor types, has had an offset
 * attached using qdata with the given @quark, return that offset. If not,
 * this indicates a programming error and results are undefined.
 *
 * This is used to implement the telepathy-glib mixin classes.
 *
 * Returns: the offset of the mixin class
 */
guint
tp_mixin_class_get_offset (gpointer klass,
                           GQuark quark)
{
  GType t;

  for (t = G_OBJECT_CLASS_TYPE (klass);
       t != 0;
       t = g_type_parent (t))
    {
      gpointer qdata = g_type_get_qdata (t, quark);

      if (qdata != NULL)
        return GPOINTER_TO_UINT (qdata);
    }

  g_return_val_if_reached (0);
}
static void
notify (GObject *object, GParamSpec *pspec)
{
	NMPropertiesChangedClassInfo *classinfo;
	NMPropertiesChangedInfo *info;
	const char *dbus_property_name = NULL;
	GValue *value;
	GType type;

	for (type = G_OBJECT_TYPE (object); type; type = g_type_parent (type)) {
		classinfo = g_type_get_qdata (type, nm_properties_changed_signal_quark ());
		if (!classinfo)
			continue;

		dbus_property_name = g_hash_table_lookup (classinfo->exported_props, pspec->name);
		if (dbus_property_name)
			break;
	}
	if (!dbus_property_name) {
		nm_log_trace (LOGD_DBUS_PROPS, "ignoring notification for prop %s on type %s",
		              pspec->name, G_OBJECT_TYPE_NAME (object));
		return;
	}

	info = g_object_get_qdata (object, nm_properties_changed_signal_quark ());
	if (!info) {
		info = g_slice_new0 (NMPropertiesChangedInfo);
		info->hash = g_hash_table_new_full (g_str_hash, g_str_equal,
		                                    NULL, destroy_value);
		info->signal_id = classinfo->signal_id;

		g_object_set_qdata_full (object, nm_properties_changed_signal_quark (),
		                         info, properties_changed_info_destroy);
	}

	value = g_slice_new0 (GValue);
	g_value_init (value, pspec->value_type);
	g_object_get_property (object, pspec->name, value);
	g_hash_table_insert (info->hash, (char *) dbus_property_name, value);

	if (!info->idle_id)
		info->idle_id = g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, properties_changed, object, idle_id_reset);
}
static NMPropertiesChangedClassInfo *
nm_properties_changed_signal_setup_type (GType type)
{
	NMPropertiesChangedClassInfo *classinfo;
	NMPropertiesChangedClassInfo *parent_classinfo = NULL;
	GObjectClass *object_class;
	GType parent;

	classinfo = g_slice_new (NMPropertiesChangedClassInfo);
	g_type_set_qdata (type, nm_properties_changed_signal_quark (), classinfo);

	object_class = g_type_class_ref (type);
	object_class->notify = notify;
	g_type_class_unref (object_class);

	classinfo->exported_props = g_hash_table_new (g_str_hash, g_str_equal);

	/* See if we've already added the signal to a parent class. (We can't just use
	 * g_signal_lookup() here because it prints a warning if the signal doesn't exist!)
	 */
	parent = g_type_parent (type);
	while (parent) {
		parent_classinfo = g_type_get_qdata (parent, nm_properties_changed_signal_quark ());
		if (parent_classinfo)
			break;
		parent = g_type_parent (parent);
	}

	if (parent_classinfo)
		classinfo->signal_id = parent_classinfo->signal_id;
	else {
		classinfo->signal_id = g_signal_new ("properties-changed",
		                                     type,
		                                     G_SIGNAL_RUN_FIRST,
		                                     0,
		                                     NULL, NULL,
		                                     g_cclosure_marshal_VOID__BOXED,
		                                     G_TYPE_NONE, 1, DBUS_TYPE_G_MAP_OF_VARIANT);
	}

	return classinfo;
}
static void
gst_dshowvideodec_base_init (gpointer klass)
{
  GstDshowVideoDecClass *videodec_class = (GstDshowVideoDecClass *) klass;
  GstPadTemplate *src, *sink;
  GstCaps *srccaps, *sinkcaps;
  GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
  GstElementDetails details;
  const VideoCodecEntry *tmp;
  gpointer qdata;

  qdata = g_type_get_qdata (G_OBJECT_CLASS_TYPE (klass), DSHOW_CODEC_QDATA);

  /* element details */
  tmp = videodec_class->entry = (VideoCodecEntry *) qdata;

  details.longname = g_strdup_printf ("DirectShow %s Decoder Wrapper",
      tmp->element_longname);
  details.klass = g_strdup ("Codec/Decoder/Video");
  details.description = g_strdup_printf ("DirectShow %s Decoder Wrapper",
      tmp->element_longname);
  details.author = "Sebastien Moutte <*****@*****.**>";
  gst_element_class_set_details (element_class, &details);
  g_free (details.longname);
  g_free (details.klass);
  g_free (details.description);

  sinkcaps = gst_caps_from_string (tmp->sinkcaps);
  gst_caps_set_simple (sinkcaps,
      "width", GST_TYPE_INT_RANGE, 16, 4096,
      "height", GST_TYPE_INT_RANGE, 16, 4096,
      "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1, NULL);

  srccaps = gst_caps_from_string (tmp->srccaps);

  sink = gst_pad_template_new ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, sinkcaps);
  src = gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS, srccaps);

  gst_element_class_add_pad_template (element_class, src);
  gst_element_class_add_pad_template (element_class, sink);
}
Exemple #29
0
MooPluginMeth *
moo_plugin_lookup_method (gpointer    plugin,
                          const char *name)
{
    GHashTable *meths;
    char *norm_name;
    MooPluginMeth *m = NULL;

    g_return_val_if_fail (MOO_IS_PLUGIN (plugin), NULL);
    g_return_val_if_fail (name != NULL, NULL);

    meths = g_type_get_qdata (G_OBJECT_TYPE (plugin), MOO_PLUGIN_METHS_QUARK);

    if (!meths)
        return NULL;

    norm_name = g_strdelimit (g_strdup (name), "_", '-');
    m = g_hash_table_lookup (meths, norm_name);
    g_free (norm_name);
    return m;
}
Exemple #30
0
static int
_wrap_g_type_wrapper__set_pytype(PyGTypeWrapper *self, PyObject* value, void *closure)
{
    GQuark key;
    PyObject *py_type;

    key = _pyg_type_key(self->type);

    py_type = g_type_get_qdata(self->type, key);
    Py_CLEAR(py_type);
    if (value == Py_None)
	g_type_set_qdata(self->type, key, NULL);
    else if (PyType_Check(value)) {
	Py_INCREF(value);
	g_type_set_qdata(self->type, key, value);
    } else {
	PyErr_SetString(PyExc_TypeError, "Value must be None or a type object");
	return -1;
    }

    return 0;
}