mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-28 19:20:35 +00:00
removed a bunch of obsolete tests, changed others to use filesrc i'm not done yet...
Original commit message from CVS: removed a bunch of obsolete tests, changed others to use filesrc i'm not done yet...
This commit is contained in:
parent
303e8225df
commit
066fa36bf1
49 changed files with 36 additions and 3996 deletions
69
test/a.c
69
test/a.c
|
@ -1,69 +0,0 @@
|
|||
#include <gst/gst.h>
|
||||
|
||||
void eof(GstElement *src) {
|
||||
g_print("have eof, quitting\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
int main(int argc,char *argv[]) {
|
||||
GstType *autype;
|
||||
GList *factories;
|
||||
GstElementFactory *parsefactory;
|
||||
GstElement *bin, *disksrc, *parse, *osssink;
|
||||
GList *padlist;
|
||||
|
||||
gst_init(&argc,&argv);
|
||||
gst_plugin_load_all();
|
||||
|
||||
bin = gst_bin_new("bin");
|
||||
|
||||
disksrc = gst_disksrc_new("disksrc");
|
||||
g_print("created disksrc\n");
|
||||
if (argc == 2)
|
||||
gst_disksrc_set_filename(disksrc,argv[1]);
|
||||
else
|
||||
gst_disksrc_set_filename(disksrc,"Thank_you_very_much.au");
|
||||
g_print("loaded file '%s'\n",gst_disksrc_get_filename(disksrc));
|
||||
|
||||
|
||||
/* now it's time to get the parser */
|
||||
autype = gst_type_get_by_mime("audio/au");
|
||||
factories = gst_type_get_sinks(autype);
|
||||
if (factories != NULL)
|
||||
parsefactory = GST_ELEMENTFACTORY(factories->data);
|
||||
else {
|
||||
g_print("sorry, can't find anyone registered to sink 'au'\n");
|
||||
return 1;
|
||||
}
|
||||
parse = gst_elementfactory_create(parsefactory,"parser");
|
||||
if (parse == NULL) {
|
||||
g_print("sorry, couldn't create parser\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
osssink = gst_osssink_new("osssink");
|
||||
|
||||
gtk_signal_connect(GTK_OBJECT(disksrc),"eos",
|
||||
GTK_SIGNAL_FUNC(eof),NULL);
|
||||
|
||||
/* add objects to the main pipeline */
|
||||
gst_bin_add(GST_BIN(bin),GST_OBJECT(disksrc));
|
||||
gst_bin_add(GST_BIN(bin),GST_OBJECT(parse));
|
||||
gst_bin_add(GST_BIN(bin),GST_OBJECT(osssink));
|
||||
|
||||
/* connect src to sink */
|
||||
gst_pad_connect(gst_element_get_pad(disksrc,"src"),
|
||||
gst_element_get_pad(parse,"sink"));
|
||||
gst_pad_connect(gst_element_get_pad(parse,"src"),
|
||||
gst_element_get_pad(osssink,"sink"));
|
||||
|
||||
while(1)
|
||||
gst_disksrc_push(GST_SRC(disksrc));
|
||||
|
||||
gst_object_destroy(GST_OBJECT(osssink));
|
||||
gst_object_destroy(GST_OBJECT(parse));
|
||||
gst_object_destroy(GST_OBJECT(disksrc));
|
||||
gst_object_destroy(GST_OBJECT(bin));
|
||||
}
|
||||
|
|
@ -1,56 +0,0 @@
|
|||
#include <gst/gst.h>
|
||||
|
||||
extern gboolean _gst_plugin_spew;
|
||||
|
||||
void ac3parse_info_chain(GstPad *pad,GstBuffer *buf) {
|
||||
g_print("got buffer of size %d\n",GST_BUFFER_SIZE(buf));
|
||||
gst_buffer_unref(buf);
|
||||
}
|
||||
|
||||
int main(int argc,char *argv[]) {
|
||||
GstPipeline *pipeline;
|
||||
GstElementFactory *srcfactory, *parsefactory;
|
||||
GstElement *src, *parse;
|
||||
GstPad *infopad;
|
||||
|
||||
g_print("have %d args\n",argc);
|
||||
|
||||
_gst_plugin_spew = TRUE;
|
||||
gst_init(&argc,&argv);
|
||||
// gst_plugin_load("ac3parse");
|
||||
gst_plugin_load_all();
|
||||
|
||||
pipeline = GST_PIPELINE (gst_pipeline_new("pipeline"));
|
||||
g_return_val_if_fail(pipeline != NULL, -1);
|
||||
|
||||
srcfactory = gst_elementfactory_find("disksrc");
|
||||
g_return_val_if_fail(srcfactory != NULL, -1);
|
||||
parsefactory = gst_elementfactory_find("ac3parse");
|
||||
g_return_val_if_fail(parsefactory != NULL, -1);
|
||||
|
||||
src = gst_elementfactory_create(srcfactory,"src");
|
||||
g_return_val_if_fail(src != NULL, -1);
|
||||
g_object_set(G_OBJECT(src),"location",argv[1],"bytesperread",4096,NULL);
|
||||
g_print("should be using file '%s'\n",argv[1]);
|
||||
parse = gst_elementfactory_create(parsefactory,"parse");
|
||||
g_return_val_if_fail(parse != NULL, -1);
|
||||
|
||||
infopad = gst_pad_new("sink",GST_PAD_SINK);
|
||||
gst_pad_set_chain_function(infopad,ac3parse_info_chain);
|
||||
|
||||
gst_bin_add(GST_BIN(pipeline),GST_ELEMENT(src));
|
||||
gst_bin_add(GST_BIN(pipeline),GST_ELEMENT(parse));
|
||||
|
||||
gst_pad_connect(gst_element_get_pad(src,"src"),
|
||||
gst_element_get_pad(parse,"sink"));
|
||||
gst_pad_connect(gst_element_get_pad(parse,"src"),
|
||||
infopad);
|
||||
|
||||
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_bin_iterate(GST_BIN(pipeline));
|
||||
}
|
|
@ -1,73 +0,0 @@
|
|||
#include <gst/gst.h>
|
||||
|
||||
#include "mem.h"
|
||||
|
||||
extern gboolean _gst_plugin_spew;
|
||||
|
||||
int main(int argc,char *argv[]) {
|
||||
GstElement *pipeline, *decodethread;
|
||||
GstElement *src, *parse, *decode, *play;
|
||||
GstElement *queue;
|
||||
|
||||
// g_print("have %d args\n",argc);
|
||||
|
||||
// _gst_plugin_spew = TRUE;
|
||||
gst_init(&argc,&argv);
|
||||
|
||||
pipeline = gst_elementfactory_make("pipeline","ac3player");
|
||||
g_return_val_if_fail(pipeline != NULL, -1);
|
||||
decodethread = gst_elementfactory_make("thread","decodethread");
|
||||
g_return_val_if_fail(decodethread != NULL, -1);
|
||||
queue = gst_elementfactory_make("queue","queue");
|
||||
g_return_val_if_fail(queue != NULL, -1);
|
||||
|
||||
src = gst_elementfactory_make("disksrc","src");
|
||||
g_return_val_if_fail(src != NULL, -1);
|
||||
g_object_set(G_OBJECT(src),"location",argv[1],NULL);
|
||||
// g_print("should be using file '%s'\n",argv[1]);
|
||||
parse = gst_elementfactory_make("ac3parse","parse");
|
||||
g_return_val_if_fail(parse != NULL, -1);
|
||||
decode = gst_elementfactory_make("ac3dec","decode");
|
||||
g_return_val_if_fail(decode != NULL, -1);
|
||||
play = gst_elementfactory_make("osssink","play");
|
||||
g_return_val_if_fail(play != NULL, -1);
|
||||
|
||||
// construct the decode thread
|
||||
g_print("constructing the decode thread\n");
|
||||
gst_bin_add(GST_BIN(decodethread),GST_ELEMENT(src));
|
||||
gst_bin_add(GST_BIN(decodethread),GST_ELEMENT(parse));
|
||||
gst_bin_add(GST_BIN(decodethread),GST_ELEMENT(decode));
|
||||
gst_pad_connect(gst_element_get_pad(src,"src"),
|
||||
gst_element_get_pad(parse,"sink"));
|
||||
gst_pad_connect(gst_element_get_pad(parse,"src"),
|
||||
gst_element_get_pad(decode,"sink"));
|
||||
gst_element_add_ghost_pad(GST_ELEMENT(decodethread),
|
||||
gst_element_get_pad(decode,"src"),"src");
|
||||
|
||||
// construct the outer pipeline
|
||||
g_print("constructing the main pipeline\n");
|
||||
gst_bin_add(GST_BIN(pipeline),GST_ELEMENT(decodethread));
|
||||
gst_bin_add(GST_BIN(pipeline),GST_ELEMENT(queue));
|
||||
gst_bin_add(GST_BIN(pipeline),GST_ELEMENT(play));
|
||||
g_print("connecting main pipeline\n");
|
||||
gst_pad_connect(gst_element_get_pad(decodethread,"src"),
|
||||
gst_element_get_pad(queue,"sink"));
|
||||
gst_pad_connect(gst_element_get_pad(queue,"src"),
|
||||
gst_element_get_pad(play,"sink"));
|
||||
|
||||
#ifndef GST_DISABLE_LOADSAVE
|
||||
xmlSaveFile("ac3play.gst", gst_xml_write(GST_ELEMENT(pipeline)));
|
||||
#endif
|
||||
|
||||
// set thread start state
|
||||
g_object_set(G_OBJECT(decodethread),"create_thread",TRUE,NULL);
|
||||
|
||||
g_print("setting to READY state\n");
|
||||
gst_element_set_state(GST_ELEMENT(pipeline),GST_STATE_PLAYING);
|
||||
|
||||
// sleep(1);
|
||||
// g_print("about to enter loop\n");
|
||||
while (1) {
|
||||
gst_bin_iterate(GST_BIN(pipeline));
|
||||
}
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
int main(int argc,char *argv[]) {
|
||||
int fd;
|
||||
int offset = 0;
|
||||
int got;
|
||||
unsigned short buf[2048];
|
||||
int i;
|
||||
int prev = 0;
|
||||
|
||||
if (argc >= 2) fd = open(argv[1],O_RDONLY);
|
||||
else fd = 0;
|
||||
|
||||
while (got = read(fd,buf,sizeof(buf))) {
|
||||
for (i=0;i<(got/2);i++) {
|
||||
if (buf[i] == 0x770b) {
|
||||
printf("have sync at %d (+%d)\n",offset+(i*2),(offset+(i*2))-prev);
|
||||
prev = offset+(i*2);
|
||||
}
|
||||
}
|
||||
offset += got;
|
||||
}
|
||||
}
|
20
test/args.c
20
test/args.c
|
@ -1,20 +0,0 @@
|
|||
#include <glib.h>
|
||||
#include <gst/gst.h>
|
||||
|
||||
int main(int argc,char *argv[]) {
|
||||
GstElement *src;
|
||||
GList *padlist;
|
||||
GtkArg arg;
|
||||
|
||||
gst_init(&argc,&argv);
|
||||
|
||||
src = gst_disksrc_new("fakesrc");
|
||||
gtk_object_set(GTK_OBJECT(src),"location","demo.mp3",NULL);
|
||||
|
||||
arg.name = "location";
|
||||
gtk_object_getv(GTK_OBJECT(src),1,&arg);
|
||||
g_print("location is %s\n",GTK_VALUE_STRING(arg));
|
||||
|
||||
gst_object_destroy(GST_OBJECT(src));
|
||||
}
|
||||
|
189
test/avi2mpg.c
189
test/avi2mpg.c
|
@ -1,189 +0,0 @@
|
|||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <glib.h>
|
||||
#include <gst/gst.h>
|
||||
|
||||
#define BUFFER 1
|
||||
|
||||
extern gboolean _gst_plugin_spew;
|
||||
gboolean idle_func(gpointer data);
|
||||
int fd;
|
||||
char *outfile;
|
||||
GstElement *mux;
|
||||
|
||||
void eof(GstElement *src) {
|
||||
g_print("have eos, quitting\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
void new_pad_created(GstElement *parse,GstPad *pad,GstElement *pipeline) {
|
||||
GstElement *audio_encode;
|
||||
GstElement *encode, *smooth, *median;
|
||||
GstElement *audio_queue, *video_queue;
|
||||
GstElement *audio_thread, *video_thread;
|
||||
|
||||
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), "audio_", 6) == 0) {
|
||||
gst_plugin_load("mpegaudio");
|
||||
// construct internal pipeline elements
|
||||
audio_encode = gst_elementfactory_make("mpegaudio","audio_encode");
|
||||
g_return_if_fail(audio_encode != 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(audio_encode));
|
||||
|
||||
g_object_set(G_OBJECT(mux),"audio","00",NULL);
|
||||
|
||||
// set up pad connections
|
||||
gst_element_add_ghost_pad(GST_ELEMENT(audio_thread),
|
||||
gst_element_get_pad(audio_encode,"sink"),"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");
|
||||
g_object_set(G_OBJECT(audio_queue),"max_level",BUFFER,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
|
||||
g_object_set(G_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("smooth");
|
||||
gst_plugin_load("median");
|
||||
gst_plugin_load("mpeg2enc");
|
||||
// construct internal pipeline elements
|
||||
smooth = gst_elementfactory_make("smooth","smooth");
|
||||
g_return_if_fail(smooth != NULL);
|
||||
median = gst_elementfactory_make("median","median");
|
||||
g_return_if_fail(median != NULL);
|
||||
g_object_set(G_OBJECT(median),"filtersize",5,NULL);
|
||||
g_object_set(G_OBJECT(median),"active",TRUE,NULL);
|
||||
|
||||
g_object_set(G_OBJECT(smooth),"filtersize",16,NULL);
|
||||
g_object_set(G_OBJECT(smooth),"tolerance",16,NULL);
|
||||
g_object_set(G_OBJECT(smooth),"active",FALSE,NULL);
|
||||
|
||||
encode = gst_elementfactory_make("mpeg2enc","encode");
|
||||
g_return_if_fail(encode != NULL);
|
||||
|
||||
g_object_set(G_OBJECT(mux),"video","00",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(smooth));
|
||||
gst_bin_add(GST_BIN(video_thread),GST_ELEMENT(median));
|
||||
gst_bin_add(GST_BIN(video_thread),GST_ELEMENT(encode));
|
||||
gst_pad_connect(gst_element_get_pad(median,"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"));
|
||||
|
||||
// set up pad connections
|
||||
gst_element_add_ghost_pad(GST_ELEMENT(video_thread),
|
||||
gst_element_get_pad(median,"sink"),"sink");
|
||||
|
||||
// construct queue and connect everything in the main pipeline
|
||||
video_queue = gst_elementfactory_make("queue","video_queue");
|
||||
g_object_set(G_OBJECT(video_queue),"max_level",BUFFER,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
|
||||
g_object_set(G_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[]) {
|
||||
GstElement *pipeline, *src, *parse, *fdsink;
|
||||
GstElementFactory *fdsinkfactory;
|
||||
|
||||
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_val_if_fail(pipeline != NULL, -1);
|
||||
|
||||
src = gst_elementfactory_make("disksrc","src");
|
||||
g_return_val_if_fail(src != NULL, -1);
|
||||
g_object_set(G_OBJECT(src),"location",argv[1],NULL);
|
||||
g_print("should be using file '%s'\n",argv[1]);
|
||||
parse = gst_elementfactory_make("avidecoder","parse");
|
||||
g_return_val_if_fail(parse != NULL, -1);
|
||||
|
||||
mux = gst_elementfactory_make("system_encode","mux");
|
||||
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_val_if_fail(fdsinkfactory != NULL, -1);
|
||||
fdsink = gst_elementfactory_create(fdsinkfactory,"fdsink");
|
||||
g_return_val_if_fail(fdsink != NULL, -1);
|
||||
g_object_set(G_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));
|
||||
|
||||
g_signal_connect(G_OBJECT(parse),"new_pad",
|
||||
G_CALLBACK(new_pad_created),pipeline);
|
||||
|
||||
g_signal_connect(G_OBJECT(src),"eos",
|
||||
G_CALLBACK(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_PLAYING);
|
||||
|
||||
g_print("about to enter loop\n");
|
||||
|
||||
g_idle_add(idle_func,pipeline);
|
||||
|
||||
//gtk_main();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
gboolean idle_func(gpointer data) {
|
||||
gst_bin_iterate(GST_BIN(data));
|
||||
return TRUE;
|
||||
}
|
150
test/aviparse.c
150
test/aviparse.c
|
@ -1,150 +0,0 @@
|
|||
|
||||
#include <gnome.h>
|
||||
#include <gst/gst.h>
|
||||
|
||||
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(GstElement *src) {
|
||||
g_print("have eos, quitting\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
void new_pad_created(GstElement *parse,GstPad *pad,GstElement *pipeline) {
|
||||
|
||||
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), "audio_", 6) == 0) {
|
||||
// construct internal pipeline elements
|
||||
play = gst_elementfactory_make("osssink","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(play));
|
||||
|
||||
// set up pad connections
|
||||
gst_element_add_ghost_pad(GST_ELEMENT(audio_thread),
|
||||
gst_element_get_pad(play,"sink"),"sink");
|
||||
|
||||
// construct queue and connect everything in the main pipelie
|
||||
audio_queue = gst_elementfactory_make("queue","audio_queue");
|
||||
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);
|
||||
g_print("setting to PLAYING state\n");
|
||||
} else if (strncmp(gst_pad_get_name(pad), "video_", 6) == 0) {
|
||||
//} else if (0) {
|
||||
gst_pad_connect(pad,
|
||||
gst_element_get_pad(video_queue,"sink"));
|
||||
}
|
||||
g_print("\n");
|
||||
gst_element_set_state(GST_ELEMENT(pipeline),GST_STATE_PLAYING);
|
||||
}
|
||||
|
||||
int main(int argc,char *argv[]) {
|
||||
GstElement *pipeline, *src, *parse;
|
||||
|
||||
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);
|
||||
//gst_plugin_load_all();
|
||||
gst_plugin_load("parseavi");
|
||||
gst_plugin_load("videosink");
|
||||
|
||||
pipeline = gst_pipeline_new("pipeline");
|
||||
g_return_val_if_fail(pipeline != NULL, -1);
|
||||
|
||||
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]);
|
||||
|
||||
parse = gst_elementfactory_make("parseavi","parse");
|
||||
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_pointer_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"),"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));
|
||||
|
||||
gtk_signal_connect(GTK_OBJECT(parse),"new_pad",
|
||||
GTK_SIGNAL_FUNC(new_pad_created),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"));
|
||||
|
||||
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);
|
||||
|
||||
#ifndef GST_DISABLE_LOADSAVE
|
||||
xmlSaveFile("aviparse.xml",gst_xml_write(GST_ELEMENT(pipeline)));
|
||||
#endif
|
||||
|
||||
g_print("about to enter loop\n");
|
||||
|
||||
// this does not work due to multithreading
|
||||
g_idle_add(idle_func,pipeline);
|
||||
|
||||
gdk_threads_enter();
|
||||
gtk_main();
|
||||
gdk_threads_leave();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
gboolean idle_func(gpointer data) {
|
||||
gst_bin_iterate(GST_BIN(data));
|
||||
return TRUE;
|
||||
}
|
109
test/basic.c
109
test/basic.c
|
@ -1,109 +0,0 @@
|
|||
#include <glib.h>
|
||||
#include <gst/gst.h>
|
||||
|
||||
void added_child(GstObject *object,GstObject *child) {
|
||||
g_print("added_child(): added child '%s' to '%s'\n",
|
||||
gst_object_get_name(child),
|
||||
gst_object_get_name(object));
|
||||
}
|
||||
|
||||
void added_parent(GstObject *object,GstObject *parent) {
|
||||
g_print("added_parent(): object '%s' has new parent '%s'\n",
|
||||
gst_object_get_name(object),
|
||||
gst_object_get_name(parent));
|
||||
}
|
||||
|
||||
void list_pads(GstElement *element) {
|
||||
GList *padlist;
|
||||
|
||||
padlist = gst_element_get_pad_list(element);
|
||||
if (padlist == NULL)
|
||||
g_print("%s has no pads...\n",gst_object_get_name(element));
|
||||
else {
|
||||
while (padlist) {
|
||||
GstPad *pad = GST_PAD(padlist->data);
|
||||
if (gst_pad_get_ghost_parent(pad) == GST_OBJECT(element))
|
||||
g_print("'%s' had %s ghost pad '%s'\n",gst_object_get_name(element),
|
||||
(gst_pad_get_direction(pad) == GST_PAD_SRC) ? "SRC" : "SINK",
|
||||
gst_pad_get_name(pad));
|
||||
else
|
||||
g_print("'%s' had %s pad '%s'\n",gst_object_get_name(element),
|
||||
(gst_pad_get_direction(pad) == GST_PAD_SRC) ? "SRC" : "SINK",
|
||||
gst_pad_get_name(pad));
|
||||
padlist = g_list_next(padlist);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc,char *argv[]) {
|
||||
GstElement *bin, *src, *binf, *filter1, *filter2, *sink;
|
||||
GList *padlist;
|
||||
|
||||
gtk_init(&argc,&argv);
|
||||
|
||||
bin = gst_bin_new("bin");
|
||||
|
||||
src = gst_disksrc_new("fakesrc");
|
||||
gst_disksrc_set_filename(src,"demo.mp3");
|
||||
list_pads(src);
|
||||
|
||||
binf = gst_bin_new("binf");
|
||||
|
||||
filter1 = gst_fakefilter_new("filter1");
|
||||
list_pads(filter1);
|
||||
|
||||
filter2 = gst_fakefilter_new("filter2");
|
||||
list_pads(filter2);
|
||||
|
||||
sink = gst_fakesink_new("fakesink");
|
||||
list_pads(sink);
|
||||
|
||||
gtk_signal_connect(GTK_OBJECT(bin),"object_added",
|
||||
GTK_SIGNAL_FUNC(added_child),NULL);
|
||||
gtk_signal_connect(GTK_OBJECT(binf),"object_added",
|
||||
GTK_SIGNAL_FUNC(added_child),NULL);
|
||||
|
||||
gtk_signal_connect(GTK_OBJECT(binf),"parent_set",
|
||||
GTK_SIGNAL_FUNC(added_parent),NULL);
|
||||
gtk_signal_connect(GTK_OBJECT(src),"parent_set",
|
||||
GTK_SIGNAL_FUNC(added_parent),NULL);
|
||||
gtk_signal_connect(GTK_OBJECT(filter1),"parent_set",
|
||||
GTK_SIGNAL_FUNC(added_parent),NULL);
|
||||
gtk_signal_connect(GTK_OBJECT(filter2),"parent_set",
|
||||
GTK_SIGNAL_FUNC(added_parent),NULL);
|
||||
gtk_signal_connect(GTK_OBJECT(sink),"parent_set",
|
||||
GTK_SIGNAL_FUNC(added_parent),NULL);
|
||||
|
||||
/* add filter1 to the subbin */
|
||||
gst_bin_add(GST_BIN(binf),GST_ELEMENT(filter1));
|
||||
gst_bin_add(GST_BIN(binf),GST_ELEMENT(filter2));
|
||||
/* connect the two together */
|
||||
gst_pad_connect(gst_element_get_pad(filter1,"src"),
|
||||
gst_element_get_pad(filter2,"sink"));
|
||||
/* export the pads */
|
||||
gst_element_add_ghost_pad(binf,gst_element_get_pad(filter1,"sink"));
|
||||
gst_element_add_ghost_pad(binf,gst_element_get_pad(filter2,"src"));
|
||||
list_pads(binf);
|
||||
|
||||
/* add objects to the main pipeline */
|
||||
gst_bin_add(GST_BIN(bin),GST_OBJECT(src));
|
||||
gst_bin_add(GST_BIN(bin),GST_OBJECT(binf));
|
||||
gst_bin_add(GST_BIN(bin),GST_OBJECT(sink));
|
||||
|
||||
/* connect src to binf */
|
||||
gst_pad_connect(gst_element_get_pad(src,"src"),
|
||||
gst_element_get_pad(binf,"sink"));
|
||||
/* connect binf to sink */
|
||||
gst_pad_connect(gst_element_get_pad(binf,"src"),
|
||||
gst_element_get_pad(sink,"sink"));
|
||||
|
||||
gst_disksrc_push(GST_SRC(src));
|
||||
|
||||
gst_object_destroy(GST_OBJECT(src));
|
||||
gst_object_destroy(GST_OBJECT(filter1));
|
||||
gst_object_destroy(GST_OBJECT(filter2));
|
||||
gst_object_destroy(GST_OBJECT(binf));
|
||||
gst_object_destroy(GST_OBJECT(sink));
|
||||
gst_object_destroy(GST_OBJECT(bin));
|
||||
}
|
||||
|
|
@ -1,54 +0,0 @@
|
|||
#include <stdlib.h>
|
||||
#include <glib.h>
|
||||
#include <gst/gst.h>
|
||||
|
||||
#include "mem.h"
|
||||
|
||||
int main(int argc,char *argv[]) {
|
||||
GstBuffer *buf;
|
||||
GstBuffer **buffers;
|
||||
int i,max;
|
||||
long usage1,usage2;
|
||||
|
||||
gst_init(&argc,&argv);
|
||||
|
||||
max = atoi(argv[1]);
|
||||
|
||||
g_print("creating and destroying a buffer %d times...",max);
|
||||
usage1 = vmsize();
|
||||
for (i=0;i<max;i++) {
|
||||
buf = gst_buffer_new();
|
||||
gst_buffer_unref(buf);
|
||||
}
|
||||
usage2 = vmsize();
|
||||
g_print(" used %ld more bytes\n",usage2-usage1);
|
||||
|
||||
// g_print("pre-allocating space...");
|
||||
// usage1 = vmsize();
|
||||
// dummy = g_malloc(100*i);
|
||||
// usage2 = vmsize();
|
||||
// g_print(" (+%d)\n",usage2-usage1);
|
||||
|
||||
g_print("creating %d buffers...",max);
|
||||
buffers = (GstBuffer **)g_new(GstBuffer, i);
|
||||
usage1 = vmsize();
|
||||
for (i=0;i<max;i++)
|
||||
buffers[i] = gst_buffer_new();
|
||||
// buffers[i] = (GstBuffer *)g_malloc(1024);
|
||||
usage2 = vmsize();
|
||||
g_print(" (+%ld bytes), and destroying them...",usage2-usage1);
|
||||
usage1 = vmsize();
|
||||
for (i=0;i<max;i++)
|
||||
gst_buffer_unref(buffers[i]);
|
||||
// g_free(buffers[i]);
|
||||
usage2 = vmsize();
|
||||
g_print("(-%ld)\n",usage1-usage2);
|
||||
g_free(buffers);
|
||||
|
||||
g_print("buffer is %d bytes, list is %d bytes\n",
|
||||
sizeof(GstBuffer),sizeof(GList));
|
||||
|
||||
g_print("memory usage is %d\n",vmsize());
|
||||
|
||||
return 0;
|
||||
}
|
42
test/cobin.c
42
test/cobin.c
|
@ -1,42 +0,0 @@
|
|||
#include <gst/gst.h>
|
||||
|
||||
extern gboolean _gst_plugin_spew;
|
||||
|
||||
int main(int argc,char *argv[]) {
|
||||
GstElement *bin;
|
||||
GstElement *src, *identity, *sink;
|
||||
|
||||
_gst_plugin_spew = TRUE;
|
||||
gst_init(&argc,&argv);
|
||||
gst_plugin_load_all();
|
||||
|
||||
bin = gst_elementfactory_make("bin","bin");
|
||||
g_return_val_if_fail(bin != NULL, -1);
|
||||
|
||||
g_print("--- creating src and sink elements\n");
|
||||
src = gst_elementfactory_make("fakesrc","src");
|
||||
g_return_val_if_fail(src != NULL, -1);
|
||||
identity = gst_elementfactory_make(argv[1],"identity");
|
||||
g_return_val_if_fail(identity != NULL, -1);
|
||||
sink = gst_elementfactory_make("fakesink","sink");
|
||||
g_return_val_if_fail(sink != NULL, -1);
|
||||
|
||||
g_print("--- about to add the elements to the pipeline\n");
|
||||
gst_bin_add(GST_BIN(bin),GST_ELEMENT(src));
|
||||
gst_bin_add(GST_BIN(bin),GST_ELEMENT(identity));
|
||||
gst_bin_add(GST_BIN(bin),GST_ELEMENT(sink));
|
||||
|
||||
g_print("--- connecting\n");
|
||||
gst_pad_connect(gst_element_get_pad(src,"src"),
|
||||
gst_element_get_pad(identity,"sink"));
|
||||
gst_pad_connect(gst_element_get_pad(identity,"src"),
|
||||
gst_element_get_pad(sink,"sink"));
|
||||
|
||||
|
||||
g_print("--- starting up\n");
|
||||
gst_bin_iterate(GST_BIN(bin));
|
||||
|
||||
g_print("\n");
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,66 +0,0 @@
|
|||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <string.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 *videoscale;
|
||||
GstElement *encoder;
|
||||
GstElement *fdsink;
|
||||
|
||||
gint fd_video;
|
||||
|
||||
gst_init (&argc, &argv);
|
||||
|
||||
bin = gst_pipeline_new ("pipeline");
|
||||
|
||||
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");
|
||||
videoscale = gst_elementfactory_make ("videoscale", "videoscale");
|
||||
gtk_object_set (GTK_OBJECT (videoscale), "width", 352, "height",288, NULL);
|
||||
encoder = gst_elementfactory_make ("mpeg2enc", "mpeg2enc");
|
||||
fdsink = gst_elementfactory_make ("fdsink", "fdsink");
|
||||
|
||||
fd_video = open (argv[2], O_CREAT|O_RDWR|O_TRUNC);
|
||||
gtk_object_set (GTK_OBJECT (fdsink), "fd", fd_video, 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 (videoscale));
|
||||
gst_bin_add (GST_BIN (bin), GST_ELEMENT (encoder));
|
||||
gst_bin_add (GST_BIN (bin), GST_ELEMENT (fdsink));
|
||||
|
||||
gst_element_connect (src, "src", dvdec, "sink");
|
||||
gst_element_connect (cspace, "src", videoscale, "sink");
|
||||
gst_element_connect (videoscale, "src", encoder, "sink");
|
||||
gst_element_connect (encoder, "src", fdsink, "sink");
|
||||
gst_element_connect (dvdec, "video", cspace, "sink");
|
||||
|
||||
gst_element_set_state (GST_ELEMENT (bin), GST_STATE_PLAYING);
|
||||
|
||||
g_idle_add (idle_func, bin);
|
||||
|
||||
gtk_main ();
|
||||
|
||||
exit (0);
|
||||
}
|
||||
|
|
@ -1,46 +0,0 @@
|
|||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <gst/gst.h>
|
||||
|
||||
extern gboolean _gst_plugin_spew;
|
||||
|
||||
int main(int argc,char *argv[]) {
|
||||
GstElement *pipeline;
|
||||
GstElement *src, *sink;
|
||||
int fd;
|
||||
|
||||
_gst_plugin_spew = TRUE;
|
||||
gst_init(&argc,&argv);
|
||||
// gst_plugin_load("dvdsrc");
|
||||
|
||||
fd = creat("output.vob",0644);
|
||||
|
||||
pipeline = gst_elementfactory_make("pipeline","dvdcat");
|
||||
g_return_val_if_fail(pipeline != NULL, -1);
|
||||
|
||||
src = gst_elementfactory_make("dvdsrc","src");
|
||||
g_return_val_if_fail(src != NULL, -1);
|
||||
|
||||
g_object_set(G_OBJECT(src),"location",argv[1],NULL);
|
||||
if (argc >= 3)
|
||||
g_object_set(G_OBJECT(src),"offset",atoi(argv[2]),NULL);
|
||||
|
||||
sink = gst_elementfactory_make("fdsink","sink");
|
||||
g_return_val_if_fail(sink != NULL, -1);
|
||||
g_object_set(G_OBJECT(sink),"fd",fd,NULL);
|
||||
|
||||
// construct the outer pipeline
|
||||
gst_bin_add(GST_BIN(pipeline),GST_ELEMENT(src));
|
||||
gst_bin_add(GST_BIN(pipeline),GST_ELEMENT(sink));
|
||||
gst_pad_connect(gst_element_get_pad(src,"src"),
|
||||
gst_element_get_pad(sink,"sink"));
|
||||
|
||||
gst_element_set_state(GST_ELEMENT(pipeline),GST_STATE_READY);
|
||||
gst_element_set_state(GST_ELEMENT(pipeline),GST_STATE_PLAYING);
|
||||
|
||||
while (1)
|
||||
gst_bin_iterate(GST_BIN(pipeline));
|
||||
}
|
|
@ -35,7 +35,7 @@ main (int argc,char *argv[])
|
|||
if (argc == 1) {
|
||||
src = gst_elementfactory_make ("dv1394src", "src");
|
||||
} else {
|
||||
src = gst_elementfactory_make ("disksrc", "src");
|
||||
src = gst_elementfactory_make ("filesrc", "src");
|
||||
gtk_object_set(GTK_OBJECT(src),"location",argv[1],"bytesperread",480,NULL);
|
||||
}
|
||||
dvdec = gst_elementfactory_make ("dvdec", "decoder");
|
||||
|
|
42
test/fake.c
42
test/fake.c
|
@ -1,42 +0,0 @@
|
|||
#include <gst/gst.h>
|
||||
|
||||
extern gboolean _gst_plugin_spew;
|
||||
|
||||
int main(int argc,char *argv[]) {
|
||||
GstBin *bin;
|
||||
GstElement *src, *sink;
|
||||
GstPad *srcpad, *sinkpad;
|
||||
|
||||
// _gst_plugin_spew = TRUE;
|
||||
gst_init(&argc,&argv);
|
||||
|
||||
bin = GST_BIN (gst_pipeline_new("pipeline"));
|
||||
g_return_val_if_fail(bin != NULL,-1);
|
||||
|
||||
g_print("--- creating src and sink elements\n");
|
||||
src = gst_elementfactory_make("fakesrc","src");
|
||||
g_return_val_if_fail(src != NULL,-1);
|
||||
sink = gst_elementfactory_make("fakesink","sink");
|
||||
g_return_val_if_fail(sink != NULL,-1);
|
||||
|
||||
g_print("--- about to add the elements to the bin\n");
|
||||
gst_bin_add(bin,GST_ELEMENT(src));
|
||||
gst_bin_add(bin,GST_ELEMENT(sink));
|
||||
|
||||
g_print("--- getting pads\n");
|
||||
srcpad = gst_element_get_pad(src,"src");
|
||||
g_return_val_if_fail(srcpad != NULL,-1);
|
||||
sinkpad = gst_element_get_pad(sink,"sink");
|
||||
g_return_val_if_fail(srcpad != NULL,-1);
|
||||
|
||||
g_print("--- connecting\n");
|
||||
gst_pad_connect(srcpad,sinkpad);
|
||||
|
||||
g_print("--- setting up\n");
|
||||
gst_element_set_state(GST_ELEMENT(bin),GST_STATE_READY);
|
||||
|
||||
g_print("--- iterating\n");
|
||||
gst_bin_iterate(bin);
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
#include <glib.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <gst/gsttrace.h>
|
||||
|
||||
int main(int argc,char *argv[]) {
|
||||
gchar *filename = argv[1];
|
||||
int fd = open(filename,O_RDONLY);
|
||||
GstTraceEntry entry;
|
||||
|
||||
while (read(fd,&entry,sizeof(entry)))
|
||||
g_print("%Ld(%ld) 0x%08lx: %s\n",entry.timestamp,entry.sequence,
|
||||
entry.data,entry.message);
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
#include <stdio.h>
|
||||
|
||||
int main() {
|
||||
char line[256];
|
||||
unsigned long long a = 0,b;
|
||||
unsigned long long difference;
|
||||
unsigned long long mindiff = -1, maxdiff = 0;
|
||||
unsigned long long total = 0;
|
||||
int samples = 0;
|
||||
|
||||
while (gets(line)) {
|
||||
sscanf(line,"%Ld",&b);
|
||||
if (a) {
|
||||
difference = b - a;
|
||||
printf("difference is %Ld\n",difference);
|
||||
if (difference > maxdiff) maxdiff = difference;
|
||||
if (difference < mindiff) mindiff = difference;
|
||||
total += difference;
|
||||
samples++;
|
||||
}
|
||||
a = b;
|
||||
}
|
||||
printf("min difference is %Ld, avg %Ld, max is %Ld\n",
|
||||
mindiff,total/samples,maxdiff);
|
||||
printf("jitter is %Ld\n",maxdiff-mindiff);
|
||||
}
|
|
@ -1,6 +1,8 @@
|
|||
#include <gst/gst.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/* FIXME: WTF does this do? */
|
||||
|
||||
static guint64 max = 0, min = -1, total = 0;
|
||||
static guint count = 0;
|
||||
static guint print_del = 1;
|
||||
|
|
76
test/m.c
76
test/m.c
|
@ -1,76 +0,0 @@
|
|||
#include <gst/gst.h>
|
||||
#include <unistd.h>
|
||||
|
||||
void eof(GstSrc *src) {
|
||||
g_print("eof\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
int main(int argc,char *argv[]) {
|
||||
guint16 type;
|
||||
GList *factories;
|
||||
GstElementFactory *parsefactory;
|
||||
GstElement *bin, *src, *parse, *sink;
|
||||
GList *padlist;
|
||||
guchar *filename;
|
||||
|
||||
if (argc == 2)
|
||||
filename = argv[1];
|
||||
else
|
||||
filename = "-";
|
||||
|
||||
gst_init(&argc,&argv);
|
||||
gst_plugin_load_all();
|
||||
|
||||
bin = gst_bin_new("bin");
|
||||
|
||||
if (!strcmp(filename,"-"))
|
||||
src = gst_fdsrc_new_with_fd("src",STDIN_FILENO);
|
||||
else if (!strncmp(filename,"http://",7))
|
||||
src = gst_httpsrc_new_with_url("src",filename);
|
||||
else
|
||||
src = gst_asyncdisksrc_new_with_file("src",filename);
|
||||
|
||||
/* now it's time to get the parser */
|
||||
type = gst_type_find_by_mime("audio/mpeg");
|
||||
factories = gst_type_get_sinks(type);
|
||||
if (factories != NULL)
|
||||
parsefactory = GST_ELEMENTFACTORY(factories->data);
|
||||
else {
|
||||
g_print("sorry, can't find anyone registered to sink 'mp3'\n");
|
||||
return 1;
|
||||
}
|
||||
parse = gst_elementfactory_create(parsefactory,"parser");
|
||||
if (parse == NULL) {
|
||||
g_print("sorry, couldn't create parser\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
sink = gst_osssink_new("osssink");
|
||||
|
||||
gtk_signal_connect(GTK_OBJECT(src),"eof",
|
||||
GTK_SIGNAL_FUNC(eof),NULL);
|
||||
|
||||
/* add objects to the main pipeline */
|
||||
gst_bin_add(GST_BIN(bin),src);
|
||||
gst_bin_add(GST_BIN(bin),parse);
|
||||
gst_bin_add(GST_BIN(bin),sink);
|
||||
|
||||
/* connect src to sink */
|
||||
gst_pad_connect(gst_element_get_pad(src,"src"),
|
||||
gst_element_get_pad(parse,"sink"));
|
||||
gst_pad_connect(gst_element_get_pad(parse,"src"),
|
||||
gst_element_get_pad(sink,"sink"));
|
||||
|
||||
while(1) {
|
||||
g_print(".");
|
||||
gst_src_push(GST_SRC(src));
|
||||
}
|
||||
|
||||
gst_object_destroy(GST_OBJECT(sink));
|
||||
gst_object_destroy(GST_OBJECT(parse));
|
||||
gst_object_destroy(GST_OBJECT(src));
|
||||
gst_object_destroy(GST_OBJECT(bin));
|
||||
}
|
||||
|
386
test/main.c
386
test/main.c
|
@ -1,386 +0,0 @@
|
|||
#include <gtk/gtk.h>
|
||||
|
||||
#include "gst/gst.h"
|
||||
#include "gst/gstparse.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GstElement *pipeline;
|
||||
GstElement *src;
|
||||
|
||||
GstElement *ap_element;
|
||||
|
||||
GstElement *audio_sink;
|
||||
GstElement *video_sink;
|
||||
|
||||
GstElement *autobin;
|
||||
GstElement *typefind;
|
||||
GstElement *autoplugcache;
|
||||
|
||||
} GstPlayInfo;
|
||||
|
||||
// Global GStreamer elements
|
||||
static GstPlayInfo *info;
|
||||
|
||||
|
||||
void destroy( GtkWidget *widget, gpointer data )
|
||||
{
|
||||
gtk_main_quit();
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
gst_play_cache_empty (GstElement *element, GstElement *pipeline)
|
||||
{
|
||||
GstElement *autobin;
|
||||
GstElement *disksrc;
|
||||
GstElement *cache;
|
||||
GstElement *new_element;
|
||||
|
||||
fprintf (stderr, "have cache empty\n");
|
||||
|
||||
gst_element_set_state (pipeline, GST_STATE_PAUSED);
|
||||
|
||||
disksrc = gst_bin_get_by_name (GST_BIN (pipeline), "disk_source");
|
||||
autobin = gst_bin_get_by_name (GST_BIN (pipeline), "autobin");
|
||||
cache = gst_bin_get_by_name (GST_BIN (autobin), "cache");
|
||||
new_element = gst_bin_get_by_name (GST_BIN (autobin), "new_element");
|
||||
|
||||
gst_element_disconnect (disksrc, "src", cache, "sink");
|
||||
gst_element_disconnect (cache, "src", new_element, "sink");
|
||||
gst_bin_remove (GST_BIN (autobin), cache);
|
||||
gst_element_connect (disksrc, "src", new_element, "sink");
|
||||
|
||||
gst_element_set_state (pipeline, GST_STATE_PLAYING);
|
||||
|
||||
fprintf (stderr, "done with cache_empty\n");
|
||||
}
|
||||
|
||||
static void
|
||||
eos(GstElement *element, GstPlayInfo *info)
|
||||
{
|
||||
printf("Got EOS signal\n");
|
||||
|
||||
//gst_element_set_state( GST_ELEMENT(pipeline), GST_STATE_NULL );
|
||||
|
||||
gst_element_set_state (GST_ELEMENT (info->pipeline), GST_STATE_NULL);
|
||||
//gtk_object_set (GTK_OBJECT (info->src), "offset", 0, NULL);
|
||||
|
||||
}
|
||||
|
||||
|
||||
gboolean
|
||||
idle_func (gpointer ptr)
|
||||
{
|
||||
GstPlayInfo *info = (GstPlayInfo*) ptr;
|
||||
|
||||
return gst_bin_iterate (GST_BIN (info->pipeline));
|
||||
}
|
||||
|
||||
static void
|
||||
gst_play_have_type (GstElement *typefind, GstCaps *caps, GstPlayInfo *info)
|
||||
{
|
||||
GstElement *vis_bin;
|
||||
GstElement *new_element;
|
||||
GstAutoplug *autoplug;
|
||||
GstElement *autobin;
|
||||
GstElement *disksrc;
|
||||
GstElement *cache;
|
||||
|
||||
GstElement *pipeline = info->pipeline;
|
||||
|
||||
printf( "In gst_play_have_type()\n" );
|
||||
|
||||
gst_element_set_state (pipeline, GST_STATE_PAUSED);
|
||||
|
||||
disksrc = gst_bin_get_by_name (GST_BIN (pipeline), "disk_source");
|
||||
autobin = gst_bin_get_by_name (GST_BIN (pipeline), "autobin");
|
||||
cache = gst_bin_get_by_name (GST_BIN (autobin), "cache");
|
||||
|
||||
// disconnect the typefind from the pipeline and remove it
|
||||
gst_element_disconnect (cache, "src", typefind, "sink");
|
||||
gst_bin_remove (GST_BIN (autobin), typefind);
|
||||
|
||||
// XXXXXXXXXXX
|
||||
|
||||
printf( "About to autoplug\n" );
|
||||
|
||||
autoplug = gst_autoplugfactory_make ("staticrender");
|
||||
g_assert (autoplug != NULL);
|
||||
|
||||
//gtk_signal_connect (GTK_OBJECT (autoplug), "new_object", GTK_SIGNAL_FUNC(gst_play_object_added), info);
|
||||
|
||||
printf( "-- 1 --\n" );
|
||||
|
||||
info->ap_element = gst_autoplug_to_renderers (autoplug,
|
||||
caps,
|
||||
//vis_bin,
|
||||
info->video_sink,
|
||||
info->audio_sink,
|
||||
NULL);
|
||||
|
||||
printf( "-- 2 --\n" );
|
||||
|
||||
if (!info->ap_element) {
|
||||
g_print ("could not autoplug, no suitable codecs found...\n");
|
||||
exit (-1);
|
||||
}
|
||||
|
||||
gst_element_set_name (info->ap_element, "new_element");
|
||||
|
||||
gst_bin_add (GST_BIN (autobin), info->ap_element);
|
||||
|
||||
gtk_object_set (GTK_OBJECT (cache), "reset", TRUE, NULL);
|
||||
|
||||
gst_element_connect (cache, "src", info->ap_element, "sink");
|
||||
|
||||
// Add the "eos" handler to the main pipeline
|
||||
gtk_signal_connect( GTK_OBJECT(disksrc),"eos", GTK_SIGNAL_FUNC(eos), info);
|
||||
|
||||
gst_element_set_state (pipeline, GST_STATE_PLAYING);
|
||||
|
||||
#ifndef GST_DISABLE_LOADSAVE
|
||||
xmlSaveFile("xmlTest.gst", gst_xml_write (GST_ELEMENT (pipeline)));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
// Handles setting up a stream and playing
|
||||
void play( GtkWidget *widget, gpointer data )
|
||||
{
|
||||
gchar *fileName = gtk_entry_get_text( GTK_ENTRY(data) );
|
||||
|
||||
printf( "In Play()\n" );
|
||||
|
||||
if( info->pipeline )
|
||||
{
|
||||
GstObject *parent;
|
||||
|
||||
parent = gst_element_get_parent (info->audio_sink);
|
||||
if (parent) {
|
||||
gst_object_ref (GST_OBJECT (info->audio_sink));
|
||||
gst_bin_remove( GST_BIN(parent), info->audio_sink );
|
||||
}
|
||||
|
||||
parent = gst_element_get_parent (info->video_sink);
|
||||
if (parent) {
|
||||
gst_object_ref (GST_OBJECT (info->video_sink));
|
||||
gst_bin_remove( GST_BIN(parent), info->video_sink );
|
||||
}
|
||||
|
||||
gst_pipeline_destroy( info->pipeline );
|
||||
}
|
||||
|
||||
// Create a new pipeline
|
||||
info->pipeline = gst_pipeline_new( "pipeline" );
|
||||
|
||||
// Create a disksrc
|
||||
info->src = gst_elementfactory_make( "disksrc", "disk_source" );
|
||||
|
||||
// Set the location of the disksrc
|
||||
gtk_object_set( GTK_OBJECT(info->src), "location", fileName, NULL );
|
||||
|
||||
gst_bin_add( GST_BIN(info->pipeline), info->src );
|
||||
|
||||
// Setup a bin to store the typefind and autoplugcache elements
|
||||
info->autobin = gst_bin_new( "autobin" );
|
||||
|
||||
// Create the typefind element
|
||||
info->typefind = gst_elementfactory_make( "typefind", "typefind" );
|
||||
gtk_signal_connect( GTK_OBJECT(info->typefind), "have_type",
|
||||
GTK_SIGNAL_FUNC(gst_play_have_type), info );
|
||||
|
||||
// Create the autoplugcache element
|
||||
info->autoplugcache = gst_elementfactory_make( "autoplugcache", "cache" );
|
||||
gtk_signal_connect( GTK_OBJECT(info->autoplugcache), "cache_empty",
|
||||
GTK_SIGNAL_FUNC(gst_play_cache_empty), info->pipeline );
|
||||
|
||||
gst_bin_add( GST_BIN(info->autobin), info->typefind );
|
||||
gst_bin_add( GST_BIN(info->autobin), info->autoplugcache );
|
||||
|
||||
// Connect the autoplugcache element to the typefind element
|
||||
gst_element_connect( info->autoplugcache, "src", info->typefind, "sink" );
|
||||
gst_element_add_ghost_pad( info->autobin, gst_element_get_pad( info->autoplugcache, "sink" ), "sink" );
|
||||
|
||||
// Add the autobin to the main pipeline and connect the disksrc to the autobin
|
||||
gst_bin_add( GST_BIN(info->pipeline), info->autobin );
|
||||
gst_element_connect( info->src, "src", info->autobin, "sink" );
|
||||
|
||||
// Set the state to GST_STATE_PLAYING
|
||||
gst_element_set_state( GST_ELEMENT(info->pipeline), GST_STATE_PLAYING );
|
||||
|
||||
gtk_idle_add( idle_func, info );
|
||||
|
||||
printf( "Leaving Play()\n" );
|
||||
|
||||
}
|
||||
|
||||
|
||||
void playMP3( GtkWidget *widget, gpointer data )
|
||||
{
|
||||
GstElement *mp3parse;
|
||||
GstElement *mpg123;
|
||||
GstElement *osssink;
|
||||
gchar *fileName;
|
||||
|
||||
|
||||
printf( "In playMP3()\n" );
|
||||
|
||||
fileName = gtk_entry_get_text( GTK_ENTRY(data) );
|
||||
|
||||
|
||||
if( info->pipeline )
|
||||
{
|
||||
gst_pipeline_destroy( info->pipeline );
|
||||
}
|
||||
|
||||
// Create a new pipeline
|
||||
info->pipeline = gst_pipeline_new( "pipeline" );
|
||||
|
||||
// Create a disksrc
|
||||
info->src = gst_elementfactory_make( "disksrc", "disk_source" );
|
||||
|
||||
// Set the location of the disksrc
|
||||
gtk_object_set( GTK_OBJECT(info->src), "location", fileName, NULL );
|
||||
|
||||
gst_bin_add( GST_BIN(info->pipeline), info->src );
|
||||
|
||||
mp3parse = gst_elementfactory_make( "mp3parse", "parser" );
|
||||
gst_element_connect( info->src, "src", mp3parse, "sink" );
|
||||
gst_bin_add( GST_BIN(info->pipeline), mp3parse );
|
||||
|
||||
mpg123 = gst_elementfactory_make( "mpg123", "decoder" );
|
||||
gst_element_connect( mp3parse, "src", mpg123, "sink" );
|
||||
gst_bin_add( GST_BIN(info->pipeline), mpg123 );
|
||||
|
||||
osssink = gst_elementfactory_make( "osssink", "audio_sink" );
|
||||
gst_element_connect( mpg123, "src", osssink, "sink" );
|
||||
gst_bin_add( GST_BIN(info->pipeline), osssink );
|
||||
|
||||
// Add the "eos" handler to the main pipeline
|
||||
gtk_signal_connect( GTK_OBJECT(info->src),"eos", GTK_SIGNAL_FUNC(eos), info);
|
||||
|
||||
// Set the state to GST_STATE_PLAYING
|
||||
gst_element_set_state( GST_ELEMENT(info->pipeline), GST_STATE_PLAYING );
|
||||
|
||||
gtk_idle_add( idle_func, info );
|
||||
}
|
||||
|
||||
|
||||
// Handles stopping a playing stream and tearing down the pipeline
|
||||
void stop( GtkWidget *widget, gpointer data )
|
||||
{
|
||||
if( info->pipeline )
|
||||
gst_element_set_state( GST_ELEMENT(info->pipeline), GST_STATE_NULL );
|
||||
}
|
||||
|
||||
// Handles pausing the playing stream
|
||||
/*
|
||||
void pause( GtkWidget *widget, gpointer data )
|
||||
{
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
int main( int argc, char *argv[] )
|
||||
{
|
||||
GtkWidget *window;
|
||||
GtkWidget *textField;
|
||||
GtkWidget *socket;
|
||||
GtkWidget *playBtn, *playMp3Btn, *stopBtn;
|
||||
GtkWidget *vbox, *hbox;
|
||||
|
||||
|
||||
gtk_init( &argc, &argv );
|
||||
gst_init( &argc, &argv );
|
||||
|
||||
|
||||
|
||||
// Allocate the struct for storing GStreamer elements
|
||||
info = (GstPlayInfo*) calloc( 1, sizeof(GstPlayInfo) );
|
||||
|
||||
// create an audio sink
|
||||
info->audio_sink = gst_elementfactory_make("osssink", "play_audio");
|
||||
|
||||
// create a video sink
|
||||
info->video_sink = gst_elementfactory_make("xvideosink", "play_video");
|
||||
|
||||
|
||||
|
||||
|
||||
// Create a new window
|
||||
window = gtk_window_new( GTK_WINDOW_TOPLEVEL );
|
||||
gtk_widget_set_usize( GTK_WIDGET(window), 300, 400 );
|
||||
|
||||
gtk_signal_connect( GTK_OBJECT(window), "delete_event",
|
||||
GTK_SIGNAL_FUNC(destroy), NULL );
|
||||
|
||||
gtk_signal_connect( GTK_OBJECT(window), "destroy",
|
||||
GTK_SIGNAL_FUNC(destroy), NULL );
|
||||
|
||||
gtk_container_set_border_width( GTK_CONTAINER(window), 10 );
|
||||
|
||||
// Create a vertical box
|
||||
vbox = gtk_vbox_new( FALSE, 0 );
|
||||
gtk_container_add( GTK_CONTAINER(window), vbox );
|
||||
gtk_widget_show( vbox );
|
||||
|
||||
// Create the socket widget
|
||||
socket = gtk_socket_new();
|
||||
gtk_box_pack_start( GTK_BOX(vbox), socket, TRUE, TRUE, 0 );
|
||||
gtk_widget_show( GTK_WIDGET(socket) );
|
||||
gtk_widget_set_usize( GTK_WIDGET(socket), 300, 300 );
|
||||
|
||||
// Connect the socket widget to the xvideosink element
|
||||
gtk_widget_realize (socket);
|
||||
gtk_socket_steal( GTK_SOCKET(socket),
|
||||
gst_util_get_int_arg( (GObject*)info->video_sink, "xid" ));
|
||||
|
||||
|
||||
// Create the text entry widget
|
||||
textField = gtk_entry_new();
|
||||
gtk_box_pack_start( GTK_BOX(vbox), textField, TRUE, TRUE, 0 );
|
||||
gtk_widget_show( GTK_WIDGET(textField) );
|
||||
|
||||
// Create a horizontal box
|
||||
hbox = gtk_hbox_new( FALSE, 0 );
|
||||
gtk_container_add( GTK_CONTAINER(vbox), hbox );
|
||||
gtk_widget_show( hbox );
|
||||
|
||||
// Create the play button
|
||||
playBtn = gtk_button_new_with_label( "Play" );
|
||||
|
||||
gtk_signal_connect( GTK_OBJECT(playBtn), "clicked",
|
||||
GTK_SIGNAL_FUNC(play), textField );
|
||||
|
||||
gtk_box_pack_start( GTK_BOX(hbox), playBtn, TRUE, TRUE, 0 );
|
||||
gtk_widget_show( GTK_WIDGET(playBtn) );
|
||||
|
||||
// Create the Play Mp3 button
|
||||
playMp3Btn = gtk_button_new_with_label( "Play Mp3" );
|
||||
|
||||
gtk_signal_connect( GTK_OBJECT(playMp3Btn), "clicked",
|
||||
GTK_SIGNAL_FUNC(playMP3), textField );
|
||||
|
||||
gtk_box_pack_start( GTK_BOX(hbox), playMp3Btn, TRUE, TRUE, 0 );
|
||||
gtk_widget_show( GTK_WIDGET(playMp3Btn) );
|
||||
|
||||
// Create the stop button
|
||||
stopBtn = gtk_button_new_with_label( "Stop" );
|
||||
|
||||
gtk_signal_connect( GTK_OBJECT(stopBtn), "clicked",
|
||||
GTK_SIGNAL_FUNC(stop), textField );
|
||||
|
||||
gtk_box_pack_start( GTK_BOX(hbox), stopBtn, TRUE, TRUE, 0 );
|
||||
gtk_widget_show( GTK_WIDGET(stopBtn) );
|
||||
|
||||
|
||||
|
||||
gtk_widget_show( window );
|
||||
|
||||
gtk_main();
|
||||
|
||||
return(0);
|
||||
|
||||
}
|
77
test/mcut.c
77
test/mcut.c
|
@ -1,77 +0,0 @@
|
|||
#include <gst/gst.h>
|
||||
|
||||
void eof(GstSrc *src) {
|
||||
g_print("have eof, quitting\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
int main(int argc,char *argv[]) {
|
||||
GstType *type;
|
||||
GList *factories;
|
||||
GstElementFactory *parsefactory;
|
||||
GstElement *bin, *src, *parse, *sink;
|
||||
GList *padlist;
|
||||
guchar *filename;
|
||||
glong length = 0, size = 4180, skip = 8360, offset = 0;
|
||||
|
||||
if (argc == 2)
|
||||
filename = argv[1];
|
||||
else {
|
||||
g_print("sorry, need a filename now\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
gst_init(&argc,&argv);
|
||||
gst_plugin_load_all();
|
||||
|
||||
bin = gst_bin_new("bin");
|
||||
|
||||
src = gst_asyncdisksrc_new("src");
|
||||
g_print("created disksrc\n");
|
||||
gtk_object_set(GTK_OBJECT(src),"location",filename,NULL);
|
||||
length = gst_util_get_long_arg(GST_OBJECT(src),"length");
|
||||
g_print("file is %d bytes long\n",length);
|
||||
|
||||
/* now it's time to get the parser */
|
||||
type = gst_type_get_by_mime("audio/mp3");
|
||||
factories = gst_type_get_sinks(type);
|
||||
if (factories != NULL)
|
||||
parsefactory = GST_ELEMENTFACTORY(factories->data);
|
||||
else {
|
||||
g_print("sorry, can't find anyone registered to sink 'mp3'\n");
|
||||
return 1;
|
||||
}
|
||||
parse = gst_elementfactory_create(parsefactory,"parser");
|
||||
if (parse == NULL) {
|
||||
g_print("sorry, couldn't create parser\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
sink = gst_osssink_new("osssink");
|
||||
|
||||
gtk_signal_connect(GTK_OBJECT(src),"eof",
|
||||
GTK_SIGNAL_FUNC(eof),NULL);
|
||||
|
||||
/* add objects to the main pipeline */
|
||||
gst_bin_add(GST_BIN(bin),src);
|
||||
gst_bin_add(GST_BIN(bin),parse);
|
||||
gst_bin_add(GST_BIN(bin),sink);
|
||||
|
||||
/* connect src to sink */
|
||||
gst_pad_connect(gst_element_get_pad(src,"src"),
|
||||
gst_element_get_pad(parse,"sink"));
|
||||
gst_pad_connect(gst_element_get_pad(parse,"src"),
|
||||
gst_element_get_pad(sink,"sink"));
|
||||
|
||||
while(offset < length) {
|
||||
gst_src_push_region(GST_SRC(src),offset,size);
|
||||
offset += skip;
|
||||
}
|
||||
|
||||
gst_object_destroy(GST_OBJECT(sink));
|
||||
gst_object_destroy(GST_OBJECT(parse));
|
||||
gst_object_destroy(GST_OBJECT(src));
|
||||
gst_object_destroy(GST_OBJECT(bin));
|
||||
}
|
||||
|
23
test/mem.c
23
test/mem.c
|
@ -1,23 +0,0 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
int vmsize() {
|
||||
int pid,fd,size,i,mem;
|
||||
char filename[17], buf[256], *ptr, *end;
|
||||
|
||||
pid = getpid();
|
||||
snprintf(filename,17,"/proc/%d/stat",pid);
|
||||
fd = open(filename,O_RDONLY);
|
||||
size = read(fd,buf,240);
|
||||
ptr = buf;
|
||||
for (i=0;i<22;i++)
|
||||
ptr = (char *)strchr(ptr,' ') + 1;
|
||||
end = (char *)strchr(ptr,' ');
|
||||
*end = 0;
|
||||
sscanf(ptr,"%d",&mem);
|
||||
close(fd);
|
||||
return mem;
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
int vmsize();
|
175
test/mp1parse.c
175
test/mp1parse.c
|
@ -1,175 +0,0 @@
|
|||
|
||||
#define BUFFER 20
|
||||
#define VIDEO_DECODER "mpeg_play"
|
||||
|
||||
#include <gnome.h>
|
||||
#include <gst/gst.h>
|
||||
|
||||
extern gboolean _gst_plugin_spew;
|
||||
gboolean idle_func(gpointer data);
|
||||
|
||||
void eof(GstElement *src) {
|
||||
g_print("have eos, quitting\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
void new_pad_created(GstElement *parse,GstPad *pad,GstElement *pipeline) {
|
||||
GstElement *parse_audio, *parse_video, *decode, *decode_video, *play, *videoscale, *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) {
|
||||
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");
|
||||
g_return_if_fail(decode != NULL);
|
||||
play = gst_elementfactory_make("osssink","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"),"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",BUFFER,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");
|
||||
} else if (strncmp(gst_pad_get_name(pad), "video_", 6) == 0) {
|
||||
//} else if (0) {
|
||||
|
||||
// construct internal pipeline elements
|
||||
parse_video = gst_elementfactory_make("mp1videoparse","parse_video");
|
||||
g_return_if_fail(parse_video != NULL);
|
||||
decode_video = gst_elementfactory_make(VIDEO_DECODER,"decode_video");
|
||||
g_return_if_fail(decode_video != NULL);
|
||||
videoscale = gst_elementfactory_make("videoscale","videoscale");
|
||||
g_return_if_fail(videoscale != NULL);
|
||||
gtk_object_set(GTK_OBJECT(videoscale),"width",704, "height", 576,NULL);
|
||||
|
||||
|
||||
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("MPEG1 player","MPEG1 player");
|
||||
gnome_app_set_contents(GNOME_APP(appwindow),
|
||||
gst_util_get_pointer_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(parse_video));
|
||||
gst_bin_add(GST_BIN(video_thread),GST_ELEMENT(decode_video));
|
||||
//gst_bin_add(GST_BIN(video_thread),GST_ELEMENT(videoscale));
|
||||
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(parse_video,"sink"),"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(videoscale,"sink"));
|
||||
//gst_pad_connect(gst_element_get_pad(videoscale,"src"),
|
||||
gst_element_get_pad(show,"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",BUFFER,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");
|
||||
}
|
||||
g_print("\n");
|
||||
gst_element_set_state(GST_ELEMENT(pipeline),GST_STATE_PLAYING);
|
||||
}
|
||||
|
||||
int main(int argc,char *argv[]) {
|
||||
GstElement *pipeline, *src, *parse;
|
||||
|
||||
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);
|
||||
|
||||
pipeline = gst_pipeline_new("pipeline");
|
||||
g_return_val_if_fail(pipeline != NULL, -1);
|
||||
|
||||
//src = gst_elementfactory_make("disksrc","src");
|
||||
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]);
|
||||
|
||||
parse = gst_elementfactory_make("mpeg1parse","parse");
|
||||
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));
|
||||
|
||||
gtk_signal_connect(GTK_OBJECT(parse),"new_pad",
|
||||
GTK_SIGNAL_FUNC(new_pad_created),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"));
|
||||
|
||||
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");
|
||||
|
||||
g_idle_add(idle_func,pipeline);
|
||||
|
||||
gdk_threads_enter();
|
||||
gtk_main();
|
||||
gdk_threads_leave();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
gboolean idle_func(gpointer data) {
|
||||
gst_bin_iterate(GST_BIN(data));
|
||||
return TRUE;
|
||||
}
|
216
test/mp1tomp1.c
216
test/mp1tomp1.c
|
@ -1,216 +0,0 @@
|
|||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <glib.h>
|
||||
#include <gst/gst.h>
|
||||
|
||||
int fd;
|
||||
char *outfile;
|
||||
|
||||
void eof(GstElement *src) {
|
||||
g_print("have eos, quitting\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
void mp2tomp1(GstElement *parser,GstPad *pad, GstElement *pipeline) {
|
||||
GstElement *parse_audio, *parse_video, *decode, *decode_video, *play, *encode;
|
||||
GstElement *audio_queue, *video_queue;
|
||||
GstElement *audio_thread, *video_thread;
|
||||
//GstElement *videoscale;
|
||||
GstElement *fdsink;
|
||||
GstElementFactory *fdsinkfactory;
|
||||
|
||||
g_print("***** a new pad %s was created\n", gst_pad_get_name(pad));
|
||||
|
||||
// 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");
|
||||
// construct internal pipeline elements
|
||||
parse_audio = gst_elementfactory_make("ac3parse","parse_audio");
|
||||
g_return_if_fail(parse_audio != NULL);
|
||||
decode = gst_elementfactory_make("ac3dec","decode_audio");
|
||||
g_return_if_fail(decode != NULL);
|
||||
play = gst_elementfactory_make("osssink","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"),"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");
|
||||
g_object_set(G_OBJECT(audio_queue),"max_level",30,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
|
||||
g_object_set(G_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);
|
||||
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) {
|
||||
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("osssink","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"),"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");
|
||||
g_object_set(G_OBJECT(audio_queue),"max_level",30,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
|
||||
g_object_set(G_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);
|
||||
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("mp1videoparse");
|
||||
gst_plugin_load("mpeg_play");
|
||||
gst_plugin_load("mpeg2enc");
|
||||
// construct internal pipeline elements
|
||||
parse_video = gst_elementfactory_make("mp1videoparse","parse_video");
|
||||
g_return_if_fail(parse_video != NULL);
|
||||
decode_video = gst_elementfactory_make("mpeg_play","decode_video");
|
||||
g_return_if_fail(decode_video != NULL);
|
||||
encode = gst_elementfactory_make("mpeg2enc","encode");
|
||||
g_return_if_fail(encode != NULL);
|
||||
//g_object_set(G_OBJECT(show),"width",640, "height", 480,NULL);
|
||||
fd = open(outfile,O_CREAT|O_RDWR|O_TRUNC);
|
||||
|
||||
fdsinkfactory = gst_elementfactory_find("fdsink");
|
||||
g_return_if_fail(fdsinkfactory != NULL);
|
||||
fdsink = gst_elementfactory_create(fdsinkfactory,"fdsink");
|
||||
g_return_if_fail(fdsink != NULL);
|
||||
g_object_set(G_OBJECT(fdsink),"fd",fd,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(encode));
|
||||
gst_bin_add(GST_BIN(video_thread),GST_ELEMENT(fdsink));
|
||||
|
||||
// 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_pad_connect(gst_element_get_pad(decode_video,"src"),
|
||||
gst_element_get_pad(encode,"sink"));
|
||||
gst_pad_connect(gst_element_get_pad(encode,"src"),
|
||||
gst_element_get_pad(fdsink,"sink"));
|
||||
|
||||
// construct queue and connect everything in the main pipeline
|
||||
video_queue = gst_elementfactory_make("queue","video_queue");
|
||||
g_object_set(G_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(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
|
||||
g_object_set(G_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("setting to PLAYING state\n");
|
||||
gst_element_set_state(GST_ELEMENT(video_thread),GST_STATE_PLAYING);
|
||||
}
|
||||
g_print("\n");
|
||||
}
|
||||
|
||||
int main(int argc,char *argv[]) {
|
||||
GstElement *pipeline, *src, *parse;
|
||||
|
||||
g_print("have %d args\n",argc);
|
||||
|
||||
gst_init(&argc,&argv);
|
||||
gst_plugin_load("mpeg1parse");
|
||||
|
||||
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);
|
||||
g_object_set(G_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]);
|
||||
outfile = argv[2];
|
||||
|
||||
parse = gst_elementfactory_make("mpeg1parse","parse");
|
||||
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));
|
||||
|
||||
g_signal_connect(G_OBJECT(parse),"new_pad",G_CALLBACK(mp2tomp1), pipeline);
|
||||
|
||||
g_signal_connect(G_OBJECT(src),"eos",G_CALLBACK(eof),NULL);
|
||||
|
||||
gst_pad_connect(gst_element_get_pad(src,"src"),
|
||||
gst_element_get_pad(parse,"sink"));
|
||||
|
||||
g_print("setting to READY state\n");
|
||||
gst_element_set_state(GST_ELEMENT(pipeline),GST_STATE_PLAYING);
|
||||
|
||||
while (1) {
|
||||
gst_bin_iterate(GST_BIN(pipeline));
|
||||
}
|
||||
}
|
272
test/mp2toavi.c
272
test/mp2toavi.c
|
@ -1,272 +0,0 @@
|
|||
|
||||
#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 (GstElement *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(G_OBJECT(element),"last_frame_size");
|
||||
|
||||
total+=frame_size;
|
||||
|
||||
g_print("encoded frame %d %ld %ld\n", framenum, frame_size, total/(framenum+1));
|
||||
}
|
||||
|
||||
void
|
||||
mp2tomp1_new_pad (GstElement *parser,GstPad *pad, GstElement *pipeline)
|
||||
{
|
||||
GstElement *parse_audio, *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 (strncmp (gst_pad_get_name (pad), "private_stream_1.0", 18) == 0) {
|
||||
GstPad *newpad;
|
||||
|
||||
// construct internal pipeline elements
|
||||
parse_audio = gst_elementfactory_make("ac3parse","parse_audio");
|
||||
g_return_if_fail(parse_audio != NULL);
|
||||
g_object_set(G_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);
|
||||
g_object_set(G_OBJECT(audio_resample),"frequency", 44100, NULL);
|
||||
|
||||
audio_encode = gst_elementfactory_make("mpegaudio","audio_encode");
|
||||
g_return_if_fail(audio_encode != 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(decode));
|
||||
gst_bin_add(GST_BIN(audio_thread),GST_ELEMENT(audio_resample));
|
||||
gst_bin_add(GST_BIN(audio_thread),GST_ELEMENT(audio_encode));
|
||||
|
||||
newpad = gst_element_request_pad_by_name (mux, "audio_[00-08]");
|
||||
g_assert (newpad != NULL);
|
||||
|
||||
// set up pad connections
|
||||
gst_element_add_ghost_pad(GST_ELEMENT(audio_thread),
|
||||
gst_element_get_pad(decode, "sink"), "sink");
|
||||
gst_element_connect (decode, "src", audio_resample, "sink");
|
||||
gst_element_connect (audio_resample, "src", audio_encode, "sink");
|
||||
gst_pad_connect (gst_element_get_pad (audio_encode, "src"), newpad);
|
||||
|
||||
// construct queue and connect everything in the main pipelie
|
||||
audio_queue = gst_elementfactory_make("queue","audio_queue");
|
||||
g_object_set(G_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
|
||||
g_object_set(G_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) {
|
||||
// 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("osssink","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"),"sink");
|
||||
gst_element_connect (parse_audio, "src", decode, "sink");
|
||||
gst_element_connect (decode, "src", play, "sink");
|
||||
|
||||
// construct queue and connect everything in the main pipelie
|
||||
audio_queue = gst_elementfactory_make("queue","audio_queue");
|
||||
g_object_set(G_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
|
||||
g_object_set(G_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) {
|
||||
GstPad *newpad;
|
||||
|
||||
// construct internal pipeline elements
|
||||
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);
|
||||
videoscale = gst_elementfactory_make("videoscale","videoscale");
|
||||
g_return_if_fail(videoscale != NULL);
|
||||
//g_object_set(G_OBJECT(videoscale),"width",352, "height", 288,NULL);
|
||||
g_object_set(G_OBJECT(videoscale),"width",640, "height", 480,NULL);
|
||||
median = gst_elementfactory_make("median","median");
|
||||
g_return_if_fail(median != NULL);
|
||||
g_object_set(G_OBJECT(median),"filtersize",9,NULL);
|
||||
g_object_set(G_OBJECT(median),"active",TRUE,NULL);
|
||||
smooth = gst_elementfactory_make("smooth","smooth");
|
||||
g_return_if_fail(smooth != NULL);
|
||||
g_object_set(G_OBJECT(smooth),"filtersize",5,NULL);
|
||||
g_object_set(G_OBJECT(smooth),"tolerance",9,NULL);
|
||||
g_object_set(G_OBJECT(smooth),"active",FALSE,NULL);
|
||||
encode = gst_elementfactory_make("winenc","encode");
|
||||
g_return_if_fail(encode != NULL);
|
||||
g_signal_connect(G_OBJECT(encode),"frame_encoded",G_CALLBACK(frame_encoded),NULL);
|
||||
g_object_set(G_OBJECT(encode),"bitrate",800*4,NULL);
|
||||
g_object_set(G_OBJECT(encode),"quality",10000,NULL);
|
||||
//g_object_set(G_OBJECT(encode),"compression",NULL,NULL);
|
||||
//encode = gst_elementfactory_make("mpeg1encoder","encode");
|
||||
//g_object_set(G_OBJECT(show),"width",640, "height", 480,NULL);
|
||||
|
||||
newpad = gst_element_request_pad_by_name (mux, "video_[00-08]");
|
||||
g_assert (newpad != 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 (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));
|
||||
|
||||
// set up pad connections
|
||||
gst_element_add_ghost_pad (GST_ELEMENT (video_thread),
|
||||
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"),
|
||||
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"), newpad);
|
||||
|
||||
// construct queue and connect everything in the main pipeline
|
||||
video_queue = gst_elementfactory_make("queue","video_queue");
|
||||
g_object_set(G_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
|
||||
g_object_set(G_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[])
|
||||
{
|
||||
GstElement *pipeline, *src, *parse;
|
||||
GstElement *fdsink;
|
||||
int fd;
|
||||
|
||||
g_print ("have %d args\n", argc);
|
||||
|
||||
gst_init (&argc ,&argv);
|
||||
|
||||
pipeline = gst_pipeline_new ("pipeline");
|
||||
g_return_val_if_fail (pipeline != NULL, -1);
|
||||
|
||||
/* create an input element */
|
||||
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);
|
||||
g_object_set (G_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]);
|
||||
|
||||
/* the parser */
|
||||
parse = gst_elementfactory_make ("mpeg2parse", "parse");
|
||||
g_return_val_if_fail (parse != NULL, -1);
|
||||
|
||||
/* the muxer */
|
||||
mux = gst_elementfactory_make ("avimux", "mux");
|
||||
g_return_val_if_fail (mux != NULL, -1);
|
||||
|
||||
/* create the output sink */
|
||||
fd = open (argv[2], O_CREAT|O_RDWR|O_TRUNC, S_IREAD|S_IWRITE);
|
||||
fdsink = gst_elementfactory_make ("fdsink", "fdsink");
|
||||
g_return_val_if_fail (fdsink != NULL, -1);
|
||||
g_object_set (G_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));
|
||||
|
||||
g_signal_connect (G_OBJECT (parse), "new_pad",
|
||||
G_CALLBACK (mp2tomp1_new_pad), pipeline);
|
||||
|
||||
g_signal_connect (G_OBJECT (src), "eos",
|
||||
G_CALLBACK (eof), NULL);
|
||||
|
||||
gst_element_connect (src, "src", parse, "sink");
|
||||
gst_element_connect (mux, "src", fdsink, "sink");
|
||||
|
||||
g_print("setting to READY state\n");
|
||||
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING);
|
||||
|
||||
while (1) {
|
||||
gst_bin_iterate (GST_BIN (pipeline));
|
||||
}
|
||||
}
|
267
test/mp2tomp1.c
267
test/mp2tomp1.c
|
@ -1,267 +0,0 @@
|
|||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <glib.h>
|
||||
#include <gst/gst.h>
|
||||
|
||||
static GstElement *mux = NULL;
|
||||
//static GstElement *merge_subtitles;
|
||||
static GstElement *fdsink;
|
||||
|
||||
static void
|
||||
eof(GstElement *src)
|
||||
{
|
||||
g_print("have eos, quitting\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
static GstPad*
|
||||
create_muxer (GstElement *pipeline, gchar *type, gchar *number)
|
||||
{
|
||||
if (!mux) {
|
||||
mux = gst_elementfactory_make("system_encode","mux");
|
||||
g_return_val_if_fail(mux != NULL, NULL);
|
||||
|
||||
gst_bin_add(GST_BIN(pipeline),GST_ELEMENT(mux));
|
||||
gst_bin_add(GST_BIN(pipeline),GST_ELEMENT(fdsink));
|
||||
gst_pad_connect(gst_element_get_pad(mux,"src"),
|
||||
gst_element_get_pad(fdsink,"sink"));
|
||||
}
|
||||
g_object_set(G_OBJECT(mux), type, number,NULL);
|
||||
|
||||
return gst_element_get_pad(mux,g_strconcat (type, "_", number, NULL));
|
||||
}
|
||||
|
||||
static void
|
||||
mp2tomp1 (GstElement *parser, GstPad *pad, GstElement *pipeline)
|
||||
{
|
||||
GstElement *decode, *decode_video, *play, *encode, *audio_resample;
|
||||
GstElement *smooth, *median;
|
||||
GstElement *audio_queue, *video_queue;
|
||||
GstElement *audio_thread, *video_thread;
|
||||
GstElement *videoscale, *audio_encode;
|
||||
GstPad *muxerpad;
|
||||
|
||||
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) {
|
||||
// construct internal pipeline elements
|
||||
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);
|
||||
g_object_set(G_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);
|
||||
//g_object_set(G_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(decode));
|
||||
gst_bin_add(GST_BIN(audio_thread),GST_ELEMENT(audio_resample));
|
||||
gst_bin_add(GST_BIN(audio_thread),GST_ELEMENT(audio_encode));
|
||||
|
||||
muxerpad = create_muxer (pipeline, "audio", "00");
|
||||
|
||||
// set up pad connections
|
||||
gst_element_add_ghost_pad(GST_ELEMENT(audio_thread),
|
||||
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"),
|
||||
gst_element_get_pad(audio_encode,"sink"));
|
||||
gst_pad_connect(gst_element_get_pad(audio_encode,"src"),
|
||||
muxerpad);
|
||||
|
||||
// construct queue and connect everything in the main pipelie
|
||||
audio_queue = gst_elementfactory_make("queue","audio_queue");
|
||||
g_object_set(G_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
|
||||
g_object_set(G_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) {
|
||||
// construct internal pipeline elements
|
||||
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);
|
||||
|
||||
// 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(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(decode,"sink"),"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");
|
||||
g_object_set(G_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
|
||||
g_object_set(G_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("mpeg1encoder");
|
||||
// construct internal pipeline elements
|
||||
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);
|
||||
videoscale = gst_elementfactory_make("videoscale","videoscale");
|
||||
g_return_if_fail(videoscale != NULL);
|
||||
g_object_set(G_OBJECT(videoscale),"width",352, "height", 288,NULL);
|
||||
median = gst_elementfactory_make("median","median");
|
||||
g_return_if_fail(median != NULL);
|
||||
g_object_set(G_OBJECT(median),"filtersize",5,NULL);
|
||||
g_object_set(G_OBJECT(median),"active",TRUE,NULL);
|
||||
smooth = gst_elementfactory_make("smooth","smooth");
|
||||
g_return_if_fail(smooth != NULL);
|
||||
g_object_set(G_OBJECT(smooth),"filtersize",5,NULL);
|
||||
g_object_set(G_OBJECT(smooth),"tolerance",9,NULL);
|
||||
g_object_set(G_OBJECT(smooth),"active",FALSE,NULL);
|
||||
encode = gst_elementfactory_make("mpeg2enc","encode");
|
||||
g_return_if_fail(encode != NULL);
|
||||
g_object_set(G_OBJECT(encode),"frames_per_second",25.0,NULL);
|
||||
//g_object_set(G_OBJECT(encode),"frames_per_second",29.97,NULL);
|
||||
//encode = gst_elementfactory_make("mpeg1encoder","encode");
|
||||
//g_object_set(G_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(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));
|
||||
|
||||
// set up pad connections
|
||||
gst_element_add_ghost_pad(GST_ELEMENT(video_thread),
|
||||
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"),
|
||||
// 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"),
|
||||
muxerpad);
|
||||
|
||||
// construct queue and connect everything in the main pipeline
|
||||
video_queue = gst_elementfactory_make("queue","video_queue");
|
||||
g_object_set(G_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
|
||||
g_object_set(G_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[]) {
|
||||
GstElement *pipeline, *src, *parse;
|
||||
GstElementFactory *fdsinkfactory;
|
||||
int fd;
|
||||
|
||||
g_print("have %d args\n",argc);
|
||||
|
||||
gst_init(&argc,&argv);
|
||||
|
||||
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);
|
||||
g_object_set(G_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);
|
||||
|
||||
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_val_if_fail(fdsinkfactory != NULL, -1);
|
||||
fdsink = gst_elementfactory_create(fdsinkfactory,"fdsink");
|
||||
g_return_val_if_fail(fdsink != NULL, -1);
|
||||
g_object_set(G_OBJECT(fdsink),"fd",fd,NULL);
|
||||
|
||||
gst_bin_add(GST_BIN(pipeline),GST_ELEMENT(src));
|
||||
gst_bin_add(GST_BIN(pipeline),GST_ELEMENT(parse));
|
||||
|
||||
|
||||
g_signal_connect(G_OBJECT(parse),"new_pad",
|
||||
G_CALLBACK (mp2tomp1), pipeline);
|
||||
|
||||
g_signal_connect(G_OBJECT(src),"eos",G_CALLBACK(eof),NULL);
|
||||
|
||||
gst_pad_connect(gst_element_get_pad(src,"src"),
|
||||
gst_element_get_pad(parse,"sink"));
|
||||
|
||||
g_print("setting to READY state\n");
|
||||
gst_element_set_state(GST_ELEMENT(pipeline),GST_STATE_PLAYING);
|
||||
|
||||
while (1) {
|
||||
gst_bin_iterate(GST_BIN(pipeline));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,68 +0,0 @@
|
|||
#include <string.h>
|
||||
#include <gst/gst.h>
|
||||
|
||||
static gchar *audio_out;
|
||||
static gchar *video_out;
|
||||
|
||||
static void
|
||||
frame_encoded (GstElement *element, GstElement *pipeline)
|
||||
{
|
||||
fprintf (stderr, ".");
|
||||
}
|
||||
|
||||
static void
|
||||
new_pad (GstElement *element, GstPad *pad, GstElement *pipeline)
|
||||
{
|
||||
gst_element_set_state (pipeline, GST_STATE_PAUSED);
|
||||
|
||||
if (strncmp(gst_pad_get_name(pad), "video_", 6) == 0) {
|
||||
gst_parse_launch (g_strdup_printf ("mpeg2dec[vdec] ! "
|
||||
"ffmpegenc_mpeg1video[venc] width=352 height=288 bit_rate=1220000 ! "
|
||||
"disksink[dv] location=%s", video_out),
|
||||
GST_BIN (pipeline));
|
||||
|
||||
g_signal_connect (gst_bin_get_by_name (GST_BIN (pipeline), "venc"), "frame_encoded",
|
||||
G_CALLBACK (frame_encoded), pipeline);
|
||||
gst_pad_connect (pad, gst_element_get_pad (gst_bin_get_by_name (GST_BIN (pipeline), "vdec"), "sink"));
|
||||
}
|
||||
else if (strcmp(gst_pad_get_name(pad), "private_stream_1.0") == 0) {
|
||||
gst_parse_launch (g_strdup_printf ("ac3dec[adec] ! ffmpegenc_mp2[aenc] ! "
|
||||
"disksink[da] location=%s", audio_out), GST_BIN (pipeline));
|
||||
|
||||
g_signal_connect (gst_bin_get_by_name (GST_BIN (pipeline), "aenc"), "frame_encoded",
|
||||
G_CALLBACK (frame_encoded), pipeline);
|
||||
gst_pad_connect (pad, gst_element_get_pad (gst_bin_get_by_name (GST_BIN (pipeline), "adec"), "sink"));
|
||||
}
|
||||
gst_element_set_state (pipeline, GST_STATE_PLAYING);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
GstElement *pipeline;
|
||||
GstElement *parser;
|
||||
|
||||
gst_init (&argc, &argv);
|
||||
|
||||
if (argc != 4) {
|
||||
g_print ("usage: %s <file.vob> <out.mp2> <out.mpv>\n", argv[0]);
|
||||
return -1;
|
||||
}
|
||||
audio_out = argv[2];
|
||||
video_out = argv[3];
|
||||
|
||||
pipeline = gst_pipeline_new ("main_pipeline");
|
||||
gst_parse_launch (g_strdup_printf("disksrc location=%s ! "
|
||||
"mpeg2parse[parser]", argv[1]), GST_BIN (pipeline));
|
||||
|
||||
parser = gst_bin_get_by_name (GST_BIN (pipeline), "parser");
|
||||
g_assert (parser != NULL);
|
||||
|
||||
g_signal_connect (G_OBJECT (parser), "new_pad", G_CALLBACK (new_pad), pipeline);
|
||||
|
||||
gst_element_set_state (pipeline, GST_STATE_PLAYING);
|
||||
while (gst_bin_iterate (GST_BIN (pipeline)));
|
||||
gst_element_set_state (pipeline, GST_STATE_NULL);
|
||||
|
||||
return 0;
|
||||
}
|
62
test/mp3.c
62
test/mp3.c
|
@ -1,62 +0,0 @@
|
|||
#include <gst/gst.h>
|
||||
|
||||
extern gboolean _gst_plugin_spew;
|
||||
|
||||
static gboolean playing = TRUE;
|
||||
|
||||
void eof(GstElement *src) {
|
||||
GST_DEBUG(0,"have EOF\n");
|
||||
playing = FALSE;
|
||||
}
|
||||
|
||||
int main(int argc,char *argv[]) {
|
||||
GstElement *bin;
|
||||
GstElementFactory *srcfactory;
|
||||
GstElement *src;
|
||||
GstElementFactory *mp3factory;
|
||||
GstElement *mp3;
|
||||
GstElementFactory *sinkfactory;
|
||||
GstElement *sink;
|
||||
|
||||
_gst_plugin_spew = TRUE;
|
||||
|
||||
gst_init(&argc,&argv);
|
||||
gst_plugin_load_all();
|
||||
|
||||
bin = gst_bin_new("bin");
|
||||
|
||||
srcfactory = gst_elementfactory_find("disksrc");
|
||||
if (argc == 3)
|
||||
mp3factory = gst_elementfactory_find(argv[2]);
|
||||
else
|
||||
mp3factory = gst_elementfactory_find("xa");
|
||||
sinkfactory = gst_elementfactory_find("osssink");
|
||||
|
||||
src = gst_elementfactory_create(srcfactory,"src");
|
||||
g_return_val_if_fail(src != NULL, -1);
|
||||
g_object_set(G_OBJECT(src),"location",argv[1]);
|
||||
mp3 = gst_elementfactory_create(mp3factory,"mp3");
|
||||
g_return_val_if_fail(mp3 != NULL, -1);
|
||||
sink = gst_elementfactory_create(sinkfactory,"sink");
|
||||
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));
|
||||
gst_bin_add(GST_BIN(bin),GST_ELEMENT(sink));
|
||||
|
||||
gst_pad_connect(gst_element_get_pad(src,"src"),
|
||||
gst_element_get_pad(mp3,"sink"));
|
||||
gst_pad_connect(gst_element_get_pad(mp3,"src"),
|
||||
gst_element_get_pad(sink,"sink"));
|
||||
|
||||
g_signal_connect(G_OBJECT(src),"eof",
|
||||
G_CALLBACK(eof),NULL);
|
||||
|
||||
gst_element_set_state(GST_ELEMENT(bin),GST_STATE_READY);
|
||||
gst_element_set_state(GST_ELEMENT(bin),GST_STATE_PLAYING);
|
||||
|
||||
while (playing)
|
||||
gst_bin_iterate(GST_BIN(bin));
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,48 +0,0 @@
|
|||
#include <gst/gst.h>
|
||||
|
||||
|
||||
int main(int argc,char *argv[]) {
|
||||
GstElementFactory *srcfactory, *decodefactory, *playfactory;
|
||||
GstElement *pipeline, *src, *decode, *play;
|
||||
|
||||
g_print("have %d args\n",argc);
|
||||
|
||||
gst_init(&argc,&argv);
|
||||
|
||||
pipeline = gst_pipeline_new("pipeline");
|
||||
g_return_val_if_fail(pipeline != NULL, -1);
|
||||
|
||||
srcfactory = gst_elementfactory_find("disksrc");
|
||||
g_return_val_if_fail(srcfactory != NULL, -1);
|
||||
decodefactory = gst_elementfactory_find("mad");
|
||||
g_return_val_if_fail(decodefactory != NULL, -1);
|
||||
playfactory = gst_elementfactory_find("osssink");
|
||||
g_return_val_if_fail(playfactory != NULL, -1);
|
||||
|
||||
src = gst_elementfactory_create(srcfactory,"src");
|
||||
g_return_val_if_fail(src != NULL, -1);
|
||||
g_object_set(G_OBJECT(src),"location",argv[1],NULL);
|
||||
g_print("should be using file '%s'\n",argv[1]);
|
||||
decode = gst_elementfactory_create(decodefactory,"decode");
|
||||
g_return_val_if_fail(decode != NULL, -1);
|
||||
play = gst_elementfactory_create(playfactory,"play");
|
||||
g_return_val_if_fail(play != NULL, -1);
|
||||
|
||||
gst_bin_add(GST_BIN(pipeline),GST_ELEMENT(src));
|
||||
gst_bin_add(GST_BIN(pipeline),GST_ELEMENT(decode));
|
||||
gst_bin_add(GST_BIN(pipeline),GST_ELEMENT(play));
|
||||
|
||||
gst_pad_connect(gst_element_get_pad(src,"src"),
|
||||
gst_element_get_pad(decode,"sink"));
|
||||
gst_pad_connect(gst_element_get_pad(decode,"src"),
|
||||
gst_element_get_pad(play,"sink"));
|
||||
|
||||
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 (gst_bin_iterate(GST_BIN(pipeline)));
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,63 +0,0 @@
|
|||
#include <gst/gst.h>
|
||||
|
||||
extern gboolean _gst_plugin_spew;
|
||||
|
||||
void eof(GstElement *src) {
|
||||
g_print("have eof, quitting\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
void mp3parse_info_chain(GstPad *pad,GstBuffer *buf) {
|
||||
g_print("sink : got buffer of size %d\n",GST_BUFFER_SIZE(buf));
|
||||
gst_buffer_unref(buf);
|
||||
}
|
||||
|
||||
int main(int argc,char *argv[]) {
|
||||
GstPipeline *pipeline;
|
||||
GstElementFactory *srcfactory, *parsefactory;
|
||||
GstElement *src, *parse;
|
||||
GstPad *infopad;
|
||||
|
||||
g_print("have %d args\n",argc);
|
||||
|
||||
_gst_plugin_spew = TRUE;
|
||||
gst_init(&argc,&argv);
|
||||
// gst_plugin_load("mp3parse");
|
||||
gst_plugin_load_all();
|
||||
|
||||
pipeline = GST_PIPELINE(gst_pipeline_new("pipeline"));
|
||||
g_return_val_if_fail(pipeline != NULL, -1);
|
||||
|
||||
srcfactory = gst_elementfactory_find("disksrc");
|
||||
g_return_val_if_fail(srcfactory != NULL, -1);
|
||||
parsefactory = gst_elementfactory_find("mp3parse");
|
||||
g_return_val_if_fail(parsefactory != NULL, -1);
|
||||
|
||||
src = gst_elementfactory_create(srcfactory,"src");
|
||||
g_return_val_if_fail(src != NULL, -1);
|
||||
g_object_set(G_OBJECT(src),"location",argv[1]);
|
||||
g_print("should be using file '%s'\n",argv[1]);
|
||||
parse = gst_elementfactory_create(parsefactory,"parse");
|
||||
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);
|
||||
|
||||
gst_bin_add(GST_BIN(pipeline),GST_ELEMENT(src));
|
||||
gst_bin_add(GST_BIN(pipeline),GST_ELEMENT(parse));
|
||||
|
||||
g_signal_connect(G_OBJECT(src),"eos",
|
||||
G_CALLBACK(eof),NULL);
|
||||
|
||||
gst_pad_connect(gst_element_get_pad(src,"src"),
|
||||
gst_element_get_pad(parse,"sink"));
|
||||
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_READY);
|
||||
|
||||
g_print("about to enter loop\n");
|
||||
while (1)
|
||||
gst_bin_iterate(GST_BIN(pipeline));
|
||||
}
|
|
@ -1,63 +0,0 @@
|
|||
#include <gst/gst.h>
|
||||
|
||||
|
||||
void eof(GstElement *src) {
|
||||
g_print("have eof, quitting\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
int main(int argc,char *argv[]) {
|
||||
GstElementFactory *srcfactory, *parsefactory, *decodefactory, *playfactory;
|
||||
GstElement *pipeline, *src, *parse, *decode, *play;
|
||||
|
||||
g_print("have %d args\n",argc);
|
||||
|
||||
gst_init(&argc,&argv);
|
||||
|
||||
pipeline = gst_pipeline_new("pipeline");
|
||||
g_return_val_if_fail(pipeline != NULL, -1);
|
||||
|
||||
srcfactory = gst_elementfactory_find("disksrc");
|
||||
g_return_val_if_fail(srcfactory != NULL, -1);
|
||||
parsefactory = gst_elementfactory_find("mp3parse");
|
||||
g_return_val_if_fail(parsefactory != NULL, -1);
|
||||
decodefactory = gst_elementfactory_find("mpg123");
|
||||
g_return_val_if_fail(decodefactory != NULL, -1);
|
||||
playfactory = gst_elementfactory_find("osssink");
|
||||
g_return_val_if_fail(playfactory != NULL, -1);
|
||||
|
||||
src = gst_elementfactory_create(srcfactory,"src");
|
||||
g_return_val_if_fail(src != NULL, -1);
|
||||
g_object_set(G_OBJECT(src),"location",argv[1], NULL);
|
||||
g_print("should be using file '%s'\n",argv[1]);
|
||||
parse = gst_elementfactory_create(parsefactory,"parse");
|
||||
g_return_val_if_fail(parse != NULL, -1);
|
||||
decode = gst_elementfactory_create(decodefactory,"decode");
|
||||
g_return_val_if_fail(decode != NULL, -1);
|
||||
play = gst_elementfactory_create(playfactory,"play");
|
||||
g_return_val_if_fail(play != NULL, -1);
|
||||
|
||||
g_signal_connect(G_OBJECT(src),"eos",
|
||||
G_CALLBACK(eof),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(decode));
|
||||
gst_bin_add(GST_BIN(pipeline),GST_ELEMENT(play));
|
||||
|
||||
gst_pad_connect(gst_element_get_pad(src,"src"),
|
||||
gst_element_get_pad(parse,"sink"));
|
||||
gst_pad_connect(gst_element_get_pad(parse,"src"),
|
||||
gst_element_get_pad(decode,"sink"));
|
||||
gst_pad_connect(gst_element_get_pad(decode,"src"),
|
||||
gst_element_get_pad(play,"sink"));
|
||||
|
||||
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_bin_iterate(GST_BIN(pipeline));
|
||||
}
|
||||
}
|
|
@ -1,78 +0,0 @@
|
|||
#include <gst/gst.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
|
||||
void eof(GstElement *src) {
|
||||
g_print("have eof, quitting\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
int main(int argc,char *argv[]) {
|
||||
GstElement *pipeline;
|
||||
GstElementFactory *srcfactory, *parsefactory, *decodefactory, *encodefactory, *sinkfactory;
|
||||
GstElement *src, *parse, *decode, *encode, *sink;
|
||||
int fd;
|
||||
|
||||
g_print("have %d args\n",argc);
|
||||
|
||||
gst_init(&argc,&argv);
|
||||
|
||||
pipeline = gst_pipeline_new("pipeline");
|
||||
g_return_val_if_fail(pipeline != NULL, -1);
|
||||
|
||||
srcfactory = gst_elementfactory_find("disksrc");
|
||||
g_return_val_if_fail(srcfactory != NULL, -1);
|
||||
parsefactory = gst_elementfactory_find("mp3parse");
|
||||
g_return_val_if_fail(parsefactory != NULL, -1);
|
||||
decodefactory = gst_elementfactory_find("mpg123");
|
||||
g_return_val_if_fail(decodefactory != NULL, -1);
|
||||
encodefactory = gst_elementfactory_find("vorbisenc");
|
||||
g_return_val_if_fail(encodefactory != NULL, -1);
|
||||
sinkfactory = gst_elementfactory_find("fdsink");
|
||||
g_return_val_if_fail(sinkfactory != NULL, -1);
|
||||
sink = gst_elementfactory_create(sinkfactory,"sink");
|
||||
|
||||
src = gst_elementfactory_create(srcfactory,"src");
|
||||
g_return_val_if_fail(src != NULL, -1);
|
||||
g_object_set(G_OBJECT(src),"location",argv[1],NULL);
|
||||
g_print("should be using file '%s'\n",argv[1]);
|
||||
parse = gst_elementfactory_create(parsefactory,"parse");
|
||||
g_return_val_if_fail(parse != NULL, -1);
|
||||
decode = gst_elementfactory_create(decodefactory,"decode");
|
||||
g_return_val_if_fail(decode != NULL, -1);
|
||||
encode = gst_elementfactory_create(encodefactory,"encode");
|
||||
g_return_val_if_fail(encode != NULL, -1);
|
||||
sink = gst_elementfactory_create(sinkfactory,"sink");
|
||||
g_return_val_if_fail(sink != NULL, -1);
|
||||
g_print("should be using output file '%s'\n",argv[2]);
|
||||
fd = open(argv[2], O_CREAT|O_RDWR|O_TRUNC);
|
||||
g_object_set(G_OBJECT(sink),"fd",fd,NULL);
|
||||
|
||||
g_signal_connect(G_OBJECT(src),"eos",
|
||||
G_CALLBACK(eof),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(decode));
|
||||
gst_bin_add(GST_BIN(pipeline),GST_ELEMENT(encode));
|
||||
gst_bin_add(GST_BIN(pipeline),GST_ELEMENT(sink));
|
||||
|
||||
gst_pad_connect(gst_element_get_pad(src,"src"),
|
||||
gst_element_get_pad(parse,"sink"));
|
||||
gst_pad_connect(gst_element_get_pad(parse,"src"),
|
||||
gst_element_get_pad(decode,"sink"));
|
||||
gst_pad_connect(gst_element_get_pad(decode,"src"),
|
||||
gst_element_get_pad(encode,"sink"));
|
||||
gst_pad_connect(gst_element_get_pad(encode,"src"),
|
||||
gst_element_get_pad(sink,"sink"));
|
||||
|
||||
g_print("setting to READY state\n");
|
||||
gst_element_set_state(GST_ELEMENT(pipeline),GST_STATE_PLAYING);
|
||||
|
||||
g_print("about to enter loop\n");
|
||||
while (1) {
|
||||
gst_bin_iterate(GST_BIN(pipeline));
|
||||
}
|
||||
}
|
|
@ -1,137 +0,0 @@
|
|||
#include <gnome.h>
|
||||
#include <gst/gst.h>
|
||||
|
||||
GstElement *parse2, *queue;
|
||||
GtkWidget *appwindow;
|
||||
|
||||
void eof(GstElement *src) {
|
||||
g_print("have eos, quitting\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
gboolean idle_func(gpointer data) {
|
||||
gst_bin_iterate(GST_BIN(data));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void mpegdemux_newpad(GstElement *parser,GstPad *pad, GstElement *pipeline) {
|
||||
|
||||
g_print("***** a new pad %s was created %p\n", gst_pad_get_name(pad), pipeline);
|
||||
gst_element_set_state(GST_ELEMENT(pipeline),GST_STATE_PAUSED);
|
||||
|
||||
if (strncmp(gst_pad_get_name(pad), "video_", 6) == 0) {
|
||||
|
||||
gst_pad_connect(pad, gst_element_get_pad(queue,"sink"));
|
||||
}
|
||||
gst_element_set_state(GST_ELEMENT(pipeline),GST_STATE_PLAYING);
|
||||
}
|
||||
|
||||
int main(int argc,char *argv[]) {
|
||||
GstPipeline *pipeline;
|
||||
GstElement *src, *parse;
|
||||
GstElement *decode, *show, *thread, *color;
|
||||
GtkWidget *gtk_socket;
|
||||
|
||||
g_print("have %d args\n",argc);
|
||||
|
||||
gst_init(&argc,&argv);
|
||||
gnome_init("MPEG2 Video player","0.0.1",argc,argv);
|
||||
//gst_plugin_load("mpeg1parse");
|
||||
|
||||
pipeline = GST_PIPELINE(gst_pipeline_new("pipeline"));
|
||||
g_return_val_if_fail(pipeline != NULL, -1);
|
||||
thread = GST_ELEMENT(gst_thread_new("thread"));
|
||||
g_return_val_if_fail(thread != 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);
|
||||
if (argc >= 3) {
|
||||
gtk_object_set(GTK_OBJECT(src),"bytesperread",atoi(argv[2]),NULL);
|
||||
g_print("block size is %d\n",atoi(argv[2]));
|
||||
}
|
||||
g_print("should be using file '%s'\n",argv[1]);
|
||||
|
||||
parse = gst_elementfactory_make("mpegdemux","parse");
|
||||
//parse = gst_elementfactory_make("mpeg1parse","parse");
|
||||
g_return_val_if_fail(parse != NULL, -1);
|
||||
|
||||
queue = gst_elementfactory_make("queue","queue");
|
||||
g_return_val_if_fail(queue != NULL, -1);
|
||||
|
||||
/****
|
||||
* you can substitute mpeg2play with you own player here
|
||||
* optionally you can remove the parse2 element. make
|
||||
* sure to remove the pad connections too and don't add the
|
||||
* mp2videoparse element to the bin.
|
||||
**/
|
||||
//parse2 = gst_elementfactory_make("mp2videoparse","parse");
|
||||
//g_return_val_if_fail(parse2 != NULL, -1);
|
||||
decode = gst_elementfactory_make("mpeg2dec","decode_video");
|
||||
g_return_val_if_fail(decode != NULL, -1);
|
||||
|
||||
color = gst_elementfactory_make("colorspace","color");
|
||||
g_return_val_if_fail(color != NULL, -1);
|
||||
|
||||
show = gst_elementfactory_make("xvideosink","show");
|
||||
//gtk_object_set(GTK_OBJECT(show),"xv_enabled",FALSE,NULL);
|
||||
g_return_val_if_fail(show != NULL, -1);
|
||||
|
||||
appwindow = gnome_app_new("MPEG player","MPEG player");
|
||||
|
||||
gtk_socket = gtk_socket_new ();
|
||||
gtk_widget_show (gtk_socket);
|
||||
gtk_widget_set_usize(gtk_socket,320,240);
|
||||
|
||||
gnome_app_set_contents(GNOME_APP(appwindow),
|
||||
GTK_WIDGET(gtk_socket));
|
||||
|
||||
gtk_widget_realize (gtk_socket);
|
||||
gtk_socket_steal (GTK_SOCKET (gtk_socket),
|
||||
gst_util_get_int_arg (GTK_OBJECT(show), "xid"));
|
||||
|
||||
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(queue));
|
||||
|
||||
//gst_bin_add(GST_BIN(thread),GST_ELEMENT(parse2));
|
||||
gst_bin_add(GST_BIN(thread),GST_ELEMENT(decode));
|
||||
gst_bin_add(GST_BIN(thread),GST_ELEMENT(color));
|
||||
gst_bin_add(GST_BIN(thread),GST_ELEMENT(show));
|
||||
|
||||
gst_bin_add(GST_BIN(pipeline),GST_ELEMENT(thread));
|
||||
|
||||
gtk_signal_connect(GTK_OBJECT(parse),"new_pad",mpegdemux_newpad, 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(queue,"src"),
|
||||
// gst_element_get_pad(parse2,"sink"));
|
||||
//gst_pad_connect(gst_element_get_pad(parse2,"src"),
|
||||
gst_element_get_pad(decode,"sink"));
|
||||
gst_pad_connect(gst_element_get_pad(decode,"src"),
|
||||
gst_element_get_pad(color,"sink"));
|
||||
gst_pad_connect(gst_element_get_pad(color,"src"),
|
||||
gst_element_get_pad(show,"sink"));
|
||||
|
||||
gtk_widget_show_all(appwindow);
|
||||
|
||||
g_print("setting to PLAYING state\n");
|
||||
gst_element_set_state(GST_ELEMENT(pipeline),GST_STATE_PLAYING);
|
||||
|
||||
gtk_idle_add(idle_func,pipeline);
|
||||
|
||||
gdk_threads_enter();
|
||||
gtk_main();
|
||||
gdk_threads_leave();
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,151 +0,0 @@
|
|||
#include <gnome.h>
|
||||
#include <gst/gst.h>
|
||||
|
||||
GstPipeline *pipeline;
|
||||
GstElement *v_queue, *a_queue, *v_thread, *a_thread;
|
||||
GtkWidget *appwindow;
|
||||
GtkWidget *gtk_socket;
|
||||
|
||||
void eof(GstElement *src) {
|
||||
g_print("have eos, quitting\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
gboolean idle_func(gpointer data) {
|
||||
return gst_bin_iterate(GST_BIN(data));
|
||||
}
|
||||
|
||||
void mpegdemux_newpad(GstElement *parser,GstPad *pad, GstElement *pipeline) {
|
||||
|
||||
g_print("***** a new pad %s was created\n", gst_pad_get_name(pad));
|
||||
|
||||
if (strncmp(gst_pad_get_name(pad), "video_", 6) == 0) {
|
||||
gst_pad_connect(pad, gst_element_get_pad(v_queue,"sink"));
|
||||
gst_bin_add(GST_BIN(pipeline),v_thread);
|
||||
gst_element_set_state(v_thread,GST_STATE_PLAYING);
|
||||
} else if (strcmp(gst_pad_get_name(pad), "private_stream_1.0") == 0) {
|
||||
gst_pad_connect(pad, gst_element_get_pad(a_queue,"sink"));
|
||||
gst_bin_add(GST_BIN(pipeline),a_thread);
|
||||
gst_element_set_state(a_thread,GST_STATE_PLAYING);
|
||||
}
|
||||
}
|
||||
|
||||
void mpegdemux_have_size(GstElement *videosink,gint width,gint height) {
|
||||
gtk_widget_set_usize(gtk_socket,width,height);
|
||||
gtk_widget_show_all(appwindow);
|
||||
}
|
||||
|
||||
int main(int argc,char *argv[]) {
|
||||
GstElement *src, *parse;
|
||||
GstElement *v_decode, *show, *color;
|
||||
GstElement *a_decode, *osssink;
|
||||
|
||||
g_print("have %d args\n",argc);
|
||||
|
||||
gst_init(&argc,&argv);
|
||||
gnome_init("MPEG2 Video player","0.0.1",argc,argv);
|
||||
|
||||
// ***** construct the main pipeline *****
|
||||
pipeline = GST_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("filesrc","src");
|
||||
}
|
||||
|
||||
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);
|
||||
g_print("block size is %d\n",atoi(argv[2]));
|
||||
}
|
||||
g_print("should be using file '%s'\n",argv[1]);
|
||||
|
||||
parse = gst_elementfactory_make("mpegdemux","parse");
|
||||
//parse = gst_elementfactory_make("mpeg1parse","parse");
|
||||
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));
|
||||
|
||||
gst_element_connect(src,"src",parse,"sink");
|
||||
|
||||
|
||||
// ***** pre-construct the video thread *****
|
||||
v_thread = GST_ELEMENT(gst_thread_new("v_thread"));
|
||||
g_return_val_if_fail(v_thread != NULL, -1);
|
||||
|
||||
v_queue = gst_elementfactory_make("queue","v_queue");
|
||||
g_return_val_if_fail(v_queue != NULL, -1);
|
||||
|
||||
v_decode = gst_elementfactory_make("mpeg2dec","decode_video");
|
||||
g_return_val_if_fail(v_decode != NULL, -1);
|
||||
|
||||
color = gst_elementfactory_make("colorspace","color");
|
||||
g_return_val_if_fail(color != NULL, -1);
|
||||
|
||||
show = gst_elementfactory_make("xvideosink","show");
|
||||
g_return_val_if_fail(show != NULL, -1);
|
||||
|
||||
gst_bin_add(GST_BIN(v_thread),GST_ELEMENT(v_queue));
|
||||
gst_bin_add(GST_BIN(v_thread),GST_ELEMENT(v_decode));
|
||||
gst_bin_add(GST_BIN(v_thread),GST_ELEMENT(color));
|
||||
gst_bin_add(GST_BIN(v_thread),GST_ELEMENT(show));
|
||||
|
||||
gst_element_connect(v_queue,"src",v_decode,"sink");
|
||||
gst_element_connect(v_decode,"src",color,"sink");
|
||||
gst_element_connect(color,"src",show,"sink");
|
||||
|
||||
|
||||
// ***** pre-construct the audio thread *****
|
||||
a_thread = GST_ELEMENT(gst_thread_new("a_thread"));
|
||||
g_return_val_if_fail(a_thread != NULL, -1);
|
||||
|
||||
a_queue = gst_elementfactory_make("queue","a_queue");
|
||||
g_return_val_if_fail(a_queue != NULL, -1);
|
||||
|
||||
a_decode = gst_elementfactory_make("a52dec","decode_audio");
|
||||
g_return_val_if_fail(a_decode != NULL, -1);
|
||||
|
||||
osssink = gst_elementfactory_make("osssink","osssink");
|
||||
g_return_val_if_fail(osssink != NULL, -1);
|
||||
|
||||
gst_bin_add(GST_BIN(a_thread),GST_ELEMENT(a_queue));
|
||||
gst_bin_add(GST_BIN(a_thread),GST_ELEMENT(a_decode));
|
||||
gst_bin_add(GST_BIN(a_thread),GST_ELEMENT(osssink));
|
||||
|
||||
gst_element_connect(a_queue,"src",a_decode,"sink");
|
||||
gst_element_connect(a_decode,"src",osssink,"sink");
|
||||
|
||||
|
||||
// ***** construct the GUI *****
|
||||
appwindow = gnome_app_new("MPEG player","MPEG player");
|
||||
|
||||
gtk_socket = gtk_socket_new ();
|
||||
gtk_widget_show (gtk_socket);
|
||||
|
||||
gnome_app_set_contents(GNOME_APP(appwindow),
|
||||
GTK_WIDGET(gtk_socket));
|
||||
|
||||
gtk_widget_realize (gtk_socket);
|
||||
gtk_socket_steal (GTK_SOCKET (gtk_socket),
|
||||
gst_util_get_int_arg (GTK_OBJECT(show), "xid"));
|
||||
|
||||
gtk_signal_connect(GTK_OBJECT(parse),"new_pad",mpegdemux_newpad, pipeline);
|
||||
gtk_signal_connect(GTK_OBJECT(src),"eos",GTK_SIGNAL_FUNC(eof),NULL);
|
||||
gtk_signal_connect(GTK_OBJECT(show),"have_size",mpegdemux_have_size, pipeline);
|
||||
|
||||
g_print("setting to PLAYING state\n");
|
||||
gst_element_set_state(GST_ELEMENT(pipeline),GST_STATE_PLAYING);
|
||||
|
||||
gtk_idle_add(idle_func,pipeline);
|
||||
|
||||
gdk_threads_enter();
|
||||
gtk_main();
|
||||
gdk_threads_leave();
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,224 +0,0 @@
|
|||
#include <gnome.h>
|
||||
#include <gst/gst.h>
|
||||
|
||||
GstElement *pipeline, *src, *parse;
|
||||
GstElement *v_decode_thread, *v_decode_queue, *v_decode, *v_color;
|
||||
GstElement *v_show_thread, *v_show_queue, *v_show;
|
||||
GstElement *a_decode_thread, *a_decode_queue, *a_decode;
|
||||
GstElement *a_sink_thread, *a_sink_queue, *a_sink;
|
||||
GtkWidget *appwindow;
|
||||
GtkWidget *gtk_socket;
|
||||
|
||||
void eof(GstElement *src) {
|
||||
fprintf(stderr,"have eos, quitting\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
gboolean idle_func(gpointer data) {
|
||||
gst_bin_iterate(GST_BIN(data));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int mpeg2parse_newpad(GstElement *parser,GstPad *pad, GstElement *pipeline) {
|
||||
|
||||
fprintf(stderr,"***** a new pad %s was created\n", gst_pad_get_name(pad));
|
||||
|
||||
if (strncmp(gst_pad_get_name(pad), "video_", 6) == 0) {
|
||||
|
||||
// build the decoder thread
|
||||
v_decode_thread = GST_ELEMENT(gst_thread_new("v_decode_thread"));
|
||||
g_return_val_if_fail(v_decode_thread != NULL, -1);
|
||||
|
||||
v_decode_queue = gst_elementfactory_make("queue","v_decode_queue");
|
||||
g_return_val_if_fail(v_decode_queue != NULL, -1);
|
||||
|
||||
v_decode = gst_elementfactory_make("mpeg2dec","v_decode");
|
||||
g_return_val_if_fail(v_decode != NULL, -1);
|
||||
|
||||
v_color = gst_elementfactory_make("colorspace","v_color");
|
||||
g_return_val_if_fail(v_color != NULL, -1);
|
||||
|
||||
gst_bin_add(GST_BIN(v_decode_thread),GST_ELEMENT(v_decode_queue));
|
||||
gst_bin_add(GST_BIN(v_decode_thread),GST_ELEMENT(v_decode));
|
||||
gst_bin_add(GST_BIN(v_decode_thread),GST_ELEMENT(v_color));
|
||||
|
||||
gst_element_connect(v_decode_queue,"src",v_decode,"sink");
|
||||
gst_element_connect(v_decode,"src",v_color,"sink");
|
||||
|
||||
gst_scheduler_show(GST_ELEMENT_SCHED(v_decode_thread));
|
||||
|
||||
|
||||
// build the show thread
|
||||
v_show_thread = GST_ELEMENT(gst_thread_new("v_show_thread"));
|
||||
g_return_val_if_fail(v_show_thread != NULL, -1);
|
||||
|
||||
v_show_queue = gst_elementfactory_make("queue","v_show_queue");
|
||||
g_return_val_if_fail(v_show_queue != NULL, -1);
|
||||
|
||||
// v_show has ben created earlier
|
||||
|
||||
gst_bin_add(GST_BIN(v_show_thread),GST_ELEMENT(v_show_queue));
|
||||
gst_bin_add(GST_BIN(v_show_thread),GST_ELEMENT(v_show));
|
||||
|
||||
gst_element_connect(v_show_queue,"src",v_show,"sink");
|
||||
|
||||
|
||||
// now assemble the decoder threads
|
||||
gst_bin_add(GST_BIN(v_decode_thread),v_show_thread);
|
||||
gst_element_connect(v_color,"src",v_show_queue,"sink");
|
||||
|
||||
gst_scheduler_show(GST_ELEMENT_SCHED(v_decode_thread));
|
||||
gst_scheduler_show(GST_ELEMENT_SCHED(v_show_thread));
|
||||
|
||||
// connect the whole thing to the main pipeline
|
||||
gst_pad_connect(pad, gst_element_get_pad(v_decode_queue,"sink"));
|
||||
gst_bin_add(GST_BIN(pipeline),v_decode_thread);
|
||||
|
||||
gst_scheduler_show(GST_ELEMENT_SCHED(v_decode_thread));
|
||||
gst_scheduler_show(GST_ELEMENT_SCHED(v_show_thread));
|
||||
|
||||
// start it playing
|
||||
gst_element_set_state(v_decode_thread,GST_STATE_PLAYING);
|
||||
|
||||
} else if (strcmp(gst_pad_get_name(pad), "private_stream_1.0") == 0) {
|
||||
// build the decoder thread
|
||||
a_decode_thread = GST_ELEMENT(gst_thread_new("a_decode_thread"));
|
||||
g_return_val_if_fail(a_decode_thread != NULL, -1);
|
||||
|
||||
a_decode_queue = gst_elementfactory_make("queue","a_decode_queue");
|
||||
g_return_val_if_fail(a_decode_queue != NULL, -1);
|
||||
|
||||
a_decode = gst_elementfactory_make("a52dec","a_decode");
|
||||
g_return_val_if_fail(a_decode != NULL, -1);
|
||||
|
||||
gst_bin_add(GST_BIN(a_decode_thread),GST_ELEMENT(a_decode_queue));
|
||||
gst_bin_add(GST_BIN(a_decode_thread),GST_ELEMENT(a_decode));
|
||||
|
||||
gst_element_connect(a_decode_queue,"src",a_decode,"sink");
|
||||
|
||||
gst_scheduler_show(GST_ELEMENT_SCHED(a_decode_thread));
|
||||
|
||||
|
||||
// build the sink thread
|
||||
a_sink_thread = GST_ELEMENT(gst_thread_new("a_sink_thread"));
|
||||
g_return_val_if_fail(a_sink_thread != NULL, -1);
|
||||
|
||||
a_sink_queue = gst_elementfactory_make("queue","a_sink_queue");
|
||||
g_return_val_if_fail(a_sink_queue != NULL, -1);
|
||||
|
||||
a_sink = gst_elementfactory_make("esdsink","a_sink");
|
||||
g_return_val_if_fail(a_sink != NULL, -1);
|
||||
|
||||
gst_bin_add(GST_BIN(a_sink_thread),GST_ELEMENT(a_sink_queue));
|
||||
gst_bin_add(GST_BIN(a_sink_thread),GST_ELEMENT(a_sink));
|
||||
|
||||
gst_element_connect(a_sink_queue,"src",a_sink,"sink");
|
||||
|
||||
|
||||
// now assemble the decoder threads
|
||||
gst_bin_add(GST_BIN(a_decode_thread),a_sink_thread);
|
||||
gst_element_connect(a_decode,"src",a_sink_queue,"sink");
|
||||
|
||||
gst_scheduler_show(GST_ELEMENT_SCHED(a_decode_thread));
|
||||
gst_scheduler_show(GST_ELEMENT_SCHED(a_sink_thread));
|
||||
|
||||
// connect the whole thing to the main pipeline
|
||||
gst_pad_connect(pad, gst_element_get_pad(a_decode_queue,"sink"));
|
||||
gst_bin_add(GST_BIN(pipeline),a_decode_thread);
|
||||
|
||||
gst_scheduler_show(GST_ELEMENT_SCHED(a_decode_thread));
|
||||
gst_scheduler_show(GST_ELEMENT_SCHED(a_sink_thread));
|
||||
|
||||
// start it playing
|
||||
gst_element_set_state(a_decode_thread,GST_STATE_PLAYING);
|
||||
|
||||
}
|
||||
|
||||
if (v_decode_thread && a_decode_thread) {
|
||||
xmlSaveFile("mpeg2parse4.gst", gst_xml_write(GST_ELEMENT(pipeline)));
|
||||
fprintf(stderr,"DUMP OF ALL SCHEDULES!!!:\n");
|
||||
gst_scheduler_show(GST_ELEMENT_SCHED(pipeline));
|
||||
gst_scheduler_show(GST_ELEMENT_SCHED(v_decode_thread));
|
||||
gst_scheduler_show(GST_ELEMENT_SCHED(v_show_thread));
|
||||
gst_scheduler_show(GST_ELEMENT_SCHED(a_decode_thread));
|
||||
gst_scheduler_show(GST_ELEMENT_SCHED(a_sink_thread));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void mpeg2parse_have_size(GstElement *videosink,gint width,gint height) {
|
||||
gtk_widget_set_usize(gtk_socket,width,height);
|
||||
gtk_widget_show_all(appwindow);
|
||||
}
|
||||
|
||||
int main(int argc,char *argv[]) {
|
||||
|
||||
g_print("have %d args\n",argc);
|
||||
|
||||
gst_init(&argc,&argv);
|
||||
gnome_init("MPEG2 Video player","0.0.1",argc,argv);
|
||||
|
||||
// ***** construct the main pipeline *****
|
||||
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);
|
||||
if (argc >= 3) {
|
||||
gtk_object_set(GTK_OBJECT(src),"bytesperread",atoi(argv[2]),NULL);
|
||||
g_print("block size is %d\n",atoi(argv[2]));
|
||||
}
|
||||
g_print("should be using file '%s'\n",argv[1]);
|
||||
|
||||
parse = gst_elementfactory_make("mpeg2parse","parse");
|
||||
//parse = gst_elementfactory_make("mpeg1parse","parse");
|
||||
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));
|
||||
|
||||
gst_element_connect(src,"src",parse,"sink");
|
||||
|
||||
|
||||
// create v_show early so we can get and connect stuff
|
||||
v_show = gst_elementfactory_make("xvideosink","v_show");
|
||||
g_return_val_if_fail(v_show != NULL, -1);
|
||||
|
||||
|
||||
|
||||
// ***** construct the GUI *****
|
||||
appwindow = gnome_app_new("MPEG player","MPEG player");
|
||||
|
||||
gtk_socket = gtk_socket_new ();
|
||||
gtk_widget_show (gtk_socket);
|
||||
|
||||
gnome_app_set_contents(GNOME_APP(appwindow),
|
||||
GTK_WIDGET(gtk_socket));
|
||||
|
||||
gtk_widget_realize (gtk_socket);
|
||||
gtk_socket_steal (GTK_SOCKET (gtk_socket),
|
||||
gst_util_get_int_arg (GTK_OBJECT(v_show), "xid"));
|
||||
|
||||
gtk_signal_connect(GTK_OBJECT(parse),"new_pad",mpeg2parse_newpad, pipeline);
|
||||
gtk_signal_connect(GTK_OBJECT(src),"eos",GTK_SIGNAL_FUNC(eof),NULL);
|
||||
gtk_signal_connect(GTK_OBJECT(v_show),"have_size",mpeg2parse_have_size, pipeline);
|
||||
|
||||
fprintf(stderr,"setting to PLAYING state\n");
|
||||
gst_element_set_state(GST_ELEMENT(pipeline),GST_STATE_PLAYING);
|
||||
|
||||
gtk_idle_add(idle_func,pipeline);
|
||||
|
||||
gdk_threads_enter();
|
||||
gtk_main();
|
||||
gdk_threads_leave();
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,67 +0,0 @@
|
|||
#include <gst/gst.h>
|
||||
|
||||
void eof(GstSrc *src) {
|
||||
g_print("have eof, quitting\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
int main(int argc,char *argv[]) {
|
||||
GList *factories;
|
||||
GstElementFactory *parsefactory;
|
||||
GstElement *bin, *disksrc, *parse, *osssink;
|
||||
GList *padlist;
|
||||
guchar *filename;
|
||||
int i;
|
||||
|
||||
if (argc == 2)
|
||||
filename = argv[1];
|
||||
else
|
||||
filename = "ctp2.mp3";
|
||||
|
||||
gst_init(&argc,&argv);
|
||||
gst_plugin_load_all();
|
||||
g_print("\n");
|
||||
|
||||
bin = gst_bin_new("bin");
|
||||
|
||||
disksrc = gst_disksrc_new("disksrc");
|
||||
g_print("created disksrc\n");
|
||||
gtk_object_set(GTK_OBJECT(disksrc),"location",filename,NULL);
|
||||
gtk_object_set(GTK_OBJECT(disksrc),"bytesperread",1048576,NULL);
|
||||
|
||||
/* now it's time to get the parser */
|
||||
parsefactory = gst_plugin_find_elementfactory("xing");
|
||||
parse = gst_elementfactory_create(parsefactory,"parser");
|
||||
if (parse == NULL) {
|
||||
g_print("sorry, couldn't create parser\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
osssink = gst_osssink_new("osssink");
|
||||
|
||||
gtk_signal_connect(GTK_OBJECT(disksrc),"eof",
|
||||
GTK_SIGNAL_FUNC(eof),NULL);
|
||||
|
||||
/* add objects to the main pipeline */
|
||||
gst_bin_add(GST_BIN(bin),GST_OBJECT(disksrc));
|
||||
gst_bin_add(GST_BIN(bin),GST_OBJECT(parse));
|
||||
gst_bin_add(GST_BIN(bin),GST_OBJECT(osssink));
|
||||
|
||||
/* connect src to sink */
|
||||
gst_pad_connect(gst_element_get_pad(disksrc,"src"),
|
||||
gst_element_get_pad(parse,"sink"));
|
||||
gst_pad_connect(gst_element_get_pad(parse,"src"),
|
||||
gst_element_get_pad(osssink,"sink"));
|
||||
|
||||
for (i=0;i<4;i++) {
|
||||
g_print("\n");
|
||||
gst_disksrc_push(GST_SRC(disksrc));
|
||||
}
|
||||
|
||||
gst_object_destroy(GST_OBJECT(osssink));
|
||||
gst_object_destroy(GST_OBJECT(parse));
|
||||
gst_object_destroy(GST_OBJECT(disksrc));
|
||||
gst_object_destroy(GST_OBJECT(bin));
|
||||
}
|
||||
|
55
test/p.c
55
test/p.c
|
@ -1,55 +0,0 @@
|
|||
#include <glib.h>
|
||||
#include <gst/gst.h>
|
||||
|
||||
void eof(GstSrc *src) {
|
||||
g_print("have eof, quitting\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
int main(int argc,char *argv[]) {
|
||||
GstElement *bin, *disksrc, *p, *osssink;
|
||||
GList *padlist;
|
||||
|
||||
gst_init(&argc,&argv);
|
||||
|
||||
bin = gst_bin_new("bin");
|
||||
|
||||
disksrc = gst_disksrc_new("disksrc");
|
||||
g_print("created disksrc\n");
|
||||
if (argc == 2)
|
||||
gst_disksrc_set_filename(disksrc,argv[1]);
|
||||
else
|
||||
gst_disksrc_set_filename(disksrc,"mendelssohn.1.raw");
|
||||
gst_disksrc_set_bytesperread(disksrc,32768);
|
||||
g_print("loaded file '%s'\n",gst_disksrc_get_filename(disksrc));
|
||||
|
||||
p = gst_plugin_find_elementfactory("pipe");
|
||||
osssink = gst_osssink_new("osssink");
|
||||
|
||||
gtk_signal_connect(GTK_OBJECT(disksrc),"eof",
|
||||
GTK_SIGNAL_FUNC(eof),NULL);
|
||||
|
||||
/* add objects to the main pipeline */
|
||||
gst_bin_add(GST_BIN(bin),GST_OBJECT(disksrc));
|
||||
gst_bin_add(GST_BIN(bin),GST_OBJECT(p));
|
||||
gst_bin_add(GST_BIN(bin),GST_OBJECT(osssink));
|
||||
|
||||
/* connect src to sink */
|
||||
gst_pad_connect(gst_element_get_pad(disksrc,"src"),
|
||||
gst_element_get_pad(p,"sink"));
|
||||
gst_pad_connect(gst_element_get_pad(p,"src"),
|
||||
gst_element_get_pad(osssink,"sink"));
|
||||
|
||||
/* set soundcard properties */
|
||||
gst_osssink_set_format(GST_AUDIOSINK(osssink),AFMT_S16_BE);
|
||||
gst_osssink_set_channels(GST_AUDIOSINK(osssink),2);
|
||||
gst_osssink_set_frequency(GST_AUDIOSINK(osssink),44100);
|
||||
|
||||
while(1)
|
||||
gst_disksrc_push(GST_SRC(disksrc));
|
||||
|
||||
gst_object_destroy(GST_OBJECT(osssink));
|
||||
gst_object_destroy(GST_OBJECT(disksrc));
|
||||
gst_object_destroy(GST_OBJECT(bin));
|
||||
}
|
||||
|
|
@ -1,63 +0,0 @@
|
|||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include <gst/gst.h>
|
||||
|
||||
|
||||
void eof(GstElement *src) {
|
||||
g_print("have eof, quitting\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
int main(int argc,char *argv[]) {
|
||||
GstElementFactory *srcfactory, *pipefactory, *sinkfactory;
|
||||
GstElement *pipeline, *src, *pipe, *sink;
|
||||
int fd;
|
||||
|
||||
g_print("have %d args\n",argc);
|
||||
|
||||
gst_init(&argc,&argv);
|
||||
|
||||
pipeline = gst_pipeline_new("pipeline");
|
||||
g_return_val_if_fail(pipeline != NULL, -1);
|
||||
|
||||
srcfactory = gst_elementfactory_find("disksrc");
|
||||
g_return_val_if_fail(srcfactory != NULL, -1);
|
||||
pipefactory = gst_elementfactory_find("pipefilter");
|
||||
g_return_val_if_fail(pipefactory != NULL, -1);
|
||||
sinkfactory = gst_elementfactory_find("fdsink");
|
||||
g_return_val_if_fail(sinkfactory != NULL, -1);
|
||||
|
||||
src = gst_elementfactory_create(srcfactory,"src");
|
||||
g_return_val_if_fail(src != NULL, -1);
|
||||
g_object_set(G_OBJECT(src),"location",argv[1],NULL);
|
||||
g_print("should be using file '%s'\n",argv[1]);
|
||||
pipe = gst_elementfactory_create(pipefactory,"pipe");
|
||||
g_return_val_if_fail(pipe != NULL, -1);
|
||||
sink = gst_elementfactory_create(sinkfactory,"fdsink");
|
||||
g_return_val_if_fail(sink != NULL, -1);
|
||||
|
||||
fd = open(argv[2],O_CREAT|O_RDWR|O_TRUNC);
|
||||
g_object_set(G_OBJECT(sink),"fd",fd,NULL);
|
||||
|
||||
g_signal_connect(G_OBJECT(src),"eos",
|
||||
G_CALLBACK(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"));
|
||||
|
||||
g_print("setting to READY state\n");
|
||||
gst_element_set_state(GST_ELEMENT(pipeline),GST_STATE_PLAYING);
|
||||
|
||||
g_print("about to enter loop\n");
|
||||
while (1) {
|
||||
gst_bin_iterate(GST_BIN(pipeline));
|
||||
}
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
#include <gst/gst.h>
|
||||
|
||||
int main(int argc,char *argv[]) {
|
||||
GstElementFactory *parseau_factory;
|
||||
GstElement *parseau;
|
||||
|
||||
gst_init(&argc,&argv);
|
||||
|
||||
gst_plugin_load_all();
|
||||
|
||||
parseau_factory = gst_plugin_find_elementfactory("parseau");
|
||||
g_print("parseau_factory is %p\n",parseau_factory);
|
||||
|
||||
parseau = gst_elementfactory_create(parseau_factory,"parser");
|
||||
g_print("got parseau '%s' from plugin!!!\n",
|
||||
gst_object_get_name(GST_OBJECT(parseau)));
|
||||
}
|
78
test/push.c
78
test/push.c
|
@ -1,78 +0,0 @@
|
|||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/tcp.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <gst/gst.h>
|
||||
|
||||
int eofflag = 0;
|
||||
|
||||
void eof(GstSrc *src) {
|
||||
eofflag = 1;
|
||||
}
|
||||
|
||||
int main(int argc,char *argv[]) {
|
||||
struct sockaddr_in src_addr, dst_addr;
|
||||
int sockaddrlen;
|
||||
int lsock;
|
||||
int one = 1;
|
||||
int sndbuf = 4096;
|
||||
int sock;
|
||||
GstElement *src,*sink;
|
||||
|
||||
gst_init(&argc,&argv);
|
||||
|
||||
lsock = socket(AF_INET,SOCK_STREAM,0);
|
||||
if (lsock < 0) {
|
||||
perror("creating socket");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (setsockopt(lsock,SOL_SOCKET,SO_REUSEADDR,&one,sizeof(one))) {
|
||||
perror("setsockopt(SO_REUSEADDR)");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
src_addr.sin_family = AF_INET;
|
||||
src_addr.sin_addr.s_addr = INADDR_ANY;
|
||||
src_addr.sin_port = htons(8001);
|
||||
|
||||
if (bind(lsock,(struct sockaddr *)&src_addr,sizeof(src_addr))) {
|
||||
perror("binding");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (setsockopt(lsock,SOL_SOCKET,SO_SNDBUF,(char *)&sndbuf,sizeof(sndbuf))) {
|
||||
perror("setsockopt(SO_SNDBUF)");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
g_print("listening\n");
|
||||
listen(lsock,8);
|
||||
|
||||
sock = accept(lsock,(struct sockaddr *)&dst_addr,&sockaddrlen);
|
||||
g_print("connected\n");
|
||||
|
||||
close(lsock);
|
||||
|
||||
g_print("creating pipeline\n");
|
||||
src = gst_disksrc_new_with_location("src",argv[1]);
|
||||
g_print("have src\n");
|
||||
gtk_signal_connect(GTK_OBJECT(src),"eof",GTK_SIGNAL_FUNC(eof),NULL);
|
||||
g_print("have eof signal\n");
|
||||
sink = gst_fdsink_new_with_fd("sink",sock);
|
||||
g_print("have sink\n");
|
||||
|
||||
g_print("connecting\n");
|
||||
gst_pad_connect(gst_element_get_pad(src,"src"),
|
||||
gst_element_get_pad(sink,"sink"));
|
||||
|
||||
g_print("pushing...\n");
|
||||
while (!eofflag)
|
||||
gst_src_push(GST_SRC(src));
|
||||
|
||||
sleep(1);
|
||||
close(sock);
|
||||
}
|
|
@ -34,7 +34,7 @@ int main(int argc,char *argv[]) {
|
|||
/* then the decode thread, source, and decoder */
|
||||
decodethread = gst_thread_new("decodethread");
|
||||
|
||||
srcfactory = gst_elementfactory_find("disksrc");
|
||||
srcfactory = gst_elementfactory_find("filesrc");
|
||||
src = gst_elementfactory_create(srcfactory,"src");
|
||||
g_object_set(G_OBJECT(src),"location",argv[1],NULL);
|
||||
gst_bin_add(GST_BIN(decodethread),GST_ELEMENT(src));
|
||||
|
|
51
test/r.c
51
test/r.c
|
@ -1,51 +0,0 @@
|
|||
#include <glib.h>
|
||||
#include <gst/gst.h>
|
||||
|
||||
void eof(GstSrc *src) {
|
||||
g_print("have eof, quitting\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
int main(int argc,char *argv[]) {
|
||||
GstElement *bin, *disksrc, *osssink;
|
||||
GList *padlist;
|
||||
|
||||
gst_init(&argc,&argv);
|
||||
|
||||
bin = gst_bin_new("bin");
|
||||
|
||||
disksrc = gst_disksrc_new("disksrc");
|
||||
g_print("created disksrc\n");
|
||||
if (argc == 2)
|
||||
gst_disksrc_set_filename(disksrc,argv[1]);
|
||||
else
|
||||
gst_disksrc_set_filename(disksrc,"mendelssohn.1.raw");
|
||||
gtk_object_set(GTK_OBJECT(disksrc),"bytesperread",32768,NULL);
|
||||
g_print("loaded file '%s'\n",gst_disksrc_get_filename(disksrc));
|
||||
|
||||
osssink = gst_osssink_new("osssink");
|
||||
|
||||
gtk_signal_connect(GTK_OBJECT(disksrc),"eof",
|
||||
GTK_SIGNAL_FUNC(eof),NULL);
|
||||
|
||||
/* add objects to the main pipeline */
|
||||
gst_bin_add(GST_BIN(bin),GST_OBJECT(disksrc));
|
||||
gst_bin_add(GST_BIN(bin),GST_OBJECT(osssink));
|
||||
|
||||
/* connect src to sink */
|
||||
gst_pad_connect(gst_element_get_pad(disksrc,"src"),
|
||||
gst_element_get_pad(osssink,"sink"));
|
||||
|
||||
/* set soundcard properties */
|
||||
gst_osssink_set_format(GST_AUDIOSINK(osssink),AFMT_S16_BE);
|
||||
gst_osssink_set_channels(GST_AUDIOSINK(osssink),2);
|
||||
gst_osssink_set_frequency(GST_AUDIOSINK(osssink),44100);
|
||||
|
||||
while(1)
|
||||
gst_disksrc_push(GST_SRC(disksrc));
|
||||
|
||||
gst_object_destroy(GST_OBJECT(osssink));
|
||||
gst_object_destroy(GST_OBJECT(disksrc));
|
||||
gst_object_destroy(GST_OBJECT(bin));
|
||||
}
|
||||
|
116
test/s.c
116
test/s.c
|
@ -1,116 +0,0 @@
|
|||
#include <glib.h>
|
||||
#include <gst/gst.h>
|
||||
#include <ghttp.h>
|
||||
|
||||
void eof(GstSrc *src) {
|
||||
g_print("have eof, quitting\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
int main(int argc,char *argv[]) {
|
||||
guint16 mp3type;
|
||||
GList *factories;
|
||||
GstElementFactory *parsefactory;
|
||||
GstElement *bin, *src, *parse, *osssink;
|
||||
GList *padlist;
|
||||
ghttp_request *pls;
|
||||
guchar *plsbuf;
|
||||
gint plsbuflen,parsedlen = 0;
|
||||
guchar *url,*local;
|
||||
GSList *urls = NULL;
|
||||
|
||||
pls = ghttp_request_new();
|
||||
if (argc >= 2)
|
||||
ghttp_set_uri(pls,argv[1]);
|
||||
else
|
||||
ghttp_set_uri(pls,"http://209.127.18.4:9000");
|
||||
ghttp_prepare(pls);
|
||||
ghttp_process(pls);
|
||||
plsbuf = ghttp_get_body(pls);
|
||||
plsbuflen = ghttp_get_body_len(pls);
|
||||
|
||||
while (parsedlen < plsbuflen) {
|
||||
local = plsbuf + parsedlen;
|
||||
if ((*local != '[') && (*local != '\n')) { /* t/v pair */
|
||||
if (!strncmp(local,"File1=",4)) { /* if file */
|
||||
url = strchr(local,'=') + 1; /* url after = */
|
||||
local = strchr(url,'\n'); /* ffwd after = */
|
||||
*(local)++ = 0; /* nullz url */
|
||||
g_print("prepending '%s' to list\n",url);
|
||||
urls = g_slist_prepend(urls,g_strdup(url));
|
||||
/* local should point to next line now */
|
||||
} else {
|
||||
local = strchr(local,'\n') + 1; /* skip line */
|
||||
}
|
||||
} else {
|
||||
local = strchr(local,'\n') + 1; /* skip line */
|
||||
}
|
||||
/* we can consider that line parsed... */
|
||||
parsedlen = local - plsbuf;
|
||||
}
|
||||
if (urls == NULL) {
|
||||
g_print("couldn't find any streams\n");
|
||||
exit(1);
|
||||
}
|
||||
ghttp_request_destroy(pls);
|
||||
|
||||
gst_init(&argc,&argv);
|
||||
gst_plugin_load_all();
|
||||
|
||||
bin = gst_bin_new("bin");
|
||||
|
||||
src = gst_httpsrc_new("src");
|
||||
if (argc == 3) {
|
||||
int i;
|
||||
for (i=1;i<atoi(argv[2]);i++)
|
||||
urls = g_slist_next(urls);
|
||||
}
|
||||
g_print("loading shoutcast server %s\n",urls->data);
|
||||
gtk_object_set(GTK_OBJECT(src),"location",urls->data,NULL);
|
||||
g_print("created src\n");
|
||||
|
||||
/* now it's time to get the parser */
|
||||
mp3type = gst_type_find_by_mime("audio/mpeg");
|
||||
factories = gst_type_get_sinks(mp3type);
|
||||
if (factories != NULL)
|
||||
parsefactory = GST_ELEMENTFACTORY(factories->data);
|
||||
else {
|
||||
g_print("sorry, can't find anyone registered to sink 'mp3'\n");
|
||||
return 1;
|
||||
}
|
||||
parse = gst_elementfactory_create(parsefactory,"parser");
|
||||
if (parse == NULL) {
|
||||
g_print("sorry, couldn't create parser\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
osssink = gst_osssink_new("osssink");
|
||||
|
||||
gtk_signal_connect(GTK_OBJECT(src),"eof",
|
||||
GTK_SIGNAL_FUNC(eof),NULL);
|
||||
|
||||
/* add objects to the main pipeline */
|
||||
gst_bin_add(GST_BIN(bin),GST_OBJECT(src));
|
||||
gst_bin_add(GST_BIN(bin),GST_OBJECT(parse));
|
||||
gst_bin_add(GST_BIN(bin),GST_OBJECT(osssink));
|
||||
|
||||
/* connect src to sink */
|
||||
gst_pad_connect(gst_element_get_pad(src,"src"),
|
||||
gst_element_get_pad(parse,"sink"));
|
||||
gst_pad_connect(gst_element_get_pad(parse,"src"),
|
||||
gst_element_get_pad(osssink,"sink"));
|
||||
|
||||
|
||||
sleep(5); /* to let the network buffer fill a bit */
|
||||
while(1) {
|
||||
g_print("calling gst_httpsrc_push\n");
|
||||
gst_httpsrc_push(GST_SRC(src));
|
||||
}
|
||||
|
||||
gst_object_destroy(GST_OBJECT(osssink));
|
||||
gst_object_destroy(GST_OBJECT(parse));
|
||||
gst_object_destroy(GST_OBJECT(src));
|
||||
gst_object_destroy(GST_OBJECT(bin));
|
||||
}
|
||||
|
|
@ -1,75 +0,0 @@
|
|||
#include <glib.h>
|
||||
#include <gst/gst.h>
|
||||
|
||||
int main(int argc,char *argv[]) {
|
||||
GstBin *bin,
|
||||
GstElement *src, *identity, *sink;
|
||||
|
||||
gst_init(&argc,&argv);
|
||||
|
||||
bin = gst_bin_new("bin");
|
||||
|
||||
src = gst_disksrc_new("fakesrc");
|
||||
gst_disksrc_set_filename(src,"demo.mp3");
|
||||
list_pads(src);
|
||||
|
||||
binf = gst_bin_new("binf");
|
||||
|
||||
filter1 = gst_fakefilter_new("filter1");
|
||||
list_pads(filter1);
|
||||
|
||||
filter2 = gst_fakefilter_new("filter2");
|
||||
list_pads(filter2);
|
||||
|
||||
sink = gst_fakesink_new("fakesink");
|
||||
list_pads(sink);
|
||||
|
||||
gtk_signal_connect(GTK_OBJECT(bin),"object_added",
|
||||
GTK_SIGNAL_FUNC(added_child),NULL);
|
||||
gtk_signal_connect(GTK_OBJECT(binf),"object_added",
|
||||
GTK_SIGNAL_FUNC(added_child),NULL);
|
||||
|
||||
gtk_signal_connect(GTK_OBJECT(binf),"parent_set",
|
||||
GTK_SIGNAL_FUNC(added_parent),NULL);
|
||||
gtk_signal_connect(GTK_OBJECT(src),"parent_set",
|
||||
GTK_SIGNAL_FUNC(added_parent),NULL);
|
||||
gtk_signal_connect(GTK_OBJECT(filter1),"parent_set",
|
||||
GTK_SIGNAL_FUNC(added_parent),NULL);
|
||||
gtk_signal_connect(GTK_OBJECT(filter2),"parent_set",
|
||||
GTK_SIGNAL_FUNC(added_parent),NULL);
|
||||
gtk_signal_connect(GTK_OBJECT(sink),"parent_set",
|
||||
GTK_SIGNAL_FUNC(added_parent),NULL);
|
||||
|
||||
/* add filter1 to the subbin */
|
||||
gst_bin_add(GST_BIN(binf),GST_ELEMENT(filter1));
|
||||
gst_bin_add(GST_BIN(binf),GST_ELEMENT(filter2));
|
||||
/* connect the two together */
|
||||
gst_pad_connect(gst_element_get_pad(filter1,"src"),
|
||||
gst_element_get_pad(filter2,"sink"));
|
||||
/* export the pads */
|
||||
gst_element_add_ghost_pad(binf,gst_element_get_pad(filter1,"sink"));
|
||||
gst_element_add_ghost_pad(binf,gst_element_get_pad(filter2,"src"));
|
||||
list_pads(binf);
|
||||
|
||||
/* add objects to the main pipeline */
|
||||
gst_bin_add(GST_BIN(bin),GST_OBJECT(src));
|
||||
gst_bin_add(GST_BIN(bin),GST_OBJECT(binf));
|
||||
gst_bin_add(GST_BIN(bin),GST_OBJECT(sink));
|
||||
|
||||
/* connect src to binf */
|
||||
gst_pad_connect(gst_element_get_pad(src,"src"),
|
||||
gst_element_get_pad(binf,"sink"));
|
||||
/* connect binf to sink */
|
||||
gst_pad_connect(gst_element_get_pad(binf,"src"),
|
||||
gst_element_get_pad(sink,"sink"));
|
||||
|
||||
gst_disksrc_push(GST_SRC(src));
|
||||
|
||||
gst_object_destroy(GST_OBJECT(src));
|
||||
gst_object_destroy(GST_OBJECT(filter1));
|
||||
gst_object_destroy(GST_OBJECT(filter2));
|
||||
gst_object_destroy(GST_OBJECT(binf));
|
||||
gst_object_destroy(GST_OBJECT(sink));
|
||||
gst_object_destroy(GST_OBJECT(bin));
|
||||
}
|
||||
|
|
@ -15,7 +15,7 @@ int main(int argc, char **argv)
|
|||
{
|
||||
guint channels;
|
||||
GtkWidget *window, *vbox, *play_button, *reset_button, *quit_button;
|
||||
GstElement *disksrc, *mad, *stereo2mono, *pod, *osssink, *pipeline;
|
||||
GstElement *filesrc, *mad, *stereo2mono, *pod, *osssink, *pipeline;
|
||||
|
||||
gst_init (&argc, &argv);
|
||||
gtk_init (&argc, &argv);
|
||||
|
@ -25,23 +25,23 @@ int main(int argc, char **argv)
|
|||
exit(-1);
|
||||
}
|
||||
|
||||
disksrc = gst_elementfactory_make("disksrc", "disksrc");
|
||||
filesrc = gst_elementfactory_make("filesrc", "filesrc");
|
||||
mad = gst_elementfactory_make("mad", "mad");
|
||||
pod = gst_elementfactory_make("playondemand", "playondemand");
|
||||
osssink = gst_elementfactory_make("osssink", "osssink");
|
||||
|
||||
gtk_object_set(GTK_OBJECT(disksrc), "location", argv[1], NULL);
|
||||
gtk_object_set(GTK_OBJECT(filesrc), "location", argv[1], NULL);
|
||||
gtk_object_set(GTK_OBJECT(osssink), "fragment", 0x00180008, NULL);
|
||||
gtk_object_get(GTK_OBJECT(disksrc), "channels", &channels, NULL);
|
||||
gtk_object_get(GTK_OBJECT(osssink), "channels", &channels, NULL);
|
||||
|
||||
pipeline = gst_pipeline_new("app");
|
||||
|
||||
gst_bin_add(GST_BIN(pipeline), disksrc);
|
||||
gst_bin_add(GST_BIN(pipeline), filesrc);
|
||||
gst_bin_add(GST_BIN(pipeline), mad);
|
||||
gst_bin_add(GST_BIN(pipeline), pod);
|
||||
gst_bin_add(GST_BIN(pipeline), osssink);
|
||||
|
||||
gst_element_connect(disksrc, "src", mad, "sink");
|
||||
gst_element_connect(filesrc, "src", mad, "sink");
|
||||
gst_element_connect(pod, "src", osssink, "sink");
|
||||
|
||||
if (channels != 2) {
|
||||
|
|
|
@ -10,7 +10,7 @@ void set_speed (GtkAdjustment *adj, gpointer data)
|
|||
int main(int argc, char **argv)
|
||||
{
|
||||
GtkWidget *window, *vbox, *hscale, *button;
|
||||
GstElement *disksrc, *mad, *stereo2mono, *speed, *osssink, *pipeline;
|
||||
GstElement *filesrc, *mad, *stereo2mono, *speed, *osssink, *pipeline;
|
||||
|
||||
gst_init (&argc, &argv);
|
||||
gtk_init (&argc, &argv);
|
||||
|
@ -36,7 +36,7 @@ int main(int argc, char **argv)
|
|||
gtk_signal_connect(GTK_OBJECT(button), "clicked", gtk_main_quit, NULL);
|
||||
gtk_widget_show(button);
|
||||
|
||||
disksrc = gst_elementfactory_make("filesrc", "filesrc");
|
||||
filesrc = gst_elementfactory_make("filesrc", "filesrc");
|
||||
mad = gst_elementfactory_make("mad", "mad");
|
||||
stereo2mono = gst_elementfactory_make("stereo2mono", "stereo2mono");
|
||||
speed = gst_elementfactory_make("speed", "speed");
|
||||
|
@ -47,16 +47,16 @@ int main(int argc, char **argv)
|
|||
"value_changed", set_speed, speed);
|
||||
|
||||
pipeline = gst_pipeline_new("app");
|
||||
gst_bin_add(GST_BIN(pipeline), disksrc);
|
||||
gst_bin_add(GST_BIN(pipeline), filesrc);
|
||||
gst_bin_add(GST_BIN(pipeline), mad);
|
||||
gst_bin_add(GST_BIN(pipeline), stereo2mono);
|
||||
gst_bin_add(GST_BIN(pipeline), speed);
|
||||
gst_bin_add(GST_BIN(pipeline), osssink);
|
||||
gst_element_connect(disksrc, "src", mad, "sink");
|
||||
gst_element_connect(filesrc, "src", mad, "sink");
|
||||
gst_element_connect(mad, "src", stereo2mono, "sink");
|
||||
gst_element_connect(stereo2mono, "src", speed, "sink");
|
||||
gst_element_connect(speed, "src", osssink, "sink");
|
||||
gtk_object_set(GTK_OBJECT(disksrc), "location", argv[1], NULL);
|
||||
gtk_object_set(GTK_OBJECT(filesrc), "location", argv[1], NULL);
|
||||
|
||||
gst_element_set_state(pipeline, GST_STATE_PLAYING);
|
||||
|
||||
|
|
|
@ -11,13 +11,13 @@ int main(int argc,char *argv[]) {
|
|||
|
||||
bin = gst_bin_new("bin");
|
||||
|
||||
disksrc = gst_disksrc_new("disksrc");
|
||||
g_print("created disksrc\n");
|
||||
filesrc = gst_filesrc_new("filesrc");
|
||||
g_print("created filesrc\n");
|
||||
if (argc == 2)
|
||||
gst_disksrc_set_filename(disksrc,argv[1]);
|
||||
gst_filesrc_set_filename(filesrc,argv[1]);
|
||||
else
|
||||
gst_disksrc_set_filename(disksrc,"Thank_you_very_much.au");
|
||||
g_print("loaded file '%s'\n",gst_disksrc_get_filename(disksrc));
|
||||
gst_filesrc_set_filename(filesrc,"Thank_you_very_much.au");
|
||||
g_print("loaded file '%s'\n",gst_filesrc_get_filename(filesrc));
|
||||
|
||||
|
||||
/* now it's time to get the parser */
|
||||
|
@ -38,26 +38,26 @@ int main(int argc,char *argv[]) {
|
|||
|
||||
osssink = gst_osssink_new("osssink");
|
||||
|
||||
gtk_signal_connect(GTK_OBJECT(disksrc),"eof",
|
||||
gtk_signal_connect(GTK_OBJECT(filesrc),"eof",
|
||||
GTK_SIGNAL_FUNC(eof),NULL);
|
||||
|
||||
/* add objects to the main pipeline */
|
||||
gst_bin_add(GST_BIN(bin),GST_OBJECT(disksrc));
|
||||
gst_bin_add(GST_BIN(bin),GST_OBJECT(filesrc));
|
||||
gst_bin_add(GST_BIN(bin),GST_OBJECT(parse));
|
||||
gst_bin_add(GST_BIN(bin),GST_OBJECT(osssink));
|
||||
|
||||
/* connect src to sink */
|
||||
gst_pad_connect(gst_element_get_pad(disksrc,"src"),
|
||||
gst_pad_connect(gst_element_get_pad(filesrc,"src"),
|
||||
gst_element_get_pad(parse,"sink"));
|
||||
gst_pad_connect(gst_element_get_pad(parse,"src"),
|
||||
gst_element_get_pad(osssink,"sink"));
|
||||
|
||||
while(1)
|
||||
gst_disksrc_push(GST_SRC(disksrc));
|
||||
gst_filesrc_push(GST_SRC(filesrc));
|
||||
|
||||
gst_object_destroy(GST_OBJECT(osssink));
|
||||
gst_object_destroy(GST_OBJECT(parse));
|
||||
gst_object_destroy(GST_OBJECT(disksrc));
|
||||
gst_object_destroy(GST_OBJECT(filesrc));
|
||||
gst_object_destroy(GST_OBJECT(bin));
|
||||
}
|
||||
|
||||
|
|
|
@ -117,7 +117,7 @@ get_audio_encoder_bin (void)
|
|||
|
||||
int main(int argc,char *argv[])
|
||||
{
|
||||
GstElement *disksrc, *audio_enc, *video_enc;
|
||||
GstElement *filesrc, *audio_enc, *video_enc;
|
||||
GstElement *muxthread_video, *muxer, *fdsink_video;
|
||||
GstElement *muxthread_audio, *fdsink_audio;
|
||||
GstElement *bin;
|
||||
|
@ -141,13 +141,13 @@ int main(int argc,char *argv[])
|
|||
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);
|
||||
filesrc = gst_elementfactory_make("filesrc", "disk_source");
|
||||
g_assert(filesrc != NULL);
|
||||
gtk_object_set(GTK_OBJECT(filesrc),"location", argv[1],NULL);
|
||||
|
||||
gst_bin_add (GST_BIN (bin), disksrc);
|
||||
gst_bin_add (GST_BIN (bin), filesrc);
|
||||
|
||||
srccaps = gst_play_typefind (GST_BIN (bin), disksrc);
|
||||
srccaps = gst_play_typefind (GST_BIN (bin), filesrc);
|
||||
|
||||
if (!srccaps) {
|
||||
g_print ("could not autoplug, unknown media type...\n");
|
||||
|
@ -171,17 +171,17 @@ int main(int argc,char *argv[])
|
|||
exit (-1);
|
||||
}
|
||||
|
||||
gst_object_ref (GST_OBJECT (disksrc));
|
||||
gst_bin_remove (GST_BIN (bin), disksrc);
|
||||
gst_object_ref (GST_OBJECT (filesrc));
|
||||
gst_bin_remove (GST_BIN (bin), filesrc);
|
||||
gst_object_destroy (GST_OBJECT (bin));
|
||||
|
||||
// FIXME hack, reparent the disksrc so the scheduler doesn't break
|
||||
// FIXME hack, reparent the filesrc so the scheduler doesn't break
|
||||
bin = gst_pipeline_new("pipeline");
|
||||
|
||||
gst_bin_add (GST_BIN (bin), disksrc);
|
||||
gst_bin_add (GST_BIN (bin), filesrc);
|
||||
gst_bin_add (GST_BIN (bin), new_element);
|
||||
|
||||
gst_element_connect (disksrc, "src", new_element, "sink");
|
||||
gst_element_connect (filesrc, "src", new_element, "sink");
|
||||
|
||||
muxer = gst_elementfactory_make ("system_encode", "muxer");
|
||||
g_assert (muxer != NULL);
|
||||
|
|
72
test/w.c
72
test/w.c
|
@ -1,72 +0,0 @@
|
|||
#include <gst/gst.h>
|
||||
|
||||
void eof(GstSrc *src) {
|
||||
g_print("have eof, quitting\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
int main(int argc,char *argv[]) {
|
||||
GstType *autype;
|
||||
GList *factories;
|
||||
GstElementFactory *parsefactory;
|
||||
GstElement *bin, *disksrc, *parse, *osssink;
|
||||
GList *padlist;
|
||||
|
||||
gst_init(&argc,&argv);
|
||||
gst_plugin_load_all();
|
||||
|
||||
bin = gst_bin_new("bin");
|
||||
|
||||
disksrc = gst_disksrc_new("disksrc");
|
||||
g_print("created disksrc\n");
|
||||
if (argc == 2)
|
||||
gst_disksrc_set_filename(disksrc,argv[1]);
|
||||
else
|
||||
gst_disksrc_set_filename(disksrc,"futile.wav");
|
||||
// gst_disksrc_set_bytesperread(disksrc,32768);
|
||||
g_print("loaded file '%s'\n",gst_disksrc_get_filename(disksrc));
|
||||
|
||||
|
||||
/* now it's time to get the parser */
|
||||
autype = gst_type_get_by_mime("audio/wav");
|
||||
factories = gst_type_get_sinks(autype);
|
||||
if (factories != NULL)
|
||||
parsefactory = GST_ELEMENTFACTORY(factories->data);
|
||||
else {
|
||||
g_print("sorry, can't find anyone registered to sink 'wav'\n");
|
||||
return 1;
|
||||
}
|
||||
parse = gst_elementfactory_create(parsefactory,"parser");
|
||||
if (parse == NULL) {
|
||||
g_print("sorry, couldn't create parser\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
osssink = gst_osssink_new("osssink");
|
||||
|
||||
gtk_signal_connect(GTK_OBJECT(disksrc),"eof",
|
||||
GTK_SIGNAL_FUNC(eof),NULL);
|
||||
|
||||
/* add objects to the main pipeline */
|
||||
gst_bin_add(GST_BIN(bin),GST_OBJECT(disksrc));
|
||||
gst_bin_add(GST_BIN(bin),GST_OBJECT(parse));
|
||||
gst_bin_add(GST_BIN(bin),GST_OBJECT(osssink));
|
||||
|
||||
/* connect src to sink */
|
||||
gst_pad_connect(gst_element_get_pad(disksrc,"src"),
|
||||
gst_element_get_pad(parse,"sink"));
|
||||
gst_pad_connect(gst_element_get_pad(parse,"src"),
|
||||
gst_element_get_pad(osssink,"sink"));
|
||||
|
||||
while(1) {
|
||||
g_print("\n");
|
||||
gst_disksrc_push(GST_SRC(disksrc));
|
||||
}
|
||||
|
||||
gst_object_destroy(GST_OBJECT(osssink));
|
||||
gst_object_destroy(GST_OBJECT(parse));
|
||||
gst_object_destroy(GST_OBJECT(disksrc));
|
||||
gst_object_destroy(GST_OBJECT(bin));
|
||||
}
|
||||
|
Loading…
Reference in a new issue