static void send_error (InsanityGstPipelineTest * ptest, const GError * error, const char *debug) { char label[32]; GValue string_value = { 0 }; ptest->priv->error_count++; g_value_init (&string_value, G_TYPE_STRING); g_value_set_string (&string_value, g_quark_to_string (error->domain)); snprintf (label, sizeof (label), "errors.%u.domain", ptest->priv->error_count); insanity_test_set_extra_info (INSANITY_TEST (ptest), label, &string_value); g_value_reset (&string_value); g_value_set_string (&string_value, error->message); snprintf (label, sizeof (label), "errors.%u.message", ptest->priv->error_count); insanity_test_set_extra_info (INSANITY_TEST (ptest), label, &string_value); g_value_reset (&string_value); if (debug) { g_value_set_string (&string_value, debug); snprintf (label, sizeof (label), "errors.%u.debug", ptest->priv->error_count); insanity_test_set_extra_info (INSANITY_TEST (ptest), label, &string_value); g_value_reset (&string_value); } }
int main(int argc, char *argv[]) { GHashTable *table; GValue gval = G_VALUE_INIT; gchar *mode, *ssid; g_type_init(); table = g_hash_table_new(NULL, NULL); g_value_init(&gval, G_TYPE_STRING); g_value_set_string(&gval, "wifi"); g_print("%s\n", g_value_get_string(&gval)); g_hash_table_insert(table, "type", &gval); g_value_reset(&gval); mode = "managed"; ssid = "ijimu"; g_value_set_string(&gval, mode); g_hash_table_insert(table, "Mode", &gval); g_value_reset(&gval); g_value_set_string(&gval, ssid); g_hash_table_insert(table, "SSID", &gval); g_value_reset(&gval); hashtable_show_value_type(table); return 0; }
static GstCaps * gst_yadif_transform_caps (GstBaseTransform * trans, GstPadDirection direction, GstCaps * caps, GstCaps * filter) { GstCaps *othercaps; othercaps = gst_caps_copy (caps); if (direction == GST_PAD_SRC) { GValue value = G_VALUE_INIT; GValue v = G_VALUE_INIT; g_value_init (&value, GST_TYPE_LIST); g_value_init (&v, G_TYPE_STRING); g_value_set_string (&v, "interleaved"); gst_value_list_append_value (&value, &v); g_value_set_string (&v, "mixed"); gst_value_list_append_value (&value, &v); g_value_set_string (&v, "progressive"); gst_value_list_append_value (&value, &v); gst_caps_set_value (othercaps, "interlace-mode", &value); g_value_reset (&value); g_value_reset (&v); } else { gst_caps_set_simple (othercaps, "interlace-mode", G_TYPE_STRING, "progressive", NULL); } return othercaps; }
static void on_rate_changed (GstElement * element, gint rate, gpointer user_data) { GValueArray *va; GValue v = { 0, }; gdouble x; if (rate / 2.0 > CUTOFF) x = exp (-2.0 * G_PI * (CUTOFF / rate)); else x = 0.0; va = g_value_array_new (1); g_value_init (&v, G_TYPE_DOUBLE); g_value_set_double (&v, 1.0 - x); g_value_array_append (va, &v); g_value_reset (&v); g_object_set (G_OBJECT (element), "a", va, NULL); g_value_array_free (va); va = g_value_array_new (1); g_value_set_double (&v, x); g_value_array_append (va, &v); g_value_reset (&v); g_object_set (G_OBJECT (element), "b", va, NULL); g_value_array_free (va); }
/* Fetches a compatible pad on the target element which isn't already * linked */ static GstPad * get_compatible_unlinked_pad (GstElement * element, GESTrack * track) { GstPad *res = NULL; GstIterator *pads; gboolean done = FALSE; const GstCaps *srccaps; GValue paditem = { 0, }; if (G_UNLIKELY (track == NULL)) goto no_track; GST_DEBUG_OBJECT (element, " track %" GST_PTR_FORMAT, track); pads = gst_element_iterate_sink_pads (element); srccaps = ges_track_get_caps (track); GST_DEBUG ("srccaps %" GST_PTR_FORMAT, srccaps); while (!done) { switch (gst_iterator_next (pads, &paditem)) { case GST_ITERATOR_OK: { GstPad *testpad = g_value_get_object (&paditem); if (!gst_pad_is_linked (testpad)) { GstCaps *sinkcaps = gst_pad_query_caps (testpad, NULL); GST_DEBUG ("sinkccaps %" GST_PTR_FORMAT, sinkcaps); if (gst_caps_can_intersect (srccaps, sinkcaps)) { res = gst_object_ref (testpad); done = TRUE; } gst_caps_unref (sinkcaps); } g_value_reset (&paditem); } break; case GST_ITERATOR_DONE: case GST_ITERATOR_ERROR: done = TRUE; break; case GST_ITERATOR_RESYNC: gst_iterator_resync (pads); break; } } g_value_reset (&paditem); gst_iterator_free (pads); return res; no_track: { GST_ERROR ("No track to check against"); return NULL; } }
static GObject* base_object_constructor (GType type, guint n_construct_properties, GObjectConstructParam *construct_properties) { /* The constructor is the one place where a GParamSpecOverride is visible * to the outside world, so we do a bunch of checks here */ GValue value1 = { 0, }; GValue value2 = { 0, }; GParamSpec *pspec; g_assert (n_construct_properties == 1); pspec = construct_properties->pspec; /* Check we got the param spec we expected */ g_assert (G_IS_PARAM_SPEC_OVERRIDE (pspec)); g_assert (pspec->param_id == BASE_PROP1); g_assert (strcmp (g_param_spec_get_name (pspec), "prop1") == 0); g_assert (g_param_spec_get_redirect_target (pspec) == iface_spec1); /* Test redirection of the nick and blurb to the redirect target */ g_assert (strcmp (g_param_spec_get_nick (pspec), "Prop1") == 0); g_assert (strcmp (g_param_spec_get_blurb (pspec), "Property 1") == 0); /* Test forwarding of the various GParamSpec methods to the redirect target */ g_value_init (&value1, G_TYPE_INT); g_value_init (&value2, G_TYPE_INT); g_param_value_set_default (pspec, &value1); g_assert (g_value_get_int (&value1) == 42); g_value_reset (&value1); g_value_set_int (&value1, 0x10000); g_assert (g_param_value_validate (pspec, &value1)); g_assert (g_value_get_int (&value1) == 0xFFFF); g_assert (!g_param_value_validate (pspec, &value1)); g_value_reset (&value1); g_value_set_int (&value1, 1); g_value_set_int (&value2, 2); g_assert (g_param_values_cmp (pspec, &value1, &value2) < 0); g_assert (g_param_values_cmp (pspec, &value2, &value1) > 0); g_value_unset (&value1); g_value_unset (&value2); return base_parent_class->constructor (type, n_construct_properties, construct_properties); }
static GstCaps * gst_ivtc_transform_caps (GstBaseTransform * trans, GstPadDirection direction, GstCaps * caps, GstCaps * filter) { GstCaps *othercaps; int i; othercaps = gst_caps_copy (caps); if (direction == GST_PAD_SRC) { GValue value = G_VALUE_INIT; GValue v = G_VALUE_INIT; g_value_init (&value, GST_TYPE_LIST); g_value_init (&v, G_TYPE_STRING); g_value_set_string (&v, "interleaved"); gst_value_list_append_value (&value, &v); g_value_set_string (&v, "mixed"); gst_value_list_append_value (&value, &v); g_value_set_string (&v, "progressive"); gst_value_list_append_value (&value, &v); for (i = 0; i < gst_caps_get_size (othercaps); i++) { GstStructure *structure = gst_caps_get_structure (othercaps, i); gst_structure_set_value (structure, "interlace-mode", &value); gst_structure_remove_field (structure, "framerate"); } g_value_reset (&value); g_value_reset (&v); } else { for (i = 0; i < gst_caps_get_size (othercaps); i++) { GstStructure *structure = gst_caps_get_structure (othercaps, i); gst_structure_set (structure, "interlace-mode", G_TYPE_STRING, "progressive", NULL); gst_structure_remove_field (structure, "framerate"); } } if (filter) { GstCaps *intersect; intersect = gst_caps_intersect (othercaps, filter); gst_caps_unref (othercaps); othercaps = intersect; } return othercaps; }
static void add_element_used (InsanityGstPipelineTest * ptest, GstElement * element) { GstElementFactory *factory; const char *factory_name; char label[32], *element_name; GValue string_value = { 0 }; GstElement *parent; /* Only add once */ element_name = gst_element_get_name (element); if (g_hash_table_lookup_extended (ptest->priv->elements_used, element_name, NULL, NULL)) { g_free (element_name); return; } g_hash_table_insert (ptest->priv->elements_used, g_strdup (element_name), NULL); ptest->priv->element_count++; g_value_init (&string_value, G_TYPE_STRING); factory = gst_element_get_factory (element); factory_name = factory ? gst_element_factory_get_metadata (factory, GST_ELEMENT_METADATA_LONGNAME) : "(no factory)"; g_value_take_string (&string_value, element_name); snprintf (label, sizeof (label), "elements-used.%u.name", ptest->priv->element_count); insanity_test_set_extra_info (INSANITY_TEST (ptest), label, &string_value); g_value_reset (&string_value); g_value_set_string (&string_value, factory_name); snprintf (label, sizeof (label), "elements-used.%u.factory", ptest->priv->element_count); insanity_test_set_extra_info (INSANITY_TEST (ptest), label, &string_value); g_value_reset (&string_value); parent = GST_ELEMENT (gst_element_get_parent (element)); if (parent) { g_value_take_string (&string_value, gst_element_get_name (parent)); snprintf (label, sizeof (label), "elements-used.%u.parent", ptest->priv->element_count); insanity_test_set_extra_info (INSANITY_TEST (ptest), label, &string_value); g_value_reset (&string_value); gst_object_unref (parent); } }
static CoglGstVideoSink * find_cogl_gst_video_sink (GstElement *element) { GstElement *sink_element = NULL; GstIterator *iterator; GstElement *iterator_value; GValue value; if (!GST_IS_BIN (element)) return NULL; iterator = gst_bin_iterate_recurse (GST_BIN (element)); g_value_init (&value, GST_TYPE_ELEMENT); while (gst_iterator_next (iterator, &value) == GST_ITERATOR_OK) { iterator_value = g_value_get_object (&value); g_value_reset (&value); if (COGL_GST_IS_VIDEO_SINK (iterator_value)) { sink_element = iterator_value; break; } } g_value_unset (&value); gst_iterator_free (iterator); return COGL_GST_VIDEO_SINK (sink_element); }
static void setup_input_selector_counters (GstElement * element) { GstIterator *iterator; gboolean done = FALSE; GValue value = { 0, }; GstPad *pad; BufferCountData *bcd; iterator = gst_element_iterate_pads (element); while (!done) { switch (gst_iterator_next (iterator, &value)) { case GST_ITERATOR_OK: pad = g_value_dup_object (&value); bcd = g_slice_new0 (BufferCountData); g_object_set_data (G_OBJECT (pad), "buffer-count-data", bcd); bcd->probe_id = gst_pad_add_probe (pad, GST_PAD_PROBE_TYPE_BUFFER, (GstPadProbeCallback) input_selector_pad_probe, NULL, NULL); bcd->pad = pad; g_value_reset (&value); break; case GST_ITERATOR_RESYNC: gst_iterator_resync (iterator); break; case GST_ITERATOR_ERROR: done = TRUE; break; case GST_ITERATOR_DONE: done = TRUE; break; } } gst_iterator_free (iterator); }
/** * ppg_animation_load_begin_values: * @animation: (in): A #PpgAnimation. * * Load the begin values for all the properties we are about to * animate. * * Returns: None. * Side effects: None. */ static void ppg_animation_load_begin_values (PpgAnimation *animation) { PpgAnimationPrivate *priv; GtkContainer *container; Tween *tween; gint i; g_return_if_fail(PPG_IS_ANIMATION(animation)); priv = animation->priv; for (i = 0; i < priv->tweens->len; i++) { tween = &g_array_index(priv->tweens, Tween, i); g_value_reset(&tween->begin); if (tween->is_child) { container = GTK_CONTAINER(gtk_widget_get_parent(priv->target)); gtk_container_child_get_property(container, priv->target, tween->pspec->name, &tween->begin); } else { g_object_get_property(priv->target, tween->pspec->name, &tween->begin); } } }
static gboolean kms_element_iterate_pads (GstIterator * it, KmsPadCallback action, gpointer data) { gboolean done = FALSE; GstPad *pad; GValue item = G_VALUE_INIT; gboolean success = TRUE; while (!done) { switch (gst_iterator_next (it, &item)) { case GST_ITERATOR_OK: pad = g_value_get_object (&item); action (pad, data); g_value_reset (&item); break; case GST_ITERATOR_RESYNC: gst_iterator_resync (it); break; case GST_ITERATOR_ERROR: success = FALSE; case GST_ITERATOR_DONE: done = TRUE; break; } } g_value_unset (&item); return success; }
static void debug_tree_cell_data_func (GtkTreeViewColumn *tree_column, GtkCellRenderer *cell, GtkTreeModel *tree_model, GtkTreeIter *iter, gpointer data) { gchar *value; static const gchar *colors[] = {"black", "red"}; GValue gvalue = {0, }; DmaVariableData *node = NULL; gtk_tree_model_get (tree_model, iter, VALUE_COLUMN, &value, -1); g_value_init (&gvalue, G_TYPE_STRING); g_value_set_static_string (&gvalue, value); g_object_set_property (G_OBJECT (cell), "text", &gvalue); gtk_tree_model_get (tree_model, iter, DTREE_ENTRY_COLUMN, &node, -1); if (node) { g_value_reset (&gvalue); g_value_set_static_string (&gvalue, colors[(node && node->modified ? 1 : 0)]); g_object_set_property (G_OBJECT (cell), "foreground", &gvalue); } g_free (value); }
static gboolean gst_rtp_mux_src_event_real (GstRTPMux * rtp_mux, GstEvent * event) { GstIterator *iter; gboolean result = FALSE; gboolean done = FALSE; iter = gst_element_iterate_sink_pads (GST_ELEMENT (rtp_mux)); while (!done) { GValue item = { 0, }; switch (gst_iterator_next (iter, &item)) { case GST_ITERATOR_OK: gst_event_ref (event); result |= gst_pad_push_event (g_value_get_object (&item), event); g_value_reset (&item); break; case GST_ITERATOR_RESYNC: gst_iterator_resync (iter); result = FALSE; break; case GST_ITERATOR_ERROR: GST_WARNING_OBJECT (rtp_mux, "Error iterating sinkpads"); case GST_ITERATOR_DONE: done = TRUE; break; } } gst_iterator_free (iter); gst_event_unref (event); return result; }
static GValue * gegl_operation_context_add_value (GeglOperationContext *self, const gchar *property_name) { Property *property = NULL; GSList *found; found = g_slist_find_custom (self->property, property_name, lookup_property); if (found) { property = found->data; } if (property) { g_value_reset (&property->value); return &property->value; } property = property_new (property_name); self->property = g_slist_prepend (self->property, property); g_value_init (&property->value, GEGL_TYPE_BUFFER); return &property->value; }
void kms_element_for_each_src_pad (GstElement * element, KmsPadCallback action, gpointer data) { GstIterator *it = gst_element_iterate_src_pads (element); gboolean done = FALSE; GstPad *pad; GValue item = G_VALUE_INIT; while (!done) { switch (gst_iterator_next (it, &item)) { case GST_ITERATOR_OK: pad = g_value_get_object (&item); action (pad, data); g_value_reset (&item); break; case GST_ITERATOR_RESYNC: gst_iterator_resync (it); break; case GST_ITERATOR_ERROR: case GST_ITERATOR_DONE: done = TRUE; break; } } g_value_unset (&item); gst_iterator_free (it); }
static void gst_interpolation_control_source_set_internal (GstInterpolationControlSource * self, GstClockTime timestamp, GValue * value) { GstControlPoint *cp; GList *node; /* check if a control point for the timestamp already exists */ if ((node = g_list_find_custom (self->priv->values, ×tamp, gst_control_point_find))) { cp = node->data; g_value_reset (&cp->value); g_value_copy (value, &cp->value); } else { /* create a new GstControlPoint */ cp = g_new0 (GstControlPoint, 1); cp->timestamp = timestamp; g_value_init (&cp->value, self->priv->type); g_value_copy (value, &cp->value); /* and sort it into the prop->values list */ self->priv->values = g_list_insert_sorted (self->priv->values, cp, gst_control_point_compare); self->priv->nvalues++; } self->priv->valid_cache = FALSE; }
static void debug_dump_element_pads (GstIterator * pad_iter, GstPad * pad, GstElement * element, GstDebugGraphDetails details, GString * str, const gint indent, guint * src_pads, guint * sink_pads) { GValue item = { 0, }; gboolean pads_done; GstPadDirection dir; pads_done = FALSE; while (!pads_done) { switch (gst_iterator_next (pad_iter, &item)) { case GST_ITERATOR_OK: pad = g_value_get_object (&item); debug_dump_element_pad (pad, element, details, str, indent); dir = gst_pad_get_direction (pad); if (dir == GST_PAD_SRC) (*src_pads)++; else if (dir == GST_PAD_SINK) (*sink_pads)++; g_value_reset (&item); break; case GST_ITERATOR_RESYNC: gst_iterator_resync (pad_iter); break; case GST_ITERATOR_ERROR: case GST_ITERATOR_DONE: pads_done = TRUE; break; } } }
static GValue * gegl_operation_context_add_value (GeglOperationContext *self, const gchar *property_name, GType proptype) { Property *property = NULL; GSList *found; found = g_slist_find_custom (self->property, property_name, lookup_property); if (found) { property = found->data; } if (property) { /* XXX: check that the existing one was of the right type */ g_value_reset (&property->value); return &property->value; } property = property_new (property_name); self->property = g_slist_prepend (self->property, property); g_value_init (&property->value, proptype); return &property->value; }
gboolean eos_callback(GstPad *pad, GstObject *parent, GstEvent *event) { GstEvent *seek_event; GstElement *bkgdec; GValue v=G_VALUE_INIT; GstPad *srcpad; GstIterator *srcpads; gboolean result; g_print("Decodebin received EOS. Someone should handle that...\n"); bkgdec=gst_pad_get_parent_element(pad); if(bkgdec->numsrcpads>0) { srcpads=gst_element_iterate_src_pads(bkgdec); gst_iterator_next(srcpads,&v); srcpad=GST_PAD(g_value_get_object(&v)); seek_event=gst_event_new_seek ( 1.0, GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH, GST_SEEK_TYPE_SET, 0, GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE); result=gst_pad_send_event(srcpad,seek_event); if(result==TRUE) { g_print("seek event sent OK.\n"); } else { g_print("seek sent FAILED.\n"); } g_value_reset(&v); g_value_unset(&v); gst_iterator_free(srcpads); return TRUE; } return gst_pad_event_default(pad,parent,event); }
static void gst_sctp_base_sink_configure_sinks (GstSCTPBaseSink * self) { GstIterator *it; GValue val = G_VALUE_INIT; gboolean done = FALSE; it = gst_bin_iterate_sinks (GST_BIN (self)); do { switch (gst_iterator_next (it, &val)) { case GST_ITERATOR_OK: { GstElement *sctpclientsink; sctpclientsink = g_value_get_object (&val); g_object_set (sctpclientsink, "socket", self->priv->socket, NULL); g_value_reset (&val); break; } case GST_ITERATOR_RESYNC: gst_iterator_resync (it); break; case GST_ITERATOR_ERROR: GST_ERROR ("Error iterating over %s's sink elements", GST_ELEMENT_NAME (self)); case GST_ITERATOR_DONE: g_value_unset (&val); done = TRUE; break; } } while (!done); gst_iterator_free (it); }
void rstto_settings_set_navbar_position (RsttoSettings *settings, guint pos) { GValue val = {0, }; g_value_init (&val, G_TYPE_STRING); switch (pos) { default: g_value_set_string (&val, "left"); break; case 1: g_value_set_string (&val, "right"); break; case 2: g_value_set_string (&val, "top"); break; case 3: g_value_set_string (&val, "bottom"); break; } g_object_set_property (G_OBJECT(settings), "navigationbar-position", &val); g_value_reset (&val); }
static guint watch_container (InsanityGstPipelineTest * ptest, GstBin * bin) { GstIterator *it; gboolean done = FALSE; GValue data = { 0, }; GstElement *e; it = gst_bin_iterate_elements (bin); while (!done) { switch (gst_iterator_next (it, &data)) { case GST_ITERATOR_OK: e = GST_ELEMENT_CAST (g_value_get_object (&data)); add_element_used (ptest, e); if (GST_IS_BIN (e)) { watch_container (ptest, GST_BIN (e)); } g_value_reset (&data); break; case GST_ITERATOR_RESYNC: gst_iterator_resync (it); break; case GST_ITERATOR_DONE: default: done = TRUE; break; } } g_value_unset (&data); gst_iterator_free (it); return g_signal_connect (bin, "element-added", (GCallback) on_element_added, ptest); }
static void entity_ref_free(gpointer ptr) { EntityRef *ref = ptr; g_value_reset(&ref->value); g_slice_free(EntityRef, ref); }
static void set_appsrc_caps (GstElement * appsrc, const GstCaps * caps) { GValue framerate = G_VALUE_INIT; GstStructure *str; GstCaps *srccaps; srccaps = gst_caps_copy (caps); str = gst_caps_get_structure (srccaps, 0); if (str == NULL) { GST_ERROR_OBJECT (appsrc, "Can not get caps at index 0 from %" GST_PTR_FORMAT, srccaps); goto end; } /* Set variable framerate 0/1 */ g_value_init (&framerate, GST_TYPE_FRACTION); gst_value_set_fraction (&framerate, 0, 1); gst_structure_set_value (str, "framerate", &framerate); g_value_reset (&framerate); GST_DEBUG_OBJECT (appsrc, "Setting source caps %" GST_PTR_FORMAT, srccaps); g_object_set (appsrc, "caps", srccaps, NULL); end: gst_caps_unref (srccaps); }
static void on_pad_added (GstElement * element, GstPad * pad, GstElement * pipeline) { GstElement *ipcpipelinesink; GstPad *sinkpad; GstCaps *caps; const GstStructure *structure; GstIterator *it; GValue elem = G_VALUE_INIT; int sockets[2]; gboolean create_sockets; caps = gst_pad_get_current_caps (pad); structure = gst_caps_get_structure (caps, 0); it = gst_bin_iterate_sinks (GST_BIN (pipeline)); if (gst_iterator_find_custom (it, find_ipcpipelinesink, &elem, (gpointer) gst_structure_get_name (structure))) { ipcpipelinesink = g_value_get_object (&elem); create_sockets = FALSE; g_value_reset (&elem); } else { ipcpipelinesink = gst_element_factory_make ("ipcpipelinesink", NULL); gst_bin_add (GST_BIN (pipeline), ipcpipelinesink); create_sockets = TRUE; } sinkpad = gst_element_get_static_pad (ipcpipelinesink, "sink"); if (gst_pad_link (pad, sinkpad) != GST_PAD_LINK_OK) { fprintf (stderr, "Failed to link ipcpipelinesink\n"); exit (1); } gst_object_unref (sinkpad); g_signal_connect (pad, "unlinked", (GCallback) on_pad_unlinked, pipeline); if (create_sockets) { if (socketpair (AF_UNIX, SOCK_STREAM, 0, sockets)) { fprintf (stderr, "Error creating sockets: %s\n", strerror (errno)); exit (1); } if (fcntl (sockets[0], F_SETFL, O_NONBLOCK) < 0 || fcntl (sockets[1], F_SETFL, O_NONBLOCK) < 0) { fprintf (stderr, "Error setting O_NONBLOCK on sockets: %s\n", strerror (errno)); exit (1); } g_object_set (ipcpipelinesink, "fdin", sockets[0], "fdout", sockets[0], NULL); printf ("new socket %d\n", sockets[1]); sendfd (pipes[1], sockets[1]); } gst_element_set_state (ipcpipelinesink, GST_STATE_PLAYING); GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS (GST_BIN (pipeline), GST_DEBUG_GRAPH_SHOW_ALL, "pad.added"); }
void ghb_array_value_reset(GValue *gval, guint size) { GArray *array; g_value_reset(gval); array = g_array_sized_new(FALSE, FALSE, sizeof(GValue*), size); g_value_take_boxed(gval, array); }
void glade_gtk_box_get_property (GladeWidgetAdaptor * adaptor, GObject * object, const gchar * id, GValue * value) { if (!strcmp (id, "use-center-child")) { g_value_reset (value); g_value_set_boolean (value, gtk_box_get_center_widget (GTK_BOX (object)) != NULL); } else if (!strcmp (id, "size")) { g_value_reset (value); g_value_set_int (value, glade_gtk_box_get_num_children (object)); } else GWA_GET_CLASS (GTK_TYPE_CONTAINER)->get_property (adaptor, object, id, value); }
static GstPad * find_next_pad (GstElement * element, GstPad * pad) { GstIterator *iterator; gboolean done = FALSE, pick = FALSE; GstPad *tmp, *next = NULL, *first = NULL; GValue value = { 0, }; iterator = gst_element_iterate_sink_pads (element); while (!done) { switch (gst_iterator_next (iterator, &value)) { case GST_ITERATOR_OK: tmp = g_value_dup_object (&value); if (first == NULL) first = gst_object_ref (tmp); if (pick) { next = tmp; done = TRUE; } else { pick = (tmp == pad); gst_object_unref (tmp); } g_value_reset (&value); break; case GST_ITERATOR_RESYNC: if (next) { gst_object_unref (next); next = NULL; if (first) { gst_object_unref (first); first = NULL; } pick = FALSE; } gst_iterator_resync (iterator); break; case GST_ITERATOR_ERROR: done = TRUE; break; case GST_ITERATOR_DONE: /* When we reach the end, we may be in the case where the pad to search from was the last one in the list, in which case we want to return the first pad. */ if (pick) { next = first; first = NULL; } done = TRUE; break; } } gst_iterator_free (iterator); if (first) gst_object_unref (first); return next; }
static void on_rate_changed (GstElement * element, gint rate, gpointer user_data) { GValueArray *va; GValue v = { 0, }; GstFFTF64 *fft; GstFFTF64Complex frequency_response[17]; gdouble tmp[32]; gdouble filter_kernel[32]; guint i; /* Create the frequency response: zero outside * a small frequency band */ for (i = 0; i < 17; i++) { if (i < 5 || i > 11) frequency_response[i].r = 0.0; else frequency_response[i].r = 1.0; frequency_response[i].i = 0.0; } /* Calculate the inverse FT of the frequency response */ fft = gst_fft_f64_new (32, TRUE); gst_fft_f64_inverse_fft (fft, frequency_response, tmp); gst_fft_f64_free (fft); /* Shift the inverse FT of the frequency response by 16, * i.e. the half of the kernel length to get the * impulse response. See http://www.dspguide.com/ch17/1.htm * for more information. */ for (i = 0; i < 32; i++) filter_kernel[i] = tmp[(i + 16) % 32]; /* Apply the hamming window to the impulse response to get * a better result than given from the rectangular window */ for (i = 0; i < 32; i++) filter_kernel[i] *= (0.54 - 0.46 * cos (2 * G_PI * i / 32)); va = g_value_array_new (1); g_value_init (&v, G_TYPE_DOUBLE); for (i = 0; i < 32; i++) { g_value_set_double (&v, filter_kernel[i]); g_value_array_append (va, &v); g_value_reset (&v); } g_object_set (G_OBJECT (element), "kernel", va, NULL); /* Latency is 1/2 of the kernel length for this method of * calculating a filter kernel from the frequency response */ g_object_set (G_OBJECT (element), "latency", (gint64) (32 / 2), NULL); g_value_array_free (va); }