static void
pad_added_cb (GstElement * uridecodebin, GstPad * pad, GstElement * encodebin)
{
    GstPad *sinkpad;

    sinkpad = gst_element_get_compatible_pad (encodebin, pad, NULL);

    if (sinkpad == NULL) {
        GstCaps *caps;

        /* Ask encodebin for a compatible pad */
        caps = gst_pad_query_caps (pad, NULL);
        g_signal_emit_by_name (encodebin, "request-pad", caps, &sinkpad);
        if (caps)
            gst_caps_unref (caps);
    }
    if (sinkpad == NULL) {
        g_print ("Couldn't get an encoding channel for pad %s:%s\n",
                 GST_DEBUG_PAD_NAME (pad));
        return;
    }

    if (G_UNLIKELY (gst_pad_link (pad, sinkpad) != GST_PAD_LINK_OK)) {
        g_print ("Couldn't link pads\n");
    }

    return;
}
Example #2
0
static gboolean rygel_wmv_transcoder_bin_autoplug_continue (RygelWMVTranscoderBin* self, GstElement* decodebin, GstPad* new_pad, GstCaps* caps) {
#line 282 "rygel-wmv-transcoder-bin.c"
	gboolean result = FALSE;
	GstPad* muxer_pad;
#line 67 "rygel-wmv-transcoder-bin.vala"
	g_return_val_if_fail (self != NULL, FALSE);
#line 67 "rygel-wmv-transcoder-bin.vala"
	g_return_val_if_fail (decodebin != NULL, FALSE);
#line 67 "rygel-wmv-transcoder-bin.vala"
	g_return_val_if_fail (new_pad != NULL, FALSE);
#line 67 "rygel-wmv-transcoder-bin.vala"
	g_return_val_if_fail (caps != NULL, FALSE);
#line 70 "rygel-wmv-transcoder-bin.vala"
	muxer_pad = _gst_object_ref0 (gst_element_get_compatible_pad (self->priv->muxer, new_pad, NULL));
#line 72 "rygel-wmv-transcoder-bin.vala"
	if (muxer_pad == NULL) {
#line 297 "rygel-wmv-transcoder-bin.c"
		result = TRUE;
		_gst_object_unref0 (muxer_pad);
#line 73 "rygel-wmv-transcoder-bin.vala"
		return result;
#line 302 "rygel-wmv-transcoder-bin.c"
	} else {
		result = gst_pad_link (new_pad, muxer_pad) != GST_PAD_LINK_OK;
		_gst_object_unref0 (muxer_pad);
#line 75 "rygel-wmv-transcoder-bin.vala"
		return result;
#line 308 "rygel-wmv-transcoder-bin.c"
	}
	_gst_object_unref0 (muxer_pad);
}
Example #3
0
void ly_mdh_push_add_id3_pad_cb(GstElement *demux, GstPad *pad,GstElement *tagger)
{
	GstPad *conn_pad = NULL;
	conn_pad = gst_element_get_compatible_pad(tagger, pad, NULL);
	gst_pad_link(pad, conn_pad);
	gst_object_unref(conn_pad);
}
Example #4
0
void
TapeComposition::onPadAdded( GstElement *src, GstPad *new_pad, GstElement *sink )
{
	GstPad *compatiblePad = gst_element_get_compatible_pad( sink, new_pad, gst_pad_get_caps( new_pad ) );

	if ( compatiblePad )
		gst_pad_link( new_pad, compatiblePad );
}
Example #5
0
bool GstUtils::link_static_to_request(GstPad * srcpad, GstElement *sink) {
  GstPad *sinkpad = gst_element_get_compatible_pad(sink,
                                                   srcpad,
                                                   nullptr);  // const GstCaps *caps to use as a filter
  bool res = GstUtils::check_pad_link_return(gst_pad_link(srcpad, sinkpad));

  if (GST_IS_PAD(sinkpad))
    gst_object_unref(sinkpad);

  return res;
}
Example #6
0
/**
 * 链接元素.
 */
void SoundSystem::LinkElement(GData **eltset, GstPad *pad)
{
        GstElement *volume;
        GstCaps *caps;
        GstStructure *str;
        GstPad *spad;

        caps = gst_pad_query_caps(pad, NULL);
        str = gst_caps_get_structure(caps, 0);
        volume = GST_ELEMENT(g_datalist_get_data(eltset, "volume-element"));
        if(strcasestr(gst_structure_get_name(str), "audio")
                 &&(spad = gst_element_get_compatible_pad(volume, pad, caps)))
                gst_pad_link(pad, spad);
        gst_caps_unref(caps);
}
Example #7
0
static void rc_plugin_tag_writer_pad_added_cb(GstElement *demux, GstPad *pad,
    GstElement *tagger)
{
    GstCaps *caps;
    GstPad *conn_pad = NULL;
    caps = gst_pad_get_caps (pad);
    conn_pad = gst_element_get_compatible_pad(tagger, pad, NULL);
    gst_pad_link(pad, conn_pad);
    gst_object_unref(conn_pad);
    if(tag_src_path!=NULL)
    {
        g_free(tag_src_path);
        tag_src_path = NULL;
    }
    if(tag_target_path!=NULL)
    {
        g_free(tag_target_path);
        tag_target_path = NULL;
    }
}
Example #8
0
gboolean
shmdata_base_reader_attach (shmdata_base_reader_t *reader)
{
    g_mutex_lock (&reader->mutex_);
    if (reader->attached_)
    {
        g_mutex_unlock (&reader->mutex_);
        return FALSE;
    }
    reader->attached_ = TRUE;
    reader->source_ = gst_element_factory_make ("shmsrc", NULL);
    reader->deserializer_ = gst_element_factory_make ("gdpdepay", NULL);
    GstPad *pad = gst_element_get_static_pad(reader->deserializer_, "src");
    gst_pad_add_data_probe (pad,
                            G_CALLBACK (shmdata_base_reader_reset_time),
                            reader);
    gst_object_unref(pad);
    reader->typefind_ = gst_element_factory_make ("typefind", NULL);
    if (NULL == reader->typefind_) {
        g_warning ("no typefind !");
        g_mutex_unlock (&reader->mutex_);
        return FALSE;
    }
    reader->have_type_handler_id_ =
        g_signal_connect (reader->typefind_,
                          "have-type",
                          G_CALLBACK (shmdata_base_reader_on_type_found),
                          reader);
    if (reader->do_absolute_)
        reader->timereset_ = FALSE;
    if (!reader->source_)
    {
        g_critical ("Reader: \"shmsrc\" element could not be created");
        g_mutex_unlock (&reader->mutex_);
        return FALSE;
    }
    if (!reader->deserializer_)
    {
        g_critical ("Reader: \"gdpdepay\" element could not be created.");
        g_mutex_unlock (&reader->mutex_);
        return FALSE;
    }
    if (!reader->typefind_)
    {
        g_critical ("Reader: \"typefind\" element could not be created.");
        g_mutex_unlock (&reader->mutex_);
        return FALSE;
    }
    g_object_set_data (G_OBJECT (reader->source_),
                       "shmdata_base_reader",
                       (gpointer)reader);
    g_object_set_data (G_OBJECT (reader->deserializer_),
                       "shmdata_base_reader",
                       (gpointer)reader);
    g_object_set (G_OBJECT (reader->source_), "socket-path",
                  reader->socket_name_, NULL);
    gst_bin_add_many (GST_BIN (reader->bin_),
                      reader->source_, reader->deserializer_, reader->typefind_, NULL);
    GstPad *src_pad = gst_element_get_static_pad (reader->typefind_,
                      "src");
    GstPad *sink_pad = gst_element_get_compatible_pad (reader->sink_,
                       src_pad,
                       GST_PAD_CAPS(src_pad));
    gst_element_link_many (reader->source_,
                           reader->deserializer_,
                           reader->typefind_,
                           NULL);
    gst_pad_link (src_pad, sink_pad);
    gst_object_unref(sink_pad);
    gst_object_unref(src_pad);
    gst_element_set_state (reader->typefind_,GST_STATE_TARGET(reader->bin_));
    gst_element_set_state (reader->deserializer_,GST_STATE_TARGET(reader->bin_));
    gst_element_set_state (reader->source_,GST_STATE_TARGET(reader->bin_));
    g_mutex_unlock (&reader->mutex_);
    return FALSE; //for g_idle_add
}
static gboolean
pad_added_cb (GstElement * element, GstPad * new_pad, InsanityTest * test)
{
  GstPadLinkReturn linkret;

  GstIterator *it = NULL;
  GstCaps *caps = NULL;
  gboolean ret = TRUE;

  GstPad *mqsinkpad = NULL, *mqsrcpad = NULL, *ssinkpad =
      NULL, *suboverlaysinkpad = NULL;

  SUBTITLES_TEST_LOCK ();

  /* First check if the pad caps are compatible with the suboverlay */
  caps = gst_pad_get_current_caps (new_pad);
  suboverlaysinkpad = gst_element_get_compatible_pad (glob_suboverlay, new_pad,
      caps);

  if (suboverlaysinkpad == NULL) {
    LOG (test,
        "Pad %" GST_PTR_FORMAT " with caps %" GST_PTR_FORMAT " Not usefull",
        new_pad, caps);
    goto error;
  }

  glob_sub_found = TRUE;
  insanity_test_validate_checklist_item (test, "testing-subtitles", TRUE, NULL);

  /* Link to the decoder */
  linkret = gst_pad_link (new_pad, suboverlaysinkpad);
  if (linkret != GST_PAD_LINK_OK) {
    ERROR (test, "Getting linking %" GST_PTR_FORMAT " with %" GST_PTR_FORMAT,
        mqsrcpad, suboverlaysinkpad);
    goto error;
  }

  LOG (test, "Pad %" GST_PTR_FORMAT " with caps %" GST_PTR_FORMAT " linked,"
      " and ready to be tested", new_pad, caps);

done:
  SUBTITLES_TEST_UNLOCK ();

  if (it)
    gst_iterator_free (it);

  if (suboverlaysinkpad)
    gst_object_unref (suboverlaysinkpad);

  if (caps)
    gst_caps_unref (caps);

  if (mqsinkpad)
    gst_object_unref (mqsinkpad);

  if (ssinkpad)
    gst_object_unref (ssinkpad);

  return ret;

error:
  ret = FALSE;
  goto done;
}
Example #10
0
int main(int argc, char * argv[])
{
    GMainLoop *loop;
    GstElement *pipeline, *sink, *mux;
    GstElement *vsrc[NR_PROG];
    GstElement *asrc[NR_PROG];
    GstElement *vparse[NR_PROG];
    GstElement *vdemux[NR_PROG];
    GstElement *aparse[NR_PROG];
    GstPad *tl_pad, *pad;
    GstStructure *pm;
    GstBus *bus;

    FILE * xml_of;

    gchar vname[][60] = {
	"/Users/lyang/src/res/mpts.test/mpts110.mpv",
	"/Users/lyang/src/res/mpts.test/mpts120.mpv",
	"/Users/lyang/src/res/mpts.test/mpts130.mpv",
	"/Users/lyang/src/res/mpts.test/mpts140.mpv",
	"/Users/lyang/src/res/mpts.test/mpts150.mpv",
	"/Users/lyang/src/res/mpts.test/mpts160.mpv",
	"/Users/lyang/src/res/mpts.test/mpts170.mpv"
    };
    gchar aname[][60] = {
	"/Users/lyang/src/res/mpts.test/mpts113.mpa",
	"/Users/lyang/src/res/mpts.test/mpts123.mpa",
	"/Users/lyang/src/res/mpts.test/mpts133.mpa",
	"/Users/lyang/src/res/mpts.test/mpts143.mpa",
	"/Users/lyang/src/res/mpts.test/mpts153.mpa",
	"/Users/lyang/src/res/mpts.test/mpts163.mpa",
	"/Users/lyang/src/res/mpts.test/mpts173.mpa"
    };
    gchar dest_dir[60];
    gchar dest_xml[60];

    gint i;

    gst_init (&argc, &argv);
    loop = g_main_loop_new (NULL, FALSE);

    pipeline = gst_pipeline_new ("mpeg-ts-muxer");
    mux = gst_element_factory_make ("mpegtsmux", "muxer");
    sink = gst_element_factory_make ("filesink", "sink");
    if (!pipeline || !mux || !sink) {
	g_printerr ( "Some element could not be created.\n");
	return -1;
    }

    for(i = 0; i< NR_PROG; i++)
    {
	vsrc[i] = gst_element_factory_make ("filesrc", NULL);
	vdemux[i] = gst_element_factory_make ("mpegpsdemux", NULL);
	vparse[i] = gst_element_factory_make ("mpegvideoparse", NULL);

	asrc[i] = gst_element_factory_make ("filesrc", NULL);
	aparse[i] = gst_element_factory_make ("mp3parse", NULL);

	if (!vsrc[i] || !vparse[i] || !vdemux[i] ||!asrc[i] || !aparse[i])
	{
	    g_printerr ( "Some element could not be created. i=%d.\n", i);
	    return -1;
	}
    }

    /* Setting paths */ 
    for(i = 0; i< NR_PROG; i++)
    {
	g_object_set (G_OBJECT (vsrc[i]), "location", vname[i], NULL);
	g_object_set (G_OBJECT (asrc[i]), "location", aname[i], NULL);
    }

    sprintf (dest_dir, "/Users/lyang/src/res/mpts.test/mpts_%02d.ts", NR_PROG);
    g_object_set (G_OBJECT (sink), "location", dest_dir, NULL);

    /* construct the pipeline */ 
    gst_bin_add_many (GST_BIN (pipeline), mux, sink, NULL);
    gst_element_link (mux, sink);
    for(i = 0; i< NR_PROG; i++)
    {
	gst_bin_add_many (GST_BIN (pipeline), vsrc[i], vdemux[i], vparse[i],
		NULL);
	gst_element_link (vsrc[i], vdemux[i]);

	g_signal_connect (vdemux[i], "pad-added", G_CALLBACK (on_pad_added),
		vparse[i]);

	gst_bin_add_many (GST_BIN (pipeline), asrc[i], aparse[i], NULL);
	gst_element_link (asrc[i], aparse[i]);
    }

    /* construct the program map */ 
    pm = gst_structure_empty_new ("program_map");
    
    /* Program 1 */ 
    for(i = 0; i< NR_PROG; i++)
    {
	/* vparse <-> mux */ 
	tl_pad = gst_element_get_static_pad (vparse[i], "src");
	if (tl_pad == NULL) {
	    g_printerr ("vparse[%d] src pad getting failed.\n", i);
	    return -1;
	}
	pad = gst_element_get_compatible_pad (mux, tl_pad, NULL);
	gst_pad_link (tl_pad, pad);
	gst_structure_set (pm,
		gst_pad_get_name(pad), G_TYPE_INT, i, NULL);
	gst_object_unref (GST_OBJECT (tl_pad));
	gst_object_unref (GST_OBJECT (pad));

	/* aparse <-> mux */ 
	tl_pad = gst_element_get_static_pad (aparse[i], "src");
	if (tl_pad == NULL) {
	    g_printerr ("aparse[%d] src pad getting failed.\n", i);
	    return -1;
	}
	pad = gst_element_get_compatible_pad (mux, tl_pad, NULL);
	gst_pad_link (tl_pad, pad);
	gst_structure_set (pm,
		gst_pad_get_name(pad), G_TYPE_INT, i, NULL);
	gst_object_unref (GST_OBJECT (tl_pad));
	gst_object_unref (GST_OBJECT (pad));
    }

    /* set the program map */ 
    g_object_set (G_OBJECT(mux), "prog-map", pm, NULL);

    bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
    gst_bus_add_watch (bus, bus_call, loop);
    gst_object_unref (bus);

    /* Write the pipeline to XML */ 
    sprintf (dest_xml, "/Users/lyang/src/res/mpts.test/mpts_%02d.xml", NR_PROG);
    xml_of = fopen (dest_xml, "w");
    gst_xml_write_file (GST_ELEMENT (pipeline), xml_of);

    g_print ("Now playing: %s\n", dest_dir);
    gst_element_set_state (pipeline, GST_STATE_PLAYING);

    /* Run! */ 
    g_print ("Running...\n");
    g_main_loop_run (loop);

    /* Out of the main loop, clean up nicely */
    g_print ("Returned, stopping playback\n");
    gst_element_set_state (pipeline, GST_STATE_NULL);

    g_print ("Deleting pipeline\n");
    gst_object_unref (GST_OBJECT (pipeline));

    return 0;

}
static gboolean
pad_added_cb (GstElement * element, GstPad * new_pad, InsanityTest * test)
{
  GstElement *fakesink;
  GstPadTemplate *mqsinktmpl;
  GstPadLinkReturn linkret;

  GstIterator *it = NULL;
  GstCaps *caps = NULL;
  gboolean ret = TRUE;

  gulong probe_id;
  GstPad *mqsinkpad = NULL, *mqsrcpad = NULL, *ssinkpad = NULL, *decodesinkpad =
      NULL, *decodesrcpad = NULL, *tmppad;

  DECODER_TEST_LOCK ();

  /* First check if the pad caps are compatible with the decoder or the parser */
  caps = gst_pad_get_current_caps (new_pad);
  if (glob_parser)
    decodesinkpad = gst_element_get_compatible_pad (glob_parser, new_pad, caps);
  else
    decodesinkpad =
        gst_element_get_compatible_pad (glob_decoder, new_pad, caps);

  if (decodesinkpad == NULL)
    goto error;

  mqsinktmpl =
      gst_element_class_get_pad_template (GST_ELEMENT_GET_CLASS
      (glob_multiqueue), "sink%d");

  if (mqsinktmpl == NULL)
    goto error;

  mqsinkpad = gst_element_request_pad (glob_multiqueue, mqsinktmpl, NULL, NULL);

  it = gst_pad_iterate_internal_links (mqsinkpad);
  if (!it || (gst_iterator_next (it, (gpointer) & mqsrcpad)) != GST_ITERATOR_OK
      || mqsrcpad == NULL) {
    ERROR (test, "Couldn't get srcpad from multiqueue for sinkpad %"
        GST_PTR_FORMAT, mqsinkpad);

    goto error;
  }

  /* Finnish creating and add to bin */
  fakesink = gst_element_factory_make ("fakesink", NULL);
  gst_bin_add (GST_BIN (glob_pipeline), fakesink);
  gst_element_sync_state_with_parent (fakesink);
  gst_element_sync_state_with_parent (glob_decoder);

  linkret = gst_pad_link (new_pad, mqsinkpad);
  if (linkret != GST_PAD_LINK_OK) {
    ERROR (test, "Getting linking %" GST_PTR_FORMAT " with %" GST_PTR_FORMAT,
        new_pad, mqsinkpad);
    goto error;
  }

  /* Link to the decoder */
  linkret = gst_pad_link (mqsrcpad, decodesinkpad);
  if (linkret != GST_PAD_LINK_OK) {
    ERROR (test, "Getting linking %" GST_PTR_FORMAT " with %" GST_PTR_FORMAT,
        mqsrcpad, decodesinkpad);
    goto error;
  }

  if (glob_parser) {
    if (!gst_element_link (glob_parser, glob_decoder)) {
      ERROR (test, "Linking parser with decoder");
      goto error;
    }
  }

  /* Now link to the faksink */
  decodesrcpad = gst_element_get_static_pad (glob_decoder, "src");
  if (decodesrcpad == NULL) {
    ERROR (test, "Getting decoder srcpad");
    goto error;
  }

  ssinkpad = gst_element_get_static_pad (fakesink, "sink");
  if (ssinkpad == NULL) {
    ERROR (test, "Getting fakesink sinkpad");
    goto error;
  }

  linkret = gst_pad_link (decodesrcpad, ssinkpad);
  if (linkret != GST_PAD_LINK_OK) {
    ERROR (test, "Getting linking %" GST_PTR_FORMAT " with %" GST_PTR_FORMAT,
        decodesrcpad, ssinkpad);
    goto error;
  }

  /* And install a probe to the decoder src pad */
  if (insanity_gst_test_add_data_probe (INSANITY_GST_TEST (test),
          GST_BIN (glob_pipeline), GST_OBJECT_NAME (glob_decoder),
          GST_ELEMENT_NAME (decodesrcpad), &tmppad, &probe_id,
          &probe_cb, NULL, NULL) == TRUE) {

    glob_prob_ctx = g_slice_new0 (ProbeContext);
    glob_prob_ctx->probe_id = probe_id;
    glob_prob_ctx->pad = tmppad;
    glob_prob_ctx->decoder = glob_decoder;
    glob_prob_ctx->fakesink = fakesink;
    glob_prob_ctx->test = test;

    insanity_test_validate_checklist_item (test, "install-probes", TRUE, NULL);
  } else {
    insanity_test_validate_checklist_item (test,
        "install-probes", FALSE, "Failed to attach probe to fakesink");

    /* No reason to keep the test alive if there is a probe we can't add */
    insanity_test_done (test);
    goto error;
  }

  if (glob_media_desc_parser)
    media_descriptor_parser_add_stream (glob_media_desc_parser, new_pad);

done:
  DECODER_TEST_UNLOCK ();

  if (it)
    gst_iterator_free (it);

  if (decodesinkpad)
    gst_object_unref (decodesinkpad);

  if (caps)
    gst_caps_unref (caps);

  if (mqsinkpad)
    gst_object_unref (mqsinkpad);

  if (ssinkpad)
    gst_object_unref (ssinkpad);

  return ret;

error:
  ret = FALSE;
  goto done;
}