mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-26 11:41:09 +00:00
0837e1e495
Original commit message from CVS: Modified a lot of plugins to use the caps system. Modified the caps of audio/raw to our agreed properties. Added the multidisksrc plugin of Dominic Ludlam Renamed audiosink/src to osssink/src and updated all the examples using the old name. Moved oss specific plugins in an oss directory. removed the old audiosink from the elements/ dir. removed audioraw.h metadata header files since we now use the properties. There are still a few plugins that won't build because they include the old audioraw.h header file. This will be fixed soon. Make sure the caps are set in the plugins as described by their padtemplates (this should solve problems with gstmediaplay with various media files). *please don't panic when some plugins won't build, just cd manually into the plugin dirs* This will be fixed soon.
104 lines
3.5 KiB
C
104 lines
3.5 KiB
C
#include <glib.h>
|
|
#include <gst/gst.h>
|
|
|
|
extern gboolean _gst_plugin_spew;
|
|
|
|
/* we don't need a lock around the application's state yet, since it's 1
|
|
bit. as it gets more fleshed in, we'll need a lock so the callbacks
|
|
don't screw around with state unexpectedly */
|
|
static gboolean playing = TRUE;
|
|
|
|
void eof(GstElement *src) {
|
|
GST_DEBUG(0,"have EOF\n");
|
|
playing = FALSE;
|
|
}
|
|
|
|
int main(int argc,char *argv[]) {
|
|
GstElement *pipeline;
|
|
GstElement *decodethread;
|
|
GstElementFactory *srcfactory;
|
|
GstElement *src;
|
|
GstElementFactory *decodefactory;
|
|
GstElement *decode;
|
|
GstElementFactory *queuefactory;
|
|
GstElement *queue;
|
|
GstElement *playthread;
|
|
GstElementFactory *sinkfactory;
|
|
GstElement *sink;
|
|
|
|
gst_init(&argc,&argv);
|
|
|
|
/* first create the main pipeline */
|
|
pipeline = GST_ELEMENT(gst_pipeline_new("pipeline"));
|
|
|
|
/* then the decode thread, source, and decoder */
|
|
decodethread = gst_thread_new("decodethread");
|
|
|
|
srcfactory = gst_elementfactory_find("disksrc");
|
|
src = gst_elementfactory_create(srcfactory,"src");
|
|
gtk_object_set(GTK_OBJECT(src),"location",argv[1],NULL);
|
|
gst_bin_add(GST_BIN(decodethread),GST_ELEMENT(src));
|
|
|
|
_gst_plugin_spew = TRUE;
|
|
|
|
if (argc > 2)
|
|
gst_plugin_load(argv[2]);
|
|
else
|
|
gst_plugin_load_all();
|
|
decodefactory = gst_elementfactory_find("mpg123");
|
|
decode = gst_elementfactory_create(decodefactory,"decode");
|
|
gst_bin_add(GST_BIN(decodethread),GST_ELEMENT(decode));
|
|
gst_element_add_ghost_pad(GST_ELEMENT(decodethread),
|
|
gst_element_get_pad(decode,"src"),"src");
|
|
|
|
gst_pad_connect(gst_element_get_pad(src,"src"),
|
|
gst_element_get_pad(decode,"sink"));
|
|
|
|
/* then the play thread and sink */
|
|
playthread = gst_thread_new("playthread");
|
|
|
|
sinkfactory = gst_elementfactory_find("osssink");
|
|
sink = gst_elementfactory_create(sinkfactory,"sink");
|
|
gst_bin_add(GST_BIN(playthread),GST_ELEMENT(sink));
|
|
gst_element_add_ghost_pad(GST_ELEMENT(playthread),
|
|
gst_element_get_pad(sink,"sink"),"sink");
|
|
|
|
/* create the queue */
|
|
queuefactory = gst_elementfactory_find("queue");
|
|
queue = gst_elementfactory_create(queuefactory,"queue");
|
|
|
|
/* add threads to the main pipeline */
|
|
gst_bin_add(GST_BIN(pipeline),decodethread);
|
|
gst_bin_add(GST_BIN(pipeline),queue);
|
|
gst_bin_add(GST_BIN(pipeline),playthread);
|
|
|
|
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(playthread,"sink"));
|
|
|
|
gtk_signal_connect(GTK_OBJECT(src),"eof",
|
|
GTK_SIGNAL_FUNC(eof),NULL);
|
|
|
|
g_print("\nsetting up the decode thread to *NOT* thread\n");
|
|
// gtk_object_set(GTK_OBJECT(decodethread),"create_thread",TRUE,NULL);
|
|
gtk_object_set(GTK_OBJECT(playthread),"create_thread",FALSE,NULL);
|
|
|
|
g_print("\neverything's built, setting it up to be runnable\n");
|
|
gst_element_set_state(GST_ELEMENT(pipeline),GST_STATE_READY);
|
|
|
|
g_print("\nok, runnable, hitting 'play'...\n");
|
|
gst_element_set_state(GST_ELEMENT(pipeline),GST_STATE_PLAYING);
|
|
|
|
g_print("\niterating on %p and %p\n",decodethread,playthread);
|
|
while (playing) {
|
|
gst_bin_iterate(GST_BIN(playthread));
|
|
/* buffers got wedged in the queue, unstick them */
|
|
// while (((GstQueue *)queue)->buffers_queued)
|
|
// gst_connection_push(GST_CONNECTION(queue));
|
|
// gst_thread_iterate(GST_THREAD(playthread));
|
|
// g_print("stuffed and unstuck the queue\n");
|
|
// sleep(1);
|
|
}
|
|
return 0;
|
|
}
|