much removal. anything that can be built with gst-launch should just have a line in a README somewhere, not a separat...

Original commit message from CVS:
much removal. anything that can be built with gst-launch should just have a line in a README
somewhere, not a separate c file.
This commit is contained in:
Andy Wingo 2002-01-04 22:18:45 +00:00
parent 3c39b171b0
commit ef36c68458
19 changed files with 0 additions and 855 deletions

View file

@ -1,10 +0,0 @@
Makefile
Makefile.in
*.o
*.lo
*.la
.deps
.libs
test
simple

View file

@ -1,16 +0,0 @@
noinst_PROGRAMS = test simple
test_SOURCES = test.c cothreads.c object.c looper.c
test_CFLAGS = $(shell gnome-config --cflags gnomeui)
test_LDFLAGS = $(shell gnome-config --libs gnomeui)
simple_SOURCES = simple.c cothreads.c
simple_CFLAGS = $(shell gnome-config --cflags gnomeui)
simple_LDFLAGS = $(shell gnome-config --libs gnomeui)
noinst_HEADERS = cothreads.h object.h looper.h
cothreads.c: $(top_srcdir)/gst/cothreads.c
ln -sf $< $@
cothreads.h: $(top_srcdir)/gst/cothreads.h
ln -sf $< $@

View file

@ -1,47 +0,0 @@
#include <stdio.h>
#include "looper.h"
void looper_loopfunc(object *obj);
void looper_init(looper *l,int source) {
l->source = source;
object_setloopfunc(OBJECT(l),looper_loopfunc);
}
looper *looper_create(char *name,int source,cothread_context *ctx) {
looper *l = malloc(sizeof(looper));
if (l == NULL) {
fprintf(stderr,"sorry, couldn't allocate memory for looper\n");
exit(2);
}
object_init(OBJECT(l),name,ctx);
looper_init(l,source);
return l;
}
void looper_loopfunc(object *obj) {
looper *l = LOOPER(obj);
if (l->source) {
while (1) {
char *buf = malloc(11);
sprintf(buf,"Hello World!");
fprintf(stderr,"\npushing buffer %p with '%s'\n",buf,buf);
object_push(OBJECT(l)->peer,buf); // this should switch
}
} else {
while (1) {
char *buf;
fprintf(stderr,"\npulling buffer\n");
buf = object_pull(OBJECT(l));
printf("got %p: '%s' from peer\n",buf,buf);
free(buf);
// return to the main process now
cothread_switch(cothread_main(OBJECT(l)->threadstate->ctx));
sleep(1000);
}
}
}

View file

@ -1,18 +0,0 @@
#ifndef __LOOPER_H__
#define __LOOPER_H__
#include "object.h"
#define LOOPER(l) ((looper *)(l))
typedef struct _looper looper;
struct _looper {
object object;
int source;
};
void looper_init(looper *l,int source);
looper *looper_create(char *name,int source,cothread_context *ctx);
#endif /* __LOOPER_H__ */

View file

@ -1,78 +0,0 @@
#include <stdio.h>
#include "object.h"
int object_loop_function(int argc,char **argv) {
object *obj = OBJECT(argv);
printf("hey, in loopfunc for object %p\n",obj);
obj->loopfunc(obj);
}
void object_init(object *obj,char *name,cothread_context *ctx) {
obj->threadstate = cothread_create(ctx);
cothread_setfunc(obj->threadstate,object_loop_function,0,(char **)obj);
if (obj->threadstate == NULL) {
fprintf(stderr,"sorry, couldn't init threadstate\n");
exit(2);
}
obj->loopfunc = NULL;
obj->name = malloc(strlen(name));
memcpy(obj->name,name,strlen(name));
obj->peer = NULL;
}
object *object_create(char *name,cothread_context *ctx) {
object *obj = malloc(sizeof(object));
if (obj == NULL) {
printf("ack!\n");
exit(2);
}
memset(obj,0,sizeof(object));
object_init(obj,name,ctx);
return obj;
}
void object_setloopfunc(object *obj,object_loopfunc func) {
obj->loopfunc = func;
fprintf(stderr,"setting object loopfunc to %p\n",func);
}
void object_setpeer(object *obj,object *peer) {
obj->peer = peer;
peer->peer = obj;
printf("peered %p and %p\n",obj,peer);
}
void object_push(object *obj,char *buf) {
obj->pen = buf;
cothread_switch(obj->threadstate);
}
char *object_pull(object *obj) {
char *buf,i=0;
if (obj == NULL) fprintf(stderr,"obj is null\n");
if (obj->peer == NULL) fprintf(stderr,"obj->peer is null\n");
if (obj->peer->threadstate == NULL) fprintf(stderr,"obj->peer->threadstate is null\n");
while (obj->pen == NULL)
cothread_switch(obj->peer->threadstate),i++;
buf = obj->pen;
obj->pen = NULL;
fprintf(stderr,"took %d switches to get %p from pen\n",i,buf);
return buf;
}
void object_start(object *obj) {
if (!obj->threadstate || !obj->loopfunc) {
fprintf(stderr,"ack, not complete\n");
fprintf(stderr,"obj->threadstate is %p, obj->loopfunc is %p\n",
obj->threadstate,obj->loopfunc);
exit(2);
}
cothread_switch(obj->threadstate);
fprintf(stderr,"returned from cothread stuff into end of object_start()\n");
}

View file

@ -1,30 +0,0 @@
#ifndef __OBJECT_H__
#define __OBJECT_H__
#include "cothreads.h"
#define OBJECT(obj) ((object*)(obj))
typedef struct _object object;
typedef void (*object_loopfunc)(object *obj);
struct _object {
cothread_state *threadstate;
object_loopfunc loopfunc;
char *name;
object *peer;
void *pen;
};
void object_init(object *obj,char *name,cothread_context *ctx);
object *object_create(char *name,cothread_context *ctx);
void object_setloopfunc(object *obj,object_loopfunc func);
void object_setpeer(object *obj,object *peer);
void object_push(object *obj,char *buf);
char *object_pull(object *obj);
int object_loop_function(int argc,char **argv);
#endif /* __OBJECT_H__ */

View file

@ -1,23 +0,0 @@
#include <stdio.h>
#include "cothreads.h"
// cothread_context is passed in argv
int loopfunc(int argc,char **argv) {
fprintf(stderr,"SIMPLE: in loopfunc\n");
cothread_switch((cothread_context *)cothread_main(argv));
}
int main(int argc,char *argv[]) {
cothread_context *ctx;
cothread_state *state;
ctx = cothread_init();
state = cothread_create(ctx);
cothread_setfunc(state,loopfunc,0,(char **)ctx);
fprintf(stderr,"SIMPLE: about to switch to cothread 1\n");
cothread_switch(state);
fprintf(stderr,"SIMPLE: back from cothread_switch\n");
return 0;
}

View file

@ -1,22 +0,0 @@
#include <stdio.h>
#include "glib.h"
#include "cothreads.h"
#include "object.h"
#include "looper.h"
cothread_context *ctx;
int main(int argc,char *argv[]) {
looper *l1,*l2;
ctx = cothread_init();
l1 = looper_create("looperone",1,ctx);
l2 = looper_create("loopertwo",0,ctx);
object_setpeer(OBJECT(l1),OBJECT(l2));
fprintf(stderr,"about to start l1\n\n");
while (1)
object_start(l1);
}

View file

@ -1,4 +0,0 @@
noinst_PROGRAMS = seek
LIBS = $(GLIB_LIBS) $(GST_LIBS)
CFLAGS = $(GLIB_CFLAGS) $(XML_CFLAGS) $(GST_CFLAGS)

View file

@ -1,68 +0,0 @@
#include <gst/gst.h>
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_PLAYING);
g_print ("--- iterating\n");
gst_bin_iterate (bin);
gst_bin_iterate (bin);
g_print ("--- seek to 100\n");
gst_pad_send_event (srcpad, gst_event_new_seek (GST_SEEK_ANY, 100, FALSE));
g_print ("--- seek done, iterating\n");
gst_bin_iterate (bin);
gst_bin_iterate (bin);
g_print ("--- seek to 200 with flush\n");
gst_pad_send_event (srcpad, gst_event_new_seek (GST_SEEK_ANY, 200, TRUE));
g_print ("--- seek done, iterating\n");
gst_bin_iterate (bin);
gst_bin_iterate (bin);
gst_bin_iterate (bin);
g_print ("--- flush\n");
gst_pad_send_event (srcpad, gst_event_new_flush ());
g_print ("--- flush done, iterating\n");
gst_bin_iterate (bin);
gst_bin_iterate (bin);
g_print ("--- cleaning up\n");
gst_element_set_state (GST_ELEMENT (bin), GST_STATE_NULL);
return 0;
}

View file

@ -1,7 +0,0 @@
# FIXME FIXME
noinst_PROGRAMS = gsmdec gsmenc
LIBS += $(GST_LIBS)
CFLAGS += $(GST_CFLAGS)

View file

@ -1,91 +0,0 @@
#include <gst/gst.h>
// Important: catch a signal( unix sig. ) to end the prog. normally
int main(int argc, char *argv[] )
{
// The Main Bin( Pipeline )
GstElement *main_pipe ;
// The thread
GstElement *sinkThread ;
// Now the elements for our Sink Bin
GstElement *gsmDec, *ossSink, *udpSrc ;
// And a queue
GstElement *queue ;
gst_init( &argc, &argv ) ; // ughh...
// Get the Boss:
main_pipe = gst_pipeline_new( "main_pipe" ) ;
// & the lower level Bosses
sinkThread = gst_thread_new( "sinkThread" ) ;
//register_sigs( (GstElement *)srcThread ) ; // forget this line
// NOTE: I have changed the osssink to a disksink, as i can't have the two
// processes( server & client ) accessing the same soundcard.
// Get the sound Card
ossSink = gst_elementfactory_make( "osssink", "audio_sink" ) ;
// Get the GSM codecs
gsmDec = gst_elementfactory_make( "gsmdec", "gsmDec" ) ;
// Get a queue
queue = gst_elementfactory_make( "queue", "sink_queue" ) ;
// Get the UDP connection to yourself
udpSrc = gst_elementfactory_make( "udpsrc", "udpSrc" ) ;
// Asserttions:
g_assert( main_pipe != NULL ) ;
g_assert( sinkThread != NULL ) ;
g_assert( ossSink != NULL ) ;
g_assert( gsmDec != NULL ) ;
g_assert( queue != NULL ) ;
g_assert( udpSrc != NULL ) ;
// Got to set the sound card:
//g_object_set( G_OBJECT( ossSink ), "frequency", 1000, NULL ) ;
//g_object_set( G_OBJECT( ossSink ), "channels", 1, NULL ) ;
//g_object_set( G_OBJECT( ossSink ), "location", "recorded", NULL ) ;
// Set the connections:
g_object_set( G_OBJECT( udpSrc ), "port", 9323, NULL ) ;
// make gsm encoders & decoder the ghost pads
gst_element_add_ghost_pad( GST_ELEMENT( sinkThread ),
gst_element_get_pad( ossSink, "sink" ), "sink" ) ;
// Connect the appropritate elements
gst_pad_connect( gst_element_get_pad( udpSrc, "src" ) ,
gst_element_get_pad( gsmDec, "sink" ) ) ;
gst_pad_connect( gst_element_get_pad( gsmDec, "src" ) ,
gst_element_get_pad( queue, "sink" ) ) ;
gst_pad_connect( gst_element_get_pad( queue, "src" ) ,
gst_element_get_pad( GST_ELEMENT( sinkThread ), "sink" ) ) ;
// Add all element to their appropriate bins
gst_bin_add( GST_BIN( sinkThread ), ossSink ) ;
gst_bin_add( GST_BIN( main_pipe ), gsmDec ) ;
gst_bin_add( GST_BIN( main_pipe ), queue ) ;
gst_bin_add( GST_BIN( main_pipe ), udpSrc ) ;
gst_bin_add( GST_BIN( main_pipe ), GST_ELEMENT( sinkThread ) ) ;
// Lets get started
gst_element_set_state( GST_ELEMENT( main_pipe ), GST_STATE_PLAYING ) ;
while( gst_bin_iterate( GST_BIN( main_pipe ) ) ) ;
gst_element_set_state( GST_ELEMENT( main_pipe ), GST_STATE_NULL ) ;
gst_object_destroy( GST_OBJECT( main_pipe ) ) ;
g_print( "Normal Program Termination\n" ) ;
exit (0) ;
}

View file

@ -1,88 +0,0 @@
#include <gst/gst.h>
// Important: catch a signal( unix sig. ) to end the prog. normally
int main(int argc, char *argv[] )
{
// The Main Bin( Thread )
GstElement *main_pipe ;
// The Two pipelines
GstElement *srcThread ;
// The elements for our Source Bin
GstElement *ossSrc, *gsmEnc, *udpSink ;
// And a queue
GstElement *queue ;
gst_init( &argc, &argv ) ; // ughh...
// Get the Boss:
main_pipe = gst_pipeline_new( "main_pipe" ) ;
// & the lower level Bosses
srcThread = gst_thread_new( "sourceThread" ) ;
//register_sigs( (GstElement *)srcThread ) ; forget about this line
// Get the sound Card
ossSrc = gst_elementfactory_make( "osssrc", "audio_src" ) ;
// Get the GSM codecs
gsmEnc = gst_elementfactory_make( "gsmenc", "gsmEnc" ) ;
// Get a queue
queue = gst_elementfactory_make( "queue", "src_queue" ) ;
// Get the UDP connection to the server
udpSink = gst_elementfactory_make( "udpsink", "udpSink" ) ;
// Asserttions:
g_assert( main_pipe != NULL ) ;
g_assert( srcThread != NULL ) ;
g_assert( ossSrc != NULL ) ;
g_assert( gsmEnc != NULL ) ;
g_assert( queue != NULL ) ;
g_assert( udpSink != NULL ) ;
// Got to set the sound card:
g_object_set( G_OBJECT( ossSrc ), "frequency", 8000, NULL ) ;
g_object_set( G_OBJECT( ossSrc ), "channels", 1, NULL ) ;
g_object_set( G_OBJECT( ossSrc ), "bytes_per_read", 320, NULL ) ;
g_object_set( G_OBJECT( ossSrc ), "format", 16, NULL ) ;
// Set the connections:
g_object_set( G_OBJECT( udpSink ), "port", 9323, NULL ) ;
// make gsm encoders & decoder the ghost pads
gst_element_add_ghost_pad( GST_ELEMENT( srcThread ),
gst_element_get_pad( udpSink, "sink" ), "sink" ) ;
// Connect the appropritate elements
gst_pad_connect( gst_element_get_pad( ossSrc, "src" ) ,
gst_element_get_pad( gsmEnc, "sink" ) ) ;
gst_pad_connect( gst_element_get_pad( gsmEnc, "src" ) ,
gst_element_get_pad( queue, "sink" ) ) ;
gst_pad_connect( gst_element_get_pad( queue, "src" ) ,
gst_element_get_pad( GST_ELEMENT( srcThread ), "sink" ) ) ;
// Add all element to their appropriate bins
gst_bin_add( GST_BIN( main_pipe ), ossSrc ) ;
gst_bin_add( GST_BIN( main_pipe ), gsmEnc ) ;
gst_bin_add( GST_BIN( main_pipe ), queue ) ;
gst_bin_add( GST_BIN( srcThread ), udpSink ) ;
gst_bin_add( GST_BIN( main_pipe ), GST_ELEMENT( srcThread ) ) ;
// Lets get started
gst_element_set_state( GST_ELEMENT( main_pipe ), GST_STATE_PLAYING ) ;
while( gst_bin_iterate( GST_BIN( main_pipe ) ) ) ;
gst_element_set_state( GST_ELEMENT( main_pipe ), GST_STATE_NULL ) ;
gst_object_destroy( GST_OBJECT( main_pipe ) ) ;
g_print( "Normal Program Termination\n" ) ;
exit (0) ;
}

View file

@ -1,125 +0,0 @@
#include "gsmtest.h"
// The Main Bin( Thread )
GstElement *main_thread ;
// The primary srcs & sinks:
GstElement *diskSrc , *ossSink, *videoSink ;
// Parsers, filters & Decoders:
GstElement *mpgParser, *mpgVideoParser, *mp3Parser ;
GstElement *mpgDecoder, *mp3Decoder ;
GstElement *colorSpace ; // see if including this works
gboolean playing ;
void eos( GstElement *element, gpointer data )
{
g_print( "eos reached, ending..." ) ;
playing = FALSE ;
}
void mpg_parser_connect( GstElement *parser, GstPad *pad )
{
g_print( "new pad %s created\n", gst_pad_get_name( pad ) ) ;
gst_element_set_state( GST_ELEMENT( main_thread ), GST_STATE_PAUSED ) ;
if( strncmp( gst_pad_get_name( pad ), "audio", 5 ) == 0 )
{
gst_pad_connect( pad, gst_element_get_pad( mp3Parser, "sink" ) ) ;
gst_pad_connect( gst_element_get_pad( mp3Parser, "src" ) ,
gst_element_get_pad( mp3Decoder, "sink" ) ) ;
gst_pad_connect( gst_element_get_pad( mp3Decoder, "src" ) ,
gst_element_get_pad( ossSink, "sink" ) ) ;
gst_bin_add( GST_BIN( main_thread ), mp3Parser ) ;
gst_bin_add( GST_BIN( main_thread ), mp3Decoder ) ;
gst_bin_add( GST_BIN( main_thread ), ossSink ) ;
}
if( strncmp( gst_pad_get_name( pad ), "video", 5 ) == 0 )
{
gst_pad_connect( pad, gst_element_get_pad( mpgVideoParser, "sink" ) ) ;
gst_pad_connect( gst_element_get_pad( mpgVideoParser, "src" ) ,
gst_element_get_pad( mpgDecoder, "sink" ) ) ;
gst_pad_connect( gst_element_get_pad( mpgDecoder, "src" ) ,
gst_element_get_pad( colorSpace, "sink" ) ) ;
gst_pad_connect( gst_element_get_pad( colorSpace, "src" ) ,
gst_element_get_pad( videoSink, "sink" ) ) ;
gst_bin_add( GST_BIN( main_thread ), mpgVideoParser ) ;
gst_bin_add( GST_BIN( main_thread ), mpgDecoder ) ;
gst_bin_add( GST_BIN( main_thread ), colorSpace ) ;
gst_bin_add( GST_BIN( main_thread ), videoSink ) ;
}
gst_element_set_state( GST_ELEMENT( main_thread ), GST_STATE_PLAYING ) ;
}
int main(int argc, char *argv[] )
{
gst_init( &argc, &argv ) ; // ughh...
// Get the Boss:
main_thread = gst_pipeline_new( "main_thread" ) ;
// Get the main Srcs & sinks
diskSrc = gst_elementfactory_make( "disksrc", "movie_file" ) ;
g_object_set( G_OBJECT( diskSrc ), "location", argv[ 1 ], NULL ) ;
g_signal_connectc( G_OBJECT( diskSrc ), "eos",
G_CALLBACK( eos ), main_thread, FALSE ) ;
ossSink = gst_elementfactory_make( "osssink", "audio_sink" ) ;
videoSink = gst_elementfactory_make( "xvideosink", "video_sink" ) ;
colorSpace = gst_elementfactory_make( "colorspace", "video_filter" ) ;
// Get the parsers
mp3Parser = gst_elementfactory_make( "mp3parse", "mp3parser" ) ;
mpgVideoParser = gst_elementfactory_make( "mp2videoparse", "mp2parser" ) ;
mpgParser = gst_elementfactory_make( "mpeg2parse", "mpgparser" ) ;
g_signal_connectc( G_OBJECT( mpgParser ), "new_pad",
G_CALLBACK( mpg_parser_connect ), NULL, FALSE ) ;
//The mpeg decoders
mpgDecoder = gst_elementfactory_make( "mpeg2dec", "mpegdecoder" ) ;
mp3Decoder = gst_elementfactory_make( "mpg123", "mp3decoder" ) ;
// Asserttions:
g_assert( main_thread != NULL ) ;
g_assert( videoSink != NULL ) ;
g_assert( diskSrc != NULL ) ;
g_assert( ossSink != NULL ) ;
g_assert( mpgParser != NULL ) ;
g_assert( mp3Parser != NULL ) ;
g_assert( mp3Decoder != NULL ) ;
g_assert( mpgDecoder != NULL ) ;
g_assert( colorSpace != NULL ) ;
g_assert( mpgVideoParser != NULL ) ;
//g_object_set( G_OBJECT( ossSink ), "frequency", 1000, NULL ) ;
//g_object_set( G_OBJECT( ossSink ), "channels", 1, NULL ) ;
// Connect the appropritate elements
gst_pad_connect( gst_element_get_pad( diskSrc, "src" ) ,
gst_element_get_pad( mpgParser, "sink" ) ) ;
// Add all element to their appropriate bins
gst_bin_add( GST_BIN( main_thread ), diskSrc ) ;
gst_bin_add( GST_BIN( main_thread ), mpgParser ) ;
// Lets get started
gst_element_set_state( GST_ELEMENT( main_thread ), GST_STATE_PLAYING ) ;
playing = TRUE ;
while( playing )
gst_bin_iterate( GST_BIN( main_thread ) ) ;
gst_element_set_state( GST_ELEMENT( main_thread ), GST_STATE_NULL ) ;
gst_object_destroy( GST_OBJECT( main_thread ) ) ;
g_print( "Normal Program Termination\n" ) ;
exit (0) ;
}

11
test/xml/.gitignore vendored
View file

@ -1,11 +0,0 @@
Makefile
Makefile.in
*.o
*.lo
*.la
.deps
.libs
createreg
readreg
*.xml

View file

@ -1,6 +0,0 @@
noinst_PROGRAMS = readreg createreg
LDADD = $(GST_LIBS)
CFLAGS = $(GLIB_CFLAGS) $(XML_CFLAGS) $(GST_CFLAGS)
EXTRA_DIST = README

View file

@ -1,5 +0,0 @@
This is my test code for reading and writing an XML registry of the
plugins. This will be eventually folded back into the main library, such
that when you query the list of plugins, you get all the plugins that are
either loaded or listed in the registry. When you actually ask for a
given plugin, it will load it if necessary. Pretty cool, huh?

View file

@ -1,67 +0,0 @@
#include <glib.h>
#include <gnome-xml/parser.h>
#include <gst/gst.h>
typedef struct _GstRegistryPlugin GstRegistryPlugin;
typedef struct _GstRegistryElement GstRegistryElement;
struct _GstRegistryPlugin {
gchar *name;
gchar *filename;
};
struct _GstRegistryElement {
GstRegistryPlugin *plugin;
gchar *name;
GstElementDetails details;
};
int main(int argc,char *argv[]) {
xmlDocPtr doc;
xmlNodePtr tree, subtree;
GList *plugins = NULL, *features = NULL;
gst_init(&argc,&argv);
gst_plugin_load_all();
doc = xmlNewDoc("1.0");
doc->root = xmlNewDocNode(doc,NULL,"GST-PluginRegistry",NULL);
plugins = gst_plugin_get_list();
while (plugins) {
GstPlugin *plugin = (GstPlugin *)plugins->data;
tree = xmlNewChild(doc->root,NULL,"plugin",NULL);
subtree = xmlNewChild(tree,NULL,"name",plugin->name);
subtree = xmlNewChild(tree,NULL,"longname",plugin->longname);
subtree = xmlNewChild(tree,NULL,"filename",plugin->filename);
features = plugin->features;
while (features) {
GstPluginFeature *feature = GST_PLUGIN_FEATURE (features->data);
if (GST_IS_ELEMENTFACTORY (feature)) {
GstElementFactory *element = GST_ELEMENTFACTORY (feature);
tree = xmlNewChild(doc->root,NULL, "element", NULL);
subtree = xmlNewChild (tree, NULL, "plugin", plugin->name);
subtree = xmlNewChild (tree, NULL, "name", gst_object_get_name (GST_OBJECT (element)));
subtree = xmlNewChild (tree, NULL, "longname",
element->details->longname);
subtree = xmlNewChild (tree, NULL, "class",
element->details->klass);
subtree = xmlNewChild (tree, NULL, "description",
element->details->description);
subtree = xmlNewChild (tree, NULL, "version",
element->details->version);
subtree = xmlNewChild (tree, NULL, "author",
element->details->author);
subtree = xmlNewChild (tree, NULL, "copyright",
element->details->copyright);
}
features = g_list_next (features);
}
plugins = g_list_next(plugins);
}
xmlSaveFile("newreg.xml",doc);
exit(0);
}

View file

@ -1,139 +0,0 @@
#include <glib.h>
#include <gnome-xml/parser.h>
#include <gst/gst.h>
// Include compatability defines: if libxml hasn't already defined these,
// we have an old version 1.x
#ifndef xmlChildrenNode
#define xmlChildrenNode childs
#define xmlRootNode root
#endif
typedef struct _GstRegistryPlugin GstRegistryPlugin;
typedef struct _GstRegistryElement GstRegistryElement;
struct _GstRegistryPlugin {
gchar *name;
gchar *filename;
};
struct _GstRegistryElement {
GstRegistryPlugin *plugin;
gchar *name;
GstElementDetails details;
};
gchar *getcontents(xmlDocPtr doc,xmlNodePtr cur) {
return g_strdup(xmlNodeListGetString(doc,cur->xmlChildrenNode,1));
}
int main(int argc,char *argv[]) {
xmlDocPtr doc;
xmlNodePtr cur;
int i;
GSList *plugins = NULL, *elements = NULL;
// gst_init(&argc,&argv);
if (argc < 2) {
fprintf(stderr,"Usage: %s <registry.xml> [element] [element] ...\n",
argv[0]);
exit(1);
}
doc = xmlParseFile(argv[1]);
g_assert(doc != NULL);
cur = doc->root;
if (cur == NULL) {
g_print("registry is empty\n");
xmlFreeDoc(doc);
exit(0);
}
if (strcmp(cur->name,"GST-PluginRegistry")) {
g_print("document not the right type\n");
xmlFreeDoc(doc);
exit(1);
}
cur = cur->xmlChildrenNode;
while (cur != NULL) {
if (!strcmp(cur->name,"plugin")) {
xmlNodePtr field = cur->xmlChildrenNode;
GstRegistryPlugin *plugin = g_new0(GstRegistryPlugin,1);
while (field) {
if (!strcmp(field->name,"name"))
plugin->name = getcontents(doc,field);
else if (!strcmp(field->name,"filename"))
plugin->filename = getcontents(doc,field);
field = field->next;
}
g_print("new plugin '%s' at '%s'\n",plugin->name,plugin->filename);
plugins = g_slist_prepend(plugins,plugin);
} else if (!strcmp(cur->name,"element")) {
xmlNodePtr field = cur->xmlChildrenNode;
GstRegistryElement *element = g_new0(GstRegistryElement,1);
while (field) {
if (!strcmp(field->name,"plugin")) {
gchar *pluginname = getcontents(doc,field);
GSList *list = plugins;
element->plugin = NULL;
while (list) {
GstRegistryPlugin *plugin = (GstRegistryPlugin *)list->data;
if (!strcmp(pluginname,plugin->name)) {
element->plugin = plugin;
break;
}
list = g_slist_next(list);
}
} else if (!strcmp(field->name,"name"))
element->name = getcontents(doc,field);
else if (!strcmp(field->name,"longname"))
element->details.longname = getcontents(doc,field);
else if (!strcmp(field->name,"class"))
element->details.klass = getcontents(doc,field);
else if (!strcmp(field->name,"description"))
element->details.description = getcontents(doc,field);
else if (!strcmp(field->name,"version"))
element->details.version = getcontents(doc,field);
else if (!strcmp(field->name,"author"))
element->details.author = getcontents(doc,field);
else if (!strcmp(field->name,"copyright"))
element->details.copyright = getcontents(doc,field);
field = field->next;
}
g_print("new element '%s' in '%s'\n",element->name,element->plugin->name);
elements = g_slist_prepend(elements,element);
}
cur = cur->next;
}
for (i=2;i<argc;i++) {
GSList *list;
g_print("\nsearching for element '%s'\n",argv[i]);
list = elements;
while (list) {
GstRegistryElement *element = (GstRegistryElement *)list->data;
// g_print("comparing against '%s'\n",element->name);
if (!strcmp(argv[i],element->name)) {
g_print("Plugin name: %s\n",element->plugin->name);
g_print("Plugin filename: %s\n",element->plugin->filename);
g_print("Element name: %s\n",element->name);
g_print("Element long name: %s\n",element->details.longname);
g_print("Element class: %s\n",element->details.klass);
g_print("Element description: %s\n",element->details.description);
g_print("Element version: %s\n",element->details.version);
g_print("Element author: %s\n",element->details.author);
g_print("Element copyright: %s\n",element->details.copyright);
// gst_plugin_load_absolute(element->plugin->filename);
}
list = g_slist_next(list);
}
}
exit(0);
}