コード例 #1
0
/**
 * gst_property_probe_get_property:
 * @probe: the #GstPropertyProbe to get the properties for.
 * @name: name of the property.
 *
 * Get #GParamSpec for a property for which probing is supported.
 *
 * Returns: the #GParamSpec of %NULL.
 */
const GParamSpec *
gst_property_probe_get_property (GstPropertyProbe * probe, const gchar * name)
{
  const GList *pspecs;

  g_return_val_if_fail (probe != NULL, NULL);
  g_return_val_if_fail (GST_IS_PROPERTY_PROBE (probe), NULL);
  g_return_val_if_fail (name != NULL, NULL);

  pspecs = gst_property_probe_get_properties (probe);

  while (pspecs) {
    const GParamSpec *pspec = pspecs->data;

    if (pspec) {
      if (!strcmp (pspec->name, name))
        return pspec;
    } else {
      GST_WARNING_OBJECT (probe, "NULL paramspec in property probe list");
    }

    pspecs = pspecs->next;
  }

  return NULL;
}
コード例 #2
0
ファイル: gsthelper.cpp プロジェクト: phen89/rtqt
/**
 * Sets the string value of a GstElement's property
 *
 * @return false if the value could not be set.
 */
bool GstHelper::setProperty(GstElement *elem, const char *propertyName, const QByteArray &propertyValue)
{
    Q_ASSERT(elem);
    Q_ASSERT(propertyName && strlen(propertyName));

    if (GST_IS_PROPERTY_PROBE(elem) && gst_property_probe_get_property( GST_PROPERTY_PROBE( elem), propertyName ) ) {
        g_object_set(G_OBJECT(elem), propertyName, propertyValue.constData(), (const char*)NULL);
        return true;
    }
    return false;
}
コード例 #3
0
/**
 * gst_property_probe_probe_and_get_values:
 * @probe: the #GstPropertyProbe object.
 * @pspec: The #GParamSpec property identifier.
 *
 * Check whether the given property requires a new probe. If so,
 * fo the probe. After that, retrieve a value list. Meant as a
 * utility function that wraps the above functions.
 *
 * Returns: the list of valid values for this property.
 */
GValueArray *
gst_property_probe_probe_and_get_values (GstPropertyProbe * probe,
    const GParamSpec * pspec)
{
  g_return_val_if_fail (probe != NULL, NULL);
  g_return_val_if_fail (GST_IS_PROPERTY_PROBE (probe), NULL);
  g_return_val_if_fail (pspec != NULL, NULL);

  if (gst_property_probe_needs_probe (probe, pspec))
    gst_property_probe_probe_property (probe, pspec);

  return gst_property_probe_get_values (probe, pspec);
}
コード例 #4
0
ファイル: gsthelper.cpp プロジェクト: phen89/rtqt
/**
 * Queries an element for the value of an object property
 */
QByteArray GstHelper::property(GstElement *elem, const char *propertyName)
{
    Q_ASSERT(elem);
    Q_ASSERT(propertyName && strlen(propertyName));
    QByteArray retVal;

    if (GST_IS_PROPERTY_PROBE(elem) && gst_property_probe_get_property( GST_PROPERTY_PROBE(elem), propertyName)) {
        gchar *value = NULL;
        g_object_get (G_OBJECT(elem), propertyName, &value, (const char*)NULL);
        retVal = QByteArray(value);
        g_free (value);
    }
    return retVal;
}
コード例 #5
0
/**
 * gst_property_probe_probe_property:
 * @probe: the #GstPropertyProbe to check.
 * @pspec: #GParamSpec of the property.
 *
 * Runs a probe on the property specified by @pspec
 */
void
gst_property_probe_probe_property (GstPropertyProbe * probe,
    const GParamSpec * pspec)
{
  GstPropertyProbeInterface *iface;

  g_return_if_fail (probe != NULL);
  g_return_if_fail (GST_IS_PROPERTY_PROBE (probe));
  g_return_if_fail (pspec != NULL);

  iface = GST_PROPERTY_PROBE_GET_IFACE (probe);

  if (iface->probe_property)
    iface->probe_property (probe, pspec->param_id, pspec);
}
コード例 #6
0
/**
 * gst_property_probe_get_properties:
 * @probe: the #GstPropertyProbe to get the properties for.
 *
 * Get a list of properties for which probing is supported.
 *
 * Returns: the list of #GParamSpec * pointers representing 
 * properties for which probing is supported by this element.
 */
const GList *
gst_property_probe_get_properties (GstPropertyProbe * probe)
{
  GstPropertyProbeInterface *iface;

  g_return_val_if_fail (probe != NULL, NULL);
  g_return_val_if_fail (GST_IS_PROPERTY_PROBE (probe), NULL);

  iface = GST_PROPERTY_PROBE_GET_IFACE (probe);

  if (iface->get_properties)
    return iface->get_properties (probe);

  return NULL;
}
コード例 #7
0
/**
 * gst_property_probe_get_values:
 * @probe: the #GstPropertyProbe object.
 * @pspec: the #GParamSpec property identifier.
 *
 * Gets the possible (probed) values for the given property,
 * requires the property to have been probed before.
 *
 * Returns: A list of valid values for the given property.
 */
GValueArray *
gst_property_probe_get_values (GstPropertyProbe * probe,
    const GParamSpec * pspec)
{
  GstPropertyProbeInterface *iface;

  g_return_val_if_fail (probe != NULL, NULL);
  g_return_val_if_fail (GST_IS_PROPERTY_PROBE (probe), NULL);
  g_return_val_if_fail (pspec != NULL, NULL);

  iface = GST_PROPERTY_PROBE_GET_IFACE (probe);

  if (iface->get_values)
    return iface->get_values (probe, pspec->param_id, pspec);

  return NULL;
}
コード例 #8
0
/**
 * gst_property_probe_needs_probe:
 * @probe: the #GstPropertyProbe object to which the given property belongs.
 * @pspec: a #GParamSpec that identifies the property to check.
 *
 * Checks whether a property needs a probe. This might be because
 * the property wasn't initialized before, or because host setup
 * changed. This might be, for example, because a new device was
 * added, and thus device probing needs to be refreshed to display
 * the new device.
 *
 * Returns: TRUE if the property needs a new probe, FALSE if not.
 */
gboolean
gst_property_probe_needs_probe (GstPropertyProbe * probe,
    const GParamSpec * pspec)
{
  GstPropertyProbeInterface *iface;

  g_return_val_if_fail (probe != NULL, FALSE);
  g_return_val_if_fail (GST_IS_PROPERTY_PROBE (probe), FALSE);
  g_return_val_if_fail (pspec != NULL, FALSE);

  iface = GST_PROPERTY_PROBE_GET_IFACE (probe);

  if (iface->needs_probe)
    return iface->needs_probe (probe, pspec->param_id, pspec);

  return FALSE;
}
コード例 #9
0
/**
 * gst_property_probe_probe_and_get_values_name:
 * @probe: the #GstPropertyProbe object.
 * @name: the name of the property to get values for.
 *
 * Same as gst_property_probe_probe_and_get_values ().
 *
 * Returns: the list of valid values for this property.
 */
GValueArray *
gst_property_probe_probe_and_get_values_name (GstPropertyProbe * probe,
    const gchar * name)
{
  const GParamSpec *pspec;

  g_return_val_if_fail (probe != NULL, NULL);
  g_return_val_if_fail (GST_IS_PROPERTY_PROBE (probe), NULL);
  g_return_val_if_fail (name != NULL, NULL);

  pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (probe), name);
  if (!pspec) {
    g_warning ("No such property %s", name);
    return NULL;
  }

  return gst_property_probe_probe_and_get_values (probe, pspec);
}
コード例 #10
0
/**
 * gst_property_probe_needs_probe_name:
 * @probe: the #GstPropertyProbe object to which the given property belongs.
 * @name: the name of the property to check.
 *
 * Same as gst_property_probe_needs_probe ().
 *
 * Returns: TRUE if the property needs a new probe, FALSE if not.
 */
gboolean
gst_property_probe_needs_probe_name (GstPropertyProbe * probe,
    const gchar * name)
{
  const GParamSpec *pspec;

  g_return_val_if_fail (probe != NULL, FALSE);
  g_return_val_if_fail (GST_IS_PROPERTY_PROBE (probe), FALSE);
  g_return_val_if_fail (name != NULL, FALSE);

  pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (probe), name);
  if (!pspec) {
    g_warning ("No such property %s", name);
    return FALSE;
  }

  return gst_property_probe_needs_probe (probe, pspec);
}
コード例 #11
0
/**
 * gst_property_probe_probe_property_name:
 * @probe: the #GstPropertyProbe to check.
 * @name: name of the property.
 *
 * Runs a probe on the property specified by @name.
 */
void
gst_property_probe_probe_property_name (GstPropertyProbe * probe,
    const gchar * name)
{
  const GParamSpec *pspec;

  g_return_if_fail (probe != NULL);
  g_return_if_fail (GST_IS_PROPERTY_PROBE (probe));
  g_return_if_fail (name != NULL);

  pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (probe), name);
  if (!pspec) {
    g_warning ("No such property %s", name);
    return;
  }

  gst_property_probe_probe_property (probe, pspec);
}
コード例 #12
0
ファイル: gsthelper.cpp プロジェクト: phen89/rtqt
/**
 * Probes a gstElement for a list of settable string-property values
 *
 * @return a QStringList containing a list of allwed string values for the given
 *           element
 */
QList<QByteArray> GstHelper::extractProperties(GstElement *elem, const QByteArray &value)
{
    Q_ASSERT(elem);
    QList<QByteArray> list;

    if (GST_IS_PROPERTY_PROBE(elem)) {
        GstPropertyProbe *probe = GST_PROPERTY_PROBE(elem);
        const GParamSpec *devspec = 0;
        GValueArray *array = NULL;

        if ((devspec = gst_property_probe_get_property (probe, value))) {
            if ((array = gst_property_probe_probe_and_get_values (probe, devspec))) {
                for (unsigned int device = 0; device < array->n_values; device++) {
                    GValue *deviceId = g_value_array_get_nth (array, device);
                    list.append(g_value_get_string(deviceId));
                }
            }
            if (array)
                g_value_array_free (array);
        }
    }
    return list;
}
コード例 #13
0
ファイル: vvconfig.c プロジェクト: Yalir/Synthese4A
static GList *
get_element_devices(const gchar *element_name)
{
	GList *ret = NULL;
	GstElement *element;
	GObjectClass *klass;
	GstPropertyProbe *probe;
	const GParamSpec *pspec;

	ret = g_list_prepend(ret, (gpointer)_("Default"));
	ret = g_list_prepend(ret, "");

	if (!strcmp(element_name, "<custom>") || (*element_name == '\0')) {
		return g_list_reverse(ret);
	}

	element = gst_element_factory_make(element_name, "test");
	if(!element) {
		purple_debug_info("vvconfig", "'%s' - unable to find element\n", element_name);
		return g_list_reverse(ret);
	}

	klass = G_OBJECT_GET_CLASS (element);
	if(!klass) {
		purple_debug_info("vvconfig", "'%s' - unable to find G_Object Class\n", element_name);
		return g_list_reverse(ret);
	}

	if (!g_object_class_find_property(klass, "device") ||
			!GST_IS_PROPERTY_PROBE(element) ||
			!(probe = GST_PROPERTY_PROBE(element)) ||
			!(pspec = gst_property_probe_get_property(probe, "device"))) {
		purple_debug_info("vvconfig", "'%s' - no device\n", element_name);
	} else {
		gint n;
		GValueArray *array;

		/* Set autoprobe[-fps] to FALSE to avoid delays when probing. */
		if (g_object_class_find_property (klass, "autoprobe")) {
			g_object_set (G_OBJECT (element), "autoprobe", FALSE, NULL);
			if (g_object_class_find_property (klass, "autoprobe-fps")) {
				g_object_set (G_OBJECT (element), "autoprobe-fps", FALSE, NULL);
			}
		}

		array = gst_property_probe_probe_and_get_values (probe, pspec);
		if (array == NULL) {
			purple_debug_info("vvconfig", "'%s' has no devices\n", element_name);
			return g_list_reverse(ret);
		}

		for (n=0; n < array->n_values; ++n) {
			GValue *device;
			const gchar *name;
			const gchar *device_name;

			device = g_value_array_get_nth(array, n);
			g_object_set_property(G_OBJECT(element), "device", device);
			if (gst_element_set_state(element, GST_STATE_READY)
					!= GST_STATE_CHANGE_SUCCESS) {
				purple_debug_warning("vvconfig",
						"Error changing state of %s\n",
						element_name);
				continue;
			}

			g_object_get(G_OBJECT(element), "device-name", &name, NULL);
			device_name = g_value_get_string(device);
			if (name == NULL)
				name = _("Unknown");
			purple_debug_info("vvconfig", "Found device %s : %s for %s\n",
					device_name, name, element_name);
			ret = g_list_prepend(ret, (gpointer)name);
			ret = g_list_prepend(ret, (gpointer)device_name);
			gst_element_set_state(element, GST_STATE_NULL);
		}
	}
	gst_object_unref(element);

	return g_list_reverse(ret);
}
コード例 #14
0
ファイル: mixerutils.c プロジェクト: matsu/gst-plugins-base
static void
gst_audio_mixer_filter_probe_feature (GstAudioMixerFilterFunc filter_func,
    GstElementFactory * factory,
    GList ** p_collection, gboolean first, gpointer user_data)
{
  GstElement *element;

  GST_DEBUG ("probing %s ...", gst_element_factory_get_longname (factory));

  /* create element */
  element = gst_element_factory_create (factory, NULL);

  if (element == NULL) {
    GST_DEBUG ("could not create element from factory");
    return;
  }

  GST_DEBUG ("created element %s (%p)", GST_ELEMENT_NAME (element), element);

  if (GST_IS_PROPERTY_PROBE (element)) {
    GstPropertyProbe *probe;
    const GParamSpec *devspec;

    probe = GST_PROPERTY_PROBE (element);

    GST_DEBUG ("probing available devices ...");
    if ((devspec = gst_property_probe_get_property (probe, "device"))) {
      GValueArray *array;

      if ((array = gst_property_probe_probe_and_get_values (probe, devspec))) {
        guint n;

        GST_DEBUG ("there are %d available devices", array->n_values);

        /* set all devices and test for mixer */
        for (n = 0; n < array->n_values; n++) {
          GValue *device;

          /* set this device */
          device = g_value_array_get_nth (array, n);
          g_object_set_property (G_OBJECT (element), "device", device);

          GST_DEBUG ("trying device %s ..", g_value_get_string (device));

          if (gst_audio_mixer_filter_check_element (element)) {
            gst_audio_mixer_filter_do_filter (filter_func, factory, &element,
                p_collection, user_data);

            if (first && *p_collection != NULL) {
              GST_DEBUG ("Stopping after first found mixer, as requested");
              break;
            }
          }
        }
        g_value_array_free (array);
      }
    }
  } else {
    GST_DEBUG ("element does not support the property probe interface");

    if (gst_audio_mixer_filter_check_element (element)) {
      gst_audio_mixer_filter_do_filter (filter_func, factory, &element,
          p_collection, user_data);
    }
  }

  if (element) {
    gst_element_set_state (element, GST_STATE_NULL);
    gst_object_unref (element);
  }
}
コード例 #15
0
ファイル: lgm-device.c プロジェクト: fluendo/VAS
GList *
lgm_device_enum_devices (const gchar * source_name, LgmDeviceType type)
{
  GstElement *source;
  GstPropertyProbe *probe;
  GValueArray *va;
  const gchar *prop_name;
  GList *list = NULL;
  guint i = 0;

  source = gst_element_factory_make (source_name, "source");
  if (!source || !GST_IS_PROPERTY_PROBE (source))
    goto finish;
  gst_element_set_state (source, GST_STATE_READY);
  gst_element_get_state (source, NULL, NULL, 5 * GST_SECOND);
  probe = GST_PROPERTY_PROBE (source);

  prop_name = lgm_device_get_property_name_for_source (source_name);

  va = gst_property_probe_probe_and_get_values_name (probe, prop_name);
  gst_element_set_state (source, GST_STATE_NULL);
  gst_element_get_state (source, NULL, NULL, 5 * GST_SECOND);
  gst_object_unref (source);

  if (!va)
    goto finish;


  for (i = 0; i < va->n_values; ++i) {
    GValue *v = g_value_array_get_nth (va, i);
    GValue valstr = { 0, };
    LgmDevice *device;
    gchar *name;

    g_value_init (&valstr, G_TYPE_STRING);
    if (!g_value_transform (v, &valstr))
      continue;

    /* Skip blackmagic on avfvideosrc as we only properly support them
     * through decklinkvideosrc. */
    if (!g_strcmp0 (source_name, "avfvideosrc"))
      if (!g_strcmp0 (g_value_get_string (&valstr), "Blackmagic"))
        continue;

    /* Use the pattern "Blackmagic%d" for device name when decklinkvideosrc */
    if (!g_strcmp0 (source_name, "decklinkvideosrc"))
      name = g_strdup_printf ("Blackmagic%s", g_value_get_string (&valstr));
    else
      name = g_value_dup_string (&valstr);
    device = lgm_device_new (source_name, name, type);
    g_value_unset (&valstr);
    g_free (name);

    lgm_device_fill_formats (device, prop_name);
    list = g_list_append (list, device);
  }
  g_value_array_free (va);

finish:
  {
    return list;
  }
}