1.1 --- a/gmyth-stream/gmemcoder/src/main.c Mon Apr 23 21:05:21 2007 +0100
1.2 +++ b/gmyth-stream/gmemcoder/src/main.c Tue May 01 22:19:50 2007 +0100
1.3 @@ -22,14 +22,9 @@
1.4 static gchar* audio_encode = NULL;
1.5 static gchar* audio_opts = NULL;
1.6 static double audio_rate = 0.0;
1.7 -static gchar* output_element = NULL;
1.8 -static gchar* output_opts = NULL;
1.9 +static gchar* mux_name = NULL;
1.10 +static gchar* output_uri = NULL;
1.11
1.12 -static void
1.13 -_mencoder_ready_cb (GMencoder *mencoder, gpointer data)
1.14 -{
1.15 - g_mencoder_play_stream (mencoder);
1.16 -}
1.17
1.18 static void
1.19 _mencoder_eos_cb (GMencoder *mencoder, gpointer data)
1.20 @@ -70,15 +65,16 @@
1.21 int
1.22 main (int argc, char** argv)
1.23 {
1.24 - GMencoder *coder;
1.25 + GMencoder *coder = NULL;
1.26 GIOChannel *ch;
1.27 - gchar **oopts;
1.28 gchar **vopts;
1.29 gchar **aopts;
1.30 + gchar **files;
1.31 + gint i;
1.32
1.33 GOptionContext *context;
1.34 static const GOptionEntry options [] = {
1.35 - {"input-file", 'i', 0, G_OPTION_ARG_STRING, &input_file, "Input File", NULL},
1.36 + {"input-files", 'i', 0, G_OPTION_ARG_STRING, &input_file, "Input File", NULL},
1.37 {"video-encode", 0, 0, G_OPTION_ARG_STRING, &video_encode, "GstElementName for used to video encode", NULL},
1.38 {"video-opts", 0, 0, G_OPTION_ARG_STRING, &video_opts, "Properties to set on video element", NULL},
1.39 {"video-fps", 0, 0, G_OPTION_ARG_DOUBLE, &video_fps, "Video FPS", NULL},
1.40 @@ -88,15 +84,16 @@
1.41 {"audio-encode", 0, 0, G_OPTION_ARG_STRING, &audio_encode, "GstElementName for use to audio encode", NULL},
1.42 {"audio-opts", 0, 0, G_OPTION_ARG_STRING, &audio_opts, "Properties to set on audio element", NULL},
1.43 {"audio-rate", 0, 0, G_OPTION_ARG_INT, &audio_rate, "Audio rate", NULL},
1.44 - {"output-element", 0, 0, G_OPTION_ARG_STRING, &output_element,"GstElementName for use to output", NULL},
1.45 - {"output-opts", 0, 0, G_OPTION_ARG_STRING, &output_opts, "Properties to set on output element", NULL},
1.46 + {"mux-element", 0, 0, G_OPTION_ARG_STRING, &mux_name, "GstElementName for use to mux file", NULL},
1.47 + {"output-uri", 'o', 0, G_OPTION_ARG_STRING, &output_uri, "Uri to output", NULL},
1.48 { NULL }
1.49 };
1.50
1.51 g_type_init ();
1.52 g_thread_init (NULL);
1.53 + mainloop = g_main_loop_new (NULL, FALSE);
1.54
1.55 - //g_set_prgname ("gmemcoder");
1.56 + g_set_prgname ("gmemcoder");
1.57 context = g_option_context_new (NULL);
1.58 g_option_context_set_help_enabled (context, TRUE);
1.59 g_option_context_add_main_entries (context, options, NULL);
1.60 @@ -105,8 +102,8 @@
1.61
1.62 gst_init (&argc, &argv);
1.63
1.64 - if (output_element == NULL) {
1.65 - g_print ("You need specify output-element name.\nTry --help for more information.\n");
1.66 + if (output_uri == NULL) {
1.67 + g_print ("You need specify output-uri.\nTry --help for more information.\n");
1.68 return 1;
1.69 }
1.70
1.71 @@ -119,27 +116,27 @@
1.72
1.73 aopts = g_strsplit (audio_opts, ",", 0);
1.74 vopts = g_strsplit (video_opts, ",", 0);
1.75 - oopts = g_strsplit (output_opts, ",", 0);
1.76
1.77 g_mencoder_setup_stream (coder,
1.78 - input_file,
1.79 + mux_name,
1.80 video_encode, vopts, video_fps, video_rate, video_width, video_height,
1.81 audio_encode, aopts, audio_rate,
1.82 - output_element, oopts);
1.83 + output_uri);
1.84
1.85 + files = g_strsplit (input_file, ",", 0);
1.86 + for (i=0; i < g_strv_length (files); i++) {
1.87 + if (!g_mencoder_append_uri (coder, files[i])) {
1.88 + g_debug ("Invalid uri: %s", files[i]);
1.89 + }
1.90 + }
1.91 +
1.92 + g_strfreev (files);
1.93 g_strfreev (aopts);
1.94 g_strfreev (vopts);
1.95 - g_strfreev (oopts);
1.96
1.97 - mainloop = g_main_loop_new (NULL, FALSE);
1.98 +
1.99 g_io_add_watch (ch, G_IO_IN, _io_channel_cb, coder);
1.100
1.101 -
1.102 - g_signal_connect (G_OBJECT (coder),
1.103 - "ready",
1.104 - G_CALLBACK (_mencoder_ready_cb),
1.105 - NULL);
1.106 -
1.107 g_signal_connect (G_OBJECT (coder),
1.108 "eos",
1.109 G_CALLBACK (_mencoder_eos_cb),
1.110 @@ -150,7 +147,14 @@
1.111 G_CALLBACK (_mencoder_error_cb),
1.112 mainloop);
1.113
1.114 + g_mencoder_play_stream (coder);
1.115 +
1.116 + g_debug ("RUNNING..");
1.117 g_main_loop_run (mainloop);
1.118
1.119 + g_mencoder_close_stream (coder);
1.120 + g_object_unref (coder);
1.121 +
1.122 +
1.123 return 0;
1.124 }