[svn r689] Added new test case to TV Chain; put back the testing scripts configuration file.
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;
34 g_object_unref (data);
35 g_main_loop_quit (mainloop);
40 _mencoder_eos_cb (GMencoder *mencoder, gpointer data)
43 g_idle_add (_quit, mencoder);
48 _mencoder_error_cb (GMencoder *mencoder, const gchar* msg, gpointer data)
50 g_print ("Error: %s\n", msg);
51 g_idle_add (_quit, mencoder);
55 _io_channel_cb (GIOChannel *ch,
56 GIOCondition condition,
59 GString *cmd = g_string_new ("");
60 g_io_channel_read_line_string (ch, cmd, NULL, NULL);
62 if (strcmp (cmd->str, "PLAY\n") == 0) {
63 g_mencoder_play_stream (G_MENCODER (data));
64 } else if (strcmp (cmd->str, "PAUSE\n") == 0) {
65 g_mencoder_pause_stream (G_MENCODER (data));
66 } else if (strcmp (cmd->str, "STOP\n") == 0) {
67 g_mencoder_close_stream (G_MENCODER (data));
68 } else if (strcmp (cmd->str, "QUIT\n") == 0) {
69 g_mencoder_close_stream (G_MENCODER (data));
70 g_main_loop_quit (mainloop);
72 g_string_free (cmd, TRUE);
77 main (int argc, char** argv)
79 GMencoder *coder = NULL;
86 GOptionContext *context;
87 static const GOptionEntry options [] = {
88 {"input-files", 'i', 0, G_OPTION_ARG_STRING, &input_file, "Input File", NULL},
89 {"video-encode", 0, 0, G_OPTION_ARG_STRING, &video_encode, "GstElementName for used to video encode", NULL},
90 {"video-opts", 0, 0, G_OPTION_ARG_STRING, &video_opts, "Properties to set on video element", NULL},
91 {"video-fps", 0, 0, G_OPTION_ARG_DOUBLE, &video_fps, "Video FPS", NULL},
92 {"video-rate", 0, 0, G_OPTION_ARG_INT, &video_rate, "Video rate", NULL},
93 {"video-width", 0, 0, G_OPTION_ARG_INT, &video_width, "Video width", NULL},
94 {"video-height", 0, 0, G_OPTION_ARG_INT, &video_height, "Video height", NULL},
95 {"audio-encode", 0, 0, G_OPTION_ARG_STRING, &audio_encode, "GstElementName for use to audio encode", NULL},
96 {"audio-opts", 0, 0, G_OPTION_ARG_STRING, &audio_opts, "Properties to set on audio element", NULL},
97 {"audio-rate", 0, 0, G_OPTION_ARG_INT, &audio_rate, "Audio rate", NULL},
98 {"mux-element", 0, 0, G_OPTION_ARG_STRING, &mux_name, "GstElementName for use to mux file", NULL},
99 {"output-uri", 'o', 0, G_OPTION_ARG_STRING, &output_uri, "Uri to output", NULL},
104 g_thread_init (NULL);
105 mainloop = g_main_loop_new (NULL, FALSE);
107 g_set_prgname ("gmemcoder");
108 context = g_option_context_new (NULL);
109 g_option_context_set_help_enabled (context, TRUE);
110 g_option_context_add_main_entries (context, options, NULL);
111 g_option_context_add_group (context, gst_init_get_option_group ());
112 g_option_context_parse (context, &argc, &argv, NULL);
114 gst_init (&argc, &argv);
116 if (output_uri == NULL) {
117 g_print ("You need specify output-uri.\nTry --help for more information.\n");
121 if (input_file == NULL) {
122 g_print ("You need specify input file\nTry --help for more information.\n");
125 coder = g_mencoder_new ();
126 ch = g_io_channel_unix_new (0);
128 aopts = g_strsplit (audio_opts, ",", 0);
129 vopts = g_strsplit (video_opts, ",", 0);
131 g_mencoder_setup_stream (coder,
133 video_encode, vopts, video_fps, video_rate, video_width, video_height,
134 audio_encode, aopts, audio_rate,
137 files = g_strsplit (input_file, ",", 0);
138 for (i=0; i < g_strv_length (files); i++) {
139 if (!g_mencoder_append_uri (coder, files[i])) {
140 g_debug ("Invalid uri: %s", files[i]);
149 g_io_add_watch (ch, G_IO_IN, _io_channel_cb, coder);
151 g_signal_connect (G_OBJECT (coder),
153 G_CALLBACK (_mencoder_eos_cb),
156 g_signal_connect (G_OBJECT (coder),
158 G_CALLBACK (_mencoder_error_cb),
161 g_mencoder_play_stream (coder);
163 g_debug ("RUNNING..");
164 g_main_loop_run (mainloop);
166 g_object_unref (coder);