2000-03-27 19:53:43 +00:00
|
|
|
#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;
|
2001-03-24 17:22:03 +00:00
|
|
|
GstElement *osssrc, *videosrc, *fdsink, *encoder, *compress, *video_queue, *video_thread;
|
|
|
|
GstElementFactory *osssrcfactory, *fdsinkfactory, *encoderfactory, *compressfactory;
|
2000-03-27 19:53:43 +00:00
|
|
|
GstElementFactory *videosrcfactory;
|
|
|
|
GList *padlist;
|
|
|
|
|
|
|
|
gst_init(&argc,&argv);
|
|
|
|
|
2000-04-02 21:36:54 +00:00
|
|
|
gst_plugin_load("v4lsrc");
|
|
|
|
gst_plugin_load("aviencoder");
|
|
|
|
gst_plugin_load("jpeg");
|
2000-03-27 19:53:43 +00:00
|
|
|
|
|
|
|
pipeline = gst_pipeline_new("pipeline");
|
|
|
|
|
2001-03-24 17:22:03 +00:00
|
|
|
osssrcfactory = gst_elementfactory_find("osssrc");
|
|
|
|
osssrc = gst_elementfactory_create(osssrcfactory,"osssrc");
|
2000-05-21 21:58:20 +00:00
|
|
|
|
2000-03-27 19:53:43 +00:00
|
|
|
videosrcfactory = gst_elementfactory_find("v4lsrc");
|
|
|
|
videosrc = gst_elementfactory_create(videosrcfactory,"videosrc");
|
2000-04-02 21:36:54 +00:00
|
|
|
compressfactory = gst_elementfactory_find("jpegenc");
|
|
|
|
compress = gst_elementfactory_create(compressfactory,"jpegenc");
|
2000-03-27 19:53:43 +00:00
|
|
|
encoderfactory = gst_elementfactory_find("aviencoder");
|
|
|
|
encoder = gst_elementfactory_create(encoderfactory,"aviencoder");
|
2000-06-25 21:38:00 +00:00
|
|
|
gtk_object_set(GTK_OBJECT(videosrc),"width",320,"height",240,NULL);
|
2000-06-18 13:50:18 +00:00
|
|
|
gtk_object_set(GTK_OBJECT(videosrc),"format",9,NULL);
|
2000-04-02 21:36:54 +00:00
|
|
|
|
2000-06-18 13:50:18 +00:00
|
|
|
gtk_object_set(GTK_OBJECT(encoder),"video","00:I420",NULL);
|
2000-03-27 19:53:43 +00:00
|
|
|
|
|
|
|
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));
|
2000-05-21 21:58:20 +00:00
|
|
|
|
|
|
|
/* 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));
|
2000-03-27 19:53:43 +00:00
|
|
|
|
2000-06-18 13:50:18 +00:00
|
|
|
|
2000-03-27 19:53:43 +00:00
|
|
|
/* connect src to sink */
|
2000-05-21 21:58:20 +00:00
|
|
|
gst_element_add_ghost_pad(GST_ELEMENT(video_thread),
|
2000-06-18 13:50:18 +00:00
|
|
|
// gst_element_get_pad(compress,"sink"));
|
|
|
|
//gst_pad_connect(gst_element_get_pad(compress,"src"),
|
2001-01-20 03:33:55 +00:00
|
|
|
gst_element_get_pad(encoder,"video_00"),"video_00");
|
2000-03-27 19:53:43 +00:00
|
|
|
gst_pad_connect(gst_element_get_pad(encoder,"src"),
|
|
|
|
gst_element_get_pad(fdsink,"sink"));
|
|
|
|
|
2000-05-21 21:58:20 +00: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",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"),
|
2000-06-18 13:50:18 +00:00
|
|
|
gst_element_get_pad(video_thread,"video_00"));
|
2000-05-21 21:58:20 +00:00
|
|
|
|
|
|
|
gtk_object_set(GTK_OBJECT(video_thread),"create_thread",TRUE,NULL);
|
2000-03-27 19:53:43 +00:00
|
|
|
g_print("\neverything's built, setting it up to be runnable\n");
|
2000-08-14 15:17:24 +00:00
|
|
|
gst_element_set_state(GST_ELEMENT(pipeline),GST_STATE_READY);
|
2000-03-27 19:53:43 +00:00
|
|
|
g_print("\nok, runnable, hitting 'play'...\n");
|
|
|
|
gst_element_set_state(GST_ELEMENT(pipeline),GST_STATE_PLAYING);
|
|
|
|
|
|
|
|
while(1)
|
2000-12-27 22:39:45 +00:00
|
|
|
gst_bin_iterate(GST_BIN(pipeline));
|
2000-03-27 19:53:43 +00:00
|
|
|
}
|
|
|
|
|