[svn r599] Automated test scripts in Python (it will runs over gcov, and generate reports on GMyth library running).
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* output_element = NULL;
26 static gchar* output_opts = NULL;
29 _mencoder_ready_cb (GMencoder *mencoder, gpointer data)
31 g_mencoder_play_stream (mencoder);
35 _mencoder_eos_cb (GMencoder *mencoder, gpointer data)
38 g_main_loop_quit ((GMainLoop *) data);
42 _mencoder_error_cb (GMencoder *mencoder, const gchar* msg, gpointer data)
44 g_print ("Error: %s\n", msg);
45 g_main_loop_quit ((GMainLoop *) data);
49 _io_channel_cb (GIOChannel *ch,
50 GIOCondition condition,
53 GString *cmd = g_string_new ("");
54 g_io_channel_read_line_string (ch, cmd, NULL, NULL);
56 if (strcmp (cmd->str, "PLAY\n") == 0) {
57 g_mencoder_play_stream (G_MENCODER (data));
58 } else if (strcmp (cmd->str, "PAUSE\n") == 0) {
59 g_mencoder_pause_stream (G_MENCODER (data));
60 } else if (strcmp (cmd->str, "STOP\n") == 0) {
61 g_mencoder_close_stream (G_MENCODER (data));
62 } else if (strcmp (cmd->str, "QUIT\n") == 0) {
63 g_mencoder_close_stream (G_MENCODER (data));
64 g_main_loop_quit (mainloop);
66 g_string_free (cmd, TRUE);
71 main (int argc, char** argv)
79 GOptionContext *context;
80 static const GOptionEntry options [] = {
81 {"input-file", 'i', 0, G_OPTION_ARG_STRING, &input_file, "Input File", NULL},
82 {"video-encode", 0, 0, G_OPTION_ARG_STRING, &video_encode, "GstElementName for used to video encode", NULL},
83 {"video-opts", 0, 0, G_OPTION_ARG_STRING, &video_opts, "Properties to set on video element", NULL},
84 {"video-fps", 0, 0, G_OPTION_ARG_DOUBLE, &video_fps, "Video FPS", NULL},
85 {"video-rate", 0, 0, G_OPTION_ARG_INT, &video_rate, "Video rate", NULL},
86 {"video-width", 0, 0, G_OPTION_ARG_INT, &video_width, "Video width", NULL},
87 {"video-height", 0, 0, G_OPTION_ARG_INT, &video_height, "Video height", NULL},
88 {"audio-encode", 0, 0, G_OPTION_ARG_STRING, &audio_encode, "GstElementName for use to audio encode", NULL},
89 {"audio-opts", 0, 0, G_OPTION_ARG_STRING, &audio_opts, "Properties to set on audio element", NULL},
90 {"audio-rate", 0, 0, G_OPTION_ARG_INT, &audio_rate, "Audio rate", NULL},
91 {"output-element", 0, 0, G_OPTION_ARG_STRING, &output_element,"GstElementName for use to output", NULL},
92 {"output-opts", 0, 0, G_OPTION_ARG_STRING, &output_opts, "Properties to set on output element", NULL},
99 //g_set_prgname ("gmemcoder");
100 context = g_option_context_new (NULL);
101 g_option_context_set_help_enabled (context, TRUE);
102 g_option_context_add_main_entries (context, options, NULL);
103 g_option_context_add_group (context, gst_init_get_option_group ());
104 g_option_context_parse (context, &argc, &argv, NULL);
106 gst_init (&argc, &argv);
108 if (output_element == NULL) {
109 g_print ("You need specify output-element name.\nTry --help for more information.\n");
113 if (input_file == NULL) {
114 g_print ("You need specify input file\nTry --help for more information.\n");
117 coder = g_mencoder_new ();
118 ch = g_io_channel_unix_new (0);
120 aopts = g_strsplit (audio_opts, ",", 0);
121 vopts = g_strsplit (video_opts, ",", 0);
122 oopts = g_strsplit (output_opts, ",", 0);
124 g_mencoder_setup_stream (coder,
126 video_encode, vopts, video_fps, video_rate, video_width, video_height,
127 audio_encode, aopts, audio_rate,
128 output_element, oopts);
134 mainloop = g_main_loop_new (NULL, FALSE);
135 g_io_add_watch (ch, G_IO_IN, _io_channel_cb, coder);
138 g_signal_connect (G_OBJECT (coder),
140 G_CALLBACK (_mencoder_ready_cb),
143 g_signal_connect (G_OBJECT (coder),
145 G_CALLBACK (_mencoder_eos_cb),
148 g_signal_connect (G_OBJECT (coder),
150 G_CALLBACK (_mencoder_error_cb),
153 g_main_loop_run (mainloop);