コード例 #1
0
ファイル: player.c プロジェクト: cyisfor/songPlayer
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);
}
コード例 #2
0
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);
}
コード例 #3
0
ファイル: compositor.c プロジェクト: FrankBau/gstreamer-imx
static void gst_imx_compositor_pad_update_canvas(GstImxCompositorPad *compositor_pad, GstImxRegion const *source_region)
{
	GstImxCompositor *compositor;
	GstVideoInfo *info = &(GST_IMXBP_VIDEO_AGGREGATOR_PAD(compositor_pad)->info);

	/* Catch redundant calls */
	if (!(compositor_pad->canvas_needs_update))
		return;

	compositor = GST_IMX_COMPOSITOR(gst_pad_get_parent_element(GST_PAD(compositor_pad)));

	/* (Re)compute the outer region */
	gst_imx_compositor_pad_compute_outer_region(compositor_pad);

	/* (Re)computer the inner region */
	gst_imx_canvas_calculate_inner_region(&(compositor_pad->canvas), info);

	/* Next, clip the canvas against the overall region,
	 * which describes the output frame's size
	 * This way, it is ensured that only the parts that are "within"
	 * the output frame are blit */
	gst_imx_canvas_clip(
		&(compositor_pad->canvas),
		&(compositor->overall_region),
		info,
		source_region,
		&(compositor_pad->source_subset)
	);

	/* Canvas updated, mark it as such */
	compositor_pad->canvas_needs_update = FALSE;

	gst_object_unref(GST_OBJECT(compositor));
}
コード例 #4
0
ファイル: bkgbin.c プロジェクト: LjsOks1/kiosk
gboolean eos_callback(GstPad *pad,
                      GstObject *parent,
                      GstEvent *event)
{
    GstEvent *seek_event;
    GstElement *bkgdec;
    GValue v=G_VALUE_INIT;
    GstPad *srcpad;
    GstIterator *srcpads;
    gboolean result;

    g_print("Decodebin received EOS. Someone should handle that...\n");
    
    bkgdec=gst_pad_get_parent_element(pad);
    if(bkgdec->numsrcpads>0) {
        srcpads=gst_element_iterate_src_pads(bkgdec);
        gst_iterator_next(srcpads,&v);
        srcpad=GST_PAD(g_value_get_object(&v));
        seek_event=gst_event_new_seek ( 1.0, GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH,
                         GST_SEEK_TYPE_SET, 0,
                         GST_SEEK_TYPE_NONE, GST_CLOCK_TIME_NONE);     
        result=gst_pad_send_event(srcpad,seek_event);
        if(result==TRUE) {
            g_print("seek event sent OK.\n");
        } else {
           g_print("seek sent FAILED.\n");
        }
        g_value_reset(&v);
        g_value_unset(&v);
        gst_iterator_free(srcpads);
        return TRUE;
    }
    return gst_pad_event_default(pad,parent,event);
}
/**
 * gst_vaapi_video_sink_lookup:
 * @element: a #GstElement
 *
 * Traverses the whole downstream elements chain and finds a suitable
 * #GstVaapiDisplay. This is a helper function for intermediate VA-API
 * elements that don't create a #GstVaapiDisplay but require one.
 * e.g. the `vaapiconvert' element.
 *
 * Return value: the #GstVaapiDisplay created by a downstream sink
 * element, or %NULL if none was found
 */
GstVaapiVideoSink *
gst_vaapi_video_sink_lookup(GstElement *element)
{
    GstVaapiVideoSink *sink = NULL;
    GstPad *pad, *peer;

    g_return_val_if_fail(GST_IS_ELEMENT(element), NULL);

    while (!sink) {
        pad = gst_element_get_static_pad(element, "src");
        if (!pad)
            break;

        peer = gst_pad_get_peer(pad);
        g_object_unref(pad);
        if (!peer)
            break;

        element = gst_pad_get_parent_element(peer);
        g_object_unref(peer);
        if (!element)
            break;

        if (GST_VAAPI_IS_VIDEO_SINK(element))
            sink = GST_VAAPI_VIDEO_SINK(element);
        g_object_unref(element);
    }
    return sink;
}
コード例 #6
0
/**
 * gst_camerabin_try_add_element:
 * @bin: tries adding an element to this bin
 * @srcpad:  src pad name, or NULL for any
 * @new_elem: new element to be added
 * @dstpad:  dst pad name, or NULL for any
 *
 * Adds given element to given @bin. Looks for an unconnected src pad
 * (with name @srcpad, if specified) from the @bin and links the element to
 * it.
 *
 * Returns: %TRUE if adding and linking succeeded, %FALSE otherwise.
 */
gboolean
gst_camerabin_try_add_element (GstBin * bin, const gchar * srcpad,
    GstElement * new_elem, const gchar * dstpad)
{
  GstPad *bin_pad;
  GstElement *bin_elem;
  gboolean ret = TRUE;

  g_return_val_if_fail (bin, FALSE);
  g_return_val_if_fail (new_elem, FALSE);

  /* Get pads for linking */
  bin_pad = gst_bin_find_unlinked_pad (bin, GST_PAD_SRC);
  /* Add to bin */
  gst_bin_add (GST_BIN (bin), new_elem);
  /* Link, if unconnected pad was found, otherwise just add it to bin */
  if (bin_pad) {
    GST_DEBUG_OBJECT (bin, "linking %s to %s:%s", GST_OBJECT_NAME (new_elem),
        GST_DEBUG_PAD_NAME (bin_pad));
    bin_elem = gst_pad_get_parent_element (bin_pad);
    gst_object_unref (bin_pad);
    if (!gst_element_link_pads_full (bin_elem, srcpad, new_elem, dstpad,
            GST_PAD_LINK_CHECK_CAPS)) {
      gst_object_ref (new_elem);
      gst_bin_remove (bin, new_elem);
      ret = FALSE;
    }
    gst_object_unref (bin_elem);
  } else {
    GST_INFO_OBJECT (bin, "no unlinked source pad in bin");
  }

  return ret;
}
コード例 #7
0
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);
  }
}
コード例 #8
0
static gboolean
remove_src_pad (gpointer user_data)
{
  GstElement *dummysrc, *bufferinjector = user_data;
  GstPad *sink = gst_element_get_static_pad (bufferinjector, "sink");
  GstPad *src;
  gboolean success = FALSE;

  fail_unless (sink);
  src = gst_pad_get_peer (sink);
  fail_unless (src);
  dummysrc = gst_pad_get_parent_element (src);

  g_signal_emit_by_name (dummysrc, "release-requested-pad",
      GST_OBJECT_NAME (src), &success);
  fail_unless (success);

  g_object_unref (src);
  g_object_unref (sink);
  g_object_unref (dummysrc);

  g_object_set_qdata (G_OBJECT (bufferinjector), disconnected_quark (),
      GINT_TO_POINTER (TRUE));

  return G_SOURCE_REMOVE;
}
コード例 #9
0
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;
}
コード例 #10
0
void AudioSourceProviderGStreamer::handleRemovedDeinterleavePad(GstPad* pad)
{
    m_deinterleaveSourcePads--;

    // Remove the queue ! appsink chain downstream of deinterleave.
    GQuark quark = g_quark_from_static_string("peer");
    GstPad* sinkPad = reinterpret_cast<GstPad*>(g_object_get_qdata(G_OBJECT(pad), quark));
    GRefPtr<GstElement> queue = adoptGRef(gst_pad_get_parent_element(sinkPad));
    GRefPtr<GstPad> queueSrcPad = adoptGRef(gst_element_get_static_pad(queue.get(), "src"));
    GRefPtr<GstPad> appsinkSinkPad = adoptGRef(gst_pad_get_peer(queueSrcPad.get()));
    GRefPtr<GstElement> sink = adoptGRef(gst_pad_get_parent_element(appsinkSinkPad.get()));
    gst_element_set_state(sink.get(), GST_STATE_NULL);
    gst_element_set_state(queue.get(), GST_STATE_NULL);
    gst_element_unlink(queue.get(), sink.get());
    gst_bin_remove_many(GST_BIN(m_audioSinkBin.get()), queue.get(), sink.get(), nullptr);
}
コード例 #11
0
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);
}
コード例 #12
0
ファイル: kmstreebin.c プロジェクト: kc7bfi/kms-core
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);
}
コード例 #13
0
ファイル: main.c プロジェクト: jcaden/tee_test
static GstPadProbeReturn
link_to_tee (GstPad * pad, GstPadProbeInfo * info, gpointer queue)
{
  GstElement *tee;

  if (gst_pad_is_linked (pad)) {
    return GST_PAD_PROBE_PASS;
  }

  GST_OBJECT_LOCK (pad);
  if (g_object_get_data (G_OBJECT (pad), "linking")) {
    GST_OBJECT_UNLOCK (pad);
    return GST_PAD_PROBE_PASS;
  }
  g_object_set_data (G_OBJECT (pad), "linking", GINT_TO_POINTER (TRUE));
  GST_OBJECT_UNLOCK (pad);

  tee = gst_pad_get_parent_element (pad);

  if (tee == NULL) {
    return GST_PAD_PROBE_PASS;
  }

  gst_element_link_pads (tee, GST_OBJECT_NAME (pad), queue, NULL);

  g_object_unref (tee);

  return GST_PAD_PROBE_REMOVE;
}
コード例 #14
0
/**
 * gst_camerabin_try_add_element:
 * @bin: tries adding an element to this bin
 * @new_elem: new element to be added
 *
 * Adds given element to given @bin. Looks for an unconnected src pad
 * from the @bin and links the element to it.
 *
 * Returns: %TRUE if adding and linking succeeded, %FALSE otherwise.
 */
gboolean
gst_camerabin_try_add_element (GstBin * bin, GstElement * new_elem)
{
  GstPad *bin_pad;
  GstElement *bin_elem;
  gboolean ret = TRUE;

  if (!bin || !new_elem) {
    return FALSE;
  }

  /* Get pads for linking */
  bin_pad = gst_bin_find_unlinked_pad (bin, GST_PAD_SRC);
  /* Add to bin */
  gst_bin_add (GST_BIN (bin), new_elem);
  /* Link, if unconnected pad was found, otherwise just add it to bin */
  if (bin_pad) {
    GST_DEBUG_OBJECT (bin, "linking %s to %s:%s", GST_OBJECT_NAME (new_elem),
        GST_DEBUG_PAD_NAME (bin_pad));
    bin_elem = gst_pad_get_parent_element (bin_pad);
    gst_object_unref (bin_pad);
    if (!gst_element_link (bin_elem, new_elem)) {
      gst_bin_remove (bin, new_elem);
      ret = FALSE;
    }
    gst_object_unref (bin_elem);
  } else {
    GST_INFO_OBJECT (bin, "no unlinked source pad in bin");
  }

  return ret;
}
コード例 #15
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);
  }
}
コード例 #16
0
ファイル: kmsagnosticbin.c プロジェクト: shelsonjava/kms-core
static GstPadProbeReturn
kms_agnostic_bin2_src_reconfigure_probe (GstPad * pad, GstPadProbeInfo * info,
    gpointer user_data)
{
  KmsAgnosticBin2 *self = KMS_AGNOSTIC_BIN2 (gst_pad_get_parent_element (pad));
  GstPadProbeReturn ret = GST_PAD_PROBE_OK;
  GstEvent *event;

  if (self == NULL) {
    return GST_PAD_PROBE_OK;
  }

  if (GST_PAD_PROBE_INFO_TYPE (info) & GST_PAD_PROBE_TYPE_EVENT_BOTH) {
    event = gst_pad_probe_info_get_event (info);

    if (GST_EVENT_TYPE (event) == GST_EVENT_RECONFIGURE) {
      KmsAgnosticBin2 *self = user_data;

      GST_DEBUG_OBJECT (pad, "Received reconfigure event");

      KMS_AGNOSTIC_BIN2_LOCK (self);
      kms_agnostic_bin2_process_pad (self, pad);
      ret = GST_PAD_PROBE_DROP;
      KMS_AGNOSTIC_BIN2_UNLOCK (self);

      goto end;
    }
  }

end:
  g_object_unref (self);

  return ret;
}
コード例 #17
0
ファイル: gstspeexenc.c プロジェクト: zsx/ossbuild
static GstCaps *
gst_speex_enc_sink_getcaps (GstPad * pad)
{
  GstCaps *caps = gst_caps_copy (gst_pad_get_pad_template_caps (pad));
  GstCaps *peercaps = NULL;
  GstSpeexEnc *enc = GST_SPEEX_ENC (gst_pad_get_parent_element (pad));

  peercaps = gst_pad_peer_get_caps (enc->srcpad);

  if (peercaps) {
    if (!gst_caps_is_empty (peercaps) && !gst_caps_is_any (peercaps)) {
      GstStructure *ps = gst_caps_get_structure (peercaps, 0);
      GstStructure *s = gst_caps_get_structure (caps, 0);
      gint rate, channels;

      if (gst_structure_get_int (ps, "rate", &rate)) {
        gst_structure_fixate_field_nearest_int (s, "rate", rate);
      }

      if (gst_structure_get_int (ps, "channels", &channels)) {
        gst_structure_fixate_field_nearest_int (s, "channels", channels);
      }
    }
    gst_caps_unref (peercaps);
  }

  gst_object_unref (enc);

  return caps;
}
コード例 #18
0
ファイル: mpf-test-eos.c プロジェクト: mdqyy/AMPF
static gboolean pad_event_handler(GstPad *pad, GstEvent *event) {
	// Establish thread-local.
	MpfComponent *component = MPF_COMPONENT(GST_OBJECT_PARENT(pad));
	mpf_component_set_curcomponent(component);
	GstElement *element = gst_pad_get_parent_element(pad);

	gchar *elementname = gst_element_get_name(element);
	gchar *padname = gst_pad_get_name(pad);
	const gchar *eventname = gst_event_type_get_name(event->type);

	MPF_PRIVATE_ALWAYS("element=%s pad=%s event=%s\n", elementname, padname,
			eventname);
	// If EOS, poke a message out of the events pad.
	if (event->type == GST_EVENT_EOS) {
		GstPad *events = gst_element_get_pad(element, "events");

		printf("GstPad *events=%p\n", events);

		GString *string = g_string_new("");
		g_string_printf(string, "%s: EOS buffer_count=%d\n", elementname,
				mpf_private.buffer_count);
		mpf_voidstar_push("events", mpf_voidstar_stralloc(string->str));
		mpf_voidstar_send_outbuffers();
		gst_pad_push_event(events, gst_event_new_eos());
	}

	g_free(elementname);
	g_free(padname);
	return gst_pad_event_default(pad, event);
}
コード例 #19
0
GstElement* tcam_gst_find_camera_src (GstElement* element)
{
    GstPad* orig_pad = gst_element_get_static_pad(element, "sink");

    GstPad* src_pad = gst_pad_get_peer(orig_pad);
    g_object_unref(orig_pad);

    if (!src_pad)
    {
        // this means we have reached a dead end where no valid tcamsrc exists
        return nullptr;
    }

    GstElement* el = gst_pad_get_parent_element(src_pad);

    gst_object_unref(src_pad);
    GstElement* ret;
    const char* name = g_type_name(gst_element_factory_get_element_type(gst_element_get_factory(el)));
    if (g_strcmp0(name, "GstTcamSrc") == 0)
    {
        return el;
    }
    ret =  tcam_gst_find_camera_src(el);

    gst_object_unref(el);

    return ret;
}
コード例 #20
0
ファイル: audiomixer.c プロジェクト: rveejay/kms-core
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;
}
コード例 #21
0
static void
debug_dump_element_pad (GstPad * pad, GstElement * element,
    GstDebugGraphDetails details, FILE * out, const gint indent)
{
  GstElement *target_element;
  GstPad *target_pad, *tmp_pad;
  GstPadDirection dir;
  gchar *element_name;
  gchar *target_element_name;
  const gchar *color_name;

  dir = gst_pad_get_direction (pad);
  element_name = debug_dump_make_object_name (GST_OBJECT (element));
  if (GST_IS_GHOST_PAD (pad)) {
    color_name =
        (dir == GST_PAD_SRC) ? "#ffdddd" : ((dir ==
            GST_PAD_SINK) ? "#ddddff" : "#ffffff");
    /* output target-pad so that it belongs to this element */
    if ((tmp_pad = gst_ghost_pad_get_target (GST_GHOST_PAD (pad)))) {
      if ((target_pad = gst_pad_get_peer (tmp_pad))) {
        gchar *pad_name, *target_pad_name;
        const gchar *spc = &spaces[MAX (sizeof (spaces) - (1 + indent * 2), 0)];

        if ((target_element = gst_pad_get_parent_element (target_pad))) {
          target_element_name =
              debug_dump_make_object_name (GST_OBJECT (target_element));
        } else {
          target_element_name = g_strdup ("");
        }
        debug_dump_pad (target_pad, color_name, target_element_name, details,
            out, indent);
        /* src ghostpad relationship */
        pad_name = debug_dump_make_object_name (GST_OBJECT (pad));
        target_pad_name = debug_dump_make_object_name (GST_OBJECT (target_pad));
        if (dir == GST_PAD_SRC) {
          fprintf (out, "%s%s_%s -> %s_%s [style=dashed, minlen=0]\n", spc,
              target_element_name, target_pad_name, element_name, pad_name);
        } else {
          fprintf (out, "%s%s_%s -> %s_%s [style=dashed, minlen=0]\n", spc,
              element_name, pad_name, target_element_name, target_pad_name);
        }
        g_free (target_pad_name);
        g_free (target_element_name);
        if (target_element)
          gst_object_unref (target_element);
        gst_object_unref (target_pad);
        g_free (pad_name);
      }
      gst_object_unref (tmp_pad);
    }
  } else {
    color_name =
        (dir == GST_PAD_SRC) ? "#ffaaaa" : ((dir ==
            GST_PAD_SINK) ? "#aaaaff" : "#cccccc");
  }
  /* pads */
  debug_dump_pad (pad, color_name, element_name, details, out, indent);
  g_free (element_name);
}
コード例 #22
0
/* XXX: this is a workaround to the absence of any proposer way to
   specify DMABUF memory capsfeatures or bufferpool option to downstream */
static gboolean
has_dmabuf_capable_peer (GstVaapiPluginBase * plugin, GstPad * pad)
{
  GstPad *other_pad = NULL;
  GstElement *element = NULL;
  gchar *element_name = NULL;
  gboolean is_dmabuf_capable = FALSE;
  gint v;

  gst_object_ref (pad);

  for (;;) {
    other_pad = gst_pad_get_peer (pad);
    gst_object_unref (pad);
    if (!other_pad)
      break;

    element = gst_pad_get_parent_element (other_pad);
    gst_object_unref (other_pad);
    if (!element)
      break;

    if (GST_IS_PUSH_SRC (element)) {
      element_name = gst_element_get_name (element);
      if (!element_name)
        break;

      if ((sscanf (element_name, "v4l2src%d", &v) != 1)
          && (sscanf (element_name, "camerasrc%d", &v) != 1))
        break;

      v = 0;
      g_object_get (element, "io-mode", &v, NULL);
      if (strncmp (element_name, "camerasrc", 9) == 0)
        is_dmabuf_capable = v == 3;
      else
        is_dmabuf_capable = v == 5;     /* "dmabuf-import" enum value */
      break;
    } else if (GST_IS_BASE_TRANSFORM (element)) {
      element_name = gst_element_get_name (element);
      if (!element_name || sscanf (element_name, "capsfilter%d", &v) != 1)
        break;

      pad = gst_element_get_static_pad (element, "sink");
      if (!pad)
        break;
    } else
      break;

    g_free (element_name);
    element_name = NULL;
    g_clear_object (&element);
  }

  g_free (element_name);
  g_clear_object (&element);
  return is_dmabuf_capable;
}
コード例 #23
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);
  }
}
コード例 #24
0
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;
}
コード例 #25
0
static void pad_added (GstElement *src, GstPad *new_pad, ServerData *app)
{
  GstElement *parent_pad = NULL;
  GstPad *sink_pad = NULL;
  GstPadLinkReturn ret;
  GstCaps *caps = NULL;
  GstStructure *pad_struct = NULL;
  gchar *src_pad_name = NULL, *sink_pad_name = NULL;
  const gchar *struct_name = NULL;
  
  caps = gst_pad_query_caps (new_pad, NULL); 
  pad_struct = gst_caps_get_structure (caps, 0);
  struct_name = gst_structure_get_name (pad_struct);

  g_debug ("Pad structure: %s\n", struct_name);

  if (strcmp (struct_name, "video/x-raw") == 0)
    sink_pad = gst_element_get_static_pad (app->v_enc_buffer, "sink");
  else if (strcmp (struct_name, "audio/x-raw") == 0)
    sink_pad = gst_element_get_static_pad (app->a_filter, "sink");
  else
    fprintf (stderr, "Cannot handle this stream: %s\n", struct_name);

  gst_caps_unref (caps);

  if (sink_pad == NULL)
    g_debug ("Could not get a pad from the encoder/muxer\n");
  else
  {
    src_pad_name = gst_pad_get_name (new_pad);
    sink_pad_name = gst_pad_get_name (sink_pad);
    parent_pad = gst_pad_get_parent_element (sink_pad);

    g_debug ("Trying to link pads:  %s[%s] --> %s[%s]: ",
        GST_ELEMENT_NAME (src), src_pad_name, 
        GST_ELEMENT_NAME (parent_pad), sink_pad_name);

    gst_object_unref (parent_pad);
    g_free (src_pad_name);
    g_free (sink_pad_name);

    ret = gst_pad_link (new_pad, sink_pad);
    if (ret != GST_PAD_LINK_OK)
    {
      g_debug ("Could not link pads (return = %d)\n", ret);
      fprintf (stderr, "Internal pipeline error\n");
    }
    else
      g_debug ("Pads linked\n");

    gst_object_unref (sink_pad);
  }       
}
コード例 #26
0
ファイル: kmsagnosticbin.c プロジェクト: shelsonjava/kms-core
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);
}
コード例 #27
0
ファイル: gstalsasink.c プロジェクト: pli3/gst-plugins-base
static gboolean
gst_alsasink_acceptcaps (GstPad * pad, GstCaps * caps)
{
    GstAlsaSink *alsa = GST_ALSA_SINK (gst_pad_get_parent_element (pad));
    GstCaps *pad_caps;
    GstStructure *st;
    gboolean ret = FALSE;
    GstRingBufferSpec spec = { 0 };

    pad_caps = gst_pad_get_caps_reffed (pad);
    if (pad_caps) {
        ret = gst_caps_can_intersect (pad_caps, caps);
        gst_caps_unref (pad_caps);
        if (!ret)
            goto done;
    }

    /* If we've not got fixed caps, creating a stream might fail, so let's just
     * return from here with default acceptcaps behaviour */
    if (!gst_caps_is_fixed (caps))
        goto done;

    /* parse helper expects this set, so avoid nasty warning
     * will be set properly later on anyway  */
    spec.latency_time = GST_SECOND;
    if (!gst_ring_buffer_parse_caps (&spec, caps))
        goto done;

    /* Make sure input is framed (one frame per buffer) and can be payloaded */
    switch (spec.type) {
    case GST_BUFTYPE_AC3:
    case GST_BUFTYPE_EAC3:
    case GST_BUFTYPE_DTS:
    case GST_BUFTYPE_MPEG:
    {
        gboolean framed = FALSE, parsed = FALSE;
        st = gst_caps_get_structure (caps, 0);

        gst_structure_get_boolean (st, "framed", &framed);
        gst_structure_get_boolean (st, "parsed", &parsed);
        if ((!framed && !parsed) || gst_audio_iec61937_frame_size (&spec) <= 0)
            goto done;
    }
    default: {
    }
    }
    ret = TRUE;

done:
    gst_caps_replace (&spec.caps, NULL);
    gst_object_unref (alsa);
    return ret;
}
コード例 #28
0
ファイル: fs-funnel.c プロジェクト: shadeslayer/farstream
static GstFlowReturn
fs_funnel_buffer_alloc (GstPad * pad, guint64 offset, guint size,
    GstCaps * caps, GstBuffer ** buf)
{
  FsFunnel *funnel = FS_FUNNEL (gst_pad_get_parent_element (pad));
  GstFlowReturn ret = GST_FLOW_OK;

  ret = gst_pad_alloc_buffer (funnel->srcpad, offset, size, caps, buf);

  gst_object_unref (funnel);

  return ret;
}
コード例 #29
0
ファイル: gstwebvttenc.c プロジェクト: madmac2501/gst-srtp
static GstFlowReturn
gst_webvtt_enc_chain (GstPad * pad, GstBuffer * buf)
{
  GstWebvttEnc *webvttenc;
  GstBuffer *new_buffer;
  gchar *timing;
  GstFlowReturn ret;

  webvttenc = GST_WEBVTT_ENC (gst_pad_get_parent_element (pad));

  if (!webvttenc->pushed_header) {
    const char *header = "WEBVTT\n\n";

    new_buffer = gst_buffer_new_and_alloc (strlen (header));
    memcpy (GST_BUFFER_DATA (new_buffer), header, strlen (header));

    GST_BUFFER_TIMESTAMP (new_buffer) = GST_CLOCK_TIME_NONE;
    GST_BUFFER_DURATION (new_buffer) = GST_CLOCK_TIME_NONE;

    ret = gst_pad_push (webvttenc->srcpad, new_buffer);
    if (ret != GST_FLOW_OK) {
      goto out;
    }

    webvttenc->pushed_header = TRUE;
  }

  gst_object_sync_values (G_OBJECT (webvttenc), GST_BUFFER_TIMESTAMP (buf));

  timing = gst_webvtt_enc_timeconvertion (webvttenc, buf);
  new_buffer =
      gst_buffer_new_and_alloc (strlen (timing) + GST_BUFFER_SIZE (buf) + 1);
  memcpy (GST_BUFFER_DATA (new_buffer), timing, strlen (timing));
  memcpy (GST_BUFFER_DATA (new_buffer) + strlen (timing), GST_BUFFER_DATA (buf),
      GST_BUFFER_SIZE (buf));
  memcpy (GST_BUFFER_DATA (new_buffer) + GST_BUFFER_SIZE (new_buffer) - 1,
      "\n", 1);
  g_free (timing);

  GST_BUFFER_TIMESTAMP (new_buffer) = GST_BUFFER_TIMESTAMP (buf);
  GST_BUFFER_DURATION (new_buffer) = GST_BUFFER_DURATION (buf);


  ret = gst_pad_push (webvttenc->srcpad, new_buffer);

out:
  gst_buffer_unref (buf);
  gst_object_unref (webvttenc);

  return ret;
}
コード例 #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);
}