static void mpegts_base_init (MpegTSBase * base) { base->sinkpad = gst_pad_new_from_static_template (&sink_template, "sink"); gst_pad_set_activate_function (base->sinkpad, mpegts_base_sink_activate); gst_pad_set_activatemode_function (base->sinkpad, mpegts_base_sink_activate_mode); gst_pad_set_chain_function (base->sinkpad, mpegts_base_chain); gst_pad_set_event_function (base->sinkpad, mpegts_base_sink_event); gst_element_add_pad (GST_ELEMENT (base), base->sinkpad); base->disposed = FALSE; base->packetizer = mpegts_packetizer_new (); base->programs = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, (GDestroyNotify) mpegts_base_free_program); base->parse_private_sections = FALSE; base->is_pes = g_new0 (guint8, 1024); base->known_psi = g_new0 (guint8, 1024); base->program_size = sizeof (MpegTSBaseProgram); base->stream_size = sizeof (MpegTSBaseStream); base->push_data = TRUE; base->push_section = TRUE; mpegts_base_reset (base); }
static void gst_rnd_buffer_size_init (GstRndBufferSize * self) { self->sinkpad = gst_pad_new_from_static_template (&sink_template, "sink"); gst_pad_set_activate_function (self->sinkpad, GST_DEBUG_FUNCPTR (gst_rnd_buffer_size_activate)); gst_pad_set_activatemode_function (self->sinkpad, GST_DEBUG_FUNCPTR (gst_rnd_buffer_size_activate_mode)); gst_pad_set_event_function (self->sinkpad, GST_DEBUG_FUNCPTR (gst_rnd_buffer_size_sink_event)); gst_pad_set_chain_function (self->sinkpad, GST_DEBUG_FUNCPTR (gst_rnd_buffer_size_chain)); GST_OBJECT_FLAG_SET (self->sinkpad, GST_PAD_FLAG_PROXY_CAPS); GST_OBJECT_FLAG_SET (self->sinkpad, GST_PAD_FLAG_PROXY_ALLOCATION); GST_OBJECT_FLAG_SET (self->sinkpad, GST_PAD_FLAG_PROXY_SCHEDULING); gst_element_add_pad (GST_ELEMENT (self), self->sinkpad); self->srcpad = gst_pad_new_from_static_template (&src_template, "src"); gst_pad_set_event_function (self->srcpad, GST_DEBUG_FUNCPTR (gst_rnd_buffer_size_src_event)); GST_OBJECT_FLAG_SET (self->srcpad, GST_PAD_FLAG_PROXY_CAPS); GST_OBJECT_FLAG_SET (self->srcpad, GST_PAD_FLAG_PROXY_ALLOCATION); GST_OBJECT_FLAG_SET (self->srcpad, GST_PAD_FLAG_PROXY_SCHEDULING); gst_element_add_pad (GST_ELEMENT (self), self->srcpad); }
/* initialize the new element * instantiate pads and add them to element * set functions * initialize structure */ static void gst_wildmidi_init (GstWildmidi * filter) { filter->sinkpad = gst_pad_new_from_static_template (&sink_factory, "sink"); gst_pad_set_activatemode_function (filter->sinkpad, gst_wildmidi_activatemode); gst_pad_set_activate_function (filter->sinkpad, gst_wildmidi_activate); gst_pad_set_event_function (filter->sinkpad, gst_wildmidi_sink_event); gst_pad_set_chain_function (filter->sinkpad, gst_wildmidi_chain); gst_element_add_pad (GST_ELEMENT (filter), filter->sinkpad); filter->srcpad = gst_pad_new_from_static_template (&src_factory, "src"); gst_pad_set_query_function (filter->srcpad, gst_wildmidi_src_query); gst_pad_set_event_function (filter->srcpad, gst_wildmidi_src_event); gst_pad_use_fixed_caps (filter->srcpad); gst_element_add_pad (GST_ELEMENT (filter), filter->srcpad); gst_segment_init (filter->o_segment, GST_FORMAT_DEFAULT); filter->adapter = gst_adapter_new (); filter->bytes_per_frame = WILDMIDI_BPS; filter->high_quality = DEFAULT_HIGH_QUALITY; filter->linear_volume = DEFAULT_LINEAR_VOLUME; }
static void gst_musepackdec_init (GstMusepackDec * musepackdec) { musepackdec->offset = 0; musepackdec->rate = 0; musepackdec->bps = 0; musepackdec->r = g_new (mpc_reader, 1); musepackdec->sinkpad = gst_pad_new_from_static_template (&sink_template, "sink"); gst_pad_set_activate_function (musepackdec->sinkpad, GST_DEBUG_FUNCPTR (gst_musepackdec_sink_activate)); gst_pad_set_activatemode_function (musepackdec->sinkpad, GST_DEBUG_FUNCPTR (gst_musepackdec_sink_activate_mode)); gst_element_add_pad (GST_ELEMENT (musepackdec), musepackdec->sinkpad); musepackdec->srcpad = gst_pad_new_from_static_template (&src_template, "src"); gst_pad_set_event_function (musepackdec->srcpad, GST_DEBUG_FUNCPTR (gst_musepackdec_src_event)); gst_pad_set_query_function (musepackdec->srcpad, GST_DEBUG_FUNCPTR (gst_musepackdec_src_query)); gst_pad_use_fixed_caps (musepackdec->srcpad); gst_element_add_pad (GST_ELEMENT (musepackdec), musepackdec->srcpad); }
static void gst_ghost_pad_init (GstGhostPad * pad) { GST_GHOST_PAD_PRIVATE (pad) = gst_ghost_pad_get_instance_private (pad); gst_pad_set_activatemode_function (GST_PAD_CAST (pad), gst_ghost_pad_activate_mode_default); }
static void gst_ghost_pad_init (GstGhostPad * pad) { GST_GHOST_PAD_PRIVATE (pad) = G_TYPE_INSTANCE_GET_PRIVATE (pad, GST_TYPE_GHOST_PAD, GstGhostPadPrivate); gst_pad_set_activatemode_function (GST_PAD_CAST (pad), gst_ghost_pad_activate_mode_default); }
static void gst_ts_shifter_init (GstTSShifter * ts) { ts->sinkpad = gst_pad_new_from_static_template (&sink_factory, "sink"); gst_pad_set_chain_function (ts->sinkpad, GST_DEBUG_FUNCPTR (gst_ts_shifter_chain)); gst_pad_set_activatemode_function (ts->sinkpad, GST_DEBUG_FUNCPTR (gst_ts_shifter_sink_activate_mode)); gst_pad_set_event_function (ts->sinkpad, GST_DEBUG_FUNCPTR (gst_ts_shifter_handle_sink_event)); gst_element_add_pad (GST_ELEMENT (ts), ts->sinkpad); ts->srcpad = gst_pad_new_from_static_template (&src_factory, "src"); gst_pad_set_activatemode_function (ts->srcpad, GST_DEBUG_FUNCPTR (gst_ts_shifter_src_activate_mode)); gst_pad_set_event_function (ts->srcpad, GST_DEBUG_FUNCPTR (gst_ts_shifter_handle_src_event)); gst_pad_set_query_function (ts->srcpad, GST_DEBUG_FUNCPTR (gst_ts_shifter_handle_src_query)); gst_element_add_pad (GST_ELEMENT (ts), ts->srcpad); /* set default values */ ts->cur_bytes = 0; ts->srcresult = GST_FLOW_FLUSHING; ts->sinkresult = GST_FLOW_FLUSHING; ts->is_eos = FALSE; ts->need_newsegment = TRUE; ts->is_leaking = FALSE; g_mutex_init (&ts->flow_lock); g_cond_init (&ts->buffer_add); ts->allocator_name = NULL; ts->cache = NULL; ts->cache_size = DEFAULT_CACHE_SIZE; GST_DEBUG_OBJECT (ts, "initialized time shifter"); }
static void gst_type_find_element_init (GstTypeFindElement * typefind) { /* sinkpad */ typefind->sink = gst_pad_new_from_static_template (&type_find_element_sink_template, "sink"); gst_pad_set_activate_function (typefind->sink, GST_DEBUG_FUNCPTR (gst_type_find_element_activate_sink)); gst_pad_set_activatemode_function (typefind->sink, GST_DEBUG_FUNCPTR (gst_type_find_element_activate_sink_mode)); gst_pad_set_chain_function (typefind->sink, GST_DEBUG_FUNCPTR (gst_type_find_element_chain)); gst_pad_set_event_function (typefind->sink, GST_DEBUG_FUNCPTR (gst_type_find_element_sink_event)); GST_PAD_SET_PROXY_ALLOCATION (typefind->sink); gst_element_add_pad (GST_ELEMENT (typefind), typefind->sink); /* srcpad */ typefind->src = gst_pad_new_from_static_template (&type_find_element_src_template, "src"); gst_pad_set_activatemode_function (typefind->src, GST_DEBUG_FUNCPTR (gst_type_find_element_activate_src_mode)); gst_pad_set_getrange_function (typefind->src, GST_DEBUG_FUNCPTR (gst_type_find_element_getrange)); gst_pad_set_event_function (typefind->src, GST_DEBUG_FUNCPTR (gst_type_find_element_src_event)); gst_pad_set_query_function (typefind->src, GST_DEBUG_FUNCPTR (gst_type_find_handle_src_query)); gst_pad_use_fixed_caps (typefind->src); gst_element_add_pad (GST_ELEMENT (typefind), typefind->src); typefind->mode = MODE_TYPEFIND; typefind->caps = NULL; typefind->min_probability = 1; typefind->adapter = gst_adapter_new (); }
static void _pad_constructed (GObject * object) { GstPad *pad = GST_PAD (object); gst_pad_set_chain_function (pad, GST_DEBUG_FUNCPTR ((GstPadChainFunction) _chain)); gst_pad_set_event_function (pad, GST_DEBUG_FUNCPTR ((GstPadEventFunction) pad_event_func)); gst_pad_set_query_function (pad, GST_DEBUG_FUNCPTR ((GstPadQueryFunction) pad_query_func)); gst_pad_set_activatemode_function (pad, GST_DEBUG_FUNCPTR ((GstPadActivateModeFunction) pad_activate_mode_func)); }
static GstPad * gst_tcp_mix_src_request_new_pad (GstElement * element, GstPadTemplate * templ, const gchar * unused, const GstCaps * caps) { GstTCPMixSrc *src = GST_TCP_MIX_SRC (element); GstPad *srcpad; gchar *name; gboolean res; int num; //g_print ("%s:%d: %s\n", __FILE__, __LINE__, __FUNCTION__); GST_INFO_OBJECT (src, "Requesting new pad %s.%s (caps: %s)", GST_ELEMENT_NAME (src), GST_PAD_TEMPLATE_NAME_TEMPLATE (templ), gst_caps_to_string (caps)); GST_OBJECT_LOCK (src); num = g_list_length (GST_ELEMENT_PADS (src)); name = g_strdup_printf ("src_%u", num); srcpad = GST_PAD_CAST (g_object_new (GST_TYPE_TCP_MIX_SRC_PAD, "name", name, "direction", templ->direction, "template", templ, NULL)); g_free (name); GST_OBJECT_UNLOCK (src); // see: gst_tcp_mix_src_activate_push gst_pad_set_active (srcpad, TRUE); gst_pad_activate_mode (srcpad, GST_PAD_MODE_PUSH, TRUE); gst_pad_set_activatemode_function (srcpad, (GstPadActivateModeFunction) gst_tcp_mix_src_activate_mode); gst_pad_set_query_function (srcpad, gst_tcp_mix_src_query); gst_pad_set_event_function (srcpad, gst_tcp_mix_src_event); gst_pad_set_getrange_function (srcpad, gst_tcp_mix_src_getrange); //GST_OBJECT_FLAG_SET (srcpad, GST_PAD_FLAG_PROXY_CAPS); //INFO ("add-pad: %s.%s", GST_ELEMENT_NAME (src), GST_PAD_NAME (srcpad)); res = gst_element_add_pad (GST_ELEMENT_CAST (src), srcpad); gst_tcp_mix_src_start (src, GST_TCP_MIX_SRC_PAD (srcpad)); if (G_UNLIKELY (!res)) { GST_ERROR_OBJECT (src, "Failed to add new pad"); } return srcpad; }
static void gst_rnd_buffer_size_init (GstRndBufferSize * self) { self->sinkpad = gst_pad_new_from_static_template (&sink_template, "sink"); gst_pad_set_activate_function (self->sinkpad, GST_DEBUG_FUNCPTR (gst_rnd_buffer_size_activate)); gst_pad_set_activatemode_function (self->sinkpad, GST_DEBUG_FUNCPTR (gst_rnd_buffer_size_activate_mode)); gst_element_add_pad (GST_ELEMENT (self), self->sinkpad); self->srcpad = gst_pad_new_from_static_template (&src_template, "src"); gst_pad_set_event_function (self->srcpad, GST_DEBUG_FUNCPTR (gst_rnd_buffer_size_src_event)); gst_element_add_pad (GST_ELEMENT (self), self->srcpad); }
/** * progress_buffer_create_sourcepad() * */ static void progress_buffer_create_sourcepad(ProgressBuffer *element) { element->srcpad = gst_pad_new_from_template (gst_element_class_get_pad_template (GST_ELEMENT_GET_CLASS(element), "src"), "src"); gst_pad_set_activatemode_function (element->srcpad, GST_DEBUG_FUNCPTR(progress_buffer_activatemode)); gst_pad_set_event_function (element->srcpad, GST_DEBUG_FUNCPTR(progress_buffer_src_event)); gst_pad_set_getrange_function (element->srcpad, GST_DEBUG_FUNCPTR(progress_buffer_getrange)); GST_PAD_UNSET_FLUSHING(element->srcpad); // Add pad gst_element_add_pad (GST_ELEMENT (element), element->srcpad); // Activate pad gst_pad_set_active (element->srcpad, TRUE); // Send "no-more-pads" gst_element_no_more_pads(GST_ELEMENT (element)); }
static void mpegts_demuxer_init(MpegTSDemuxer *demuxer) { // Input. demuxer->sinkpad = gst_pad_new_from_static_template(&sink_template, "sink"); gst_pad_set_chain_function(demuxer->sinkpad, GST_DEBUG_FUNCPTR(mpegts_demuxer_chain)); gst_pad_set_query_function (demuxer->sinkpad, GST_DEBUG_FUNCPTR(mpegts_demuxer_sink_query)); gst_pad_set_event_function(demuxer->sinkpad, GST_DEBUG_FUNCPTR(mpegts_demuxer_sink_event)); gst_pad_set_activatemode_function(demuxer->sinkpad, GST_DEBUG_FUNCPTR(mpegts_demuxer_activatemode)); gst_element_add_pad(GST_ELEMENT(demuxer), demuxer->sinkpad); g_mutex_init(&demuxer->lock); g_cond_init(&demuxer->add_cond); g_cond_init(&demuxer->del_cond); demuxer->sink_adapter = gst_adapter_new(); demuxer->reader_thread = NULL; demuxer->numpads = 0; demuxer->base_pts = GST_CLOCK_TIME_NONE; }
static void gst_real_audio_demux_init (GstRealAudioDemux * demux) { demux->sinkpad = gst_pad_new_from_static_template (&sink_template, "sink"); gst_pad_set_chain_function (demux->sinkpad, GST_DEBUG_FUNCPTR (gst_real_audio_demux_chain)); gst_pad_set_event_function (demux->sinkpad, GST_DEBUG_FUNCPTR (gst_real_audio_demux_sink_event)); gst_pad_set_activate_function (demux->sinkpad, GST_DEBUG_FUNCPTR (gst_real_audio_demux_sink_activate)); gst_pad_set_activatemode_function (demux->sinkpad, GST_DEBUG_FUNCPTR (gst_real_audio_demux_sink_activate_mode)); gst_element_add_pad (GST_ELEMENT (demux), demux->sinkpad); demux->adapter = gst_adapter_new (); gst_real_audio_demux_reset (demux); }
static void gst_aggregator_init (GstAggregator * self, GstAggregatorClass * klass) { GstPadTemplate *pad_template; GstAggregatorPrivate *priv; g_return_if_fail (klass->aggregate != NULL); self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GST_TYPE_AGGREGATOR, GstAggregatorPrivate); priv = self->priv; pad_template = gst_element_class_get_pad_template (GST_ELEMENT_CLASS (klass), "src"); g_return_if_fail (pad_template != NULL); priv->padcount = -1; priv->tags_changed = FALSE; self->priv->latency_live = FALSE; self->priv->latency_min = 0; self->priv->latency_max = GST_CLOCK_TIME_NONE; _reset_flow_values (self); AGGREGATOR_QUEUE (self) = g_async_queue_new (); self->srcpad = gst_pad_new_from_template (pad_template, "src"); gst_pad_set_event_function (self->srcpad, GST_DEBUG_FUNCPTR ((GstPadEventFunction) src_event_func)); gst_pad_set_query_function (self->srcpad, GST_DEBUG_FUNCPTR ((GstPadQueryFunction) src_query_func)); gst_pad_set_activatemode_function (self->srcpad, GST_DEBUG_FUNCPTR ((GstPadActivateModeFunction) src_activate_mode)); gst_element_add_pad (GST_ELEMENT (self), self->srcpad); self->clock = gst_system_clock_obtain (); self->timeout = -1; g_mutex_init (&self->priv->setcaps_lock); }
static void gst_sctp_enc_init(GstSctpEnc *self) { self->sctp_association_id = DEFAULT_GST_SCTP_ASSOCIATION_ID; self->remote_sctp_port = DEFAULT_REMOTE_SCTP_PORT; self->sctp_association = NULL; self->outbound_sctp_packet_queue = gst_data_queue_new(data_queue_check_full_cb, data_queue_full_cb, data_queue_empty_cb, NULL); self->src_pad = gst_pad_new_from_static_template(&src_template, "src"); gst_pad_set_event_function(self->src_pad, GST_DEBUG_FUNCPTR((GstPadEventFunction)gst_sctp_enc_src_event)); gst_pad_set_activatemode_function (self->src_pad, GST_DEBUG_FUNCPTR (gst_sctp_enc_src_activate_mode)); gst_element_add_pad(GST_ELEMENT(self), self->src_pad); g_queue_init(&self->pending_pads); }
static void gst_ghost_pad_dispose (GObject * object) { GstPad *pad; GstPad *internal; GstPad *peer; pad = GST_PAD (object); GST_DEBUG_OBJECT (pad, "dispose"); gst_ghost_pad_set_target (GST_GHOST_PAD (pad), NULL); /* Unlink here so that gst_pad_dispose doesn't. That would lead to a call to * gst_ghost_pad_unlink_default when the ghost pad is in an inconsistent state */ peer = gst_pad_get_peer (pad); if (peer) { if (GST_PAD_IS_SRC (pad)) gst_pad_unlink (pad, peer); else gst_pad_unlink (peer, pad); gst_object_unref (peer); } GST_OBJECT_LOCK (pad); internal = GST_PROXY_PAD_INTERNAL (pad); if (internal) { gst_pad_set_activatemode_function (internal, NULL); GST_PROXY_PAD_INTERNAL (pad) = NULL; GST_PROXY_PAD_INTERNAL (internal) = NULL; /* disposes of the internal pad, since the ghostpad is the only possible object * that has a refcount on the internal pad. */ gst_object_unparent (GST_OBJECT_CAST (internal)); } GST_OBJECT_UNLOCK (pad); G_OBJECT_CLASS (gst_ghost_pad_parent_class)->dispose (object); }
static void gst_raw_parse_init (GstRawParse * rp, GstRawParseClass * g_class) { GstPadTemplate *src_pad_template; GstElementClass *element_class = GST_ELEMENT_CLASS (g_class); rp->sinkpad = gst_pad_new_from_static_template (&gst_raw_parse_sink_pad_template, "sink"); gst_pad_set_chain_function (rp->sinkpad, GST_DEBUG_FUNCPTR (gst_raw_parse_chain)); gst_pad_set_event_function (rp->sinkpad, GST_DEBUG_FUNCPTR (gst_raw_parse_sink_event)); gst_pad_set_activate_function (rp->sinkpad, GST_DEBUG_FUNCPTR (gst_raw_parse_sink_activate)); gst_pad_set_activatemode_function (rp->sinkpad, GST_DEBUG_FUNCPTR (gst_raw_parse_sink_activatemode)); gst_element_add_pad (GST_ELEMENT (rp), rp->sinkpad); src_pad_template = gst_element_class_get_pad_template (element_class, "src"); if (src_pad_template) { rp->srcpad = gst_pad_new_from_template (src_pad_template, "src"); } else { g_warning ("Subclass didn't specify a src pad template"); g_assert_not_reached (); } gst_pad_set_event_function (rp->srcpad, GST_DEBUG_FUNCPTR (gst_raw_parse_src_event)); gst_pad_set_query_function (rp->srcpad, GST_DEBUG_FUNCPTR (gst_raw_parse_src_query)); gst_element_add_pad (GST_ELEMENT (rp), rp->srcpad); rp->adapter = gst_adapter_new (); rp->fps_n = 1; rp->fps_d = 0; rp->framesize = 1; gst_raw_parse_reset (rp); }
static void gst_asf_parse_init (GstAsfParse * asfparse) { asfparse->sinkpad = gst_pad_new_from_static_template (&sink_factory, "sink"); gst_pad_set_chain_function (asfparse->sinkpad, gst_asf_parse_chain); gst_pad_set_activate_function (asfparse->sinkpad, gst_asf_parse_sink_activate); gst_pad_set_activatemode_function (asfparse->sinkpad, gst_asf_parse_sink_activate_mode); gst_element_add_pad (GST_ELEMENT (asfparse), asfparse->sinkpad); asfparse->srcpad = gst_pad_new_from_static_template (&src_factory, "src"); gst_pad_use_fixed_caps (asfparse->srcpad); gst_element_add_pad (GST_ELEMENT (asfparse), asfparse->srcpad); asfparse->adapter = gst_adapter_new (); asfparse->outcaps = gst_caps_new_empty_simple ("video/x-ms-asf"); asfparse->asfinfo = gst_asf_file_info_new (); asfparse->packetinfo = g_new0 (GstAsfPacketInfo, 1); gst_asf_parse_reset (asfparse); }
static void gst_tee_init (GstTee * tee) { tee->sinkpad = gst_pad_new_from_static_template (&sinktemplate, "sink"); tee->sink_mode = GST_PAD_MODE_NONE; gst_pad_set_event_function (tee->sinkpad, GST_DEBUG_FUNCPTR (gst_tee_sink_event)); gst_pad_set_query_function (tee->sinkpad, GST_DEBUG_FUNCPTR (gst_tee_sink_query)); gst_pad_set_activatemode_function (tee->sinkpad, GST_DEBUG_FUNCPTR (gst_tee_sink_activate_mode)); gst_pad_set_chain_function (tee->sinkpad, GST_DEBUG_FUNCPTR (gst_tee_chain)); gst_pad_set_chain_list_function (tee->sinkpad, GST_DEBUG_FUNCPTR (gst_tee_chain_list)); GST_OBJECT_FLAG_SET (tee->sinkpad, GST_PAD_FLAG_PROXY_CAPS); gst_element_add_pad (GST_ELEMENT (tee), tee->sinkpad); tee->pad_indexes = g_hash_table_new (NULL, NULL); tee->last_message = NULL; }
static void gst_er_dtls_enc_init(GstErDtlsEnc *self) { self->connection_id = NULL; self->connection = NULL; self->is_client = DEFAULT_IS_CLIENT; self->encoder_key = NULL; self->srtp_cipher = DEFAULT_SRTP_CIPHER; self->srtp_auth = DEFAULT_SRTP_AUTH; self->queue = g_ptr_array_sized_new(INITIAL_QUEUE_SIZE); g_mutex_init(&self->queue_lock); g_cond_init(&self->queue_cond_add); self->src = gst_pad_new_from_static_template(&src_template, "src"); g_return_if_fail(self->src); gst_pad_set_activatemode_function(self->src, GST_DEBUG_FUNCPTR((GstPadActivateModeFunction) src_activate_mode)); gst_element_add_pad(GST_ELEMENT(self), self->src); }
/* initialize the new element * instantiate pads and add them to element * set functions * initialize structure */ static void gst_midi_parse_init (GstMidiParse * filter) { filter->sinkpad = gst_pad_new_from_static_template (&sink_factory, "sink"); gst_pad_set_activatemode_function (filter->sinkpad, gst_midi_parse_activatemode); gst_pad_set_activate_function (filter->sinkpad, gst_midi_parse_activate); gst_pad_set_event_function (filter->sinkpad, gst_midi_parse_sink_event); gst_pad_set_chain_function (filter->sinkpad, gst_midi_parse_chain); gst_element_add_pad (GST_ELEMENT (filter), filter->sinkpad); filter->srcpad = gst_pad_new_from_static_template (&src_factory, "src"); gst_pad_set_query_function (filter->srcpad, gst_midi_parse_src_query); gst_pad_set_event_function (filter->srcpad, gst_midi_parse_src_event); gst_pad_use_fixed_caps (filter->srcpad); gst_element_add_pad (GST_ELEMENT (filter), filter->srcpad); gst_segment_init (&filter->segment, GST_FORMAT_TIME); filter->adapter = gst_adapter_new (); }
static void gst_aggregator_init (GstAggregator * self, GstAggregatorClass * klass) { GstPadTemplate *pad_template; GstAggregatorPrivate *priv; g_return_if_fail (klass->aggregate != NULL); self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GST_TYPE_AGGREGATOR, GstAggregatorPrivate); priv = self->priv; pad_template = gst_element_class_get_pad_template (GST_ELEMENT_CLASS (klass), "src"); g_return_if_fail (pad_template != NULL); priv->padcount = -1; priv->tags_changed = FALSE; _reset_flow_values (self); priv->mcontext = g_main_context_new (); self->srcpad = gst_pad_new_from_template (pad_template, "src"); gst_pad_set_event_function (self->srcpad, GST_DEBUG_FUNCPTR ((GstPadEventFunction) src_event_func)); gst_pad_set_query_function (self->srcpad, GST_DEBUG_FUNCPTR ((GstPadQueryFunction) src_query_func)); gst_pad_set_activatemode_function (self->srcpad, GST_DEBUG_FUNCPTR ((GstPadActivateModeFunction) src_activate_mode)); gst_element_add_pad (GST_ELEMENT (self), self->srcpad); g_mutex_init (&self->priv->mcontext_lock); }
static gboolean activate_session (GstRDTManager * rdtmanager, GstRDTManagerSession * session, guint32 ssrc, guint8 pt) { GstPadTemplate *templ; GstElementClass *klass; gchar *name; GstCaps *caps; GValue ret = { 0 }; GValue args[3] = { {0} , {0} , {0} }; GST_DEBUG_OBJECT (rdtmanager, "creating stream"); session->ssrc = ssrc; session->pt = pt; /* get pt map */ g_value_init (&args[0], GST_TYPE_ELEMENT); g_value_set_object (&args[0], rdtmanager); g_value_init (&args[1], G_TYPE_UINT); g_value_set_uint (&args[1], session->id); g_value_init (&args[2], G_TYPE_UINT); g_value_set_uint (&args[2], pt); g_value_init (&ret, GST_TYPE_CAPS); g_value_set_boxed (&ret, NULL); g_signal_emitv (args, gst_rdt_manager_signals[SIGNAL_REQUEST_PT_MAP], 0, &ret); g_value_unset (&args[0]); g_value_unset (&args[1]); g_value_unset (&args[2]); caps = (GstCaps *) g_value_dup_boxed (&ret); g_value_unset (&ret); if (caps) gst_rdt_manager_parse_caps (rdtmanager, session, caps); name = g_strdup_printf ("recv_rtp_src_%u_%u_%u", session->id, ssrc, pt); klass = GST_ELEMENT_GET_CLASS (rdtmanager); templ = gst_element_class_get_pad_template (klass, "recv_rtp_src_%u_%u_%u"); session->recv_rtp_src = gst_pad_new_from_template (templ, name); g_free (name); gst_pad_set_element_private (session->recv_rtp_src, session); gst_pad_set_query_function (session->recv_rtp_src, gst_rdt_manager_query_src); gst_pad_set_activatemode_function (session->recv_rtp_src, gst_rdt_manager_src_activate_mode); gst_pad_set_active (session->recv_rtp_src, TRUE); gst_pad_set_caps (session->recv_rtp_src, caps); gst_caps_unref (caps); gst_element_add_pad (GST_ELEMENT_CAST (rdtmanager), session->recv_rtp_src); return TRUE; }
static GstPad * gst_tee_request_new_pad (GstElement * element, GstPadTemplate * templ, const gchar * name_templ, const GstCaps * caps) { gchar *name; GstPad *srcpad; GstTee *tee; GstPadMode mode; gboolean res; guint index = 0; tee = GST_TEE (element); GST_DEBUG_OBJECT (tee, "requesting pad"); GST_OBJECT_LOCK (tee); if (name_templ) { sscanf (name_templ, "src_%u", &index); GST_LOG_OBJECT (element, "name: %s (index %d)", name_templ, index); if (g_hash_table_contains (tee->pad_indexes, GUINT_TO_POINTER (index))) { GST_ERROR_OBJECT (element, "pad name %s is not unique", name_templ); GST_OBJECT_UNLOCK (tee); return NULL; } if (index >= tee->next_pad_index) tee->next_pad_index = index + 1; } else { index = tee->next_pad_index; while (g_hash_table_contains (tee->pad_indexes, GUINT_TO_POINTER (index))) index++; tee->next_pad_index = index + 1; } g_hash_table_insert (tee->pad_indexes, GUINT_TO_POINTER (index), NULL); name = g_strdup_printf ("src_%u", index); srcpad = GST_PAD_CAST (g_object_new (GST_TYPE_TEE_PAD, "name", name, "direction", templ->direction, "template", templ, NULL)); GST_TEE_PAD_CAST (srcpad)->index = index; g_free (name); mode = tee->sink_mode; GST_OBJECT_UNLOCK (tee); switch (mode) { case GST_PAD_MODE_PULL: /* we already have a src pad in pull mode, and our pull mode can only be SINGLE, so fall through to activate this new pad in push mode */ case GST_PAD_MODE_PUSH: res = gst_pad_activate_mode (srcpad, GST_PAD_MODE_PUSH, TRUE); break; default: res = TRUE; break; } if (!res) goto activate_failed; gst_pad_set_activatemode_function (srcpad, GST_DEBUG_FUNCPTR (gst_tee_src_activate_mode)); gst_pad_set_query_function (srcpad, GST_DEBUG_FUNCPTR (gst_tee_src_query)); gst_pad_set_getrange_function (srcpad, GST_DEBUG_FUNCPTR (gst_tee_src_get_range)); /* Forward sticky events to the new srcpad */ gst_pad_sticky_events_foreach (tee->sinkpad, forward_sticky_events, srcpad); GST_OBJECT_FLAG_SET (srcpad, GST_PAD_FLAG_PROXY_CAPS); gst_element_add_pad (GST_ELEMENT_CAST (tee), srcpad); return srcpad; /* ERRORS */ activate_failed: { gboolean changed = FALSE; GST_OBJECT_LOCK (tee); GST_DEBUG_OBJECT (tee, "warning failed to activate request pad"); if (tee->allocpad == srcpad) { tee->allocpad = NULL; changed = TRUE; } GST_OBJECT_UNLOCK (tee); gst_object_unref (srcpad); if (changed) { gst_tee_notify_alloc_pad (tee); } return NULL; } }
/** * 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; } }