Build fixes.

Original commit message from CVS:
Build fixes.
Adapted the test directory to the new state management
added an mpeg2 to avi encoder.
added a v4l to divx capture example.
This commit is contained in:
Wim Taymans 2000-08-14 15:17:24 +00:00
parent e9bb9dac5d
commit d6e6b9cb60
29 changed files with 613 additions and 225 deletions

View file

@ -1,4 +1,4 @@
SUBDIRS = gst libs plugins test editor tools docs tests
SUBDIRS = gst libs plugins gstplay test editor tools docs tests
bin_SCRIPTS = gstreamer-config

View file

@ -61,7 +61,7 @@ for dir in `find * -name autogen.sh -print | grep -v '^autogen.sh$' | \
popd > /dev/null
done
./configure --enable-maintainer-mode --enable-debug "$@"
./configure --enable-maintainer-mode "$@"
echo
echo "Now type 'make' to compile $package."

View file

@ -341,6 +341,7 @@ libs/videoscale/Makefile
libs/getbits/Makefile
libs/putbits/Makefile
libs/winloader/Makefile
libs/idct/Makefile
plugins/Makefile
plugins/au/Makefile
plugins/wav/Makefile

View file

@ -1,6 +1,6 @@
SUBDIRS =
if HAVE_GTK_DOC
SUBDIRS += gst manual
SUBDIRS += gst
endif
DIST_SUBDIRS = gst manual

2
test/.gitignore vendored
View file

@ -38,6 +38,8 @@ mp1parse
aviparse
avi2mpg
vidcapture
vidcapture2
mp2tomp1
mp2toavi
mp1tomp1
pipetest

View file

@ -1,26 +1,13 @@
#noinst_PROGRAMS = basic m types a r plugin w s args mpg123 mcut push qtest
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
aviparse vidcapture avi2mpg mp2tomp1 mp1tomp1 pipetest \
vidcapture2 mp2toavi
SUBDIRS = xml cothreads bindings
spectrum_CFLAGS = $(shell gnome-config --cflags gnomeui)
spectrum_LDFLAGS = $(shell gnome-config --libs gnomeui)
wave_CFLAGS = $(shell gnome-config --cflags gnomeui)
wave_LDFLAGS = $(shell gnome-config --libs gnomeui)
videotest_CFLAGS = $(shell gnome-config --cflags gnomeui)
videotest_LDFLAGS = $(shell gnome-config --libs gnomeui)
aviparse_CFLAGS = $(shell gnome-config --cflags gnomeui)
aviparse_LDFLAGS = $(shell gnome-config --libs gnomeui)
mp1parse_CFLAGS = $(shell gnome-config --cflags gnomeui)
mp1parse_LDFLAGS = $(shell gnome-config --libs gnomeui)
mpeg2parse_CFLAGS = $(shell gnome-config --cflags gnomeui)
mpeg2parse_LDFLAGS = $(shell gnome-config --libs gnomeui)
mp2tomp1_CFLAGS = $(shell gnome-config --cflags gnomeui)
mp2tomp1_LDFLAGS = $(shell gnome-config --libs gnomeui)
mp1tomp1_CFLAGS = $(shell gnome-config --cflags gnomeui)
mp1tomp1_LDFLAGS = $(shell gnome-config --libs gnomeui)
CFLAGS = -Wall $(shell gnome-config --cflags gnomeui)
LDFLAGS = $(shell gnome-config --libs gnomeui)
buffer_SOURCES = buffer.c mem.c
teardown_SOURCES = teardown.c mem.c
@ -28,9 +15,12 @@ ac3play_SOURCES = ac3play.c mem.c
noinst_HEADERS = mem.h
LDADD = $(GLIB_LIBS) $(GTK_LIBS) $(top_builddir)/gst/libgst.la \
$(top_builddir)/plugins/videosink/gdkxvimage.lo -lXv -lXxf86vm
#LDADD = $(GLIB_LIBS) $(GTK_LIBS) $(top_builddir)/gst/libgst.la \
# $(top_builddir)/plugins/videosink/libvideosink.la -L/usr/X11/lib -lXxf86dga
LDADD = $(GLIB_LIBS) $(GTK_LIBS) $(top_builddir)/gst/libgst.la
#LDADD = $(GLIB_LIBS) $(GTK_LIBS) $(top_builddir)/gst/libgst.la
INCLUDES = $(GLIB_CFLAGS) $(GTK_CFLAGS) -I$(top_srcdir) \

View file

@ -46,8 +46,8 @@ int main(int argc,char *argv[]) {
gst_pad_connect(gst_element_get_pad(parse,"src"),
infopad);
g_print("setting to RUNNING state\n");
gst_element_set_state(GST_ELEMENT(pipeline),GST_STATE_RUNNING);
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)

View file

@ -69,14 +69,14 @@ int main(int argc,char *argv[]) {
gtk_object_set(GTK_OBJECT(decodethread),"create_thread",TRUE,NULL);
gtk_object_set(GTK_OBJECT(playthread),"create_thread",FALSE,NULL);
g_print("setting to RUNNING state\n");
gst_element_set_state(GST_ELEMENT(pipeline),GST_STATE_RUNNING);
g_print("setting to READY state\n");
gst_element_set_state(GST_ELEMENT(pipeline),GST_STATE_READY);
gst_element_set_state(GST_ELEMENT(pipeline),GST_STATE_PLAYING);
// sleep(1);
g_print("about to enter loop\n");
while (1) {
gst_thread_iterate(GST_THREAD(playthread));
gst_thread_main_loop(GST_THREAD(playthread));
g_print("using %d bytes\n",vmsize());
}

View file

@ -1,6 +1,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#include <glib.h>
#include <gst/gst.h>
@ -18,14 +19,13 @@ void eof(GstSrc *src) {
}
void new_pad_created(GstElement *parse,GstPad *pad,GstElement *pipeline) {
GstElement *parse_audio, *parse_video, *decode, *decode_video, *audio_encode;
GstElement *audio_encode;
GstElement *encode, *smooth, *median;
GstElement *audio_queue, *video_queue;
GstElement *audio_thread, *video_thread;
GtkWidget *appwindow;
g_print("***** a new pad %s was created\n", gst_pad_get_name(pad));
gst_element_set_state(GST_ELEMENT(pipeline),GST_STATE_PAUSED);
// connect to audio pad
//if (0) {
@ -61,10 +61,8 @@ void new_pad_created(GstElement *parse,GstPad *pad,GstElement *pipeline) {
// set up thread state and kick things off
gtk_object_set(GTK_OBJECT(audio_thread),"create_thread",TRUE,NULL);
g_print("setting to RUNNING state\n");
gst_element_set_state(GST_ELEMENT(audio_thread),GST_STATE_RUNNING);
g_print("setting to PLAYING state\n");
gst_element_set_state(GST_ELEMENT(audio_thread),GST_STATE_PLAYING);
g_print("setting to READY state\n");
gst_element_set_state(GST_ELEMENT(audio_thread),GST_STATE_READY);
} else if (strncmp(gst_pad_get_name(pad), "video_", 6) == 0) {
//} else if (0) {
@ -117,12 +115,11 @@ void new_pad_created(GstElement *parse,GstPad *pad,GstElement *pipeline) {
// set up thread state and kick things off
gtk_object_set(GTK_OBJECT(video_thread),"create_thread",TRUE,NULL);
g_print("setting to RUNNING state\n");
gst_element_set_state(GST_ELEMENT(video_thread),GST_STATE_RUNNING);
g_print("setting to PLAYING state\n");
gst_element_set_state(GST_ELEMENT(video_thread),GST_STATE_PLAYING);
g_print("setting to READY state\n");
gst_element_set_state(GST_ELEMENT(video_thread),GST_STATE_READY);
}
g_print("\n");
gst_element_set_state(GST_ELEMENT(pipeline),GST_STATE_PLAYING);
}
int main(int argc,char *argv[]) {
@ -133,29 +130,30 @@ int main(int argc,char *argv[]) {
g_print("have %d args\n",argc);
//_gst_plugin_spew = TRUE;
g_thread_init(NULL);
gst_init(&argc,&argv);
gst_plugin_load("parseavi");
gst_plugin_load("system_encode");
pipeline = gst_pipeline_new("pipeline");
g_return_if_fail(pipeline != NULL);
g_return_val_if_fail(pipeline != NULL, -1);
src = gst_elementfactory_make("disksrc","src");
g_return_if_fail(src != NULL);
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_make("parseavi","parse");
g_return_if_fail(parse != NULL);
g_return_val_if_fail(parse != NULL, -1);
mux = gst_elementfactory_make("system_encode","mux");
g_return_if_fail(mux != NULL);
g_return_val_if_fail(mux != NULL, -1);
g_print("should be using output file '%s'\n",argv[2]);
outfile = argv[2];
fd = open(argv[2],O_CREAT|O_RDWR|O_TRUNC);
fdsinkfactory = gst_elementfactory_find("fdsink");
g_return_if_fail(fdsinkfactory != NULL);
g_return_val_if_fail(fdsinkfactory != NULL, -1);
fdsink = gst_elementfactory_create(fdsinkfactory,"fdsink");
g_return_if_fail(fdsink != NULL);
g_return_val_if_fail(fdsink != NULL, -1);
gtk_object_set(GTK_OBJECT(fdsink),"fd",fd,NULL);
gst_bin_add(GST_BIN(pipeline),GST_ELEMENT(src));
@ -174,22 +172,18 @@ int main(int argc,char *argv[]) {
gst_pad_connect(gst_element_get_pad(mux,"src"),
gst_element_get_pad(fdsink,"sink"));
g_print("setting to RUNNING state\n");
gst_element_set_state(GST_ELEMENT(pipeline),GST_STATE_RUNNING);
xmlSaveFile("aviparse.xml",gst_xml_write(GST_ELEMENT(pipeline)));
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));
}
// this does not work due to multithreading
/*
g_idle_add(idle_func,src);
gdk_threads_enter();
gtk_main();
*/
gdk_threads_leave();
return 0;
}
gboolean idle_func(gpointer data) {

View file

@ -4,6 +4,10 @@
extern gboolean _gst_plugin_spew;
gboolean idle_func(gpointer data);
GtkWidget *appwindow;
GstElement *show, *play;
GstElement *audio_thread, *video_thread;
GstElement *audio_queue, *video_queue;
void eof(GstSrc *src) {
g_print("have eos, quitting\n");
@ -11,13 +15,9 @@ void eof(GstSrc *src) {
}
void new_pad_created(GstElement *parse,GstPad *pad,GstElement *pipeline) {
GstElement *parse_audio, *parse_video, *decode, *decode_video, *play, *show;
GstElement *audio_queue, *video_queue;
GstElement *audio_thread, *video_thread;
GtkWidget *appwindow;
g_print("***** a new pad %s was created\n", gst_pad_get_name(pad));
gst_element_set_state(GST_ELEMENT(pipeline),GST_STATE_PAUSED);
// connect to audio pad
//if (0) {
@ -46,50 +46,16 @@ void new_pad_created(GstElement *parse,GstPad *pad,GstElement *pipeline) {
// set up thread state and kick things off
gtk_object_set(GTK_OBJECT(audio_thread),"create_thread",TRUE,NULL);
g_print("setting to RUNNING state\n");
gst_element_set_state(GST_ELEMENT(audio_thread),GST_STATE_RUNNING);
g_print("setting to READY state\n");
gst_element_set_state(GST_ELEMENT(audio_thread),GST_STATE_READY);
g_print("setting to PLAYING state\n");
gst_element_set_state(GST_ELEMENT(audio_thread),GST_STATE_PLAYING);
} else if (strncmp(gst_pad_get_name(pad), "video_", 6) == 0) {
//} else if (0) {
gst_plugin_load("videosink");
// construct internal pipeline elements
show = gst_elementfactory_make("videosink","show");
g_return_if_fail(show != NULL);
//gtk_object_set(GTK_OBJECT(show),"width",640, "height", 480,NULL);
appwindow = gnome_app_new("AVI player","AVI player");
gnome_app_set_contents(GNOME_APP(appwindow),
gst_util_get_widget_arg(GTK_OBJECT(show),"widget"));
gtk_widget_show_all(appwindow);
// 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(show));
// set up pad connections
gst_element_add_ghost_pad(GST_ELEMENT(video_thread),
gst_element_get_pad(show,"sink"));
// construct queue and connect everything in the main pipeline
video_queue = gst_elementfactory_make("queue","video_queue");
gst_bin_add(GST_BIN(pipeline),GST_ELEMENT(video_queue));
gst_bin_add(GST_BIN(pipeline),GST_ELEMENT(video_thread));
//} else if (0) {
gst_pad_connect(pad,
gst_element_get_pad(video_queue,"sink"));
gst_pad_connect(gst_element_get_pad(video_queue,"src"),
gst_element_get_pad(video_thread,"sink"));
// set up thread state and kick things off
gtk_object_set(GTK_OBJECT(video_thread),"create_thread",TRUE,NULL);
g_print("setting to RUNNING state\n");
gst_element_set_state(GST_ELEMENT(video_thread),GST_STATE_RUNNING);
g_print("setting to PLAYING state\n");
gst_element_set_state(GST_ELEMENT(video_thread),GST_STATE_PLAYING);
}
g_print("\n");
gst_element_set_state(GST_ELEMENT(pipeline),GST_STATE_PLAYING);
}
int main(int argc,char *argv[]) {
@ -98,22 +64,54 @@ int main(int argc,char *argv[]) {
g_print("have %d args\n",argc);
g_thread_init(NULL);
gtk_init(&argc,&argv);
gnome_init("AVI Video player","0.0.1",argc,argv);
//_gst_plugin_spew = TRUE;
gst_init(&argc,&argv);
gnome_init("AVI Video player","0.0.1",argc,argv);
//gst_plugin_load_all();
gst_plugin_load("parseavi");
gst_plugin_load("videosink");
pipeline = gst_pipeline_new("pipeline");
g_return_if_fail(pipeline != NULL);
g_return_val_if_fail(pipeline != NULL, -1);
src = gst_elementfactory_make("disksrc","src");
g_return_if_fail(src != NULL);
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_make("parseavi","parse");
g_return_if_fail(parse != NULL);
g_return_val_if_fail(parse != NULL, -1);
video_thread = gst_thread_new("video_thread");
g_return_val_if_fail(video_thread != NULL, -1);
// construct internal pipeline elements
show = gst_elementfactory_make("videosink","show");
g_return_val_if_fail(show != NULL, -1);
gtk_object_set(GTK_OBJECT(show),"xv_enabled",FALSE,NULL);
//gtk_object_set(GTK_OBJECT(show),"width",640, "height", 480,NULL);
appwindow = gnome_app_new("AVI player","AVI player");
gnome_app_set_contents(GNOME_APP(appwindow),
gst_util_get_widget_arg(GTK_OBJECT(show),"widget"));
gtk_widget_show_all(appwindow);
// create the thread and pack stuff into it
gst_bin_add(GST_BIN(video_thread),GST_ELEMENT(show));
// set up pad connections
gst_element_add_ghost_pad(GST_ELEMENT(video_thread),
gst_element_get_pad(show,"sink"));
// construct queue and connect everything in the main pipeline
video_queue = gst_elementfactory_make("queue","video_queue");
gst_bin_add(GST_BIN(pipeline),GST_ELEMENT(video_queue));
gst_bin_add(GST_BIN(pipeline),GST_ELEMENT(video_thread));
// set up thread state and kick things off
gst_pad_connect(gst_element_get_pad(video_queue,"src"),
gst_element_get_pad(video_thread,"sink"));
gtk_object_set(GTK_OBJECT(video_thread),"create_thread",TRUE,NULL);
gst_bin_add(GST_BIN(pipeline),GST_ELEMENT(src));
gst_bin_add(GST_BIN(pipeline),GST_ELEMENT(parse));
@ -127,22 +125,22 @@ int main(int argc,char *argv[]) {
gst_pad_connect(gst_element_get_pad(src,"src"),
gst_element_get_pad(parse,"sink"));
g_print("setting to RUNNING state\n");
gst_element_set_state(GST_ELEMENT(pipeline),GST_STATE_RUNNING);
g_print("setting to READY state\n");
gst_element_set_state(GST_ELEMENT(pipeline),GST_STATE_READY);
gst_element_set_state(GST_ELEMENT(pipeline),GST_STATE_PLAYING);
xmlSaveFile("aviparse.xml",gst_xml_write(GST_ELEMENT(pipeline)));
g_print("about to enter loop\n");
while (1) {
gst_src_push(GST_SRC(src));
}
// this does not work due to multithreading
/*
g_idle_add(idle_func,src);
gdk_threads_enter();
gtk_main();
*/
gdk_threads_leave();
return 0;
}
gboolean idle_func(gpointer data) {

View file

@ -6,5 +6,8 @@ libcrashtest_la_SOURCES = \
include_HEADERS = \
dummy.h
CFLAGS = $(shell gnome-config --cflags gnomeui)
LDFLAGS = $(shell gnome-config --libs gnomeui)
noinst_PROGRAMS = test
test_LDADD = libcrashtest.la

View file

@ -1,7 +1,11 @@
noinst_PROGRAMS = test simple
test_SOURCES = test.c cothreads.c object.c looper.c
test_CFLAGS = $(shell gnome-config --cflags gnomeui)
test_LDFLAGS = $(shell gnome-config --libs gnomeui)
simple_SOURCES = simple.c cothreads.c
simple_CFLAGS = $(shell gnome-config --cflags gnomeui)
simple_LDFLAGS = $(shell gnome-config --libs gnomeui)
noinst_HEADERS = cothreads.h object.h looper.h

View file

@ -36,11 +36,11 @@ int main(int argc,char *argv[]) {
gst_pad_connect(gst_element_get_pad(src,"src"),
gst_element_get_pad(sink,"sink"));
gst_element_set_state(GST_ELEMENT(pipeline),GST_STATE_RUNNING);
gst_element_set_state(GST_ELEMENT(pipeline),GST_STATE_READY);
gst_element_set_state(GST_ELEMENT(pipeline),GST_STATE_PLAYING);
// while (GST_STATE_IS_SET(src,GST_STATE_RUNNING))
// while (GST_STATE_IS_SET(src,GST_STATE_READY))
// while (1)
while (GST_STATE_IS_SET(src,1<<16))
while (GST_STATE(src) & 1<<16)
gst_src_push(GST_SRC(src));
}

View file

@ -21,6 +21,7 @@ void new_pad_created(GstElement *parse,GstPad *pad,GstElement *pipeline) {
GtkWidget *appwindow;
g_print("***** a new pad %s was created\n", gst_pad_get_name(pad));
gst_element_set_state(GST_ELEMENT(pipeline),GST_STATE_PAUSED);
// connect to audio pad
//if (0) {
@ -62,10 +63,8 @@ void new_pad_created(GstElement *parse,GstPad *pad,GstElement *pipeline) {
// set up thread state and kick things off
gtk_object_set(GTK_OBJECT(audio_thread),"create_thread",TRUE,NULL);
g_print("setting to RUNNING state\n");
gst_element_set_state(GST_ELEMENT(audio_thread),GST_STATE_RUNNING);
g_print("setting to PLAYING state\n");
gst_element_set_state(GST_ELEMENT(audio_thread),GST_STATE_PLAYING);
g_print("setting to READY state\n");
gst_element_set_state(GST_ELEMENT(audio_thread),GST_STATE_READY);
} else if (strncmp(gst_pad_get_name(pad), "video_", 6) == 0) {
//} else if (0) {
@ -122,12 +121,11 @@ void new_pad_created(GstElement *parse,GstPad *pad,GstElement *pipeline) {
// set up thread state and kick things off
gtk_object_set(GTK_OBJECT(video_thread),"create_thread",TRUE,NULL);
g_print("setting to RUNNING state\n");
gst_element_set_state(GST_ELEMENT(video_thread),GST_STATE_RUNNING);
g_print("setting to PLAYING state\n");
gst_element_set_state(GST_ELEMENT(video_thread),GST_STATE_PLAYING);
g_print("setting to READY state\n");
gst_element_set_state(GST_ELEMENT(video_thread),GST_STATE_READY);
}
g_print("\n");
gst_element_set_state(GST_ELEMENT(pipeline),GST_STATE_PLAYING);
}
int main(int argc,char *argv[]) {
@ -137,21 +135,22 @@ int main(int argc,char *argv[]) {
g_print("have %d args\n",argc);
//_gst_plugin_spew = TRUE;
g_thread_init(NULL);
gst_init(&argc,&argv);
gnome_init("MPEG1 Video player","0.0.1",argc,argv);
gst_plugin_load("mpeg1parse");
pipeline = gst_pipeline_new("pipeline");
g_return_if_fail(pipeline != NULL);
g_return_val_if_fail(pipeline != NULL, -1);
//src = gst_elementfactory_make("asyncdisksrc","src");
src = gst_elementfactory_make("disksrc","src");
g_return_if_fail(src != NULL);
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_make("mpeg1parse","parse");
g_return_if_fail(parse != NULL);
g_return_val_if_fail(parse != NULL, -1);
gst_bin_add(GST_BIN(pipeline),GST_ELEMENT(src));
gst_bin_add(GST_BIN(pipeline),GST_ELEMENT(parse));
@ -165,22 +164,19 @@ int main(int argc,char *argv[]) {
gst_pad_connect(gst_element_get_pad(src,"src"),
gst_element_get_pad(parse,"sink"));
g_print("setting to RUNNING state\n");
gst_element_set_state(GST_ELEMENT(pipeline),GST_STATE_RUNNING);
xmlSaveFile("mp1parse.xml",gst_xml_write(GST_ELEMENT(pipeline)));
g_print("setting to READY state\n");
gst_element_set_state(GST_ELEMENT(pipeline),GST_STATE_READY);
gst_element_set_state(GST_ELEMENT(pipeline),GST_STATE_PLAYING);
g_print("about to enter loop\n");
while (1) {
gst_src_push(GST_SRC(src));
}
// this does not work due to multithreading
/*
g_idle_add(idle_func,src);
gdk_threads_enter();
gtk_main();
*/
gdk_threads_leave();
return 0;
}
gboolean idle_func(gpointer data) {

View file

@ -63,8 +63,8 @@ void mp2tomp1(GstElement *parser,GstPad *pad, GstElement *pipeline) {
// set up thread state and kick things off
gtk_object_set(GTK_OBJECT(audio_thread),"create_thread",TRUE,NULL);
g_print("setting to RUNNING state\n");
gst_element_set_state(GST_ELEMENT(audio_thread),GST_STATE_RUNNING);
g_print("setting to READY state\n");
gst_element_set_state(GST_ELEMENT(audio_thread),GST_STATE_READY);
g_print("setting to PLAYING state\n");
gst_element_set_state(GST_ELEMENT(audio_thread),GST_STATE_PLAYING);
} else if (strncmp(gst_pad_get_name(pad), "audio_", 6) == 0) {
@ -105,8 +105,8 @@ void mp2tomp1(GstElement *parser,GstPad *pad, GstElement *pipeline) {
// set up thread state and kick things off
gtk_object_set(GTK_OBJECT(audio_thread),"create_thread",TRUE,NULL);
g_print("setting to RUNNING state\n");
gst_element_set_state(GST_ELEMENT(audio_thread),GST_STATE_RUNNING);
g_print("setting to READY state\n");
gst_element_set_state(GST_ELEMENT(audio_thread),GST_STATE_READY);
g_print("setting to PLAYING state\n");
gst_element_set_state(GST_ELEMENT(audio_thread),GST_STATE_PLAYING);
} else if (strncmp(gst_pad_get_name(pad), "video_", 6) == 0) {
@ -161,8 +161,8 @@ void mp2tomp1(GstElement *parser,GstPad *pad, GstElement *pipeline) {
// set up thread state and kick things off
gtk_object_set(GTK_OBJECT(video_thread),"create_thread",TRUE,NULL);
g_print("setting to RUNNING state\n");
gst_element_set_state(GST_ELEMENT(video_thread),GST_STATE_RUNNING);
g_print("setting to READY state\n");
gst_element_set_state(GST_ELEMENT(video_thread),GST_STATE_READY);
g_print("setting to PLAYING state\n");
gst_element_set_state(GST_ELEMENT(video_thread),GST_STATE_PLAYING);
}
@ -209,8 +209,8 @@ int main(int argc,char *argv[]) {
gst_pad_connect(gst_element_get_pad(src,"src"),
gst_element_get_pad(parse,"sink"));
g_print("setting to RUNNING state\n");
gst_element_set_state(GST_ELEMENT(pipeline),GST_STATE_RUNNING);
g_print("setting to READY state\n");
gst_element_set_state(GST_ELEMENT(pipeline),GST_STATE_READY);
while (1) {
gst_src_push(GST_SRC(src));

291
test/mp2toavi.c Normal file
View file

@ -0,0 +1,291 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#include <glib.h>
#include <gst/gst.h>
GstElement *mux;
GstElement *merge_subtitles;
void eof(GstSrc *src) {
g_print("have eos, quitting\n");
exit(0);
}
void frame_encoded(GstElement *element, gint framenum, gpointer data) {
gulong frame_size;
static gulong total = 0;
frame_size = gst_util_get_long_arg(GTK_OBJECT(element),"last_frame_size");
total+=frame_size;
g_print("encoded frame %d %ld %ld\n", framenum, frame_size, total/(framenum+1));
}
void mp2tomp1(GstElement *parser,GstPad *pad, GstElement *pipeline) {
GstElement *parse_audio, *parse_video, *decode, *decode_video, *play, *encode, *audio_resample;
GstElement *smooth, *median;
GstElement *audio_queue, *video_queue;
GstElement *audio_thread, *video_thread;
GstElement *videoscale, *audio_encode;
g_print("***** a new pad %s was created\n", gst_pad_get_name(pad));
gst_element_set_state(GST_ELEMENT(pipeline),GST_STATE_PAUSED);
// connect to audio pad
if (0) {
//if (strncmp(gst_pad_get_name(pad), "private_stream_1.0", 18) == 0) {
gst_plugin_load("ac3parse");
gst_plugin_load("ac3dec");
gst_plugin_load("audioscale");
gst_plugin_load("mpegaudio");
// 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");
g_return_if_fail(audio_resample != NULL);
gtk_object_set(GTK_OBJECT(audio_resample),"frequency", 44100, NULL);
audio_encode = gst_elementfactory_make("mpegaudio","audio_encode");
//audio_encode = gst_elementfactory_make("pipefilter","audio_encode");
g_return_if_fail(audio_encode != NULL);
//gtk_object_set(GTK_OBJECT(audio_encode),"command", "lame -x - -", NULL);
// 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));
gtk_object_set(GTK_OBJECT(mux),"audio","00",NULL);
// set up pad connections
gst_element_add_ghost_pad(GST_ELEMENT(audio_thread),
gst_element_get_pad(parse_audio,"sink"));
gst_pad_connect(gst_element_get_pad(parse_audio,"src"),
gst_element_get_pad(decode,"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"),
gst_element_get_pad(audio_encode,"sink"));
gst_pad_connect(gst_element_get_pad(audio_encode,"src"),
gst_element_get_pad(mux,"audio_00"));
// construct queue and connect everything in the main pipelie
audio_queue = gst_elementfactory_make("queue","audio_queue");
gtk_object_set(GTK_OBJECT(audio_queue),"max_level",1,NULL);
gst_bin_add(GST_BIN(pipeline),GST_ELEMENT(audio_queue));
gst_bin_add(GST_BIN(pipeline),GST_ELEMENT(audio_thread));
gst_pad_connect(pad,
gst_element_get_pad(audio_queue,"sink"));
gst_pad_connect(gst_element_get_pad(audio_queue,"src"),
gst_element_get_pad(audio_thread,"sink"));
// set up thread state and kick things off
gtk_object_set(GTK_OBJECT(audio_thread),"create_thread",TRUE,NULL);
g_print("setting to READY state\n");
gst_element_set_state(GST_ELEMENT(audio_thread),GST_STATE_READY);
} else if (strncmp(gst_pad_get_name(pad), "subtitle_stream_4", 17) == 0) {
gst_pad_connect(pad,
gst_element_get_pad(merge_subtitles,"subtitle"));
} else if (strncmp(gst_pad_get_name(pad), "audio_", 6) == 0) {
gst_plugin_load("mp3parse");
gst_plugin_load("mpg123");
// 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");
g_return_if_fail(decode != NULL);
play = gst_elementfactory_make("audiosink","play_audio");
g_return_if_fail(play != NULL);
// 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"));
gst_pad_connect(gst_element_get_pad(parse_audio,"src"),
gst_element_get_pad(decode,"sink"));
gst_pad_connect(gst_element_get_pad(decode,"src"),
gst_element_get_pad(play,"sink"));
// construct queue and connect everything in the main pipelie
audio_queue = gst_elementfactory_make("queue","audio_queue");
gtk_object_set(GTK_OBJECT(audio_queue),"max_level",1,NULL);
gst_bin_add(GST_BIN(pipeline),GST_ELEMENT(audio_queue));
gst_bin_add(GST_BIN(pipeline),GST_ELEMENT(audio_thread));
gst_pad_connect(pad,
gst_element_get_pad(audio_queue,"sink"));
gst_pad_connect(gst_element_get_pad(audio_queue,"src"),
gst_element_get_pad(audio_thread,"sink"));
// set up thread state and kick things off
gtk_object_set(GTK_OBJECT(audio_thread),"create_thread",TRUE,NULL);
g_print("setting to READY state\n");
gst_element_set_state(GST_ELEMENT(audio_thread),GST_STATE_READY);
} else if (strncmp(gst_pad_get_name(pad), "video_", 6) == 0) {
//} else if (0) {
gst_plugin_load("mp1videoparse");
gst_plugin_load("mpeg2play");
gst_plugin_load("mpeg2subt");
gst_plugin_load("smooth");
gst_plugin_load("median");
gst_plugin_load("videoscale");
gst_plugin_load("wincodec");
//gst_plugin_load("mpeg1encoder");
// construct internal pipeline elements
parse_video = gst_elementfactory_make("mp1videoparse","parse_video");
g_return_if_fail(parse_video != NULL);
decode_video = gst_elementfactory_make("mpeg2play","decode_video");
g_return_if_fail(decode_video != NULL);
merge_subtitles = gst_elementfactory_make("mpeg2subt","merge_subtitles");
g_return_if_fail(merge_subtitles != NULL);
videoscale = gst_elementfactory_make("videoscale","videoscale");
g_return_if_fail(videoscale != NULL);
//gtk_object_set(GTK_OBJECT(videoscale),"width",352, "height", 288,NULL);
gtk_object_set(GTK_OBJECT(videoscale),"width",640, "height", 480,NULL);
median = gst_elementfactory_make("median","median");
g_return_if_fail(median != NULL);
gtk_object_set(GTK_OBJECT(median),"filtersize",9,NULL);
gtk_object_set(GTK_OBJECT(median),"active",TRUE,NULL);
smooth = gst_elementfactory_make("smooth","smooth");
g_return_if_fail(smooth != NULL);
gtk_object_set(GTK_OBJECT(smooth),"filtersize",5,NULL);
gtk_object_set(GTK_OBJECT(smooth),"tolerance",9,NULL);
gtk_object_set(GTK_OBJECT(smooth),"active",FALSE,NULL);
encode = gst_elementfactory_make("winenc","encode");
g_return_if_fail(encode != NULL);
gtk_signal_connect(GTK_OBJECT(encode),"frame_encoded",GTK_SIGNAL_FUNC(frame_encoded),NULL);
gtk_object_set(GTK_OBJECT(encode),"bitrate",800*4,NULL);
gtk_object_set(GTK_OBJECT(encode),"quality",10000,NULL);
//gtk_object_set(GTK_OBJECT(encode),"compression",NULL,NULL);
//encode = gst_elementfactory_make("mpeg1encoder","encode");
//gtk_object_set(GTK_OBJECT(show),"width",640, "height", 480,NULL);
gtk_object_set(GTK_OBJECT(mux),"video","00:DIV3",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(median));
gst_bin_add(GST_BIN(video_thread),GST_ELEMENT(smooth));
gst_bin_add(GST_BIN(video_thread),GST_ELEMENT(videoscale));
gst_bin_add(GST_BIN(video_thread),GST_ELEMENT(encode));
gst_bin_use_cothreads(GST_BIN(video_thread), FALSE);
// set up pad connections
gst_element_add_ghost_pad(GST_ELEMENT(video_thread),
gst_element_get_pad(parse_video,"sink"));
gst_pad_connect(gst_element_get_pad(parse_video,"src"),
gst_element_get_pad(decode_video,"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"),
gst_element_get_pad(merge_subtitles,"video"));
gst_pad_connect(gst_element_get_pad(merge_subtitles,"src"),
gst_element_get_pad(videoscale,"sink"));
gst_pad_connect(gst_element_get_pad(videoscale,"src"),
gst_element_get_pad(smooth,"sink"));
gst_pad_connect(gst_element_get_pad(smooth,"src"),
gst_element_get_pad(encode,"sink"));
gst_pad_connect(gst_element_get_pad(encode,"src"),
gst_element_get_pad(mux,"video_00"));
// construct queue and connect everything in the main pipeline
video_queue = gst_elementfactory_make("queue","video_queue");
gtk_object_set(GTK_OBJECT(video_queue),"max_level",1,NULL);
gst_bin_add(GST_BIN(pipeline),GST_ELEMENT(video_queue));
gst_bin_add(GST_BIN(pipeline),GST_ELEMENT(video_thread));
gst_pad_connect(pad,
gst_element_get_pad(video_queue,"sink"));
gst_pad_connect(gst_element_get_pad(video_queue,"src"),
gst_element_get_pad(video_thread,"sink"));
// set up thread state and kick things off
gtk_object_set(GTK_OBJECT(video_thread),"create_thread",TRUE,NULL);
g_print("setting to READY state\n");
gst_element_set_state(GST_ELEMENT(video_thread),GST_STATE_READY);
}
g_print("\n");
gst_element_set_state(GST_ELEMENT(pipeline),GST_STATE_PLAYING);
}
int main(int argc,char *argv[]) {
GstPipeline *pipeline;
GstElement *src, *parse;
GstElement *fdsink;
GstElementFactory *fdsinkfactory;
int fd;
g_print("have %d args\n",argc);
gst_init(&argc,&argv);
gst_plugin_load("mpeg2parse");
gst_plugin_load("aviencoder");
pipeline = gst_pipeline_new("pipeline");
g_return_val_if_fail(pipeline != NULL, -1);
if (strstr(argv[1],"video_ts")) {
src = gst_elementfactory_make("dvdsrc","src");
g_print("using DVD source\n");
} else
src = gst_elementfactory_make("disksrc","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]);
g_print("should be using output file '%s'\n",argv[2]);
parse = gst_elementfactory_make("mpeg2parse","parse");
g_return_val_if_fail(parse != NULL, -1);
mux = gst_elementfactory_make("aviencoder","mux");
g_return_val_if_fail(mux != NULL, -1);
fd = open(argv[2],O_CREAT|O_RDWR|O_TRUNC, S_IREAD|S_IWRITE);
fdsinkfactory = gst_elementfactory_find("fdsink");
g_return_val_if_fail(fdsinkfactory != NULL, -1);
fdsink = gst_elementfactory_create(fdsinkfactory,"fdsink");
g_return_val_if_fail(fdsink != NULL, -1);
gtk_object_set(GTK_OBJECT(fdsink),"fd",fd,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(mux));
gst_bin_add(GST_BIN(pipeline),GST_ELEMENT(fdsink));
gtk_signal_connect(GTK_OBJECT(parse),"new_pad",mp2tomp1, pipeline);
gtk_signal_connect(GTK_OBJECT(src),"eos",GTK_SIGNAL_FUNC(eof),NULL);
gst_pad_connect(gst_element_get_pad(src,"src"),
gst_element_get_pad(parse,"sink"));
gst_pad_connect(gst_element_get_pad(mux,"src"),
gst_element_get_pad(fdsink,"sink"));
g_print("setting to READY state\n");
gst_element_set_state(GST_ELEMENT(pipeline),GST_STATE_READY);
while (1) {
gst_src_push(GST_SRC(src));
}
}

View file

@ -2,10 +2,12 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#include <glib.h>
#include <gst/gst.h>
GstElement *mux;
GstElement *merge_subtitles;
void eof(GstSrc *src) {
g_print("have eos, quitting\n");
@ -20,6 +22,7 @@ void mp2tomp1(GstElement *parser,GstPad *pad, GstElement *pipeline) {
GstElement *videoscale, *audio_encode;
g_print("***** a new pad %s was created\n", gst_pad_get_name(pad));
gst_element_set_state(GST_ELEMENT(pipeline),GST_STATE_PAUSED);
// connect to audio pad
//if (0) {
@ -31,7 +34,7 @@ void mp2tomp1(GstElement *parser,GstPad *pad, GstElement *pipeline) {
// 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", 0, 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");
@ -77,10 +80,11 @@ void mp2tomp1(GstElement *parser,GstPad *pad, GstElement *pipeline) {
// set up thread state and kick things off
gtk_object_set(GTK_OBJECT(audio_thread),"create_thread",TRUE,NULL);
g_print("setting to RUNNING state\n");
gst_element_set_state(GST_ELEMENT(audio_thread),GST_STATE_RUNNING);
g_print("setting to PLAYING state\n");
gst_element_set_state(GST_ELEMENT(audio_thread),GST_STATE_PLAYING);
g_print("setting to READY state\n");
gst_element_set_state(GST_ELEMENT(audio_thread),GST_STATE_READY);
} else if (strncmp(gst_pad_get_name(pad), "subtitle_stream_4", 17) == 0) {
gst_pad_connect(pad,
gst_element_get_pad(merge_subtitles,"subtitle"));
} else if (strncmp(gst_pad_get_name(pad), "audio_", 6) == 0) {
gst_plugin_load("mp3parse");
gst_plugin_load("mpg123");
@ -120,15 +124,14 @@ void mp2tomp1(GstElement *parser,GstPad *pad, GstElement *pipeline) {
// set up thread state and kick things off
gtk_object_set(GTK_OBJECT(audio_thread),"create_thread",TRUE,NULL);
g_print("setting to RUNNING state\n");
gst_element_set_state(GST_ELEMENT(audio_thread),GST_STATE_RUNNING);
g_print("setting to PLAYING state\n");
gst_element_set_state(GST_ELEMENT(audio_thread),GST_STATE_PLAYING);
g_print("setting to READY state\n");
gst_element_set_state(GST_ELEMENT(audio_thread),GST_STATE_READY);
} else if (strncmp(gst_pad_get_name(pad), "video_", 6) == 0) {
//} else if (0) {
gst_plugin_load("mp1videoparse");
gst_plugin_load("mpeg2play");
gst_plugin_load("mpeg2subt");
gst_plugin_load("smooth");
gst_plugin_load("median");
gst_plugin_load("videoscale");
@ -139,19 +142,23 @@ void mp2tomp1(GstElement *parser,GstPad *pad, GstElement *pipeline) {
g_return_if_fail(parse_video != NULL);
decode_video = gst_elementfactory_make("mpeg2play","decode_video");
g_return_if_fail(decode_video != NULL);
merge_subtitles = gst_elementfactory_make("mpeg2subt","merge_subtitles");
g_return_if_fail(merge_subtitles != NULL);
videoscale = gst_elementfactory_make("videoscale","videoscale");
g_return_if_fail(videoscale != NULL);
gtk_object_set(GTK_OBJECT(videoscale),"width",352, "height", 240,NULL);
gtk_object_set(GTK_OBJECT(videoscale),"width",352, "height", 288,NULL);
median = gst_elementfactory_make("median","median");
g_return_if_fail(median != NULL);
gtk_object_set(GTK_OBJECT(median),"filtersize",9,NULL);
gtk_object_set(GTK_OBJECT(median),"filtersize",5,NULL);
gtk_object_set(GTK_OBJECT(median),"active",TRUE,NULL);
smooth = gst_elementfactory_make("smooth","smooth");
g_return_if_fail(smooth != NULL);
gtk_object_set(GTK_OBJECT(smooth),"filtersize",5,NULL);
gtk_object_set(GTK_OBJECT(smooth),"tolerance",9,NULL);
gtk_object_set(GTK_OBJECT(smooth),"active",FALSE,NULL);
encode = gst_elementfactory_make("mpeg2enc","encode");
g_return_if_fail(encode != NULL);
gtk_object_set(GTK_OBJECT(encode),"frames_per_second",24.0,NULL);
gtk_object_set(GTK_OBJECT(encode),"frames_per_second",25.0,NULL);
//encode = gst_elementfactory_make("mpeg1encoder","encode");
//gtk_object_set(GTK_OBJECT(show),"width",640, "height", 480,NULL);
@ -162,10 +169,12 @@ void mp2tomp1(GstElement *parser,GstPad *pad, GstElement *pipeline) {
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(median));
gst_bin_add(GST_BIN(video_thread),GST_ELEMENT(smooth));
gst_bin_add(GST_BIN(video_thread),GST_ELEMENT(videoscale));
gst_bin_add(GST_BIN(video_thread),GST_ELEMENT(encode));
gst_bin_use_cothreads(GST_BIN(video_thread), FALSE);
// set up pad connections
gst_element_add_ghost_pad(GST_ELEMENT(video_thread),
@ -175,10 +184,12 @@ void mp2tomp1(GstElement *parser,GstPad *pad, GstElement *pipeline) {
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"),
gst_element_get_pad(merge_subtitles,"video"));
gst_pad_connect(gst_element_get_pad(merge_subtitles,"src"),
gst_element_get_pad(videoscale,"sink"));
gst_pad_connect(gst_element_get_pad(videoscale,"src"),
// gst_element_get_pad(smooth,"sink"));
//gst_pad_connect(gst_element_get_pad(smooth,"src"),
gst_element_get_pad(smooth,"sink"));
gst_pad_connect(gst_element_get_pad(smooth,"src"),
gst_element_get_pad(encode,"sink"));
gst_pad_connect(gst_element_get_pad(encode,"src"),
gst_element_get_pad(mux,"video_00"));
@ -195,22 +206,19 @@ void mp2tomp1(GstElement *parser,GstPad *pad, GstElement *pipeline) {
// set up thread state and kick things off
gtk_object_set(GTK_OBJECT(video_thread),"create_thread",TRUE,NULL);
g_print("setting to RUNNING state\n");
gst_element_set_state(GST_ELEMENT(video_thread),GST_STATE_RUNNING);
g_print("setting to PLAYING state\n");
gst_element_set_state(GST_ELEMENT(video_thread),GST_STATE_PLAYING);
g_print("setting to READY state\n");
gst_element_set_state(GST_ELEMENT(video_thread),GST_STATE_READY);
}
g_print("\n");
gst_element_set_state(GST_ELEMENT(pipeline),GST_STATE_PLAYING);
}
int main(int argc,char *argv[]) {
GstPipeline *pipeline;
GstElement *src, *parse, *out;
GstPad *infopad;
GstElement *src, *parse;
GstElement *fdsink;
GstElementFactory *fdsinkfactory;
int fd;
int i,c;
g_print("have %d args\n",argc);
@ -219,7 +227,7 @@ int main(int argc,char *argv[]) {
gst_plugin_load("system_encode");
pipeline = gst_pipeline_new("pipeline");
g_return_if_fail(pipeline != NULL);
g_return_val_if_fail(pipeline != NULL, -1);
if (strstr(argv[1],"video_ts")) {
src = gst_elementfactory_make("dvdsrc","src");
@ -227,22 +235,23 @@ int main(int argc,char *argv[]) {
} else
src = gst_elementfactory_make("disksrc","src");
g_return_if_fail(src != NULL);
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]);
g_print("should be using output file '%s'\n",argv[2]);
parse = gst_elementfactory_make("mpeg2parse","parse");
g_return_if_fail(parse != NULL);
g_return_val_if_fail(parse != NULL, -1);
mux = gst_elementfactory_make("system_encode","mux");
g_return_if_fail(mux != NULL);
fd = open(argv[2],O_CREAT|O_RDWR|O_TRUNC);
g_return_val_if_fail(mux != NULL, -1);
fd = open(argv[2],O_CREAT|O_RDWR|O_TRUNC, S_IREAD|S_IWRITE);
g_return_val_if_fail(fd >= 0, -1);
fdsinkfactory = gst_elementfactory_find("fdsink");
g_return_if_fail(fdsinkfactory != NULL);
g_return_val_if_fail(fdsinkfactory != NULL, -1);
fdsink = gst_elementfactory_create(fdsinkfactory,"fdsink");
g_return_if_fail(fdsink != NULL);
g_return_val_if_fail(fdsink != NULL, -1);
gtk_object_set(GTK_OBJECT(fdsink),"fd",fd,NULL);
gst_bin_add(GST_BIN(pipeline),GST_ELEMENT(src));
@ -259,10 +268,12 @@ int main(int argc,char *argv[]) {
gst_pad_connect(gst_element_get_pad(mux,"src"),
gst_element_get_pad(fdsink,"sink"));
g_print("setting to RUNNING state\n");
gst_element_set_state(GST_ELEMENT(pipeline),GST_STATE_RUNNING);
g_print("setting to READY state\n");
gst_element_set_state(GST_ELEMENT(pipeline),GST_STATE_READY);
while (1) {
gst_src_push(GST_SRC(src));
}
return 0;
}

View file

@ -19,8 +19,6 @@ int main(int argc,char *argv[]) {
GstElementFactory *sinkfactory;
GstElement *sink;
GtkWidget *appwindow;
_gst_plugin_spew = TRUE;
gst_init(&argc,&argv);
@ -36,12 +34,12 @@ int main(int argc,char *argv[]) {
sinkfactory = gst_elementfactory_find("audiosink");
src = gst_elementfactory_create(srcfactory,"src");
g_return_if_fail(src != NULL);
g_return_val_if_fail(src != NULL, -1);
gtk_object_set(GTK_OBJECT(src),"location",argv[1],NULL);
mp3 = gst_elementfactory_create(mp3factory,"mp3");
g_return_if_fail(mp3 != NULL);
g_return_val_if_fail(mp3 != NULL, -1);
sink = gst_elementfactory_create(sinkfactory,"sink");
g_return_if_fail(sink != NULL);
g_return_val_if_fail(sink != NULL, -1);
gst_bin_add(GST_BIN(bin),GST_ELEMENT(src));
gst_bin_add(GST_BIN(bin),GST_ELEMENT(mp3));
@ -55,9 +53,11 @@ int main(int argc,char *argv[]) {
gtk_signal_connect(GTK_OBJECT(src),"eof",
GTK_SIGNAL_FUNC(eof),NULL);
gst_element_set_state(GST_ELEMENT(bin),GST_STATE_RUNNING);
gst_element_set_state(GST_ELEMENT(bin),GST_STATE_READY);
gst_element_set_state(GST_ELEMENT(bin),GST_STATE_PLAYING);
while (playing)
gst_src_push(GST_SRC(src));
return 0;
}

View file

@ -26,19 +26,19 @@ int main(int argc,char *argv[]) {
gst_plugin_load_all();
pipeline = gst_pipeline_new("pipeline");
g_return_if_fail(pipeline != NULL);
g_return_val_if_fail(pipeline != NULL, -1);
srcfactory = gst_elementfactory_find("disksrc");
g_return_if_fail(srcfactory != NULL);
g_return_val_if_fail(srcfactory != NULL, -1);
parsefactory = gst_elementfactory_find("mp3parse");
g_return_if_fail(parsefactory != NULL);
g_return_val_if_fail(parsefactory != NULL, -1);
src = gst_elementfactory_create(srcfactory,"src");
g_return_if_fail(src != NULL);
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_if_fail(parse != NULL);
g_return_val_if_fail(parse != NULL, -1);
infopad = gst_pad_new("sink",GST_PAD_SINK);
gst_pad_set_chain_function(infopad,mp3parse_info_chain);
@ -55,7 +55,7 @@ int main(int argc,char *argv[]) {
infopad);
g_print("setting to RUNNING state\n");
gst_element_set_state(GST_ELEMENT(pipeline),GST_STATE_RUNNING);
gst_element_set_state(GST_ELEMENT(pipeline),GST_STATE_READY);
g_print("about to enter loop\n");
while (1)

View file

@ -56,8 +56,8 @@ int main(int argc,char *argv[]) {
gst_pad_connect(gst_element_get_pad(decode,"src"),
gst_element_get_pad(play,"sink"));
g_print("setting to RUNNING state\n");
gst_element_set_state(GST_ELEMENT(pipeline),GST_STATE_RUNNING);
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) {

View file

@ -12,6 +12,8 @@ gboolean idle_func(gpointer data) {
return TRUE;
}
GstElement *merge_subtitles;
void mpeg2parse_newpad(GstElement *parser,GstPad *pad, GstElement *pipeline) {
GstElement *parse_audio, *parse_video, *decode, *decode_video, *play, *show;
GstElement *audio_queue, *video_queue;
@ -20,6 +22,7 @@ void mpeg2parse_newpad(GstElement *parser,GstPad *pad, GstElement *pipeline) {
GtkWidget *appwindow;
g_print("***** a new pad %s was created\n", gst_pad_get_name(pad));
gst_element_set_state(GST_ELEMENT(pipeline),GST_STATE_PAUSED);
// connect to audio pad
//if (0) {
@ -61,10 +64,12 @@ void mpeg2parse_newpad(GstElement *parser,GstPad *pad, GstElement *pipeline) {
// set up thread state and kick things off
gtk_object_set(GTK_OBJECT(audio_thread),"create_thread",TRUE,NULL);
g_print("setting to RUNNING state\n");
gst_element_set_state(GST_ELEMENT(audio_thread),GST_STATE_RUNNING);
g_print("setting to PLAYING state\n");
gst_element_set_state(GST_ELEMENT(audio_thread),GST_STATE_PLAYING);
g_print("setting to READY state\n");
gst_element_set_state(GST_ELEMENT(audio_thread),GST_STATE_READY);
} else if (strncmp(gst_pad_get_name(pad), "subtitle_stream_4", 17) == 0) {
gst_pad_connect(pad,
gst_element_get_pad(merge_subtitles,"subtitle"));
} else if (strncmp(gst_pad_get_name(pad), "audio_", 6) == 0) {
gst_plugin_load("mp3parse");
gst_plugin_load("mpg123");
@ -103,22 +108,24 @@ void mpeg2parse_newpad(GstElement *parser,GstPad *pad, GstElement *pipeline) {
// set up thread state and kick things off
gtk_object_set(GTK_OBJECT(audio_thread),"create_thread",TRUE,NULL);
g_print("setting to RUNNING state\n");
gst_element_set_state(GST_ELEMENT(audio_thread),GST_STATE_RUNNING);
g_print("setting to PLAYING state\n");
gst_element_set_state(GST_ELEMENT(audio_thread),GST_STATE_PLAYING);
g_print("setting to READY state\n");
gst_element_set_state(GST_ELEMENT(audio_thread),GST_STATE_READY);
} else if (strncmp(gst_pad_get_name(pad), "video_", 6) == 0) {
//} else if (0) {
gst_plugin_load("mp1videoparse");
gst_plugin_load("mpeg2play");
gst_plugin_load("mpeg2subt");
gst_plugin_load("videosink");
// construct internal pipeline elements
parse_video = gst_elementfactory_make("mp1videoparse","parse_video");
g_return_if_fail(parse_video != NULL);
decode_video = gst_elementfactory_make("mpeg2play","decode_video");
g_return_if_fail(decode_video != NULL);
merge_subtitles = gst_elementfactory_make("mpeg2subt","merge_subtitles");
g_return_if_fail(merge_subtitles != NULL);
show = gst_elementfactory_make("videosink","show");
//gtk_object_set(GTK_OBJECT(show),"xv_enabled",FALSE,NULL);
g_return_if_fail(show != NULL);
//gtk_object_set(GTK_OBJECT(show),"width",640, "height", 480,NULL);
@ -132,7 +139,9 @@ void mpeg2parse_newpad(GstElement *parser,GstPad *pad, GstElement *pipeline) {
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(show));
gst_bin_use_cothreads(GST_BIN(video_thread), FALSE);
// set up pad connections
gst_element_add_ghost_pad(GST_ELEMENT(video_thread),
@ -140,6 +149,8 @@ void mpeg2parse_newpad(GstElement *parser,GstPad *pad, GstElement *pipeline) {
gst_pad_connect(gst_element_get_pad(parse_video,"src"),
gst_element_get_pad(decode_video,"sink"));
gst_pad_connect(gst_element_get_pad(decode_video,"src"),
gst_element_get_pad(merge_subtitles,"video"));
gst_pad_connect(gst_element_get_pad(merge_subtitles,"src"),
gst_element_get_pad(show,"sink"));
// construct queue and connect everything in the main pipeline
@ -154,22 +165,20 @@ void mpeg2parse_newpad(GstElement *parser,GstPad *pad, GstElement *pipeline) {
// set up thread state and kick things off
gtk_object_set(GTK_OBJECT(video_thread),"create_thread",TRUE,NULL);
g_print("setting to RUNNING state\n");
gst_element_set_state(GST_ELEMENT(video_thread),GST_STATE_RUNNING);
g_print("setting to PLAYING state\n");
gst_element_set_state(GST_ELEMENT(video_thread),GST_STATE_PLAYING);
g_print("setting to READY state\n");
gst_element_set_state(GST_ELEMENT(video_thread),GST_STATE_READY);
}
g_print("\n");
gst_element_set_state(GST_ELEMENT(pipeline),GST_STATE_PLAYING);
}
int main(int argc,char *argv[]) {
GstPipeline *pipeline;
GstElement *src, *parse, *out;
GstPad *infopad;
int i,c;
GstElement *src, *parse;
g_print("have %d args\n",argc);
g_thread_init(NULL);
gtk_init(&argc,&argv);
gst_init(&argc,&argv);
gnome_init("MPEG2 Video player","0.0.1",argc,argv);
@ -177,7 +186,7 @@ int main(int argc,char *argv[]) {
//gst_plugin_load("mpeg1parse");
pipeline = gst_pipeline_new("pipeline");
g_return_if_fail(pipeline != NULL);
g_return_val_if_fail(pipeline != NULL, -1);
if (strstr(argv[1],"video_ts")) {
src = gst_elementfactory_make("dvdsrc","src");
@ -185,7 +194,7 @@ int main(int argc,char *argv[]) {
} else
src = gst_elementfactory_make("disksrc","src");
g_return_if_fail(src != NULL);
g_return_val_if_fail(src != NULL, -1);
gtk_object_set(GTK_OBJECT(src),"location",argv[1],NULL);
if (argc >= 3) {
gtk_object_set(GTK_OBJECT(src),"bytesperread",atoi(argv[2]),NULL);
@ -195,7 +204,7 @@ int main(int argc,char *argv[]) {
parse = gst_elementfactory_make("mpeg2parse","parse");
//parse = gst_elementfactory_make("mpeg1parse","parse");
g_return_if_fail(parse != NULL);
g_return_val_if_fail(parse != NULL, -1);
gst_bin_add(GST_BIN(pipeline),GST_ELEMENT(src));
gst_bin_add(GST_BIN(pipeline),GST_ELEMENT(parse));
@ -207,10 +216,15 @@ int main(int argc,char *argv[]) {
gst_pad_connect(gst_element_get_pad(src,"src"),
gst_element_get_pad(parse,"sink"));
g_print("setting to RUNNING state\n");
gst_element_set_state(GST_ELEMENT(pipeline),GST_STATE_RUNNING);
g_print("setting to READY state\n");
gst_element_set_state(GST_ELEMENT(pipeline),GST_STATE_READY);
gst_element_set_state(GST_ELEMENT(pipeline),GST_STATE_PLAYING);
gtk_idle_add(idle_func,src);
gdk_threads_enter();
gtk_main();
gdk_threads_leave();
return 0;
}

View file

@ -14,7 +14,6 @@ int main(int argc,char *argv[]) {
GstPipeline *pipeline;
GstElementFactory *srcfactory, *pipefactory, *sinkfactory;
GstElement *src, *pipe, *sink;
GstPad *infopad;
int fd;
g_print("have %d args\n",argc);
@ -22,23 +21,23 @@ int main(int argc,char *argv[]) {
gst_init(&argc,&argv);
pipeline = gst_pipeline_new("pipeline");
g_return_if_fail(pipeline != NULL);
g_return_val_if_fail(pipeline != NULL, -1);
srcfactory = gst_elementfactory_find("disksrc");
g_return_if_fail(srcfactory != NULL);
g_return_val_if_fail(srcfactory != NULL, -1);
pipefactory = gst_elementfactory_find("pipefilter");
g_return_if_fail(pipefactory != NULL);
g_return_val_if_fail(pipefactory != NULL, -1);
sinkfactory = gst_elementfactory_find("fdsink");
g_return_if_fail(sinkfactory != NULL);
g_return_val_if_fail(sinkfactory != NULL, -1);
src = gst_elementfactory_create(srcfactory,"src");
g_return_if_fail(src != NULL);
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]);
pipe = gst_elementfactory_create(pipefactory,"pipe");
g_return_if_fail(pipe != NULL);
g_return_val_if_fail(pipe != NULL, -1);
sink = gst_elementfactory_create(sinkfactory,"fdsink");
g_return_if_fail(sink != NULL);
g_return_val_if_fail(sink != NULL, -1);
fd = open(argv[2],O_CREAT|O_RDWR|O_TRUNC);
gtk_object_set(GTK_OBJECT(sink),"fd",fd,NULL);
@ -55,8 +54,8 @@ int main(int argc,char *argv[]) {
gst_pad_connect(gst_element_get_pad(pipe,"src"),
gst_element_get_pad(sink,"sink"));
g_print("setting to RUNNING state\n");
gst_element_set_state(GST_ELEMENT(pipeline),GST_STATE_RUNNING);
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) {

View file

@ -30,7 +30,7 @@ int main(int argc,char *argv[]) {
gst_init(&argc,&argv);
/* first create the main pipeline */
pipeline = gst_pipeline_new("pipeline");
pipeline = GST_ELEMENT(gst_pipeline_new("pipeline"));
/* then the decode thread, source, and decoder */
decodethread = gst_thread_new("decodethread");
@ -86,14 +86,14 @@ int main(int argc,char *argv[]) {
gtk_object_set(GTK_OBJECT(playthread),"create_thread",FALSE,NULL);
g_print("\neverything's built, setting it up to be runnable\n");
gst_element_set_state(GST_ELEMENT(pipeline),GST_STATE_RUNNING);
gst_element_set_state(GST_ELEMENT(pipeline),GST_STATE_READY);
g_print("\nok, runnable, hitting 'play'...\n");
gst_element_set_state(GST_ELEMENT(pipeline),GST_STATE_PLAYING);
g_print("\niterating on %p and %p\n",decodethread,playthread);
while (playing) {
gst_thread_iterate(GST_THREAD(playthread));
gst_thread_main_loop(GST_THREAD(playthread));
/* buffers got wedged in the queue, unstick them */
// while (((GstQueue *)queue)->buffers_queued)
// gst_connection_push(GST_CONNECTION(queue));
@ -101,4 +101,5 @@ int main(int argc,char *argv[]) {
// g_print("stuffed and unstuck the queue\n");
// sleep(1);
}
return 0;
}

View file

@ -12,7 +12,7 @@ int main(int argc,char *argv[]) {
gst_init(&argc,&argv);
pipeline = gst_pipeline_new("pipeline");
pipeline = GST_ELEMENT(gst_pipeline_new("pipeline"));
audiosrcfactory = gst_elementfactory_find("audiosrc");
audiosrc = gst_elementfactory_create(audiosrcfactory,"audiosrc");
@ -32,7 +32,7 @@ int main(int argc,char *argv[]) {
gst_element_get_pad(fdsink,"sink"));
g_print("\neverything's built, setting it up to be runnable\n");
gst_element_set_state(GST_ELEMENT(pipeline),GST_STATE_RUNNING);
gst_element_set_state(GST_ELEMENT(pipeline),GST_STATE_READY);
g_print("\nok, runnable, hitting 'play'...\n");
gst_element_set_state(GST_ELEMENT(pipeline),GST_STATE_PLAYING);

View file

@ -52,17 +52,19 @@ int main(int argc,char *argv[]) {
gnome_app_set_contents(GNOME_APP(appwindow),drawingarea);
gtk_widget_show_all(appwindow);
gst_element_set_state(GST_ELEMENT(bin),GST_STATE_RUNNING);
gst_element_set_state(GST_ELEMENT(bin),GST_STATE_READY);
gst_element_set_state(GST_ELEMENT(bin),GST_STATE_PLAYING);
g_idle_add(idle_func,src);
gtk_main();
return 0;
}
void spectrum_chain(GstPad *pad,GstBuffer *buf) {
gint i,size;
gint i;
guchar *data = buf->data;
gdk_draw_rectangle(drawingarea->window,drawingarea->style->black_gc,

View file

@ -71,7 +71,7 @@ int main(int argc,char *argv[]) {
gtk_object_set(GTK_OBJECT(video_thread),"create_thread",TRUE,NULL);
g_print("\neverything's built, setting it up to be runnable\n");
gst_element_set_state(GST_ELEMENT(pipeline),GST_STATE_RUNNING);
gst_element_set_state(GST_ELEMENT(pipeline),GST_STATE_READY);
g_print("\nok, runnable, hitting 'play'...\n");
gst_element_set_state(GST_ELEMENT(pipeline),GST_STATE_PLAYING);

82
test/vidcapture2.c Normal file
View file

@ -0,0 +1,82 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <glib.h>
#include <gst/gst.h>
int main(int argc,char *argv[]) {
int fd;
GstPipeline *pipeline;
GstElement *audiosrc, *videosrc, *fdsink, *encoder, *compress, *video_queue, *video_thread;
GstElementFactory *audiosrcfactory, *fdsinkfactory, *encoderfactory, *compressfactory;
GstElementFactory *videosrcfactory;
GList *padlist;
gst_init(&argc,&argv);
gst_plugin_load("v4lsrc");
gst_plugin_load("aviencoder");
gst_plugin_load("wincodec");
pipeline = gst_pipeline_new("pipeline");
audiosrcfactory = gst_elementfactory_find("audiosrc");
audiosrc = gst_elementfactory_create(audiosrcfactory,"audiosrc");
videosrcfactory = gst_elementfactory_find("v4lsrc");
videosrc = gst_elementfactory_create(videosrcfactory,"videosrc");
compressfactory = gst_elementfactory_find("winenc");
compress = gst_elementfactory_create(compressfactory,"winenc");
g_assert(compress != NULL);
encoderfactory = gst_elementfactory_find("aviencoder");
encoder = gst_elementfactory_create(encoderfactory,"aviencoder");
gtk_object_set(GTK_OBJECT(videosrc),"width",320,"height",240,NULL);
gtk_object_set(GTK_OBJECT(videosrc),"format",5,NULL);
gtk_object_set(GTK_OBJECT(encoder),"video","00:DIV3",NULL);
fd = open(argv[1],O_CREAT|O_RDWR|O_TRUNC);
fdsinkfactory = gst_elementfactory_find("fdsink");
fdsink = gst_elementfactory_create(fdsinkfactory,"fdsink");
gtk_object_set(GTK_OBJECT(fdsink),"fd",fd,NULL);
gst_bin_add(GST_BIN(pipeline),GST_ELEMENT(videosrc));
/* add objects to the main pipeline */
video_thread = gst_thread_new("video_thread");
g_return_if_fail(video_thread != NULL);
gst_bin_add(GST_BIN(video_thread),GST_ELEMENT(compress));
gst_bin_add(GST_BIN(video_thread),GST_ELEMENT(encoder));
gst_bin_add(GST_BIN(video_thread),GST_ELEMENT(fdsink));
/* connect src to sink */
gst_element_add_ghost_pad(GST_ELEMENT(video_thread),
gst_element_get_pad(compress,"sink"));
gst_pad_connect(gst_element_get_pad(compress,"src"),
gst_element_get_pad(encoder,"video_00"));
gst_pad_connect(gst_element_get_pad(encoder,"src"),
gst_element_get_pad(fdsink,"sink"));
// construct queue and connect everything in the main pipeline
video_queue = gst_elementfactory_make("queue","video_queue");
gtk_object_set(GTK_OBJECT(video_queue),"max_level",30,NULL);
gst_bin_add(GST_BIN(pipeline),GST_ELEMENT(video_queue));
gst_bin_add(GST_BIN(pipeline),GST_ELEMENT(video_thread));
gst_pad_connect(gst_element_get_pad(videosrc, "src"),
gst_element_get_pad(video_queue,"sink"));
gst_pad_connect(gst_element_get_pad(video_queue,"src"),
gst_element_get_pad(video_thread,"sink"));
gtk_object_set(GTK_OBJECT(video_thread),"create_thread",TRUE,NULL);
g_print("\neverything's built, setting it up to be runnable\n");
gst_element_set_state(GST_ELEMENT(pipeline),GST_STATE_READY);
g_print("\nok, runnable, hitting 'play'...\n");
gst_element_set_state(GST_ELEMENT(pipeline),GST_STATE_PLAYING);
while(1)
gst_src_push(GST_SRC(videosrc));
}

View file

@ -68,7 +68,7 @@ int main(int argc,char *argv[]) {
gtk_widget_show_all(appwindow);
gst_element_set_state(GST_ELEMENT(bin),GST_STATE_RUNNING);
gst_element_set_state(GST_ELEMENT(bin),GST_STATE_READY);
gst_element_set_state(GST_ELEMENT(bin),GST_STATE_PLAYING);
//gtk_object_set(GTK_OBJECT(src),"tune",133250,NULL);

View file

@ -25,9 +25,9 @@ int main(int argc,char *argv[]) {
bin = gst_bin_new("bin");
srcfactory = gst_elementfactory_find("audiosrc");
g_return_if_fail(srcfactory != NULL);
g_return_val_if_fail(srcfactory != NULL, -1);
wavefactory = gst_elementfactory_find("smoothwave");
g_return_if_fail(wavefactory != NULL);
g_return_val_if_fail(wavefactory != NULL, -1);
src = gst_elementfactory_create(srcfactory,"src");
gtk_object_set(GTK_OBJECT(src),"bytes_per_read",(gulong)2048,NULL);
@ -46,7 +46,7 @@ int main(int argc,char *argv[]) {
gnome_app_set_contents(GNOME_APP(appwindow),gst_util_get_widget_arg(GTK_OBJECT(wave),"widget"));
gtk_widget_show_all(appwindow);
gst_element_set_state(GST_ELEMENT(bin),GST_STATE_RUNNING);
gst_element_set_state(GST_ELEMENT(bin),GST_STATE_READY);
gst_element_set_state(GST_ELEMENT(bin),GST_STATE_PLAYING);
g_idle_add(idle_func,src);