From 5f7a20ff6f545a11b6eb4e18251461c9668d2de5 Mon Sep 17 00:00:00 2001 From: Erik Walthinsen Date: Tue, 12 Dec 2000 09:40:25 +0000 Subject: [PATCH] Added LAME encoder. Wow. Original commit message from CVS: Added LAME encoder. Wow. --- configure.in | 2 ++ gst/elements/gstfdsink.c | 4 +++- gst/gstbin.c | 4 ++-- gst/gstplugin.c | 1 + plugins/elements/gstfdsink.c | 4 +++- tests/Makefile.am | 2 +- tests/rip.c | 49 ++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 61 insertions(+), 5 deletions(-) create mode 100644 tests/rip.c diff --git a/configure.in b/configure.in index d9f045f..a9028fb 100644 --- a/configure.in +++ b/configure.in @@ -429,6 +429,8 @@ plugins/mp3decode/xa/Makefile plugins/mp3decode/xing/Makefile plugins/mp3decode/mpg123/Makefile plugins/mp3decode/parse/Makefile +plugins/mp3encode/Makefile +plugins/mp3encode/lame/Makefile plugins/mpeg2/Makefile plugins/mpeg2/parse/Makefile plugins/mpeg2/ac3parse/Makefile diff --git a/gst/elements/gstfdsink.c b/gst/elements/gstfdsink.c index 6e0a36d..389b344 100644 --- a/gst/elements/gstfdsink.c +++ b/gst/elements/gstfdsink.c @@ -116,8 +116,10 @@ gst_fdsink_chain (GstPad *pad, GstBuffer *buf) g_return_if_fail (fdsink->fd >= 0); - if (GST_BUFFER_DATA (buf)) + if (GST_BUFFER_DATA (buf)) { + DEBUG("writing %d bytes to file descriptor %d\n",GST_BUFFER_SIZE (buf), fdsink->fd); write (fdsink->fd, GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf)); + } gst_buffer_unref (buf); } diff --git a/gst/gstbin.c b/gst/gstbin.c index e2b9696..ef9725d 100644 --- a/gst/gstbin.c +++ b/gst/gstbin.c @@ -794,7 +794,7 @@ gst_bin_create_plan_func (GstBin *bin) gst_bin_create_plan (GST_BIN (element)); } else if (GST_IS_SRC (element)) { - DEBUG("adding '%s' as entry point\n",gst_element_get_name (element)); + DEBUG("adding '%s' as entry point, because it's a source\n",gst_element_get_name (element)); bin->entries = g_list_prepend (bin->entries,element); bin->numentries++; cothread_setfunc(element->threadstate,gst_bin_src_wrapper,0,(char **)element); @@ -859,7 +859,7 @@ GST_DEBUG_PAD_NAME(pad->peer),GST_DEBUG_PAD_NAME(pad),&pad->pullfunc); gst_bin_create_plan (GST_BIN (element)); } if (GST_IS_SRC (element)) { - g_print("gstbin: adding '%s' as entry point\n",gst_element_get_name (element)); + g_print("adding '%s' as entry point, because it's a source\n",gst_element_get_name (element)); bin->entries = g_list_prepend (bin->entries, element); bin->numentries++; } else { diff --git a/gst/gstplugin.c b/gst/gstplugin.c index 85917b3..3eff53c 100644 --- a/gst/gstplugin.c +++ b/gst/gstplugin.c @@ -270,6 +270,7 @@ gboolean gst_plugin_load_absolute(gchar *name) { GstPlugin *gst_plugin_new(gchar *name) { GstPlugin *plugin = (GstPlugin *)g_malloc(sizeof(GstPlugin)); + // FIXME need to make sure the plugin hasn't already loaded plugin->name = g_strdup(name); plugin->longname = NULL; plugin->types = NULL; diff --git a/plugins/elements/gstfdsink.c b/plugins/elements/gstfdsink.c index 6e0a36d..389b344 100644 --- a/plugins/elements/gstfdsink.c +++ b/plugins/elements/gstfdsink.c @@ -116,8 +116,10 @@ gst_fdsink_chain (GstPad *pad, GstBuffer *buf) g_return_if_fail (fdsink->fd >= 0); - if (GST_BUFFER_DATA (buf)) + if (GST_BUFFER_DATA (buf)) { + DEBUG("writing %d bytes to file descriptor %d\n",GST_BUFFER_SIZE (buf), fdsink->fd); write (fdsink->fd, GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf)); + } gst_buffer_unref (buf); } diff --git a/tests/Makefile.am b/tests/Makefile.am index 22b404d..34b5b9b 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,4 +1,4 @@ -noinst_PROGRAMS = init loadall simplefake states caps queue registry paranoia +noinst_PROGRAMS = init loadall simplefake states caps queue registry paranoia rip LDADD = $(GLIB_LIBS) $(GTK_LIBS) $(top_builddir)/gst/libgst.la CFLAGS = -Wall diff --git a/tests/rip.c b/tests/rip.c new file mode 100644 index 0000000..d69544b --- /dev/null +++ b/tests/rip.c @@ -0,0 +1,49 @@ +#include +#include +#include +#include + +int main(int argc,char *argv[]) { + GstPipeline *pipeline; + GstElement *paranoia,*lame,*sink; + int i; + int outfile; + + DEBUG_ENTER("(%d)",argc); + + gst_init(&argc,&argv); + + unlink(argv[1]); + outfile = open(argv[1],O_CREAT | O_RDWR | O_TRUNC); + if (!outfile) { + fprintf(stderr,"couldn't open file\n"); + exit(1); + } + fprintf(stderr,"outfile is fd %d\n",outfile); + + pipeline = gst_pipeline_new("ripper"); + paranoia = gst_elementfactory_make("cdparanoia","paranoia"); + g_return_val_if_fail(1,paranoia != NULL); + lame = gst_elementfactory_make("lame","lame"); + g_return_val_if_fail(2,lame != NULL); + gtk_object_set(GTK_OBJECT(lame),"bitrate",320,NULL); + sink = gst_elementfactory_make("fdsink","fdsink"); + g_return_val_if_fail(3,sink != NULL); + gtk_object_set(GTK_OBJECT(sink),"fd",outfile,NULL); + + fprintf(stderr,"paranoia is %p, lame is %p, sink is %p\n",paranoia,lame,sink); + gst_bin_add(GST_BIN(pipeline),paranoia); + gst_bin_add(GST_BIN(pipeline),lame); + gst_bin_add(GST_BIN(pipeline),sink); + + gst_element_connect(paranoia,"src",lame,"sink"); + gst_element_connect(lame,"src",sink,"sink"); + + gst_element_set_state(GST_ELEMENT(pipeline),GST_STATE_PLAYING); + if (GST_STATE(paranoia) != GST_STATE_PLAYING) fprintf(stderr,"error: state not set\n"); + + for (i=0;i<((argc >= 3)?atoi(argv[2]):4500);i++) { + fprintf(stderr,"\n"); + gst_bin_iterate(GST_BIN(pipeline)); + } +} -- 2.7.4