static gboolean
parse_options (int *argc, char *argv[])
{
  GOptionContext *ctx;
  gboolean success;
  GError *error = NULL;

  ctx = g_option_context_new (" - encoder test options");
  if (!ctx)
    return FALSE;

  g_option_context_add_group (ctx, gst_init_get_option_group ());
  g_option_context_add_main_entries (ctx, g_options, NULL);
  g_option_context_set_help_enabled (ctx, TRUE);
  success = g_option_context_parse (ctx, argc, &argv, &error);
  if (!success) {
    g_printerr ("Option parsing failed: %s\n", error->message);
    g_error_free (error);
    goto bail;
  }

  if (!g_codec_str)
    g_codec_str = g_strdup ("h264");
  if (!g_output_file_name)
    g_output_file_name = generate_output_filename (g_codec_str);

bail:
  g_option_context_free (ctx);
  return success;
}
int main (int argc, char **argv)
{
	GOptionGroup *options;
	GOptionContext *context;
	GError *error = NULL;
	GMainLoop *loop;
	GstElement *play;

	bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
	textdomain (GETTEXT_PACKAGE);

	g_set_application_name (_("Audio Preview"));
	g_setenv("PULSE_PROP_application.icon_name", "totem", TRUE);
	g_setenv("PULSE_PROP_media.role", "music", TRUE);

	context = g_option_context_new ("Plays audio passed on the standard input or the filename passed on the command-line");
	options = gst_init_get_option_group ();
	g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
	g_option_context_add_group (context, options);

	if (g_option_context_parse (context, &argc, &argv, &error) == FALSE) {
		g_print ("couldn't parse command-line options: %s\n", error->message);
		g_error_free (error);
		return 1;
	}

	if (g_fatal_warnings) {
		GLogLevelFlags fatal_mask;

		fatal_mask = g_log_set_always_fatal (G_LOG_FATAL_MASK);
		fatal_mask |= G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL;
		g_log_set_always_fatal (fatal_mask);
	}

	if (show_mimetype == TRUE) {
		print_mimetypes ();
		return 0;
	}

	if (filenames != NULL && g_strv_length (filenames) != 1) {
		char *help;
		help = g_option_context_get_help (context, FALSE, NULL);
		g_print ("%s", help);
		g_free (help);
		return 1;
	}

	play = gst_element_factory_make ("playbin", "play");
	setup_play (play);
	setup_filename (play);
	setup_errors (play);
	totem_resources_monitor_start (NULL, -1);
	gst_element_set_state (play, GST_STATE_PLAYING);

	loop = g_main_loop_new (NULL, TRUE);
	g_main_loop_run (loop);

	return 0;
}
Exemple #3
0
int
main (int   argc,
      char *argv[])
{
  gboolean silent = FALSE;
  gchar *savefile = NULL;
  GOptionContext *ctx;
  GError *err = NULL;
  GOptionEntry entries[] = {
    { "silent", 's', 0, G_OPTION_ARG_NONE, &silent,
      "do not output status information", NULL },
    { "output", 'o', 0, G_OPTION_ARG_STRING, &savefile,
      "save xml representation of pipeline to FILE and exit", "FILE" },
    { NULL }
  };

  ctx = g_option_context_new ("- Your application");
  g_option_context_add_main_entries (ctx, entries, NULL);
  g_option_context_add_group (ctx, gst_init_get_option_group ());
  if (!g_option_context_parse (ctx, &argc, &argv, &err)) {
    g_print ("Failed to initialize: %s\n", err->message);
    g_error_free (err);
    return 1;
  }

  printf ("Run me with --help to see the Application options appended.\n");

  return 0;
}
int
main (int argc, char **argv)
{
  static const GOptionEntry test_goptions[] = {
    {G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &filenames, NULL},
    {NULL, '\0', 0, 0, NULL, NULL, NULL}
  };
  GOptionContext *ctx;
  GError *opt_err = NULL;

  gtk_init (&argc, &argv);

  /* command line option parsing */
  ctx = g_option_context_new (" VIDEOFILE");
  g_option_context_add_group (ctx, gst_init_get_option_group ());
  g_option_context_add_main_entries (ctx, test_goptions, NULL);

  if (!g_option_context_parse (ctx, &argc, &argv, &opt_err)) {
    g_error ("Error parsing command line options: %s", opt_err->message);
    return -1;
  }

  if (filenames == NULL || filenames[0] == NULL || filenames[0][0] == '\0') {
    g_printerr ("Please specify a path to a video file\n\n");
    return -1;
  }

  run_gui (filenames[0]);

  g_free (filenames);
  g_option_context_free (ctx);

  return 0;
}
Exemple #5
0
static GOptionContext *
gth_application_create_option_context (void)
{
	GOptionContext *context;
	static gsize    initialized = FALSE;

	context = g_option_context_new (N_("— Image browser and viewer"));
	g_option_context_set_translation_domain (context, GETTEXT_PACKAGE);
	g_option_context_set_ignore_unknown_options (context, TRUE);
	g_option_context_add_main_entries (context, options, GETTEXT_PACKAGE);

	if (g_once_init_enter (&initialized)) {
		g_option_context_add_group (context, gtk_get_option_group (TRUE));
#ifdef HAVE_CLUTTER
		g_option_context_add_group (context, clutter_get_option_group_without_init ());
		g_option_context_add_group (context, gtk_clutter_get_option_group ());
#endif
#ifdef HAVE_GSTREAMER
		g_option_context_add_group (context, gst_init_get_option_group ());
#endif
		g_once_init_leave (&initialized, TRUE);
	}

	return context;
}
Exemple #6
0
gboolean
video_output_init (int *argc, char *argv[], GOptionEntry * options)
{
  GOptionContext *ctx;
  gboolean success;

#if !GLIB_CHECK_VERSION(2,31,0)
  if (!g_thread_supported ())
    g_thread_init (NULL);
#endif

  ctx = g_option_context_new ("- test options");
  if (!ctx)
    return FALSE;

  g_option_context_add_group (ctx, gst_init_get_option_group ());
  g_option_context_add_main_entries (ctx, g_options, NULL);
  if (options)
    g_option_context_add_main_entries (ctx, options, NULL);
  success = g_option_context_parse (ctx, argc, &argv, NULL);
  g_option_context_free (ctx);

  if (g_list_outputs) {
    list_outputs ();
    exit (0);
  }
  return success;
}
Exemple #7
0
/**
 * games_sound_add_option_group:
 * @context: a #GOptionContext
 *
 * Adds the GStreamer option group to @context.
 */
void
games_sound_add_option_group (GOptionContext *context)
{
#ifdef HAVE_GSTREAMER
  g_option_context_add_group (context, gst_init_get_option_group ());
#endif /* HAVE_GSTREAMER */
}
int
main (int argc, char *argv[])
{
  GMainLoop *loop;
  GstRTSPServer *server;
  GstRTSPMountPoints *mounts;
  GstRTSPMediaFactory *factory;
  GOptionContext *optctx;
  GError *error = NULL;

  optctx = g_option_context_new ("<launch line> - Test RTSP Server, Launch\n\n"
      "Example: \"( decodebin name=depay0 ! autovideosink )\"");
  g_option_context_add_main_entries (optctx, entries, NULL);
  g_option_context_add_group (optctx, gst_init_get_option_group ());
  if (!g_option_context_parse (optctx, &argc, &argv, &error)) {
    g_printerr ("Error parsing options: %s\n", error->message);
    return -1;
  }

  if (argc < 2) {
    g_print ("%s\n", g_option_context_get_help (optctx, TRUE, NULL));
    return 1;
  }
  g_option_context_free (optctx);

  loop = g_main_loop_new (NULL, FALSE);

  /* create a server instance */
  server = gst_rtsp_server_new ();

  /* get the mount points for this server, every server has a default object
   * that be used to map uri mount points to media factories */
  mounts = gst_rtsp_server_get_mount_points (server);

  /* make a media factory for a test stream. The default media factory can use
   * gst-launch syntax to create pipelines.
   * any launch line works as long as it contains elements named depay%d. Each
   * element with depay%d names will be a stream */
  factory = gst_rtsp_media_factory_new ();
  gst_rtsp_media_factory_set_transport_mode (factory,
      GST_RTSP_TRANSPORT_MODE_RECORD);
  gst_rtsp_media_factory_set_launch (factory, argv[1]);
  gst_rtsp_media_factory_set_latency (factory, 2000);

  /* attach the test factory to the /test url */
  gst_rtsp_mount_points_add_factory (mounts, "/test", factory);

  /* don't need the ref to the mapper anymore */
  g_object_unref (mounts);

  /* attach the server to the default maincontext */
  gst_rtsp_server_attach (server, NULL);

  /* start serving */
  g_print ("stream ready at rtsp://127.0.0.1:%s/test\n", port);
  g_main_loop_run (loop);

  return 0;
}
int
main (int argc, char *argv[])
{
  GstElementFactory *factory;
  GOptionEntry options[] = {
    GST_TOOLS_GOPTION_VERSION,
    {NULL}
  };
  GOptionContext *ctx;
  GError *err = NULL;

  setlocale (LC_ALL, "");

#if !GLIB_CHECK_VERSION (2, 31, 0)
  g_thread_init (NULL);
#endif

  gst_tools_set_prgname ("gst-xmlinspect");

  ctx = g_option_context_new ("[ELEMENT-NAME]");
  g_option_context_add_main_entries (ctx, options, GETTEXT_PACKAGE);
  g_option_context_add_group (ctx, gst_init_get_option_group ());
  if (!g_option_context_parse (ctx, &argc, &argv, &err)) {
    g_print ("Error initializing: %s\n", err->message);
    exit (1);
  }
  g_option_context_free (ctx);

  gst_tools_print_version ("gst-xmlinspect");

  /* if no arguments, print out all elements */
  if (argc == 1) {
    GList *features, *f;

    features = gst_registry_get_feature_list (gst_registry_get_default (),
        GST_TYPE_ELEMENT_FACTORY);

    PUT_STRING (0, "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>");

    for (f = features; f != NULL; f = f->next)
      print_element_info (GST_ELEMENT_FACTORY (f->data));

    gst_plugin_feature_list_free (features);
    return 0;
  }

  /* else we try to get a factory */
  factory = gst_element_factory_find (argv[1]);

  /* if there's a factory, print out the info */
  if (factory) {
    PUT_STRING (0, "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>");
    return print_element_info (factory);
  }

  /* otherwise, error out */
  g_printerr ("no such element '%s'\n", argv[1]);
  return -1;
}
int
main (int argc, char **argv)
{
  GError *err = NULL;
  GOptionContext *ctx;
  GESPipeline *pipeline;
  GMainLoop *mainloop;
  gdouble duration = DEFAULT_DURATION;
  char *path = NULL, *text;
  guint64 color;
  gdouble xpos = DEFAULT_POS, ypos = DEFAULT_POS;

  GOptionEntry options[] = {
    {"duration", 'd', 0, G_OPTION_ARG_DOUBLE, &duration,
        "duration of segment", "seconds"},
    {"path", 'p', 0, G_OPTION_ARG_STRING, &path,
        "path to file", "path"},
    {"text", 't', 0, G_OPTION_ARG_STRING, &text,
        "text to render", "text"},
    {"color", 'c', 0, G_OPTION_ARG_INT64, &color,
        "color of the text", "color"},
    {"xpos", 'x', 0, G_OPTION_ARG_DOUBLE, &xpos,
        "horizontal position of the text", "color"},
    {"ypos", 'y', 0, G_OPTION_ARG_DOUBLE, &ypos,
        "vertical position of the text", "color"},
    {NULL}
  };

  ctx = g_option_context_new ("- file segment playback with text overlay");
  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)) {
    g_print ("Error initializing %s\n", err->message);
    exit (1);
  }

  if (argc > 1) {
    g_print ("%s", g_option_context_get_help (ctx, TRUE, NULL));
    exit (0);
  }

  g_option_context_free (ctx);

  ges_init ();

  if (path == NULL)
    g_error ("Must specify --path=/path/to/media/file option\n");

  pipeline = make_timeline (path, duration, text, color, xpos, ypos);

  mainloop = g_main_loop_new (NULL, FALSE);
  g_timeout_add_seconds ((duration) + 1, (GSourceFunc) g_main_loop_quit,
      mainloop);
  gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING);
  g_main_loop_run (mainloop);

  return 0;
}
Exemple #11
0
int main (int argc, char *argv[])
{
    SourceAppData data;
    data.port = 7236;

    GOptionEntry main_entries[] =
    {
        { "rtsp_port", 0, 0, G_OPTION_ARG_INT, &(data.port), "Specify optional RTSP port number, 7236 by default", "rtsp_port"},
        { NULL }
    };

    GOptionContext* context = g_option_context_new ("- WFD desktop source demo application\n");
    g_option_context_add_main_entries (context, main_entries, NULL);
    g_option_context_add_group (context, gst_init_get_option_group ());

    GError* error = NULL;
    if (!g_option_context_parse (context, &argc, &argv, &error)) {
        g_print ("option parsing failed: %s\n", error->message);
        g_option_context_free(context);
        exit (1);
    }
    g_option_context_free(context);

    GMainLoop *main_loop =  g_main_loop_new(NULL, TRUE);
    g_unix_signal_add(SIGINT, _sig_handler, main_loop);
    g_unix_signal_add(SIGTERM, _sig_handler, main_loop);

    GIOChannel* io_channel = g_io_channel_unix_new (STDIN_FILENO);
    g_io_add_watch(io_channel, G_IO_IN, _user_input_handler, &data);
    g_io_channel_unref(io_channel);

    // Create a information element for a simple WFD Source
    // FIXME: is this correct? maybe we're supposed to actively scan for
    // WFD sinks instead
    P2P::InformationElement ie;
    auto sub_element = P2P::new_subelement(P2P::DEVICE_INFORMATION);
    auto dev_info = (P2P::DeviceInformationSubelement*)sub_element;
    dev_info->session_management_control_port =  htons(data.port);
    dev_info->maximum_throughput = htons(50);
    dev_info->field1.device_type = P2P::SOURCE;
    dev_info->field1.session_availability = true;
    ie.add_subelement (sub_element);

    std::cout << "Registering Wifi Source on port with IE " << ie.to_string() <<  std::endl;

    // register the P2P service with connman
    auto array = ie.serialize ();
    data.connman.reset(new ConnmanClient (array));

    if (create_source(&data))
        g_main_loop_run (main_loop);

    g_main_loop_unref (main_loop);

    return 0;
}
int
main (int argc, gchar ** argv)
{
  GError *err = NULL;
  GOptionEntry options[] = {
    {NULL}
  };
  GOptionContext *ctx;
  GMainLoop *mainloop;
  GstBus *bus;

  ctx = g_option_context_new ("tests thumbnail supoprt (produces no output)");
  g_option_context_set_summary (ctx, "");
  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)) {
    g_print ("Error initializing: %s\n", err->message);
    g_option_context_free (ctx);
    exit (1);
  }

  g_option_context_free (ctx);
  /* Initialize the GStreamer Editing Services */
  ges_init ();

  /* Create the pipeline */
  pipeline = create_timeline ();
  if (!pipeline)
    exit (-1);

  ges_pipeline_set_mode (pipeline, TIMELINE_MODE_PREVIEW);

  /* Play the pipeline */
  mainloop = g_main_loop_new (NULL, FALSE);

  g_print ("thumbnailing every 1 seconds\n");
  g_timeout_add (1000, thumbnail_cb, pipeline);

  bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
  gst_bus_add_signal_watch (bus);
  g_signal_connect (bus, "message", G_CALLBACK (bus_message_cb), mainloop);

  if (gst_element_set_state (GST_ELEMENT (pipeline),
          GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE) {
    g_print ("Failed to start the encoding\n");
    return 1;
  }
  g_main_loop_run (mainloop);

  gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL);
  gst_object_unref (pipeline);

  return 0;
}
int
main (int argc, char *argv[])
{
  GError *err = NULL;
  gint cpu_usage = 100;
  GstTranscoder *transcoder;
  gchar *src_uri, *dest_uri;
  GOptionContext *ctx;

  GOptionEntry options[] = {
    {"cpu-usage", 'c', 0, G_OPTION_ARG_INT, &cpu_usage,
        "The CPU usage to target in the transcoding process", NULL},
    {NULL}
  };

  g_set_prgname ("gst-play");

  ctx = g_option_context_new ("<source uri> <destination uri> "
      "<encoding target name>[/<encoding profile name>]");

  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)) {
    g_print ("Error initializing: %s\n", GST_STR_NULL (err->message));
    g_clear_error (&err);
    g_option_context_free (ctx);
    return 1;
  }

  if (argc != 4) {
    g_print ("%s", g_option_context_get_help (ctx, TRUE, NULL));
    g_option_context_free (ctx);

    return -1;
  }
  g_option_context_free (ctx);

  src_uri = ensure_uri (argv[1]);
  dest_uri = ensure_uri (argv[2]);
  transcoder = gst_transcoder_new (src_uri, dest_uri, argv[3]);
  gst_transcoder_set_cpu_usage (transcoder, cpu_usage);
  g_signal_connect (transcoder, "position-updated",
      G_CALLBACK (position_updated_cb), NULL);

  g_assert (transcoder);

  gst_transcoder_run (transcoder, &err);

  if (err)
    GST_ERROR ("Badam %s", err->message);

  return 0;
}
int
main (int argc, char **argv)
{
        GError *err = NULL;
        GList *profiles = NULL;
        GUPnPDLNADiscoverer *discover;

        GOptionEntry options[] = {
                {"verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose,
                 "Print (very) verbose output", NULL},
                {"relaxed", 'r', 0, G_OPTION_ARG_NONE, &relaxed,
                 "Read profiles in relaxed mode (only useful with -v)", NULL},
                {NULL}
        };

        GOptionContext *ctx;

        if (!g_thread_supported ())
                g_thread_init(NULL);

        ctx = g_option_context_new (" - program to list all the DLNA profiles supported by gupnp-dlna");
        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)) {

                g_print ("Error initializing: %s\n", err->message);
                exit (1);
        }

        g_option_context_free (ctx);

        gst_init (&argc, &argv);

        discover = gupnp_dlna_discoverer_new ((GstClockTime) GST_SECOND,
                                              relaxed,
                                              TRUE);

        profiles = (GList *) gupnp_dlna_discoverer_list_profiles (discover);

        if (!verbose) {
                g_print ("  %-30s%s\n", "Name", "MIME type");
                g_print ("---------------------------------------------------"
                         "---------------------\n");
        }
        g_list_foreach (profiles, (GFunc) print_profile, NULL);
        g_print ("\nProfiles with a '*' against their name are extended "
                 "(non-standard) profiles.\n\n");

        g_object_unref (discover);

        return 0;
}
Exemple #15
0
int main(int argc, char** argv)
{
    // Options parser
    GOptionContext* ctx = g_option_context_new("streamplay");
    const gchar** remaining_args = NULL;
    GOptionEntry entries[] = {
        { G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_STRING_ARRAY,
            &remaining_args, NULL, "FILE" },
        { NULL, '\0', 0, G_OPTION_ARG_NONE, NULL, NULL, NULL }
    };
    g_option_context_add_main_entries(ctx, entries, NULL);
    g_option_context_add_group(ctx, gst_init_get_option_group() );

    GError* err = NULL;
    if(!g_option_context_parse(ctx, &argc, &argv, &err)) {
        std::cerr << "Argument error:" << err->message << std::endl;
        g_error_free(err);
        return 1;
    }
    if(! remaining_args) { // Missing url argument
        std::cerr << "Usage: [uri]" << std::endl;
        return 1;
    }

    const gchar* uri = remaining_args[0];

    // GStreamer version info
    guint major, minor, micro, nano;
    gst_init(&argc, &argv);
    gst_version(&major, &minor, &micro, &nano);
    const gchar *nano_str = "";
    switch(nano) {
        case 1:
            nano_str = "(CVS)";
            break;
        case 2:
            nano_str = "(Prerelease)";
            break;
    } 
    std::cout << "Using GStreamer " << major << "." << minor << "." << micro << " " << nano_str << std::endl;

    // Start main loop
    {
        loop = g_main_loop_new(NULL, FALSE);
        InternetRadio radio(uri, loop);
        g_main_loop_run(loop);
    }

    g_main_loop_unref(loop);

    return 0;
}
Exemple #16
0
int
main (int argc, char **argv)
{
	ArvViewer *viewer;
	int status;
	GOptionContext *context;
	GError *error = NULL;

	bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
	textdomain (GETTEXT_PACKAGE);

	arv_g_thread_init (NULL);

	gtk_init (&argc, &argv);
	gst_init (&argc, &argv);

	context = g_option_context_new (NULL);
	g_option_context_add_main_entries (context, arv_viewer_option_entries, NULL);
	g_option_context_add_group (context, gtk_get_option_group (TRUE));
	g_option_context_add_group (context, gst_init_get_option_group ());
	if (!g_option_context_parse (context, &argc, &argv, &error)) {
		g_option_context_free (context);
		g_print ("Option parsing failed: %s\n", error->message);
		g_error_free (error);
		return EXIT_FAILURE;
	}

	g_option_context_free (context);

	arv_debug_enable (arv_viewer_option_debug_domains);

	viewer = arv_viewer_new ();
	if (!ARV_IS_VIEWER (viewer))
		return EXIT_FAILURE;

	arv_viewer_set_options (viewer,
				arv_viewer_option_auto_socket_buffer,
				!arv_viewer_option_no_packet_resend,
				arv_viewer_option_packet_timeout,
				arv_viewer_option_frame_retention);

	notify_init ("Aravis Viewer");

	status = g_application_run (G_APPLICATION (viewer), argc, argv);

	g_object_unref (viewer);

	notify_uninit ();

	return status;
}
Exemple #17
0
gint main (gint argc, gchar *argv[])
{
  //initialise threads before any gtk stuff (because not using gtk_init)
  g_thread_init(NULL);
  /*this is more complicated than plain gtk_init/gst_init, so that options from
    all over can be gathered and presented together.
   */
  GOptionGroup *gst_opts = gst_init_get_option_group();
  GOptionGroup *gtk_opts = gtk_get_option_group(TRUE);
  GOptionContext *ctx = g_option_context_new("...!");
  g_option_context_add_main_entries(ctx, entries, NULL);
  g_option_context_add_group(ctx, gst_opts);
  g_option_context_add_group(ctx, gtk_opts);
  GError *error = NULL;
  if (!g_option_context_parse(ctx, &argc, &argv, &error)){
    g_print ("Error initializing: %s\n", GST_STR_NULL(error->message));
    exit (1);
  }
  g_option_context_free(ctx);

  GMainLoop *loop = g_main_loop_new(NULL, FALSE);

  windows_t windows;
  windows.realised = 0;

  int i;
  for (i = 0; i < option_screens; i++){
    GtkWidget *window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    g_signal_connect(window, "realize",
        G_CALLBACK(video_widget_realize_cb), &windows);
    /* set up sink here */
    GstElement *sink = gst_element_factory_make("ximagesink", NULL);
    set_up_window(loop, window, i + option_first_screen);
    windows.gtk_windows[i] = window;
    windows.sinks[i] = sink;
  }

  GstElement *pipeline = (GstElement *)make_multi_pipeline(&windows, option_screens);

  GstBus *bus = gst_pipeline_get_bus(GST_PIPELINE(pipeline));
  gst_bus_add_watch(bus, (GstBusFunc)bus_call, &windows);
  gst_object_unref(bus);

  gst_element_set_state(pipeline, GST_STATE_PLAYING);

  g_main_loop_run(loop);

  gst_element_set_state (pipeline, GST_STATE_NULL);
  gst_object_unref (pipeline);
  return 0;
}
Exemple #18
0
int
main (int argc, char *argv[])
{
  gchar **filenames = NULL;
  guint num, i;
  GError *err = NULL;
  GOptionContext *ctx;
  GOptionEntry options[] = {
    GST_TOOLS_GOPTION_VERSION,
    {G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &filenames, NULL},
    {NULL}
  };

#ifdef ENABLE_NLS
  bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
  textdomain (GETTEXT_PACKAGE);
#endif

#if !GLIB_CHECK_VERSION (2, 31, 0)
  g_thread_init (NULL);
#endif

  gst_tools_set_prgname ("gst-typefind");

  ctx = g_option_context_new ("FILES");
  g_option_context_add_main_entries (ctx, options, GETTEXT_PACKAGE);
  g_option_context_add_group (ctx, gst_init_get_option_group ());
  if (!g_option_context_parse (ctx, &argc, &argv, &err)) {
    g_print ("Error initializing: %s\n", GST_STR_NULL (err->message));
    exit (1);
  }
  g_option_context_free (ctx);

  gst_tools_print_version ("gst-typefind");

  if (filenames == NULL || *filenames == NULL) {
    g_print ("Please give a filename to typefind\n\n");
    return 1;
  }

  num = g_strv_length (filenames);

  for (i = 0; i < num; ++i) {
    typefind_file (filenames[i]);
  }

  g_strfreev (filenames);

  return 0;
}
Exemple #19
0
/**
 * @brief Parse command line arguments.
 */
static void
gst_switch_ui_parse_args (int *argc, char **argv[])
{
  GOptionContext *context;
  GError *error = NULL;
  context = g_option_context_new ("");
  g_option_context_add_main_entries (context, entries, "gst-switch-ui");
  g_option_context_add_group (context, gst_init_get_option_group ());
  if (!g_option_context_parse (context, argc, argv, &error)) {
    g_print ("option parsing failed: %s\n", error->message);
    exit (1);
  }
  g_option_context_free (context);
}
Exemple #20
0
static void
options(int argc, char *argv[]) {
    GOptionGroup *gst_opts = gst_init_get_option_group();
    GOptionGroup *gtk_opts = gtk_get_option_group(TRUE);
    GOptionContext *ctx = g_option_context_new("...!");
    g_option_context_add_main_entries(ctx, entries, NULL);
    g_option_context_add_group(ctx, gst_opts);
    g_option_context_add_group(ctx, gtk_opts);
    GError *error = NULL;
    if (!g_option_context_parse(ctx, &argc, &argv, &error)) {
        GST_WARNING("Error initializing: %s\n", GST_STR_NULL(error->message));
        exit (1);
    }
    g_option_context_free(ctx);
}
Exemple #21
0
gboolean
process_args (int argc, char *argv[],
    gchar * file_list[], gboolean * fullscreen, GOptionContext * context)
{
  gboolean version = FALSE;
  guint c, index, pos = 0;
  GOptionEntry entries[] = {
    {"fullscreen", 'f', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE, fullscreen,
        "Fullscreen mode", NULL},
    {"version", 'v', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE, &version,
        "Print version", NULL},
    {NULL}
  };
  GError *err = NULL;

  g_option_context_add_main_entries (context, entries, NULL);
  g_option_context_add_group (context, gst_init_get_option_group ());
  g_option_context_add_group (context, clutter_get_option_group ());

  // Command line arguments.
  if (!g_option_context_parse (context, &argc, &argv, &err)) {
    g_print ("Error initializing: %s\n", err->message);
    g_error_free (err);
    goto quit;
  }

  if (version) {
    g_print ("snappy version %s\n", VERSION);
    goto quit;
  }
  // File arguments
  if (argc < 2) {
    g_print ("%s", g_option_context_get_help (context, TRUE, NULL));
    goto quit;
  }

  for (index = 1; index < argc; index++) {
    file_list[pos] = argv[index];
    g_debug ("Adding file: %s\n", file_list[pos]);
    pos++;
  }

  return TRUE;

quit:
  return FALSE;
}
Exemple #22
0
gint
main (gint   argc,
      gchar *argv[])
{
  GOptionContext *ctx;
  GtkWidget *win;
  GList *elements;

  /* i18n */
  bindtextdomain (GETTEXT_PACKAGE, MATELOCALEDIR);
  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
  textdomain (GETTEXT_PACKAGE);

  g_thread_init (NULL);
  ctx = g_option_context_new ("mate-volume-control");
  g_option_context_add_main_entries(ctx, entries, GETTEXT_PACKAGE);
  g_option_context_add_group (ctx, gst_init_get_option_group ());
  g_option_context_parse(ctx, &argc, &argv, NULL);
  g_option_context_free(ctx);

  gtk_init (&argc, &argv);

  gtk_window_set_default_icon_name ("multimedia-volume-control");

  if (!(elements = create_mixer_collection ())) {
    win = gtk_message_dialog_new (NULL, 0, GTK_MESSAGE_ERROR,
				  GTK_BUTTONS_CLOSE,
				  _("No volume control GStreamer plugins and/or devices found."));
    gtk_widget_show (win);
    gtk_dialog_run (GTK_DIALOG (win));
    gtk_widget_destroy (win);
    return -1;
  }

  /* window contains everything automagically */
  win = mate_volume_control_window_new (elements);
  if (page != NULL)
    mate_volume_control_window_set_page(win, page);
  g_signal_connect (win, "destroy", G_CALLBACK (cb_destroy), NULL);
  g_signal_connect (win, "check_resize", G_CALLBACK (cb_check_resize), NULL);

  gtk_widget_show (win);
  gtk_main ();

  return 0;
}
Exemple #23
0
gint
main (gint argc, gchar **argv)
{
  GOptionContext *context;
  GOptionGroup *gstreamer_group, *gtk_group;
  GError *err = NULL;

  context = g_option_context_new ("gtk-demo-app");

  /* get command line options from GStreamer and add them to the group */
  gstreamer_group = gst_init_get_option_group ();
  g_option_context_add_group (context, gstreamer_group);
  gtk_group = gtk_get_option_group (TRUE);
  g_option_context_add_group (context, gtk_group);

  /* add our own options. If you are using gettext for translation of your
   * strings, use GETTEXT_PACKAGE here instead of NULL */
  g_option_context_add_main_entries (context, cmd_options, NULL);

  /* now parse the commandline options, note that this already
   * calls gtk_init() and gst_init() */
  if (!g_option_context_parse (ctx, &argc, &argv, &err)) {
    g_print ("Error initializing: %s\n", err->message);
    exit (1);
  }

  /* any filenames we got passed on the command line? parse them! */
  if (cmd_filenames != NULL) {
    guint i, num;

    num = g_strv_length (cmd_filenames);
    for (i = 0; i < num; ++i) {
      /* do something with the filename ... */
      g_print ("Adding to play queue: %s\n", cmd_filenames[i]);
    }

    g_strfreev (cmd_filenames);
    cmd_filenames = NULL;
  }

/*** block b  from ../../../docs/manual/appendix-integration.xml ***/
  return 0;

/*** block c  from ../../../docs/manual/appendix-integration.xml ***/
}
Exemple #24
0
int
main(int argc, char ** argv)
{
  GOptionContext *context;
  GError *gerror = NULL;
  int count = 0;

  error = 0;

  gst_init (&argc, &argv);

  GST_DEBUG_CATEGORY_INIT (GST_CAT_DEFAULT, GST_DEFAULT_NAME, 0,
      GST_DEFAULT_NAME);

  context = g_option_context_new (NULL);
  g_option_context_add_main_entries (context, entries, NULL);
  g_option_context_add_group (context, gst_init_get_option_group () );

  if (!g_option_context_parse (context, &argc, &argv, &gerror) ) {
    GST_ERROR ("option parsing failed: %s\n", gerror->message);
    g_option_context_free (context);
    g_error_free (gerror);
    return 1;
  }

  g_option_context_free (context);

  loop = g_main_loop_new (NULL, TRUE);

  while (count < times && !g_atomic_int_get (&error)) {
    execute_test (count++);
    GST_INFO ("Executed %d times", count);
    if (g_atomic_int_get (&error)) {
      GST_ERROR ("Test terminated with error");
    } else {
      GST_INFO ("Test terminated correctly");
    }
  }

  g_main_loop_unref (loop);

  return error;
}
int
main (int argc, gchar ** argv)
{
  gchar **filenames = NULL;
  GOptionEntry options[] = {
    {G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &filenames, NULL},
    {NULL}
  };
  GOptionContext *ctx;
  GError *err = NULL;
  guint i, num;

  gst_init (&argc, &argv);

  if (argc == 1) {
    g_printerr ("Usage: %s FILE.JPG [FILE2.JPG] [FILE..JPG]\n", argv[0]);
    return -1;
  }

  ctx = g_option_context_new ("JPEG FILES");
  g_option_context_add_main_entries (ctx, options, GETTEXT_PACKAGE);
  g_option_context_add_group (ctx, gst_init_get_option_group ());
  if (!g_option_context_parse (ctx, &argc, &argv, &err)) {
    g_print ("Error initializing: %s\n", GST_STR_NULL (err->message));
    exit (1);
  }
  g_option_context_free (ctx);

  if (filenames == NULL || *filenames == NULL) {
    g_printerr ("Please provide one or more filenames.");
    return 1;
  }

  num = g_strv_length (filenames);

  for (i = 0; i < num; ++i) {
    process_file (filenames[i]);
  }

  g_strfreev (filenames);

  return 0;
}
int
main (int argc, char *argv[])
{
  GError *error = NULL;
  GOptionContext *context;
  GstSwitchUI *switchui;
  GMainLoop *main_loop;

  //if (!g_thread_supported ()) g_thread_init(NULL);

  context = g_option_context_new ("- FIXME");
  g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
  g_option_context_add_group (context, gst_init_get_option_group ());
  if (!g_option_context_parse (context, &argc, &argv, &error)) {
    g_print ("option parsing failed: %s\n", error->message);
    exit (1);
  }
  g_option_context_free (context);

  switchui = gst_switchui_new ();

  if (argc > 1) {
    gchar *uri;
    if (gst_uri_is_valid (argv[1])) {
      uri = g_strdup (argv[1]);
    } else {
      uri = g_filename_to_uri (argv[1], NULL, NULL);
    }
    gst_switchui_create_pipeline_playbin (switchui, uri);
    g_free (uri);
  } else {
    gst_switchui_create_pipeline (switchui);
  }

  gst_switchui_start (switchui);

  main_loop = g_main_loop_new (NULL, TRUE);
  switchui->main_loop = main_loop;

  g_main_loop_run (main_loop);

  exit (0);
}
int
main (int argc, char **argv)
{
  GtkWidget *window, *hbox, *combo, *edit, *test;
  GConfClient *gconf;
  GOptionContext *context;
  GError *error = NULL;

  g_thread_init (NULL);
  context = g_option_context_new (NULL);
  g_option_context_add_group (context, gst_init_get_option_group ());
  g_option_context_add_group (context, gtk_get_option_group (TRUE));
  if (g_option_context_parse (context, &argc, &argv, &error) == FALSE) {
	  g_print ("%s\nRun '%s --help' to see a full list of available command line options.\n",
		   error->message, argv[0]);
	  g_error_free (error);
	  g_option_context_free (context);
	  exit (1);
  }
  g_option_context_free (context);

  gconf = gconf_client_get_default ();
  gnome_media_profiles_init (gconf);

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  combo = gm_audio_profile_choose_new ();

  edit = gtk_button_new_with_mnemonic ("_Edit Profiles");
  test = gtk_button_new_with_mnemonic ("_Test");
  g_signal_connect (edit, "clicked", (GCallback) edit_clicked_cb, window);
  g_signal_connect (test, "clicked", (GCallback) test_clicked_cb, combo);
  g_signal_connect (edit, "destroy", (GCallback) gtk_main_quit, NULL);

  hbox = gtk_hbox_new (FALSE, 7);
  gtk_box_pack_start (GTK_BOX (hbox), combo, TRUE, TRUE, 0);
  gtk_box_pack_start (GTK_BOX (hbox), test, FALSE, TRUE, 0);
  gtk_box_pack_start (GTK_BOX (hbox), edit, FALSE, TRUE, 0);
  gtk_container_add (GTK_CONTAINER (window), hbox);
  gtk_widget_show_all (window);
  gtk_main ();

  return 0;
}
Exemple #28
0
int
main (int argc, char *argv[])
{
  GError *error = NULL;
  GOptionContext *context;
  GstPlayRegion *PlayRegion;
  GMainLoop *main_loop;

  if (argc < 2) {
    g_print ("usage: %s <uri>\n", argv[0]);
    return -1;
  }

  context = g_option_context_new ("- FIXME");
  g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
  g_option_context_add_group (context, gst_init_get_option_group ());
  if (!g_option_context_parse (context, &argc, &argv, &error)) {
    g_print ("option parsing failed: %s\n", error->message);
    exit (1);
  }
  g_option_context_free (context);

  PlayRegion = gst_PlayRegion_new ();

  gchar *uri;
  if (gst_uri_is_valid (argv[1])) {
    uri = g_strdup (argv[1]);
  } else {
    uri = g_filename_to_uri (argv[1], NULL, NULL);
  }
  gst_PlayRegion_create_pipeline (PlayRegion, uri);
  g_free (uri);

  gst_PlayRegion_start (PlayRegion);

  main_loop = g_main_loop_new (NULL, TRUE);
  PlayRegion->main_loop = main_loop;

  g_main_loop_run (main_loop);

  exit (0);
}
Exemple #29
0
static GOptionContext *
goo_application_create_option_context (void)
{
	GOptionContext *options_context;
	static gsize    initialized = FALSE;

	options_context = g_option_context_new (N_("Play CDs and save the tracks to disk as files"));
	g_option_context_set_translation_domain (options_context, GETTEXT_PACKAGE);
	g_option_context_set_ignore_unknown_options (options_context, TRUE);
	g_option_context_add_main_entries (options_context, options, GETTEXT_PACKAGE);

	if (g_once_init_enter (&initialized)) {
		g_option_context_add_group (options_context, gtk_get_option_group (TRUE));
		g_option_context_add_group (options_context, gst_init_get_option_group ());

		g_once_init_leave (&initialized, TRUE);
	}

	return options_context;
}
gint
main (gint argc, gchar ** argv)
{
  GOptionContext *opt_ctx;
  GstClock *clock;
  GError *err = NULL;

  opt_ctx = g_option_context_new ("- GStreamer PTP clock test app");
  g_option_context_add_main_entries (opt_ctx, opt_entries, NULL);
  g_option_context_add_group (opt_ctx, gst_init_get_option_group ());
  if (!g_option_context_parse (opt_ctx, &argc, &argv, &err))
    g_error ("Error parsing options: %s", err->message);
  g_clear_error (&err);
  g_option_context_free (opt_ctx);

  if (!gst_ptp_init (GST_PTP_CLOCK_ID_NONE, NULL))
    g_error ("failed to init ptp");

  if (stats)
    gst_ptp_statistics_callback_add (stats_cb, NULL, NULL);

  clock = gst_ptp_clock_new ("test-clock", domain);

  gst_clock_wait_for_sync (GST_CLOCK (clock), GST_CLOCK_TIME_NONE);

  while (TRUE) {
    GstClockTime local, remote;
    GstClockTimeDiff diff;

    local = g_get_real_time () * 1000;
    remote = gst_clock_get_time (clock);
    diff = GST_CLOCK_DIFF (local, remote);

    g_print ("local: %" GST_TIME_FORMAT " ptp: %" GST_TIME_FORMAT " diff: %s%"
        GST_TIME_FORMAT "\n", GST_TIME_ARGS (local), GST_TIME_ARGS (remote),
        (diff < 0 ? "-" : " "), GST_TIME_ARGS (ABS (diff)));
    g_usleep (100000);
  }

  return 0;
}