#include <glib.h>
#include <glib-object.h>
#include <gst/gst.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>

GstPipeline* pipeline = NULL;
GstElement* source = NULL;
GstElement* converter = NULL;
GstElement* codec = NULL;
GstElement* tagger = NULL;
GstElement* muxer = NULL;
GstElement* sink = NULL;


int main (int argc, char ** argv) {
	GMainLoop* loop;

	g_thread_init (NULL);
	g_type_init ();


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

	pipeline = (GstPipeline*) gst_pipeline_new ("pipeline");

	source    = gst_element_factory_make ("audiotestsrc", "source");
	converter = gst_element_factory_make ("audioconvert", "converter");
	codec     = gst_element_factory_make ("vorbisenc", "codec");
	tagger    = gst_element_factory_make ("vorbistag", "tagger");
	muxer     = gst_element_factory_make ("oggmux", "muxer");
	sink      = gst_element_factory_make ("shout2send", "sink");

	g_object_set(sink, "mount", "/test", NULL);
	g_object_set(sink, "ip", "127.0.0.1", NULL);
	g_object_set(sink, "port", 8000, NULL);
	g_object_set(sink, "password", "hackme", NULL);
	gst_bin_add_many ((GstBin*) pipeline, source, converter, codec, tagger, muxer, sink, NULL);

	gst_element_link (source, converter);
	gst_element_link (converter, codec);
	gst_element_link (codec, tagger);
	gst_element_link (tagger, muxer);
	gst_element_link (muxer, sink);

  gst_tag_setter_add_tags(GST_TAG_SETTER(tagger),
                          GST_TAG_MERGE_REPLACE_ALL,
                          GST_TAG_TITLE,  "Sample Title",
                          GST_TAG_ARTIST, "Sample Artist",
                          GST_TAG_CODEC,  "Vorbis",
                          NULL);


	gst_element_set_state ((GstElement*) pipeline, GST_STATE_PLAYING);



	g_main_loop_run (loop);

	g_main_loop_unref(loop);

	return 0;
}



