static void owr_inter_src_init(OwrInterSrc *self) { GstPad *srcpad, *sinkpad; GST_OBJECT_FLAG_SET(self, GST_ELEMENT_FLAG_SOURCE); self->queue = gst_element_factory_make("queue", NULL); gst_bin_add(GST_BIN(self), self->queue); srcpad = gst_element_get_static_pad(self->queue, "src"); self->srcpad = gst_ghost_pad_new_from_template("src", srcpad, gst_static_pad_template_get(&src_template)); gst_object_unref(srcpad); gst_element_add_pad(GST_ELEMENT(self), self->srcpad); /* Just to allow linking... */ self->dummy_sinkpad = gst_pad_new("dummy_sinkpad", GST_PAD_SINK); gst_object_set_parent(GST_OBJECT(self->dummy_sinkpad), GST_OBJECT(self)); self->internal_srcpad = gst_pad_new("internal_src", GST_PAD_SRC); gst_object_set_parent(GST_OBJECT(self->internal_srcpad), GST_OBJECT(self->dummy_sinkpad)); gst_pad_set_event_function(self->internal_srcpad, owr_inter_src_internal_src_event); gst_pad_set_query_function(self->internal_srcpad, owr_inter_src_internal_src_query); sinkpad = gst_element_get_static_pad(self->queue, "sink"); gst_pad_link(self->internal_srcpad, sinkpad); gst_object_unref(sinkpad); }
static void transport_stream_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec) { TransportStream *stream = TRANSPORT_STREAM (object); switch (prop_id) { case PROP_WEBRTC: gst_object_set_parent (GST_OBJECT (stream), g_value_get_object (value)); break; } GST_OBJECT_LOCK (stream); switch (prop_id) { case PROP_WEBRTC: break; case PROP_SESSION_ID: stream->session_id = g_value_get_uint (value); break; case PROP_RTCP_MUX: stream->rtcp_mux = g_value_get_boolean (value); break; case PROP_DTLS_CLIENT: stream->dtls_client = g_value_get_boolean (value); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } GST_OBJECT_UNLOCK (stream); }
static void webrtc_transceiver_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec) { WebRTCTransceiver *trans = WEBRTC_TRANSCEIVER (object); switch (prop_id) { case PROP_WEBRTC: gst_object_set_parent (GST_OBJECT (trans), g_value_get_object (value)); break; } GST_OBJECT_LOCK (trans); switch (prop_id) { case PROP_WEBRTC: break; case PROP_FEC_TYPE: trans->fec_type = g_value_get_enum (value); break; case PROP_DO_NACK: trans->do_nack = g_value_get_boolean (value); break; case PROP_FEC_PERCENTAGE: trans->fec_percentage = g_value_get_uint (value); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } GST_OBJECT_UNLOCK (trans); }
static GstStateChangeReturn gst_audio_ringbuffer_change_state (GstElement * element, GstStateChange transition) { GstAudioRingbuffer *ringbuffer; GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS; ringbuffer = GST_AUDIO_RINGBUFFER (element); switch (transition) { case GST_STATE_CHANGE_NULL_TO_READY: if (ringbuffer->buffer == NULL) { ringbuffer->buffer = gst_int_ring_buffer_new (); gst_object_set_parent (GST_OBJECT (ringbuffer->buffer), GST_OBJECT (ringbuffer)); gst_ring_buffer_open_device (ringbuffer->buffer); } break; case GST_STATE_CHANGE_READY_TO_PAUSED: ringbuffer->next_sample = -1; ringbuffer->last_align = -1; gst_ring_buffer_set_flushing (ringbuffer->buffer, FALSE); gst_ring_buffer_may_start (ringbuffer->buffer, TRUE); break; case GST_STATE_CHANGE_PAUSED_TO_READY: GST_OBJECT_LOCK (ringbuffer); ringbuffer->flushing = TRUE; ringbuffer->waiting = FALSE; g_cond_broadcast (ringbuffer->cond); GST_OBJECT_UNLOCK (ringbuffer); gst_ring_buffer_set_flushing (ringbuffer->buffer, TRUE); gst_ring_buffer_may_start (ringbuffer->buffer, FALSE); break; default: break; } ret = GST_ELEMENT_CLASS (elem_parent_class)->change_state (element, transition); switch (transition) { case GST_STATE_CHANGE_PAUSED_TO_READY: gst_ring_buffer_activate (ringbuffer->buffer, FALSE); gst_ring_buffer_release (ringbuffer->buffer); break; case GST_STATE_CHANGE_READY_TO_NULL: if (ringbuffer->buffer != NULL) { gst_ring_buffer_close_device (ringbuffer->buffer); gst_object_unparent (GST_OBJECT (ringbuffer->buffer)); ringbuffer->buffer = NULL; } break; default: break; } return ret; }
static void gst_deinterlace2_set_method (GstDeinterlace2 * self, GstDeinterlace2Methods method) { if (self->method) { gst_child_proxy_child_removed (GST_OBJECT (self), GST_OBJECT (self->method)); gst_object_unparent (GST_OBJECT (self->method)); self->method = NULL; } switch (method) { case GST_DEINTERLACE2_TOMSMOCOMP: self->method = g_object_new (GST_TYPE_DEINTERLACE_TOMSMOCOMP, NULL); break; case GST_DEINTERLACE2_GREEDY_H: self->method = g_object_new (GST_TYPE_DEINTERLACE_GREEDY_H, NULL); break; case GST_DEINTERLACE2_GREEDY_L: self->method = g_object_new (GST_TYPE_DEINTERLACE_GREEDY_L, NULL); break; case GST_DEINTERLACE2_VFIR: self->method = g_object_new (GST_TYPE_DEINTERLACE_VFIR, NULL); break; case GST_DEINTERLACE2_LINEAR: self->method = g_object_new (GST_TYPE_DEINTERLACE_LINEAR, NULL); break; case GST_DEINTERLACE2_LINEAR_BLEND: self->method = g_object_new (GST_TYPE_DEINTERLACE_LINEAR_BLEND, NULL); break; case GST_DEINTERLACE2_SCALER_BOB: self->method = g_object_new (GST_TYPE_DEINTERLACE_SCALER_BOB, NULL); break; case GST_DEINTERLACE2_WEAVE: self->method = g_object_new (GST_TYPE_DEINTERLACE_WEAVE, NULL); break; case GST_DEINTERLACE2_WEAVE_TFF: self->method = g_object_new (GST_TYPE_DEINTERLACE_WEAVE_TFF, NULL); break; case GST_DEINTERLACE2_WEAVE_BFF: self->method = g_object_new (GST_TYPE_DEINTERLACE_WEAVE_BFF, NULL); break; default: GST_WARNING ("Invalid Deinterlacer Method"); return; } self->method_id = method; gst_object_set_name (GST_OBJECT (self->method), "method"); gst_object_set_parent (GST_OBJECT (self->method), GST_OBJECT (self)); gst_child_proxy_child_added (GST_OBJECT (self), GST_OBJECT (self->method)); }
void gss_program_add_stream (GssProgram * program, GssStream * stream) { g_return_if_fail (GSS_IS_PROGRAM (program)); g_return_if_fail (GSS_IS_STREAM (stream)); program->streams = g_list_append (program->streams, stream); stream->program = program; gss_stream_add_resources (stream); gst_object_set_parent (GST_OBJECT (stream), GST_OBJECT (program)); }
/** * gst_base_audio_src_create_ringbuffer: * @src: a #GstBaseAudioSrc. * * Create and return the #GstRingBuffer for @src. This function will call the * ::create_ringbuffer vmethod and will set @src as the parent of the returned * buffer (see gst_object_set_parent()). * * Returns: The new ringbuffer of @src. */ GstRingBuffer * gst_base_audio_src_create_ringbuffer (GstBaseAudioSrc * src) { GstBaseAudioSrcClass *bclass; GstRingBuffer *buffer = NULL; bclass = GST_BASE_AUDIO_SRC_GET_CLASS (src); if (bclass->create_ringbuffer) buffer = bclass->create_ringbuffer (src); if (G_LIKELY (buffer)) gst_object_set_parent (GST_OBJECT_CAST (buffer), GST_OBJECT_CAST (src)); return buffer; }
static void gst_object_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec) { GstObject *gstobject; gstobject = GST_OBJECT_CAST (object); switch (prop_id) { case PROP_NAME: gst_object_set_name (gstobject, g_value_get_string (value)); break; case PROP_PARENT: gst_object_set_parent (gstobject, g_value_get_object (value)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } }
void gst_iir_equalizer_compute_frequencies (GstIirEqualizer * equ, guint new_count) { guint old_count, i; gdouble freq0, freq1, step; gchar name[20]; if (equ->freq_band_count == new_count) return; BANDS_LOCK (equ); if (G_UNLIKELY (equ->freq_band_count == new_count)) { BANDS_UNLOCK (equ); return; } old_count = equ->freq_band_count; equ->freq_band_count = new_count; GST_DEBUG ("bands %u -> %u", old_count, new_count); if (old_count < new_count) { /* add new bands */ equ->bands = g_realloc (equ->bands, sizeof (GstObject *) * new_count); for (i = old_count; i < new_count; i++) { /* otherwise they get names like 'iirequalizerband5' */ sprintf (name, "band%u", i); equ->bands[i] = g_object_new (GST_TYPE_IIR_EQUALIZER_BAND, "name", name, NULL); GST_DEBUG ("adding band[%d]=%p", i, equ->bands[i]); gst_object_set_parent (GST_OBJECT (equ->bands[i]), GST_OBJECT (equ)); gst_child_proxy_child_added (GST_OBJECT (equ), GST_OBJECT (equ->bands[i])); } } else { /* free unused bands */ for (i = new_count; i < old_count; i++) { GST_DEBUG ("removing band[%d]=%p", i, equ->bands[i]); gst_child_proxy_child_removed (GST_OBJECT (equ), GST_OBJECT (equ->bands[i])); gst_object_unparent (GST_OBJECT (equ->bands[i])); equ->bands[i] = NULL; } } alloc_history (equ); /* set center frequencies and name band objects * FIXME: arg! we can't change the name of parented objects :( * application should read band->freq to get the name */ step = pow (HIGHEST_FREQ / LOWEST_FREQ, 1.0 / new_count); freq0 = LOWEST_FREQ; for (i = 0; i < new_count; i++) { freq1 = freq0 * step; if (i == 0) equ->bands[i]->type = BAND_TYPE_LOW_SHELF; else if (i == new_count - 1) equ->bands[i]->type = BAND_TYPE_HIGH_SHELF; else equ->bands[i]->type = BAND_TYPE_PEAK; equ->bands[i]->freq = freq0 + ((freq1 - freq0) / 2.0); equ->bands[i]->width = freq1 - freq0; GST_DEBUG ("band[%2d] = '%lf'", i, equ->bands[i]->freq); g_object_notify (G_OBJECT (equ->bands[i]), "bandwidth"); g_object_notify (G_OBJECT (equ->bands[i]), "freq"); g_object_notify (G_OBJECT (equ->bands[i]), "type"); /* if(equ->bands[i]->freq<10000.0) sprintf (name,"%dHz",(gint)equ->bands[i]->freq); else sprintf (name,"%dkHz",(gint)(equ->bands[i]->freq/1000.0)); gst_object_set_name( GST_OBJECT (equ->bands[i]), name); GST_DEBUG ("band[%2d] = '%s'",i,name); */ freq0 = freq1; } equ->need_new_coefficients = TRUE; BANDS_UNLOCK (equ); }
/** * gst_ghost_pad_construct: * @gpad: the newly allocated ghost pad * * Finish initialization of a newly allocated ghost pad. * * This function is most useful in language bindings and when subclassing * #GstGhostPad; plugin and application developers normally will not call this * function. Call this function directly after a call to g_object_new * (GST_TYPE_GHOST_PAD, "direction", @dir, ..., NULL). * * Returns: %TRUE if the construction succeeds, %FALSE otherwise. */ gboolean gst_ghost_pad_construct (GstGhostPad * gpad) { GstPadDirection dir, otherdir; GstPadTemplate *templ; GstPad *pad, *internal; g_return_val_if_fail (GST_IS_GHOST_PAD (gpad), FALSE); g_return_val_if_fail (GST_GHOST_PAD_PRIVATE (gpad)->constructed == FALSE, FALSE); g_object_get (gpad, "direction", &dir, "template", &templ, NULL); g_return_val_if_fail (dir != GST_PAD_UNKNOWN, FALSE); pad = GST_PAD (gpad); /* Set directional padfunctions for ghostpad */ if (dir == GST_PAD_SINK) { gst_pad_set_chain_function (pad, gst_proxy_pad_chain_default); gst_pad_set_chain_list_function (pad, gst_proxy_pad_chain_list_default); } else { gst_pad_set_getrange_function (pad, gst_proxy_pad_getrange_default); } /* INTERNAL PAD, it always exists and is child of the ghostpad */ otherdir = (dir == GST_PAD_SRC) ? GST_PAD_SINK : GST_PAD_SRC; if (templ) { internal = g_object_new (GST_TYPE_PROXY_PAD, "name", NULL, "direction", otherdir, "template", templ, NULL); /* release ref obtained via g_object_get */ gst_object_unref (templ); } else { internal = g_object_new (GST_TYPE_PROXY_PAD, "name", NULL, "direction", otherdir, NULL); } GST_PAD_UNSET_FLUSHING (internal); /* Set directional padfunctions for internal pad */ if (dir == GST_PAD_SRC) { gst_pad_set_chain_function (internal, gst_proxy_pad_chain_default); gst_pad_set_chain_list_function (internal, gst_proxy_pad_chain_list_default); } else { gst_pad_set_getrange_function (internal, gst_proxy_pad_getrange_default); } GST_OBJECT_LOCK (pad); /* now make the ghostpad a parent of the internal pad */ if (!gst_object_set_parent (GST_OBJECT_CAST (internal), GST_OBJECT_CAST (pad))) goto parent_failed; /* The ghostpad is the parent of the internal pad and is the only object that * can have a refcount on the internal pad. * At this point, the GstGhostPad has a refcount of 1, and the internal pad has * a refcount of 1. * When the refcount of the GstGhostPad drops to 0, the ghostpad will dispose * its refcount on the internal pad in the dispose method by un-parenting it. * This is why we don't take extra refcounts in the assignments below */ GST_PROXY_PAD_INTERNAL (pad) = internal; GST_PROXY_PAD_INTERNAL (internal) = pad; /* special activation functions for the internal pad */ gst_pad_set_activatemode_function (internal, gst_ghost_pad_internal_activate_mode_default); GST_OBJECT_UNLOCK (pad); GST_GHOST_PAD_PRIVATE (gpad)->constructed = TRUE; return TRUE; /* ERRORS */ parent_failed: { GST_WARNING_OBJECT (gpad, "Could not set internal pad %s:%s", GST_DEBUG_PAD_NAME (internal)); g_critical ("Could not set internal pad %s:%s", GST_DEBUG_PAD_NAME (internal)); GST_OBJECT_UNLOCK (pad); gst_object_unref (internal); return FALSE; } }
bool Object::setParent(const ObjectPtr & parent) { return gst_object_set_parent(object<GstObject>(), parent); }
static GstPad * gst_ghost_pad_new_full (const gchar * name, GstPadDirection dir, GstPadTemplate * templ) { GstPad *ret; GstPad *internal; GstPadDirection otherdir; g_return_val_if_fail (dir != GST_PAD_UNKNOWN, NULL); /* OBJECT CREATION */ if (templ) { ret = g_object_new (GST_TYPE_GHOST_PAD, "name", name, "direction", dir, "template", templ, NULL); } else { ret = g_object_new (GST_TYPE_GHOST_PAD, "name", name, "direction", dir, NULL); } /* Set directional padfunctions for ghostpad */ if (dir == GST_PAD_SINK) { gst_pad_set_bufferalloc_function (ret, GST_DEBUG_FUNCPTR (gst_proxy_pad_do_bufferalloc)); gst_pad_set_chain_function (ret, GST_DEBUG_FUNCPTR (gst_proxy_pad_do_chain)); } else { gst_pad_set_getrange_function (ret, GST_DEBUG_FUNCPTR (gst_proxy_pad_do_getrange)); gst_pad_set_checkgetrange_function (ret, GST_DEBUG_FUNCPTR (gst_proxy_pad_do_checkgetrange)); } /* link/unlink functions */ gst_pad_set_link_function (ret, GST_DEBUG_FUNCPTR (gst_ghost_pad_do_link)); gst_pad_set_unlink_function (ret, GST_DEBUG_FUNCPTR (gst_ghost_pad_do_unlink)); /* INTERNAL PAD, it always exists and is child of the ghostpad */ otherdir = (dir == GST_PAD_SRC) ? GST_PAD_SINK : GST_PAD_SRC; if (templ) { internal = g_object_new (GST_TYPE_PROXY_PAD, "name", NULL, "direction", otherdir, "template", templ, NULL); } else { internal = g_object_new (GST_TYPE_PROXY_PAD, "name", NULL, "direction", otherdir, NULL); } GST_PAD_UNSET_FLUSHING (internal); /* Set directional padfunctions for internal pad */ if (dir == GST_PAD_SRC) { gst_pad_set_bufferalloc_function (internal, GST_DEBUG_FUNCPTR (gst_proxy_pad_do_bufferalloc)); gst_pad_set_chain_function (internal, GST_DEBUG_FUNCPTR (gst_proxy_pad_do_chain)); } else { gst_pad_set_getrange_function (internal, GST_DEBUG_FUNCPTR (gst_proxy_pad_do_getrange)); gst_pad_set_checkgetrange_function (internal, GST_DEBUG_FUNCPTR (gst_proxy_pad_do_checkgetrange)); } GST_PROXY_LOCK (ret); /* now make the ghostpad a parent of the internal pad */ if (!gst_object_set_parent (GST_OBJECT_CAST (internal), GST_OBJECT_CAST (ret))) goto parent_failed; /* The ghostpad is the parent of the internal pad and is the only object that * can have a refcount on the internal pad. * At this point, the GstGhostPad has a refcount of 1, and the internal pad has * a refcount of 1. * When the refcount of the GstGhostPad drops to 0, the ghostpad will dispose * it's refcount on the internal pad in the dispose method by un-parenting it. * This is why we don't take extra refcounts in the assignments below */ GST_PROXY_PAD_INTERNAL (ret) = internal; GST_PROXY_PAD_INTERNAL (internal) = ret; /* could be more general here, iterating over all writable properties... * taking the short road for now tho */ GST_GHOST_PAD_CAST (ret)->notify_id = g_signal_connect (internal, "notify::caps", G_CALLBACK (on_int_notify), ret); /* call function to init values of the pad caps */ on_int_notify (internal, NULL, GST_GHOST_PAD_CAST (ret)); /* special activation functions for the internal pad */ gst_pad_set_activatepull_function (internal, GST_DEBUG_FUNCPTR (gst_ghost_pad_internal_do_activate_pull)); gst_pad_set_activatepush_function (internal, GST_DEBUG_FUNCPTR (gst_ghost_pad_internal_do_activate_push)); GST_PROXY_UNLOCK (ret); return ret; /* ERRORS */ parent_failed: { GST_WARNING_OBJECT (ret, "Could not set internal pad %s:%s", GST_DEBUG_PAD_NAME (internal)); g_critical ("Could not set internal pad %s:%s", GST_DEBUG_PAD_NAME (internal)); GST_PROXY_UNLOCK (ret); gst_object_unref (ret); gst_object_unref (internal); return NULL; } }