[svn r645] Added checkings to the Gnu coverage and profiling tools.
13 static GMainLoop *mainloop = NULL;
15 static gchar* input_file = NULL;
16 static gchar* video_encode = NULL;
17 static gchar* video_opts = NULL;
18 static gdouble video_fps = 0.0;
19 static gint video_rate = 0;
20 static gint video_width = 0;
21 static gint video_height = 0;
22 static gchar* audio_encode = NULL;
23 static gchar* audio_opts = NULL;
24 static double audio_rate = 0.0;
25 static gchar* mux_name = NULL;
26 static gchar* output_uri = NULL;
30 _mencoder_eos_cb (GMencoder *mencoder, gpointer data)
33 g_main_loop_quit ((GMainLoop *) data);
37 _mencoder_error_cb (GMencoder *mencoder, const gchar* msg, gpointer data)
39 g_print ("Error: %s\n", msg);
40 g_mencoder_close_stream (mencoder);
41 g_main_loop_quit ((GMainLoop *) data);
45 _io_channel_cb (GIOChannel *ch,
46 GIOCondition condition,
49 GString *cmd = g_string_new ("");
50 g_io_channel_read_line_string (ch, cmd, NULL, NULL);
52 if (strcmp (cmd->str, "PLAY\n") == 0) {
53 g_mencoder_play_stream (G_MENCODER (data));
54 } else if (strcmp (cmd->str, "PAUSE\n") == 0) {
55 g_mencoder_pause_stream (G_MENCODER (data));
56 } else if (strcmp (cmd->str, "STOP\n") == 0) {
57 g_mencoder_close_stream (G_MENCODER (data));
58 } else if (strcmp (cmd->str, "QUIT\n") == 0) {
59 g_mencoder_close_stream (G_MENCODER (data));
60 g_main_loop_quit (mainloop);
62 g_string_free (cmd, TRUE);
67 main (int argc, char** argv)
69 GMencoder *coder = NULL;
76 GOptionContext *context;
77 static const GOptionEntry options [] = {
78 {"input-files", 'i', 0, G_OPTION_ARG_STRING, &input_file, "Input File", NULL},
79 {"video-encode", 0, 0, G_OPTION_ARG_STRING, &video_encode, "GstElementName for used to video encode", NULL},
80 {"video-opts", 0, 0, G_OPTION_ARG_STRING, &video_opts, "Properties to set on video element", NULL},
81 {"video-fps", 0, 0, G_OPTION_ARG_DOUBLE, &video_fps, "Video FPS", NULL},
82 {"video-rate", 0, 0, G_OPTION_ARG_INT, &video_rate, "Video rate", NULL},
83 {"video-width", 0, 0, G_OPTION_ARG_INT, &video_width, "Video width", NULL},
84 {"video-height", 0, 0, G_OPTION_ARG_INT, &video_height, "Video height", NULL},
85 {"audio-encode", 0, 0, G_OPTION_ARG_STRING, &audio_encode, "GstElementName for use to audio encode", NULL},
86 {"audio-opts", 0, 0, G_OPTION_ARG_STRING, &audio_opts, "Properties to set on audio element", NULL},
87 {"audio-rate", 0, 0, G_OPTION_ARG_INT, &audio_rate, "Audio rate", NULL},
88 {"mux-element", 0, 0, G_OPTION_ARG_STRING, &mux_name, "GstElementName for use to mux file", NULL},
89 {"output-uri", 'o', 0, G_OPTION_ARG_STRING, &output_uri, "Uri to output", NULL},
95 mainloop = g_main_loop_new (NULL, FALSE);
97 g_set_prgname ("gmemcoder");
98 context = g_option_context_new (NULL);
99 g_option_context_set_help_enabled (context, TRUE);
100 g_option_context_add_main_entries (context, options, NULL);
101 g_option_context_add_group (context, gst_init_get_option_group ());
102 g_option_context_parse (context, &argc, &argv, NULL);
104 gst_init (&argc, &argv);
106 if (output_uri == NULL) {
107 g_print ("You need specify output-uri.\nTry --help for more information.\n");
111 if (input_file == NULL) {
112 g_print ("You need specify input file\nTry --help for more information.\n");
115 coder = g_mencoder_new ();
116 ch = g_io_channel_unix_new (0);
118 aopts = g_strsplit (audio_opts, ",", 0);
119 vopts = g_strsplit (video_opts, ",", 0);
121 g_mencoder_setup_stream (coder,
123 video_encode, vopts, video_fps, video_rate, video_width, video_height,
124 audio_encode, aopts, audio_rate,
127 files = g_strsplit (input_file, ",", 0);
128 for (i=0; i < g_strv_length (files); i++) {
129 if (!g_mencoder_append_uri (coder, files[i])) {
130 g_debug ("Invalid uri: %s", files[i]);
139 g_io_add_watch (ch, G_IO_IN, _io_channel_cb, coder);
141 g_signal_connect (G_OBJECT (coder),
143 G_CALLBACK (_mencoder_eos_cb),
146 g_signal_connect (G_OBJECT (coder),
148 G_CALLBACK (_mencoder_error_cb),
151 g_mencoder_play_stream (coder);
153 g_debug ("RUNNING..");
154 g_main_loop_run (mainloop);
156 g_object_unref (coder);