Пример #1
0
static void
_free_input_chain (struct input_chain *chain)
{
  if (!chain)
    return;

  if (chain->ghost_pad)
    gst_object_unref (chain->ghost_pad);
  chain->ghost_pad = NULL;

  if (chain->upload) {
    gst_bin_remove (GST_BIN (chain->self), chain->upload);
    gst_object_unref (chain->upload);
    chain->upload = NULL;
  }

  if (chain->in_convert) {
    gst_bin_remove (GST_BIN (chain->self), chain->in_convert);
    gst_object_unref (chain->in_convert);
    chain->in_convert = NULL;
  }

  if (chain->mixer_pad) {
    gst_element_release_request_pad (chain->self->mixer, chain->mixer_pad);
    gst_object_unref (chain->mixer_pad);
    chain->mixer_pad = NULL;
  }

  g_free (chain);
}
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();
}
Пример #3
0
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);
  }
}
Пример #4
0
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);
}
Пример #5
0
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;
}
Пример #6
0
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;
}
static gboolean
get_pads_from_mq (GstSplitMuxSink * splitmux, GstPad ** sink_pad,
    GstPad ** src_pad)
{
  GstPad *mq_sink;
  GstPad *mq_src;

  /* Request a pad from multiqueue, then connect this one, then
   * discover the corresponding output pad and return both */
  mq_sink = gst_element_get_request_pad (splitmux->mq, "sink_%u");
  if (mq_sink == NULL)
    return FALSE;

  mq_src = mq_sink_to_src (splitmux->mq, mq_sink);
  if (mq_src == NULL)
    goto fail;

  *sink_pad = mq_sink;
  *src_pad = mq_src;

  return TRUE;

fail:
  gst_element_release_request_pad (splitmux->mq, mq_sink);
  return FALSE;
}
Пример #8
0
static void
kms_element_release_pad (GstElement * element, GstPad * pad)
{
  GstElement *agnosticbin;
  GstPad *target;

  if (g_str_has_prefix (GST_OBJECT_NAME (pad), "audio_src")) {
    agnosticbin = KMS_ELEMENT (element)->priv->audio_agnosticbin;
  } else if (g_str_has_prefix (GST_OBJECT_NAME (pad), "video_src")) {
    agnosticbin = KMS_ELEMENT (element)->priv->video_agnosticbin;
  } else {
    return;
  }

  // TODO: Remove pad if is a sinkpad

  target = gst_ghost_pad_get_target (GST_GHOST_PAD (pad));

  if (target != NULL && agnosticbin != NULL)
    gst_element_release_request_pad (agnosticbin, target);

  if (GST_STATE (element) >= GST_STATE_PAUSED
      || GST_STATE_PENDING (element) >= GST_STATE_PAUSED)
    gst_pad_set_active (pad, FALSE);

  gst_element_remove_pad (element, pad);
}
Пример #9
0
/* 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);
}
Пример #10
0
/* 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);
}
Пример #11
0
static void
gst_mxf_mux_reset (GstMXFMux * mux)
{
  GList *l;

  GST_OBJECT_LOCK (mux);
  while ((l = GST_ELEMENT_CAST (mux)->sinkpads) != NULL) {
    GstPad *pad = (GstPad *) l->data;

    gst_object_ref (pad);
    GST_OBJECT_UNLOCK (mux);
    gst_element_release_request_pad (GST_ELEMENT_CAST (mux), pad);
    gst_object_unref (pad);
    GST_OBJECT_LOCK (mux);
  }
  GST_OBJECT_UNLOCK (mux);

  mux->state = GST_MXF_MUX_STATE_HEADER;
  mux->n_pads = 0;

  if (mux->metadata) {
    g_hash_table_destroy (mux->metadata);
    mux->preface = NULL;
    g_list_free (mux->metadata_list);
    mux->metadata_list = NULL;
  }
  mux->metadata = mxf_metadata_hash_table_new ();

  mxf_partition_pack_reset (&mux->partition);
  mxf_primer_pack_reset (&mux->primer);
  memset (&mux->min_edit_rate, 0, sizeof (MXFFraction));
  mux->last_gc_timestamp = 0;
  mux->last_gc_position = 0;
  mux->offset = 0;
}
Пример #12
0
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);
}
static gpointer
stop_source_thread (gpointer data)
{
  FsRtpSpecialSource *self = FS_RTP_SPECIAL_SOURCE (data);

  gst_element_set_locked_state (self->priv->src, TRUE);
  gst_element_set_state (self->priv->src, GST_STATE_NULL);

  FS_RTP_SPECIAL_SOURCE_LOCK (self);
  if (self->priv->muxer_request_pad)
  {
    gst_element_release_request_pad (self->priv->rtpmuxer,
        self->priv->muxer_request_pad);
    gst_object_unref (self->priv->muxer_request_pad);
  }
  self->priv->muxer_request_pad = NULL;

  gst_bin_remove (GST_BIN (self->priv->outer_bin), self->priv->src);
  self->priv->src = NULL;
  FS_RTP_SPECIAL_SOURCE_UNLOCK (self);

  g_object_unref (self);

  return NULL;
}
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);
}
Пример #15
0
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);
  }
}
Пример #16
0
static gboolean
remove_elements_from_pipeline (KmsAlphaBlendingData * port_data)
{
  KmsAlphaBlending *self = port_data->mixer;
  GstElement *videoconvert, *videoscale, *videorate, *capsfilter, *queue,
      *videobox;

  KMS_ALPHA_BLENDING_LOCK (self);

  videobox = port_data->videobox;
  gst_element_unlink (videobox, self->priv->videomixer);

  if (port_data->video_mixer_pad != NULL) {
    gst_element_release_request_pad (self->priv->videomixer,
        port_data->video_mixer_pad);
    g_object_unref (port_data->video_mixer_pad);
    port_data->video_mixer_pad = NULL;
  }

  videoconvert = g_object_ref (port_data->videoconvert);
  videorate = g_object_ref (port_data->videorate);
  queue = g_object_ref (port_data->queue);
  videoscale = g_object_ref (port_data->videoscale);
  capsfilter = g_object_ref (port_data->capsfilter);
  g_object_ref (videobox);

  g_object_unref (port_data->videoconvert_sink_pad);

  port_data->videoconvert_sink_pad = NULL;
  port_data->videoconvert = NULL;
  port_data->videorate = NULL;
  port_data->queue = NULL;
  port_data->videoscale = NULL;
  port_data->capsfilter = NULL;
  port_data->videobox = NULL;

  gst_bin_remove_many (GST_BIN (self), videoconvert, videoscale, capsfilter,
      videorate, queue, videobox, NULL);

  kms_base_hub_unlink_video_src (KMS_BASE_HUB (self), port_data->id);

  KMS_ALPHA_BLENDING_UNLOCK (self);

  gst_element_set_state (videoconvert, GST_STATE_NULL);
  gst_element_set_state (videoscale, GST_STATE_NULL);
  gst_element_set_state (videorate, GST_STATE_NULL);
  gst_element_set_state (capsfilter, GST_STATE_NULL);
  gst_element_set_state (queue, GST_STATE_NULL);
  gst_element_set_state (videobox, GST_STATE_NULL);

  g_object_unref (videoconvert);
  g_object_unref (videoscale);
  g_object_unref (videorate);
  g_object_unref (capsfilter);
  g_object_unref (queue);
  g_object_unref (videobox);

  return G_SOURCE_REMOVE;
}
static void
gst_splitmux_sink_release_pad (GstElement * element, GstPad * pad)
{
  GstSplitMuxSink *splitmux = (GstSplitMuxSink *) element;
  GstPad *mqsink, *mqsrc, *muxpad;
  MqStreamCtx *ctx =
      (MqStreamCtx *) (g_object_get_qdata ((GObject *) (pad), PAD_CONTEXT));

  GST_SPLITMUX_LOCK (splitmux);

  if (splitmux->muxer == NULL || splitmux->mq == NULL)
    goto fail;                  /* Elements don't exist yet - nothing to release */

  GST_INFO_OBJECT (pad, "releasing request pad");

  mqsink = gst_ghost_pad_get_target (GST_GHOST_PAD (pad));
  mqsrc = mq_sink_to_src (splitmux->mq, mqsink);
  muxpad = gst_pad_get_peer (mqsrc);

  /* Remove the context from our consideration */
  splitmux->contexts = g_list_remove (splitmux->contexts, ctx);

  if (ctx->sink_pad_block_id)
    gst_pad_remove_probe (ctx->sinkpad, ctx->sink_pad_block_id);

  if (ctx->src_pad_block_id)
    gst_pad_remove_probe (ctx->srcpad, ctx->src_pad_block_id);

  /* Can release the context now */
  mq_stream_ctx_unref (ctx);

  /* Release and free the mq input */
  gst_element_release_request_pad (splitmux->mq, mqsink);

  /* Release and free the muxer input */
  gst_element_release_request_pad (splitmux->muxer, muxpad);

  gst_object_unref (mqsink);
  gst_object_unref (mqsrc);
  gst_object_unref (muxpad);

  gst_element_remove_pad (element, pad);

fail:
  GST_SPLITMUX_UNLOCK (splitmux);
}
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);
  }
}
Пример #19
0
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");
}
Пример #20
0
static void
remove_on_unlinked (GstPad * pad, GstPad * peer, gpointer data)
{
  GstElement *parent = gst_pad_get_parent_element (pad);

  if (parent != NULL) {
    gst_element_release_request_pad (parent, pad);
    g_object_unref (parent);
  }
}
Пример #21
0
static gboolean
remove_elements_from_pipeline (KmsCompositeMixerData * port_data)
{
  KmsCompositeMixer *self = port_data->mixer;

  KMS_COMPOSITE_MIXER_LOCK (self);

  gst_element_unlink (port_data->capsfilter, self->priv->videomixer);

  if (port_data->video_mixer_pad != NULL) {
    gst_element_release_request_pad (self->priv->videomixer,
        port_data->video_mixer_pad);
    g_object_unref (port_data->video_mixer_pad);
    port_data->video_mixer_pad = NULL;
  }

  g_object_unref (port_data->videoconvert_sink_pad);

  gst_bin_remove_many (GST_BIN (self),
      g_object_ref (port_data->input_capsfilter),
      g_object_ref (port_data->videoconvert),
      g_object_ref (port_data->videoscale),
      g_object_ref (port_data->capsfilter), g_object_ref (port_data->videorate),
      g_object_ref (port_data->queue), NULL);

  kms_base_hub_unlink_video_src (KMS_BASE_HUB (self), port_data->id);

  KMS_COMPOSITE_MIXER_UNLOCK (self);

  gst_element_set_state (port_data->input_capsfilter, GST_STATE_NULL);
  gst_element_set_state (port_data->videoconvert, GST_STATE_NULL);
  gst_element_set_state (port_data->videoscale, GST_STATE_NULL);
  gst_element_set_state (port_data->videorate, GST_STATE_NULL);
  gst_element_set_state (port_data->capsfilter, GST_STATE_NULL);
  gst_element_set_state (port_data->queue, GST_STATE_NULL);

  g_object_unref (port_data->input_capsfilter);
  g_object_unref (port_data->videoconvert);
  g_object_unref (port_data->videoscale);
  g_object_unref (port_data->videorate);
  g_object_unref (port_data->capsfilter);
  g_object_unref (port_data->queue);

  port_data->videoconvert_sink_pad = NULL;
  port_data->input_capsfilter = NULL;
  port_data->videoconvert = NULL;
  port_data->videoscale = NULL;
  port_data->capsfilter = NULL;
  port_data->videorate = NULL;
  port_data->queue = NULL;

  return G_SOURCE_REMOVE;
}
Пример #22
0
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
}
Пример #23
0
static void
remove_tee_pad_on_unlink (GstPad * pad, GstPad * peer, gpointer user_data)
{
  GstElement *tee = gst_pad_get_parent_element (pad);

  if (tee == NULL) {
    return;
  }

  gst_element_release_request_pad (tee, pad);
  g_object_unref (tee);
}
Пример #24
0
static void
remove_elements (RsnDvdBin * dvdbin)
{
  gint i;
  GList *tmp;

  if (dvdbin->pieces[DVD_ELEM_MQUEUE] != NULL) {
    for (tmp = dvdbin->mq_req_pads; tmp; tmp = g_list_next (tmp)) {
      gst_element_release_request_pad (dvdbin->pieces[DVD_ELEM_MQUEUE],
          GST_PAD (tmp->data));
    }
  }
  g_list_free (dvdbin->mq_req_pads);
  dvdbin->mq_req_pads = NULL;

  for (i = 0; i < DVD_ELEM_LAST; i++) {
    DVDBIN_LOCK (dvdbin);
    if (dvdbin->pieces[i] != NULL) {
      GstElement *piece = dvdbin->pieces[i];

      dvdbin->pieces[i] = NULL;
      DVDBIN_UNLOCK (dvdbin);

      gst_element_set_state (piece, GST_STATE_NULL);
      gst_bin_remove (GST_BIN (dvdbin), piece);
    } else
      DVDBIN_UNLOCK (dvdbin);
  }
  if (dvdbin->video_pad) {
    if (dvdbin->video_added)
      gst_element_remove_pad (GST_ELEMENT (dvdbin), dvdbin->video_pad);
    else
      gst_object_unref (dvdbin->video_pad);
  }
  if (dvdbin->audio_pad) {
    if (dvdbin->audio_added)
      gst_element_remove_pad (GST_ELEMENT (dvdbin), dvdbin->audio_pad);
    else
      gst_object_unref (dvdbin->audio_pad);
  }
  if (dvdbin->subpicture_pad) {
    if (dvdbin->subpicture_added)
      gst_element_remove_pad (GST_ELEMENT (dvdbin), dvdbin->subpicture_pad);
    else
      gst_object_unref (dvdbin->subpicture_pad);
  }

  dvdbin->video_added = dvdbin->audio_added = dvdbin->subpicture_added = FALSE;
  dvdbin->audio_broken = FALSE;
  dvdbin->video_pad = dvdbin->audio_pad = dvdbin->subpicture_pad = NULL;
  dvdbin->did_no_more_pads = FALSE;
}
Пример #25
0
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
}
GST_END_TEST
GST_START_TEST (create_test)
{
  GstElement *agnosticbin = gst_element_factory_make ("agnosticbin", NULL);
  GstPad *pad;

  pad = gst_element_get_request_pad (agnosticbin, "src_%u");

  GST_DEBUG_OBJECT (pad, "Pad created");

  gst_element_release_request_pad (agnosticbin, pad);

  g_object_unref (agnosticbin);
}
static void
release_test_objects (struct TestData *td)
{
  gst_pad_set_active (td->mysink, FALSE);
  gst_pad_set_active (td->mysrc1, FALSE);
  gst_pad_set_active (td->mysrc1, FALSE);

  gst_object_unref (td->mysink);
  gst_object_unref (td->mysrc1);
  gst_object_unref (td->mysrc2);

  fail_unless (gst_element_set_state (td->funnel, GST_STATE_NULL) ==
      GST_STATE_CHANGE_SUCCESS);

  gst_object_unref (td->funnelsrc);
  gst_element_release_request_pad (td->funnel, td->funnelsink11);
  gst_object_unref (td->funnelsink11);
  gst_element_release_request_pad (td->funnel, td->funnelsink22);
  gst_object_unref (td->funnelsink22);

  gst_caps_unref (td->mycaps);
  gst_object_unref (td->funnel);
}
Пример #28
0
static void
destroy_pad (PadInfos * infos)
{
  if (G_LIKELY (infos->bin)) {
    gst_element_set_state (infos->bin, GST_STATE_NULL);
    gst_element_unlink (infos->bin, infos->self->adder);
    gst_bin_remove (GST_BIN (infos->self), infos->bin);
  }

  if (infos->adder_pad) {
    gst_element_release_request_pad (infos->self->adder, infos->adder_pad);
    gst_object_unref (infos->adder_pad);
  }
  g_slice_free (PadInfos, infos);
}
Пример #29
0
static void
dvb_base_bin_reset (DvbBaseBin * dvbbasebin)
{
  if (dvbbasebin->hwcam) {
    cam_device_close (dvbbasebin->hwcam);
    cam_device_free (dvbbasebin->hwcam);
    dvbbasebin->hwcam = NULL;
  }

  if (dvbbasebin->ts_pad) {
    gst_element_release_request_pad (GST_ELEMENT (dvbbasebin->mpegtsparse),
        dvbbasebin->ts_pad);
    dvbbasebin->ts_pad = NULL;
  }
}
Пример #30
0
static void
remove_unlinked_pad (GstPad * pad, GstPad * peer, gpointer user_data)
{
  GstElement *parent = gst_pad_get_parent_element (pad);

  if (parent == NULL)
    return;

  GST_DEBUG_OBJECT (GST_OBJECT_PARENT (parent), "Removing pad %" GST_PTR_FORMAT,
      pad);

  gst_element_release_request_pad (parent, pad);

  g_object_unref (parent);
}