static gboolean gst_droidcamsrc_mode_negotiate_pad (GstDroidCamSrcMode * mode, GstPad * pad, gboolean force) { GstDroidCamSrcPad *data = gst_pad_get_element_private (pad); /* take pad lock */ g_mutex_lock (&data->lock); if (!force) { if (!gst_pad_check_reconfigure (data->pad)) { g_mutex_unlock (&data->lock); return TRUE; } } /* * stream start * we must send it before we send our CAPS event */ if (G_UNLIKELY (data->open_stream)) { gchar *stream_id; GstEvent *event; stream_id = gst_pad_create_stream_id (data->pad, GST_ELEMENT_CAST (mode->src), GST_PAD_NAME (data->pad)); GST_DEBUG_OBJECT (pad, "Pushing STREAM_START for pad"); event = gst_event_new_stream_start (stream_id); gst_event_set_group_id (event, gst_util_group_id_next ()); if (!gst_pad_push_event (data->pad, event)) { GST_ERROR_OBJECT (mode->src, "failed to push STREAM_START event for pad %s", GST_PAD_NAME (data->pad)); } g_free (stream_id); data->open_stream = FALSE; } /* negotiate */ if (!data->negotiate (data)) { GST_ELEMENT_ERROR (mode->src, STREAM, FORMAT, (NULL), ("failed to negotiate %s.", GST_PAD_NAME (data->pad))); g_mutex_unlock (&data->lock); return FALSE; } /* toss pad queue */ g_queue_foreach (data->queue, (GFunc) gst_buffer_unref, NULL); g_queue_clear (data->queue); /* unlock */ g_mutex_unlock (&data->lock); return TRUE; }
static GstGhostPad * gst_switch_request_new_sink_pad (GstSwitch * swit, GstPadTemplate * templ, const gchar * name, const GstCaps * caps) { GstElement *swcase = gst_switch_select (swit, templ, name, caps); GstGhostPad *pad = NULL; GstPad *basepad = NULL; if (!swcase) goto error_no_case; basepad = gst_switch_get_case_sink_pad (swcase, caps); if (!basepad) goto error_no_basepad; if (gst_pad_is_linked (basepad)) goto error_basepad_already_linked; if (name) { pad = GST_GHOST_PAD (gst_ghost_pad_new (name, basepad)); } else { name = g_strdup_printf ("sink_%u", GST_ELEMENT (swit)->numsinkpads); pad = GST_GHOST_PAD (gst_ghost_pad_new (name, basepad)); g_free ((gchar *) name); } gst_object_unref (basepad); return pad; error_no_case: { GST_ERROR_OBJECT (swit, "Failed to request new case for %s.%s", GST_ELEMENT_NAME (swit), GST_PAD_TEMPLATE_NAME_TEMPLATE (templ)); return NULL; } error_no_basepad: { GST_ERROR_OBJECT (swit, "Failed to request new pad on %s", GST_ELEMENT_NAME (swcase)); return NULL; } error_basepad_already_linked: { GstPad *pp = GST_PAD_PEER (basepad); GstElement *ppp = GST_PAD_PARENT (pp); GST_ERROR_OBJECT (swit, "Pad %s.%s already linked with %s.%s", GST_ELEMENT_NAME (swcase), GST_PAD_NAME (basepad), GST_ELEMENT_NAME (ppp), GST_PAD_NAME (pp)); gst_object_unref (basepad); return NULL; } }
static gboolean sink_setcaps (GstPad *pad, GstCaps *caps) { GstStructure *structure; GstOmxBaseFilter21 *self; GOmxCore *gomx; GstVideoFormat format; int sink_number; self = GST_OMX_BASE_FILTER21 (GST_PAD_PARENT (pad)); if(strcmp(GST_PAD_NAME(pad), "sink_00") == 0){ sink_number=0; } else if(strcmp(GST_PAD_NAME(pad), "sink_01") == 0){ sink_number=1; } gomx = (GOmxCore *) self->gomx; GST_INFO_OBJECT (self, "setcaps (sink): %d", sink_number); GST_INFO_OBJECT (self, "setcaps (sink): %" GST_PTR_FORMAT, caps); g_return_val_if_fail (caps, FALSE); g_return_val_if_fail (gst_caps_is_fixed (caps), FALSE); structure = gst_caps_get_structure (caps, 0); g_return_val_if_fail (structure, FALSE); if (!gst_video_format_parse_caps_strided (caps, &format, &self->in_width[sink_number], &self->in_height[sink_number], &self->in_stride[sink_number])) { GST_WARNING_OBJECT (self, "width and/or height is not set in caps"); return FALSE; } if (!self->in_stride[sink_number]) { self->in_stride[sink_number] = gstomx_calculate_stride (self->in_width[sink_number], format); } { /* Output framerate correspond to the minimum input framerate */ const GValue *sink_framerate = NULL; sink_framerate = gst_structure_get_value (structure, "framerate"); if( GST_VALUE_HOLDS_FRACTION(sink_framerate) ) { if( self->out_framerate == NULL || gst_value_compare(sink_framerate, self->out_framerate) == GST_VALUE_LESS_THAN ) { self->out_framerate = sink_framerate; self->duration = gst_util_uint64_scale_int(GST_SECOND, gst_value_get_fraction_denominator(sink_framerate), gst_value_get_fraction_numerator(sink_framerate)); } } } return gst_pad_set_caps (pad, caps); }
/* Should return 0 for elements to be included */ static gint src_pad_compare_func (gconstpointer a, gconstpointer b) { GstPad *pad = GST_PAD (g_value_get_object (a)); const gchar *prefix = g_value_get_string (b); gint res = 1; GST_OBJECT_LOCK (pad); res = !GST_PAD_NAME (pad) || g_str_has_prefix (GST_PAD_NAME (pad), prefix); GST_OBJECT_UNLOCK (pad); return res; }
static void pad_added_handler (GstElement *src, GstPad *new_pad, gpointer data) { #if (TRANS_TYPE == TRANS_TYPE_TCP) GstPad *sink_pad = gst_element_get_static_pad (gst_data.convert, "sink"); #else GstPad *sink_pad = gst_element_get_static_pad (gst_data.tee, "sink"); #endif GstPadLinkReturn ret; GstCaps *new_pad_caps = NULL; GstStructure *new_pad_struct = NULL; const gchar *new_pad_type = NULL; guint caps_size = 0, i; g_print ("Received new pad '%s' from '%s':\n", GST_PAD_NAME (new_pad), GST_ELEMENT_NAME (src)); g_print ("sink_pad: '%s'\n", GST_PAD_NAME (sink_pad)); if (gst_pad_is_linked (sink_pad)) { g_print ("We are already linked. Ignoring.\n"); goto exit; } new_pad_caps = gst_pad_get_current_caps(new_pad); caps_size = gst_caps_get_size(new_pad_caps); g_print ("caps_size : %d\n", caps_size); for (i = 0; i < caps_size; i++) { new_pad_struct = gst_caps_get_structure(new_pad_caps, i); new_pad_type = gst_structure_get_name(new_pad_struct); g_print ("new_pad_type %d: '%s'\n", i, new_pad_type); if (strstr(new_pad_type, "audio/x-raw")) { ret = gst_pad_link (new_pad, sink_pad); if (GST_PAD_LINK_FAILED (ret)) { g_print ("Type is '%s' but link failed.\n", new_pad_type); } else { g_print ("Link succeeded (type '%s').\n", new_pad_type); } break; } } exit: /* Unreference the new pad's caps, if we got them */ if (new_pad_caps != NULL) gst_caps_unref (new_pad_caps); /* Unreference the sink pad */ gst_object_unref (sink_pad); }
/* Should return 0 for elements to be included */ static gint src_pad_compare_func (gconstpointer a, gconstpointer b) { GstPad *pad = GST_PAD (g_value_get_object (a)); const gchar *prefix = g_value_get_string (b); gint res; /* 0 means equal means we accept the pad, accepted if there is a name * and it starts with the prefix */ GST_OBJECT_LOCK (pad); res = !GST_PAD_NAME (pad) || !g_str_has_prefix (GST_PAD_NAME (pad), prefix); GST_OBJECT_UNLOCK (pad); return res; }
static GstPad * gst_switch_request_new_pad (GstElement * element, GstPadTemplate * templ, const gchar * name, const GstCaps * caps) { GstSwitch *swit = GST_SWITCH (element); GstGhostPad *pad; INFO ("requesting: %s.%s (%d=%d+%d)", GST_ELEMENT_NAME (swit), name ? name : GST_PAD_TEMPLATE_NAME_TEMPLATE (templ), element->numpads, element->numsrcpads, element->numsinkpads); GST_SWITCH_LOCK (swit); switch (GST_PAD_TEMPLATE_DIRECTION (templ)) { case GST_PAD_SRC: pad = gst_switch_request_new_src_pad (swit, templ, name, caps); break; case GST_PAD_SINK: pad = gst_switch_request_new_sink_pad (swit, templ, name, caps); break; default: pad = NULL; break; } if (pad) { gst_pad_set_active (GST_PAD (pad), TRUE); if (gst_element_add_pad (GST_ELEMENT (swit), GST_PAD (pad))) { GstPad *basepad = gst_ghost_pad_get_target (pad); GstElement *swcase = GST_ELEMENT (GST_PAD_PARENT (basepad)); GST_OBJECT_FLAG_SET (basepad, GST_SWITCH_PAD_FLAG_GHOSTED); GST_DEBUG_OBJECT (swit, "New %s:%s on %s:%s", GST_ELEMENT_NAME (swit), GST_PAD_NAME (pad), GST_ELEMENT_NAME (swcase), GST_PAD_NAME (basepad)); INFO ("requested %s.%s on %s.%s", GST_ELEMENT_NAME (swit), GST_PAD_NAME (pad), GST_ELEMENT_NAME (swcase), GST_PAD_NAME (basepad)); } } GST_SWITCH_UNLOCK (swit); return GST_PAD (pad); }
static void _rtpbin_pad_added (GstElement *rtpbin, GstPad *new_pad, gpointer user_data) { FsRtpConference *self = FS_RTP_CONFERENCE (user_data); gchar *name; GST_DEBUG_OBJECT (self, "pad %s added %" GST_PTR_FORMAT, GST_PAD_NAME (new_pad), GST_PAD_CAPS (new_pad)); name = gst_pad_get_name (new_pad); if (g_str_has_prefix (name, "recv_rtp_src_")) { guint session_id, ssrc, pt; if (sscanf (name, "recv_rtp_src_%u_%u_%u", &session_id, &ssrc, &pt) == 3 && ssrc <= G_MAXUINT32) { FsRtpSession *session = fs_rtp_conference_get_session_by_id (self, session_id); if (session) { fs_rtp_session_new_recv_pad (session, new_pad, ssrc, pt); g_object_unref (session); } } } g_free (name); }
void GstPlayer::handleAddedPad(GstElement * upstream, GstPad * upstreamNewPad, GstElement * downstream) { GstPad *downstreamPad = gst_element_get_static_pad ( downstream, "sink"); GstPadLinkReturn result; GstCaps * newPadCaps = NULL; GstStructure * newPadStruct = NULL; const gchar * newPadType = NULL; QLOG_TRACE() << "Got pad " << GST_PAD_NAME (upstreamNewPad) << " from " << GST_ELEMENT_NAME (upstream); if (gst_pad_is_linked (downstreamPad)) { QLOG_TRACE() << " Pad already connected to downstream."; }else{ newPadCaps = gst_pad_get_caps (upstreamNewPad); newPadStruct = gst_caps_get_structure (newPadCaps, 0); newPadType = gst_structure_get_name (newPadStruct); if (!g_str_has_prefix (newPadType, "audio/x-raw")) { QLOG_TRACE() << "Pad is not of type is not raw audio but of type "<< newPadType <<". Can't connect."; }else{ result = gst_pad_link (upstreamNewPad, downstreamPad); if (GST_PAD_LINK_FAILED (result)) { QLOG_TRACE() << "Failed to link."; } else { QLOG_TRACE() << "Link successful."; } } } if (newPadCaps != NULL) gst_caps_unref (newPadCaps); gst_object_unref (downstreamPad); }
static void on_demuxElementAdded (GstBin * demux, GstElement * element, gpointer user_data) { GstAdaptiveDemuxTestEnginePrivate *priv = (GstAdaptiveDemuxTestEnginePrivate *) user_data; GstAdaptiveDemuxTestOutputStream *stream = NULL; GstPad *internal_pad; gchar *srcbin_name; gint i; srcbin_name = GST_ELEMENT_NAME (element); GST_TEST_LOCK (priv); for (i = 0; i < priv->engine.output_streams->len; i++) { stream = g_ptr_array_index (priv->engine.output_streams, i); if (strstr (srcbin_name, GST_PAD_NAME (stream->pad)) != NULL) break; } fail_unless (stream != NULL); /* keep the reference to the internal_pad. * We will need it to identify the stream in the on_demuxReceivesEvent callback */ if (stream->internal_pad) { gst_pad_remove_probe (stream->internal_pad, stream->internal_pad_probe); gst_object_unref (stream->internal_pad); } internal_pad = gst_element_get_static_pad (element, "src"); stream->internal_pad_probe = gst_pad_add_probe (internal_pad, GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM, (GstPadProbeCallback) on_demuxReceivesEvent, priv, NULL); stream->internal_pad = internal_pad; GST_TEST_UNLOCK (priv); }
void pad_added_cb (GstElement *src, GstPad *new_pad, MbMedia *media) { GstCaps *new_pad_caps = NULL; GstStructure *new_pad_struct = NULL; GstPad *peer = NULL; const gchar *new_pad_type = NULL; gboolean success = FALSE; g_assert (media); g_debug ("Received new pad '%s' from '%s'\n", GST_PAD_NAME(new_pad), media->name); new_pad_caps = gst_pad_query_caps (new_pad, NULL); new_pad_struct = gst_caps_get_structure (new_pad_caps, 0); new_pad_type = gst_structure_get_name (new_pad_struct); g_debug ("New pad type: %s\n", new_pad_type); g_mutex_lock(&(media->mutex)); media->valid_pads++; if (g_str_has_prefix(new_pad_type, "video")) { success = set_video_bin (media->bin, media, new_pad); if (success) peer = gst_element_get_static_pad(_mb_global_data.video_mixer, media->video_pad_name); } else if (g_str_has_prefix(new_pad_type, "audio")) { success = set_audio_bin (media->bin, media, new_pad); if (success) peer = gst_element_get_static_pad(_mb_global_data.audio_mixer, media->audio_pad_name); } if (success) { gst_pad_set_offset (new_pad, media->start_offset); if (peer != NULL) { gst_pad_add_probe (peer, GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM, eos_event_cb, media, NULL); gst_object_unref(peer); } } g_mutex_unlock(&(media->mutex)); if (new_pad_caps != NULL) gst_caps_unref (new_pad_caps); }
static gboolean _create_input_chain (GstGLMixerBin * self, struct input_chain *chain, GstPad * mixer_pad) { GstGLMixerBinClass *klass = GST_GL_MIXER_BIN_GET_CLASS (self); GstPad *pad; gboolean res = TRUE; gchar *name; chain->self = self; chain->mixer_pad = mixer_pad; chain->upload = gst_element_factory_make ("glupload", NULL); chain->in_convert = gst_element_factory_make ("glcolorconvert", NULL); res &= gst_bin_add (GST_BIN (self), chain->in_convert); res &= gst_bin_add (GST_BIN (self), chain->upload); pad = gst_element_get_static_pad (chain->in_convert, "src"); if (gst_pad_link (pad, mixer_pad) != GST_PAD_LINK_OK) { gst_object_unref (pad); return FALSE; } gst_object_unref (pad); res &= gst_element_link_pads (chain->upload, "src", chain->in_convert, "sink"); pad = gst_element_get_static_pad (chain->upload, "sink"); if (!pad) { return FALSE; } else { GST_DEBUG_OBJECT (self, "setting target sink pad %" GST_PTR_FORMAT, pad); name = gst_object_get_name (GST_OBJECT (mixer_pad)); if (klass->create_input_pad) { chain->ghost_pad = klass->create_input_pad (self, chain->mixer_pad); gst_object_set_name (GST_OBJECT (chain->ghost_pad), name); gst_ghost_pad_set_target (chain->ghost_pad, pad); } else { chain->ghost_pad = GST_GHOST_PAD (gst_ghost_pad_new (GST_PAD_NAME (chain->mixer_pad), pad)); } g_free (name); GST_OBJECT_LOCK (self); if (self->priv->running) gst_pad_set_active (GST_PAD (chain->ghost_pad), TRUE); GST_OBJECT_UNLOCK (self); gst_element_add_pad (GST_ELEMENT_CAST (self), GST_PAD (chain->ghost_pad)); gst_object_unref (pad); } gst_element_sync_state_with_parent (chain->upload); gst_element_sync_state_with_parent (chain->in_convert); return TRUE; }
void GstShow::newPad(GstElement *src, GstPad *new_pad, gpointer data) { GstPad *sink_pad; GstElement *color = (GstElement *) data; GstPadLinkReturn ret; GstCaps *new_pad_caps = NULL; GstStructure *new_pad_struct = NULL; const gchar *new_pad_type = NULL; g_print ("Received new pad '%s' from '%s':\n", GST_PAD_NAME (new_pad), GST_ELEMENT_NAME (src)); new_pad_caps = gst_pad_get_current_caps (new_pad); new_pad_struct = gst_caps_get_structure (new_pad_caps, 0); new_pad_type = gst_structure_get_name (new_pad_struct); g_print (" It has type '%s'.\n", new_pad_type); sink_pad = gst_element_get_static_pad (color, "sink"); if (!sink_pad){ L_(lerror) << "Gstreamer: no pad named sink"; return; } /* If our converter is already linked, we have nothing to do here */ if (gst_pad_is_linked (sink_pad)) { g_print (" We are already linked. Ignoring.\n"); /* Unreference the new pad's caps, if we got them */ if (new_pad_caps != NULL) gst_caps_unref (new_pad_caps); /* Unreference the sink pad */ gst_object_unref (sink_pad); return; } /* Attempt the link */ ret = gst_pad_link (new_pad, sink_pad); if (GST_PAD_LINK_FAILED (ret)) { g_print (" Type is '%s' but link failed.\n", new_pad_type); /* Unreference the new pad's caps, if we got them */ if (new_pad_caps != NULL) gst_caps_unref (new_pad_caps); /* Unreference the sink pad */ gst_object_unref (sink_pad); return; } else { g_print (" Link succeeded (type '%s').\n", new_pad_type); } }
static void vc_pad_added_handler (GstElement *src, GstPad *new_pad, vc_data *data) { GstPad *sink_pad = gst_element_get_static_pad (data->gst_data.depayloader, "sink"); GstPadLinkReturn ret; GstCaps *new_pad_caps = NULL; GstStructure *new_pad_struct = NULL; const gchar *new_pad_type = NULL; g_print ("Received new pad '%s' from '%s':\n", GST_PAD_NAME (new_pad), GST_ELEMENT_NAME (src)); /* Check the new pad's name */ if (!g_str_has_prefix (GST_PAD_NAME (new_pad), "recv_rtp_src_")) { g_print (" It is not the right pad. Need recv_rtp_src_. Ignoring.\n"); goto exit; } /* If our converter is already linked, we have nothing to do here */ if (gst_pad_is_linked (sink_pad)) { g_print (" Sink pad from %s already linked. Ignoring.\n", GST_ELEMENT_NAME (src)); goto exit; } /* Check the new pad's type */ new_pad_caps = gst_pad_get_caps (new_pad); new_pad_struct = gst_caps_get_structure (new_pad_caps, 0); new_pad_type = gst_structure_get_name (new_pad_struct); /* Attempt the link */ ret = gst_pad_link (new_pad, sink_pad); if (GST_PAD_LINK_FAILED (ret)) { g_print (" Type is '%s' but link failed.\n", new_pad_type); } else { g_print (" Link succeeded (type '%s').\n", new_pad_type); } exit: /* Unreference the new pad's caps, if we got them */ if (new_pad_caps != NULL) gst_caps_unref (new_pad_caps); /* Unreference the sink pad */ gst_object_unref (sink_pad); }
static gboolean gst_v4l2_transform_query (GstBaseTransform * trans, GstPadDirection direction, GstQuery * query) { GstV4l2Transform *self = GST_V4L2_TRANSFORM (trans); gboolean ret = TRUE; switch (GST_QUERY_TYPE (query)) { case GST_QUERY_CAPS:{ GstCaps *filter, *caps = NULL, *result = NULL; GstPad *pad, *otherpad; gst_query_parse_caps (query, &filter); if (direction == GST_PAD_SRC) { pad = GST_BASE_TRANSFORM_SRC_PAD (trans); otherpad = GST_BASE_TRANSFORM_SINK_PAD (trans); if (self->probed_srccaps) caps = gst_caps_ref (self->probed_srccaps); } else { pad = GST_BASE_TRANSFORM_SINK_PAD (trans); otherpad = GST_BASE_TRANSFORM_SRC_PAD (trans); if (self->probed_sinkcaps) caps = gst_caps_ref (self->probed_sinkcaps); } if (!caps) caps = gst_pad_get_pad_template_caps (pad); if (filter) { GstCaps *tmp = caps; caps = gst_caps_intersect_full (filter, tmp, GST_CAPS_INTERSECT_FIRST); gst_caps_unref (tmp); } result = gst_pad_peer_query_caps (otherpad, caps); result = gst_caps_make_writable (result); gst_caps_append (result, caps); GST_DEBUG_OBJECT (self, "Returning %s caps %" GST_PTR_FORMAT, GST_PAD_NAME (pad), result); gst_query_set_caps_result (query, result); gst_caps_unref (result); break; } default: ret = GST_BASE_TRANSFORM_CLASS (parent_class)->query (trans, direction, query); break; } return ret; }
/* we can only accept caps that we and downstream can handle. * if we have filtercaps set, use those to constrain the target caps. */ static GstCaps * gst_adder_sink_getcaps (GstPad * pad) { GstAdder *adder; GstCaps *result, *peercaps, *sinkcaps, *filter_caps; adder = GST_ADDER (GST_PAD_PARENT (pad)); GST_OBJECT_LOCK (adder); /* take filter */ if ((filter_caps = adder->filter_caps)) gst_caps_ref (filter_caps); GST_OBJECT_UNLOCK (adder); /* get the downstream possible caps */ peercaps = gst_pad_peer_get_caps (adder->srcpad); /* get the allowed caps on this sinkpad, we use the fixed caps function so * that it does not call recursively in this function. */ sinkcaps = gst_pad_get_fixed_caps_func (pad); if (peercaps) { /* restrict with filter-caps if any */ if (filter_caps) { GST_DEBUG_OBJECT (adder, "filtering peer caps"); result = gst_caps_intersect (peercaps, filter_caps); gst_caps_unref (peercaps); peercaps = result; } /* if the peer has caps, intersect */ GST_DEBUG_OBJECT (adder, "intersecting peer and template caps"); result = gst_caps_intersect (peercaps, sinkcaps); gst_caps_unref (peercaps); gst_caps_unref (sinkcaps); } else { /* the peer has no caps (or there is no peer), just use the allowed caps * of this sinkpad. */ /* restrict with filter-caps if any */ if (filter_caps) { GST_DEBUG_OBJECT (adder, "no peer caps, using filtered sinkcaps"); result = gst_caps_intersect (sinkcaps, filter_caps); gst_caps_unref (sinkcaps); } else { GST_DEBUG_OBJECT (adder, "no peer caps, using sinkcaps"); result = sinkcaps; } } if (filter_caps) gst_caps_unref (filter_caps); GST_LOG_OBJECT (adder, "getting caps on pad %p,%s to %" GST_PTR_FORMAT, pad, GST_PAD_NAME (pad), result); return result; }
/* This function will be called by the pad-added signal */ static void pad_added_handler(GstElement *src, GstPad *new_pad, CustomData *data) { GstPad *sink_pad = NULL; GstPadLinkReturn ret; GstCaps *new_pad_caps = NULL; GstStructure *new_pad_struct = NULL; const gchar *new_pad_type = NULL; g_print("Received new pad '%s' from '%s':\n", GST_PAD_NAME(new_pad), GST_ELEMENT_NAME(src)); /* Check the new pad's type */ new_pad_caps = gst_pad_get_caps(new_pad); new_pad_struct = gst_caps_get_structure(new_pad_caps, 0); new_pad_type = gst_structure_get_name(new_pad_struct); if (g_str_has_prefix(new_pad_type, "video/x-raw")) { sink_pad = gst_element_get_static_pad(data->vsink, "sink"); if (gst_pad_is_linked(sink_pad)) { g_print(" We are already linked. Ignoring.\n"); goto exit; } } if (g_str_has_prefix(new_pad_type, "audio/x-raw")) { sink_pad = gst_element_get_static_pad(data->convert, "sink"); if (gst_pad_is_linked(sink_pad)) { g_print(" We are already linked. Ignoring.\n"); goto exit; } } /* Attempt the link */ ret = gst_pad_link(new_pad, sink_pad); if (GST_PAD_LINK_FAILED(ret)) { g_print(" Type is '%s' but link failed.\n", new_pad_type); } else { g_print(" Link succeeded (type '%s').\n", new_pad_type); } exit: /* Unreference the new pad's caps, if we got them */ if (new_pad_caps != NULL) gst_caps_unref(new_pad_caps); /* Unreference the sink pad */ if (sink_pad != NULL) gst_object_unref(sink_pad); }
static GstFlowReturn gst_tcp_mix_src_get_range (GstTCPMixSrc * src, GstPad * pad, guint64 offset, guint length, GstBuffer ** buf) { g_print ("%s:%d:info: getrange: %s, %ld, %d\n", __FILE__, __LINE__, GST_PAD_NAME (pad), offset, length); return GST_FLOW_OK; }
/****************************************************************************** * gst_tiaudenc1_sink_event * Perform event processing on the input stream. At the moment, this * function isn't needed as this element doesn't currently perform any * specialized event processing. We'll leave it in for now in case we need * it later on. ******************************************************************************/ static gboolean gst_tiaudenc1_sink_event(GstPad *pad, GstEvent *event) { GstTIAudenc1 *audenc1; gboolean ret; audenc1 = GST_TIAUDENC1(GST_OBJECT_PARENT(pad)); GST_DEBUG("pad \"%s\" received: %s\n", GST_PAD_NAME(pad), GST_EVENT_TYPE_NAME(event)); switch (GST_EVENT_TYPE(event)) { case GST_EVENT_NEWSEGMENT: /* Propagate NEWSEGMENT to downstream elements */ ret = gst_pad_push_event(audenc1->srcpad, event); break; case GST_EVENT_EOS: /* end-of-stream: process any remaining encoded frame data */ GST_LOG("no more input; draining remaining encoded audio data\n"); if (!audenc1->drainingEOS) { gst_tiaudenc1_drain_pipeline(audenc1); } /* Propagate EOS to downstream elements */ ret = gst_pad_push_event(audenc1->srcpad, event); break; case GST_EVENT_FLUSH_STOP: ret = gst_pad_push_event(audenc1->srcpad, event); break; /* Unhandled events */ case GST_EVENT_BUFFERSIZE: case GST_EVENT_CUSTOM_BOTH: case GST_EVENT_CUSTOM_BOTH_OOB: case GST_EVENT_CUSTOM_DOWNSTREAM: case GST_EVENT_CUSTOM_DOWNSTREAM_OOB: case GST_EVENT_CUSTOM_UPSTREAM: case GST_EVENT_FLUSH_START: case GST_EVENT_NAVIGATION: case GST_EVENT_QOS: case GST_EVENT_SEEK: case GST_EVENT_TAG: default: ret = gst_pad_event_default(pad, event); break; } return ret; }
static gboolean gst_teletextdec_src_set_caps (GstPad * pad, GstCaps * caps) { GstTeletextDec *teletext; GstStructure *structure = NULL; const gchar *mimetype; GstPad *peer; teletext = GST_TELETEXTDEC (gst_pad_get_parent (pad)); GST_DEBUG_OBJECT (teletext, "Linking teletext source pad"); if (gst_caps_is_empty (caps)) { GST_ERROR_OBJECT (teletext, "pad %s refused renegotiation to %" GST_PTR_FORMAT, GST_PAD_NAME (pad), caps); goto refuse_caps; } peer = gst_pad_get_peer (pad); if (peer) { gst_pad_set_caps (peer, caps); gst_object_unref (peer); } structure = gst_caps_get_structure (caps, 0); mimetype = gst_structure_get_name (structure); if (g_strcmp0 (mimetype, "video/x-raw-rgb") == 0) { teletext->output_format = GST_TELETEXTDEC_OUTPUT_FORMAT_RGBA; GST_DEBUG_OBJECT (teletext, "Selected RGBA output format"); } else if (g_strcmp0 (mimetype, "text/html") == 0) { teletext->output_format = GST_TELETEXTDEC_OUTPUT_FORMAT_HTML; GST_DEBUG_OBJECT (teletext, "Selected HTML output format"); } else if (g_strcmp0 (mimetype, "text/plain") == 0) { teletext->output_format = GST_TELETEXTDEC_OUTPUT_FORMAT_TEXT; GST_DEBUG_OBJECT (teletext, "Selected text output format"); } else if (g_strcmp0 (mimetype, "text/x-pango-markup") == 0) { teletext->output_format = GST_TELETEXTDEC_OUTPUT_FORMAT_PANGO; GST_DEBUG_OBJECT (teletext, "Selected pango markup output format"); } else goto refuse_caps; gst_object_unref (teletext); return TRUE; refuse_caps: { gst_object_unref (teletext); return FALSE; } }
GstPad * GetExistingPadByName(GstElement * inElement, const std::string & inPadName) { GstPad * result(0); GstIterator * it = gst_element_iterate_pads(inElement); if (!it) { throw std::runtime_error("Failed to create an iterator for the given element."); } bool done = false; while (!done) { gpointer pad = 0; switch (gst_iterator_next(it, &pad)) { case GST_ITERATOR_OK: { if (inPadName == GST_PAD_NAME(pad)) { result = GST_PAD(pad); done = true; } break; } case GST_ITERATOR_RESYNC: { gst_iterator_resync(it); break; } case GST_ITERATOR_ERROR: { done = true; break; } case GST_ITERATOR_DONE: { done = true; break; } }; } gst_iterator_free(it); if (!result) { std::string msg = MakeString() << "Element does not contain a pad with name " << inPadName << ". "; throw std::runtime_error(msg); } return result; }
static void connect_sink_on_srcpad_added (GstElement * element, GstPad * pad, gpointer user_data) { GstElement *sink; GstPad *sinkpad; if (g_str_has_prefix (GST_PAD_NAME (pad), KMS_AUDIO_PREFIX)) { GST_DEBUG_OBJECT (pad, "Connecting video stream"); sink = g_object_get_data (G_OBJECT (element), AUDIO_SINK); } else if (g_str_has_prefix (GST_PAD_NAME (pad), KMS_VIDEO_PREFIX)) { GST_DEBUG_OBJECT (pad, "Connecting audio stream"); sink = g_object_get_data (G_OBJECT (element), VIDEO_SINK); } else { GST_TRACE_OBJECT (pad, "Not src pad type"); return; } sinkpad = gst_element_get_static_pad (sink, "sink"); gst_pad_link (pad, sinkpad); g_object_unref (sinkpad); gst_element_sync_state_with_parent (sink); }
static void pad_added_cb (GstElement * rtpbin, GstPad * new_pad, gpointer data) { GstPad *sinkpad; GstPadLinkReturn lres; g_print ("new payload on pad: %s\n", GST_PAD_NAME (new_pad)); sinkpad = gst_element_get_static_pad (videodepay, "sink"); g_assert (sinkpad); lres = gst_pad_link (new_pad, sinkpad); g_assert (lres == GST_PAD_LINK_OK); gst_object_unref (sinkpad); }
/* This function will be called by the pad-added signal */ void pad_added_handler(GstElement *src, GstPad *new_pad, CustomData *data) { GstPad *sink_pad = gst_element_get_static_pad(data->buffer, "sink"); GstPadLinkReturn ret; GstCaps *new_pad_caps = NULL; GstStructure *new_pad_struct = NULL; const gchar *new_pad_type = NULL; GPlayerDEBUG("Received new pad '%s' from '%s':\n", GST_PAD_NAME(new_pad), GST_ELEMENT_NAME(src)); /* If our converter is already linked, we have nothing to do here */ if (gst_pad_is_linked(sink_pad)) { GPlayerDEBUG(" We are already linked. Ignoring.\n"); goto exit; } /* Check the new pad's type */ new_pad_caps = gst_pad_query_caps(new_pad, NULL); new_pad_struct = gst_caps_get_structure(new_pad_caps, 0); new_pad_type = gst_structure_get_name(new_pad_struct); if (!g_str_has_prefix(new_pad_type, "audio/x-raw")) { GPlayerDEBUG(" It has type '%s' which is not raw audio. Ignoring.\n", new_pad_type); goto exit; } /* Attempt the link */ ret = gst_pad_link(new_pad, sink_pad); if (GST_PAD_LINK_FAILED(ret)) { GPlayerDEBUG(" Type is '%s' but link failed.\n", new_pad_type); gplayer_error(-1, data); data->target_state = GST_STATE_NULL; data->is_live = (gst_element_set_state(data->pipeline, data->target_state) == GST_STATE_CHANGE_NO_PREROLL); } else { GPlayerDEBUG(" Link succeeded (type '%s').\n", new_pad_type); } exit: /* Unreference the new pad's caps, if we got them */ if (new_pad_caps != NULL) gst_caps_unref(new_pad_caps); /* Unreference the sink pad */ kill_object(sink_pad); }
static GstPad * _request_new_pad (GstElement * element, GstPadTemplate * templ, const gchar * req_name, const GstCaps * caps) { GstAggregator *self; GstAggregatorPad *agg_pad; GstElementClass *klass = GST_ELEMENT_GET_CLASS (element); GstAggregatorPrivate *priv = GST_AGGREGATOR (element)->priv; self = GST_AGGREGATOR (element); if (templ == gst_element_class_get_pad_template (klass, "sink_%u")) { gint serial = 0; gchar *name = NULL; GST_OBJECT_LOCK (element); if (req_name == NULL || strlen (req_name) < 6 || !g_str_has_prefix (req_name, "sink_")) { /* no name given when requesting the pad, use next available int */ priv->padcount++; } else { /* parse serial number from requested padname */ serial = g_ascii_strtoull (&req_name[5], NULL, 10); if (serial >= priv->padcount) priv->padcount = serial; } name = g_strdup_printf ("sink_%u", priv->padcount); agg_pad = g_object_new (GST_AGGREGATOR_GET_CLASS (self)->sinkpads_type, "name", name, "direction", GST_PAD_SINK, "template", templ, NULL); g_free (name); GST_OBJECT_UNLOCK (element); } else { return NULL; } GST_DEBUG_OBJECT (element, "Adding pad %s", GST_PAD_NAME (agg_pad)); if (priv->running) gst_pad_set_active (GST_PAD (agg_pad), TRUE); /* add the pad to the element */ gst_element_add_pad (element, GST_PAD (agg_pad)); return GST_PAD (agg_pad); }
static GstSplitMuxPartPad * gst_splitmux_part_reader_new_proxy_pad (GstSplitMuxPartReader * reader, GstPad * target) { GstSplitMuxPartPad *pad = g_object_new (SPLITMUX_TYPE_PART_PAD, "name", GST_PAD_NAME (target), "direction", GST_PAD_SINK, NULL); pad->target = target; pad->reader = reader; gst_pad_set_active (GST_PAD_CAST (pad), TRUE); return pad; }
static gboolean gst_teletextdec_sink_setcaps (GstPad * pad, GstCaps * caps) { GstTeletextDec *teletext = GST_TELETEXTDEC (gst_pad_get_parent (pad)); GstStructure *structure = gst_caps_get_structure (caps, 0); const gchar *mimetype = gst_structure_get_name (structure); GST_DEBUG_OBJECT (teletext, "%s:%s, caps=%" GST_PTR_FORMAT, GST_DEBUG_PAD_NAME (pad), caps); if (g_strcmp0 (mimetype, "private/teletext") == 0) { teletext->process_buf_func = gst_teletextdec_process_telx_buffer; goto accept_caps; } else if (g_strcmp0 (mimetype, "video/mpeg") == 0) { gint version; gboolean is_systemstream; if (!gst_structure_get_int (structure, "mpegversion", &version) || !gst_structure_get_boolean (structure, "systemstream", &is_systemstream)) goto refuse_caps; if (version != 2 || !is_systemstream) goto refuse_caps; teletext->process_buf_func = gst_teletextdec_process_pes_buffer; teletext->demux = vbi_dvb_pes_demux_new (gst_teletextdec_convert, teletext); goto accept_caps; } else goto refuse_caps; accept_caps: { gst_object_unref (teletext); return gst_teletextdec_push_preroll_buffer (teletext); } refuse_caps: { GST_ERROR_OBJECT (teletext, "pad %s refused renegotiation to %" GST_PTR_FORMAT, GST_PAD_NAME (pad), caps); gst_object_unref (teletext); return FALSE; } }
static gboolean gst_rrparser_sink_event(GstPad *pad, GstEvent *event) { GstRRParser * rrparser =(GstRRParser *) gst_pad_get_parent(pad); gboolean ret = FALSE; GST_DEBUG("pad \"%s\" received: %s\n", GST_PAD_NAME(pad), GST_EVENT_TYPE_NAME(event)); switch (GST_EVENT_TYPE(event)) { case GST_EVENT_EOS: ret = gst_pad_push_event(rrparser->src_pad, event); break; default: ret = gst_pad_push_event(rrparser->src_pad, event); } return ret; }
static void pad_added_handler (GstElement *src, GstPad *new_pad, CustomData *data) { GstPad *sink_pad = gst_element_get_static_pad (data->audioconvert, "sink"); GstPadLinkReturn ret; GstCaps *new_pad_caps = NULL; GstStructure *new_pad_struct = NULL; const gchar *new_pad_type = NULL; g_print ("Received new pad '%s' from '%s':\n", GST_PAD_NAME (new_pad), GST_ELEMENT_NAME (src)); /* If our converter is already linked, we have nothing to do here */ if (gst_pad_is_linked (sink_pad)) { g_print (" We are already linked. Ignoring.\n"); goto exit; } /* Check the new pad's type */ #if GST_VERSION_MAJOR == (0) new_pad_caps = gst_pad_get_caps (new_pad); #else new_pad_caps = gst_pad_query_caps (new_pad, NULL); #endif new_pad_struct = gst_caps_get_structure (new_pad_caps, 0); new_pad_type = gst_structure_get_name (new_pad_struct); if (!g_str_has_prefix (new_pad_type, "audio/x-raw")) { g_print (" It has type '%s' which is not raw audio. Ignoring.\n", new_pad_type); goto exit; } /* Attempt the link */ ret = gst_pad_link (new_pad, sink_pad); if (GST_PAD_LINK_FAILED (ret)) { g_print (" Type is '%s' but link failed.\n", new_pad_type); } else { g_print (" Link succeeded (type '%s').\n", new_pad_type); } exit: /* Unreference the new pad's caps, if we got them */ if (new_pad_caps != NULL) gst_caps_unref (new_pad_caps); /* Unreference the sink pad */ gst_object_unref (sink_pad); }
/** * gst_proxy_pad_save_thyself: * @pad: a ghost #GstPad to save. * @parent: the parent #xmlNodePtr to save the description in. * * Saves the ghost pad into an xml representation. * * Returns: the #xmlNodePtr representation of the pad. */ static xmlNodePtr gst_proxy_pad_save_thyself (GstObject * object, xmlNodePtr parent) { xmlNodePtr self; GstProxyPad *proxypad; GstPad *pad; GstPad *peer; g_return_val_if_fail (GST_IS_PROXY_PAD (object), NULL); self = xmlNewChild (parent, NULL, (xmlChar *) "ghostpad", NULL); xmlNewChild (self, NULL, (xmlChar *) "name", (xmlChar *) GST_OBJECT_NAME (object)); xmlNewChild (self, NULL, (xmlChar *) "parent", (xmlChar *) GST_OBJECT_NAME (GST_OBJECT_PARENT (object))); proxypad = GST_PROXY_PAD_CAST (object); pad = GST_PAD_CAST (proxypad); peer = GST_PAD_CAST (pad->peer); if (GST_IS_PAD (pad)) { if (GST_PAD_IS_SRC (pad)) xmlNewChild (self, NULL, (xmlChar *) "direction", (xmlChar *) "source"); else if (GST_PAD_IS_SINK (pad)) xmlNewChild (self, NULL, (xmlChar *) "direction", (xmlChar *) "sink"); else xmlNewChild (self, NULL, (xmlChar *) "direction", (xmlChar *) "unknown"); } else { xmlNewChild (self, NULL, (xmlChar *) "direction", (xmlChar *) "unknown"); } if (GST_IS_PAD (peer)) { gchar *content = g_strdup_printf ("%s.%s", GST_OBJECT_NAME (GST_PAD_PARENT (peer)), GST_PAD_NAME (peer)); xmlNewChild (self, NULL, (xmlChar *) "peer", (xmlChar *) content); g_free (content); } else { xmlNewChild (self, NULL, (xmlChar *) "peer", NULL); } return self; }