static GstPad * gst_gl_mixer_bin_request_new_pad (GstElement * element, GstPadTemplate * templ, const gchar * req_name, const GstCaps * caps) { GstGLMixerBin *self = GST_GL_MIXER_BIN (element); GstPadTemplate *mixer_templ; struct input_chain *chain; GstPad *mixer_pad; chain = g_new0 (struct input_chain, 1); mixer_templ = _find_element_pad_template (self->mixer, GST_PAD_TEMPLATE_DIRECTION (templ), GST_PAD_TEMPLATE_PRESENCE (templ)); g_return_val_if_fail (mixer_templ, NULL); mixer_pad = gst_element_request_pad (self->mixer, mixer_templ, req_name, NULL); g_return_val_if_fail (mixer_pad, NULL); if (!_create_input_chain (self, chain, mixer_pad)) { gst_element_release_request_pad (self->mixer, mixer_pad); _free_input_chain (chain); return NULL; } GST_OBJECT_LOCK (element); self->priv->input_chains = g_list_prepend (self->priv->input_chains, chain); GST_OBJECT_UNLOCK (element); gst_child_proxy_child_added (GST_CHILD_PROXY (self), G_OBJECT (chain->ghost_pad), GST_OBJECT_NAME (chain->ghost_pad)); return GST_PAD (chain->ghost_pad); }
void GstUtils::release_request_pad(GstPad *pad, gpointer user_data) { // checking if the pad has been requested and releasing it needed GstPadTemplate *pad_templ = gst_pad_get_pad_template(pad); if (nullptr != pad_templ && GST_PAD_TEMPLATE_PRESENCE(pad_templ) == GST_PAD_REQUEST) { gst_element_release_request_pad((GstElement *)user_data, pad); gst_object_unref(pad); // release does not free } //gst_object_unref(pad_templ); // bug in gst 0.10 ? gst_object_unref(pad); // for iterator }
void shmdata_base_reader_release_request_pad (GstPad *pad, gpointer user_data) { //checking if the pad has been requested and releasing it needed GstPadTemplate *pad_templ = gst_pad_get_pad_template (pad); if (GST_PAD_TEMPLATE_PRESENCE (pad_templ) == GST_PAD_REQUEST) { gst_element_release_request_pad ((GstElement *)user_data, pad); gst_object_unref(pad); } // gst_object_unref(pad_templ); // bug in gst 0.10 ? gst_object_unref(pad); // for pad iterator }
static void debug_dump_pad (GstPad * pad, const gchar * color_name, const gchar * element_name, GstDebugGraphDetails details, FILE * out, const gint indent) { GstPadTemplate *pad_templ; GstPadPresence presence; gchar *pad_name; const gchar *style_name; const gchar *spc = &spaces[MAX (sizeof (spaces) - (1 + indent * 2), 0)]; pad_name = debug_dump_make_object_name (GST_OBJECT (pad)); /* pad availability */ style_name = "filled,solid"; if ((pad_templ = gst_pad_get_pad_template (pad))) { presence = GST_PAD_TEMPLATE_PRESENCE (pad_templ); if (presence == GST_PAD_SOMETIMES) { style_name = "filled,dotted"; } else if (presence == GST_PAD_REQUEST) { style_name = "filled,dashed"; } } if (details & GST_DEBUG_GRAPH_SHOW_STATES) { gchar pad_flags[4]; const gchar *activation_mode = "-><"; /* check if pad flags */ pad_flags[0] = GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_FLAG_BLOCKED) ? 'B' : 'b'; pad_flags[1] = GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_FLAG_FLUSHING) ? 'F' : 'f'; pad_flags[2] = GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_FLAG_BLOCKING) ? 'B' : 'b'; pad_flags[3] = '\0'; fprintf (out, "%s %s_%s [color=black, fillcolor=\"%s\", label=\"%s\\n[%c][%s]\", height=\"0.2\", style=\"%s\"];\n", spc, element_name, pad_name, color_name, GST_OBJECT_NAME (pad), activation_mode[pad->mode], pad_flags, style_name); } else { fprintf (out, "%s %s_%s [color=black, fillcolor=\"%s\", label=\"%s\", height=\"0.2\", style=\"%s\"];\n", spc, element_name, pad_name, color_name, GST_OBJECT_NAME (pad), style_name); } g_free (pad_name); }
static GstPadTemplate * _find_element_pad_template (GstElement * element, GstPadDirection direction, GstPadPresence presence) { GstElementClass *klass = GST_ELEMENT_GET_CLASS (element); GList *templ_list = gst_element_class_get_pad_template_list (klass); GstPadTemplate *templ; /* find suitable template */ while (templ_list) { templ = (GstPadTemplate *) templ_list->data; if (GST_PAD_TEMPLATE_DIRECTION (templ) != direction || GST_PAD_TEMPLATE_PRESENCE (templ) != presence) { templ_list = templ_list->next; templ = NULL; continue; } break; } return templ; }
static void debug_dump_pad (GstPad * pad, const gchar * color_name, const gchar * element_name, GstDebugGraphDetails details, GString * str, const gint indent) { GstPadTemplate *pad_templ; GstPadPresence presence; gchar *pad_name; const gchar *style_name; const gchar *spc = &spaces[MAX (sizeof (spaces) - (1 + indent * 2), 0)]; pad_name = debug_dump_make_object_name (GST_OBJECT (pad)); /* pad availability */ style_name = "filled,solid"; if ((pad_templ = gst_pad_get_pad_template (pad))) { presence = GST_PAD_TEMPLATE_PRESENCE (pad_templ); gst_object_unref (pad_templ); if (presence == GST_PAD_SOMETIMES) { style_name = "filled,dotted"; } else if (presence == GST_PAD_REQUEST) { style_name = "filled,dashed"; } } if (details & GST_DEBUG_GRAPH_SHOW_STATES) { gchar pad_flags[4]; const gchar *activation_mode = "-><"; const gchar *task_mode = ""; GstTask *task; GST_OBJECT_LOCK (pad); task = GST_PAD_TASK (pad); if (task) { switch (gst_task_get_state (task)) { case GST_TASK_STARTED: task_mode = "[T]"; break; case GST_TASK_PAUSED: task_mode = "[t]"; break; default: /* Invalid task state, ignoring */ break; } } GST_OBJECT_UNLOCK (pad); /* check if pad flags */ pad_flags[0] = GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_FLAG_BLOCKED) ? 'B' : 'b'; pad_flags[1] = GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_FLAG_FLUSHING) ? 'F' : 'f'; pad_flags[2] = GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_FLAG_BLOCKING) ? 'B' : 'b'; pad_flags[3] = '\0'; g_string_append_printf (str, "%s %s_%s [color=black, fillcolor=\"%s\", label=\"%s\\n[%c][%s]%s\", height=\"0.2\", style=\"%s\"];\n", spc, element_name, pad_name, color_name, GST_OBJECT_NAME (pad), activation_mode[pad->mode], pad_flags, task_mode, style_name); } else { g_string_append_printf (str, "%s %s_%s [color=black, fillcolor=\"%s\", label=\"%s\", height=\"0.2\", style=\"%s\"];\n", spc, element_name, pad_name, color_name, GST_OBJECT_NAME (pad), style_name); } g_free (pad_name); }
static gboolean connect_element (InsanityTest * test, GstElement * demux) { GList *pads; gboolean res = TRUE; gboolean dynamic = FALSE; GList *to_connect = NULL; /* 1. Loop over pad templates, grabbing existing pads along the way */ for (pads = GST_ELEMENT_GET_CLASS (demux)->padtemplates; pads; pads = g_list_next (pads)) { GstPadTemplate *templ = GST_PAD_TEMPLATE (pads->data); const gchar *templ_name; /* we are only interested in source pads */ if (GST_PAD_TEMPLATE_DIRECTION (templ) != GST_PAD_SRC) continue; templ_name = GST_PAD_TEMPLATE_NAME_TEMPLATE (templ); /* figure out what kind of pad this is */ switch (GST_PAD_TEMPLATE_PRESENCE (templ)) { case GST_PAD_ALWAYS: { GstPad *pad = gst_element_get_static_pad (demux, templ_name); /* We concider the demuxer is not broken, and thus always * pads are always here */ to_connect = g_list_prepend (to_connect, pad); break; } case GST_PAD_SOMETIMES: { /* try to get the pad to see if it is already created or * not */ GstPad *pad = gst_element_get_static_pad (demux, templ_name); if (pad) { /* the pad is created, we need to try to link to it */ to_connect = g_list_prepend (to_connect, pad); } else { /* we have an element that will create dynamic pads */ dynamic = TRUE; } break; } case GST_PAD_REQUEST: /* ignore request pads */ break; } } /* 2. if there are more potential pads, connect to signal */ if (dynamic) { g_signal_connect (glob_demuxer, "pad-added", G_CALLBACK (pad_added_cb), test); } /* 3. for every available pad, check if we can connect it */ for (pads = to_connect; pads; pads = g_list_next (pads)) { GstPad *pad = GST_PAD_CAST (pads->data); pad_added_cb (demux, pad, test); gst_object_unref (pad); } g_list_free (to_connect); return res; }
/* if element caps already in list, will make sure Transform elements have * priority and replace old ones */ static GList * create_codec_cap_list (GstElementFactory *factory, GstPadDirection direction, GList *list, GstCaps *rtp_caps) { const GList *pads = factory->staticpadtemplates; gint i; /* Let us look at each pad for stuff to add*/ while (pads) { GstCaps *caps = NULL; GstStaticPadTemplate *padtemplate = NULL; padtemplate = (GstStaticPadTemplate *) (pads->data); pads = g_list_next (pads); if (padtemplate->direction != direction) continue; if (GST_PAD_TEMPLATE_PRESENCE (padtemplate) != GST_PAD_ALWAYS) { continue; } caps = gst_static_caps_get (&padtemplate->static_caps); /* DEBUG ("%s caps are %s", gst_plugin_feature_get_name (GST_PLUGIN_FEATURE (factory)), gst_caps_to_string (caps)); */ /* skips caps ANY */ if (!caps || gst_caps_is_any (caps)) { goto done; } /* let us add one entry to the list per media type */ for (i = 0; i < gst_caps_get_size (caps); i++) { CodecCap *entry = NULL; GList *found_item = NULL; GstStructure *structure = gst_caps_get_structure (caps, i); GstCaps *cur_caps = gst_caps_new_full (gst_structure_copy (structure), NULL); /* FIXME fix this in gstreamer! The rtpdepay element is bogus, it claims to * be a depayloader yet has application/x-rtp on both sides and does * absolutely nothing */ /* Let's check if media caps are really media caps, this is to deal with * wierd elements such as rtpdepay that says it's a depayloader but has * application/x-rtp on src and sink pads */ const gchar *name = gst_structure_get_name (structure); if (g_ascii_strcasecmp (name, "application/x-rtp") == 0) { GST_DEBUG ("skipping %s", gst_plugin_feature_get_name (GST_PLUGIN_FEATURE (factory))); continue; } /* let's check if this caps is already in the list, if so let's replace * that CodecCap list instead of creating a new one */ /* we need to compare both media caps and rtp caps */ found_item = g_list_find_custom (list, cur_caps, (GCompareFunc)compare_media_caps); if (found_item) { entry = (CodecCap *)found_item->data; /* if RTP caps exist and don't match nullify entry */ if (rtp_caps && compare_rtp_caps (found_item->data, rtp_caps)) { entry = NULL; } } if (!entry) { entry = g_slice_new0 (CodecCap); entry->caps = cur_caps; if (rtp_caps) { entry->rtp_caps = rtp_caps; gst_caps_ref (rtp_caps); } list = g_list_append (list, entry); entry->element_list1 = g_list_prepend (NULL, g_list_prepend (NULL, factory)); gst_object_ref (factory); } else { GstCaps *newcaps; entry->element_list1->data = g_list_append (entry->element_list1->data, factory); gst_object_ref (factory); if (rtp_caps) { if (entry->rtp_caps) { GstCaps *new_rtp_caps; new_rtp_caps = gst_caps_union (rtp_caps, entry->rtp_caps); gst_caps_unref (entry->rtp_caps); entry->rtp_caps = new_rtp_caps; } else { entry->rtp_caps = rtp_caps; /* This shouldn't happen, its we're looking at rtp elements * or we're not */ g_assert_not_reached (); } gst_caps_unref (rtp_caps); } newcaps = gst_caps_union (cur_caps, entry->caps); gst_caps_unref (entry->caps); gst_caps_unref (cur_caps); entry->caps = newcaps; } } done: if (caps != NULL) { gst_caps_unref (caps); } } return list; }