2 * Copyright (C) 2013 Stefan Sauer <ensonic@users.sf.net>
4 * gst-stats.c: statistics tracing front end
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
33 static GRegex *raw_log = NULL;
34 static GRegex *ansi_log = NULL;
36 /* global statistics */
37 static GHashTable *threads = NULL;
38 static GPtrArray *elements = NULL;
39 static GPtrArray *pads = NULL;
40 static guint64 num_buffers = 0, num_events = 0, num_messages = 0, num_queries =
42 static guint num_elements = 0, num_bins = 0, num_pads = 0, num_ghostpads = 0;
43 static GstClockTime last_ts = G_GUINT64_CONSTANT (0);
44 static guint total_cpuload = 0;
45 static gboolean have_cpuload = FALSE;
49 /* human readable pad name and details */
50 gchar *name, *type_name;
52 gboolean is_ghost_pad;
54 /* buffer statistics */
56 guint num_live, num_decode_only, num_discont, num_resync, num_corrupted,
57 num_marker, num_header, num_gap, num_droppable, num_delta;
58 guint min_size, max_size, avg_size;
59 /* first and last activity on the pad, expected next_ts */
60 GstClockTime first_ts, last_ts, next_ts;
61 /* in which thread does it operate */
69 /* human readable element name */
70 gchar *name, *type_name;
73 /* buffer statistics */
74 guint recv_buffers, sent_buffers;
75 guint64 recv_bytes, sent_bytes;
76 /* event, message statistics */
77 guint num_events, num_messages, num_queries;
78 /* first activity on the element */
79 GstClockTime first_ts, last_ts;
86 /* time spend in this thread */
94 free_element_stats (gpointer data)
96 g_slice_free (GstElementStats, data);
99 static inline GstElementStats *
100 get_element_stats (guint ix)
102 return (ix != G_MAXUINT) ? g_ptr_array_index (elements, ix) : NULL;
105 static inline GstPadStats *
106 get_pad_stats (guint ix)
108 return (ix != G_MAXUINT) ? g_ptr_array_index (pads, ix) : NULL;
112 free_pad_stats (gpointer data)
114 g_slice_free (GstPadStats, data);
117 static inline GstThreadStats *
118 get_thread_stats (guint id)
120 GstThreadStats *stats = g_hash_table_lookup (threads, GUINT_TO_POINTER (id));
122 if (G_UNLIKELY (!stats)) {
123 stats = g_slice_new0 (GstThreadStats);
124 stats->tthread = GST_CLOCK_TIME_NONE;
125 g_hash_table_insert (threads, GUINT_TO_POINTER (id), stats);
131 new_pad_stats (GstStructure * s)
136 gboolean is_ghost_pad;
140 gst_structure_get (s,
141 "ix", G_TYPE_UINT, &ix,
142 "parent-ix", G_TYPE_UINT, &parent_ix,
143 "name", G_TYPE_STRING, &name,
144 "type", G_TYPE_STRING, &type,
145 "is-ghostpad", G_TYPE_BOOLEAN, &is_ghost_pad,
146 "pad-direction", GST_TYPE_PAD_DIRECTION, &dir,
147 "thread-id", G_TYPE_UINT, &thread_id, NULL);
149 stats = g_slice_new0 (GstPadStats);
154 stats->type_name = type;
156 stats->is_ghost_pad = is_ghost_pad;
158 stats->min_size = G_MAXUINT;
159 stats->first_ts = stats->last_ts = stats->next_ts = GST_CLOCK_TIME_NONE;
160 stats->thread_id = thread_id;
161 stats->parent_ix = parent_ix;
164 g_ptr_array_set_size (pads, ix + 1);
165 g_ptr_array_index (pads, ix) = stats;
169 new_element_stats (GstStructure * s)
171 GstElementStats *stats;
176 gst_structure_get (s,
177 "ix", G_TYPE_UINT, &ix,
178 "parent-ix", G_TYPE_UINT, &parent_ix,
179 "name", G_TYPE_STRING, &name,
180 "type", G_TYPE_STRING, &type, "is-bin", G_TYPE_BOOLEAN, &is_bin, NULL);
182 stats = g_slice_new0 (GstElementStats);
188 stats->type_name = type;
189 stats->is_bin = is_bin;
190 stats->first_ts = GST_CLOCK_TIME_NONE;
191 stats->parent_ix = parent_ix;
193 if (elements->len <= ix)
194 g_ptr_array_set_size (elements, ix + 1);
195 g_ptr_array_index (elements, ix) = stats;
199 free_thread_stats (gpointer data)
201 g_slice_free (GstThreadStats, data);
205 do_pad_stats (GstPadStats * stats, guint elem_ix, guint size, guint64 ts,
206 guint64 buffer_ts, guint64 buffer_dur, GstBufferFlags buffer_flags)
211 if (stats->parent_ix == G_MAXUINT) {
212 stats->parent_ix = elem_ix;
215 if (stats->thread_id) {
216 get_thread_stats (stats->thread_id);
220 avg_size = (((gulong) stats->avg_size * (gulong) stats->num_buffers) + size);
221 stats->num_buffers++;
222 stats->avg_size = (guint) (avg_size / stats->num_buffers);
223 if (size < stats->min_size)
224 stats->min_size = size;
225 else if (size > stats->max_size)
226 stats->max_size = size;
228 if (!GST_CLOCK_TIME_IS_VALID (stats->last_ts))
229 stats->first_ts = ts;
232 if (buffer_flags & GST_BUFFER_FLAG_LIVE)
234 if (buffer_flags & GST_BUFFER_FLAG_DECODE_ONLY)
235 stats->num_decode_only++;
236 if (buffer_flags & GST_BUFFER_FLAG_DISCONT)
237 stats->num_discont++;
238 if (buffer_flags & GST_BUFFER_FLAG_RESYNC)
240 if (buffer_flags & GST_BUFFER_FLAG_CORRUPTED)
241 stats->num_corrupted++;
242 if (buffer_flags & GST_BUFFER_FLAG_MARKER)
244 if (buffer_flags & GST_BUFFER_FLAG_HEADER)
246 if (buffer_flags & GST_BUFFER_FLAG_GAP)
248 if (buffer_flags & GST_BUFFER_FLAG_DROPPABLE)
249 stats->num_droppable++;
250 if (buffer_flags & GST_BUFFER_FLAG_DELTA_UNIT)
252 /* update timestamps */
253 if (GST_CLOCK_TIME_IS_VALID (buffer_ts) &&
254 GST_CLOCK_TIME_IS_VALID (buffer_dur)) {
255 stats->next_ts = buffer_ts + buffer_dur;
257 stats->next_ts = GST_CLOCK_TIME_NONE;
262 do_element_stats (GstElementStats * stats, GstElementStats * peer_stats,
263 guint size, guint64 ts)
265 stats->sent_buffers++;
266 peer_stats->recv_buffers++;
267 stats->sent_bytes += size;
268 peer_stats->recv_bytes += size;
270 if (G_UNLIKELY (!GST_CLOCK_TIME_IS_VALID (stats->first_ts))) {
271 stats->first_ts = ts;
273 if (G_UNLIKELY (!GST_CLOCK_TIME_IS_VALID (peer_stats->first_ts))) {
274 peer_stats->first_ts = ts + 1;
279 do_buffer_stats (GstStructure * s)
281 guint64 ts, buffer_ts, buffer_dur;
282 guint pad_ix, elem_ix, peer_elem_ix;
284 GstBufferFlags buffer_flags;
285 GstPadStats *pad_stats;
286 GstElementStats *elem_stats, *peer_elem_stats;
289 gst_structure_get (s, "ts", G_TYPE_UINT64, &ts,
290 "pad-ix", G_TYPE_UINT, &pad_ix,
291 "elem-ix", G_TYPE_UINT, &elem_ix,
292 "peer-elem-ix", G_TYPE_UINT, &peer_elem_ix,
293 "buffer-size", G_TYPE_UINT, &size,
294 "buffer-ts", G_TYPE_UINT64, &buffer_ts,
295 "buffer-duration", G_TYPE_UINT64, &buffer_dur,
296 "buffer-flags", GST_TYPE_BUFFER_FLAGS, &buffer_flags, NULL);
297 last_ts = MAX (last_ts, ts);
298 if (!(pad_stats = get_pad_stats (pad_ix))) {
299 GST_WARNING ("no pad stats found for ix=%u", pad_ix);
302 if (!(elem_stats = get_element_stats (elem_ix))) {
303 GST_WARNING ("no element stats found for ix=%u", elem_ix);
306 if (!(peer_elem_stats = get_element_stats (peer_elem_ix))) {
307 GST_WARNING ("no element stats found for ix=%u", peer_elem_ix);
310 do_pad_stats (pad_stats, elem_ix, size, ts, buffer_ts, buffer_dur,
312 if (pad_stats->dir == GST_PAD_SRC) {
314 do_element_stats (elem_stats, peer_elem_stats, size, ts);
317 do_element_stats (peer_elem_stats, elem_stats, size, ts);
322 do_event_stats (GstStructure * s)
325 guint pad_ix, elem_ix;
326 GstPadStats *pad_stats;
327 GstElementStats *elem_stats;
330 gst_structure_get (s, "ts", G_TYPE_UINT64, &ts,
331 "pad-ix", G_TYPE_UINT, &pad_ix, "elem-ix", G_TYPE_UINT, &elem_ix, NULL);
332 last_ts = MAX (last_ts, ts);
333 if (!(pad_stats = get_pad_stats (pad_ix))) {
334 GST_WARNING ("no pad stats found for ix=%u", pad_ix);
337 if (!(elem_stats = get_element_stats (elem_ix))) {
338 // e.g. reconfigure events are send over unparented pads
339 GST_INFO ("no element stats found for ix=%u", elem_ix);
342 elem_stats->num_events++;
346 do_message_stats (GstStructure * s)
350 GstElementStats *elem_stats;
353 gst_structure_get (s, "ts", G_TYPE_UINT64, &ts,
354 "elem-ix", G_TYPE_UINT, &elem_ix, NULL);
355 last_ts = MAX (last_ts, ts);
356 if (!(elem_stats = get_element_stats (elem_ix))) {
357 GST_WARNING ("no element stats found for ix=%u", elem_ix);
360 elem_stats->num_messages++;
364 do_query_stats (GstStructure * s)
368 GstElementStats *elem_stats;
371 gst_structure_get (s, "ts", G_TYPE_UINT64, &ts,
372 "elem-ix", G_TYPE_UINT, &elem_ix, NULL);
373 last_ts = MAX (last_ts, ts);
374 if (!(elem_stats = get_element_stats (elem_ix))) {
375 GST_WARNING ("no element stats found for ix=%u", elem_ix);
378 elem_stats->num_queries++;
382 do_thread_rusage_stats (GstStructure * s)
385 guint thread_id, cpuload;
386 GstThreadStats *thread_stats;
388 gst_structure_get (s, "ts", G_TYPE_UINT64, &ts,
389 "thread-id", G_TYPE_UINT, &thread_id,
390 "average-cpuload", G_TYPE_UINT, &cpuload, "time", G_TYPE_UINT64, &tthread,
392 thread_stats = get_thread_stats (thread_id);
393 thread_stats->cpuload = cpuload;
394 thread_stats->tthread = tthread;
395 last_ts = MAX (last_ts, ts);
399 do_proc_rusage_stats (GstStructure * s)
403 gst_structure_get (s, "ts", G_TYPE_UINT64, &ts,
404 "average-cpuload", G_TYPE_UINT, &total_cpuload, NULL);
405 last_ts = MAX (last_ts, ts);
412 find_pad_stats_for_thread (gconstpointer value, gconstpointer user_data)
414 const GstPadStats *stats = (const GstPadStats *) value;
416 if ((stats->thread_id == GPOINTER_TO_UINT (user_data)) &&
417 (stats->num_buffers)) {
424 print_pad_stats (gpointer value, gpointer user_data)
426 GstPadStats *stats = (GstPadStats *) value;
428 if (stats->thread_id == GPOINTER_TO_UINT (user_data)) {
429 /* there seem to be some temporary pads */
430 if (stats->num_buffers) {
431 GstClockTimeDiff running =
432 GST_CLOCK_DIFF (stats->first_ts, stats->last_ts);
433 GstElementStats *elem_stats = get_element_stats (stats->parent_ix);
434 gchar fullname[30 + 1];
436 g_snprintf (fullname, 30, "%s.%s", elem_stats->name, stats->name);
439 (" %c %-30.30s: buffers %7u (live %5u,dec %5u,dis %5u,res %5u,"
440 "cor %5u,mar %5u,hdr %5u,gap %5u,drop %5u,dlt %5u),",
441 (stats->dir == GST_PAD_SRC) ? '>' : '<', fullname, stats->num_buffers,
442 stats->num_live, stats->num_decode_only, stats->num_discont,
443 stats->num_resync, stats->num_corrupted, stats->num_marker,
444 stats->num_header, stats->num_gap, stats->num_droppable,
446 if (stats->min_size == stats->max_size) {
447 printf (" size (min/avg/max) ......./%7u/.......,", stats->avg_size);
449 printf (" size (min/avg/max) %7u/%7u/%7u,",
450 stats->min_size, stats->avg_size, stats->max_size);
452 printf (" time %" GST_TIME_FORMAT ","
454 GST_TIME_ARGS (running),
455 ((gdouble) (stats->num_buffers * stats->avg_size) * GST_SECOND) /
456 ((gdouble) running));
462 print_thread_stats (gpointer key, gpointer value, gpointer user_data)
464 GSList *list = user_data;
465 GSList *node = g_slist_find_custom (list, key, find_pad_stats_for_thread);
466 GstThreadStats *stats = (GstThreadStats *) value;
468 /* skip stats if there are no pads for that thread (e.g. a pipeline) */
472 printf ("Thread %p Statistics:\n", key);
473 if (GST_CLOCK_TIME_IS_VALID (stats->tthread)) {
474 printf (" Time: %" GST_TIME_FORMAT "\n", GST_TIME_ARGS (stats->tthread));
475 printf (" Avg CPU load: %4.1f %%\n", (gfloat) stats->cpuload / 10.0);
478 puts (" Pad Statistics:");
479 g_slist_foreach (node, print_pad_stats, key);
483 print_element_stats (gpointer value, gpointer user_data)
485 GstElementStats *stats = (GstElementStats *) value;
487 /* skip temporary elements */
488 if (stats->first_ts != GST_CLOCK_TIME_NONE) {
489 gchar fullname[45 + 1];
491 g_snprintf (fullname, 45, "%s:%s", stats->type_name, stats->name);
493 printf (" %-45s:", fullname);
494 if (stats->recv_buffers)
495 printf (" buffers in/out %7u", stats->recv_buffers);
497 printf (" buffers in/out %7s", "-");
498 if (stats->sent_buffers)
499 printf ("/%7u", stats->sent_buffers);
501 printf ("/%7s", "-");
502 if (stats->recv_bytes)
503 printf (" bytes in/out %12" G_GUINT64_FORMAT, stats->recv_bytes);
505 printf (" bytes in/out %12s", "-");
506 if (stats->sent_bytes)
507 printf ("/%12" G_GUINT64_FORMAT, stats->sent_bytes);
509 printf ("/%12s", "-");
510 printf (" first activity %" GST_TIME_FORMAT ", "
511 " ev/msg/qry sent %5u/%5u/%5u\n", GST_TIME_ARGS (stats->first_ts),
512 stats->num_events, stats->num_messages, stats->num_queries);
517 accum_element_stats (gpointer value, gpointer user_data)
519 GstElementStats *stats = (GstElementStats *) value;
521 if (stats->parent_ix != G_MAXUINT) {
522 GstElementStats *parent_stats = get_element_stats (stats->parent_ix);
524 parent_stats->num_events += stats->num_events;
525 parent_stats->num_messages += stats->num_messages;
526 parent_stats->num_queries += stats->num_queries;
527 if (!GST_CLOCK_TIME_IS_VALID (parent_stats->first_ts)) {
528 parent_stats->first_ts = stats->first_ts;
529 } else if (GST_CLOCK_TIME_IS_VALID (stats->first_ts)) {
530 parent_stats->first_ts = MIN (parent_stats->first_ts, stats->first_ts);
532 if (!GST_CLOCK_TIME_IS_VALID (parent_stats->last_ts)) {
533 parent_stats->last_ts = stats->last_ts;
534 } else if (GST_CLOCK_TIME_IS_VALID (stats->last_ts)) {
535 parent_stats->last_ts = MAX (parent_stats->last_ts, stats->last_ts);
543 sort_pad_stats_by_first_activity (gconstpointer ps1, gconstpointer ps2)
545 GstPadStats *s1 = (GstPadStats *) ps1;
546 GstPadStats *s2 = (GstPadStats *) ps2;
548 gint order = GST_CLOCK_DIFF (s2->first_ts, s1->first_ts);
551 order = s1->dir - s2->dir;
557 sort_pad_stats (gpointer value, gpointer user_data)
559 GSList **list = user_data;
562 g_slist_insert_sorted (*list, value, sort_pad_stats_by_first_activity);
566 sort_element_stats_by_first_activity (gconstpointer es1, gconstpointer es2)
568 return (GST_CLOCK_DIFF (((GstElementStats *) es2)->first_ts,
569 ((GstElementStats *) es1)->first_ts));
573 sort_bin_stats (gpointer value, gpointer user_data)
575 if (((GstElementStats *) value)->is_bin) {
576 GSList **list = user_data;
579 g_slist_insert_sorted (*list, value,
580 sort_element_stats_by_first_activity);
585 sort_element_stats (gpointer value, gpointer user_data)
587 if (!(((GstElementStats *) value)->is_bin)) {
588 GSList **list = user_data;
591 g_slist_insert_sorted (*list, value,
592 sort_element_stats_by_first_activity);
597 check_bin_parent (gpointer key, gpointer value, gpointer user_data)
599 GstElementStats *stats = (GstElementStats *) value;
601 return (stats->parent_ix == GPOINTER_TO_UINT (user_data));
605 process_leaf_bins (gpointer key, gpointer value, gpointer user_data)
607 GHashTable *accum_bins = user_data;
609 /* if we find no bin that has this bin as a parent ... */
610 if (!g_hash_table_find (accum_bins, check_bin_parent, key)) {
611 /* accumulate stats to the parent and remove */
612 accum_element_stats (value, NULL);
623 /* compile the parser regexps */
624 /* 0:00:00.004925027 31586 0x1c5c600 DEBUG GST_REGISTRY gstregistry.c:463:gst_registry_add_plugin:<registry0> adding plugin 0x1c79160 for filename "/usr/lib/gstreamer-1.0/libgstxxx.so" */
625 raw_log = g_regex_new (
636 /* 6: file:line:func: */
637 "([^:]+:[0-9]+:[^:]+:)"
638 /* 7: (obj)? log-text */
639 "(.*)$", 0, 0, NULL);
641 GST_WARNING ("failed to compile the 'raw' parser");
645 ansi_log = g_regex_new (
649 "\\\e\\\[[0-9;]+m *([0-9]+)\\\e\\\[00m +"
653 "(?:\\\e\\\[[0-9;]+m)?([A-Z]+) +\\\e\\\[00m +"
655 "\\\e\\\[[0-9;]+m +([a-zA-Z_-]+) +"
656 /* 6: file:line:func: */
657 "([^:]+:[0-9]+:[^:]+:)(?:\\\e\\\[00m)?"
658 /* 7: (obj)? log-text */
659 "(.*)$", 0, 0, NULL);
661 GST_WARNING ("failed to compile the 'ansi' parser");
665 elements = g_ptr_array_new_with_free_func (free_element_stats);
666 pads = g_ptr_array_new_with_free_func (free_pad_stats);
667 threads = g_hash_table_new_full (NULL, NULL, NULL, free_thread_stats);
676 g_ptr_array_free (pads, TRUE);
678 g_ptr_array_free (elements, TRUE);
680 g_hash_table_destroy (threads);
683 g_regex_unref (raw_log);
685 g_regex_unref (ansi_log);
691 guint num_threads = g_hash_table_size (threads);
693 /* print overall stats */
694 puts ("\nOverall Statistics:");
695 printf ("Number of Threads: %u\n", num_threads);
696 printf ("Number of Elements: %u\n", num_elements - num_bins);
697 printf ("Number of Bins: %u\n", num_bins);
698 printf ("Number of Pads: %u\n", num_pads - num_ghostpads);
699 printf ("Number of GhostPads: %u\n", num_ghostpads);
700 printf ("Number of Buffers passed: %" G_GUINT64_FORMAT "\n", num_buffers);
701 printf ("Number of Events sent: %" G_GUINT64_FORMAT "\n", num_events);
702 printf ("Number of Message sent: %" G_GUINT64_FORMAT "\n", num_messages);
703 printf ("Number of Queries sent: %" G_GUINT64_FORMAT "\n", num_queries);
704 printf ("Time: %" GST_TIME_FORMAT "\n", GST_TIME_ARGS (last_ts));
706 printf ("Avg CPU load: %4.1f %%\n", (gfloat) total_cpuload / 10.0);
714 g_ptr_array_foreach (pads, sort_pad_stats, &list);
715 g_hash_table_foreach (threads, print_thread_stats, list);
724 puts ("Element Statistics:");
725 /* sort by first_activity */
726 g_ptr_array_foreach (elements, sort_element_stats, &list);
727 /* attribute element stats to bins */
728 g_slist_foreach (list, accum_element_stats, NULL);
729 g_slist_foreach (list, print_element_stats, NULL);
738 GHashTable *accum_bins = g_hash_table_new_full (NULL, NULL, NULL, NULL);
740 puts ("Bin Statistics:");
741 /* attribute bin stats to parent-bins */
742 for (i = 0; i < num_elements; i++) {
743 GstElementStats *stats = g_ptr_array_index (elements, i);
745 g_hash_table_insert (accum_bins, GUINT_TO_POINTER (i), stats);
748 while (g_hash_table_size (accum_bins)) {
749 g_hash_table_foreach_remove (accum_bins, process_leaf_bins, accum_bins);
751 g_hash_table_destroy (accum_bins);
752 /* sort by first_activity */
753 g_ptr_array_foreach (elements, sort_bin_stats, &list);
754 g_slist_foreach (list, print_element_stats, NULL);
761 collect_stats (const gchar * filename)
765 if ((log = fopen (filename, "rt"))) {
769 if (fgets (line, 5000, log)) {
770 GMatchInfo *match_info;
776 if (strchr (line, 27)) {
778 GST_INFO ("format is 'ansi'");
781 GST_INFO ("format is 'raw'");
786 while (!feof (log)) {
787 if (fgets (line, 5000, log)) {
788 if (g_regex_match (parser, line, 0, &match_info)) {
789 /* filter by level */
790 level = g_match_info_fetch (match_info, 4);
791 if (!strcmp (level, "TRACE")) {
792 data = g_match_info_fetch (match_info, 7);
793 if ((s = gst_structure_from_string (data, NULL))) {
794 const gchar *name = gst_structure_get_name (s);
796 if (!strcmp (name, "new-pad")) {
798 } else if (!strcmp (name, "new-element")) {
799 new_element_stats (s);
800 } else if (!strcmp (name, "buffer")) {
802 } else if (!strcmp (name, "event")) {
804 } else if (!strcmp (name, "message")) {
805 do_message_stats (s);
806 } else if (!strcmp (name, "query")) {
808 } else if (!strcmp (name, "thread-rusage")) {
809 do_thread_rusage_stats (s);
810 } else if (!strcmp (name, "proc-rusage")) {
811 do_proc_rusage_stats (s);
813 // TODO(ensonic): parse the xxx.class log lines
814 if (!g_str_has_suffix (data, ".class")) {
815 GST_WARNING ("unknown log entry: '%s'", data);
818 gst_structure_free (s);
820 GST_WARNING ("unknown log entry: '%s'", data);
825 GST_WARNING ("foreign log entry: %s:%d:'%s'", filename, lnr,
829 g_match_info_free (match_info);
834 // TODO(ensonic): run wc -L on the log file
835 fprintf (stderr, "line too long");
841 GST_WARNING ("empty log");
847 main (gint argc, gchar * argv[])
849 gchar **filenames = NULL;
853 GOptionEntry options[] = {
854 GST_TOOLS_GOPTION_VERSION,
855 // TODO(ensonic): add a summary flag, if set read the whole thing, print
856 // stats once, and exit
857 {G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &filenames, NULL}
863 bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
864 bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
865 textdomain (GETTEXT_PACKAGE);
868 g_set_prgname ("gst-stats-" GST_API_VERSION);
870 ctx = g_option_context_new ("FILE");
871 g_option_context_add_main_entries (ctx, options, GETTEXT_PACKAGE);
872 g_option_context_add_group (ctx, gst_init_get_option_group ());
873 if (!g_option_context_parse (ctx, &argc, &argv, &err)) {
874 g_print ("Error initializing: %s\n", GST_STR_NULL (err->message));
877 g_option_context_free (ctx);
879 gst_tools_print_version ();
881 if (filenames == NULL || *filenames == NULL) {
882 g_print ("Please give one filename to %s\n\n", g_get_prgname ());
885 num = g_strv_length (filenames);
886 if (num == 0 || num > 1) {
887 g_print ("Please give exactly one filename to %s (%d given).\n\n",
888 g_get_prgname (), num);
893 collect_stats (filenames[0]);
898 g_strfreev (filenames);