Beispiel #1
0
void
fs_rtp_tfrc_destroy (FsRtpTfrc *self)
{
  GST_OBJECT_LOCK (self);

  if (self->modder_check_probe_id)
    gst_pad_remove_probe (self->in_rtp_pad, self->modder_check_probe_id);
  self->modder_check_probe_id = 0;

  if (self->in_rtp_probe_id)
    gst_pad_remove_probe (self->in_rtp_pad, self->in_rtp_probe_id);
  self->in_rtp_probe_id = 0;
  if (self->in_rtcp_probe_id)
    gst_pad_remove_probe (self->in_rtcp_pad, self->in_rtcp_probe_id);
  self->in_rtcp_probe_id = 0;


  if (self->on_ssrc_validated_id)
    g_signal_handler_disconnect (self->rtpsession, self->on_ssrc_validated_id);
  self->on_ssrc_validated_id = 0;
  if (self->on_sending_rtcp_id)
    g_signal_handler_disconnect (self->rtpsession, self->on_sending_rtcp_id);
  self->on_sending_rtcp_id = 0;

  g_hash_table_destroy (g_hash_table_ref (self->tfrc_sources));

  self->fsrtpsession = NULL;

  GST_OBJECT_UNLOCK (self);
}
static GstPadProbeReturn
parsebin_pending_event_probe (GstPad * pad, GstPadProbeInfo * info,
    PendingPad * ppad)
{
  GstDecodebin3 *dbin = ppad->dbin;
  /* We drop all events by default */
  GstPadProbeReturn ret = GST_PAD_PROBE_DROP;
  GstEvent *ev = GST_PAD_PROBE_INFO_EVENT (info);

  GST_DEBUG_OBJECT (pad, "Got event %p %s", ev, GST_EVENT_TYPE_NAME (ev));
  switch (GST_EVENT_TYPE (ev)) {
    case GST_EVENT_EOS:
    {
      GST_DEBUG_OBJECT (pad, "Pending pad marked as EOS, removing");
      ppad->input->pending_pads =
          g_list_remove (ppad->input->pending_pads, ppad);
      gst_pad_remove_probe (ppad->pad, ppad->buffer_probe);
      gst_pad_remove_probe (ppad->pad, ppad->event_probe);
      g_free (ppad);

      check_all_streams_for_eos (dbin);
    }
      break;
    default:
      break;
  }

  return ret;
}
static GstPadProbeReturn
pad_probe_cb (GstPad * pad, GstPadProbeInfo * info, gpointer user_data)
{
  GstElement *dummysrc;
  gboolean success;
  gchar *padname;

  GST_DEBUG_OBJECT (pad, "pad is blocked now");

  /* remove the probe first */
  gst_pad_remove_probe (pad, GST_PAD_PROBE_INFO_ID (info));

  dummysrc = gst_pad_get_parent_element (pad);
  fail_if (dummysrc == NULL);

  padname = gst_pad_get_name (pad);
  GST_DEBUG_OBJECT (dummysrc, "Invoking action release-requested-pad for %s",
      padname);

  g_signal_emit_by_name (dummysrc, "release-requested-pad", padname, &success);
  fail_if (!success);

  g_object_unref (dummysrc);
  g_free (padname);

  return GST_PAD_PROBE_OK;
}
/**
 * gst_buffer_straw_stop_pipeline:
 * @bin: the pipeline previously started via gst_buffer_straw_start_pipeline()
 * @pad: the pad previously passed to gst_buffer_straw_start_pipeline()
 *
 * Set @bin to #GST_STATE_NULL and release resource allocated in
 * gst_buffer_straw_start_pipeline().
 *
 * You must have previously called gst_buffer_straw_start_pipeline() on
 * @pipeline and @pad.
 */
void
gst_buffer_straw_stop_pipeline (GstElement * bin, GstPad * pad)
{
  GstStateChangeReturn ret;

  g_mutex_lock (&lock);
  if (buf)
    gst_buffer_unref (buf);
  buf = NULL;
  gst_pad_remove_probe (pad, (guint) id);
  id = 0;
  g_cond_signal (&cond);
  g_mutex_unlock (&lock);

  ret = gst_element_set_state (bin, GST_STATE_NULL);
  fail_if (ret == GST_STATE_CHANGE_FAILURE, "Could not stop test pipeline");
  if (ret == GST_STATE_CHANGE_ASYNC) {
    ret = gst_element_get_state (bin, NULL, NULL, GST_CLOCK_TIME_NONE);
    fail_if (ret != GST_STATE_CHANGE_SUCCESS, "Could not stop test pipeline");
  }

  g_mutex_lock (&lock);
  if (buf)
    gst_buffer_unref (buf);
  buf = NULL;
  g_mutex_unlock (&lock);
}
Beispiel #5
0
static GstPadProbeReturn
buffer_probe_cb (GstPad * pad, GstPadProbeInfo * info, gpointer user_data)
{
    gboolean call;

    GST_DEBUG_OBJECT (pad, "Removing probe %lu", GST_PAD_PROBE_INFO_ID (info));

    G_LOCK (hash_mutex);
    if (!g_hash_table_contains (padhash, pad)) {
        GST_DEBUG ("Inserting %" GST_PTR_FORMAT, pad);
        g_hash_table_insert (padhash, GST_OBJECT_NAME (pad), NULL);
        G_UNLOCK (hash_mutex);
        call = g_atomic_int_dec_and_test (&counter);
    } else {
        G_UNLOCK (hash_mutex);
        call = FALSE;
    }

    gst_pad_remove_probe (pad, GST_PAD_PROBE_INFO_ID (info));

    if (call) {
        g_idle_add (recv_callback, cb_data);
    }

    return GST_PAD_PROBE_OK;
}
static void
on_demuxElementAdded (GstBin * demux, GstElement * element, gpointer user_data)
{
  GstAdaptiveDemuxTestEnginePrivate *priv =
      (GstAdaptiveDemuxTestEnginePrivate *) user_data;
  GstAdaptiveDemuxTestOutputStream *stream = NULL;
  GstPad *internal_pad;
  gchar *srcbin_name;
  gint i;

  srcbin_name = GST_ELEMENT_NAME (element);
  GST_TEST_LOCK (priv);
  for (i = 0; i < priv->engine.output_streams->len; i++) {
    stream = g_ptr_array_index (priv->engine.output_streams, i);
    if (strstr (srcbin_name, GST_PAD_NAME (stream->pad)) != NULL)
      break;
  }
  fail_unless (stream != NULL);

  /* keep the reference to the internal_pad.
   * We will need it to identify the stream in the on_demuxReceivesEvent callback
   */
  if (stream->internal_pad) {
    gst_pad_remove_probe (stream->internal_pad, stream->internal_pad_probe);
    gst_object_unref (stream->internal_pad);
  }
  internal_pad = gst_element_get_static_pad (element, "src");
  stream->internal_pad_probe =
      gst_pad_add_probe (internal_pad, GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM,
      (GstPadProbeCallback) on_demuxReceivesEvent, priv, NULL);
  stream->internal_pad = internal_pad;
  GST_TEST_UNLOCK (priv);

}
/* 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);
}
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;
}
Beispiel #9
0
static void
brasero_transcode_stop_pipeline (BraseroTranscode *transcode)
{
	BraseroTranscodePrivate *priv;
	GstPad *sinkpad;

	priv = BRASERO_TRANSCODE_PRIVATE (transcode);
	if (!priv->pipeline)
		return;

	sinkpad = gst_element_get_static_pad (priv->sink, "sink");
	if (priv->probe)
		gst_pad_remove_probe (sinkpad, priv->probe);

	gst_object_unref (sinkpad);

	gst_element_set_state (priv->pipeline, GST_STATE_NULL);
	gst_object_unref (GST_OBJECT (priv->pipeline));

	priv->link = NULL;
	priv->sink = NULL;
	priv->source = NULL;
	priv->convert = NULL;
	priv->pipeline = NULL;

	priv->set_active_state = 0;
}
static void
unblock_proxypad (GstPlaySinkConvertBin * self)
{
  if (self->sink_proxypad_block_id != 0) {
    gst_pad_remove_probe (self->sink_proxypad, self->sink_proxypad_block_id);
    self->sink_proxypad_block_id = 0;
  }
}
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);
}
Beispiel #12
0
void
kms_stats_probe_remove (KmsStatsProbe * probe)
{
  if (probe->probe_id != 0UL) {
    gst_pad_remove_probe (probe->pad, probe->probe_id);
    probe->probe_id = 0UL;
  }
}
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");
}
Beispiel #14
0
void InbandTextTrackPrivateGStreamer::disconnect()
{
    if (!m_pad)
        return;

    gst_pad_remove_probe(m_pad.get(), m_eventProbe);

    TrackPrivateBaseGStreamer::disconnect();
}
static void
cleanup_with_event (void)
{
  gst_pad_remove_probe (mysinkpad, myprobe);
  myprobe = 0;
  myreceivedevents = NULL;
  mypushedevents = NULL;

  cleanup ();
}
static GstPadProbeReturn
src_buffer_probe_cb (GstPad * pad, GstPadProbeInfo * info, gpointer user_data)
{
  GstBuffer *buffer = GST_PAD_PROBE_INFO_BUFFER (info);
  GstPad *otherpad = GST_PAD (user_data);

  if (GST_BUFFER_TIMESTAMP (buffer) == buf1.ts)
    gst_pad_remove_probe (otherpad, probe_id);

  return GST_PAD_PROBE_OK;
}
Beispiel #17
0
void
kms_utils_remb_event_manager_destroy (RembEventManager * manager)
{
  kms_utils_remb_event_manager_destroy_user_data (manager);

  gst_pad_remove_probe (manager->pad, manager->probe_id);
  g_object_unref (manager->pad);
  g_hash_table_destroy (manager->remb_hash);
  g_mutex_clear (&manager->mutex);
  g_slice_free (RembEventManager, manager);
}
static void
parsebin_pad_removed_cb (GstElement * demux, GstPad * pad, DecodebinInput * inp)
{
  GstDecodebin3 *dbin = inp->dbin;
  DecodebinInputStream *input = NULL;
  GList *tmp;
  GST_DEBUG_OBJECT (pad, "removed");

  for (tmp = dbin->input_streams; tmp; tmp = tmp->next) {
    DecodebinInputStream *cand = (DecodebinInputStream *) tmp->data;
    if (cand->srcpad == pad)
      input = cand;
  }
  /* If there are no pending pads, this means we will definitely not need this
   * stream anymore */
  if (input) {
    GST_DEBUG_OBJECT (pad, "stream %p", input);
    if (inp->pending_pads == NULL) {
      MultiQueueSlot *slot;

      GST_DEBUG_OBJECT (pad, "Remove input stream %p", input);

      SELECTION_LOCK (dbin);
      slot = get_slot_for_input (dbin, input);
      SELECTION_UNLOCK (dbin);

      remove_input_stream (dbin, input);

      SELECTION_LOCK (dbin);
      if (slot && g_list_find (dbin->slots, slot) && slot->is_drained) {
        /* if slot is still there and already drained, remove it in here */
        if (slot->output) {
          DecodebinOutputStream *output = slot->output;
          GST_DEBUG_OBJECT (pad,
              "Multiqueue was drained, Remove output stream");

          dbin->output_streams = g_list_remove (dbin->output_streams, output);
          free_output_stream (dbin, output);
        }
        GST_DEBUG_OBJECT (pad, "No pending pad, Remove multiqueue slot");
        dbin->slots = g_list_remove (dbin->slots, slot);
        free_multiqueue_slot_async (dbin, slot);
      }
      SELECTION_UNLOCK (dbin);
    } else {
      input->srcpad = NULL;
      if (input->input_buffer_probe_id)
        gst_pad_remove_probe (pad, input->input_buffer_probe_id);
      input->input_buffer_probe_id = 0;
    }
  }
}
static void
element_remove_probe (GstElement * e, const gchar * pad_name, gulong id)
{
  GstPad *pad;

  if (id == 0UL) {
    return;
  }

  pad = gst_element_get_static_pad (e, pad_name);
  gst_pad_remove_probe (pad, id);
  g_object_unref (pad);
}
Beispiel #20
0
GstPadProbeReturn MediaPlayer::cb_event_probe_toggle_splitter(GstPad *pad, GstPadProbeInfo *info, gpointer user_data)
{
    MediaPlayer * self = reinterpret_cast<MediaPlayer*>( user_data );

    // remove the probe first
    gst_pad_remove_probe( pad, GST_PAD_PROBE_INFO_ID (info) );

    // Is the element already in the bin?
    if ( self->m_gst_audio_karaokesplitter == 0 )
    {
        Logger::debug( "GstMediaPlayer:  karaokesplitter is not enabled, enabling");
        self->m_gst_audio_karaokesplitter = self->createElement ("audiokaraoke", "karaoke", false );

        // This might happen if the player requested it despite us returning no such capability
        if ( !self->m_gst_audio_karaokesplitter )
            return GST_PAD_PROBE_OK;

        // Add splitter into the bin
        gst_bin_add( GST_BIN (self->m_gst_pipeline), self->m_gst_audio_karaokesplitter );

        // Unlink the place for the splitter
        gst_element_unlink( self->m_gst_audioconverter, self->m_gst_audio_volume );

        // Link it in
        gst_element_link_many( self->m_gst_audioconverter, self->m_gst_audio_karaokesplitter, self->m_gst_audio_volume, NULL );

        // And start playing it
        gst_element_set_state( self->m_gst_audio_karaokesplitter, GST_STATE_PLAYING );

        Logger::debug( "GstMediaPlayer: karaoke splitter enabled");
    }
    else
    {
        Logger::debug( "GstMediaPlayer: karaokesplitter is enabled, disabling");

        // Stop the splitter
        gst_element_set_state( self->m_gst_audio_karaokesplitter, GST_STATE_NULL );

        // Remove splitter from the bin (it unlinks it too)
        gst_bin_remove( GST_BIN (self->m_gst_pipeline), self->m_gst_audio_karaokesplitter );
        self->m_gst_audio_karaokesplitter = 0;

        // And link the disconnected elements again
        gst_element_link_many( self->m_gst_audioconverter, self->m_gst_audio_volume, NULL );

        Logger::debug( "GstMediaPlayer: karaoke splitter disabled");
    }

    return GST_PAD_PROBE_OK;
}
Beispiel #21
0
static GstPadProbeReturn
data_probe_cb (GstPad * pad, GstPadProbeInfo * info, KmsConnectData * data)
{
  GstBuffer *buffer;
  GstMapInfo minfo;
  gchar *msg;

  buffer = GST_PAD_PROBE_INFO_BUFFER (info);

  if (!gst_buffer_map (buffer, &minfo, GST_MAP_READ)) {
    GST_ERROR_OBJECT (pad, "Failed to map input buffer");
    return GST_FLOW_ERROR;
  }

  msg = g_strndup ((const gchar *) minfo.data, minfo.size);
  GST_INFO ("Buffer content: (%s)", msg);
  g_free (msg);

  gst_buffer_unmap (buffer, &minfo);

  gst_pad_remove_probe (pad, GST_PAD_PROBE_INFO_ID (info));

  CONNECT_DATA_LOCK (data);
  if (!data->data_buff) {
    gboolean actived;

    data->data_buff = TRUE;
    CONNECT_DATA_UNLOCK (data);

    GST_DEBUG_OBJECT (data->sink, "Disabling reception of data stream");
    g_object_get (G_OBJECT (data->sink), "data", &actived, NULL);
    if (actived) {
      /* Do not accept more data */
      g_object_set (G_OBJECT (data->sink), "data", FALSE, NULL);
    } else {
      gchar *padname;
      gboolean success;

      padname = gst_pad_get_name (pad);

      g_signal_emit_by_name (data->sink, "release-requested-pad", padname,
          &success);
      fail_if (!success);
    }
  } else {
    CONNECT_DATA_UNLOCK (data);
  }

  return GST_PAD_PROBE_OK;
}
void InbandTextTrackPrivateGStreamer::disconnect()
{
    if (!m_pad)
        return;

    gst_pad_remove_probe(m_pad.get(), m_eventProbe);
    g_signal_handlers_disconnect_by_func(m_pad.get(),
        reinterpret_cast<gpointer>(textTrackPrivateEventCallback), this);

    if (m_tagTimerHandler)
        g_source_remove(m_tagTimerHandler);

    m_pad.clear();
}
static void
teardown_input_selector_with_2_streams (void)
{
  fail_unless (gst_element_set_state (selector,
          GST_STATE_NULL) == GST_STATE_CHANGE_SUCCESS, "could not set to null");

  gst_pad_remove_probe (output_pad, eos_probe);

  gst_pad_set_active (output_pad, FALSE);
  gst_check_teardown_sink_pad (selector);
  gst_check_teardown_element (selector);

  g_mutex_clear (&eos_probe_lock);
  g_cond_clear (&eos_probe_cond);
}
Beispiel #24
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->latency_probe_id > 0) {
    gst_pad_remove_probe (port_data->video_mixer_pad,
        port_data->latency_probe_id);
    port_data->latency_probe_id = 0;
  }

  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;
  }

  gst_bin_remove_many (GST_BIN (self),
      g_object_ref (port_data->capsfilter),
      g_object_ref (port_data->tee), g_object_ref (port_data->fakesink), 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->capsfilter, GST_STATE_NULL);
  gst_element_set_state (port_data->tee, GST_STATE_NULL);
  gst_element_set_state (port_data->fakesink, GST_STATE_NULL);

  g_object_unref (port_data->capsfilter);
  g_object_unref (port_data->tee);
  g_object_unref (port_data->fakesink);
  g_object_unref (port_data->tee_sink_pad);

  port_data->tee_sink_pad = NULL;
  port_data->capsfilter = NULL;
  port_data->tee = NULL;
  port_data->fakesink = NULL;

  return G_SOURCE_REMOVE;
}
static void
destroy_pad (PadInfos * infos)
{
  gst_pad_remove_probe (infos->mixer_pad, infos->probe_id);

  if (G_LIKELY (infos->bin)) {
    gst_element_set_state (infos->bin, GST_STATE_NULL);
    gst_element_unlink (infos->bin, infos->self->mixer);
    gst_bin_remove (GST_BIN (infos->self), infos->bin);
  }

  if (infos->mixer_pad) {
    gst_element_release_request_pad (infos->self->mixer, infos->mixer_pad);
    gst_object_unref (infos->mixer_pad);
  }

  g_slice_free (PadInfos, infos);
}
static void
no_more_pads_cb (GstElement * timeline, GESPipeline * self)
{
  GList *tmp;

  GST_DEBUG ("received no-more-pads");
  for (tmp = self->priv->chains; tmp; tmp = g_list_next (tmp)) {
    OutputChain *chain = (OutputChain *) tmp->data;

    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;
    }
  }
}
static GstPadProbeReturn
event_probe_cb (GstPad * pad, GstPadProbeInfo * info, gpointer user_data)
{
  GMainLoop *loop = user_data;
  GstElement *next;

  if (GST_EVENT_TYPE (GST_PAD_PROBE_INFO_DATA (info)) != GST_EVENT_EOS)
    return GST_PAD_PROBE_OK;

  gst_pad_remove_probe (pad, GST_PAD_PROBE_INFO_ID (info));

  /* push current event back into the queue */
  g_queue_push_tail (&effects, gst_object_ref (cur_effect));
  /* take next effect from the queue */
  next = g_queue_pop_head (&effects);
  if (next == NULL) {
    GST_DEBUG_OBJECT (pad, "no more effects");
    g_main_loop_quit (loop);
    return GST_PAD_PROBE_DROP;
  }

  g_print ("Switching from '%s' to '%s'..\n", GST_OBJECT_NAME (cur_effect),
      GST_OBJECT_NAME (next));

  gst_element_set_state (cur_effect, GST_STATE_NULL);

  /* remove unlinks automatically */
  GST_DEBUG_OBJECT (pipeline, "removing %" GST_PTR_FORMAT, cur_effect);
  gst_bin_remove (GST_BIN (pipeline), cur_effect);

  GST_DEBUG_OBJECT (pipeline, "adding   %" GST_PTR_FORMAT, next);
  gst_bin_add (GST_BIN (pipeline), next);

  GST_DEBUG_OBJECT (pipeline, "linking..");
  gst_element_link_many (conv_before, next, conv_after, NULL);

  gst_element_set_state (next, GST_STATE_PLAYING);

  cur_effect = next;
  GST_DEBUG_OBJECT (pipeline, "done");

  return GST_PAD_PROBE_DROP;
}
/* Create input-selector with given number of sink pads and switch
   given number of input buffers to each sink pad.
 */
static void
run_input_selector_buffer_count (gint num_input_pads,
    gint num_buffers_per_input)
{
  /* set up input_pads ! selector ! output_pad */
  gint i = 0, probe_id = 0;
  GList *input_pads = NULL, *output_pads = NULL;
  GstElement *sel = gst_check_setup_element ("input-selector");
  GstPad *output_pad = gst_check_setup_sink_pad (sel, &sinktemplate);

  output_pads = g_list_append (output_pads, output_pad);
  gst_pad_set_active (output_pad, TRUE);
  for (i = 0; i < num_input_pads; i++) {
    input_pads = g_list_append (input_pads, setup_input_pad (sel));
  }
  /* add probe */
  probe_id =
      gst_pad_add_probe (output_pad, GST_PAD_PROBE_TYPE_DATA_BOTH,
      (GstPadProbeCallback) probe_cb, NULL, NULL);
  g_object_set_data (G_OBJECT (output_pad), "probe_id",
      GINT_TO_POINTER (probe_id));

  /* run the test */
  fail_unless (gst_element_set_state (sel,
          GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
      "could not set to playing");
  push_newsegment_events (input_pads);
  push_switched_buffers (input_pads, sel, input_pads, num_buffers_per_input);
  count_output_buffers (output_pads, (num_input_pads * num_buffers_per_input));
  fail_unless (gst_element_set_state (sel,
          GST_STATE_NULL) == GST_STATE_CHANGE_SUCCESS, "could not set to null");

  /* clean up */
  gst_pad_remove_probe (output_pad, probe_id);
  gst_pad_set_active (output_pad, FALSE);
  gst_check_teardown_sink_pad (sel);
  GST_DEBUG ("setting selector pad to NULL");
  selector_set_active_pad (sel, NULL);  // unref input-selector active pad
  g_list_foreach (input_pads, (GFunc) cleanup_pad, sel);
  g_list_free (input_pads);
  g_list_free (output_pads);
  gst_check_teardown_element (sel);
}
Beispiel #29
0
static void
stop_pipeline (GstElement * element)
{
  GstBuffer *buf;

  while ((buf = g_async_queue_try_pop (pending_buffers)))
    gst_buffer_unref (buf);

  gst_pad_remove_probe (mysinkpad, id);
  id = 0;

  gst_element_set_state (element, GST_STATE_NULL);

  while ((buf = g_async_queue_try_pop (pending_buffers)))
    gst_buffer_unref (buf);

  g_async_queue_unref (pending_buffers);
  pending_buffers = NULL;
}
static void
update_video_sink (GstFPSDisplaySink * self, GstElement * video_sink)
{
  GstPad *sink_pad;

  if (self->video_sink) {

    /* remove pad probe */
    sink_pad = gst_element_get_static_pad (self->video_sink, "sink");
    gst_pad_remove_probe (sink_pad, self->data_probe_id);
    gst_object_unref (sink_pad);
    self->data_probe_id = -1;

    /* remove ghost pad target */
    gst_ghost_pad_set_target (GST_GHOST_PAD (self->ghost_pad), NULL);

    /* remove old sink */
    gst_bin_remove (GST_BIN (self), self->video_sink);
    gst_object_unref (self->video_sink);
  }

  /* create child elements */
  self->video_sink = video_sink;

  if (self->video_sink == NULL)
    return;

  fps_display_sink_update_sink_sync (self);

  /* take a ref before bin takes the ownership */
  gst_object_ref (self->video_sink);

  gst_bin_add (GST_BIN (self), self->video_sink);

  /* attach or pad probe */
  sink_pad = gst_element_get_static_pad (self->video_sink, "sink");
  self->data_probe_id = gst_pad_add_probe (sink_pad,
      GST_PAD_PROBE_TYPE_DATA_BOTH, on_video_sink_data_flow,
      (gpointer) self, NULL);
  gst_object_unref (sink_pad);
}