/* Create and link input pad: input_pad ! selector:sink%d */ GstPad * setup_input_pad (GstElement * element) { GstPad *sinkpad = NULL, *input_pad = NULL; /* create input_pad */ input_pad = gst_pad_new_from_static_template (&srctemplate, "src"); fail_if (input_pad == NULL, "Could not create a input_pad"); /* request sink pad */ sinkpad = gst_element_get_request_pad (element, "sink%d"); fail_if (sinkpad == NULL, "Could not get sink pad from %s", GST_ELEMENT_NAME (element)); /* link pads and activate */ fail_unless (gst_pad_link (input_pad, sinkpad) == GST_PAD_LINK_OK, "Could not link input_pad and %s sink", GST_ELEMENT_NAME (element)); gst_pad_set_active (input_pad, TRUE); GST_DEBUG_OBJECT (input_pad, "set up %" GST_PTR_FORMAT " ! %" GST_PTR_FORMAT, input_pad, sinkpad); gst_object_unref (sinkpad); ASSERT_OBJECT_REFCOUNT (sinkpad, "sinkpad", 1); return input_pad; }
static gboolean kms_base_hub_create_and_link_ghost_pad (KmsBaseHub * mixer, GstPad * src_pad, const gchar * gp_name, const gchar * gp_template_name, GstPad * target) { GstPadTemplate *templ; GstPad *gp; gboolean ret; templ = gst_element_class_get_pad_template (GST_ELEMENT_CLASS (G_OBJECT_GET_CLASS (mixer)), gp_template_name); gp = gst_ghost_pad_new_from_template (gp_name, target, templ); if (GST_STATE (mixer) >= GST_STATE_PAUSED || GST_STATE_PENDING (mixer) >= GST_STATE_PAUSED || GST_STATE_TARGET (mixer) >= GST_STATE_PAUSED) { gst_pad_set_active (gp, TRUE); } ret = gst_element_add_pad (GST_ELEMENT (mixer), gp); if (ret) { gst_pad_link (src_pad, gp); } else { g_object_unref (gp); } return ret; }
static void maybe_start_renderer(OwrMediaRenderer *renderer) { OwrMediaRendererPrivate *priv; GstPad *sinkpad, *srcpad; GstElement *src; GstCaps *caps; GstPadLinkReturn pad_link_return; priv = renderer->priv; if (!priv->sink || !priv->source) return; sinkpad = gst_element_get_static_pad(priv->sink, "sink"); g_assert(sinkpad); caps = OWR_MEDIA_RENDERER_GET_CLASS(renderer)->get_caps(renderer); src = _owr_media_source_request_source(priv->source, caps); gst_caps_unref(caps); g_assert(src); srcpad = gst_element_get_static_pad(src, "src"); g_assert(srcpad); priv->src = src; /* The sink is always inside the bin already */ gst_bin_add_many(GST_BIN(priv->pipeline), priv->src, NULL); pad_link_return = gst_pad_link(srcpad, sinkpad); gst_object_unref(sinkpad); gst_object_unref(srcpad); if (pad_link_return != GST_PAD_LINK_OK) { GST_ERROR("Failed to link source with renderer (%d)", pad_link_return); return; } gst_element_set_state(priv->pipeline, GST_STATE_PLAYING); }
static void fake_demuxer_prepare_pads (GstBin * pipeline, GstElement * demux, GstValidateRunner * runner) { gint i = 0; GList *tmp; fail_unless (g_list_length (demux->srcpads), 3); for (tmp = demux->srcpads; tmp; tmp = tmp->next) { GstPad *new_peer; gchar *name = g_strdup_printf ("sink-%d", i++); GstElement *sink = gst_element_factory_make ("fakesink", name); gst_bin_add (pipeline, sink); new_peer = sink->sinkpads->data; gst_pad_link (tmp->data, new_peer); gst_element_set_state (sink, GST_STATE_PLAYING); gst_pad_activate_mode (tmp->data, GST_PAD_MODE_PUSH, TRUE); g_free (name); } fail_unless (gst_pad_activate_mode (demux->sinkpads->data, GST_PAD_MODE_PUSH, TRUE)); }
void Uridecodebin::pad_to_shmdata_writer(GstElement* bin, GstPad* pad) { // detecting type of media bool stream_is_image = false; std::string padname = get_pad_name(pad); gchar** padname_split = g_strsplit_set(padname.c_str(), "/", -1); On_scope_exit { g_strfreev(padname_split); }; stream_is_image = pad_is_image(padname); g_debug("uridecodebin new pad name is %s", padname.c_str()); GstElement* shmdatasink = nullptr; GstUtils::make_element("shmdatasink", &shmdatasink); if (stream_is_image) { GstElement* decodebin = nullptr; GstUtils::make_element("decodebin", &decodebin); g_signal_connect(G_OBJECT(decodebin), "pad-added", (GCallback)Uridecodebin::decodebin_pad_added_cb, (gpointer)this); g_object_set_data(G_OBJECT(decodebin), "decodebin", decodebin); g_object_set_data(G_OBJECT(decodebin), "shmdatasink", shmdatasink); g_object_set_data(G_OBJECT(decodebin), "bin", bin); gst_bin_add(GST_BIN(bin), decodebin); GstUtils::sync_state_with_parent(decodebin); GstPad* sinkpad = gst_element_get_static_pad(decodebin, "sink"); On_scope_exit { gst_object_unref(sinkpad); }; if (GST_PAD_LINK_OK != gst_pad_link(pad, sinkpad)) g_warning("pad link failed from uridecodebin to decodebin (fixed image in uridecodebin)"); } else {
void Pipeline::cb_new_pad (GstElement* decodebin, GstPad* pad, gboolean last, GstElement* glimagesink) { GstPad* glpad = gst_element_get_pad (glimagesink, "sink"); //only link once if (GST_PAD_IS_LINKED (glpad)) { gst_object_unref (glpad); return; } GstCaps* caps = gst_pad_get_caps (pad); GstStructure* str = gst_caps_get_structure (caps, 0); if (!g_strrstr (gst_structure_get_name (str), "video")) { gst_caps_unref (caps); gst_object_unref (glpad); return; } gst_caps_unref (caps); GstPadLinkReturn ret = gst_pad_link (pad, glpad); if (ret != GST_PAD_LINK_OK) g_warning ("Failed to link with decodebin!\n"); }
static void src_pad_added_cb (FsStream *stream, GstPad *pad, FsCodec *codec, gpointer user_data) { GstElement *pipeline = GST_ELEMENT_CAST (user_data); GstElement *sink = NULL; GError *error = NULL; GstPad *pad2; g_print ("Adding receive pipeline\n"); if (g_getenv ("AUDIOSINK")) sink = gst_parse_bin_from_description (g_getenv ("AUDIOSINK"), TRUE, &error); else sink = gst_parse_bin_from_description (DEFAULT_AUDIOSINK, TRUE, &error); print_error (error); g_assert (sink); g_assert (gst_bin_add (GST_BIN (pipeline), sink)); pad2 = gst_element_get_static_pad (sink, "sink"); g_assert (pad2); g_assert (GST_PAD_LINK_SUCCESSFUL (gst_pad_link (pad, pad2))); g_assert (gst_element_set_state (sink, GST_STATE_PLAYING) != GST_STATE_CHANGE_FAILURE); gst_object_unref (pad2); }
static void linked_srcpad_added_link_buffer_injector (GstElement * dummysrc, GstPad * new_pad, gpointer user_data) { GstElement *bufferinjector; GstElement *sink; GstPad *sinkpad; GST_DEBUG_OBJECT (dummysrc, "Added pad %" GST_PTR_FORMAT, new_pad); bufferinjector = gst_element_factory_make ("bufferinjector", NULL); sink = gst_element_factory_make ("fakesink", NULL); g_object_set (G_OBJECT (sink), "async", FALSE, "sync", FALSE, "signal-handoffs", TRUE, NULL); signal_id = g_signal_connect (sink, "handoff", G_CALLBACK (unlink_buffer_injector_on_handoff), bufferinjector); gst_bin_add_many (GST_BIN (pipeline), bufferinjector, sink, NULL); gst_element_sync_state_with_parent (sink); gst_element_sync_state_with_parent (bufferinjector); gst_element_link (bufferinjector, sink); sinkpad = gst_element_get_static_pad (bufferinjector, "sink"); if (gst_pad_link (new_pad, sinkpad) != GST_PAD_LINK_OK) { fail ("Could not link pads"); } g_object_unref (sinkpad); }
static void new_decoded_pad_cb(GstElement *demuxer, GstPad *new_pad, gpointer user_data) { GstElement *decoder; GstPad *pad; GstCaps *caps; gchar *str; caps = gst_pad_get_caps(new_pad); str = gst_caps_to_string(caps); if (g_str_has_prefix(str, "video/")) { decoder = GST_ELEMENT(user_data); pad = gst_element_get_pad(decoder, "sink"); if (GST_PAD_LINK_FAILED(gst_pad_link(new_pad, pad))) { g_warning("Failed to link %s:%s to %s:%s", GST_DEBUG_PAD_NAME(new_pad), GST_DEBUG_PAD_NAME(pad)); } } g_free(str); gst_caps_unref(caps); }
static gboolean rygel_wmv_transcoder_bin_autoplug_continue (RygelWMVTranscoderBin* self, GstElement* decodebin, GstPad* new_pad, GstCaps* caps) { #line 282 "rygel-wmv-transcoder-bin.c" gboolean result = FALSE; GstPad* muxer_pad; #line 67 "rygel-wmv-transcoder-bin.vala" g_return_val_if_fail (self != NULL, FALSE); #line 67 "rygel-wmv-transcoder-bin.vala" g_return_val_if_fail (decodebin != NULL, FALSE); #line 67 "rygel-wmv-transcoder-bin.vala" g_return_val_if_fail (new_pad != NULL, FALSE); #line 67 "rygel-wmv-transcoder-bin.vala" g_return_val_if_fail (caps != NULL, FALSE); #line 70 "rygel-wmv-transcoder-bin.vala" muxer_pad = _gst_object_ref0 (gst_element_get_compatible_pad (self->priv->muxer, new_pad, NULL)); #line 72 "rygel-wmv-transcoder-bin.vala" if (muxer_pad == NULL) { #line 297 "rygel-wmv-transcoder-bin.c" result = TRUE; _gst_object_unref0 (muxer_pad); #line 73 "rygel-wmv-transcoder-bin.vala" return result; #line 302 "rygel-wmv-transcoder-bin.c" } else { result = gst_pad_link (new_pad, muxer_pad) != GST_PAD_LINK_OK; _gst_object_unref0 (muxer_pad); #line 75 "rygel-wmv-transcoder-bin.vala" return result; #line 308 "rygel-wmv-transcoder-bin.c" } _gst_object_unref0 (muxer_pad); }
static void on_new_pad (GstElement * dec, GstPad * pad, GstElement * sinkElement) { GstPad *sinkpad; if(pad==NULL) return; if(sinkElement==NULL) return; sinkpad = gst_element_get_static_pad (sinkElement, "sink"); if(sinkpad==NULL) return; if (!gst_pad_is_linked (sinkpad)) { GstPadLinkReturn ret = gst_pad_link (pad, sinkpad); if(ret == GST_PAD_LINK_NOFORMAT) { GstCaps* a, *b; a = gst_pad_get_current_caps(pad); b = gst_pad_get_current_caps(sinkpad); g_warning("Formats of A: %s\nFormats of B:%s\n", a ? gst_caps_to_string(a) : "<NULL>", b ? gst_caps_to_string(b) : "<NULL>"); gst_pad_unlink (pad, sinkpad); } else if(ret != GST_PAD_LINK_OK) { GstElement* parentA = gst_pad_get_parent_element(pad); GstElement* parentB = gst_pad_get_parent_element(sinkpad); g_error ("Failed to link pads! %s - %s : %d", gst_element_get_name(parentA), gst_element_get_name(parentB), ret); g_object_unref(parentA); g_object_unref(parentB); exit(3); } } gst_object_unref (sinkpad); }
void HTTPSDPDec::httpsdpdec_pad_added_cb(GstElement* /*object */, GstPad* pad, gpointer user_data) { HTTPSDPDec* context = static_cast<HTTPSDPDec*>(user_data); std::unique_ptr<DecodebinToShmdata> decodebin = std::make_unique<DecodebinToShmdata>( context->gst_pipeline_.get(), [context](GstElement* el, const std::string& media_type, const std::string& media_label) { context->configure_shmdatasink(el, media_type, media_label); }, context->decompress_streams_); if (!decodebin->invoke_with_return<gboolean>([context](GstElement* el) { return gst_bin_add(GST_BIN(context->gst_pipeline_->get_pipeline()), el); })) { g_warning("decodebin cannot be added to pipeline"); } GstPad* sinkpad = decodebin->invoke_with_return<GstPad*>( [](GstElement* el) { return gst_element_get_static_pad(el, "sink"); }); On_scope_exit { gst_object_unref(GST_OBJECT(sinkpad)); }; GstUtils::check_pad_link_return(gst_pad_link(pad, sinkpad)); auto caps = gst_pad_get_allowed_caps(pad); On_scope_exit { gst_caps_unref(caps); }; auto structure = gst_caps_get_structure(caps, 0); auto media_label = gst_structure_get_string(structure, "media-label"); if (nullptr != media_label) decodebin->set_media_label(gst_structure_get_string(structure, "media-label")); decodebin->invoke([](GstElement* el) { GstUtils::sync_state_with_parent(el); }); context->decodebins_.push_back(std::move(decodebin)); }
static void bbd_new_decoded_pad(GstElement *decodebin, GstPad *pad, gboolean last, gpointer data) { GstCaps *caps; GstStructure *str; GstPad *audiopad; BansheeBpmDetector *detector = (BansheeBpmDetector *)data; g_return_if_fail(detector != NULL); audiopad = gst_element_get_static_pad(detector->audioconvert, "sink"); if(GST_PAD_IS_LINKED(audiopad)) { g_object_unref(audiopad); return; } caps = gst_pad_query_caps(pad, NULL); str = gst_caps_get_structure(caps, 0); if(!g_strrstr(gst_structure_get_name(str), "audio")) { gst_caps_unref(caps); gst_object_unref(audiopad); return; } gst_caps_unref(caps); gst_pad_link(pad, audiopad); }
/* Create and link output pad: selector:src%d ! output_pad */ GstPad * setup_output_pad (GstElement * element) { GstPad *srcpad = NULL, *output_pad = NULL; gulong probe_id = 0; /* create output_pad */ output_pad = gst_pad_new_from_static_template (&sinktemplate, "sink"); fail_if (output_pad == NULL, "Could not create a output_pad"); /* add probe */ probe_id = gst_pad_add_data_probe (output_pad, G_CALLBACK (probe_cb), NULL); g_object_set_data (G_OBJECT (output_pad), "probe_id", GINT_TO_POINTER (probe_id)); /* request src pad */ srcpad = gst_element_get_request_pad (element, "src%d"); fail_if (srcpad == NULL, "Could not get source pad from %s", GST_ELEMENT_NAME (element)); /* link pads and activate */ fail_unless (gst_pad_link (srcpad, output_pad) == GST_PAD_LINK_OK, "Could not link %s source and output pad", GST_ELEMENT_NAME (element)); gst_pad_set_active (output_pad, TRUE); GST_DEBUG_OBJECT (output_pad, "set up %" GST_PTR_FORMAT " ! %" GST_PTR_FORMAT, srcpad, output_pad); gst_object_unref (srcpad); ASSERT_OBJECT_REFCOUNT (srcpad, "srcpad", 1); return output_pad; }
void on_pad_added(GstElement * element, GstPad * pad) { GstCaps * caps; GstStructure * str; GstPad * targetsink = NULL; caps = gst_pad_get_caps(pad); g_assert(caps != NULL); str = gst_caps_get_structure(caps, 0); g_assert(str != NULL); /* if the file has video and the media type is video connect it to the pipewriter */ if(g_strrstr(gst_structure_get_name(str), "video")) { targetsink = gst_element_get_pad(videodec, "sink"); } /* if the file has audio and the media type is audio connect it to the pipewriter */ else if(g_strrstr(gst_structure_get_name (str), "audio")) { targetsink = gst_element_get_pad(audiodec, "sink"); } if (targetsink != 0) { gst_pad_link(pad, targetsink); gst_object_unref(targetsink); } gst_caps_unref(caps); }
static void connect_to_sink (GstElement * sink, const gchar * sinkname, GstPad * srcpad) { GstPad *sinkpad; GST_DEBUG ("Getting pad %s from %" GST_PTR_FORMAT, sinkname, sink); sinkpad = gst_element_get_static_pad (sink, sinkname); if (sinkpad == NULL) sinkpad = gst_element_get_request_pad (sink, sinkname); if (sinkpad == NULL) { GST_ERROR ("Can not get sink pad."); return; } if (gst_pad_is_linked (sinkpad)) { GST_ERROR ("Pad %" GST_PTR_FORMAT " is already linked.", sinkpad); goto end; } if (gst_pad_link (srcpad, sinkpad) != GST_PAD_LINK_OK) GST_ERROR ("Can not link pad %" GST_PTR_FORMAT " to %" GST_PTR_FORMAT, srcpad, sinkpad); else GST_DEBUG ("Connected %" GST_PTR_FORMAT " to %" GST_PTR_FORMAT, srcpad, sinkpad); end: g_object_unref (sinkpad); }
static void new_decoded_pad (GstElement * dec, GstPad * new_pad, gboolean last, AppInfo * info) { const gchar *sname; GstElement *csp, *scale, *filter; GstStructure *s; GstCaps *caps; GstPad *sinkpad; /* already found a video stream? */ if (info->got_video) return; /* FIXME: is this racy or does decodebin2 make sure caps are always * negotiated at this point? */ caps = gst_pad_get_caps (new_pad); g_return_if_fail (caps != NULL); s = gst_caps_get_structure (caps, 0); sname = gst_structure_get_name (s); if (!g_str_has_prefix (sname, "video/x-raw-")) goto not_video; csp = create_element ("ffmpegcolorspace"); scale = create_element ("videoscale"); filter = create_element ("capsfilter"); info->sink = create_element ("gdkpixbufsink"); g_object_set (info->sink, "qos", FALSE, "max-lateness", (gint64) - 1, NULL); gst_bin_add_many (GST_BIN (info->pipe), csp, scale, filter, info->sink, NULL); sinkpad = gst_element_get_static_pad (csp, "sink"); if (GST_PAD_LINK_FAILED (gst_pad_link (new_pad, sinkpad))) g_error ("Can't link new decoded pad to ffmpegcolorspace's sink pad"); gst_object_unref (sinkpad); if (!gst_element_link (csp, scale)) g_error ("Can't link ffmpegcolorspace to videoscale"); if (!gst_element_link (scale, filter)) g_error ("Can't link videoscale to capsfilter"); if (!gst_element_link (filter, info->sink)) g_error ("Can't link capsfilter to gdkpixbufsink"); gst_element_set_state (info->sink, GST_STATE_PAUSED); gst_element_set_state (filter, GST_STATE_PAUSED); gst_element_set_state (scale, GST_STATE_PAUSED); gst_element_set_state (csp, GST_STATE_PAUSED); info->got_video = TRUE; return; not_video: { if (last) { g_error ("This file does not contain a video track, or you do not have " "the necessary decoder(s) installed"); } } }
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 cb_newpad (GstElement *decodebin, GstPad *pad, gboolean last, gpointer data) { GstCaps *caps; GstStructure *str; GstPad *audiopad; audiopad = gst_element_get_static_pad (audio, "sink"); if (GST_PAD_IS_LINKED (audiopad)) { g_object_unref (audiopad); decodebin = NULL; last = false; data = NULL; return; } caps = gst_pad_get_caps (pad); str = gst_caps_get_structure (caps, 0); if (!g_strrstr (gst_structure_get_name (str), "audio")) { gst_caps_unref (caps); gst_object_unref (audiopad); return; } gst_caps_unref (caps); gst_pad_link (pad, audiopad); }
static GstPad * connect_thru_mq (RsnDvdBin * dvdbin, GstPad * pad) { GstPad *mq_sink; GstPad *mq_src; gchar *tmp, *sinkname, *srcname; /* Request a pad from multiqueue, then connect this one, then * discover the corresponding output pad and return it */ mq_sink = gst_element_get_request_pad (dvdbin->pieces[DVD_ELEM_MQUEUE], "sink_%u"); if (mq_sink == NULL) return FALSE; dvdbin->mq_req_pads = g_list_prepend (dvdbin->mq_req_pads, mq_sink); if (gst_pad_link (pad, mq_sink) != GST_PAD_LINK_OK) return FALSE; sinkname = gst_pad_get_name (mq_sink); tmp = sinkname + 5; srcname = g_strdup_printf ("src_%s", tmp); mq_src = gst_element_get_static_pad (dvdbin->pieces[DVD_ELEM_MQUEUE], srcname); g_free (sinkname); g_free (srcname); return mq_src; }
void MediaParserGst::link_to_fakesink(GstPad* pad) { GstElement* fakesink = gst_element_factory_make("fakesink", NULL); if (!fakesink) { throw MediaException(_("MediaParserGst Failed to create fakesink.")); } gboolean success = gst_bin_add(GST_BIN(_bin), fakesink); if (!success) { gst_object_unref(fakesink); throw MediaException(_("MediaParserGst Failed to create fakesink.")); } GstPad* sinkpad = gst_element_get_static_pad (fakesink, "sink"); if (!sinkpad) { gst_object_unref(fakesink); throw MediaException(_("MediaParserGst: couldn't get the fakesink " "src element.")); } GstPadLinkReturn ret = gst_pad_link(pad, sinkpad); if (!GST_PAD_LINK_SUCCESSFUL(ret)) { gst_object_unref(fakesink); gst_object_unref(sinkpad); throw MediaException(_("MediaParserGst: couln't link fakesink")); } if (!gst_element_set_state (_bin, GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS) { throw GnashException(_("MediaParserGst could not change element state")); } }
static void pad_added_cb (GstElement * uridecodebin, GstPad * pad, GstElement * encodebin) { GstPad *sinkpad; sinkpad = gst_element_get_compatible_pad (encodebin, pad, NULL); if (sinkpad == NULL) { GstCaps *caps; /* Ask encodebin for a compatible pad */ caps = gst_pad_query_caps (pad, NULL); g_signal_emit_by_name (encodebin, "request-pad", caps, &sinkpad); if (caps) gst_caps_unref (caps); } if (sinkpad == NULL) { g_print ("Couldn't get an encoding channel for pad %s:%s\n", GST_DEBUG_PAD_NAME (pad)); return; } if (G_UNLIKELY (gst_pad_link (pad, sinkpad) != GST_PAD_LINK_OK)) { g_print ("Couldn't link pads\n"); } return; }
static void _test_flow_aggregation (GstFlowReturn flow, GstFlowReturn flow1, GstFlowReturn flow2, GstFlowReturn demux_flow, gboolean should_fail) { GstPad *srcpad; GstValidateReport *report; GstValidatePadMonitor *pmonitor, *pmonitor1, *pmonitor2; GstElement *demuxer = fake_demuxer_new (); GstBin *pipeline = GST_BIN (gst_pipeline_new ("validate-pipeline")); GList *reports; GstValidateRunner *runner; GstValidateMonitor *monitor; fail_unless (g_setenv ("GST_VALIDATE_REPORTING_DETAILS", "all", TRUE)); runner = gst_validate_runner_new (); monitor = gst_validate_monitor_factory_create (GST_OBJECT (pipeline), runner, NULL); gst_validate_reporter_set_handle_g_logs (GST_VALIDATE_REPORTER (monitor)); gst_bin_add (pipeline, demuxer); fake_demuxer_prepare_pads (pipeline, demuxer, runner); srcpad = gst_pad_new ("srcpad1", GST_PAD_SRC); gst_pad_link (srcpad, demuxer->sinkpads->data); fail_unless (gst_pad_activate_mode (srcpad, GST_PAD_MODE_PUSH, TRUE)); gst_check_setup_events_with_stream_id (srcpad, demuxer, NULL, GST_FORMAT_TIME, "the-stream"); pmonitor = _get_pad_monitor (gst_pad_get_peer (demuxer->srcpads->data)); pmonitor1 = _get_pad_monitor (gst_pad_get_peer (demuxer->srcpads->next->data)); pmonitor2 = _get_pad_monitor (gst_pad_get_peer (demuxer->srcpads->next->next->data)); pmonitor->last_flow_return = flow; pmonitor1->last_flow_return = flow1; pmonitor2->last_flow_return = flow2; FAKE_DEMUXER (demuxer)->return_value = demux_flow; fail_unless_equals_int (gst_pad_push (srcpad, gst_buffer_new ()), demux_flow); reports = gst_validate_runner_get_reports (runner); if (should_fail) { assert_equals_int (g_list_length (reports), 1); report = reports->data; fail_unless_equals_int (report->level, GST_VALIDATE_REPORT_LEVEL_CRITICAL); fail_unless_equals_int (report->issue->issue_id, WRONG_FLOW_RETURN); } else { assert_equals_int (g_list_length (reports), 0); } g_list_free_full (reports, (GDestroyNotify) gst_validate_report_unref); clean_bus (GST_ELEMENT (pipeline)); gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL); ASSERT_OBJECT_REFCOUNT (pipeline, "ours", 1); check_destroyed (pipeline, demuxer, NULL); check_destroyed (monitor, pmonitor, NULL); }
static void owr_inter_src_init(OwrInterSrc *self) { GstPad *srcpad, *sinkpad; GST_OBJECT_FLAG_SET(self, GST_ELEMENT_FLAG_SOURCE); self->queue = gst_element_factory_make("queue", NULL); gst_bin_add(GST_BIN(self), self->queue); srcpad = gst_element_get_static_pad(self->queue, "src"); self->srcpad = gst_ghost_pad_new_from_template("src", srcpad, gst_static_pad_template_get(&src_template)); gst_object_unref(srcpad); gst_element_add_pad(GST_ELEMENT(self), self->srcpad); /* Just to allow linking... */ self->dummy_sinkpad = gst_pad_new("dummy_sinkpad", GST_PAD_SINK); gst_object_set_parent(GST_OBJECT(self->dummy_sinkpad), GST_OBJECT(self)); self->internal_srcpad = gst_pad_new("internal_src", GST_PAD_SRC); gst_object_set_parent(GST_OBJECT(self->internal_srcpad), GST_OBJECT(self->dummy_sinkpad)); gst_pad_set_event_function(self->internal_srcpad, owr_inter_src_internal_src_event); gst_pad_set_query_function(self->internal_srcpad, owr_inter_src_internal_src_query); sinkpad = gst_element_get_static_pad(self->queue, "sink"); gst_pad_link(self->internal_srcpad, sinkpad); gst_object_unref(sinkpad); }
static void Lastfmfp_cb_newpad(GstElement *decodebin, GstPad *pad, gboolean last, LastfmfpAudio *ma) { GstCaps *caps; GstStructure *str; GstPad *audiopad; // only link once audiopad = gst_element_get_pad(ma->audio, "sink"); if (GST_PAD_IS_LINKED(audiopad)) { g_object_unref(audiopad); return; } // check media type caps = gst_pad_get_caps(pad); str = gst_caps_get_structure(caps, 0); if (!g_strrstr(gst_structure_get_name(str), "audio")) { gst_caps_unref(caps); gst_object_unref(audiopad); return; } gst_caps_unref(caps); // link gst_pad_link(pad, audiopad); gst_object_unref(audiopad); }
static gboolean gst_uri_downloader_set_uri (GstUriDownloader * downloader, const gchar * uri) { GstPad *pad; if (!gst_uri_is_valid (uri)) return FALSE; GST_DEBUG_OBJECT (downloader, "Creating source element for the URI:%s", uri); downloader->priv->urisrc = gst_element_make_from_uri (GST_URI_SRC, uri, NULL); if (!downloader->priv->urisrc) return FALSE; /* add a sync handler for the bus messages to detect errors in the download */ gst_element_set_bus (GST_ELEMENT (downloader->priv->urisrc), downloader->priv->bus); gst_bus_set_sync_handler (downloader->priv->bus, gst_uri_downloader_bus_handler, downloader); pad = gst_element_get_static_pad (downloader->priv->urisrc, "src"); if (!pad) return FALSE; gst_pad_link (pad, downloader->priv->pad); gst_object_unref (pad); return TRUE; }
static void cb_newpad (GstElement *decodebin, GstPad *pad, gboolean last, gpointer data) { GstCaps *caps; GstStructure *str; GstPad *audiopad; /* only link once */ audiopad = gst_element_get_pad (audio, "sink"); if (GST_PAD_IS_LINKED (audiopad)) { g_object_unref (audiopad); return; } /* check media type */ caps = gst_pad_get_caps (pad); str = gst_caps_get_structure (caps, 0); if (!g_strrstr (gst_structure_get_name (str), "audio")) { gst_caps_unref (caps); gst_object_unref (audiopad); return; } gst_caps_unref (caps); /* link'n'play */ gst_pad_link (pad, audiopad); }
static void cb_new_pad (GstElement* decodebin, GstPad* pad, GstElement* identity) { GstPad* identity_pad = gst_element_get_static_pad (identity, "sink"); //only link once if (GST_PAD_IS_LINKED (identity_pad)) { gst_object_unref (identity_pad); return; } GstCaps* caps = gst_pad_get_current_caps (pad); GstStructure* str = gst_caps_get_structure (caps, 0); if (!g_strrstr (gst_structure_get_name (str), "video")) { gst_caps_unref (caps); gst_object_unref (identity_pad); return; } gst_caps_unref (caps); GstPadLinkReturn ret = gst_pad_link (pad, identity_pad); if (ret != GST_PAD_LINK_OK) g_warning ("Failed to link with decodebin!\n"); }
/* dynamically add the source to the pipeline and link it to a new pad on * adder */ static SourceInfo * add_source (gdouble freq) { SourceInfo *info; info = g_new0 (SourceInfo, 1); info->freq = freq; /* make source with unique name */ info->element = gst_element_factory_make ("audiotestsrc", NULL); g_object_set (info->element, "freq", freq, NULL); /* add to the bin */ gst_bin_add (GST_BIN (pipeline), info->element); /* get pad from the element */ info->srcpad = gst_element_get_static_pad (info->element, "src"); /* get new pad from adder, adder will now wait for data on this pad */ info->sinkpad = gst_element_get_request_pad (adder, "sink_%u"); /* link pad to adder */ gst_pad_link (info->srcpad, info->sinkpad); /* and play the element */ gst_element_set_state (info->element, GST_STATE_PLAYING); g_print ("added freq %f\n", info->freq); return info; }
static void post_decodebin_pad_added_handler (GstElement * decodebin, GstPad * pad, KmsHttpEndpoint * self) { GstElement *appsink; GstPad *sinkpad; GST_DEBUG_OBJECT (pad, "Pad added"); /* Create appsink and link to pad */ appsink = gst_element_factory_make ("appsink", NULL); g_object_set (appsink, "sync", TRUE, "enable-last-sample", FALSE, "emit-signals", TRUE, "qos", FALSE, "max-buffers", 1, "async", FALSE, NULL); gst_bin_add (GST_BIN (self->pipeline), appsink); sinkpad = gst_element_get_static_pad (appsink, "sink"); if (gst_pad_link (pad, sinkpad) != GST_PAD_LINK_OK) { GST_ERROR_OBJECT (self, "Can not link %" GST_PTR_FORMAT " to %" GST_PTR_FORMAT, decodebin, appsink); } gst_pad_add_probe (sinkpad, GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM, set_appsrc_caps, self, NULL); g_object_unref (sinkpad); g_object_set_qdata (G_OBJECT (pad), appsink_data_quark (), appsink); gst_element_sync_state_with_parent (appsink); }