static void gst_artsdsink_init (GstArtsdsink * artsdsink) { artsdsink->sinkpad = gst_pad_new_from_template (gst_element_get_pad_template (GST_ELEMENT (artsdsink), "sink"), "sink"); gst_element_add_pad (GST_ELEMENT (artsdsink), artsdsink->sinkpad); gst_pad_set_chain_function (artsdsink->sinkpad, gst_artsdsink_chain); gst_pad_set_link_function (artsdsink->sinkpad, gst_artsdsink_link); artsdsink->connected = FALSE; artsdsink->mute = FALSE; artsdsink->connect_name = NULL; }
static void instance_init(GTypeInstance *instance, void *g_class) { struct obj *self = (struct obj *)instance; GstElementClass *element_class = g_class; self->sinkpad = gst_pad_new_from_template(gst_element_class_get_pad_template(element_class, "sink"), "sink"); gst_pad_set_chain_function(self->sinkpad, pad_chain); gst_pad_set_event_function(self->sinkpad, sink_event); self->srcpad = gst_pad_new_from_template(gst_element_class_get_pad_template(element_class, "src"), "src"); gst_pad_use_fixed_caps(self->srcpad); gst_element_add_pad((GstElement *)self, self->sinkpad); gst_element_add_pad((GstElement *)self, self->srcpad); gst_pad_set_setcaps_function(self->sinkpad, sink_setcaps); g_mutex_init(&self->mutex); }
static void gst_xine_audio_sink_sub_init (GTypeInstance * instance, gpointer g_class) { GstElementClass *klass = GST_ELEMENT_GET_CLASS (instance); GstXineAudioSink *xine = GST_XINE_AUDIO_SINK (instance); xine->sinkpad = gst_pad_new_from_template (gst_element_class_get_pad_template (klass, "sink"), "sink"); gst_pad_set_chain_function (xine->sinkpad, gst_xine_audio_sink_chain); gst_pad_set_getcaps_function (xine->sinkpad, _xine_audio_sink_get_caps); gst_pad_set_link_function (xine->sinkpad, _xine_audio_sink_link); gst_element_add_pad (GST_ELEMENT (xine), xine->sinkpad); }
/* Create a pad for receiving RTCP for the session in @name */ static GstPad * create_recv_rtcp (GstRTPDec * rtpdec, GstPadTemplate * templ, const gchar * name) { guint sessid; GstRTPDecSession *session; /* first get the session number */ if (name == NULL || sscanf (name, "recv_rtcp_sink_%u", &sessid) != 1) goto no_name; GST_DEBUG_OBJECT (rtpdec, "finding session %d", sessid); /* get the session, it must exist or we error */ session = find_session_by_id (rtpdec, sessid); if (!session) goto no_session; /* check if pad was requested */ if (session->recv_rtcp_sink != NULL) goto existed; GST_DEBUG_OBJECT (rtpdec, "getting RTCP sink pad"); session->recv_rtcp_sink = gst_pad_new_from_template (templ, name); gst_pad_set_element_private (session->recv_rtp_sink, session); gst_pad_set_chain_function (session->recv_rtcp_sink, gst_rtp_dec_chain_rtcp); gst_pad_set_active (session->recv_rtcp_sink, TRUE); gst_element_add_pad (GST_ELEMENT_CAST (rtpdec), session->recv_rtcp_sink); return session->recv_rtcp_sink; /* ERRORS */ no_name: { g_warning ("rtpdec: invalid name given"); return NULL; } no_session: { g_warning ("rtpdec: no session with id %d", sessid); return NULL; } existed: { g_warning ("rtpdec: recv_rtcp pad already requested for session %d", sessid); return NULL; } }
static GstPad * gst_mxf_mux_request_new_pad (GstElement * element, GstPadTemplate * templ, const gchar * pad_name) { GstMXFMux *mux = GST_MXF_MUX (element); GstMXFMuxPad *cpad; GstPad *pad = NULL; guint pad_number; gchar *name = NULL; const MXFEssenceElementWriter *writer; if (mux->state != GST_MXF_MUX_STATE_HEADER) { GST_WARNING_OBJECT (mux, "Can't request pads after writing header"); return NULL; } writer = mxf_essence_element_writer_find (templ); if (!writer) { GST_ERROR_OBJECT (mux, "Not our template"); return NULL; } pad_number = g_atomic_int_exchange_and_add ((gint *) & mux->n_pads, 1); name = gst_mxf_mux_create_pad_name (templ, pad_number); GST_DEBUG_OBJECT (mux, "Creating pad '%s'", name); pad = gst_pad_new_from_template (templ, name); g_free (name); cpad = (GstMXFMuxPad *) gst_collect_pads_add_pad (mux->collect, pad, sizeof (GstMXFMuxPad)); cpad->last_timestamp = 0; cpad->adapter = gst_adapter_new (); cpad->writer = writer; /* FIXME: hacked way to override/extend the event function of * GstCollectPads; because it sets its own event function giving the * element no access to events. */ mux->collect_event = (GstPadEventFunction) GST_PAD_EVENTFUNC (pad); gst_pad_set_event_function (pad, GST_DEBUG_FUNCPTR (gst_mxf_mux_handle_sink_event)); gst_pad_set_setcaps_function (pad, gst_mxf_mux_setcaps); gst_pad_use_fixed_caps (pad); gst_pad_set_active (pad, TRUE); gst_element_add_pad (element, pad); return pad; }
static void gst_vorbis_enc_init (GstVorbisEnc * vorbisenc, GstVorbisEncClass * klass) { vorbisenc->sinkpad = gst_pad_new_from_template (gst_vorbis_enc_sink_template, "sink"); gst_pad_set_event_function (vorbisenc->sinkpad, GST_DEBUG_FUNCPTR (gst_vorbis_enc_sink_event)); gst_pad_set_chain_function (vorbisenc->sinkpad, GST_DEBUG_FUNCPTR (gst_vorbis_enc_chain)); gst_pad_set_setcaps_function (vorbisenc->sinkpad, GST_DEBUG_FUNCPTR (gst_vorbis_enc_sink_setcaps)); gst_pad_set_getcaps_function (vorbisenc->sinkpad, GST_DEBUG_FUNCPTR (gst_vorbis_enc_sink_getcaps)); gst_pad_set_query_function (vorbisenc->sinkpad, GST_DEBUG_FUNCPTR (gst_vorbis_enc_sink_query)); gst_element_add_pad (GST_ELEMENT (vorbisenc), vorbisenc->sinkpad); vorbisenc->srcpad = gst_pad_new_from_template (gst_vorbis_enc_src_template, "src"); gst_pad_set_query_function (vorbisenc->srcpad, GST_DEBUG_FUNCPTR (gst_vorbis_enc_src_query)); gst_pad_set_query_type_function (vorbisenc->srcpad, GST_DEBUG_FUNCPTR (gst_vorbis_enc_get_query_types)); gst_element_add_pad (GST_ELEMENT (vorbisenc), vorbisenc->srcpad); vorbisenc->channels = -1; vorbisenc->frequency = -1; vorbisenc->managed = FALSE; vorbisenc->max_bitrate = MAX_BITRATE_DEFAULT; vorbisenc->bitrate = BITRATE_DEFAULT; vorbisenc->min_bitrate = MIN_BITRATE_DEFAULT; vorbisenc->quality = QUALITY_DEFAULT; vorbisenc->quality_set = FALSE; vorbisenc->last_message = NULL; }
static void gst_rtp_pt_demux_init (GstRtpPtDemux * ptdemux, GstRtpPtDemuxClass * g_class) { GstElementClass *klass = GST_ELEMENT_GET_CLASS (ptdemux); ptdemux->sink = gst_pad_new_from_template (gst_element_class_get_pad_template (klass, "sink"), "sink"); g_assert (ptdemux->sink != NULL); gst_pad_set_chain_function (ptdemux->sink, gst_rtp_pt_demux_chain); gst_pad_set_event_function (ptdemux->sink, gst_rtp_pt_demux_sink_event); gst_element_add_pad (GST_ELEMENT (ptdemux), ptdemux->sink); }
static void gst_vtenc_init (GstVTEnc * self) { GstVTEncClass *klass = (GstVTEncClass *) G_OBJECT_GET_CLASS (self); GstElementClass *element_klass = GST_ELEMENT_CLASS (klass); GstElement *element = GST_ELEMENT (self); self->details = GST_VTENC_CLASS_GET_CODEC_DETAILS (klass); self->sinkpad = gst_pad_new_from_template (gst_element_class_get_pad_template (element_klass, "sink"), "sink"); gst_element_add_pad (element, self->sinkpad); gst_pad_set_setcaps_function (self->sinkpad, gst_vtenc_sink_setcaps); gst_pad_set_chain_function (self->sinkpad, gst_vtenc_chain); self->srcpad = gst_pad_new_from_template (gst_element_class_get_pad_template (element_klass, "src"), "src"); gst_pad_set_event_function (self->srcpad, gst_vtenc_src_event); gst_element_add_pad (element, self->srcpad); /* These could be controlled by properties later */ self->dump_properties = FALSE; self->dump_attributes = FALSE; }
/** * hls_progress_buffer_init() * * Initializer. Automatically declared in the GST_BOILERPLATE macro above. Should be * only called by GStreamer. */ static void hls_progress_buffer_init(HLSProgressBuffer *element, HLSProgressBufferClass *element_klass) { GstElementClass *klass = GST_ELEMENT_CLASS (element_klass); int i = 0; element->sinkpad = gst_pad_new_from_template (gst_element_class_get_pad_template (klass, "sink"), "sink"); gst_pad_set_chain_function(element->sinkpad, hls_progress_buffer_chain); gst_pad_set_event_function(element->sinkpad, hls_progress_buffer_sink_event); gst_element_add_pad (GST_ELEMENT (element), element->sinkpad); element->srcpad = gst_pad_new_from_template (gst_element_class_get_pad_template (GST_ELEMENT_GET_CLASS(element), "src"), "src"); gst_pad_set_activatepush_function(element->srcpad, hls_progress_buffer_activatepush_src); gst_pad_set_event_function(element->srcpad, hls_progress_buffer_src_event); gst_element_add_pad (GST_ELEMENT (element), element->srcpad); element->lock = g_mutex_new(); element->add_cond = g_cond_new(); element->del_cond = g_cond_new(); for (i = 0; i < NUM_OF_CACHED_SEGMENTS; i++) { element->cache[i] = create_cache(); element->cache_size[i] = 0; element->cache_write_ready[i] = TRUE; } element->cache_write_index = -1; element->cache_read_index = 0; element->send_new_segment = TRUE; element->is_flushing = FALSE; element->is_eos = FALSE; element->srcresult = GST_FLOW_OK; }
static GstPad * gst_multipart_mux_request_new_pad (GstElement * element, GstPadTemplate * templ, const gchar * req_name) { GstMultipartMux *multipart_mux; GstPad *newpad; GstElementClass *klass = GST_ELEMENT_GET_CLASS (element); gchar *name; if (templ != gst_element_class_get_pad_template (klass, "sink_%d")) goto wrong_template; multipart_mux = GST_MULTIPART_MUX (element); /* create new pad with the name */ name = g_strdup_printf ("sink_%02d", multipart_mux->numpads); newpad = gst_pad_new_from_template (templ, name); g_free (name); /* construct our own wrapper data structure for the pad to * keep track of its status */ { GstMultipartPadData *multipartpad; multipartpad = (GstMultipartPadData *) gst_collect_pads_add_pad (multipart_mux->collect, newpad, sizeof (GstMultipartPadData)); /* save a pointer to our data in the pad */ gst_pad_set_element_private (newpad, multipartpad); multipart_mux->numpads++; } /* add the pad to the element */ gst_element_add_pad (element, newpad); return newpad; /* ERRORS */ wrong_template: { g_warning ("multipart_mux: this is not our template!"); return NULL; } }
static void gst_icydemux_init (GstICYDemux * icydemux) { GstElementClass *klass = GST_ELEMENT_GET_CLASS (icydemux); icydemux->sinkpad = gst_pad_new_from_template (gst_element_class_get_pad_template (klass, "sink"), "sink"); gst_pad_set_chain_function (icydemux->sinkpad, GST_DEBUG_FUNCPTR (gst_icydemux_chain)); gst_pad_set_event_function (icydemux->sinkpad, GST_DEBUG_FUNCPTR (gst_icydemux_handle_event)); gst_pad_set_setcaps_function (icydemux->sinkpad, GST_DEBUG_FUNCPTR (gst_icydemux_sink_setcaps)); gst_element_add_pad (GST_ELEMENT (icydemux), icydemux->sinkpad); gst_icydemux_reset (icydemux); }
/** * 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)); }
/* Create a pad for sending RTCP for the session in @name */ static GstPad * create_rtcp (GstRDTManager * rdtmanager, GstPadTemplate * templ, const gchar * name) { guint sessid; GstRDTManagerSession *session; /* first get the session number */ if (name == NULL || sscanf (name, "rtcp_src_%u", &sessid) != 1) goto no_name; /* get or create session */ session = find_session_by_id (rdtmanager, sessid); if (!session) goto no_session; /* check if pad was requested */ if (session->rtcp_src != NULL) goto existed; session->rtcp_src = gst_pad_new_from_template (templ, name); gst_pad_set_active (session->rtcp_src, TRUE); gst_element_add_pad (GST_ELEMENT_CAST (rdtmanager), session->rtcp_src); return session->rtcp_src; /* ERRORS */ no_name: { g_warning ("rdtmanager: invalid name given"); return NULL; } no_session: { g_warning ("rdtmanager: session with id %d does not exist", sessid); return NULL; } existed: { g_warning ("rdtmanager: rtcp_src pad already requested for session %d", sessid); return NULL; } }
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_activatepull_function (rp->sinkpad, GST_DEBUG_FUNCPTR (gst_raw_parse_sink_activatepull)); 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_type_function (rp->srcpad, GST_DEBUG_FUNCPTR (gst_raw_parse_src_query_type)); 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_multipart_mux_init (GstMultipartMux * multipart_mux) { GstElementClass *klass = GST_ELEMENT_GET_CLASS (multipart_mux); multipart_mux->srcpad = gst_pad_new_from_template (gst_element_class_get_pad_template (klass, "src"), "src"); gst_pad_set_event_function (multipart_mux->srcpad, gst_multipart_mux_handle_src_event); gst_element_add_pad (GST_ELEMENT (multipart_mux), multipart_mux->srcpad); multipart_mux->boundary = g_strdup (DEFAULT_BOUNDARY); multipart_mux->collect = gst_collect_pads_new (); gst_collect_pads_set_function (multipart_mux->collect, (GstCollectPadsFunction) GST_DEBUG_FUNCPTR (gst_multipart_mux_collected), multipart_mux); }
static void gst_rtp_mux_init (GstRTPMux * rtp_mux) { GstElementClass *klass = GST_ELEMENT_GET_CLASS (rtp_mux); rtp_mux->srcpad = gst_pad_new_from_template (gst_element_class_get_pad_template (klass, "src"), "src"); gst_pad_set_event_function (rtp_mux->srcpad, GST_DEBUG_FUNCPTR (gst_rtp_mux_src_event)); gst_pad_use_fixed_caps (rtp_mux->srcpad); gst_element_add_pad (GST_ELEMENT (rtp_mux), rtp_mux->srcpad); rtp_mux->ssrc = DEFAULT_SSRC; rtp_mux->ts_offset = DEFAULT_TIMESTAMP_OFFSET; rtp_mux->seqnum_offset = DEFAULT_SEQNUM_OFFSET; rtp_mux->last_stop = GST_CLOCK_TIME_NONE; }
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 mpegpsmux_init (MpegPsMux * mux, MpegPsMuxClass * g_class) { mux->srcpad = gst_pad_new_from_template (gst_static_pad_template_get (&mpegpsmux_src_factory), "src"); gst_pad_use_fixed_caps (mux->srcpad); gst_element_add_pad (GST_ELEMENT (mux), mux->srcpad); mux->collect = gst_collect_pads_new (); gst_collect_pads_set_function (mux->collect, (GstCollectPadsFunction) GST_DEBUG_FUNCPTR (mpegpsmux_collected), mux); mux->psmux = psmux_new (); psmux_set_write_func (mux->psmux, new_packet_cb, mux); mux->first = TRUE; mux->last_flow_ret = GST_FLOW_OK; mux->last_ts = 0; /* XXX: or -1? */ }
static GstPad * gst_mpeg_demux_new_output_pad (GstMPEGDemux * mpeg_demux, const gchar * name, GstPadTemplate * temp) { GstPad *pad; pad = gst_pad_new_from_template (temp, name); #if 0 gst_pad_set_event_function (pad, GST_DEBUG_FUNCPTR (gst_mpeg_demux_handle_src_event)); #endif gst_pad_set_query_type_function (pad, GST_DEBUG_FUNCPTR (gst_mpeg_parse_get_src_query_types)); gst_pad_set_query_function (pad, GST_DEBUG_FUNCPTR (gst_mpeg_parse_handle_src_query)); gst_pad_use_fixed_caps (pad); return pad; }
static void gst_vdp_vpp_init (GstVdpVideoPostProcess * vpp, GstVdpVideoPostProcessClass * gclass) { GstPadTemplate *src_template, *sink_template; vpp->device = NULL; vpp->mixer = VDP_INVALID_HANDLE; vpp->display = NULL; vpp->force_aspect_ratio = FALSE; vpp->mode = GST_VDP_DEINTERLACE_MODE_AUTO; vpp->method = GST_VDP_DEINTERLACE_METHOD_BOB; vpp->noise_reduction = 0.0; vpp->sharpening = 0.0; /* SRC PAD */ src_template = gst_element_class_get_pad_template (GST_ELEMENT_CLASS (gclass), "src"); vpp->srcpad = GST_PAD (gst_vdp_output_src_pad_new (src_template, "src")); gst_element_add_pad (GST_ELEMENT (vpp), vpp->srcpad); gst_pad_set_event_function (vpp->srcpad, GST_DEBUG_FUNCPTR (gst_vdp_vpp_src_event)); /* SINK PAD */ sink_template = gst_element_class_get_pad_template (GST_ELEMENT_CLASS (gclass), "sink"); vpp->sinkpad = gst_pad_new_from_template (sink_template, "sink"); gst_element_add_pad (GST_ELEMENT (vpp), vpp->sinkpad); gst_pad_set_getcaps_function (vpp->sinkpad, gst_vdp_vpp_sink_getcaps); gst_pad_set_setcaps_function (vpp->sinkpad, gst_vdp_vpp_sink_setcaps); gst_pad_set_chain_function (vpp->sinkpad, GST_DEBUG_FUNCPTR (gst_vdp_vpp_chain)); gst_pad_set_event_function (vpp->sinkpad, GST_DEBUG_FUNCPTR (gst_vdp_vpp_sink_event)); }
static void qtwrapper_audio_decoder_init (QTWrapperAudioDecoder * qtwrapper) { QTWrapperAudioDecoderClass *oclass; oclass = (QTWrapperAudioDecoderClass *) (G_OBJECT_GET_CLASS (qtwrapper)); /* Sink pad */ qtwrapper->sinkpad = gst_pad_new_from_template (oclass->sinktempl, "sink"); gst_pad_set_setcaps_function (qtwrapper->sinkpad, GST_DEBUG_FUNCPTR (qtwrapper_audio_decoder_sink_setcaps)); gst_pad_set_chain_function (qtwrapper->sinkpad, GST_DEBUG_FUNCPTR (qtwrapper_audio_decoder_chain)); gst_pad_set_event_function (qtwrapper->sinkpad, GST_DEBUG_FUNCPTR (qtwrapper_audio_decoder_sink_event)); gst_element_add_pad (GST_ELEMENT (qtwrapper), qtwrapper->sinkpad); /* Source pad */ qtwrapper->srcpad = gst_pad_new_from_static_template (&src_templ, "src"); gst_element_add_pad (GST_ELEMENT (qtwrapper), qtwrapper->srcpad); }
/** * progress_buffer_init() * * Initializer. Automatically declared in the G_DEFINE_TYPE macro above. Should be * only called by GStreamer. */ static void progress_buffer_init(ProgressBuffer *element) { element->sinkpad = gst_pad_new_from_template (gst_element_class_get_pad_template (GST_ELEMENT_GET_CLASS(element), "sink"), "sink"); gst_pad_set_chain_function (element->sinkpad, GST_DEBUG_FUNCPTR(progress_buffer_chain)); gst_pad_set_event_function (element->sinkpad, GST_DEBUG_FUNCPTR(progress_buffer_sink_event)); gst_element_add_pad (GST_ELEMENT (element), element->sinkpad); element->srcpad = NULL; element->cache = NULL; element->cache_read_offset = 0; g_mutex_init(&element->lock); g_cond_init(&element->add_cond); element->bandwidth_timer = g_timer_new(); element->is_source_seeking = FALSE; #if ENABLE_PULL_MODE element->monitor_thread = NULL; #endif progress_buffer_flush_data(element); }
static GstPad * gst_mxf_mux_request_new_pad (GstElement * element, GstPadTemplate * templ, const gchar * pad_name, const GstCaps * caps) { GstMXFMux *mux = GST_MXF_MUX (element); GstMXFMuxPad *cpad; GstPad *pad = NULL; guint pad_number; gchar *name = NULL; const MXFEssenceElementWriter *writer; if (mux->state != GST_MXF_MUX_STATE_HEADER) { GST_WARNING_OBJECT (mux, "Can't request pads after writing header"); return NULL; } writer = mxf_essence_element_writer_find (templ); if (!writer) { GST_ERROR_OBJECT (mux, "Not our template"); return NULL; } pad_number = g_atomic_int_add ((gint *) & mux->n_pads, 1); name = gst_mxf_mux_create_pad_name (templ, pad_number); GST_DEBUG_OBJECT (mux, "Creating pad '%s'", name); pad = gst_pad_new_from_template (templ, name); g_free (name); cpad = (GstMXFMuxPad *) gst_collect_pads_add_pad (mux->collect, pad, sizeof (GstMXFMuxPad), NULL, TRUE); cpad->last_timestamp = 0; cpad->adapter = gst_adapter_new (); cpad->writer = writer; gst_pad_use_fixed_caps (pad); gst_pad_set_active (pad, TRUE); gst_element_add_pad (element, pad); return pad; }
static gboolean gst_icydemux_add_srcpad (GstICYDemux * icydemux, GstCaps * new_caps) { if (icydemux->src_caps == NULL || !gst_caps_is_equal (new_caps, icydemux->src_caps)) { gst_caps_replace (&(icydemux->src_caps), new_caps); if (icydemux->srcpad != NULL) { GST_DEBUG_OBJECT (icydemux, "Changing src pad caps to %" GST_PTR_FORMAT, icydemux->src_caps); gst_pad_set_caps (icydemux->srcpad, icydemux->src_caps); } } else { /* Caps never changed */ gst_caps_unref (new_caps); } if (icydemux->srcpad == NULL) { icydemux->srcpad = gst_pad_new_from_template (gst_element_class_get_pad_template (GST_ELEMENT_GET_CLASS (icydemux), "src"), "src"); g_return_val_if_fail (icydemux->srcpad != NULL, FALSE); gst_pad_use_fixed_caps (icydemux->srcpad); if (icydemux->src_caps) gst_pad_set_caps (icydemux->srcpad, icydemux->src_caps); GST_DEBUG_OBJECT (icydemux, "Adding src pad with caps %" GST_PTR_FORMAT, icydemux->src_caps); gst_pad_set_active (icydemux->srcpad, TRUE); if (!(gst_element_add_pad (GST_ELEMENT (icydemux), icydemux->srcpad))) return FALSE; gst_element_no_more_pads (GST_ELEMENT (icydemux)); } return TRUE; }
static void gst_wavpack_parse_init (GstWavpackParse * parse, GstWavpackParseClass * gclass) { GstElementClass *klass = GST_ELEMENT_GET_CLASS (parse); GstPadTemplate *tmpl; tmpl = gst_element_class_get_pad_template (klass, "sink"); parse->sinkpad = gst_pad_new_from_template (tmpl, "sink"); gst_pad_set_activate_function (parse->sinkpad, GST_DEBUG_FUNCPTR (gst_wavpack_parse_sink_activate)); gst_pad_set_activatepull_function (parse->sinkpad, GST_DEBUG_FUNCPTR (gst_wavpack_parse_sink_activate_pull)); gst_pad_set_event_function (parse->sinkpad, GST_DEBUG_FUNCPTR (gst_wavpack_parse_sink_event)); gst_pad_set_chain_function (parse->sinkpad, GST_DEBUG_FUNCPTR (gst_wavpack_parse_chain)); gst_element_add_pad (GST_ELEMENT (parse), parse->sinkpad); parse->srcpad = NULL; gst_wavpack_parse_reset (parse); }
static gboolean gst_streamid_demux_srcpad_create (GstStreamidDemux * demux, GstPad * pad, const gchar * stream_id) { gchar *padname = NULL; GstPad *srcpad = NULL; GstPadTemplate *pad_tmpl = NULL; padname = g_strdup_printf ("src_%u", demux->nb_srcpads++); pad_tmpl = gst_static_pad_template_get (&gst_streamid_demux_src_factory); GST_LOG_OBJECT (demux, "generating a srcpad:%s", padname); srcpad = gst_pad_new_from_template (pad_tmpl, padname); gst_object_unref (pad_tmpl); g_free (padname); g_return_val_if_fail (srcpad != NULL, FALSE); demux->active_srcpad = srcpad; g_hash_table_insert (demux->stream_id_pairs, g_strdup (stream_id), gst_object_ref (srcpad)); return TRUE; }
static GstPad * mpegpsmux_request_new_pad (GstElement * element, GstPadTemplate * templ, const gchar * name) { MpegPsMux *mux = GST_MPEG_PSMUX (element); GstPad *pad = NULL; MpegPsPadData *pad_data = NULL; pad = gst_pad_new_from_template (templ, name); pad_data = (MpegPsPadData *) gst_collect_pads_add_pad (mux->collect, pad, sizeof (MpegPsPadData)); if (pad_data == NULL) goto pad_failure; pad_data->last_ts = GST_CLOCK_TIME_NONE; pad_data->codec_data = NULL; pad_data->prepare_func = NULL; if (G_UNLIKELY (!gst_element_add_pad (element, pad))) goto could_not_add; return pad; could_not_add: GST_ELEMENT_ERROR (element, STREAM, FAILED, ("Internal data stream error."), ("Could not add pad to element")); gst_collect_pads_remove_pad (mux->collect, pad); gst_object_unref (pad); return NULL; pad_failure: GST_ELEMENT_ERROR (element, STREAM, FAILED, ("Internal data stream error."), ("Could not add pad to collectpads")); gst_object_unref (pad); return NULL; }
static GstPad * gst_output_selector_request_new_pad (GstElement * element, GstPadTemplate * templ, const gchar * name, const GstCaps * caps) { gchar *padname; GstPad *srcpad; GstOutputSelector *osel; osel = GST_OUTPUT_SELECTOR (element); GST_DEBUG_OBJECT (osel, "requesting pad"); GST_OBJECT_LOCK (osel); padname = g_strdup_printf ("src_%u", osel->nb_srcpads++); srcpad = gst_pad_new_from_template (templ, padname); GST_OBJECT_UNLOCK (osel); gst_pad_set_active (srcpad, TRUE); /* Forward sticky events to the new srcpad */ gst_pad_sticky_events_foreach (osel->sinkpad, forward_sticky_events, srcpad); gst_element_add_pad (GST_ELEMENT (osel), srcpad); /* Set the first requested src pad as active by default */ GST_OBJECT_LOCK (osel); if (osel->active_srcpad == NULL) { osel->active_srcpad = srcpad; GST_OBJECT_UNLOCK (osel); g_object_notify (G_OBJECT (osel), "active-pad"); } else { GST_OBJECT_UNLOCK (osel); } g_free (padname); return srcpad; }
static GstPad * gst_aggregator_request_new_pad (GstElement * element, GstPadTemplate * templ, const gchar * unused, const GstCaps * caps) { GstAggregator *aggregator = GST_AGGREGATOR (element); gchar *name; GstPad *newpad; gint padcount; if (templ->direction != GST_PAD_SINK) return NULL; /* create new pad */ padcount = g_atomic_int_add (&aggregator->padcount, 1); name = g_strdup_printf ("sink_%u", padcount); newpad = gst_pad_new_from_template (templ, name); g_free (name); gst_collect_pads_add_pad (aggregator->collect, newpad, sizeof (GstCollectData), NULL, TRUE); /* takes ownership of the pad */ if (!gst_element_add_pad (GST_ELEMENT (aggregator), newpad)) goto could_not_add; GST_DEBUG_OBJECT (aggregator, "added new pad %s", GST_OBJECT_NAME (newpad)); return newpad; /* errors */ could_not_add: { GST_DEBUG_OBJECT (aggregator, "could not add pad"); gst_collect_pads_remove_pad (aggregator->collect, newpad); gst_object_unref (newpad); return NULL; } }
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); }