5 static gboolean ready = FALSE;
22 print_caps (GstCaps * caps)
26 s = gst_caps_to_string (caps);
32 print_format (GstCaps * caps)
36 s = gst_caps_to_string (caps);
37 g_print (" format: %s\n", s);
42 print_lbs_info (struct probe_context *context, gint stream)
44 const GstFormat *formats;
46 /* FIXME: need a better name here */
47 g_print (" stream info:\n");
49 /* report info in all supported formats */
50 formats = gst_pad_get_formats (context->pad);
52 const GstFormatDefinition *definition;
53 gint64 value_start, value_end;
60 if (format == context->ls_format) {
64 definition = gst_format_get_details (format);
66 /* get start and end position of this stream */
67 res = gst_pad_convert (context->pad,
68 context->ls_format, stream, &format, &value_start);
69 res &= gst_pad_convert (context->pad,
70 context->ls_format, stream + 1, &format, &value_end);
73 /* substract to get the length */
74 value_end -= value_start;
76 if (format == GST_FORMAT_TIME) {
77 value_end /= (GST_SECOND / 100);
78 g_print (" %s: %lld:%02lld.%02lld\n", definition->nick,
79 value_end / 6000, (value_end / 100) % 60, (value_end % 100));
81 g_print (" %s: %lld\n", definition->nick, value_end);
84 g_print (" could not get logical stream %s\n", definition->nick);
90 deep_notify (GObject * object, GstObject * origin,
91 GParamSpec * pspec, gpointer data)
93 struct probe_context *context = (struct probe_context *) data;
94 GValue value = { 0, };
96 if (!strcmp (pspec->name, "metadata")) {
98 g_value_init (&value, pspec->value_type);
99 g_object_get_property (G_OBJECT (origin), pspec->name, &value);
100 context->metadata = g_value_peek_pointer (&value);
101 } else if (!strcmp (pspec->name, "streaminfo")) {
103 g_value_init (&value, pspec->value_type);
104 g_object_get_property (G_OBJECT (origin), pspec->name, &value);
105 context->streaminfo = g_value_peek_pointer (&value);
106 } else if (!strcmp (pspec->name, "caps")) {
107 if (GST_IS_PAD (origin) && GST_PAD (origin) == context->pad) {
108 g_value_init (&value, pspec->value_type);
109 g_object_get_property (G_OBJECT (origin), pspec->name, &value);
110 context->caps = g_value_peek_pointer (&value);
118 collect_logical_stream_properties (struct probe_context *context, gint stream)
124 g_print ("info for logical stream %d:\n", stream);
127 event = gst_event_new_seek (context->ls_format |
128 GST_SEEK_METHOD_SET | GST_SEEK_FLAG_FLUSH, stream);
129 res = gst_pad_send_event (context->pad, event);
131 g_warning ("seek to logical track failed");
135 /* run the pipeline to get the info */
138 while (gst_bin_iterate (GST_BIN (context->pipeline)) && !ready) {
144 print_caps (context->metadata);
145 print_caps (context->streaminfo);
146 print_format (context->caps);
147 print_lbs_info (context, stream);
155 collect_stream_properties (struct probe_context *context)
157 const GstFormat *formats;
160 while (gst_bin_iterate (GST_BIN (context->pipeline)) && !ready);
162 g_print ("stream info:\n");
164 context->total_ls = -1;
166 /* report info in all supported formats */
167 formats = gst_pad_get_formats (context->pad);
169 const GstFormatDefinition *definition;
177 res = gst_pad_query (context->pad, GST_QUERY_TOTAL, &format, &value);
179 definition = gst_format_get_details (format);
182 if (format == GST_FORMAT_TIME) {
183 value /= (GST_SECOND / 100);
184 g_print (" total %s: %lld:%02lld.%02lld\n", definition->nick,
185 value / 6000, (value / 100) % 60, (value % 100));
187 if (format == context->ls_format)
188 context->total_ls = value;
189 g_print (" total %s: %lld\n", definition->nick, value);
194 if (context->total_ls == -1) {
195 g_warning (" could not get number of logical streams");
201 main (int argc, char **argv)
203 GstElement *pipeline;
205 GstElement *vorbisfile;
207 GstFormat logical_stream_format;
208 struct probe_context *context;
211 gst_init (&argc, &argv);
214 g_print ("usage: %s <oggfile>\n", argv[0]);
218 pipeline = gst_pipeline_new ("pipeline");
220 filesrc = gst_element_factory_make ("filesrc", "filesrc");
222 g_object_set (G_OBJECT (filesrc), "location", argv[1], NULL);
224 vorbisfile = gst_element_factory_make ("vorbisfile", "vorbisfile");
225 //vorbisfile = gst_element_factory_make ("mad", "vorbisfile");
226 g_assert (vorbisfile);
228 gst_bin_add (GST_BIN (pipeline), filesrc);
229 gst_bin_add (GST_BIN (pipeline), vorbisfile);
231 gst_element_link_pads (filesrc, "src", vorbisfile, "sink");
233 pad = gst_element_get_pad (vorbisfile, "src");
236 logical_stream_format = gst_format_get_by_nick ("logical_stream");
237 g_assert (logical_stream_format != 0);
239 context = g_new0 (struct probe_context, 1);
240 context->pipeline = pipeline;
241 context->element = vorbisfile;
243 context->ls_format = logical_stream_format;
245 g_signal_connect (G_OBJECT (pipeline), "deep_notify",
246 G_CALLBACK (deep_notify), context);
248 gst_element_set_state (pipeline, GST_STATE_PLAYING);
250 /* at this point we can inspect the stream */
251 collect_stream_properties (context);
253 /* loop over all logical streams to get info */
255 while (stream < context->total_ls) {
256 collect_logical_stream_properties (context, stream);
261 gst_element_set_state (pipeline, GST_STATE_NULL);