diff options
author | Thomas Vander Stichele <thomas@apestaart.org> | 2004-03-14 22:34:33 +0000 |
---|---|---|
committer | Thomas Vander Stichele <thomas@apestaart.org> | 2004-03-14 22:34:33 +0000 |
commit | 7a778ee4b7ec09a1f5b2185c9cceee3910dfbdf2 (patch) | |
tree | f863b467dea9559a6ec9c48affbfae11f8104164 /examples/indexing | |
parent | a19db4bbdc4a15ea0d8f4d28e9a1302c9c3d1657 (diff) | |
download | gst-plugins-bad-7a778ee4b7ec09a1f5b2185c9cceee3910dfbdf2.tar.gz gst-plugins-bad-7a778ee4b7ec09a1f5b2185c9cceee3910dfbdf2.tar.bz2 gst-plugins-bad-7a778ee4b7ec09a1f5b2185c9cceee3910dfbdf2.zip |
gst-indent
Original commit message from CVS:
gst-indent
Diffstat (limited to 'examples/indexing')
-rw-r--r-- | examples/indexing/indexmpeg.c | 141 |
1 files changed, 68 insertions, 73 deletions
diff --git a/examples/indexing/indexmpeg.c b/examples/indexing/indexmpeg.c index 29b89280..48a7ca23 100644 --- a/examples/indexing/indexmpeg.c +++ b/examples/indexing/indexmpeg.c @@ -24,26 +24,26 @@ static gboolean verbose = FALSE; static gboolean quiet = FALSE; static void -entry_added (GstIndex *index, GstIndexEntry *entry) +entry_added (GstIndex * index, GstIndexEntry * entry) { switch (entry->type) { case GST_INDEX_ENTRY_ID: - g_print ("id %d describes writer %s\n", entry->id, - GST_INDEX_ID_DESCRIPTION (entry)); + g_print ("id %d describes writer %s\n", entry->id, + GST_INDEX_ID_DESCRIPTION (entry)); break; case GST_INDEX_ENTRY_FORMAT: - g_print ("%d: registered format %d for %s\n", entry->id, - GST_INDEX_FORMAT_FORMAT (entry), - GST_INDEX_FORMAT_KEY (entry)); + g_print ("%d: registered format %d for %s\n", entry->id, + GST_INDEX_FORMAT_FORMAT (entry), GST_INDEX_FORMAT_KEY (entry)); break; case GST_INDEX_ENTRY_ASSOCIATION: { gint i; - g_print ("%p, %d: %08x ", entry, entry->id, GST_INDEX_ASSOC_FLAGS (entry)); + g_print ("%p, %d: %08x ", entry, entry->id, + GST_INDEX_ASSOC_FLAGS (entry)); for (i = 0; i < GST_INDEX_NASSOCS (entry); i++) { - g_print ("%d %lld ", GST_INDEX_ASSOC_FORMAT (entry, i), - GST_INDEX_ASSOC_VALUE (entry, i)); + g_print ("%d %lld ", GST_INDEX_ASSOC_FORMAT (entry, i), + GST_INDEX_ASSOC_VALUE (entry, i)); } g_print ("\n"); break; @@ -55,15 +55,15 @@ entry_added (GstIndex *index, GstIndexEntry *entry) typedef struct { - const gchar *padname; - GstPad *target; - GstElement *bin; - GstElement *pipeline; - GstIndex *index; + const gchar *padname; + GstPad *target; + GstElement *bin; + GstElement *pipeline; + GstIndex *index; } dyn_link; static void -dynamic_link (GstPadTemplate *templ, GstPad *newpad, gpointer data) +dynamic_link (GstPadTemplate * templ, GstPad * newpad, gpointer data) { dyn_link *link = (dyn_link *) data; @@ -77,27 +77,25 @@ dynamic_link (GstPadTemplate *templ, GstPad *newpad, gpointer data) } static void -setup_dynamic_linking (GstElement *pipeline, - GstElement *element, - const gchar *padname, - GstPad *target, - GstElement *bin, - GstIndex *index) +setup_dynamic_linking (GstElement * pipeline, + GstElement * element, + const gchar * padname, GstPad * target, GstElement * bin, GstIndex * index) { dyn_link *link; link = g_new0 (dyn_link, 1); - link->padname = g_strdup (padname); - link->target = target; - link->bin = bin; - link->pipeline = pipeline; - link->index = index; - - g_signal_connect (G_OBJECT (element), "new_pad", G_CALLBACK (dynamic_link), link); + link->padname = g_strdup (padname); + link->target = target; + link->bin = bin; + link->pipeline = pipeline; + link->index = index; + + g_signal_connect (G_OBJECT (element), "new_pad", G_CALLBACK (dynamic_link), + link); } -static GstElement* -make_mpeg_systems_pipeline (const gchar *path, GstIndex *index) +static GstElement * +make_mpeg_systems_pipeline (const gchar * path, GstIndex * index) { GstElement *pipeline; GstElement *src, *demux; @@ -117,12 +115,12 @@ make_mpeg_systems_pipeline (const gchar *path, GstIndex *index) } gst_element_link_pads (src, "src", demux, "sink"); - + return pipeline; } -static GstElement* -make_mpeg_decoder_pipeline (const gchar *path, GstIndex *index) +static GstElement * +make_mpeg_decoder_pipeline (const gchar * path, GstIndex * index) { GstElement *pipeline; GstElement *src, *demux; @@ -145,29 +143,27 @@ make_mpeg_decoder_pipeline (const gchar *path, GstIndex *index) video_decoder = gst_element_factory_make ("mpeg2dec", "video_decoder"); gst_bin_add (GST_BIN (video_bin), video_decoder); - - setup_dynamic_linking (pipeline, demux, "video_00", - gst_element_get_pad (video_decoder, "sink"), - video_bin, index); + + setup_dynamic_linking (pipeline, demux, "video_00", + gst_element_get_pad (video_decoder, "sink"), video_bin, index); audio_bin = gst_bin_new ("audio_bin"); audio_decoder = gst_element_factory_make ("mad", "audio_decoder"); - setup_dynamic_linking (pipeline, demux, "audio_00", - gst_element_get_pad (audio_decoder, "sink"), - audio_bin, index); + setup_dynamic_linking (pipeline, demux, "audio_00", + gst_element_get_pad (audio_decoder, "sink"), audio_bin, index); gst_bin_add (GST_BIN (audio_bin), audio_decoder); if (index) { gst_element_set_index (pipeline, index); } - + return pipeline; } static void -print_progress (GstPad *pad) +print_progress (GstPad * pad) { gint i = 0; gchar status[53]; @@ -181,14 +177,14 @@ print_progress (GstPad *pad) format = GST_FORMAT_PERCENT; res = gst_pad_query (pad, GST_QUERY_POSITION, &format, &value); if (res) { - percent = value / (2 * GST_FORMAT_PERCENT_SCALE); + percent = value / (2 * GST_FORMAT_PERCENT_SCALE); } - + for (i = 0; i < percent; i++) { - status[i+1] = '='; + status[i + 1] = '='; } for (i = percent; i < 50; i++) { - status[i+1] = ' '; + status[i + 1] = ' '; } status[51] = '|'; status[52] = 0; @@ -196,8 +192,8 @@ print_progress (GstPad *pad) g_print ("%s\r", status); } -gint -main (gint argc, gchar *argv[]) +gint +main (gint argc, gchar * argv[]) { GstElement *pipeline; GstElement *src; @@ -208,27 +204,28 @@ main (gint argc, gchar *argv[]) gboolean res; GstElement *sink; struct poptOption options[] = { - { "verbose", 'v', POPT_ARG_NONE|POPT_ARGFLAG_STRIP, &verbose, 0, - "Print index entries", NULL}, - { "quiet", 'q', POPT_ARG_NONE|POPT_ARGFLAG_STRIP, &quiet, 0, - "don't print progress bar", NULL}, - POPT_TABLEEND - }; + {"verbose", 'v', POPT_ARG_NONE | POPT_ARGFLAG_STRIP, &verbose, 0, + "Print index entries", NULL}, + {"quiet", 'q', POPT_ARG_NONE | POPT_ARGFLAG_STRIP, &quiet, 0, + "don't print progress bar", NULL}, + POPT_TABLEEND + }; if (!gst_init_check_with_popt_table (&argc, &argv, options) || argc < 3) { - g_print ("usage: %s [-v] <type> <filename> \n" - " type can be: 0 mpeg_systems\n" - " 1 mpeg_decoder\n" - " -v : report added index entries\n" - " -q : don't print progress\n" , argv[0]); + g_print ("usage: %s [-v] <type> <filename> \n" + " type can be: 0 mpeg_systems\n" + " 1 mpeg_decoder\n" + " -v : report added index entries\n" + " -q : don't print progress\n", argv[0]); return -1; } /* create index that elements can fill */ index = gst_index_factory_make ("memindex"); if (index) { - if (verbose) - g_signal_connect (G_OBJECT (index), "entry_added", G_CALLBACK (entry_added), NULL); + if (verbose) + g_signal_connect (G_OBJECT (index), "entry_added", + G_CALLBACK (entry_added), NULL); g_object_set (G_OBJECT (index), "resolver", 1, NULL); } @@ -247,10 +244,10 @@ main (gint argc, gchar *argv[]) } /* setup some default info/error handlers */ - g_signal_connect (G_OBJECT (pipeline), "deep_notify", - G_CALLBACK (gst_element_default_deep_notify), NULL); - g_signal_connect (G_OBJECT (pipeline), "error", - G_CALLBACK (gst_element_default_error), NULL); + g_signal_connect (G_OBJECT (pipeline), "deep_notify", + G_CALLBACK (gst_element_default_deep_notify), NULL); + g_signal_connect (G_OBJECT (pipeline), "error", + G_CALLBACK (gst_element_default_error), NULL); /* get a pad to perform progress reporting on */ src = gst_bin_get_by_name (GST_BIN (pipeline), "src"); @@ -259,7 +256,7 @@ main (gint argc, gchar *argv[]) /* prepare for iteration */ gst_element_set_state (pipeline, GST_STATE_PLAYING); - g_print ("indexing %s...\n", argv [2]); + g_print ("indexing %s...\n", argv[2]); /* run through the complete stream to let it generate an index */ while (gst_bin_iterate (GST_BIN (pipeline))) { if (!quiet && (count % 1000 == 0)) { @@ -285,24 +282,23 @@ main (gint argc, gchar *argv[]) gint total_tm; gst_index_get_writer_id (index, GST_OBJECT (src), &id); - + entry = gst_index_get_assoc_entry (index, id, GST_INDEX_LOOKUP_BEFORE, 0, - GST_FORMAT_TIME, G_MAXINT64); + GST_FORMAT_TIME, G_MAXINT64); g_assert (entry); gst_index_entry_assoc_map (entry, GST_FORMAT_TIME, &result); total_tm = result * 60 / GST_SECOND; g_print ("total time = %.2fs\n", total_tm / 60.0); } - + pad = gst_element_get_pad (src, "src"); sink = gst_element_factory_make ("fakesink", "sink"); gst_element_link_pads (src, "src", sink, "sink"); gst_bin_add (GST_BIN (pipeline), sink); - g_print ("seeking %s...\n", argv [2]); + g_print ("seeking %s...\n", argv[2]); event = gst_event_new_seek (GST_FORMAT_TIME | - GST_SEEK_METHOD_SET | - GST_SEEK_FLAG_FLUSH, 5 * GST_SECOND); + GST_SEEK_METHOD_SET | GST_SEEK_FLAG_FLUSH, 5 * GST_SECOND); res = gst_pad_send_event (pad, event); if (!res) { @@ -322,4 +318,3 @@ main (gint argc, gchar *argv[]) return 1; } - |