diff --git a/gst/gstelementfactory.c b/gst/gstelementfactory.c index 88746ded81..6debdf435d 100644 --- a/gst/gstelementfactory.c +++ b/gst/gstelementfactory.c @@ -50,9 +50,12 @@ void gst_elementfactory_register(GstElementFactory *elementfactory) { * Returns: #GstElementFactory if found, NULL otherwise */ GstElementFactory *gst_elementfactory_find(gchar *name) { - GList *walk = _gst_elementfactories; + GList *walk; GstElementFactory *factory; + gst_plugin_load_elementfactory(name); + + walk = _gst_elementfactories; while (walk) { factory = (GstElementFactory *)(walk->data); if (!strcmp(name,factory->name)) @@ -149,7 +152,7 @@ GstElement *gst_elementfactory_make(gchar *factoryname,gchar *name) { GstElementFactory *factory; GstElement *element; - gst_plugin_load_elementfactory(factoryname); + //gst_plugin_load_elementfactory(factoryname); factory = gst_elementfactory_find(factoryname); if (factory == NULL) return NULL; element = gst_elementfactory_create(factory,name); diff --git a/test/Makefile.am b/test/Makefile.am index 257d0d9baf..dceff9dc88 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -2,7 +2,7 @@ noinst_PROGRAMS = qtest spectrum record wave mp3 teardown buffer mp3parse \ mpeg2parse mp1parse mp3play ac3parse ac3play dvdcat fake cobin videotest \ aviparse vidcapture avi2mpg mp2tomp1 mp1tomp1 pipetest \ - vidcapture2 mp2toavi + vidcapture2 mp2toavi mp3tovorbis SUBDIRS = xml cothreads bindings diff --git a/test/mp3tovorbis.c b/test/mp3tovorbis.c new file mode 100644 index 0000000000..cf8ba5ca1a --- /dev/null +++ b/test/mp3tovorbis.c @@ -0,0 +1,77 @@ +#include +#include +#include +#include + + +void eof(GstSrc *src) { + g_print("have eof, quitting\n"); + exit(0); +} + +int main(int argc,char *argv[]) { + GstElement *pipeline; + GstElementFactory *srcfactory, *parsefactory, *decodefactory, *encodefactory, *sinkfactory; + GstElement *src, *parse, *decode, *encode, *sink; + int fd; + + g_print("have %d args\n",argc); + + gst_init(&argc,&argv); + + pipeline = gst_pipeline_new("pipeline"); + g_return_val_if_fail(pipeline != NULL, -1); + + srcfactory = gst_elementfactory_find("disksrc"); + g_return_val_if_fail(srcfactory != NULL, -1); + parsefactory = gst_elementfactory_find("mp3parse"); + g_return_val_if_fail(parsefactory != NULL, -1); + decodefactory = gst_elementfactory_find("mpg123"); + g_return_val_if_fail(decodefactory != NULL, -1); + encodefactory = gst_elementfactory_find("vorbisenc"); + g_return_val_if_fail(encodefactory != NULL, -1); + sinkfactory = gst_elementfactory_find("fdsink"); + g_return_val_if_fail(sinkfactory != NULL, -1); + + src = gst_elementfactory_create(srcfactory,"src"); + g_return_val_if_fail(src != NULL, -1); + gtk_object_set(GTK_OBJECT(src),"location",argv[1],NULL); + g_print("should be using file '%s'\n",argv[1]); + parse = gst_elementfactory_create(parsefactory,"parse"); + g_return_val_if_fail(parse != NULL, -1); + decode = gst_elementfactory_create(decodefactory,"decode"); + g_return_val_if_fail(decode != NULL, -1); + encode = gst_elementfactory_create(encodefactory,"encode"); + g_return_val_if_fail(encode != NULL, -1); + sink = gst_elementfactory_create(sinkfactory,"sink"); + g_return_val_if_fail(sink != NULL, -1); + g_print("should be using output file '%s'\n",argv[2]); + fd = open(argv[2], O_CREAT|O_RDWR|O_TRUNC); + gtk_object_set(GTK_OBJECT(sink),"fd",fd,NULL); + + gtk_signal_connect(GTK_OBJECT(src),"eos", + GTK_SIGNAL_FUNC(eof),NULL); + + gst_bin_add(GST_BIN(pipeline),GST_ELEMENT(src)); + gst_bin_add(GST_BIN(pipeline),GST_ELEMENT(parse)); + gst_bin_add(GST_BIN(pipeline),GST_ELEMENT(decode)); + gst_bin_add(GST_BIN(pipeline),GST_ELEMENT(encode)); + gst_bin_add(GST_BIN(pipeline),GST_ELEMENT(sink)); + + gst_pad_connect(gst_element_get_pad(src,"src"), + gst_element_get_pad(parse,"sink")); + gst_pad_connect(gst_element_get_pad(parse,"src"), + gst_element_get_pad(decode,"sink")); + gst_pad_connect(gst_element_get_pad(decode,"src"), + gst_element_get_pad(encode,"sink")); + gst_pad_connect(gst_element_get_pad(encode,"src"), + gst_element_get_pad(sink,"sink")); + + g_print("setting to READY state\n"); + gst_element_set_state(GST_ELEMENT(pipeline),GST_STATE_READY); + + g_print("about to enter loop\n"); + while (1) { + gst_src_push(GST_SRC(src)); + } +}