Exemplo n.º 1
0
/**
 * g_value_array_append:
 * @value_array: #GValueArray to add an element to
 * @value: (allow-none): #GValue to copy into #GValueArray, or %NULL
 *
 * Insert a copy of @value as last element of @value_array. If @value is
 * %NULL, an uninitialized value is appended.
 *
 * Returns: (transfer none): the #GValueArray passed in as @value_array
 */
GValueArray*
g_value_array_append (GValueArray  *value_array,
              const GValue *value)
{
  g_return_val_if_fail (value_array != NULL, NULL);

  return g_value_array_insert (value_array, value_array->n_values, value);
}
Exemplo n.º 2
0
/**
 * g_value_array_append:
 * @value_array: #GValueArray to add an element to
 * @value: (allow-none): #GValue to copy into #GValueArray, or %NULL
 *
 * Insert a copy of @value as last element of @value_array. If @value is
 * %NULL, an uninitialized value is appended.
 *
 * Returns: (transfer none): the #GValueArray passed in as @value_array
 *
 * Deprecated: 2.32: Use #GArray and g_array_append_val() instead.
 */
GValueArray*
g_value_array_append (GValueArray  *value_array,
		      const GValue *value)
{
  g_return_val_if_fail (value_array != NULL, NULL);

  G_GNUC_BEGIN_IGNORE_DEPRECATIONS
  return g_value_array_insert (value_array, value_array->n_values, value);
  G_GNUC_END_IGNORE_DEPRECATIONS
}
Exemplo n.º 3
0
/**
 * g_controller_create_event:
 * @controller: a #GController
 * @action: the action for the event 
 * @index_type: the type of the indices
 * @n_indices: the number of indices, or 0 to create an empty event and
 *   use the #GControllerEvent API to fill it
 * @...: the indices
 *
 * Creates a new #GControllerEvent for the given indices.
 *
 * This function should only be used by implementations of the
 * #GController API.
 *
 * This is a variadic arguments version of g_controller_create_eventv(),
 * for the convenience of users of the C API.
 *
 * Return value: (transfer full): a newly created #GControllerEvent
 *   instance. Use g_object_unref() when done using the returned
 *   object
 */
GControllerEvent *
g_controller_create_event (GController       *controller,
                           GControllerAction  action,
                           GType              index_type,
                           gint               n_indices,
                           ...)
{
  GControllerEvent *ref;
  GValueArray *indices;
  va_list args;
  gint i;

  g_return_val_if_fail (G_IS_CONTROLLER (controller), NULL);
  g_return_val_if_fail (index_type != G_TYPE_INVALID, NULL);

  /* short-circuit the empty event case */
  if (n_indices == 0)
    return g_controller_create_event_internal (controller, action, index_type, NULL);

  indices = g_value_array_new (n_indices);

  va_start (args, n_indices);

  for (i = 0; i < n_indices; i++)
    {
      gchar *error;

      g_value_array_insert (indices, i, NULL);

      G_VALUE_COLLECT_INIT (&(indices->values[i]), index_type,
                            args, 0,
                            &error);

      if (error != NULL)
        {
          g_warning ("%s: %s", G_STRLOC, error);
          g_free (error);
          break;
        }
    }

  va_end (args);

  ref = g_controller_create_event_internal (controller, action,
                                            index_type,
                                            indices);

  g_value_array_free (indices);

  return ref;
}
static GValueArray *
gst_video_parse_int_valarray_from_string (const gchar * str)
{
  gchar **strv;
  guint length;
  guint i;
  GValueArray *valarray;
  GValue gvalue = G_VALUE_INIT;

  if (str == NULL)
    return NULL;

  strv = g_strsplit (str, ",", GST_VIDEO_MAX_PLANES);
  if (strv == NULL)
    return NULL;

  length = g_strv_length (strv);
  valarray = g_value_array_new (length);
  g_value_init (&gvalue, G_TYPE_UINT);

  for (i = 0; i < length; i++) {
    gint64 val;

    val = g_ascii_strtoll (strv[i], NULL, 10);
    if (val < G_MININT || val > G_MAXINT) {
      goto error;
    }

    g_value_set_uint (&gvalue, val);
    g_value_array_insert (valarray, i, &gvalue);
  }

finish:
  g_strfreev (strv);
  return valarray;

error:
  g_value_array_free (valarray);
  valarray = NULL;
  goto finish;
}
Exemplo n.º 5
0
static void
gst_raw_video_parse_get_property (GObject * object, guint prop_id,
    GValue * value, GParamSpec * pspec)
{
  GstRawVideoParse *raw_video_parse = GST_RAW_VIDEO_PARSE (object);
  GstRawVideoParseConfig *props_cfg = &(raw_video_parse->properties_config);

  switch (prop_id) {
    case PROP_WIDTH:
      GST_RAW_BASE_PARSE_CONFIG_MUTEX_LOCK (object);
      g_value_set_int (value, props_cfg->width);
      GST_RAW_BASE_PARSE_CONFIG_MUTEX_UNLOCK (object);
      break;

    case PROP_HEIGHT:
      GST_RAW_BASE_PARSE_CONFIG_MUTEX_LOCK (object);
      g_value_set_int (value, props_cfg->height);
      GST_RAW_BASE_PARSE_CONFIG_MUTEX_UNLOCK (object);
      break;

    case PROP_FORMAT:
      GST_RAW_BASE_PARSE_CONFIG_MUTEX_LOCK (object);
      g_value_set_enum (value, props_cfg->format);
      GST_RAW_BASE_PARSE_CONFIG_MUTEX_UNLOCK (object);
      break;

    case PROP_PIXEL_ASPECT_RATIO:
      GST_RAW_BASE_PARSE_CONFIG_MUTEX_LOCK (object);
      gst_value_set_fraction (value, props_cfg->pixel_aspect_ratio_n,
          props_cfg->pixel_aspect_ratio_d);
      GST_RAW_BASE_PARSE_CONFIG_MUTEX_UNLOCK (object);

      break;

    case PROP_FRAMERATE:
      GST_RAW_BASE_PARSE_CONFIG_MUTEX_LOCK (object);
      gst_value_set_fraction (value, props_cfg->framerate_n,
          props_cfg->framerate_d);
      GST_RAW_BASE_PARSE_CONFIG_MUTEX_UNLOCK (object);
      break;

    case PROP_INTERLACED:
      GST_RAW_BASE_PARSE_CONFIG_MUTEX_LOCK (object);
      g_value_set_boolean (value, props_cfg->interlaced);
      GST_RAW_BASE_PARSE_CONFIG_MUTEX_UNLOCK (object);
      break;

    case PROP_TOP_FIELD_FIRST:
      GST_RAW_BASE_PARSE_CONFIG_MUTEX_LOCK (object);
      g_value_set_boolean (value, props_cfg->top_field_first);
      GST_RAW_BASE_PARSE_CONFIG_MUTEX_UNLOCK (object);
      break;

    case PROP_PLANE_STRIDES:
    {
      guint i, n_planes;
      GValue val = G_VALUE_INIT;
      GValueArray *valarray;

      GST_RAW_BASE_PARSE_CONFIG_MUTEX_LOCK (object);

      n_planes = GST_VIDEO_INFO_N_PLANES (&(props_cfg->info));
      valarray = g_value_array_new (n_planes);
      g_value_init (&val, G_TYPE_UINT);

      for (i = 0; i < n_planes; ++i) {
        g_value_set_uint (&val, props_cfg->plane_strides[i]);
        g_value_array_insert (valarray, i, &val);
      }

      g_value_unset (&val);

      GST_RAW_BASE_PARSE_CONFIG_MUTEX_UNLOCK (object);

      /* Pass on ownership to the value array,
       * since we don't need it anymore */
      g_value_take_boxed (value, valarray);
      break;
    }

    case PROP_PLANE_OFFSETS:
    {
      guint i, n_planes;
      GValue val = G_VALUE_INIT;
      GValueArray *valarray;

      GST_RAW_BASE_PARSE_CONFIG_MUTEX_LOCK (object);

      n_planes = GST_VIDEO_INFO_N_PLANES (&(props_cfg->info));
      valarray = g_value_array_new (n_planes);
      g_value_init (&val, G_TYPE_UINT);

      for (i = 0; i < n_planes; ++i) {
        g_value_set_uint (&val, props_cfg->plane_offsets[i]);
        g_value_array_insert (valarray, i, &val);
      }

      g_value_unset (&val);

      GST_RAW_BASE_PARSE_CONFIG_MUTEX_UNLOCK (object);

      /* Pass on ownership to the value array,
       * since we don't need it anymore */
      g_value_take_boxed (value, valarray);
      break;
    }

    case PROP_FRAME_STRIDE:
      GST_RAW_BASE_PARSE_CONFIG_MUTEX_LOCK (object);
      g_value_set_uint (value, raw_video_parse->properties_config.frame_stride);
      GST_RAW_BASE_PARSE_CONFIG_MUTEX_UNLOCK (object);
      break;

    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
      break;
  }
}
Exemplo n.º 6
0
static void
gst_raw_audio_parse_get_property (GObject * object, guint prop_id,
    GValue * value, GParamSpec * pspec)
{
  GstRawAudioParse *raw_audio_parse = GST_RAW_AUDIO_PARSE (object);

  switch (prop_id) {
    case PROP_FORMAT:
      GST_RAW_BASE_PARSE_CONFIG_MUTEX_LOCK (object);
      g_value_set_enum (value, raw_audio_parse->properties_config.format);
      GST_RAW_BASE_PARSE_CONFIG_MUTEX_UNLOCK (object);
      break;

    case PROP_PCM_FORMAT:
      GST_RAW_BASE_PARSE_CONFIG_MUTEX_LOCK (object);
      g_value_set_enum (value, raw_audio_parse->properties_config.pcm_format);
      GST_RAW_BASE_PARSE_CONFIG_MUTEX_UNLOCK (object);
      break;

    case PROP_SAMPLE_RATE:
      GST_RAW_BASE_PARSE_CONFIG_MUTEX_LOCK (object);
      g_value_set_int (value, raw_audio_parse->properties_config.sample_rate);
      GST_RAW_BASE_PARSE_CONFIG_MUTEX_UNLOCK (object);
      break;

    case PROP_NUM_CHANNELS:
      GST_RAW_BASE_PARSE_CONFIG_MUTEX_LOCK (object);
      g_value_set_int (value, raw_audio_parse->properties_config.num_channels);
      GST_RAW_BASE_PARSE_CONFIG_MUTEX_UNLOCK (object);
      break;

    case PROP_INTERLEAVED:
      GST_RAW_BASE_PARSE_CONFIG_MUTEX_LOCK (object);
      g_value_set_boolean (value,
          raw_audio_parse->properties_config.interleaved);
      GST_RAW_BASE_PARSE_CONFIG_MUTEX_UNLOCK (object);
      break;

    case PROP_CHANNEL_POSITIONS:
    {
      GstRawAudioParseConfig *config;
      GValueArray *valarray;

      GST_RAW_BASE_PARSE_CONFIG_MUTEX_LOCK (object);

      valarray = NULL;
      config = &(raw_audio_parse->properties_config);

      /* Copy channel positions into the valuearray */
      if (config->num_channels > 0) {
        guint i;
        GValue val = G_VALUE_INIT;
        g_assert (config->channel_positions);

        g_value_init (&val, GST_TYPE_AUDIO_CHANNEL_POSITION);
        valarray = g_value_array_new (config->num_channels);

        for (i = 0; i < config->num_channels; ++i) {
          g_value_set_enum (&val, config->channel_positions[i]);
          g_value_array_insert (valarray, i, &val);
        }

        g_value_unset (&val);
      }

      GST_RAW_BASE_PARSE_CONFIG_MUTEX_UNLOCK (object);

      /* Pass on ownership to the value array,
       * since we don't need it anymore */
      g_value_take_boxed (value, valarray);

      break;
    }

    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
      break;
  }
}