summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Boulton <richard@tartarus.org>2001-04-22 10:16:34 +0000
committerRichard Boulton <richard@tartarus.org>2001-04-22 10:16:34 +0000
commit17d04915d16d64427498f8616cdf9e05a0205adb (patch)
tree0ce535e1b2c4a461ba3c8f556139097dace979eb
parent3a3b69bdc6a9431234fda285591c0262b86adc2c (diff)
Original commit message from CVS: Merged from trunk
-rw-r--r--configure.in5
-rw-r--r--examples/autoplug/autoplug.c5
-rw-r--r--gst/autoplug/gststaticautoplugrender.c7
-rw-r--r--gst/gstbuffer.c33
-rw-r--r--gst/gstbuffer.h8
-rw-r--r--gst/gstcaps.h4
-rw-r--r--gst/gstprops.h1
-rw-r--r--libs/putbits/gstputbits.c2
-rw-r--r--test/Makefile.am2
-rw-r--r--test/dvshow.c93
-rw-r--r--test/mp2tomp1.c32
-rw-r--r--test/video2mp1.c236
-rw-r--r--tests/old/examples/autoplug/autoplug.c5
13 files changed, 399 insertions, 34 deletions
diff --git a/configure.in b/configure.in
index bc6fab84af..b1f3b8f9e0 100644
--- a/configure.in
+++ b/configure.in
@@ -445,6 +445,9 @@ dnl Check for libraw1394
AC_MSG_CHECKING(raw1394 library)
AC_CHECK_LIB(raw1394, raw1394_get_handle, HAVE_RAW1394=yes, HAVE_RAW1394=no, )
+dnl Check for libdv
+AC_MSG_CHECKING(libdv)
+AC_CHECK_LIB(dv, dv_init, HAVE_LIBDV=yes, HAVE_LIBDV=no, -lm $GLIB_LIBS $GLIB_CFLAGS)
dnl check if css-auth.c exists (FIXME)
@@ -711,6 +714,7 @@ AM_CONDITIONAL(HAVE_LIBXMMS, test "x$HAVE_LIBXMMS" = "xyes")
AM_CONDITIONAL(HAVE_LIBRTP, test "x$HAVE_LIBRTP" = "xyes")
AM_CONDITIONAL(HAVE_ARTS, test "x$HAVE_ARTS" = "xyes")
AM_CONDITIONAL(HAVE_RAW1394, test "x%HAVE_RAW1394" = "xyes")
+AM_CONDITIONAL(HAVE_LIBDV, test "x%HAVE_LIBDV" = "xyes")
@@ -881,6 +885,7 @@ plugins/artsd/Makefile
plugins/xmms/Makefile
plugins/arts/Makefile
plugins/1394/Makefile
+plugins/dv/Makefile
gstplay/Makefile
dnl components/bonobo-gstmediaplay/Makefile
test/Makefile
diff --git a/examples/autoplug/autoplug.c b/examples/autoplug/autoplug.c
index 091508e352..e9135fb8d2 100644
--- a/examples/autoplug/autoplug.c
+++ b/examples/autoplug/autoplug.c
@@ -112,6 +112,11 @@ int main(int argc,char *argv[])
exit (-1);
}
+ gst_bin_remove (GST_BIN (bin), disksrc);
+ // FIXME hack, reparent the disksrc so the scheduler doesn't break
+ bin = gst_pipeline_new("pipeline");
+
+ gst_bin_add (GST_BIN (bin), disksrc);
gst_bin_add (GST_BIN (bin), new_element);
gst_element_connect (disksrc, "src", new_element, "sink");
diff --git a/gst/autoplug/gststaticautoplugrender.c b/gst/autoplug/gststaticautoplugrender.c
index caf5ef5fb8..c544f7f189 100644
--- a/gst/autoplug/gststaticautoplugrender.c
+++ b/gst/autoplug/gststaticautoplugrender.c
@@ -270,7 +270,10 @@ gst_static_autoplug_to_render (GstAutoplug *autoplug, GstCaps *srccaps, GstEleme
pad = GST_PAD_REALIZE (gst_element_get_pad_list (targetelement)->data);
templ = GST_PAD_PADTEMPLATE (pad);
- caps.sink = GST_PADTEMPLATE_CAPS (templ);
+ if (templ)
+ caps.sink = GST_PADTEMPLATE_CAPS (templ);
+ else
+ goto next;
GST_INFO (GST_CAT_AUTOPLUG_ATTEMPT,"autoplugging two caps structures");
@@ -286,7 +289,7 @@ gst_static_autoplug_to_render (GstAutoplug *autoplug, GstCaps *srccaps, GstEleme
}
else {
}
-
+next:
targetelement = va_arg (args, GstElement *);
}
diff --git a/gst/gstbuffer.c b/gst/gstbuffer.c
index 5f29ab84d1..6993391efa 100644
--- a/gst/gstbuffer.c
+++ b/gst/gstbuffer.c
@@ -64,7 +64,6 @@ gst_buffer_new(void)
buffer->refcount = 1;
#endif
buffer->flags = 0;
- buffer->type = 0;
buffer->data = NULL;
buffer->size = 0;
buffer->maxsize = 0;
@@ -126,7 +125,6 @@ gst_buffer_create_sub (GstBuffer *parent,
// copy flags and type from parent, for lack of better
buffer->flags = parent->flags;
- buffer->type = parent->type;
// set the data pointer, size, offset, and maxsize
buffer->data = parent->data + offset;
@@ -395,3 +393,34 @@ gst_buffer_remove_meta (GstBuffer *buffer, GstMeta *meta)
buffer->metas = g_slist_remove (buffer->metas, meta);
gst_meta_unref (meta);
}
+
+
+
+/**
+ * gst_buffer_copy:
+ * @buffer: the orignal GstBuffer to make a copy of
+ *
+ * Make a full copy of the give buffer, data and all.
+ *
+ * Returns: new buffer
+ */
+GstBuffer *
+gst_buffer_copy (GstBuffer *buffer)
+{
+ GstBuffer *newbuf;
+
+ newbuf = gst_buffer_new();
+ GST_BUFFER_SIZE(newbuf) = GST_BUFFER_SIZE(buffer);
+ GST_BUFFER_DATA(newbuf) = malloc(GST_BUFFER_SIZE(buffer));
+ memcpy(GST_BUFFER_DATA(newbuf),GST_BUFFER_DATA(buffer),GST_BUFFER_SIZE(buffer));
+ GST_BUFFER_MAXSIZE(newbuf) = GST_BUFFER_MAXSIZE(buffer);
+ GST_BUFFER_OFFSET(newbuf) = GST_BUFFER_OFFSET(buffer);
+ GST_BUFFER_TIMESTAMP(newbuf) = GST_BUFFER_TIMESTAMP(buffer);
+ GST_BUFFER_MAXAGE(newbuf) = GST_BUFFER_MAXAGE(buffer);
+
+ // since we just created a new buffer, so we have no ties to old stuff
+ GST_BUFFER_PARENT(newbuf) = NULL;
+ GST_BUFFER_POOL(newbuf) = NULL;
+
+ return newbuf;
+}
diff --git a/gst/gstbuffer.h b/gst/gstbuffer.h
index bf9fe23f36..0c8f224f17 100644
--- a/gst/gstbuffer.h
+++ b/gst/gstbuffer.h
@@ -54,13 +54,14 @@ extern "C" {
G_STMT_START{ (GST_BUFFER_FLAGS(buf) &= ~(1<<(flag))); }G_STMT_END
-#define GST_BUFFER_TYPE(buf) (GST_BUFFER(buf)->type)
#define GST_BUFFER_DATA(buf) (GST_BUFFER(buf)->data)
#define GST_BUFFER_SIZE(buf) (GST_BUFFER(buf)->size)
#define GST_BUFFER_OFFSET(buf) (GST_BUFFER(buf)->offset)
#define GST_BUFFER_MAXSIZE(buf) (GST_BUFFER(buf)->maxsize)
#define GST_BUFFER_TIMESTAMP(buf) (GST_BUFFER(buf)->timestamp)
+#define GST_BUFFER_MAXAGE(buf) (GST_BUFFER(buf)->maxage)
#define GST_BUFFER_BUFFERPOOL(buf) (GST_BUFFER(buf)->pool)
+#define GST_BUFFER_PARENT(buf) (GST_BUFFER(buf)->parent)
#define GST_BUFFER_POOL_PRIVATE(buf) (GST_BUFFER(buf)->pool_private)
@@ -96,8 +97,6 @@ struct _GstBuffer {
#define GST_BUFFER_REFCOUNT(buf) (GST_BUFFER(buf)->refcount)
#endif
- /* data type of this buffer */
- guint16 type;
/* flags */
guint16 flags;
@@ -143,6 +142,9 @@ void gst_buffer_unref (GstBuffer *buffer);
/* destroying the buffer */
void gst_buffer_destroy (GstBuffer *buffer);
+/* copy buffer */
+GstBuffer* gst_buffer_copy (GstBuffer *buffer);
+
/* add, retrieve, and remove metadata from the buffer */
void gst_buffer_add_meta (GstBuffer *buffer, GstMeta *meta);
void gst_buffer_remove_meta (GstBuffer *buffer, GstMeta *meta);
diff --git a/gst/gstcaps.h b/gst/gstcaps.h
index 50afb3d88a..2665a8d7d5 100644
--- a/gst/gstcaps.h
+++ b/gst/gstcaps.h
@@ -61,7 +61,7 @@ gst_caps_new ( \
name, \
type, \
gst_props_new ( \
- ##a, \
+ a, \
NULL))
#define GST_CAPS_FACTORY(factoryname, a...) \
@@ -70,7 +70,7 @@ factoryname (void) \
{ \
static GstCaps *caps = NULL; \
if (!caps) { \
- caps = gst_caps_chain (##a, NULL); \
+ caps = gst_caps_chain (a, NULL); \
} \
return caps; \
}
diff --git a/gst/gstprops.h b/gst/gstprops.h
index a67acf8aea..07cab144bc 100644
--- a/gst/gstprops.h
+++ b/gst/gstprops.h
@@ -51,6 +51,7 @@ typedef enum {
} GstPropsId;
#define GST_MAKE_FOURCC(a,b,c,d) ((a)|(b)<<8|(c)<<16|(d)<<24)
+#define GST_STR_FOURCC(f) (((f)[0])|((f)[1]<<8)|((f)[2]<<16)|((f)[3]<<24))
#define GST_PROPS_LIST(a...) GST_PROPS_LIST_ID,##a,NULL
#define GST_PROPS_INT(a) GST_PROPS_INT_ID,(a)
diff --git a/libs/putbits/gstputbits.c b/libs/putbits/gstputbits.c
index 9ec9750bb5..cf4a4c17c4 100644
--- a/libs/putbits/gstputbits.c
+++ b/libs/putbits/gstputbits.c
@@ -63,7 +63,7 @@ void gst_putbits(gst_putbits_t *pb, int val, int n)
int i;
unsigned int mask;
- //printf("putbits: %d %d %ld %ld\n", val, n, pb->outcnt, pb->newlen);
+ //printf("putbits: %p %08x %d %d %d\n", pb, val, n, pb->outcnt, pb->newlen);
mask = 1 << (n-1); /* selects first (leftmost) bit */
for (i=0; i<n; i++)
diff --git a/test/Makefile.am b/test/Makefile.am
index 9e7e1a111e..fe01e4d7b1 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -4,7 +4,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 mp3tovorbis mpeg2parse2 xmmstest videotest2 \
- mp3mad
+ mp3mad video2mp1 dvshow
SUBDIRS = xml bindings
diff --git a/test/dvshow.c b/test/dvshow.c
new file mode 100644
index 0000000000..21c25b03b7
--- /dev/null
+++ b/test/dvshow.c
@@ -0,0 +1,93 @@
+#include <gnome.h>
+#include <gst/gst.h>
+
+static gboolean
+idle_func (gpointer data)
+{
+ gst_bin_iterate(GST_BIN(data));
+
+ return TRUE;
+}
+
+int
+main (int argc,char *argv[])
+{
+ GstElement *bin;
+ GstElement *src;
+ GstElement *dvdec;
+ GstElement *cspace;
+ GstElement *videosink;
+
+ GtkWidget *appwindow;
+ GtkWidget *vbox1;
+ GtkWidget *button;
+ guint32 draw;
+ GtkWidget *gtk_socket;
+
+
+ gst_init(&argc,&argv);
+
+ gnome_init("Videotest","0.0.1",argc,argv);
+
+ bin = gst_bin_new("bin");
+
+ if (argc == 1) {
+ src = gst_elementfactory_make ("gst1394src", "src");
+ } else {
+ src = gst_elementfactory_make ("disksrc", "src");
+ gtk_object_set(GTK_OBJECT(src),"location",argv[1],"bytesperread",480,NULL);
+ }
+ dvdec = gst_elementfactory_make ("dvdec", "decoder");
+// cspace = gst_elementfactory_make ("colorspace", "cspace");
+ videosink = gst_elementfactory_make ("xvideosink", "videosink");
+ gtk_object_set(GTK_OBJECT(videosink),"width",720,"height",480,NULL);
+
+ gst_bin_add(GST_BIN(bin),GST_ELEMENT(src));
+ gst_bin_add(GST_BIN(bin),GST_ELEMENT(dvdec));
+// gst_bin_add(GST_BIN(bin),GST_ELEMENT(cspace));
+ gst_bin_add(GST_BIN(bin),GST_ELEMENT(videosink));
+
+ gst_element_connect(src,"src",dvdec,"sink");
+// gst_element_connect(cspace,"src",videosink,"sink");
+// gst_element_connect(dvdec,"video",cspace,"sink");
+ gst_element_connect(dvdec,"video",videosink,"sink");
+
+ appwindow = gnome_app_new("Videotest","Videotest");
+
+ vbox1 = gtk_vbox_new (FALSE, 0);
+ gtk_widget_show (vbox1);
+
+ button = gtk_button_new_with_label(_("test"));//_with_label (_("chup"));
+ gtk_widget_show (button);
+ gtk_box_pack_start (GTK_BOX (vbox1), button, FALSE, FALSE, 0);
+
+ draw = gst_util_get_int_arg (GTK_OBJECT (videosink), "xid"),
+
+ gtk_socket = gtk_socket_new ();
+ gtk_widget_show (gtk_socket);
+
+ gnome_app_set_contents(GNOME_APP(appwindow), vbox1);
+
+ gtk_box_pack_start (GTK_BOX (vbox1),
+ GTK_WIDGET(gtk_socket),
+ TRUE, TRUE, 0);
+
+ gtk_widget_realize (gtk_socket);
+ gtk_socket_steal (GTK_SOCKET (gtk_socket), draw);
+
+ gtk_object_set(GTK_OBJECT(appwindow),"allow_grow",TRUE,NULL);
+ gtk_object_set(GTK_OBJECT(appwindow),"allow_shrink",TRUE,NULL);
+
+ gtk_widget_show_all(appwindow);
+
+ xmlSaveFile("dvshow.xml",gst_xml_write(GST_ELEMENT(bin)));
+
+ gst_element_set_state(GST_ELEMENT(bin),GST_STATE_PLAYING);
+
+ g_idle_add(idle_func,bin);
+
+ gtk_main();
+
+ exit (0);
+}
+
diff --git a/test/mp2tomp1.c b/test/mp2tomp1.c
index 78d9550ec1..3a609f1162 100644
--- a/test/mp2tomp1.c
+++ b/test/mp2tomp1.c
@@ -37,7 +37,7 @@ create_muxer (GstElement *pipeline, gchar *type, gchar *number)
static void
mp2tomp1 (GstElement *parser, GstPad *pad, GstElement *pipeline)
{
- GstElement *parse_audio, *parse_video, *decode, *decode_video, *play, *encode, *audio_resample;
+ GstElement *decode, *decode_video, *play, *encode, *audio_resample;
GstElement *smooth, *median;
GstElement *audio_queue, *video_queue;
GstElement *audio_thread, *video_thread;
@@ -51,9 +51,6 @@ mp2tomp1 (GstElement *parser, GstPad *pad, GstElement *pipeline)
//if (0) {
if (strncmp(gst_pad_get_name(pad), "private_stream_1.0", 18) == 0) {
// construct internal pipeline elements
- parse_audio = gst_elementfactory_make("ac3parse","parse_audio");
- g_return_if_fail(parse_audio != NULL);
- gtk_object_set(GTK_OBJECT(parse_audio),"skip", 15, NULL);
decode = gst_elementfactory_make("ac3dec","decode_audio");
g_return_if_fail(decode != NULL);
audio_resample = gst_elementfactory_make("audioscale","audioscale");
@@ -68,7 +65,6 @@ mp2tomp1 (GstElement *parser, GstPad *pad, GstElement *pipeline)
// create the thread and pack stuff into it
audio_thread = gst_thread_new("audio_thread");
g_return_if_fail(audio_thread != NULL);
- gst_bin_add(GST_BIN(audio_thread),GST_ELEMENT(parse_audio));
gst_bin_add(GST_BIN(audio_thread),GST_ELEMENT(decode));
gst_bin_add(GST_BIN(audio_thread),GST_ELEMENT(audio_resample));
gst_bin_add(GST_BIN(audio_thread),GST_ELEMENT(audio_encode));
@@ -77,9 +73,7 @@ mp2tomp1 (GstElement *parser, GstPad *pad, GstElement *pipeline)
// set up pad connections
gst_element_add_ghost_pad(GST_ELEMENT(audio_thread),
- gst_element_get_pad(parse_audio,"sink"),"sink");
- gst_pad_connect(gst_element_get_pad(parse_audio,"src"),
- gst_element_get_pad(decode,"sink"));
+ gst_element_get_pad(decode,"sink"),"sink");
gst_pad_connect(gst_element_get_pad(decode,"src"),
gst_element_get_pad(audio_resample,"sink"));
gst_pad_connect(gst_element_get_pad(audio_resample,"src"),
@@ -106,9 +100,7 @@ mp2tomp1 (GstElement *parser, GstPad *pad, GstElement *pipeline)
// gst_element_get_pad(merge_subtitles,"subtitle"));
} else if (strncmp(gst_pad_get_name(pad), "audio_", 6) == 0) {
// construct internal pipeline elements
- parse_audio = gst_elementfactory_make("mp3parse","parse_audio");
- g_return_if_fail(parse_audio != NULL);
- decode = gst_elementfactory_make("mpg123","decode_audio");
+ decode = gst_elementfactory_make("mad","decode_audio");
g_return_if_fail(decode != NULL);
play = gst_elementfactory_make("osssink","play_audio");
g_return_if_fail(play != NULL);
@@ -116,16 +108,13 @@ mp2tomp1 (GstElement *parser, GstPad *pad, GstElement *pipeline)
// create the thread and pack stuff into it
audio_thread = gst_thread_new("audio_thread");
g_return_if_fail(audio_thread != NULL);
- gst_bin_add(GST_BIN(audio_thread),GST_ELEMENT(parse_audio));
gst_bin_add(GST_BIN(audio_thread),GST_ELEMENT(decode));
gst_bin_add(GST_BIN(audio_thread),GST_ELEMENT(play));
// set up pad connections
gst_element_add_ghost_pad(GST_ELEMENT(audio_thread),
- gst_element_get_pad(parse_audio,"sink"),"sink");
- gst_pad_connect(gst_element_get_pad(parse_audio,"src"),
- gst_element_get_pad(decode,"sink"));
+ gst_element_get_pad(decode,"sink"),"sink");
gst_pad_connect(gst_element_get_pad(decode,"src"),
gst_element_get_pad(play,"sink"));
@@ -148,9 +137,7 @@ mp2tomp1 (GstElement *parser, GstPad *pad, GstElement *pipeline)
//gst_plugin_load("mpeg1encoder");
// construct internal pipeline elements
- parse_video = gst_elementfactory_make("mp2videoparse","parse_video");
- g_return_if_fail(parse_video != NULL);
- decode_video = gst_elementfactory_make("mpeg2play","decode_video");
+ decode_video = gst_elementfactory_make("mpeg2dec","decode_video");
g_return_if_fail(decode_video != NULL);
//merge_subtitles = gst_elementfactory_make("mpeg2subt","merge_subtitles");
//g_return_if_fail(merge_subtitles != NULL);
@@ -174,13 +161,14 @@ mp2tomp1 (GstElement *parser, GstPad *pad, GstElement *pipeline)
//gtk_object_set(GTK_OBJECT(show),"width",640, "height", 480,NULL);
muxerpad = create_muxer (pipeline, "video", "00");
+ g_return_if_fail(muxerpad != NULL);
+
// create the thread and pack stuff into it
video_thread = gst_thread_new("video_thread");
g_return_if_fail(video_thread != NULL);
- gst_bin_add(GST_BIN(video_thread),GST_ELEMENT(parse_video));
gst_bin_add(GST_BIN(video_thread),GST_ELEMENT(decode_video));
- gst_bin_add(GST_BIN(video_thread),GST_ELEMENT(merge_subtitles));
+ //gst_bin_add(GST_BIN(video_thread),GST_ELEMENT(merge_subtitles));
gst_bin_add(GST_BIN(video_thread),GST_ELEMENT(median));
gst_bin_add(GST_BIN(video_thread),GST_ELEMENT(smooth));
gst_bin_add(GST_BIN(video_thread),GST_ELEMENT(videoscale));
@@ -189,9 +177,7 @@ mp2tomp1 (GstElement *parser, GstPad *pad, GstElement *pipeline)
// set up pad connections
gst_element_add_ghost_pad(GST_ELEMENT(video_thread),
- gst_element_get_pad(parse_video,"sink"),"sink");
- gst_pad_connect(gst_element_get_pad(parse_video,"src"),
- gst_element_get_pad(decode_video,"sink"));
+ gst_element_get_pad(decode_video,"sink"),"sink");
gst_pad_connect(gst_element_get_pad(decode_video,"src"),
gst_element_get_pad(median,"sink"));
gst_pad_connect(gst_element_get_pad(median,"src"),
diff --git a/test/video2mp1.c b/test/video2mp1.c
new file mode 100644
index 0000000000..79b3a50c91
--- /dev/null
+++ b/test/video2mp1.c
@@ -0,0 +1,236 @@
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <string.h>
+#include <glib.h>
+#include <gst/gst.h>
+#include <gnome.h>
+
+static void
+gst_play_have_type (GstElement *sink, GstElement *sink2, gpointer data)
+{
+ GST_DEBUG (0,"GstPipeline: play have type %p\n", (gboolean *)data);
+
+ *(gboolean *)data = TRUE;
+}
+
+gboolean
+idle_func (gpointer data)
+{
+ return gst_bin_iterate (GST_BIN (data));
+}
+
+static GstCaps*
+gst_play_typefind (GstBin *bin, GstElement *element)
+{
+ gboolean found = FALSE;
+ GstElement *typefind;
+ GstCaps *caps = NULL;
+
+ GST_DEBUG (0,"GstPipeline: typefind for element \"%s\" %p\n",
+ GST_ELEMENT_NAME(element), &found);
+
+ typefind = gst_elementfactory_make ("typefind", "typefind");
+ g_return_val_if_fail (typefind != NULL, FALSE);
+
+ gtk_signal_connect (GTK_OBJECT (typefind), "have_type",
+ GTK_SIGNAL_FUNC (gst_play_have_type), &found);
+
+ gst_pad_connect (gst_element_get_pad (element, "src"),
+ gst_element_get_pad (typefind, "sink"));
+
+ gst_bin_add (bin, typefind);
+
+ gst_element_set_state (GST_ELEMENT (bin), GST_STATE_PLAYING);
+
+ // push a buffer... the have_type signal handler will set the found flag
+ gst_bin_iterate (bin);
+
+ gst_element_set_state (GST_ELEMENT (bin), GST_STATE_NULL);
+
+ caps = gst_pad_get_caps (gst_element_get_pad (element, "src"));
+
+ gst_pad_disconnect (gst_element_get_pad (element, "src"),
+ gst_element_get_pad (typefind, "sink"));
+ gst_bin_remove (bin, typefind);
+ gst_object_unref (GST_OBJECT (typefind));
+
+ return caps;
+}
+
+static GstElement*
+get_video_encoder_bin (void)
+{
+ GstElement *bin;
+ GstElement *encoder, *queue, *colorspace, *videoscale;
+
+ bin = gst_bin_new ("video_encoder_bin");
+
+ colorspace = gst_elementfactory_make ("colorspace", "colorspace");
+ g_assert (colorspace != NULL);
+ videoscale = gst_elementfactory_make ("videoscale", "videoscale");
+ g_assert (videoscale != NULL);
+ gtk_object_set (GTK_OBJECT (videoscale), "width", 352, "height", 288, NULL);
+ encoder = gst_elementfactory_make ("mpeg2enc", "video_encoder");
+ g_assert (encoder != NULL);
+ queue = gst_elementfactory_make ("queue", "video_encoder_queue");
+ g_assert (queue != NULL);
+
+ gst_bin_add (GST_BIN (bin), colorspace);
+ gst_bin_add (GST_BIN (bin), videoscale);
+ gst_bin_add (GST_BIN (bin), encoder);
+ gst_bin_add (GST_BIN (bin), queue);
+
+ gst_element_connect (colorspace, "src", videoscale, "sink");
+ gst_element_connect (videoscale, "src", encoder, "sink");
+ gst_element_connect (encoder, "src", queue, "sink");
+
+ gst_element_add_ghost_pad (bin, gst_element_get_pad (colorspace, "sink"), "sink");
+ gst_element_add_ghost_pad (bin, gst_element_get_pad (queue, "src"), "src");
+
+ return bin;
+}
+
+static GstElement*
+get_audio_encoder_bin (void)
+{
+ GstElement *bin;
+ GstElement *encoder, *queue;
+
+ bin = gst_bin_new ("audio_encoder_bin");
+
+ encoder = gst_elementfactory_make ("mpegaudio", "audio_encoder");
+ g_assert (encoder != NULL);
+ queue = gst_elementfactory_make ("queue", "audio_encoder_queue");
+ g_assert (queue != NULL);
+
+ gst_bin_add (GST_BIN (bin), encoder);
+ gst_bin_add (GST_BIN (bin), queue);
+
+ gst_element_connect (encoder, "src", queue, "sink");
+
+ gst_element_add_ghost_pad (bin, gst_element_get_pad (encoder, "sink"), "sink");
+ gst_element_add_ghost_pad (bin, gst_element_get_pad (queue, "src"), "src");
+
+ return bin;
+}
+
+int main(int argc,char *argv[])
+{
+ GstElement *disksrc, *audio_enc, *video_enc;
+ GstElement *muxthread_video, *muxer, *fdsink_video;
+ GstElement *muxthread_audio, *fdsink_audio;
+ GstElement *bin;
+ GtkWidget *appwindow;
+ GstCaps *srccaps;
+ GstElement *new_element;
+ GstAutoplug *autoplug;
+ GtkWidget *socket;
+ gint fd_video;
+ gint fd_audio;
+
+ g_thread_init(NULL);
+ gst_init(&argc,&argv);
+ gnome_init("autoplug","0.0.1", argc,argv);
+
+ if (argc != 4) {
+ g_print("usage: %s <in_filename> <out_video> <out_audio>\n", argv[0]);
+ exit(-1);
+ }
+
+ /* create a new bin to hold the elements */
+ bin = gst_pipeline_new("pipeline");
+ g_assert(bin != NULL);
+
+ /* create a disk reader */
+ disksrc = gst_elementfactory_make("disksrc", "disk_source");
+ g_assert(disksrc != NULL);
+ gtk_object_set(GTK_OBJECT(disksrc),"location", argv[1],NULL);
+
+ gst_bin_add (GST_BIN (bin), disksrc);
+
+ srccaps = gst_play_typefind (GST_BIN (bin), disksrc);
+
+ if (!srccaps) {
+ g_print ("could not autoplug, unknown media type...\n");
+ exit (-1);
+ }
+
+ audio_enc = get_audio_encoder_bin();
+ video_enc = get_video_encoder_bin();
+
+ autoplug = gst_autoplugfactory_make ("staticrender");
+ g_assert (autoplug != NULL);
+
+ new_element = gst_autoplug_to_renderers (autoplug,
+ srccaps,
+ video_enc,
+ audio_enc,
+ NULL);
+
+ if (!new_element) {
+ g_print ("could not autoplug, no suitable codecs found...\n");
+ exit (-1);
+ }
+
+ gst_bin_remove (GST_BIN (bin), disksrc);
+ gst_object_destroy (GST_OBJECT (bin));
+
+ // FIXME hack, reparent the disksrc so the scheduler doesn't break
+ bin = gst_pipeline_new("pipeline");
+
+ gst_bin_add (GST_BIN (bin), disksrc);
+ gst_bin_add (GST_BIN (bin), new_element);
+
+ gst_element_connect (disksrc, "src", new_element, "sink");
+
+ muxer = gst_elementfactory_make ("system_encode", "muxer");
+ g_assert (muxer != NULL);
+
+ if (gst_bin_get_by_name (GST_BIN (new_element), "video_encoder_bin")) {
+ muxthread_video = gst_thread_new("thread_video");
+
+ fdsink_video = gst_elementfactory_make ("fdsink", "fdsink_video");
+ g_assert (fdsink_video != NULL);
+ fd_video = open (argv[2], O_CREAT|O_RDWR|O_TRUNC);
+ gtk_object_set (GTK_OBJECT (fdsink_video), "fd", fd_video, NULL);
+
+ gst_element_connect (video_enc, "src", fdsink_video, "sink");
+ gst_bin_add (GST_BIN (muxthread_video), fdsink_video);
+
+ gst_bin_add (GST_BIN (bin), muxthread_video);
+ }
+
+ if (gst_bin_get_by_name (GST_BIN (new_element), "audio_encoder_bin")) {
+ muxthread_audio = gst_thread_new("thread_audio");
+
+ fdsink_audio = gst_elementfactory_make ("fdsink", "fdsink_audio");
+ g_assert (fdsink_audio != NULL);
+ fd_audio = open (argv[3], O_CREAT|O_RDWR|O_TRUNC);
+ gtk_object_set (GTK_OBJECT (fdsink_audio), "fd", fd_audio, NULL);
+
+ gst_element_connect (audio_enc, "src", fdsink_audio, "sink");
+ gst_bin_add (GST_BIN (muxthread_audio), fdsink_audio);
+
+ gst_bin_add (GST_BIN (bin), muxthread_audio);
+ }
+
+ //gtk_object_set (GTK_OBJECT (muxer), "video", "00", NULL);
+ //gtk_object_set (GTK_OBJECT (muxer), "audio", "00", NULL);
+
+ /* start playing */
+ gst_element_set_state(GST_ELEMENT(bin), GST_STATE_PLAYING);
+
+ gtk_idle_add(idle_func, bin);
+
+ gst_main();
+
+ /* stop the bin */
+ gst_element_set_state(GST_ELEMENT(bin), GST_STATE_NULL);
+
+ gst_pipeline_destroy(bin);
+
+ exit(0);
+}
+
diff --git a/tests/old/examples/autoplug/autoplug.c b/tests/old/examples/autoplug/autoplug.c
index 091508e352..e9135fb8d2 100644
--- a/tests/old/examples/autoplug/autoplug.c
+++ b/tests/old/examples/autoplug/autoplug.c
@@ -112,6 +112,11 @@ int main(int argc,char *argv[])
exit (-1);
}
+ gst_bin_remove (GST_BIN (bin), disksrc);
+ // FIXME hack, reparent the disksrc so the scheduler doesn't break
+ bin = gst_pipeline_new("pipeline");
+
+ gst_bin_add (GST_BIN (bin), disksrc);
gst_bin_add (GST_BIN (bin), new_element);
gst_element_connect (disksrc, "src", new_element, "sink");