static HRESULT WINAPI Gstreamer_transform_Cleanup(TransformFilter *tf, PIN_DIRECTION dir) { GstTfImpl *This = (GstTfImpl*)tf; TRACE("%p 0x%x\n", This, dir); mark_wine_thread(); if (dir == PINDIR_INPUT) { if (This->filter) { gst_element_set_state(This->filter, GST_STATE_NULL); gst_object_unref(This->filter); } This->filter = NULL; if (This->my_src) { gst_pad_unlink(This->my_src, This->their_sink); gst_object_unref(This->my_src); gst_object_unref(This->their_sink); } if (This->my_sink) { gst_pad_unlink(This->their_src, This->my_sink); gst_object_unref(This->my_sink); gst_object_unref(This->their_src); } This->my_sink = This->my_src = This->their_sink = This->their_src = NULL; } return S_OK; }
/* Clean up output/input pad and respective selector request pad */ static void cleanup_pad (GstPad * pad, GstElement * element) { GstPad *selpad = NULL; guint probe_id = 0; fail_if (pad == NULL, "pad doesn't exist"); /* remove probe if necessary */ probe_id = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (pad), "probe_id")); if (probe_id) gst_pad_remove_probe (pad, probe_id); /* unlink */ selpad = gst_pad_get_peer (pad); if (GST_PAD_DIRECTION (selpad) == GST_PAD_SRC) { gst_pad_unlink (selpad, pad); } else { gst_pad_unlink (pad, selpad); } GST_DEBUG_OBJECT (pad, "clean up %" GST_PTR_FORMAT " and %" GST_PTR_FORMAT, selpad, pad); /* cleanup the pad */ gst_pad_set_active (pad, FALSE); ASSERT_OBJECT_REFCOUNT (pad, "pad", 1); gst_object_unref (pad); /* cleanup selector pad, reffed by this function (_get_peer) and creator */ gst_element_release_request_pad (element, selpad); gst_object_unref (selpad); }
/** * gst_ghost_pad_set_target: * @gpad: the #GstGhostPad * @newtarget: (transfer none) (allow-none): the new pad target * * Set the new target of the ghostpad @gpad. Any existing target * is unlinked and links to the new target are established. if @newtarget is * %NULL the target will be cleared. * * Returns: (transfer full): %TRUE if the new target could be set. This function * can return %FALSE when the internal pads could not be linked. */ gboolean gst_ghost_pad_set_target (GstGhostPad * gpad, GstPad * newtarget) { GstPad *internal; GstPad *oldtarget; GstPadLinkReturn lret; g_return_val_if_fail (GST_IS_GHOST_PAD (gpad), FALSE); g_return_val_if_fail (GST_PAD_CAST (gpad) != newtarget, FALSE); g_return_val_if_fail (newtarget != GST_PROXY_PAD_INTERNAL (gpad), FALSE); GST_OBJECT_LOCK (gpad); internal = GST_PROXY_PAD_INTERNAL (gpad); if (newtarget) GST_DEBUG_OBJECT (gpad, "set target %s:%s", GST_DEBUG_PAD_NAME (newtarget)); else GST_DEBUG_OBJECT (gpad, "clearing target"); /* clear old target */ if ((oldtarget = gst_pad_get_peer (internal))) { GST_OBJECT_UNLOCK (gpad); /* unlink internal pad */ if (GST_PAD_IS_SRC (internal)) gst_pad_unlink (internal, oldtarget); else gst_pad_unlink (oldtarget, internal); gst_object_unref (oldtarget); } else { GST_OBJECT_UNLOCK (gpad); } if (newtarget) { /* and link to internal pad without any checks */ GST_DEBUG_OBJECT (gpad, "connecting internal pad to target %" GST_PTR_FORMAT, newtarget); if (GST_PAD_IS_SRC (internal)) lret = gst_pad_link_full (internal, newtarget, GST_PAD_LINK_CHECK_NOTHING); else lret = gst_pad_link_full (newtarget, internal, GST_PAD_LINK_CHECK_NOTHING); if (lret != GST_PAD_LINK_OK) goto link_failed; } return TRUE; /* ERRORS */ link_failed: { GST_WARNING_OBJECT (gpad, "could not link internal and target, reason:%s", gst_pad_link_get_name (lret)); return FALSE; } }
static GstElement * remove_smpte_from_bin (GESTrackVideoTransitionPrivate * priv, GstPad * sink) { GstPad *smpte_src, *peer_src, *smpte_sink; GstElement *smpte, *peer; smpte_src = gst_pad_get_peer (sink); smpte = gst_pad_get_parent_element (smpte_src); if (smpte == NULL) { gst_object_unref (smpte_src); GST_ERROR ("The pad %" GST_PTR_FORMAT " has no parent element. " "This should not happen", smpte_src); return (NULL); } smpte_sink = gst_element_get_static_pad (smpte, "sink"); peer_src = gst_pad_get_peer (smpte_sink); peer = gst_pad_get_parent_element (peer_src); gst_pad_unlink (peer_src, smpte_sink); gst_pad_unlink (smpte_src, sink); gst_element_set_state (smpte, GST_STATE_NULL); gst_bin_remove (GST_BIN (priv->topbin), smpte); gst_object_unref (smpte); gst_object_unref (smpte_sink); gst_object_unref (smpte_src); gst_object_unref (peer_src); return (peer); }
static gboolean set_target (GstPad * gp, GstPad * target) { GstPad *old_target; GstPad *peer; old_target = gst_ghost_pad_get_target (GST_GHOST_PAD (gp)); if (old_target == NULL) { goto end; } peer = gst_pad_get_peer (old_target); if (peer != NULL) { if (peer->direction == GST_PAD_SINK) { gst_pad_unlink (old_target, peer); } else { gst_pad_unlink (peer, old_target); } g_object_unref (peer); } g_object_unref (old_target); end: return gst_ghost_pad_set_target (GST_GHOST_PAD (gp), target); }
EXPORT_C #endif gboolean gst_ghost_pad_set_target (GstGhostPad * gpad, GstPad * newtarget) { GstPad *internal; GstPad *oldtarget; gboolean result; GstPadLinkReturn lret; g_return_val_if_fail (GST_IS_GHOST_PAD (gpad), FALSE); GST_PROXY_LOCK (gpad); internal = GST_PROXY_PAD_INTERNAL (gpad); GST_DEBUG_OBJECT (gpad, "set target %s:%s", GST_DEBUG_PAD_NAME (newtarget)); /* clear old target */ if ((oldtarget = GST_PROXY_PAD_TARGET (gpad))) { /* if we have an internal pad, unlink */ if (internal) { if (GST_PAD_IS_SRC (internal)) gst_pad_unlink (internal, oldtarget); else gst_pad_unlink (oldtarget, internal); } } result = gst_proxy_pad_set_target_unlocked (GST_PAD_CAST (gpad), newtarget); if (result && newtarget) { /* and link to internal pad */ GST_DEBUG_OBJECT (gpad, "connecting internal pad to target"); if (GST_PAD_IS_SRC (internal)) lret = gst_pad_link (internal, newtarget); else lret = gst_pad_link (newtarget, internal); if (lret != GST_PAD_LINK_OK) goto link_failed; } GST_PROXY_UNLOCK (gpad); return result; /* ERRORS */ link_failed: { GST_WARNING_OBJECT (gpad, "could not link internal and target, reason:%d", lret); /* and unset target again */ gst_proxy_pad_set_target_unlocked (GST_PAD_CAST (gpad), NULL); GST_PROXY_UNLOCK (gpad); return FALSE; } }
static void pad_removed_cb (GstElement * timeline, GstPad * pad, GESPipeline * self) { OutputChain *chain; GESTrack *track; GstPad *peer; GST_DEBUG_OBJECT (self, "pad removed %s:%s", GST_DEBUG_PAD_NAME (pad)); if (G_UNLIKELY (!(track = ges_timeline_get_track_for_pad (self->priv->timeline, pad)))) { GST_WARNING_OBJECT (self, "Couldn't find coresponding track !"); return; } if (G_UNLIKELY (!(chain = get_output_chain_for_track (self, track)))) { GST_DEBUG_OBJECT (self, "Pad wasn't used"); return; } /* Unlink encodebin */ if (chain->encodebinpad) { peer = gst_pad_get_peer (chain->encodebinpad); gst_pad_unlink (peer, chain->encodebinpad); gst_object_unref (peer); gst_element_release_request_pad (self->priv->encodebin, chain->encodebinpad); } /* Unlink playsink */ if (chain->playsinkpad) { peer = gst_pad_get_peer (chain->playsinkpad); gst_pad_unlink (peer, chain->playsinkpad); gst_object_unref (peer); gst_element_release_request_pad (self->priv->playsink, chain->playsinkpad); gst_object_unref (chain->playsinkpad); } if (chain->blocked_pad) { GST_DEBUG_OBJECT (chain->blocked_pad, "unblocking pad"); gst_pad_remove_probe (chain->blocked_pad, chain->probe_id); gst_object_unref (chain->blocked_pad); chain->blocked_pad = NULL; chain->probe_id = 0; } /* Unlike/remove tee */ peer = gst_element_get_static_pad (chain->tee, "sink"); gst_pad_unlink (pad, peer); gst_object_unref (peer); gst_element_set_state (chain->tee, GST_STATE_NULL); gst_bin_remove (GST_BIN (self), chain->tee); self->priv->chains = g_list_remove (self->priv->chains, chain); g_free (chain); GST_DEBUG ("done"); }
void GstUtils::unlink_pad(GstPad *pad) { GstPad *peer; if ((peer = gst_pad_get_peer(pad))) { if (gst_pad_get_direction(pad) == GST_PAD_SRC) gst_pad_unlink(pad, peer); else gst_pad_unlink(peer, pad); gst_object_unref(peer); } gst_object_unref(pad); // for iterator }
//FIXME this should be part of the library void shmdata_base_reader_unlink_pad (GstPad *pad) { GstPad *peer; if ((peer = gst_pad_get_peer (pad))) { if (gst_pad_get_direction (pad) == GST_PAD_SRC) gst_pad_unlink (pad, peer); else gst_pad_unlink (peer, pad); gst_object_unref (peer); } gst_object_unref(pad); }
static void really_remove_filter (GstPad *pad, gboolean blocked, RBGstPipelineOp *op) { GstPad *mypad; GstPad *prevpad, *nextpad; GstElement *bin; /* get the containing bin and remove it */ bin = GST_ELEMENT (gst_element_get_parent (op->element)); if (bin == NULL) { return; } rb_debug ("removing filter %p", op->element); _rb_player_gst_filter_emit_filter_pre_remove (RB_PLAYER_GST_FILTER (op->player), op->element); /* probably check return? */ gst_element_set_state (bin, GST_STATE_NULL); /* unlink our sink */ mypad = gst_element_get_static_pad (bin, "sink"); prevpad = gst_pad_get_peer (mypad); gst_pad_unlink (prevpad, mypad); gst_object_unref (mypad); /* unlink our src */ mypad = gst_element_get_static_pad (bin, "src"); nextpad = gst_pad_get_peer (mypad); gst_pad_unlink (mypad, nextpad); gst_object_unref (mypad); /* link previous and next pads */ gst_pad_link (prevpad, nextpad); gst_object_unref (prevpad); gst_object_unref (nextpad); gst_bin_remove (GST_BIN (op->fixture), bin); gst_object_unref (bin); /* if we're supposed to be playing, unblock the sink */ if (blocked) { rb_debug ("unblocking pad after removing filter"); gst_pad_set_blocked_async (pad, FALSE, (GstPadBlockCallback)pipeline_op_done, NULL); } free_pipeline_op (op); }
static void change_input (gpointer pipeline) { GstBin *pipe = GST_BIN (pipeline); GstElement *agnosticbin; GstPad *peer, *sink; GstElement *agnosticbin2 = gst_bin_get_by_name (pipe, "agnosticbin_2"); GstElement *enc = gst_element_factory_make ("vp8enc", NULL); GstElement *fakesink = gst_bin_get_by_name (pipe, "fakesink"); g_signal_connect (G_OBJECT (fakesink), "handoff", G_CALLBACK (fakesink_hand_off), loop); gst_bin_add (pipe, enc); gst_element_sync_state_with_parent (enc); sink = gst_element_get_static_pad (agnosticbin2, "sink"); peer = gst_pad_get_peer (sink); agnosticbin = gst_pad_get_parent_element (peer); gst_pad_unlink (peer, sink); GST_INFO ("Got peer: %" GST_PTR_FORMAT, peer); gst_element_release_request_pad (agnosticbin, peer); gst_element_link (enc, agnosticbin2); gst_element_link (agnosticbin, enc); g_object_unref (agnosticbin); g_object_unref (agnosticbin2); g_object_unref (sink); g_object_unref (peer); }
static void fakesink_hand_off_simple (GstElement * fakesink, GstBuffer * buf, GstPad * pad, gpointer data) { static int count = 0; GMainLoop *loop = (GMainLoop *) data; count++; if (count == 40) { GstPad *peer = gst_pad_get_peer (pad); ElementsData *elements = g_slice_new (ElementsData); elements->agnosticbin = gst_pad_get_parent_element (peer); elements->fakesink = g_object_ref (fakesink); gst_pad_unlink (peer, pad); g_object_unref (peer); g_idle_add_full (G_PRIORITY_DEFAULT, reconnect_elements, elements, free_elements); } else if (count > 100) { g_object_set (G_OBJECT (fakesink), "signal-handoffs", FALSE, NULL); g_idle_add (quit_main_loop_idle, loop); } }
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); }
static GstFlowReturn no_fail_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer) { GstFlowReturn ret; GstPadChainFunction old_func = g_object_get_data (G_OBJECT (pad), OLD_CHAIN_KEY); if (old_func == NULL) { return GST_FLOW_OK; } ret = old_func (pad, parent, buffer); if (G_UNLIKELY (ret != GST_FLOW_OK)) { GstPad *peer; switch (ret) { case GST_FLOW_FLUSHING: break; default: GST_WARNING_OBJECT (pad, "Chain returned: %s. It will be unlinked", gst_flow_get_name (ret)); peer = gst_pad_get_peer (pad); if (peer != NULL) { gst_pad_unlink (peer, pad); g_object_unref (peer); } } } return GST_FLOW_OK; }
void kms_tree_bin_unlink_input_element_from_tee (KmsTreeBin * self) { GstPad *queue_sink, *peer, *tee_src; GstElement *tee; queue_sink = gst_element_get_static_pad (self->priv->input_element, "sink"); peer = gst_pad_get_peer (queue_sink); if (GST_IS_PROXY_PAD (peer)) { GstProxyPad *ghost; ghost = gst_proxy_pad_get_internal (GST_PROXY_PAD (peer)); tee_src = gst_pad_get_peer (GST_PAD (ghost)); g_object_unref (peer); g_object_unref (ghost); } else { tee_src = peer; } gst_pad_unlink (tee_src, queue_sink); tee = gst_pad_get_parent_element (tee_src); if (tee != NULL) { gst_element_release_request_pad (tee, tee_src); g_object_unref (tee); } g_object_unref (tee_src); g_object_unref (queue_sink); }
void GStreamerGWorld::removePlatformVideoSink() { if (!m_dynamicPadName) return; // Get video sink bin and the elements to remove. GstElement* sinkPtr = 0; g_object_get(m_pipeline, "video-sink", &sinkPtr, NULL); GRefPtr<GstElement> videoSink = adoptGRef(sinkPtr); GRefPtr<GstElement> tee = adoptGRef(gst_bin_get_by_name(GST_BIN(videoSink.get()), "videoTee")); GRefPtr<GstElement> platformVideoSink = adoptGRef(gst_bin_get_by_name(GST_BIN(videoSink.get()), "platformVideoSink")); GRefPtr<GstElement> queue = adoptGRef(gst_bin_get_by_name(GST_BIN(videoSink.get()), "queue")); GRefPtr<GstElement> colorspace = adoptGRef(gst_bin_get_by_name(GST_BIN(videoSink.get()), "colorspace")); GRefPtr<GstElement> videoScale = adoptGRef(gst_bin_get_by_name(GST_BIN(videoSink.get()), "videoScale")); GRefPtr<GstPad> srcPad = adoptGRef(gst_element_get_static_pad(tee.get(), m_dynamicPadName.get())); GRefPtr<GstPad> sinkPad = adoptGRef(gst_element_get_static_pad(queue.get(), "sink")); gst_pad_unlink(srcPad.get(), sinkPad.get()); gst_element_release_request_pad(tee.get(), srcPad.get()); gst_element_unlink_many(queue.get(), colorspace.get(), videoScale.get(), platformVideoSink.get(), NULL); gst_bin_remove_many(GST_BIN(videoSink.get()), queue.get(), colorspace.get(), videoScale.get(), platformVideoSink.get(), NULL); gst_element_set_state(platformVideoSink.get(), GST_STATE_NULL); gst_element_set_state(videoScale.get(), GST_STATE_NULL); gst_element_set_state(colorspace.get(), GST_STATE_NULL); gst_element_set_state(queue.get(), GST_STATE_NULL); m_dynamicPadName.clear(); }
static void gst_hls_demux_stop_fetcher (GstHLSDemux * demux, gboolean cancelled) { GstPad *pad; /* When the fetcher is stopped while it's downloading, we will get an EOS that * unblocks the fetcher thread and tries to stop it again from that thread. * Here we check if the fetcher as already been stopped before continuing */ if (demux->fetcher == NULL || demux->stopping_fetcher) return; GST_DEBUG_OBJECT (demux, "Stopping fetcher."); demux->stopping_fetcher = TRUE; /* set the element state to NULL */ gst_element_set_state (demux->fetcher, GST_STATE_NULL); gst_element_get_state (demux->fetcher, NULL, NULL, GST_CLOCK_TIME_NONE); /* unlink it from the internal pad */ pad = gst_pad_get_peer (demux->fetcherpad); if (pad) { gst_pad_unlink (pad, demux->fetcherpad); gst_object_unref (pad); } /* and finally unref it */ gst_object_unref (demux->fetcher); demux->fetcher = NULL; /* if we stopped it to cancell a download, free the cached buffer */ if (cancelled && !gst_adapter_available (demux->download)) { gst_adapter_clear (demux->download); } /* signal the fetcher thread that the download has finished/cancelled */ if (cancelled) g_cond_broadcast (demux->fetcher_cond); }
/* remove the source from the pipeline after removing it from adder */ static void remove_source (SourceInfo * info) { g_print ("remove freq %f\n", info->freq); /* lock the state so that we can put it to NULL without the parent messing * with our state */ gst_element_set_locked_state (info->element, TRUE); /* first stop the source. Remember that this might block when in the PAUSED * state. Alternatively one could send EOS to the source, install an event * probe and schedule a state change/unlink/release from the mainthread. * Note that changing the state of a source makes it emit an EOS, which can * make adder go EOS. */ gst_element_set_state (info->element, GST_STATE_NULL); /* unlink from adder */ gst_pad_unlink (info->srcpad, info->sinkpad); gst_object_unref (info->srcpad); /* remove from the bin */ gst_bin_remove (GST_BIN (pipeline), info->element); /* give back the pad */ gst_element_release_request_pad (adder, info->sinkpad); gst_object_unref (info->sinkpad); g_free (info); }
static GstPadProbeReturn unlink_audiotestsrc (GstPad * pad, GstPadProbeInfo * info, gpointer user_data) { GstElement *audiotestsrc = GST_ELEMENT (user_data); GstElement *audiomixer; GstPad *sinkpad; GST_DEBUG ("Blocked %" GST_PTR_FORMAT, pad); sinkpad = gst_pad_get_peer (pad); if (sinkpad == NULL) { GST_DEBUG_OBJECT (pad, "No peer pad"); return GST_PAD_PROBE_DROP; } audiomixer = gst_pad_get_parent_element (sinkpad); if (audiomixer == NULL) { GST_DEBUG_OBJECT (pad, "No audiomixer"); return GST_PAD_PROBE_DROP; } if (!gst_pad_unlink (pad, sinkpad)) { GST_ERROR ("Can not unilnk pads"); } GST_DEBUG ("Releasing %" GST_PTR_FORMAT, sinkpad); gst_element_release_request_pad (audiomixer, sinkpad); gst_object_unref (sinkpad); gst_object_unref (audiomixer); g_idle_add ((GSourceFunc) remove_audiotestsrc, audiotestsrc); return GST_PAD_PROBE_DROP; }
void MediaSink::unlinkUnchecked (GstPad *sink) { GstPad *peer; GstPad *sinkPad; if (sink == NULL) sinkPad = gst_element_get_static_pad (getElement(), getPadName().c_str() ); else sinkPad = sink; if (sinkPad == NULL) return; peer = gst_pad_get_peer (sinkPad); if (peer != NULL) { gst_pad_unlink (peer, sinkPad); g_object_unref (peer); } if (sink == NULL) { GstElement *elem; elem = gst_pad_get_parent_element (sinkPad); gst_element_release_request_pad (elem, sinkPad); g_object_unref (elem); g_object_unref (sinkPad); } }
static GstPadProbeReturn tee_idle_probe_cb(GstPad *teepad, GstPadProbeInfo *info, gpointer user_data) { OwrMediaSource * media_source = user_data; GstElement *sink_bin; GstPad *sinkpad; GstObject *parent; GstElement *tee; gst_pad_remove_probe(teepad, GST_PAD_PROBE_INFO_ID(info)); sinkpad = gst_pad_get_peer(teepad); g_assert(sinkpad); sink_bin = GST_ELEMENT(gst_object_get_parent(GST_OBJECT(sinkpad))); g_warn_if_fail(gst_pad_unlink(teepad, sinkpad)); parent = gst_pad_get_parent(teepad); tee = GST_ELEMENT(parent); gst_element_release_request_pad(tee, teepad); gst_object_unref(parent); gst_object_unref(sinkpad); parent = gst_object_get_parent(GST_OBJECT(sink_bin)); g_assert(parent); gst_bin_remove(GST_BIN(parent), sink_bin); gst_element_set_state(sink_bin, GST_STATE_NULL); gst_object_unref(sink_bin); gst_object_unref(parent); GST_DEBUG_OBJECT(media_source, "Source successfully unlinked"); return GST_PAD_PROBE_OK; }
static void kms_webrtc_data_session_bin_pad_removed (GstElement * sctpdec, GstPad * srcpad, KmsWebRtcDataSessionBin * self) { GstPad *chann_srcpad, *sctpenc_sinkpad; gboolean emit_signal = FALSE; GstElement *channel; guint sctp_stream_id; gchar *name; name = gst_pad_get_name (srcpad); GST_DEBUG_OBJECT (self, "Pad removed %" GST_PTR_FORMAT, srcpad); if (!sscanf (name, "src_%u", &sctp_stream_id)) { g_free (name); return; } g_free (name); KMS_WEBRTC_DATA_SESSION_BIN_LOCK (self); channel = (GstElement *) g_hash_table_lookup (self->priv->data_channels, GUINT_TO_POINTER (sctp_stream_id)); g_hash_table_remove (self->priv->data_channels, GUINT_TO_POINTER (sctp_stream_id)); g_hash_table_remove (self->priv->channels, GUINT_TO_POINTER (sctp_stream_id)); if (channel == NULL) { GST_WARNING_OBJECT (self, "No data channel (%d) for pad %" GST_PTR_FORMAT, sctp_stream_id, srcpad); goto end; } gst_element_set_state (channel, GST_STATE_NULL); chann_srcpad = gst_element_get_static_pad (channel, "src"); sctpenc_sinkpad = gst_pad_get_peer (chann_srcpad); if (sctpenc_sinkpad != NULL) { gst_pad_unlink (chann_srcpad, sctpenc_sinkpad); gst_element_release_request_pad (self->priv->sctpenc, sctpenc_sinkpad); g_object_unref (sctpenc_sinkpad); } g_object_unref (chann_srcpad); gst_bin_remove (GST_BIN (self), channel); emit_signal = TRUE; end: KMS_WEBRTC_DATA_SESSION_BIN_UNLOCK (self); if (emit_signal) { g_signal_emit (self, obj_signals[DATA_CHANNEL_CLOSED], 0, sctp_stream_id); } }
void MediaSinkImpl::unlinkUnchecked (GstPad *sink) { GstPad *peer; GstPad *sinkPad; if (sink == NULL) { sinkPad = gst_element_get_static_pad (getGstreamerElement(), getPadName().c_str() ); } else { sinkPad = sink; } if (sinkPad == NULL) { return; } peer = gst_pad_get_peer (sinkPad); if (peer != NULL) { Glib::Threads::Cond cond; Glib::Threads::Mutex cmutex; bool blocked = FALSE; std::function <void (GstPad *, GstPadProbeInfo *) > blockedLambda = [&] (GstPad * pad, GstPadProbeInfo * info) { Glib::Threads::Mutex::Lock lock (cmutex); GST_DEBUG ("Peer pad blocked %" GST_PTR_FORMAT, pad); if (blocked) { return; } gst_pad_unlink (pad, sinkPad); blocked = TRUE; cond.signal(); }; gst_pad_add_probe (peer, (GstPadProbeType) (GST_PAD_PROBE_TYPE_BLOCKING), pad_blocked_adaptor, &blockedLambda, NULL); cmutex.lock (); while (!blocked) { cond.wait (cmutex); } cmutex.unlock (); g_object_unref (peer); } if (sink == NULL) { gst_element_release_request_pad (getGstreamerElement(), sinkPad); g_object_unref (sinkPad); } }
///////////////////////////////////////////////////////////////////////////////// // Unlinks all elements // bool CDFKAFU050::UnlinkPipeline() { #ifdef USE_AFU050 gst_element_set_state (_Pipeline.pipeline, GST_STATE_PAUSED); gst_element_set_state (_Pipeline.pipeline, GST_STATE_NULL); g_main_loop_quit (_Pipeline.loop); // Pipeline to the tee. Does the camera control and color image. gst_element_unlink_many(GetElement("appsrc"), GetElement("jpegdec"), GetElement("cogcolorspace"), GetElement("tee"), NULL); gst_element_unlink_many(GetElement("queue1"), GetElement("videoscale1"), GetElement("filter"), GetElement("ximagesink"), NULL); gst_element_unlink_many(GetElement("queue2"), GetElement("image_sink"), NULL); gst_pad_unlink(tee_q1_pad, q1_pad); gst_pad_unlink(tee_q2_pad, q2_pad); gst_object_unref(GetElement("appsrc")); gst_object_unref(GetElement("filter")); gst_object_unref(GetElement("jpegdec")); gst_object_unref(GetElement("tee")); gst_object_unref(GetElement("ximagesink")); gst_object_unref(GetElement("queue1")); gst_object_unref(GetElement("queue2")); gst_object_unref(GetElement("videoscale1")); gst_object_unref(GetElement("image_sink")); // clean up and delete the pipeline gst_object_unref (GST_OBJECT (_Pipeline.pipeline)); g_source_remove (_Pipeline.bus_watch_id); #endif return true; }
static void _unlink_track (GESPipeline * self, GESTrack * track) { OutputChain *chain; GST_DEBUG_OBJECT (self, "Unlinking removed %" GST_PTR_FORMAT, track); if (G_UNLIKELY (!(chain = get_output_chain_for_track (self, track)))) { GST_DEBUG_OBJECT (self, "Track wasn't used"); return; } /* Unlink encodebin */ if (chain->encodebinpad) { GstPad *peer = gst_pad_get_peer (chain->encodebinpad); gst_pad_unlink (peer, chain->encodebinpad); gst_object_unref (peer); gst_element_release_request_pad (self->priv->encodebin, chain->encodebinpad); gst_object_unref (chain->encodebinpad); } /* Unlink playsink */ if (chain->playsinkpad) { GstPad *peer = gst_pad_get_peer (chain->playsinkpad); gst_pad_unlink (peer, chain->playsinkpad); gst_object_unref (peer); gst_element_release_request_pad (self->priv->playsink, chain->playsinkpad); gst_object_unref (chain->playsinkpad); } gst_element_set_state (chain->tee, GST_STATE_NULL); gst_bin_remove (GST_BIN (self), chain->tee); if (chain->query_position_id) { g_signal_handler_disconnect (ges_track_get_composition (track), chain->query_position_id); chain->query_position_id = 0; } self->priv->chains = g_list_remove (self->priv->chains, chain); g_free (chain); GST_DEBUG ("done"); }
static void gst_ghost_pad_dispose (GObject * object) { GstPad *pad; GstPad *internal; GstPad *peer; pad = GST_PAD (object); GST_DEBUG_OBJECT (pad, "dispose"); gst_ghost_pad_set_target (GST_GHOST_PAD (pad), NULL); /* Unlink here so that gst_pad_dispose doesn't. That would lead to a call to * gst_ghost_pad_do_unlink when the ghost pad is in an inconsistent state */ peer = gst_pad_get_peer (pad); if (peer) { if (GST_PAD_IS_SRC (pad)) gst_pad_unlink (pad, peer); else gst_pad_unlink (peer, pad); gst_object_unref (peer); } GST_PROXY_LOCK (pad); internal = GST_PROXY_PAD_INTERNAL (pad); gst_pad_set_activatepull_function (internal, NULL); gst_pad_set_activatepush_function (internal, NULL); g_signal_handler_disconnect (internal, GST_GHOST_PAD_PRIVATE (pad)->notify_id); /* disposes of the internal pad, since the ghostpad is the only possible object * that has a refcount on the internal pad. */ gst_object_unparent (GST_OBJECT_CAST (internal)); GST_PROXY_PAD_INTERNAL (pad) = NULL; GST_PROXY_UNLOCK (pad); G_OBJECT_CLASS (gst_ghost_pad_parent_class)->dispose (object); }
static gboolean toggle_pads_link_state (GstPad * pad1, GstPad * pad2) { gboolean ok = TRUE; if (gst_pad_is_linked (pad1)) { if (gst_pad_get_direction (pad1) == GST_PAD_SINK) gst_pad_unlink (pad2, pad1); else gst_pad_unlink (pad1, pad2); } else { if (gst_pad_get_direction (pad1) == GST_PAD_SINK) ok &= (gst_pad_link (pad2, pad1) == 0); else ok &= (gst_pad_link (pad1, pad2) == 0); } return ok; }
static gboolean disconnect_elements (GstElement * agnosticbin, GstElement * audiomixer) { gboolean done = FALSE, disconnected = FALSE; GValue val = G_VALUE_INIT; GstIterator *it; it = gst_element_iterate_src_pads (agnosticbin); do { switch (gst_iterator_next (it, &val)) { case GST_ITERATOR_OK: { GstPad *srcpad, *sinkpad; GstElement *mixer; srcpad = g_value_get_object (&val); sinkpad = gst_pad_get_peer (srcpad); mixer = gst_pad_get_parent_element (sinkpad); if (mixer == audiomixer) { GST_DEBUG ("Unlink %" GST_PTR_FORMAT " and %" GST_PTR_FORMAT, agnosticbin, mixer); if (!gst_pad_unlink (srcpad, sinkpad)) { GST_ERROR ("Can not unlink %" GST_PTR_FORMAT " and %" GST_PTR_FORMAT, srcpad, sinkpad); } gst_element_release_request_pad (mixer, sinkpad); gst_element_release_request_pad (agnosticbin, srcpad); disconnected |= TRUE; } gst_object_unref (sinkpad); gst_object_unref (mixer); g_value_reset (&val); break; } case GST_ITERATOR_RESYNC: gst_iterator_resync (it); break; case GST_ITERATOR_ERROR: GST_ERROR ("Error iterating over %s's src pads", GST_ELEMENT_NAME (agnosticbin)); case GST_ITERATOR_DONE: g_value_unset (&val); done = TRUE; break; } } while (!done); gst_iterator_free (it); return disconnected; }
static HRESULT WINAPI Gstreamer_transform_Cleanup(TransformFilter *tf, PIN_DIRECTION dir) { GstTfImpl *This = (GstTfImpl*)tf; if (dir == PINDIR_INPUT) { if (This->filter) { gst_element_set_state(This->filter, GST_STATE_NULL); gst_object_unref(This->filter); } if (This->filter2) { gst_element_set_state(This->filter2, GST_STATE_NULL); gst_object_unref(This->filter2); } This->filter = NULL; if (This->filter2) { gst_pad_unlink(This->my_src, This->their_sink2); gst_pad_unlink(This->their_src2, This->their_sink); gst_pad_unlink(This->their_src, This->my_sink); } else if (This->my_src) gst_pad_unlink(This->my_src, This->their_sink); if (This->their_src) gst_pad_unlink(This->their_src, This->my_sink); if (This->my_src) gst_object_unref(This->my_src); if (This->their_sink) gst_object_unref(This->their_sink); if (This->their_src) gst_object_unref(This->their_src); if (This->their_sink2) gst_object_unref(This->their_sink2); if (This->their_src2) gst_object_unref(This->their_src2); if (This->my_sink) gst_object_unref(This->my_sink); This->my_sink = This->my_src = This->their_sink = This->their_src = NULL; This->their_src2 = This->their_sink2 = NULL; This->filter2 = NULL; } return S_OK; }
static void unlink_src_pad (GstElement * element, const gchar * pad_name) { GstPad *pad = gst_element_get_static_pad (element, pad_name); GstPad *peer = gst_pad_get_peer (pad); gst_pad_unlink (pad, peer); g_object_unref (pad); g_object_unref (peer); }