RosGstPlay()
      {
        GstPad *audiopad;

        std::string dst_type;

        // The destination of the audio
        ros::param::param<std::string>("~dst", dst_type, "alsasink");

        _sub = _nh.subscribe("audio", 10, &RosGstPlay::onAudio, this);

        _loop = g_main_loop_new(NULL, false);

        _pipeline = gst_pipeline_new("app_pipeline");
        _source = gst_element_factory_make("appsrc", "app_source");
        gst_bin_add( GST_BIN(_pipeline), _source);

        //_playbin = gst_element_factory_make("playbin2", "uri_play");
        //g_object_set( G_OBJECT(_playbin), "uri", "file:///home/test/test.mp3", NULL);
        if (dst_type == "alsasink")
        {
          _decoder = gst_element_factory_make("decodebin", "decoder");
          g_signal_connect(_decoder, "new-decoded-pad", G_CALLBACK(cb_newpad),this);
          gst_bin_add( GST_BIN(_pipeline), _decoder);
          gst_element_link(_source, _decoder);

          _audio = gst_bin_new("audiobin");
          _convert = gst_element_factory_make("audioconvert", "convert");
          audiopad = gst_element_get_static_pad(_convert, "sink");
          _sink = gst_element_factory_make("alsasink", "sink");
          gst_bin_add_many( GST_BIN(_audio), _convert, _sink, NULL);
          gst_element_link(_convert, _sink);
          gst_element_add_pad(_audio, gst_ghost_pad_new("sink", audiopad));
          gst_object_unref(audiopad);

          gst_bin_add(GST_BIN(_pipeline), _audio);
          
        }
        else
        {
          _sink = gst_element_factory_make("filesink", "sink");
          g_object_set( G_OBJECT(_sink), "location", dst_type.c_str(), NULL);
          gst_bin_add(GST_BIN(_pipeline), _sink);
          gst_element_link(_source, _sink);
        }

        gst_element_set_state(GST_ELEMENT(_pipeline), GST_STATE_PLAYING);
        //gst_element_set_state(GST_ELEMENT(_playbin), GST_STATE_PLAYING);

        _gst_thread = boost::thread( boost::bind(g_main_loop_run, _loop) );
      }
Beispiel #2
0
static GstElement *
create_default_video_src(PurpleMedia *media,
		const gchar *session_id, const gchar *participant)
{
	GstElement *sendbin, *src, *videoscale, *capsfilter;
	GstPad *pad;
	GstPad *ghost;
	GstCaps *caps;

#ifdef _WIN32
	/* autovideosrc doesn't pick ksvideosrc for some reason */
	src = gst_element_factory_make("ksvideosrc", NULL);
	if (src == NULL)
		src = gst_element_factory_make("dshowvideosrc", NULL);
	if (src == NULL)
		src = gst_element_factory_make("autovideosrc", NULL);
#else
	src = gst_element_factory_make("gconfvideosrc", NULL);
	if (src == NULL)
		src = gst_element_factory_make("autovideosrc", NULL);
	if (src == NULL)
		src = gst_element_factory_make("v4l2src", NULL);
	if (src == NULL)
		src = gst_element_factory_make("v4lsrc", NULL);
#endif
	if (src == NULL) {
		purple_debug_error("gtkmedia", "Unable to find a suitable "
				"element for the default video source.\n");
		return NULL;
	}

	sendbin = gst_bin_new("pidgindefaultvideosrc");
	videoscale = gst_element_factory_make("videoscale", NULL);
	capsfilter = gst_element_factory_make("capsfilter", NULL);

	/* It was recommended to set the size <= 352x288 and framerate <= 20 */
	caps = gst_caps_from_string("video/x-raw-yuv , width=[250,352] , "
			"height=[200,288] , framerate=[1/1,20/1]");
	g_object_set(G_OBJECT(capsfilter), "caps", caps, NULL);

	gst_bin_add_many(GST_BIN(sendbin), src,
			videoscale, capsfilter, NULL);
	gst_element_link_many(src, videoscale, capsfilter, NULL);

	pad = gst_element_get_static_pad(capsfilter, "src");
	ghost = gst_ghost_pad_new("ghostsrc", pad);
	gst_object_unref(pad);
	gst_element_add_pad(sendbin, ghost);

	return sendbin;
}
Beispiel #3
0
void		ly_ppl_init		()
{
	GstElement* playbin=NULL;
	GstElement* equalizer=NULL;
	GstElement* convert=NULL;
	GstElement* volume=NULL;
	GstElement* audiosink=NULL;
	GstElement* fakesink=NULL;
	GstPad*     mpad;
	GstBus* bus=NULL;

	playbin=gst_element_factory_make("playbin", "playbin");
	equalizer=gst_element_factory_make("equalizer-10bands","equalizer");
	volume= gst_element_factory_make("volume","volume");
	convert=gst_element_factory_make("audioconvert","autoconvert");
	audiosink=gst_element_factory_make("autoaudiosink","autoaudiosink");
	fakesink=gst_element_factory_make("fakesink","fakesink");
	
	bus=gst_pipeline_get_bus(GST_PIPELINE(playbin));
	gst_element_set_state(playbin,GST_STATE_NULL);
	gst_bus_add_watch(bus,(GstBusFunc)ly_ppl_bus_cb, NULL);
	gst_object_unref(bus);
	
	ly_ppl_audio_bin=gst_bin_new("audio-bin");
	gst_bin_add_many(GST_BIN(ly_ppl_audio_bin),equalizer,convert,volume,audiosink,NULL);
	gst_element_link_many(equalizer,convert,volume,audiosink,NULL);
	mpad = gst_element_get_static_pad(equalizer, "sink");
	gst_element_add_pad(ly_ppl_audio_bin, gst_ghost_pad_new(NULL,mpad));
	g_object_set(G_OBJECT(playbin),"audio-sink",ly_ppl_audio_bin,NULL);
	
	ly_ppl_video_bin=gst_bin_new("video-bin");
	gst_bin_add_many(GST_BIN(ly_ppl_video_bin), fakesink,NULL);
	mpad = gst_element_get_static_pad(fakesink, "sink");
	gst_element_add_pad(ly_ppl_video_bin, gst_ghost_pad_new(NULL,mpad));
	g_object_set(G_OBJECT(playbin),"video-sink",ly_ppl_video_bin,NULL);
	
	ly_ppl_playbin=playbin;
}
bool GstEnginePipeline::ReplaceDecodeBin(const QUrl& url) {
  GstElement* new_bin = nullptr;

#ifdef HAVE_SPOTIFY
  if (url.scheme() == "spotify") {
    new_bin = gst_bin_new("spotify_bin");

    // Create elements
    GstElement* src = engine_->CreateElement("tcpserversrc", new_bin);
    if (!src) return false;
    GstElement* gdp = engine_->CreateElement("gdpdepay", new_bin);
    if (!gdp) return false;

    // Pick a port number
    const int port = Utilities::PickUnusedPort();
    g_object_set(G_OBJECT(src), "host", "127.0.0.1", nullptr);
    g_object_set(G_OBJECT(src), "port", port, nullptr);

    // Link the elements
    gst_element_link(src, gdp);

    // Add a ghost pad
    GstPad* pad = gst_element_get_static_pad(gdp, "src");
    gst_element_add_pad(GST_ELEMENT(new_bin), gst_ghost_pad_new("src", pad));
    gst_object_unref(GST_OBJECT(pad));

    // Tell spotify to start sending data to us.
    SpotifyServer* spotify_server =
        InternetModel::Service<SpotifyService>()->server();
    // Need to schedule this in the spotify server's thread
    QMetaObject::invokeMethod(
        spotify_server, "StartPlayback", Qt::QueuedConnection,
        Q_ARG(QString, url.toString()), Q_ARG(quint16, port));
  } else {
#endif
    new_bin = engine_->CreateElement("uridecodebin");
    if (!new_bin) return false;
    g_object_set(G_OBJECT(new_bin), "uri", url.toEncoded().constData(),
                 nullptr);
    CHECKED_GCONNECT(G_OBJECT(new_bin), "drained", &SourceDrainedCallback,
                     this);
    CHECKED_GCONNECT(G_OBJECT(new_bin), "pad-added", &NewPadCallback, this);
    CHECKED_GCONNECT(G_OBJECT(new_bin), "notify::source", &SourceSetupCallback,
                     this);
#ifdef HAVE_SPOTIFY
  }
#endif

  return ReplaceDecodeBin(new_bin);
}
Beispiel #5
0
/* Creates simple bin that plays a background JPEG image or sequence 
*  with 30fps. Should be used as the first input of the video mixer. 
*  Scaling should be set when linked to the mixer element! 
*  bin elements : multifilesrc ! jpegdec ! videoscale ! queue
*  src ghost pad is added as an output to the bin.*/
GstElement* bkgbin_new(CustomData *data)
{
   GstElement *bkgbin,*bkgsrc,*bkgdec,*bkgscale,*bkgqueue,*bkgfreeze;
   GstCaps *freeze_caps,*scale_caps;
   GstPad *pad,*dec_pad_sink;
   //Create bin, elements, caps and link everything.
   bkgbin=gst_bin_new("bkgbin");
   bkgsrc=gst_element_factory_make("multifilesrc","bkgsrc");
   bkgdec=gst_element_factory_make("jpegdec","bkgdec");
   bkgfreeze=gst_element_factory_make("imagefreeze","bkgfreeze");
   bkgscale=gst_element_factory_make("videoscale","bkgscale");
   bkgqueue=gst_element_factory_make("queue","bkgqueue");
   gst_bin_add_many(GST_BIN(bkgbin),bkgsrc,bkgdec,bkgscale,bkgqueue,bkgfreeze,NULL);
   freeze_caps=gst_caps_new_simple("video/x-raw",
                                "framerate",GST_TYPE_FRACTION,FRAMES_PER_SEC,1,
                                NULL);
   scale_caps=gst_caps_new_simple("video/x-raw",
//                                "format",G_TYPE_STRING,"YUV",
//                                "alpha",G_TYPE_INT,0,
//                                "framerate",GST_TYPE_FRACTION,FRAMES_PER_SEC,1,
                                "width",G_TYPE_INT,CAMERA_RES_WIDTH,
                                "height",G_TYPE_INT,CAMERA_RES_HEIGHT,
                                NULL);
//   gst_element_link(bkgsrc,bkgdec);
   gst_element_link_many(bkgsrc,bkgdec,NULL);
   /* decodebin's src pad is a sometimes pad - it gets created dynamically */
//   g_signal_connect(bkgdec,"pad-added",G_CALLBACK(on_new_decoded_pad),bkgscale);
   gst_element_link(bkgdec,bkgscale);
   gst_element_link_filtered(bkgscale,bkgfreeze,scale_caps);
   gst_element_link_filtered(bkgfreeze,bkgqueue,freeze_caps);
//   gst_element_link_filtered(bkgscale,bkgqueue,scale_caps);
   gst_caps_unref(scale_caps);
   gst_caps_unref(freeze_caps);
   //Create the ghost src pad for the bin.
   pad=gst_element_get_static_pad(bkgqueue,"src");
   gst_element_add_pad(bkgbin,gst_ghost_pad_new("src",pad));
   gst_object_unref(pad);
   
   /* set initial parameters */
   g_object_set(G_OBJECT(bkgsrc),"location",data->config[data->selected_config].background,
          "loop",TRUE,NULL);
//   g_object_set(G_OBJECT(bkgqueue),"leaky",2,NULL);
   
   /* set eos handler function */
   dec_pad_sink=gst_element_get_static_pad(bkgdec,"sink");
//   gst_pad_set_event_function(dec_pad_sink,eos_callback);

   return bkgbin;
}
/* dynamically add the source to the pipeline and link it to a new pad on
 * adder */
static SourceInfo *
add_source (gdouble freq, gfloat pos)
{
  SourceInfo *info;

  info = g_new0 (SourceInfo, 1);
  info->freq = freq;
  info->pos = pos;

  /* make source with unique name */
  info->bin = gst_element_factory_make ("bin", NULL);
  info->src = gst_element_factory_make ("audiotestsrc", NULL);
  info->fx = gst_element_factory_make ("audiopanorama", NULL);

  g_object_set (info->src, "freq", freq, "volume", (gdouble) 0.35, NULL);
  g_object_set (info->fx, "panorama", pos, NULL);

  /* add to the bin */
  gst_bin_add (GST_BIN (info->bin), info->src);
  gst_bin_add (GST_BIN (info->bin), info->fx);

  /* get pads from the elements */
  info->src_srcpad = gst_element_get_static_pad (info->src, "src");
  info->fx_srcpad = gst_element_get_static_pad (info->fx, "src");
  info->fx_sinkpad = gst_element_get_static_pad (info->fx, "sink");

  /* create and add a pad for the bin */
  info->bin_srcpad = gst_ghost_pad_new ("src", info->fx_srcpad);
  gst_element_add_pad (info->bin, info->bin_srcpad);

  /* get new pad from adder, adder will now wait for data on this pad */
  info->adder_sinkpad = gst_element_get_request_pad (adder, "sink_%u");

  /* link inside the bin */
  gst_pad_link (info->src_srcpad, info->fx_sinkpad);

  /* add bin to pipeline */
  gst_bin_add (GST_BIN (pipeline), info->bin);

  /* link bin to adder */
  gst_pad_link (info->bin_srcpad, info->adder_sinkpad);

  /* and play the elements */
  gst_element_set_state (info->bin, GST_STATE_PLAYING);

  g_print ("added  freq %5.0f, pos %3.1f\n", info->freq, info->pos);

  return info;
}
GstElement* VolumeFaderEffect::createEffectBin()
{
    GstElement *audioBin = gst_bin_new(NULL);

    // We need a queue to handle tee-connections from parent node
    GstElement *queue = gst_element_factory_make("queue", NULL);
    gst_bin_add(GST_BIN(audioBin), queue);

    GstElement *mconv = gst_element_factory_make("audioconvert", NULL);
    gst_bin_add(GST_BIN(audioBin), mconv);
    gst_bin_add(GST_BIN(audioBin), effectElement());

    // Link src pad
    GstPad *srcPad = gst_element_get_static_pad(effectElement(), "src");
    gst_element_add_pad(audioBin, gst_ghost_pad_new("src", srcPad));
    gst_object_unref(srcPad);

    // Link sink pad
    gst_element_link_many(queue, mconv, effectElement(), NULL);
    GstPad *sinkpad = gst_element_get_static_pad(queue, "sink");
    gst_element_add_pad(audioBin, gst_ghost_pad_new("sink", sinkpad));
    gst_object_unref(sinkpad);
    return audioBin;
}
Beispiel #8
0
VideoCompositor::VideoCompositor(RecorderPipeline *pipeline) :
    numSink(0)
{
    bin = gst_bin_new(NULL);
    pipeline->addToPipeline(GST_ELEMENT(gst_object_ref(bin)));

    videomixer = gst_element_factory_make("videomixer", NULL);
    gst_bin_add(GST_BIN(bin), videomixer);

    g_object_set(videomixer, "background", 1, NULL);

    GstPad *pad = gst_element_get_static_pad(videomixer, "src");
    gst_element_add_pad(bin, gst_ghost_pad_new("src", pad));
    gst_object_unref(pad);
}
Beispiel #9
0
bool PlayerGst::prepare()
{
	GstElement *dec, *conv, *sink, *audio, *vol, *playbin;
	GstPad *audiopad;
	pipeline = gst_pipeline_new ("pipeline");
	bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));

	dec = gst_element_factory_make ("decodebin", "decoder");
	g_signal_connect (dec, "new-decoded-pad", G_CALLBACK (cb_newpad), NULL);
	gst_bin_add (GST_BIN (pipeline), dec);

	audio = gst_bin_new ("audiobin");
	conv = gst_element_factory_make ("audioconvert", "aconv");
	audiopad = gst_element_get_static_pad (conv, "sink");
	vol = gst_element_factory_make ("volume", "volume");
	sink = gst_element_factory_make ("autoaudiosink", "sink");
	gst_bin_add_many (GST_BIN (audio), conv, vol, sink, NULL);
	gst_element_link (conv, vol);
	gst_element_link (vol, sink);
	gst_element_add_pad (audio, gst_ghost_pad_new ("sink", audiopad));
	gst_object_unref (audiopad);
	gst_bin_add (GST_BIN (pipeline), audio);


	GstElement *l_src, *http_src;
	l_src = gst_element_factory_make ("filesrc", "localsrc");
	http_src = gst_element_factory_make("neonhttpsrc", "httpsrc");
	gst_bin_add_many (GST_BIN (pipeline), l_src, http_src, NULL);
	gst_element_set_state (l_src, GST_STATE_NULL);
	gst_element_set_locked_state (l_src, TRUE);
	gst_element_set_state (http_src, GST_STATE_NULL);
	gst_element_set_locked_state (http_src, TRUE);
	//gst_element_link (src, dec);

	if(canUsePlaybin) {
		playbin = gst_element_factory_make ("playbin2", "player");
		if(playbin) g_signal_connect(playbin, "about-to-finish", G_CALLBACK(gst_finish), NULL);
		else playbin = gst_element_factory_make ("playbin", "player");
		gst_bin_add (GST_BIN (pipeline), playbin);
		//g_object_set (G_OBJECT(playbin), "audio-sink", audio, NULL);
		gst_element_set_state (playbin, GST_STATE_NULL);
		gst_element_set_locked_state (playbin, TRUE);
 	//sync_set_state(player, GST_STATE_NULL);
// 	gst_element_set_state (GST_ELEMENT (player), GST_STATE_NULL);
	}

	return pipeline;
}
Beispiel #10
0
bool TrackAnalyser::prepare()
{
        GstElement *dec, *conv, *sink, *cutter, *audio, *analysis;
        GstPad *audiopad;
        GstCaps *caps;

        caps = gst_caps_new_simple ("audio/x-raw-int",
                                    "channels", G_TYPE_INT, 2, NULL);

        pipeline = gst_pipeline_new ("pipeline");
        bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));


        dec = gst_element_factory_make ("decodebin2", "decoder");
        g_signal_connect (dec, "new-decoded-pad", G_CALLBACK (cb_newpad_ta), this);
        gst_bin_add (GST_BIN (pipeline), dec);

        audio = gst_bin_new ("audiobin");
        conv = gst_element_factory_make ("audioconvert", "conv");
        audiopad = gst_element_get_static_pad (conv, "sink");
        analysis = gst_element_factory_make ("rganalysis", "analysis");
        cutter = gst_element_factory_make ("cutter", "cutter");
        sink = gst_element_factory_make ("fakesink", "sink");

        g_object_set (analysis, "message", TRUE, NULL);
        g_object_set (analysis, "num-tracks", 1, NULL);
        g_object_set (cutter, "threshold-dB", -25.0, NULL);

        gst_bin_add_many (GST_BIN (audio), conv, analysis, cutter, sink, NULL);
        gst_element_link (conv, analysis);
        gst_element_link_filtered (analysis, cutter, caps);
        gst_element_link (cutter, sink);
        gst_element_add_pad (audio, gst_ghost_pad_new ("sink", audiopad));

        gst_bin_add (GST_BIN (pipeline), audio);

        GstElement *l_src;
        l_src = gst_element_factory_make ("filesrc", "localsrc");
        gst_bin_add_many (GST_BIN (pipeline), l_src, NULL);
        gst_element_set_state (l_src, GST_STATE_NULL);
        gst_element_link ( l_src,dec);

        gst_object_unref (audiopad);

        gst_bus_set_sync_handler (bus, bus_cb, this);

        return pipeline;
}
static GstElement *owr_audio_renderer_get_element(OwrMediaRenderer *renderer)
{
    GstElement *renderer_bin;
    GstElement *audioresample, *audioconvert, *capsfilter, *volume, *sink;
    GstCaps *filter_caps;
    GstPad *ghostpad, *sinkpad;
    gchar *bin_name;

    g_assert(renderer);

    bin_name = g_strdup_printf("audio-renderer-bin-%u", g_atomic_int_add(&unique_bin_id, 1));
    renderer_bin = gst_bin_new(bin_name);
    g_free(bin_name);

    audioresample = gst_element_factory_make("audioresample", "audio-renderer-resample");
    audioconvert = gst_element_factory_make("audioconvert", "audio-renderer-convert");

    capsfilter = gst_element_factory_make("capsfilter", "audio-renderer-capsfilter");
    filter_caps = gst_caps_new_simple("audio/x-raw",
        "format", G_TYPE_STRING, "S16LE", NULL);
    g_object_set(capsfilter, "caps", filter_caps, NULL);

    volume = gst_element_factory_make("volume", "audio-renderer-volume");
    g_object_bind_property(renderer, "disabled", volume, "mute", G_BINDING_SYNC_CREATE);

    sink = gst_element_factory_make(AUDIO_SINK, "audio-renderer-sink");
    g_assert(sink);

    g_object_set(sink, "buffer-time", SINK_BUFFER_TIME,
        "latency-time", G_GINT64_CONSTANT(10000), NULL);

    gst_bin_add_many(GST_BIN(renderer_bin), audioresample, audioconvert, capsfilter,
        volume, sink, NULL);

    LINK_ELEMENTS(volume, sink);
    LINK_ELEMENTS(capsfilter, volume);
    LINK_ELEMENTS(audioconvert, capsfilter);
    LINK_ELEMENTS(audioresample, audioconvert);

    sinkpad = gst_element_get_static_pad(audioresample, "sink");
    g_assert(sinkpad);
    ghostpad = gst_ghost_pad_new("sink", sinkpad);
    gst_pad_set_active(ghostpad, TRUE);
    gst_element_add_pad(renderer_bin, ghostpad);
    gst_object_unref(sinkpad);

    return renderer_bin;
}
static void
pad_added_cb (GstElement * element, GstPad * pad, GESTrack * track)
{
  GESTrackPrivate *priv = track->priv;

  GST_DEBUG ("track:%p, pad %s:%s", track, GST_DEBUG_PAD_NAME (pad));

  /* ghost the pad */
  priv->srcpad = gst_ghost_pad_new ("src", pad);

  gst_pad_set_active (priv->srcpad, TRUE);

  gst_element_add_pad (GST_ELEMENT (track), priv->srcpad);

  GST_DEBUG ("done");
}
Beispiel #13
0
static void
dvb_base_bin_init (DvbBaseBin * dvbbasebin)
{
  DvbBaseBinStream *stream;
  GstPad *ghost, *pad;
  int i;

  dvbbasebin->dvbsrc = gst_element_factory_make ("dvbsrc", NULL);
  dvbbasebin->buffer_queue = gst_element_factory_make ("queue", NULL);
  dvbbasebin->tsparse = gst_element_factory_make ("tsparse", NULL);

  g_object_set (dvbbasebin->buffer_queue, "max-size-buffers", 0,
      "max-size-bytes", 0, "max-size-time", 0, NULL);

  gst_bin_add_many (GST_BIN (dvbbasebin), dvbbasebin->dvbsrc,
      dvbbasebin->buffer_queue, dvbbasebin->tsparse, NULL);

  gst_element_link_many (dvbbasebin->dvbsrc,
      dvbbasebin->buffer_queue, dvbbasebin->tsparse, NULL);

  /* Expose tsparse source pad */
  pad = gst_element_get_static_pad (dvbbasebin->tsparse, "src");
  gst_pad_add_probe (pad, GST_PAD_PROBE_TYPE_DATA_DOWNSTREAM,
      dvb_base_bin_ts_pad_probe_cb, dvbbasebin, NULL);
  ghost = gst_ghost_pad_new ("src", pad);
  gst_element_add_pad (GST_ELEMENT (dvbbasebin), ghost);

  dvbbasebin->programs = g_hash_table_new_full (g_direct_hash, g_direct_equal,
      NULL, dvb_base_bin_program_destroy);
  dvbbasebin->streams = g_hash_table_new_full (g_direct_hash, g_direct_equal,
      NULL, g_free);

  dvbbasebin->pmtlist = NULL;
  dvbbasebin->pmtlist_changed = FALSE;

  dvbbasebin->disposed = FALSE;
  dvb_base_bin_reset (dvbbasebin);

  /* add PAT, CAT, NIT, SDT, EIT, TDT to pids filter for dvbsrc */
  i = 0;
  while (initial_pids[i] >= 0) {
    stream = dvb_base_bin_add_stream (dvbbasebin, (guint16) initial_pids[i]);
    ++stream->usecount;
    i++;
  }
  dvb_base_bin_rebuild_filter (dvbbasebin);
}
static gboolean
link_unlinked_pads (GstElement *bin,
    GstPadDirection dir,
    const gchar *pad_name,
    guint *pad_count,
    GError **error)
{
  GstPad *pad = NULL;
  guint i = 0;

  while ((pad = gst_bin_find_unlinked_pad (GST_BIN (bin), dir)))
  {
    GstPad *ghostpad;
    gchar *tmp;

    if (i)
      tmp = g_strdup_printf ("%s%d", pad_name, i);
    else
      tmp = g_strdup (pad_name);
    i++;

    ghostpad = gst_ghost_pad_new (tmp, pad);
    gst_object_unref (pad);
    g_free (tmp);

    if (!ghostpad)
    {
      g_set_error (error, FS_ERROR, FS_ERROR_CONSTRUCTION,
          "Could not create ghostpad for pad %s:%s",
          GST_DEBUG_PAD_NAME (pad));
      return FALSE;
    }

    if (!gst_element_add_pad (bin, ghostpad))
    {
      g_set_error (error, FS_ERROR, FS_ERROR_CONSTRUCTION,
          "Could not add pad %s to bin", GST_OBJECT_NAME (ghostpad));
      return FALSE;
    }
  }

  if (pad_count)
    *pad_count = i;

  return TRUE;
}
static GstElement *
ges_title_source_create_element (GESTrackElement * object)
{
  GESTitleSource *self = GES_TITLE_SOURCE (object);
  GESTitleSourcePrivate *priv = self->priv;
  GstElement *topbin, *background, *text;
  GstPad *src;

  topbin = gst_bin_new ("titlesrc-bin");
  background = gst_element_factory_make ("videotestsrc", "titlesrc-bg");

  text = gst_element_factory_make ("textoverlay", "titlsrc-text");
  if (priv->text) {
    g_object_set (text, "text", priv->text, NULL);
  }
  if (priv->font_desc) {
    g_object_set (text, "font-desc", priv->font_desc, NULL);
  }
  g_object_set (text, "valignment", (gint) priv->valign, "halignment",
      (gint) priv->halign, NULL);

  g_object_set (background, "pattern", (gint) GES_VIDEO_TEST_PATTERN_SOLID,
      NULL);
  g_object_set (background, "foreground-color", (guint) self->priv->background,
      NULL);
  g_object_set (text, "color", (guint) self->priv->color, NULL);
  g_object_set (text, "xpos", (gdouble) self->priv->xpos, NULL);
  g_object_set (text, "ypos", (gdouble) self->priv->ypos, NULL);

  gst_bin_add_many (GST_BIN (topbin), background, text, NULL);

  gst_element_link_pads_full (background, "src", text, "video_sink",
      GST_PAD_LINK_CHECK_NOTHING);

  src = gst_ghost_pad_new ("src", gst_element_get_static_pad (text, "src"));
  gst_element_add_pad (topbin, src);

  gst_object_ref (text);
  gst_object_ref (background);

  priv->text_el = text;
  priv->background_el = background;

  return topbin;
}
Beispiel #16
0
static gboolean
acam_webcam_setup_create_photo_save_bin (acam_webcam_device_s *acam_webcam_device, GError **error)
{
	GstElement *csp_photo_save_bin;

	gboolean ok;
	GstPad  *pad;
	GstCaps *caps;

	/* Create a new bin (photo bin) */
	acam_webcam_device->photo_save_bin = gst_bin_new ("photo_save_bin");

	if ((csp_photo_save_bin = gst_element_factory_make ("ffmpegcolorspace", "csp_photo_save_bin")) == NULL) {
		g_print ("Element not found: ffmpegcolorspace\n");
	}
	if ((acam_webcam_device->photo_sink = gst_element_factory_make ("fakesink", "photo_sink")) == NULL) {
		g_print ("Element not found: fakesink\n");
	}

	if (error != NULL && *error != NULL)
		return FALSE;

	gst_bin_add_many (GST_BIN (acam_webcam_device->photo_save_bin),
	    				csp_photo_save_bin,
						acam_webcam_device->photo_sink, NULL);

	/* Add ghostpad */
	pad = gst_element_get_pad (csp_photo_save_bin, "sink");
	gst_element_add_pad (acam_webcam_device->photo_save_bin, gst_ghost_pad_new ("sink", pad));
	gst_object_unref (GST_OBJECT (pad));

	caps = gst_caps_new_simple ("video/x-raw-rgb",
								"bpp", G_TYPE_INT, 24,
								"depth", G_TYPE_INT, 24,
								NULL);
	ok = gst_element_link_filtered (csp_photo_save_bin, acam_webcam_device->photo_sink, caps);
	gst_caps_unref (caps);

	g_object_set (G_OBJECT (acam_webcam_device->photo_sink), "signal-handoffs", TRUE, NULL);

	if (!ok)
		g_error ("Unable to create photo save pipeline");

	return TRUE;
}
Beispiel #17
0
static void
pad_block (GstPad * pad, gboolean blocked, gpointer user_data)
{
  GstPad *ghost;
  GstBin *bin;

  if (!blocked)
    return;

  bin = GST_BIN (user_data);

  ghost = gst_ghost_pad_new ("src", pad);
  gst_pad_set_active (ghost, TRUE);

  gst_element_add_pad (GST_ELEMENT (bin), ghost);

  gst_pad_set_blocked_async (pad, FALSE, pad_block, NULL);
}
RygelMP3TranscoderBin* rygel_mp3_transcoder_bin_construct (GType object_type, GstElement* src, RygelMP3Transcoder* transcoder, GError** error) {
	GError * _inner_error_;
	RygelMP3TranscoderBin * self;
	GstElement* decodebin;
	GstElement* _tmp0_;
	GstElement* _tmp1_;
	GstElement* _tmp4_;
	GstElement* _tmp3_;
	GstElement* _tmp2_;
	GstPad* src_pad;
	GstGhostPad* ghost;
	GstPad* _tmp5_;
	g_return_val_if_fail (src != NULL, NULL);
	g_return_val_if_fail (transcoder != NULL, NULL);
	_inner_error_ = NULL;
	self = g_object_newv (object_type, 0, NULL);
	decodebin = rygel_gst_utils_create_element (RYGEL_MP3_TRANSCODER_BIN_DECODEBIN, RYGEL_MP3_TRANSCODER_BIN_DECODEBIN, &_inner_error_);
	if (_inner_error_ != NULL) {
		g_propagate_error (error, _inner_error_);
		return;
	}
	_tmp0_ = rygel_mp3_transcoder_create_encoder (transcoder, RYGEL_MP3_TRANSCODER_BIN_AUDIO_SRC_PAD, RYGEL_MP3_TRANSCODER_BIN_AUDIO_SINK_PAD, &_inner_error_);
	if (_inner_error_ != NULL) {
		g_propagate_error (error, _inner_error_);
		(decodebin == NULL) ? NULL : (decodebin = (gst_object_unref (decodebin), NULL));
		return;
	}
	_tmp1_ = NULL;
	self->priv->audio_enc = (_tmp1_ = _tmp0_, (self->priv->audio_enc == NULL) ? NULL : (self->priv->audio_enc = (gst_object_unref (self->priv->audio_enc), NULL)), _tmp1_);
	_tmp4_ = NULL;
	_tmp3_ = NULL;
	_tmp2_ = NULL;
	gst_bin_add_many ((GstBin*) self, (_tmp2_ = src, (_tmp2_ == NULL) ? NULL : gst_object_ref (_tmp2_)), (_tmp3_ = decodebin, (_tmp3_ == NULL) ? NULL : gst_object_ref (_tmp3_)), (_tmp4_ = self->priv->audio_enc, (_tmp4_ == NULL) ? NULL : gst_object_ref (_tmp4_)), NULL);
	gst_element_link (src, decodebin);
	src_pad = gst_element_get_static_pad (self->priv->audio_enc, RYGEL_MP3_TRANSCODER_BIN_AUDIO_SRC_PAD);
	ghost = (GstGhostPad*) gst_ghost_pad_new (NULL, src_pad);
	_tmp5_ = NULL;
	gst_element_add_pad ((GstElement*) self, (_tmp5_ = (GstPad*) ghost, (_tmp5_ == NULL) ? NULL : gst_object_ref (_tmp5_)));
	g_signal_connect_object (decodebin, "pad-added", (GCallback) _rygel_mp3_transcoder_bin_decodebin_pad_added_gst_element_pad_added, self, 0);
	(decodebin == NULL) ? NULL : (decodebin = (gst_object_unref (decodebin), NULL));
	(src_pad == NULL) ? NULL : (src_pad = (gst_object_unref (src_pad), NULL));
	(ghost == NULL) ? NULL : (ghost = (gst_object_unref (ghost), NULL));
	return self;
}
Beispiel #19
0
static gboolean
init_playbin_player (APP_STATE_T * state, const gchar * uri)
{
    GstPad *pad = NULL;
    GstPad *ghostpad = NULL;
    GstElement *vbin = gst_bin_new ("vbin");

    /* insert a gl filter so that the GstGLBufferPool
     * is managed automatically */
    GstElement *glfilter = gst_element_factory_make ("glcolorscale", "glfilter");
    GstElement *vsink = gst_element_factory_make ("fakesink", "vsink");
    g_object_set (vsink, "sync", TRUE, "silent", TRUE, "qos", TRUE,
                  "enable-last-sample", FALSE,
                  "max-lateness", 20 * GST_MSECOND, "signal-handoffs", TRUE, NULL);

    g_signal_connect (vsink, "preroll-handoff", G_CALLBACK (preroll_cb), state);
    g_signal_connect (vsink, "handoff", G_CALLBACK (buffers_cb), state);

    gst_bin_add_many (GST_BIN (vbin), glfilter, vsink, NULL);

    pad = gst_element_get_static_pad (glfilter, "sink");
    ghostpad = gst_ghost_pad_new ("sink", pad);
    gst_object_unref (pad);
    gst_element_add_pad (vbin, ghostpad);

    pad = gst_element_get_static_pad (vsink, "sink");
    gst_pad_add_probe (pad, GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM, events_cb, state,
                       NULL);
    gst_pad_add_probe (pad, GST_PAD_PROBE_TYPE_QUERY_DOWNSTREAM, query_cb, state,
                       NULL);
    gst_object_unref (pad);

    gst_element_link (glfilter, vsink);

    /* Instantiate and configure playbin */
    state->pipeline = gst_element_factory_make ("playbin", "player");
    g_object_set (state->pipeline, "uri", uri,
                  "video-sink", vbin, "flags",
                  GST_PLAY_FLAG_NATIVE_VIDEO | GST_PLAY_FLAG_AUDIO, NULL);

    state->vsink = gst_object_ref (vsink);
    return TRUE;
}
Beispiel #20
0
static void
gst_push_file_src_init (GstPushFileSrc * src, GstPushFileSrcClass * g_class)
{
  src->filesrc = gst_element_factory_make ("filesrc", "real-filesrc");
  if (src->filesrc) {
    GstPad *pad;

    gst_bin_add (GST_BIN (src), src->filesrc);
    pad = gst_element_get_static_pad (src->filesrc, "src");
    g_assert (pad != NULL);
    src->srcpad = gst_ghost_pad_new ("src", pad);
    /* FIXME^H^HCORE: try pushfile:///foo/bar.ext ! typefind ! fakesink without
     * this and watch core bugginess (some pad stays in flushing state) */
    gst_pad_set_checkgetrange_function (src->srcpad,
        GST_DEBUG_FUNCPTR (gst_push_file_src_ghostpad_checkgetrange));
    gst_element_add_pad (GST_ELEMENT (src), src->srcpad);
    gst_object_unref (pad);
  }
}
bool GstEnginePipeline::ReplaceDecodeBin(const QUrl& url) {
    GstElement* new_bin = NULL;

    if (url.scheme() == "spotify") {
#ifdef HAVE_SPOTIFY
        new_bin = gst_bin_new("spotify_bin");

        // Create elements
        GstElement* src = engine_->CreateElement("tcpserversrc", new_bin);
        GstElement* gdp = engine_->CreateElement("gdpdepay", new_bin);
        if (!src || !gdp)
            return false;

        // Pick a port number
        const int port = Utilities::PickUnusedPort();
        g_object_set(G_OBJECT(src), "host", "127.0.0.1", NULL);
        g_object_set(G_OBJECT(src), "port", port, NULL);

        // Link the elements
        gst_element_link(src, gdp);

        // Add a ghost pad
        GstPad* pad = gst_element_get_static_pad(gdp, "src");
        gst_element_add_pad(GST_ELEMENT(new_bin), gst_ghost_pad_new("src", pad));
        gst_object_unref(GST_OBJECT(pad));

        // Tell spotify to start sending data to us.
        InternetModel::Service<SpotifyService>()->server()->StartPlaybackLater(url.toString(), port);
#else // HAVE_SPOTIFY
        qLog(Error) << "Tried to play a spotify:// url, but spotify support is not compiled in";
        return false;
#endif
    } else {
        new_bin = engine_->CreateElement("uridecodebin");
        g_object_set(G_OBJECT(new_bin), "uri", url.toEncoded().constData(), NULL);
        CHECKED_GCONNECT(G_OBJECT(new_bin), "drained", &SourceDrainedCallback, this);
        CHECKED_GCONNECT(G_OBJECT(new_bin), "pad-added", &NewPadCallback, this);
        CHECKED_GCONNECT(G_OBJECT(new_bin), "notify::source", &SourceSetupCallback, this);
    }

    return ReplaceDecodeBin(new_bin);
}
static void
ges_smart_adder_init (GESSmartAdder * self)
{
  GstPad *pad;

  g_mutex_init (&self->lock);

  self->adder = gst_element_factory_make ("adder", "smart-adder-adder");
  gst_bin_add (GST_BIN (self), self->adder);

  pad = gst_element_get_static_pad (self->adder, "src");
  self->srcpad = gst_ghost_pad_new ("src", pad);
  gst_pad_set_active (self->srcpad, TRUE);
  gst_object_unref (pad);

  gst_element_add_pad (GST_ELEMENT (self), self->srcpad);

  self->pads_infos = g_hash_table_new_full (g_direct_hash, g_direct_equal,
      NULL, (GDestroyNotify) destroy_pad);
}
static void
ges_smart_mixer_init (GESSmartMixer * self)
{
  GstPad *pad;
  g_mutex_init (&self->lock);

  self->mixer = gst_element_factory_create (ges_get_compositor_factory (),
      "smart-mixer-mixer");
  g_object_set (self->mixer, "background", 1, NULL);
  gst_bin_add (GST_BIN (self), self->mixer);

  pad = gst_element_get_static_pad (self->mixer, "src");
  self->srcpad = gst_ghost_pad_new ("src", pad);
  gst_pad_set_active (self->srcpad, TRUE);
  gst_object_unref (pad);
  gst_element_add_pad (GST_ELEMENT (self), self->srcpad);

  self->pads_infos = g_hash_table_new_full (g_direct_hash, g_direct_equal,
      NULL, (GDestroyNotify) destroy_pad);
}
static gboolean
_create_ghost_pad (GstElement *current_element, const gchar *padname, GstElement
  *codec_bin, GError **error)
{
  GstPad *ghostpad;
  GstPad *pad = gst_element_get_static_pad (current_element, padname);
  gboolean ret = FALSE;

  if (!pad)
  {
    g_set_error (error, FS_ERROR, FS_ERROR_CONSTRUCTION,
      "Could not find the %s pad on the element", padname);
      return FALSE;
  }

  ghostpad = gst_ghost_pad_new (padname, pad);
  if (!ghostpad)
  {
    g_set_error (error, FS_ERROR, FS_ERROR_CONSTRUCTION,
      "Could not create a ghost pad for pad %s", padname);
    goto done;
  }

  if (!gst_pad_set_active (ghostpad, TRUE))
  {
    g_set_error (error, FS_ERROR, FS_ERROR_CONSTRUCTION,
      "Could not active ghostpad %s", padname);
    gst_object_unref (ghostpad);
    goto done;
  }

  if (!gst_element_add_pad (codec_bin, ghostpad))
    g_set_error (error, FS_ERROR, FS_ERROR_CONSTRUCTION,
      "Could not add ghostpad %s to the codec bin", padname);

  ret = TRUE;
 done:
  gst_object_unref (pad);

  return ret;
}
Beispiel #25
0
void VideoCompositor::addSource(GstPad *srcPad, QRect rect)
{
    GstPad *sinkPad, *targetPad;
    QByteArray padName = QString("sink_%1").arg(numSink++).toLatin1();
    GstElement *queue = gst_element_factory_make("queue", NULL);
    targetPad = gst_element_get_static_pad(queue, "sink");

    GstElement *filter = gst_element_factory_make("capsfilter", NULL);
    QByteArray capsString = QByteArray("video/x-raw,format=I420");
    if(rect.isValid())capsString.append(QString(",width=(int)%1,height=(int)%2").arg(rect.width()).arg(rect.height()).toLatin1());
    GstCaps *caps = gst_caps_from_string(capsString.constData());
    g_object_set(filter, "caps", caps, NULL);

    gst_bin_add_many(GST_BIN(bin), queue, filter, NULL);
    gst_caps_unref(caps);

    if(rect.isValid())
    {
        GstElement *videoscale = gst_element_factory_make("videoscale", NULL);
        gst_bin_add(GST_BIN(bin), videoscale);
        gst_element_link_many(queue, videoscale, filter, videomixer, NULL);
        GstPad *mixPad = gst_element_get_static_pad(videomixer, padName.constData());
        g_object_set(mixPad, "xpos", rect.x(), "ypos", rect.y(), NULL);
        gst_object_unref(mixPad);
    }
    else
    {
        gst_element_link_many(queue, filter, videomixer, NULL);
    }

    GstState state;
    gst_element_get_state(bin, &state, NULL, GST_SECOND);
    GstPad *ghost = gst_ghost_pad_new(padName.constData(), targetPad);
    if(state==GST_STATE_PLAYING)gst_pad_set_active(ghost, TRUE);
    gst_element_add_pad(bin, ghost);
    sinkPad = gst_element_get_static_pad(bin, padName.constData());
    gst_pad_link(srcPad, sinkPad);
    gst_object_unref(sinkPad);
    gst_object_unref(targetPad);
    gst_object_unref(srcPad);
}
GstElement *
audiotest_bin_src (const gchar * name, guint64 start,
    gint64 duration, guint priority, gboolean intaudio)
{
  GstElement *source = NULL;
  GstElement *identity = NULL;
  GstElement *audiotestsrc = NULL;
  GstElement *audioconvert = NULL;
  GstElement *bin = NULL;
  GstCaps *caps;
  GstPad *srcpad = NULL;

  audiotestsrc = gst_element_factory_make_or_warn ("audiotestsrc", NULL);
  identity = gst_element_factory_make_or_warn ("identity", NULL);
  bin = gst_bin_new (NULL);
  source = new_nle_src (name, start, duration, priority);
  audioconvert = gst_element_factory_make_or_warn ("audioconvert", NULL);

  if (intaudio)
    caps = gst_caps_from_string ("audio/x-raw,format=(string)S16LE");
  else
    caps = gst_caps_from_string ("audio/x-raw,format=(string)F32LE");

  gst_bin_add_many (GST_BIN (bin), audiotestsrc, audioconvert, identity, NULL);
  gst_element_link_pads_full (audiotestsrc, "src", audioconvert, "sink",
      GST_PAD_LINK_CHECK_NOTHING);
  fail_if ((gst_element_link_filtered (audioconvert, identity, caps)) != TRUE);

  gst_caps_unref (caps);

  gst_bin_add (GST_BIN (source), bin);

  srcpad = gst_element_get_static_pad (identity, "src");

  gst_element_add_pad (bin, gst_ghost_pad_new ("src", srcpad));

  gst_object_unref (srcpad);

  return source;
}
static void
gst_gl_sink_bin_init (GstGLSinkBin * self)
{
  gboolean res = TRUE;
  GstPad *pad;

  self->upload = gst_element_factory_make ("glupload", NULL);
  self->convert = gst_element_factory_make ("glcolorconvert", NULL);
  self->balance = gst_element_factory_make ("glcolorbalance", NULL);

  res &= gst_bin_add (GST_BIN (self), self->upload);
  res &= gst_bin_add (GST_BIN (self), self->convert);
  res &= gst_bin_add (GST_BIN (self), self->balance);

  res &= gst_element_link_pads (self->upload, "src", self->convert, "sink");
  res &= gst_element_link_pads (self->convert, "src", self->balance, "sink");

  pad = gst_element_get_static_pad (self->upload, "sink");
  if (!pad) {
    res = FALSE;
  } else {
    GST_DEBUG_OBJECT (self, "setting target sink pad %" GST_PTR_FORMAT, pad);
    self->sinkpad = gst_ghost_pad_new ("sink", pad);
    gst_element_add_pad (GST_ELEMENT_CAST (self), self->sinkpad);
    gst_object_unref (pad);
  }

  gst_gl_object_add_control_binding_proxy (GST_OBJECT (self->balance),
      GST_OBJECT (self), "contrast");
  gst_gl_object_add_control_binding_proxy (GST_OBJECT (self->balance),
      GST_OBJECT (self), "brightness");
  gst_gl_object_add_control_binding_proxy (GST_OBJECT (self->balance),
      GST_OBJECT (self), "hue");
  gst_gl_object_add_control_binding_proxy (GST_OBJECT (self->balance),
      GST_OBJECT (self), "saturation");

  if (!res) {
    GST_WARNING_OBJECT (self, "Failed to add/connect the necessary machinery");
  }
}
void AudioSourceProviderGStreamer::configureAudioBin(GstElement* audioBin, GstElement* teePredecessor)
{
    m_audioSinkBin = audioBin;

    GstElement* audioTee = gst_element_factory_make("tee", "audioTee");
    GstElement* audioQueue = gst_element_factory_make("queue", 0);
    GstElement* audioConvert = gst_element_factory_make("audioconvert", 0);
    GstElement* audioConvert2 = gst_element_factory_make("audioconvert", 0);
    GstElement* audioResample = gst_element_factory_make("audioresample", 0);
    GstElement* audioResample2 = gst_element_factory_make("audioresample", 0);
    GstElement* volumeElement = gst_element_factory_make("volume", "volume");
    GstElement* audioSink = gst_element_factory_make("autoaudiosink", 0);

    gst_bin_add_many(GST_BIN(m_audioSinkBin.get()), audioTee, audioQueue, audioConvert, audioResample, volumeElement, audioConvert2, audioResample2, audioSink, nullptr);

    // In cases where the audio-sink needs elements before tee (such
    // as scaletempo) they need to be linked to tee which in this case
    // doesn't need a ghost pad. It is assumed that the teePredecessor
    // chain already configured a ghost pad.
    if (teePredecessor)
        gst_element_link_pads_full(teePredecessor, "src", audioTee, "sink", GST_PAD_LINK_CHECK_NOTHING);
    else {
        // Add a ghostpad to the bin so it can proxy to tee.
        GRefPtr<GstPad> audioTeeSinkPad = adoptGRef(gst_element_get_static_pad(audioTee, "sink"));
        gst_element_add_pad(m_audioSinkBin.get(), gst_ghost_pad_new("sink", audioTeeSinkPad.get()));
    }

    // Link a new src pad from tee to queue ! audioconvert !
    // audioresample ! volume ! audioconvert ! audioresample !
    // autoaudiosink. The audioresample and audioconvert are needed to
    // ensure the audio sink receives buffers in the correct format.
    gst_element_link_pads_full(audioTee, "src_%u", audioQueue, "sink", GST_PAD_LINK_CHECK_NOTHING);
    gst_element_link_pads_full(audioQueue, "src", audioConvert, "sink", GST_PAD_LINK_CHECK_NOTHING);
    gst_element_link_pads_full(audioConvert, "src", audioResample, "sink", GST_PAD_LINK_CHECK_NOTHING);
    gst_element_link_pads_full(audioResample, "src", volumeElement, "sink", GST_PAD_LINK_CHECK_NOTHING);
    gst_element_link_pads_full(volumeElement, "src", audioConvert2, "sink", GST_PAD_LINK_CHECK_NOTHING);
    gst_element_link_pads_full(audioConvert2, "src", audioResample2, "sink", GST_PAD_LINK_CHECK_NOTHING);
    gst_element_link_pads_full(audioResample2, "src", audioSink, "sink", GST_PAD_LINK_CHECK_NOTHING);
}
Beispiel #29
0
static GstElement *
gen_audio_element (void)
{
  GstElement *element;
  GstElement *conv;
  GstElement *sink;
  GstPad *pad;

  element = gst_bin_new ("abin");
  conv = gst_element_factory_make ("audioconvert", "conv");
  sink = gst_element_factory_make (DEFAULT_AUDIOSINK, "sink");

  gst_bin_add (GST_BIN (element), conv);
  gst_bin_add (GST_BIN (element), sink);
  gst_element_link_pads (conv, "src", sink, "sink");

  pad = gst_element_get_pad (conv, "sink");
  gst_element_add_pad (element, gst_ghost_pad_new ("sink", pad));
  gst_object_unref (pad);

  return element;
}
Beispiel #30
0
int
main (int   argc,
      char *argv[])
{
  GstElement *bin, *sink;
  GstPad *pad;
  
  xmlfile = "ghostpad";
  std_log(LOG_FILENAME_LINE, "Test Started ghostpad");
 
  /* init */
  gst_init (&argc, &argv);
  
  /* create element, add to bin */
  sink = gst_element_factory_make ("fakesink", "sink");
  bin = gst_bin_new ("mybin");
  gst_bin_add (GST_BIN (bin), sink);


  /* add ghostpad */
  pad = gst_element_get_pad (sink, "sink");
  gst_element_add_pad (bin, gst_ghost_pad_new ("sink", pad));
  gst_object_unref (GST_OBJECT (pad));
  
    if(!sink || !bin || !pad)
        {
        std_log(LOG_FILENAME_LINE, "Test Failed");
        create_xml(1);
        return -1;
        }

  std_log(LOG_FILENAME_LINE, "Test Successful");
  create_xml(0); 
/*** block b  from ../../../docs/manual/basics-pads.xml ***/
  return 0;

/*** block c  from ../../../docs/manual/basics-pads.xml ***/
}