#include <gst/gst.h>

int main(void)
{
	GstElement *pipeline;
	GstElement *src, *caps, *conv, *enc, *sink;

	gst_init(NULL, NULL);

	pipeline = gst_pipeline_new(NULL);

	src = gst_element_factory_make("audiotestsrc", NULL);
	caps = gst_element_factory_make("capsfilter", NULL);
	conv = gst_element_factory_make("audioconvert", NULL);
	enc = gst_element_factory_make("vorbisenc", NULL);
	sink = gst_element_factory_make("fakesink", NULL);


	g_object_set(caps, "caps", gst_caps_from_string("audio/x-raw,format=S16LE,channels=6,channel-mask=(bitmask)0x3f"), NULL);
	g_object_set(sink, "silent", FALSE, NULL);
	g_object_set(sink, "dump", TRUE, NULL);

	gst_bin_add_many(GST_BIN(pipeline), src, caps, conv, enc, sink, NULL);
	gst_element_link_many(src, caps, conv, enc, sink, NULL);

	gst_element_set_state(pipeline, GST_STATE_PLAYING);

	g_usleep(2 * G_USEC_PER_SEC);

	g_object_set(caps, "caps", gst_caps_from_string("audio/x-raw,format=S16LE,channels=2"), NULL);

	g_usleep(3 * G_USEC_PER_SEC);

	g_object_set(caps, "caps", gst_caps_from_string("audio/x-raw,format=S16LE,channels=6,channel-mask=(bitmask)0x3f"), NULL);

	g_usleep(10 * G_USEC_PER_SEC);

	return 0;
}
