gst-indent

Original commit message from CVS:
gst-indent
parent 1e83b097
2004-03-14 Thomas Vander Stichele <thomas at apestaart dot org>
* *.c, *.h: run gst-indent
2004-03-14 Benjamin Otte <otte@gnome.org> 2004-03-14 Benjamin Otte <otte@gnome.org>
* gst/modplug/gstmodplug.cc: * gst/modplug/gstmodplug.cc:
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* connection would use the I420 format (assuming Xv is enabled) */ * connection would use the I420 format (assuming Xv is enabled) */
static void static void
new_pad_func (GstElement *element, GstPad *newpad, gpointer data) new_pad_func (GstElement * element, GstPad * newpad, gpointer data)
{ {
GstElement *pipeline = (GstElement *) data; GstElement *pipeline = (GstElement *) data;
GstElement *queue = gst_bin_get_by_name (GST_BIN (pipeline), "queue"); GstElement *queue = gst_bin_get_by_name (GST_BIN (pipeline), "queue");
...@@ -19,7 +19,7 @@ new_pad_func (GstElement *element, GstPad *newpad, gpointer data) ...@@ -19,7 +19,7 @@ new_pad_func (GstElement *element, GstPad *newpad, gpointer data)
} }
gint gint
main (gint argc, gchar *argv[]) main (gint argc, gchar * argv[])
{ {
GstElement *pipeline; GstElement *pipeline;
GstElement *filesrc; GstElement *filesrc;
...@@ -44,7 +44,8 @@ main (gint argc, gchar *argv[]) ...@@ -44,7 +44,8 @@ main (gint argc, gchar *argv[])
g_object_set (G_OBJECT (filesrc), "location", argv[1], NULL); g_object_set (G_OBJECT (filesrc), "location", argv[1], NULL);
demux = gst_element_factory_make ("mpegdemux", "demux"); demux = gst_element_factory_make ("mpegdemux", "demux");
g_return_val_if_fail (demux, -1); g_return_val_if_fail (demux, -1);
g_signal_connect (G_OBJECT (demux), "new_pad", G_CALLBACK (new_pad_func), pipeline); g_signal_connect (G_OBJECT (demux), "new_pad", G_CALLBACK (new_pad_func),
pipeline);
thread = gst_thread_new ("thread"); thread = gst_thread_new ("thread");
queue = gst_element_factory_make ("queue", "queue"); queue = gst_element_factory_make ("queue", "queue");
...@@ -58,7 +59,7 @@ main (gint argc, gchar *argv[]) ...@@ -58,7 +59,7 @@ main (gint argc, gchar *argv[])
gst_bin_add (GST_BIN (pipeline), filesrc); gst_bin_add (GST_BIN (pipeline), filesrc);
gst_bin_add (GST_BIN (pipeline), demux); gst_bin_add (GST_BIN (pipeline), demux);
gst_bin_add (GST_BIN (thread), queue); gst_bin_add (GST_BIN (thread), queue);
gst_bin_add (GST_BIN (thread), mpeg2dec); gst_bin_add (GST_BIN (thread), mpeg2dec);
gst_bin_add (GST_BIN (thread), colorspace); gst_bin_add (GST_BIN (thread), colorspace);
...@@ -70,11 +71,9 @@ main (gint argc, gchar *argv[]) ...@@ -70,11 +71,9 @@ main (gint argc, gchar *argv[])
gst_element_link (mpeg2dec, "src", colorspace, "sink"); gst_element_link (mpeg2dec, "src", colorspace, "sink");
/* force RGB data passing between colorspace and xvideosink */ /* force RGB data passing between colorspace and xvideosink */
res = gst_element_link_filtered (colorspace, "src", xvideosink, "sink", res = gst_element_link_filtered (colorspace, "src", xvideosink, "sink",
GST_CAPS_NEW ( GST_CAPS_NEW ("filtercaps",
"filtercaps", "video/raw", "format", GST_PROPS_FOURCC (GST_STR_FOURCC ("RGB "))
"video/raw", ));
"format", GST_PROPS_FOURCC (GST_STR_FOURCC ("RGB "))
));
if (!res) { if (!res) {
g_print ("could not connect colorspace and xvideosink\n"); g_print ("could not connect colorspace and xvideosink\n");
return -1; return -1;
...@@ -83,7 +82,7 @@ main (gint argc, gchar *argv[]) ...@@ -83,7 +82,7 @@ main (gint argc, gchar *argv[])
gst_element_set_state (pipeline, GST_STATE_PLAYING); gst_element_set_state (pipeline, GST_STATE_PLAYING);
while (gst_bin_iterate (GST_BIN (pipeline))); while (gst_bin_iterate (GST_BIN (pipeline)));
gst_element_set_state (pipeline, GST_STATE_NULL); gst_element_set_state (pipeline, GST_STATE_NULL);
return 0; return 0;
......
This diff is collapsed.
...@@ -16,14 +16,14 @@ ...@@ -16,14 +16,14 @@
* Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA. * Boston, MA 02111-1307, USA.
*/ */
#include <gst/play/play.h> #include <gst/play/play.h>
static GMainLoop *loop = NULL; static GMainLoop *loop = NULL;
static gint64 length = 0; static gint64 length = 0;
static void static void
print_tag (const GstTagList *list, const gchar *tag, gpointer unused) print_tag (const GstTagList * list, const gchar * tag, gpointer unused)
{ {
gint i, count; gint i, count;
...@@ -31,14 +31,14 @@ print_tag (const GstTagList *list, const gchar *tag, gpointer unused) ...@@ -31,14 +31,14 @@ print_tag (const GstTagList *list, const gchar *tag, gpointer unused)
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
gchar *str; gchar *str;
if (gst_tag_get_type (tag) == G_TYPE_STRING) { if (gst_tag_get_type (tag) == G_TYPE_STRING) {
g_assert (gst_tag_list_get_string_index (list, tag, i, &str)); g_assert (gst_tag_list_get_string_index (list, tag, i, &str));
} else { } else {
str = g_strdup_value_contents ( str =
gst_tag_list_get_value_index (list, tag, i)); g_strdup_value_contents (gst_tag_list_get_value_index (list, tag, i));
} }
if (i == 0) { if (i == 0) {
g_print ("%15s: %s\n", gst_tag_get_nick (tag), str); g_print ("%15s: %s\n", gst_tag_get_nick (tag), str);
} else { } else {
...@@ -50,46 +50,46 @@ print_tag (const GstTagList *list, const gchar *tag, gpointer unused) ...@@ -50,46 +50,46 @@ print_tag (const GstTagList *list, const gchar *tag, gpointer unused)
} }
static void static void
got_found_tag (GstPlay *play,GstElement *source, GstTagList *tag_list) got_found_tag (GstPlay * play, GstElement * source, GstTagList * tag_list)
{ {
gst_tag_list_foreach (tag_list, print_tag, NULL); gst_tag_list_foreach (tag_list, print_tag, NULL);
} }
static void static void
got_time_tick (GstPlay *play, gint64 time_nanos) got_time_tick (GstPlay * play, gint64 time_nanos)
{ {
g_print ("time tick %f\n", time_nanos / (float) GST_SECOND); g_print ("time tick %f\n", time_nanos / (float) GST_SECOND);
} }
static void static void
got_stream_length (GstPlay *play, gint64 length_nanos) got_stream_length (GstPlay * play, gint64 length_nanos)
{ {
g_print ("got length %llu\n", length_nanos); g_print ("got length %llu\n", length_nanos);
length = length_nanos; length = length_nanos;
} }
static void static void
got_video_size (GstPlay *play, gint width, gint height) got_video_size (GstPlay * play, gint width, gint height)
{ {
g_print ("got video size %d, %d\n", width, height); g_print ("got video size %d, %d\n", width, height);
} }
static void static void
got_eos (GstPlay *play) got_eos (GstPlay * play)
{ {
g_print ("End Of Stream\n"); g_print ("End Of Stream\n");
g_main_loop_quit (loop); g_main_loop_quit (loop);
} }
static gboolean static gboolean
seek_timer (GstPlay *play) seek_timer (GstPlay * play)
{ {
gst_play_seek_to_time (play, length / 2); gst_play_seek_to_time (play, length / 2);
return FALSE; return FALSE;
} }
static gboolean static gboolean
idle_iterate (GstPlay *play) idle_iterate (GstPlay * play)
{ {
gst_bin_iterate (GST_BIN (play)); gst_bin_iterate (GST_BIN (play));
return (GST_STATE (GST_ELEMENT (play)) == GST_STATE_PLAYING); return (GST_STATE (GST_ELEMENT (play)) == GST_STATE_PLAYING);
...@@ -114,8 +114,7 @@ main (int argc, char *argv[]) ...@@ -114,8 +114,7 @@ main (int argc, char *argv[])
/* Creating the GstPlay object */ /* Creating the GstPlay object */
play = gst_play_new (&error); play = gst_play_new (&error);
if (error) if (error) {
{
g_print ("Error: could not create play object:\n%s\n", error->message); g_print ("Error: could not create play object:\n%s\n", error->message);
g_error_free (error); g_error_free (error);
return 1; return 1;
...@@ -140,17 +139,16 @@ main (int argc, char *argv[]) ...@@ -140,17 +139,16 @@ main (int argc, char *argv[])
/* gst_xml_write_file (GST_ELEMENT (play), stdout); */ /* gst_xml_write_file (GST_ELEMENT (play), stdout); */
g_signal_connect (G_OBJECT (play), "time_tick", g_signal_connect (G_OBJECT (play), "time_tick",
G_CALLBACK (got_time_tick), NULL); G_CALLBACK (got_time_tick), NULL);
g_signal_connect (G_OBJECT (play), "stream_length", g_signal_connect (G_OBJECT (play), "stream_length",
G_CALLBACK (got_stream_length), NULL); G_CALLBACK (got_stream_length), NULL);
g_signal_connect (G_OBJECT (play), "have_video_size", g_signal_connect (G_OBJECT (play), "have_video_size",
G_CALLBACK (got_video_size), NULL); G_CALLBACK (got_video_size), NULL);
g_signal_connect (G_OBJECT (play), "found_tag", g_signal_connect (G_OBJECT (play), "found_tag",
G_CALLBACK (got_found_tag), NULL); G_CALLBACK (got_found_tag), NULL);
g_signal_connect (G_OBJECT (play), "error", g_signal_connect (G_OBJECT (play), "error",
G_CALLBACK (gst_element_default_error), NULL); G_CALLBACK (gst_element_default_error), NULL);
g_signal_connect (G_OBJECT (play), "eos", g_signal_connect (G_OBJECT (play), "eos", G_CALLBACK (got_eos), NULL);
G_CALLBACK (got_eos), NULL);
/* Change state to PLAYING */ /* Change state to PLAYING */
gst_element_set_state (GST_ELEMENT (play), GST_STATE_PLAYING); gst_element_set_state (GST_ELEMENT (play), GST_STATE_PLAYING);
...@@ -163,9 +161,9 @@ main (int argc, char *argv[]) ...@@ -163,9 +161,9 @@ main (int argc, char *argv[])
g_print ("setting pipeline to ready\n"); g_print ("setting pipeline to ready\n");
gst_element_set_state (GST_ELEMENT (play), GST_STATE_READY); gst_element_set_state (GST_ELEMENT (play), GST_STATE_READY);
/* unref /* unref
gst_object_unref (GST_OBJECT (play)); */ gst_object_unref (GST_OBJECT (play)); */
exit (0); exit (0);
} }
...@@ -24,26 +24,26 @@ static gboolean verbose = FALSE; ...@@ -24,26 +24,26 @@ static gboolean verbose = FALSE;
static gboolean quiet = FALSE; static gboolean quiet = FALSE;
static void static void
entry_added (GstIndex *index, GstIndexEntry *entry) entry_added (GstIndex * index, GstIndexEntry * entry)
{ {
switch (entry->type) { switch (entry->type) {
case GST_INDEX_ENTRY_ID: case GST_INDEX_ENTRY_ID:
g_print ("id %d describes writer %s\n", entry->id, g_print ("id %d describes writer %s\n", entry->id,
GST_INDEX_ID_DESCRIPTION (entry)); GST_INDEX_ID_DESCRIPTION (entry));
break; break;
case GST_INDEX_ENTRY_FORMAT: case GST_INDEX_ENTRY_FORMAT:
g_print ("%d: registered format %d for %s\n", entry->id, g_print ("%d: registered format %d for %s\n", entry->id,
GST_INDEX_FORMAT_FORMAT (entry), GST_INDEX_FORMAT_FORMAT (entry), GST_INDEX_FORMAT_KEY (entry));
GST_INDEX_FORMAT_KEY (entry));
break; break;
case GST_INDEX_ENTRY_ASSOCIATION: case GST_INDEX_ENTRY_ASSOCIATION:
{ {
gint i; 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++) { for (i = 0; i < GST_INDEX_NASSOCS (entry); i++) {
g_print ("%d %lld ", GST_INDEX_ASSOC_FORMAT (entry, i), g_print ("%d %lld ", GST_INDEX_ASSOC_FORMAT (entry, i),
GST_INDEX_ASSOC_VALUE (entry, i)); GST_INDEX_ASSOC_VALUE (entry, i));
} }
g_print ("\n"); g_print ("\n");
break; break;
...@@ -55,15 +55,15 @@ entry_added (GstIndex *index, GstIndexEntry *entry) ...@@ -55,15 +55,15 @@ entry_added (GstIndex *index, GstIndexEntry *entry)
typedef struct typedef struct
{ {
const gchar *padname; const gchar *padname;
GstPad *target; GstPad *target;
GstElement *bin; GstElement *bin;
GstElement *pipeline; GstElement *pipeline;
GstIndex *index; GstIndex *index;
} dyn_link; } dyn_link;
static void static void
dynamic_link (GstPadTemplate *templ, GstPad *newpad, gpointer data) dynamic_link (GstPadTemplate * templ, GstPad * newpad, gpointer data)
{ {
dyn_link *link = (dyn_link *) data; dyn_link *link = (dyn_link *) data;
...@@ -77,27 +77,25 @@ dynamic_link (GstPadTemplate *templ, GstPad *newpad, gpointer data) ...@@ -77,27 +77,25 @@ dynamic_link (GstPadTemplate *templ, GstPad *newpad, gpointer data)
} }
static void static void
setup_dynamic_linking (GstElement *pipeline, setup_dynamic_linking (GstElement * pipeline,
GstElement *element, GstElement * element,
const gchar *padname, const gchar * padname, GstPad * target, GstElement * bin, GstIndex * index)
GstPad *target,
GstElement *bin,
GstIndex *index)
{ {
dyn_link *link; dyn_link *link;
link = g_new0 (dyn_link, 1); link = g_new0 (dyn_link, 1);
link->padname = g_strdup (padname); link->padname = g_strdup (padname);
link->target = target; link->target = target;
link->bin = bin; link->bin = bin;
link->pipeline = pipeline; link->pipeline = pipeline;
link->index = index; link->index = index;
g_signal_connect (G_OBJECT (element), "new_pad", G_CALLBACK (dynamic_link), link); g_signal_connect (G_OBJECT (element), "new_pad", G_CALLBACK (dynamic_link),
link);
} }
static GstElement* static GstElement *
make_mpeg_systems_pipeline (const gchar *path, GstIndex *index) make_mpeg_systems_pipeline (const gchar * path, GstIndex * index)
{ {
GstElement *pipeline; GstElement *pipeline;
GstElement *src, *demux; GstElement *src, *demux;
...@@ -117,12 +115,12 @@ make_mpeg_systems_pipeline (const gchar *path, GstIndex *index) ...@@ -117,12 +115,12 @@ make_mpeg_systems_pipeline (const gchar *path, GstIndex *index)
} }
gst_element_link_pads (src, "src", demux, "sink"); gst_element_link_pads (src, "src", demux, "sink");
return pipeline; return pipeline;
} }
static GstElement* static GstElement *
make_mpeg_decoder_pipeline (const gchar *path, GstIndex *index) make_mpeg_decoder_pipeline (const gchar * path, GstIndex * index)
{ {
GstElement *pipeline; GstElement *pipeline;
GstElement *src, *demux; GstElement *src, *demux;
...@@ -145,29 +143,27 @@ make_mpeg_decoder_pipeline (const gchar *path, GstIndex *index) ...@@ -145,29 +143,27 @@ make_mpeg_decoder_pipeline (const gchar *path, GstIndex *index)
video_decoder = gst_element_factory_make ("mpeg2dec", "video_decoder"); video_decoder = gst_element_factory_make ("mpeg2dec", "video_decoder");
gst_bin_add (GST_BIN (video_bin), video_decoder); gst_bin_add (GST_BIN (video_bin), video_decoder);
setup_dynamic_linking (pipeline, demux, "video_00", setup_dynamic_linking (pipeline, demux, "video_00",
gst_element_get_pad (video_decoder, "sink"), gst_element_get_pad (video_decoder, "sink"), video_bin, index);
video_bin, index);
audio_bin = gst_bin_new ("audio_bin"); audio_bin = gst_bin_new ("audio_bin");
audio_decoder = gst_element_factory_make ("mad", "audio_decoder"); audio_decoder = gst_element_factory_make ("mad", "audio_decoder");
setup_dynamic_linking (pipeline, demux, "audio_00", setup_dynamic_linking (pipeline, demux, "audio_00",
gst_element_get_pad (audio_decoder, "sink"), gst_element_get_pad (audio_decoder, "sink"), audio_bin, index);
audio_bin, index);
gst_bin_add (GST_BIN (audio_bin), audio_decoder); gst_bin_add (GST_BIN (audio_bin), audio_decoder);
if (index) { if (index) {
gst_element_set_index (pipeline, index); gst_element_set_index (pipeline, index);
} }
return pipeline; return pipeline;
} }
static void static void
print_progress (GstPad *pad) print_progress (GstPad * pad)
{ {
gint i = 0; gint i = 0;
gchar status[53]; gchar status[53];
...@@ -181,14 +177,14 @@ print_progress (GstPad *pad) ...@@ -181,14 +177,14 @@ print_progress (GstPad *pad)
format = GST_FORMAT_PERCENT; format = GST_FORMAT_PERCENT;
res = gst_pad_query (pad, GST_QUERY_POSITION, &format, &value); res = gst_pad_query (pad, GST_QUERY_POSITION, &format, &value);
if (res) { if (res) {
percent = value / (2 * GST_FORMAT_PERCENT_SCALE); percent = value / (2 * GST_FORMAT_PERCENT_SCALE);
} }
for (i = 0; i < percent; i++) { for (i = 0; i < percent; i++) {
status[i+1] = '='; status[i + 1] = '=';
} }
for (i = percent; i < 50; i++) { for (i = percent; i < 50; i++) {
status[i+1] = ' '; status[i + 1] = ' ';
} }
status[51] = '|'; status[51] = '|';
status[52] = 0; status[52] = 0;
...@@ -196,8 +192,8 @@ print_progress (GstPad *pad) ...@@ -196,8 +192,8 @@ print_progress (GstPad *pad)
g_print ("%s\r", status); g_print ("%s\r", status);
} }
gint gint
main (gint argc, gchar *argv[]) main (gint argc, gchar * argv[])
{ {
GstElement *pipeline; GstElement *pipeline;
GstElement *src; GstElement *src;
...@@ -208,27 +204,28 @@ main (gint argc, gchar *argv[]) ...@@ -208,27 +204,28 @@ main (gint argc, gchar *argv[])
gboolean res; gboolean res;
GstElement *sink; GstElement *sink;
struct poptOption options[] = { struct poptOption options[] = {
{ "verbose", 'v', POPT_ARG_NONE|POPT_ARGFLAG_STRIP, &verbose, 0, {"verbose", 'v', POPT_ARG_NONE | POPT_ARGFLAG_STRIP, &verbose, 0,
"Print index entries", NULL}, "Print index entries", NULL},
{ "quiet", 'q', POPT_ARG_NONE|POPT_ARGFLAG_STRIP, &quiet, 0, {"quiet", 'q', POPT_ARG_NONE | POPT_ARGFLAG_STRIP, &quiet, 0,
"don't print progress bar", NULL}, "don't print progress bar", NULL},
POPT_TABLEEND POPT_TABLEEND
}; };
if (!gst_init_check_with_popt_table (&argc, &argv, options) || argc < 3) { if (!gst_init_check_with_popt_table (&argc, &argv, options) || argc < 3) {
g_print ("usage: %s [-v] <type> <filename> \n" g_print ("usage: %s [-v] <type> <filename> \n"
" type can be: 0 mpeg_systems\n" " type can be: 0 mpeg_systems\n"
" 1 mpeg_decoder\n" " 1 mpeg_decoder\n"
" -v : report added index entries\n" " -v : report added index entries\n"
" -q : don't print progress\n" , argv[0]); " -q : don't print progress\n", argv[0]);
return -1; return -1;
} }
/* create index that elements can fill */ /* create index that elements can fill */
index = gst_index_factory_make ("memindex"); index = gst_index_factory_make ("memindex");
if (index) { if (index) {
if (verbose) if (verbose)
g_signal_connect (G_OBJECT (index), "entry_added", G_CALLBACK (entry_added), NULL); g_signal_connect (G_OBJECT (index), "entry_added",
G_CALLBACK (entry_added), NULL);
g_object_set (G_OBJECT (index), "resolver", 1, NULL); g_object_set (G_OBJECT (index), "resolver", 1, NULL);
} }
...@@ -247,10 +244,10 @@ main (gint argc, gchar *argv[]) ...@@ -247,10 +244,10 @@ main (gint argc, gchar *argv[])
} }
/* setup some default info/error handlers */ /* setup some default info/error handlers */
g_signal_connect (G_OBJECT (pipeline), "deep_notify", g_signal_connect (G_OBJECT (pipeline), "deep_notify",
G_CALLBACK (gst_element_default_deep_notify), NULL); G_CALLBACK (gst_element_default_deep_notify), NULL);
g_signal_connect (G_OBJECT (pipeline), "error", g_signal_connect (G_OBJECT (pipeline), "error",
G_CALLBACK (gst_element_default_error), NULL); G_CALLBACK (gst_element_default_error), NULL);
/* get a pad to perform progress reporting on */ /* get a pad to perform progress reporting on */
src = gst_bin_get_by_name (GST_BIN (pipeline), "src"); src = gst_bin_get_by_name (GST_BIN (pipeline), "src");
...@@ -259,7 +256,7 @@ main (gint argc, gchar *argv[]) ...@@ -259,7 +256,7 @@ main (gint argc, gchar *argv[])
/* prepare for iteration */ /* prepare for iteration */
gst_element_set_state (pipeline, GST_STATE_PLAYING); 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 */ /* run through the complete stream to let it generate an index */
while (gst_bin_iterate (GST_BIN (pipeline))) { while (gst_bin_iterate (GST_BIN (pipeline))) {
if (!quiet && (count % 1000 == 0)) { if (!quiet && (count % 1000 == 0)) {
...@@ -285,24 +282,23 @@ main (gint argc, gchar *argv[]) ...@@ -285,24 +282,23 @@ main (gint argc, gchar *argv[])
gint total_tm; gint total_tm;