tools: Count argc after parsing GOption on Windows
[platform/upstream/gstreamer.git] / subprojects / gst-plugins-bad / tools / gst-transcoder.c
index a1ba29c..b7a7673 100644 (file)
@@ -362,12 +362,21 @@ real_main (int argc, char *argv[])
   g_option_context_add_main_entries (ctx, options, NULL);
   g_option_context_add_group (ctx, gst_init_get_option_group ());
 
-  if (!g_option_context_parse (ctx, &argc, &argv, &err)) {
+#ifdef G_OS_WIN32
+  if (!g_option_context_parse_strv (ctx, &argv, &err))
+#else
+  if (!g_option_context_parse (ctx, &argc, &argv, &err))
+#endif
+  {
     g_print ("Error initializing: %s\n", GST_STR_NULL (err->message));
     g_clear_error (&err);
     g_option_context_free (ctx);
     return 1;
   }
+#ifdef G_OS_WIN32
+  argc = g_strv_length (argv);
+#endif
+
   gst_pb_utils_init ();
 
   if (settings.list) {
@@ -468,9 +477,21 @@ no_extension:
 int
 main (int argc, char *argv[])
 {
+  int ret;
+
+#ifdef G_OS_WIN32
+  argv = g_win32_get_command_line ();
+#endif
+
 #if defined(__APPLE__) && TARGET_OS_MAC && !TARGET_OS_IPHONE
-  return gst_macos_main ((GstMainFunc) real_main, argc, argv, NULL);
+  ret = gst_macos_main ((GstMainFunc) real_main, argc, argv, NULL);
 #else
-  return real_main (argc, argv);
+  ret = real_main (argc, argv);
 #endif
+
+#ifdef G_OS_WIN32
+  g_strfreev (argv);
+#endif
+
+  return ret;
 }