1 | /* GStreamer |
---|
2 | * Copyright (C) 2003 Erik Walthinsen <omega@cse.ogi.edu> |
---|
3 | * |
---|
4 | * This library is free software; you can redistribute it and/or |
---|
5 | * modify it under the terms of the GNU Library General Public |
---|
6 | * License as published by the Free Software Foundation; either |
---|
7 | * version 2 of the License, or (at your option) any later version. |
---|
8 | * |
---|
9 | * This library is distributed in the hope that it will be useful, |
---|
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
12 | * Library General Public License for more details. |
---|
13 | * |
---|
14 | * You should have received a copy of the GNU Library General Public |
---|
15 | * License along with this library; if not, write to the |
---|
16 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
---|
17 | * Boston, MA 02111-1307, USA. |
---|
18 | */ |
---|
19 | |
---|
20 | #include <gst/gst.h> |
---|
21 | |
---|
22 | static void |
---|
23 | my_resolver (GstIndex * index, GstObject * _ign, gchar ** writer_string, |
---|
24 | gpointer user_data) |
---|
25 | { |
---|
26 | *writer_string = user_data; |
---|
27 | } |
---|
28 | |
---|
29 | gint |
---|
30 | main (gint argc, gchar * argv[]) |
---|
31 | { |
---|
32 | GstIndex *index; |
---|
33 | GstObject *identity; |
---|
34 | gint id; |
---|
35 | gint64 cur; |
---|
36 | |
---|
37 | gst_init (&argc, &argv); |
---|
38 | |
---|
39 | if (argc != 3) { |
---|
40 | g_print ("usage: dumpfileindex /path/to/fileindex writer_id\n"); |
---|
41 | exit (0); |
---|
42 | } |
---|
43 | |
---|
44 | index = gst_index_factory_make ("fileindex"); |
---|
45 | g_assert (index != NULL); |
---|
46 | |
---|
47 | g_object_set (index, "location", argv[1], NULL); |
---|
48 | gst_index_set_resolver (index, (GstIndexResolver) my_resolver, argv[2]); |
---|
49 | |
---|
50 | identity = (GstObject *) gst_element_factory_make ("identity", "element"); |
---|
51 | g_assert (identity); |
---|
52 | gst_index_get_writer_id (index, identity, &id); |
---|
53 | |
---|
54 | cur = 0; |
---|
55 | while (1) { |
---|
56 | gint fx; |
---|
57 | GstIndexEntry *entry = |
---|
58 | gst_index_get_assoc_entry (index, id, GST_INDEX_LOOKUP_AFTER, 0, |
---|
59 | GST_FORMAT_TIME, cur); |
---|
60 | |
---|
61 | if (!entry) |
---|
62 | break; |
---|
63 | |
---|
64 | g_print ("%x", GST_INDEX_ASSOC_FLAGS (entry)); |
---|
65 | for (fx = 0; fx < GST_INDEX_NASSOCS (entry); fx++) { |
---|
66 | GstFormat fmt = GST_INDEX_ASSOC_FORMAT (entry, fx); |
---|
67 | const GstFormatDefinition *def = gst_format_get_details (fmt); |
---|
68 | |
---|
69 | if (fmt == GST_FORMAT_TIME) { |
---|
70 | cur = GST_INDEX_ASSOC_VALUE (entry, fx) + 1; |
---|
71 | g_print (" time %.4f", |
---|
72 | GST_INDEX_ASSOC_VALUE (entry, fx) / (double) GST_SECOND); |
---|
73 | } else |
---|
74 | g_print (" %s %lld", def->nick, GST_INDEX_ASSOC_VALUE (entry, fx)); |
---|
75 | } |
---|
76 | g_print ("\n"); |
---|
77 | } |
---|
78 | |
---|
79 | return 0; |
---|
80 | } |
---|