gmyth-stream/gmemcoder/src/main.c
branchtrunk
changeset 748 bf9dac4bdc5d
parent 691 726550e48c21
child 752 b7f71ba285da
     1.1 --- a/gmyth-stream/gmemcoder/src/main.c	Fri May 18 19:36:49 2007 +0100
     1.2 +++ b/gmyth-stream/gmemcoder/src/main.c	Tue Jun 12 22:13:46 2007 +0100
     1.3 @@ -4,7 +4,7 @@
     1.4  #include <string.h>
     1.5  
     1.6  #include <gst/gst.h>
     1.7 -#include <glib.h> 
     1.8 +#include <glib.h>
     1.9  
    1.10  #include "gmencoder.h"
    1.11  
    1.12 @@ -30,16 +30,16 @@
    1.13  static gboolean
    1.14  _quit (gpointer data)
    1.15  {
    1.16 -	g_object_unref (data);
    1.17 -	g_main_loop_quit (mainloop);
    1.18 -	return FALSE;
    1.19 +    g_object_unref (data);
    1.20 +    g_main_loop_quit (mainloop);
    1.21 +    return FALSE;
    1.22  }
    1.23  
    1.24  static void
    1.25  _mencoder_eos_cb (GMencoder *mencoder, gpointer data)
    1.26 -{		
    1.27 +{
    1.28      g_print ("EOS\n");
    1.29 -	g_idle_add (_quit, mencoder);
    1.30 +    g_idle_add (_quit, mencoder);
    1.31  }
    1.32  
    1.33  
    1.34 @@ -47,7 +47,7 @@
    1.35  _mencoder_error_cb (GMencoder *mencoder, const gchar* msg, gpointer data)
    1.36  {
    1.37      g_print ("Error: %s\n", msg);
    1.38 -	g_idle_add (_quit, mencoder);
    1.39 +    g_idle_add (_quit, mencoder);
    1.40  }
    1.41  
    1.42  static gboolean
    1.43 @@ -72,7 +72,7 @@
    1.44      return TRUE;
    1.45  }
    1.46  
    1.47 -int 
    1.48 +int
    1.49  main (int argc, char** argv)
    1.50  {
    1.51      GMencoder *coder = NULL;
    1.52 @@ -84,41 +84,67 @@
    1.53  
    1.54      GOptionContext *context;
    1.55      static const GOptionEntry options []  = {
    1.56 -        {"input-files",    'i', 0, G_OPTION_ARG_STRING,          &input_file,    "Input File", NULL},
    1.57 -        {"video-encode",    0, 0, G_OPTION_ARG_STRING,          &video_encode,  "GstElementName for used to video encode", NULL},
    1.58 -        {"video-opts",      0, 0, G_OPTION_ARG_STRING,          &video_opts,    "Properties to set on video element", NULL},
    1.59 -        {"video-fps",       0, 0, G_OPTION_ARG_DOUBLE,          &video_fps,     "Video FPS", NULL},
    1.60 -        {"video-rate",      0, 0, G_OPTION_ARG_INT,             &video_rate,    "Video rate", NULL},
    1.61 -        {"video-width",     0, 0, G_OPTION_ARG_INT,             &video_width,   "Video width", NULL},
    1.62 -        {"video-height",    0, 0, G_OPTION_ARG_INT,             &video_height,  "Video height", NULL},
    1.63 -        {"audio-encode",    0, 0, G_OPTION_ARG_STRING,          &audio_encode,  "GstElementName for use to audio encode", NULL},
    1.64 -        {"audio-opts",      0, 0, G_OPTION_ARG_STRING,          &audio_opts,    "Properties to set on audio element", NULL},
    1.65 -        {"audio-rate",      0, 0, G_OPTION_ARG_INT,             &audio_rate,    "Audio rate", NULL},
    1.66 -        {"mux-element",     0, 0, G_OPTION_ARG_STRING,          &mux_name,      "GstElementName for use to mux file", NULL},
    1.67 -        {"output-uri",    'o', 0, G_OPTION_ARG_STRING,          &output_uri,    "Uri to output", NULL},
    1.68 +        {"input-files", 'i', 0, G_OPTION_ARG_STRING, &input_file,
    1.69 +         "Input File", NULL},
    1.70 +
    1.71 +        {"video-encode", 0, 0, G_OPTION_ARG_STRING, &video_encode,
    1.72 +         "GstElementName for used to video encode", NULL},
    1.73 +
    1.74 +        {"video-opts", 0, 0, G_OPTION_ARG_STRING, &video_opts,
    1.75 +         "Properties to set on video element", NULL},
    1.76 +
    1.77 +        {"video-fps", 0, 0, G_OPTION_ARG_DOUBLE, &video_fps,
    1.78 +         "Video FPS", NULL},
    1.79 +
    1.80 +        {"video-rate", 0, 0, G_OPTION_ARG_INT, &video_rate,
    1.81 +         "Video rate", NULL},
    1.82 +
    1.83 +        {"video-width", 0, 0, G_OPTION_ARG_INT, &video_width,
    1.84 +         "Video width", NULL},
    1.85 +
    1.86 +        {"video-height", 0, 0, G_OPTION_ARG_INT, &video_height,
    1.87 +         "Video height", NULL},
    1.88 +
    1.89 +        {"audio-encode", 0, 0, G_OPTION_ARG_STRING, &audio_encode,
    1.90 +         "GstElementName for use to audio encode", NULL},
    1.91 +
    1.92 +        {"audio-opts", 0, 0, G_OPTION_ARG_STRING, &audio_opts,
    1.93 +         "Properties to set on audio element", NULL},
    1.94 +
    1.95 +        {"audio-rate", 0, 0, G_OPTION_ARG_INT, &audio_rate,
    1.96 +         "Audio rate", NULL},
    1.97 +
    1.98 +        {"mux-element", 0, 0, G_OPTION_ARG_STRING, &mux_name,
    1.99 +         "GstElementName for use to mux file", NULL},
   1.100 +
   1.101 +        {"output-uri", 'o', 0, G_OPTION_ARG_STRING, &output_uri,
   1.102 +         "Uri to output", NULL},
   1.103 +
   1.104          { NULL }
   1.105      };
   1.106  
   1.107 -	g_type_init ();
   1.108 +    g_type_init ();
   1.109      g_thread_init (NULL);
   1.110 -	mainloop = g_main_loop_new (NULL, FALSE);
   1.111 +    mainloop = g_main_loop_new (NULL, FALSE);
   1.112  
   1.113 -	g_set_prgname ("gmemcoder");
   1.114 +    g_set_prgname ("gmemcoder");
   1.115      context = g_option_context_new (NULL);
   1.116      g_option_context_set_help_enabled (context, TRUE);
   1.117      g_option_context_add_main_entries (context, options, NULL);
   1.118      g_option_context_add_group (context, gst_init_get_option_group ());
   1.119      g_option_context_parse (context, &argc, &argv, NULL);
   1.120  
   1.121 -	gst_init (&argc, &argv);
   1.122 +    gst_init (&argc, &argv);
   1.123  
   1.124      if (output_uri == NULL) {
   1.125 -        g_print ("You need specify output-uri.\nTry --help for more information.\n");
   1.126 -        return 1; 
   1.127 +        g_print ("You need to specify output-uri.\nTry --help "
   1.128 +                 "for more information.\n");
   1.129 +        return 1;
   1.130      }
   1.131  
   1.132      if (input_file == NULL) {
   1.133 -        g_print ("You need specify input file\nTry --help for more information.\n");
   1.134 +        g_print ("You need to specify input file\nTry --help "
   1.135 +                 "for more information.\n");
   1.136      }
   1.137  
   1.138      coder = g_mencoder_new ();
   1.139 @@ -127,42 +153,42 @@
   1.140      aopts = g_strsplit (audio_opts, ",", 0);
   1.141      vopts = g_strsplit (video_opts, ",", 0);
   1.142  
   1.143 -    g_mencoder_setup_stream (coder, 
   1.144 -            mux_name,
   1.145 -            video_encode, vopts, video_fps, video_rate, video_width, video_height,
   1.146 -            audio_encode, aopts, audio_rate, 
   1.147 -            output_uri);
   1.148 +    g_mencoder_setup_stream (coder, mux_name,
   1.149 +                             video_encode, vopts, video_fps,
   1.150 +                             video_rate, video_width, video_height,
   1.151 +                             audio_encode, aopts, audio_rate,
   1.152 +                             output_uri);
   1.153  
   1.154      files = g_strsplit (input_file, ",", 0);
   1.155      for (i=0; i < g_strv_length (files); i++) {
   1.156          if (!g_mencoder_append_uri (coder, files[i])) {
   1.157              g_debug ("Invalid uri: %s", files[i]);
   1.158 -        } 
   1.159 +        }
   1.160      }
   1.161 -                
   1.162 +
   1.163      g_strfreev (files);
   1.164      g_strfreev (aopts);
   1.165      g_strfreev (vopts);
   1.166  
   1.167  
   1.168 -    g_io_add_watch (ch, G_IO_IN, _io_channel_cb, coder);    
   1.169 +    g_io_add_watch (ch, G_IO_IN, _io_channel_cb, coder);
   1.170  
   1.171      g_signal_connect (G_OBJECT (coder),
   1.172 -                        "eos",
   1.173 -                        G_CALLBACK (_mencoder_eos_cb),
   1.174 -                        mainloop);
   1.175 +                      "eos",
   1.176 +                      G_CALLBACK (_mencoder_eos_cb),
   1.177 +                      mainloop);
   1.178  
   1.179      g_signal_connect (G_OBJECT (coder),
   1.180 -                        "error",
   1.181 -                        G_CALLBACK (_mencoder_error_cb),
   1.182 -                        mainloop);
   1.183 +                      "error",
   1.184 +                      G_CALLBACK (_mencoder_error_cb),
   1.185 +                      mainloop);
   1.186  
   1.187      g_mencoder_play_stream (coder);
   1.188  
   1.189      g_debug ("RUNNING..");
   1.190 -	g_main_loop_run (mainloop);
   1.191 -	g_debug ("DONE");
   1.192 +    g_main_loop_run (mainloop);
   1.193 +    g_debug ("DONE");
   1.194      g_object_unref (coder);
   1.195  
   1.196 -	return 0;
   1.197 +    return 0;
   1.198  }