mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-09-27 14:31:01 +00:00
b214d35eed
Original commit message from CVS: commit to make gstreamer follow the gtk function/macro naming conventions: GstPadTemplate <-> gst_pad_template <-> GST_PAD_TEMPLATE and the same for *factory and typefind.
61 lines
1.4 KiB
C
61 lines
1.4 KiB
C
#include <gst/gst.h>
|
|
|
|
void
|
|
type_found (GstElement *typefind, GstCaps* caps)
|
|
{
|
|
xmlDocPtr doc;
|
|
xmlNodePtr parent;
|
|
|
|
doc = xmlNewDoc ("1.0");
|
|
doc->xmlRootNode = xmlNewDocNode (doc, NULL, "Capabilities", NULL);
|
|
|
|
parent = xmlNewChild (doc->xmlRootNode, NULL, "Caps1", NULL);
|
|
gst_caps_save_thyself (caps, parent);
|
|
|
|
xmlDocDump (stdout, doc);
|
|
}
|
|
|
|
int
|
|
main(int argc, char *argv[])
|
|
{
|
|
GstElement *bin, *filesrc, *typefind;
|
|
|
|
gst_init(&argc,&argv);
|
|
|
|
if (argc != 2) {
|
|
g_print("usage: %s <filename>\n", argv[0]);
|
|
exit(-1);
|
|
}
|
|
|
|
/* create a new bin to hold the elements */
|
|
bin = gst_pipeline_new("bin");
|
|
g_assert(bin != NULL);
|
|
|
|
/* create a file reader */
|
|
filesrc = gst_element_factory_make("filesrc", "file_source");
|
|
g_assert(filesrc != NULL);
|
|
g_object_set(G_OBJECT(filesrc),"location", argv[1],NULL);
|
|
|
|
typefind = gst_element_factory_make("typefind", "typefind");
|
|
g_assert(typefind != NULL);
|
|
|
|
/* add objects to the main pipeline */
|
|
gst_bin_add(GST_BIN(bin), filesrc);
|
|
gst_bin_add(GST_BIN(bin), typefind);
|
|
|
|
g_signal_connect (G_OBJECT (typefind), "have_type",
|
|
G_CALLBACK (type_found), NULL);
|
|
|
|
gst_pad_connect(gst_element_get_pad(filesrc,"src"),
|
|
gst_element_get_pad(typefind,"sink"));
|
|
|
|
/* start playing */
|
|
gst_element_set_state(GST_ELEMENT(bin), GST_STATE_PLAYING);
|
|
|
|
gst_bin_iterate(GST_BIN(bin));
|
|
|
|
gst_element_set_state(GST_ELEMENT(bin), GST_STATE_NULL);
|
|
|
|
exit(0);
|
|
}
|
|
|