Thread: Including from GStreamer Base plugin
hi
want make program uses of classes gstreamer base plugin. problem is, can't find anywhere in documentation supposed include in top of file use classes use , if need add on compilation line. in example below, want use gsttcpserversink class. here test.cpp , make file:
code:#include <gst/gst.h> #include <glib.h> static gboolean bus_call (gstbus *bus, gstmessage *msg, gpointer data) { gmainloop *loop = (gmainloop *) data; switch (gst_message_type (msg)) { case gst_message_eos: g_print ("end of stream\n"); g_main_loop_quit (loop); break; case gst_message_error: { gchar *debug; gerror *error; gst_message_parse_error (msg, &error, &debug); g_free (debug); g_printerr ("error: %s\n", error->message); g_error_free (error); g_main_loop_quit (loop); break; } default: break; } return true; } static void on_pad_added (gstelement *element, gstpad *pad, gpointer data) { gstpad *sinkpad; gstelement *decoder = (gstelement *) data; /* can link pad vorbis-decoder sink pad */ g_print ("dynamic pad created, linking demuxer/decoder\n"); sinkpad = gst_element_get_static_pad (decoder, "sink"); gst_pad_link (pad, sinkpad); gst_object_unref (sinkpad); } int main (int argc, char *argv[]) { gmainloop *loop; gstelement *pipeline, *source, *demuxer, *decoder, *conv; gsttcpserversink *sink; gstbus *bus; /* initialisation */ gst_init (&argc, &argv); loop = g_main_loop_new (null, false); /* check input arguments */ if (argc != 2) { g_printerr ("usage: %s <ogg/vorbis filename>\n", argv[0]); return -1; } /* create gstreamer elements */ pipeline = gst_pipeline_new ("audio-player"); source = gst_element_factory_make ("filesrc", "file-source"); demuxer = gst_element_factory_make ("oggdemux", "ogg-demuxer"); decoder = gst_element_factory_make ("vorbisdec", "vorbis-decoder"); conv = gst_element_factory_make ("audioconvert", "converter"); sink = gst_element_factory_make ("tcpserversink", "audio-output"); if (!pipeline || !source || !demuxer || !decoder || !conv || !sink) { g_printerr ("one element not created. exiting.\n"); return -1; } /* set pipeline */ /* set input filename source element */ g_object_set (g_object (source), "location", argv[1], null); /* add message handler */ bus = gst_pipeline_get_bus (gst_pipeline (pipeline)); gst_bus_add_watch (bus, bus_call, loop); gst_object_unref (bus); /* add elements pipeline */ /* file-source | ogg-demuxer | vorbis-decoder | converter | alsa-output */ gst_bin_add_many (gst_bin (pipeline), source, demuxer, decoder, conv, sink, null); /* link elements */ /* file-source -> ogg-demuxer ~> vorbis-decoder -> converter -> alsa-output */ gst_element_link (source, demuxer); gst_element_link_many (decoder, conv, sink, null); g_signal_connect (demuxer, "pad-added", g_callback (on_pad_added), decoder); /* note demuxer linked decoder dynamically. reason ogg may contain various streams (for example audio , video). source pad(s) created @ run time, demuxer when detects amount , nature of streams. therefore connect callback function executed when "pad-added" emitted.*/ /* set pipeline "playing" state*/ g_print ("now playing: %s\n", argv[1]); gst_element_set_state (pipeline, gst_state_playing); /* iterate */ g_print ("running...\n"); g_main_loop_run (loop); /* out of main loop, clean 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; }i keep getting message saying gsttcpserversink not declared. there documentation on this? need include , there need include compilation?code:cc = g++ cflags = -wall prog = myprogram #source files srcs = test.cpp #compiler flags cflags=-wall #libraries gstream_libs=`pkg-config --cflags --libs gstreamer-0.10` all: $(prog) $(prog): $(srcs) $(cc) $(cflags) -o $(prog) $(srcs) $(gstream_libs) clean: rm -f $(prog)
have downloaded gstreamer plugins repository.
paul
i think have found shared object need class.
in path:
/usr/lib/gstreamer-0.10/libgsttcp.so.
how change makefile link shared object. quite new make files , not sure how work.
paul
Forum The Ubuntu Forum Community Ubuntu Specialised Support Development & Programming Programming Talk Including from GStreamer Base plugin
Ubuntu
Comments
Post a Comment