summaryrefslogtreecommitdiff
path: root/tests/registry.c
blob: 804df82302dd3af4377b911419d0e1b362ec6a1c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#include <gst/gst.h>

static void 
dump_plugins (void)
{
  GList *plugins;
  plugins = gst_plugin_get_list ();

  while (plugins) {
    GstPlugin *plugin = (GstPlugin *)plugins->data;
    
    g_print ("plugin: %s, loaded %d\n", plugin->name, plugin->loaded);

    plugins = g_list_next (plugins);
  }
}

static void 
dump_factories (void)
{
  GList *factories;
  factories = gst_elementfactory_get_list ();

  while (factories) {
    GstElementFactory *factory = (GstElementFactory *)factories->data;
    
    g_print ("factory: %s %d\n", factory->name, factory->type);

    factories = g_list_next (factories);
  }
}

static void 
dump_factory (gchar *name)
{
  GstElementFactory *factory;

  factory = gst_elementfactory_find (name);

  if (factory) {
    GList *padtemplates = factory->padtemplates;
    xmlDocPtr doc;

    doc = xmlNewDoc ("1.0");
    doc->xmlRootNode = xmlNewDocNode (doc, NULL, "templates", NULL);

    while (padtemplates) {
      xmlNodePtr parent;
      GstPadTemplate *template = (GstPadTemplate *) padtemplates->data;

      parent = xmlNewChild (doc->xmlRootNode, NULL, "template", NULL);

      gst_padtemplate_save_thyself (template, parent);

      padtemplates = g_list_next (padtemplates);
    }

    xmlDocDump(stdout, doc);
  }
}

static void 
dump_types (void)
{
  GList *types;
  types = gst_type_get_list ();

  while (types) {
    GstType *factory = (GstType *)types->data;
    
    g_print ("type: %s %d\n", factory->mime, factory->id);

    types = g_list_next (types);
  }
}

static void 
load_something (gchar *name)
{
  GstElementFactory *factory;
  GstElement *element;

  //factory = gst_elementfactory_find ("foo");
  //g_print ("factory \"foo\" %s\n", (factory?"found":"not found"));

  factory = gst_elementfactory_find (name);
  g_print ("factory \"%s\" %s\n", name, (factory?"found":"not found"));

  element = gst_elementfactory_create (factory, "test");

  g_print ("element \"%s\" %s\n", name, (element?"found":"not found"));
}

static void 
print_some_providers (gchar *mime)
{
  guint16 type;
  GList *srcs, *sinks;
  type = gst_type_find_by_mime (mime);

  /*
  srcs = gst_type_get_srcs (type);

  while (srcs) {
    GstElementFactory *factory;

    factory = (GstElementFactory *) srcs->data;

    g_print ("factory src: \"%s\"\n", factory->name);

    srcs = g_list_next (srcs);
  }

  sinks = gst_type_get_sinks (type);
  while (sinks) {
    GstElementFactory *factory;

    factory = (GstElementFactory *) sinks->data;

    g_print ("factory sink: \"%s\"\n", factory->name);

    sinks = g_list_next (sinks);
  }
  */
}

int main(int argc,char *argv[]) 
{

  gst_init(&argc,&argv);

  //dump_plugins ();
  //dump_factories ();
  //dump_types ();

  //print_some_providers ("audio/mp3");

  load_something ("fdsink");

  print_some_providers ("audio/mp3");

  load_something ("mpg123");

  dump_plugins ();
  dump_factories ();
  dump_types ();

  dump_factory ("lame");
  dump_factory ("mpeg_play");
}