diff -r 3219eb5401c0 -r 7ad2e23504e6 gmyth-stream/gmemcoder/src/main.c --- a/gmyth-stream/gmemcoder/src/main.c Mon Apr 23 21:05:21 2007 +0100 +++ b/gmyth-stream/gmemcoder/src/main.c Fri May 04 23:03:05 2007 +0100 @@ -22,14 +22,9 @@ static gchar* audio_encode = NULL; static gchar* audio_opts = NULL; static double audio_rate = 0.0; -static gchar* output_element = NULL; -static gchar* output_opts = NULL; +static gchar* mux_name = NULL; +static gchar* output_uri = NULL; -static void -_mencoder_ready_cb (GMencoder *mencoder, gpointer data) -{ - g_mencoder_play_stream (mencoder); -} static void _mencoder_eos_cb (GMencoder *mencoder, gpointer data) @@ -70,15 +65,16 @@ int main (int argc, char** argv) { - GMencoder *coder; + GMencoder *coder = NULL; GIOChannel *ch; - gchar **oopts; gchar **vopts; gchar **aopts; + gchar **files; + gint i; GOptionContext *context; static const GOptionEntry options [] = { - {"input-file", 'i', 0, G_OPTION_ARG_STRING, &input_file, "Input File", NULL}, + {"input-files", 'i', 0, G_OPTION_ARG_STRING, &input_file, "Input File", NULL}, {"video-encode", 0, 0, G_OPTION_ARG_STRING, &video_encode, "GstElementName for used to video encode", NULL}, {"video-opts", 0, 0, G_OPTION_ARG_STRING, &video_opts, "Properties to set on video element", NULL}, {"video-fps", 0, 0, G_OPTION_ARG_DOUBLE, &video_fps, "Video FPS", NULL}, @@ -88,15 +84,16 @@ {"audio-encode", 0, 0, G_OPTION_ARG_STRING, &audio_encode, "GstElementName for use to audio encode", NULL}, {"audio-opts", 0, 0, G_OPTION_ARG_STRING, &audio_opts, "Properties to set on audio element", NULL}, {"audio-rate", 0, 0, G_OPTION_ARG_INT, &audio_rate, "Audio rate", NULL}, - {"output-element", 0, 0, G_OPTION_ARG_STRING, &output_element,"GstElementName for use to output", NULL}, - {"output-opts", 0, 0, G_OPTION_ARG_STRING, &output_opts, "Properties to set on output element", NULL}, + {"mux-element", 0, 0, G_OPTION_ARG_STRING, &mux_name, "GstElementName for use to mux file", NULL}, + {"output-uri", 'o', 0, G_OPTION_ARG_STRING, &output_uri, "Uri to output", NULL}, { NULL } }; g_type_init (); g_thread_init (NULL); + mainloop = g_main_loop_new (NULL, FALSE); - //g_set_prgname ("gmemcoder"); + g_set_prgname ("gmemcoder"); context = g_option_context_new (NULL); g_option_context_set_help_enabled (context, TRUE); g_option_context_add_main_entries (context, options, NULL); @@ -105,8 +102,8 @@ gst_init (&argc, &argv); - if (output_element == NULL) { - g_print ("You need specify output-element name.\nTry --help for more information.\n"); + if (output_uri == NULL) { + g_print ("You need specify output-uri.\nTry --help for more information.\n"); return 1; } @@ -119,27 +116,27 @@ aopts = g_strsplit (audio_opts, ",", 0); vopts = g_strsplit (video_opts, ",", 0); - oopts = g_strsplit (output_opts, ",", 0); g_mencoder_setup_stream (coder, - input_file, + mux_name, video_encode, vopts, video_fps, video_rate, video_width, video_height, audio_encode, aopts, audio_rate, - output_element, oopts); + output_uri); + files = g_strsplit (input_file, ",", 0); + for (i=0; i < g_strv_length (files); i++) { + if (!g_mencoder_append_uri (coder, files[i])) { + g_debug ("Invalid uri: %s", files[i]); + } + } + + g_strfreev (files); g_strfreev (aopts); g_strfreev (vopts); - g_strfreev (oopts); - mainloop = g_main_loop_new (NULL, FALSE); + g_io_add_watch (ch, G_IO_IN, _io_channel_cb, coder); - - g_signal_connect (G_OBJECT (coder), - "ready", - G_CALLBACK (_mencoder_ready_cb), - NULL); - g_signal_connect (G_OBJECT (coder), "eos", G_CALLBACK (_mencoder_eos_cb), @@ -150,7 +147,14 @@ G_CALLBACK (_mencoder_error_cb), mainloop); + g_mencoder_play_stream (coder); + + g_debug ("RUNNING.."); g_main_loop_run (mainloop); + g_mencoder_close_stream (coder); + g_object_unref (coder); + + return 0; }