2000-05-28 20:04:31 +00:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
|
|
|
|
#include <gst/gst.h>
|
|
|
|
|
|
|
|
|
2000-12-30 01:53:05 +00:00
|
|
|
void eof(GstElement *src) {
|
2000-05-28 20:04:31 +00:00
|
|
|
g_print("have eof, quitting\n");
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
int main(int argc,char *argv[]) {
|
|
|
|
GstElementFactory *srcfactory, *pipefactory, *sinkfactory;
|
2000-12-30 01:53:05 +00:00
|
|
|
GstElement *pipeline, *src, *pipe, *sink;
|
2000-05-28 20:04:31 +00:00
|
|
|
int fd;
|
|
|
|
|
|
|
|
g_print("have %d args\n",argc);
|
|
|
|
|
|
|
|
gst_init(&argc,&argv);
|
|
|
|
|
|
|
|
pipeline = gst_pipeline_new("pipeline");
|
2000-08-14 15:17:24 +00:00
|
|
|
g_return_val_if_fail(pipeline != NULL, -1);
|
2000-05-28 20:04:31 +00:00
|
|
|
|
|
|
|
srcfactory = gst_elementfactory_find("disksrc");
|
2000-08-14 15:17:24 +00:00
|
|
|
g_return_val_if_fail(srcfactory != NULL, -1);
|
2000-05-28 20:04:31 +00:00
|
|
|
pipefactory = gst_elementfactory_find("pipefilter");
|
2000-08-14 15:17:24 +00:00
|
|
|
g_return_val_if_fail(pipefactory != NULL, -1);
|
2000-05-28 20:04:31 +00:00
|
|
|
sinkfactory = gst_elementfactory_find("fdsink");
|
2000-08-14 15:17:24 +00:00
|
|
|
g_return_val_if_fail(sinkfactory != NULL, -1);
|
2000-05-28 20:04:31 +00:00
|
|
|
|
|
|
|
src = gst_elementfactory_create(srcfactory,"src");
|
2000-08-14 15:17:24 +00:00
|
|
|
g_return_val_if_fail(src != NULL, -1);
|
2000-05-28 20:04:31 +00:00
|
|
|
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");
|
2000-08-14 15:17:24 +00:00
|
|
|
g_return_val_if_fail(pipe != NULL, -1);
|
2000-05-28 20:04:31 +00:00
|
|
|
sink = gst_elementfactory_create(sinkfactory,"fdsink");
|
2000-08-14 15:17:24 +00:00
|
|
|
g_return_val_if_fail(sink != NULL, -1);
|
2000-05-28 20:04:31 +00:00
|
|
|
|
|
|
|
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(pipe));
|
|
|
|
gst_bin_add(GST_BIN(pipeline),GST_ELEMENT(sink));
|
|
|
|
|
|
|
|
gst_pad_connect(gst_element_get_pad(src,"src"),
|
|
|
|
gst_element_get_pad(pipe,"sink"));
|
|
|
|
gst_pad_connect(gst_element_get_pad(pipe,"src"),
|
|
|
|
gst_element_get_pad(sink,"sink"));
|
|
|
|
|
2000-08-14 15:17:24 +00:00
|
|
|
g_print("setting to READY state\n");
|
2000-12-27 22:39:45 +00:00
|
|
|
gst_element_set_state(GST_ELEMENT(pipeline),GST_STATE_PLAYING);
|
2000-05-28 20:04:31 +00:00
|
|
|
|
|
|
|
g_print("about to enter loop\n");
|
|
|
|
while (1) {
|
2000-12-27 22:39:45 +00:00
|
|
|
gst_bin_iterate(GST_BIN(pipeline));
|
2000-05-28 20:04:31 +00:00
|
|
|
}
|
|
|
|
}
|