Example #1
0
int
main (int argc, char **argv)
{
  GjsContext *js_context;
  GError *error;

#ifdef GDK_WINDOWING_X11
  XInitThreads ();
#endif

  clutter_x11_set_use_argb_visual (TRUE);

  if (gtk_clutter_init (&argc, &argv) < 0)
    return EXIT_FAILURE;

  clutter_gst_init (0, NULL);

  parse_options (&argc, &argv);

  js_context = gjs_context_new_with_search_path (NULL);
  error = NULL;

  register_all_viewers (js_context);

  if (!gjs_context_eval (js_context,
                         "const Main = imports.ui.main;\n"
                         "Main.run();\n",
                         -1,
                         __FILE__,
                         NULL,
                         &error))
    g_error("Failed to load main javascript: %s", error->message);

  return EXIT_SUCCESS;
}
Example #2
0
static void
cheese_widget_class_init (CheeseWidgetClass *klass)
{
  GObjectClass   *object_class = G_OBJECT_CLASS (klass);
  GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);

  gtk_clutter_init (NULL, NULL);
  clutter_gst_init (NULL, NULL);

  object_class->finalize = cheese_widget_finalize;
#if 0
  object_class->set_property = cheese_widget_set_property;
#endif
  object_class->get_property = cheese_widget_get_property;
  widget_class->realize      = cheese_widget_realize;

  /**
   * CheeseWidget:state:
   *
   * Current state of the widget.
   *
   * Connect to notify::state signal to get notified about state
   * changes. Useful to update other widgets sensitiveness when the
   * camera is ready or to handle errors if camera setup fails.
   */
  g_object_class_install_property (object_class, PROP_STATE,
                                   g_param_spec_enum ("state",
                                                      NULL,
                                                      NULL,
                                                      CHEESE_TYPE_WIDGET_STATE,
                                                      CHEESE_WIDGET_STATE_NONE,
                                                      G_PARAM_READABLE));

  g_type_class_add_private (klass, sizeof (CheeseWidgetPrivate));
}
int main(int argc, char *argv[]) {
    GstElement *pipeline, *sink;
    ClutterTimeline *timeline;
    ClutterActor *stage, *texture;

    /* clutter-gst takes care of initializing Clutter and GStreamer */
    if (clutter_gst_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) {
        g_error ("Failed to initialize clutter\n");
        return -1;
    }

    stage = clutter_stage_get_default ();

    /* Make a timeline */
    timeline = clutter_timeline_new (1000);
    g_object_set(timeline, "loop", TRUE, NULL);

    /* Create new texture and disable slicing so the video is properly mapped onto it */
    texture = CLUTTER_ACTOR (g_object_new (CLUTTER_TYPE_TEXTURE, "disable-slicing", TRUE, NULL));
    g_signal_connect (texture, "size-change", G_CALLBACK (size_change), NULL);

    /* Build the GStreamer pipeline */
    pipeline = gst_parse_launch ("playbin2 uri=http://docs.gstreamer.com/media/sintel_trailer-480p.webm", NULL);

    /* Instantiate the Clutter sink */
    sink = gst_element_factory_make ("autocluttersink", NULL);
    if (sink == NULL) {
        /* Revert to the older cluttersink, in case autocluttersink was not found */
        sink = gst_element_factory_make ("cluttersink", NULL);
    }
    if (sink == NULL) {
        g_printerr ("Unable to find a Clutter sink.\n");
        return -1;
    }

    /* Link GStreamer with Clutter by passing the Clutter texture to the Clutter sink*/
    g_object_set (sink, "texture", texture, NULL);

    /* Add the Clutter sink to the pipeline */
    g_object_set (pipeline, "video-sink", sink, NULL);

    /* Start playing */
    gst_element_set_state (pipeline, GST_STATE_PLAYING);

    /* start the timeline */
    clutter_timeline_start (timeline);

    /* Add texture to the stage, and show it */
    clutter_group_add (CLUTTER_GROUP (stage), texture);
    clutter_actor_show_all (stage);

    clutter_main();

    /* Free resources */
    gst_element_set_state (pipeline, GST_STATE_NULL);
    gst_object_unref (pipeline);
    return 0;
}
int
main (int argc, char *argv[])
{
  ClutterActor *vtexture;
  int i;

  clutter_gst_init (&argc, &argv);

  for (i = 0; ; i++)
  {
    g_debug("VideoTexure #%d", i);
    vtexture = clutter_gst_video_texture_new();
    g_object_ref_sink (vtexture);
    g_object_unref (vtexture);
  }

  return EXIT_SUCCESS;
}
static void
gt_player_backend_gstreamer_clutter_class_init(GtPlayerBackendGstreamerClutterClass* klass)
{
    GObjectClass* obj_class = G_OBJECT_CLASS(klass);
    static gboolean init = FALSE;

    obj_class->finalize = finalise;
    obj_class->get_property = get_property;
    obj_class->set_property = set_property;

    props[PROP_VOLUME] = g_param_spec_double("volume",
                                             "Volume",
                                             "Volume of player",
                                             0.0, 1.0, 0.3,
                                             G_PARAM_READWRITE | G_PARAM_CONSTRUCT);
    props[PROP_PLAYING] = g_param_spec_boolean("playing",
                                               "Playing",
                                               "Whether playing",
                                               FALSE,
                                               G_PARAM_READABLE | G_PARAM_CONSTRUCT);
    props[PROP_URI] = g_param_spec_string("uri",
                                          "Uri",
                                          "Current uri",
                                          "",
                                          G_PARAM_READWRITE);
    props[PROP_BUFFER_FILL] = g_param_spec_double("buffer-fill",
                                                     "Buffer fill",
                                                     "Current buffer fill",
                                                     0, 1.0, 0,
                                                     G_PARAM_READWRITE | G_PARAM_CONSTRUCT);

    g_object_class_override_property(obj_class, PROP_VOLUME, "volume");
    g_object_class_override_property(obj_class, PROP_PLAYING, "playing");
    g_object_class_override_property(obj_class, PROP_URI, "uri");
    g_object_class_override_property(obj_class, PROP_BUFFER_FILL, "buffer-fill");

    if (!init)
    {
        gint res = gtk_clutter_init(NULL, NULL);
        clutter_gst_init(NULL, NULL);
        init = TRUE;
    }
}
Example #6
0
void Platform::init(int* argc, char*** argv)
{
    if(m_initialized)
        return;

    m_initialized = true;

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

    clutter_gst_init (argc, argv);

    m_stage = clutter_stage_get_default();
    clutter_actor_set_size(m_stage, (gfloat)960, (gfloat)540);

    m_videoTexture = clutter_texture_new ();
    GstPlaybin::getInstance().init(m_videoTexture);
    clutter_container_add_actor (CLUTTER_CONTAINER (m_stage), m_videoTexture);
    g_signal_connect (CLUTTER_STAGE (m_stage), "fullscreen", G_CALLBACK (Platform::windowSizeChanged), this);
    g_signal_connect (CLUTTER_STAGE (m_stage), "unfullscreen", G_CALLBACK (Platform::windowSizeChanged), this);
//	g_signal_connect (CLUTTER_STAGE (m_stage), "event", G_CALLBACK (Platform::stageEvent), this);
}
Example #7
0
static void
mex_base_init (int *argc, char ***argv)
{
  static gsize initialised;

  if (g_once_init_enter (&initialised))
    {
      /* initialize debugging infrastructure */
      _mex_log_init_core_domains ();

      /* initialise Clutter */
      if (!clutter_init (argc, argv))
        g_error ("Failed to initialize clutter");

#ifdef USE_PLAYER_CLUTTER_GST
      clutter_gst_init (argc, argv);
#endif

      mex_init_default_categories ();
      mex_init_load_grilo_plugins();

      g_once_init_leave (&initialised, TRUE);
    }
}
Example #8
0
int
main (int argc,
    char *argv[])
{
  GOptionContext *optcontext;
  GOptionEntry options[] = {
      { NULL }
  };
#ifdef ENABLE_DEBUG
  TpDebugSender *debug_sender;
#endif
  GError *error = NULL;
  gint retval;
  GtkSettings *gtk_settings;

  /* Init */
  g_thread_init (NULL);

#ifdef GDK_WINDOWING_X11
  /* We can't call clutter_gst_init() before gtk_clutter_init(), so no choice
   * but to intiialise X11 threading ourself */
  XInitThreads ();
#endif

  /* Clutter needs this */
  gdk_disable_multidevice ();

  optcontext = g_option_context_new (N_("- Empathy Audio/Video Client"));
  g_option_context_add_group (optcontext, gst_init_get_option_group ());
  g_option_context_add_group (optcontext, gtk_get_option_group (TRUE));
  g_option_context_add_group (optcontext, cogl_get_option_group ());
  g_option_context_add_group (optcontext,
      clutter_get_option_group_without_init ());
  g_option_context_add_group (optcontext, gtk_clutter_get_option_group ());
  g_option_context_add_main_entries (optcontext, options, GETTEXT_PACKAGE);

  if (!g_option_context_parse (optcontext, &argc, &argv, &error)) {
    g_print ("%s\nRun '%s --help' to see a full list of available command "
        "line options.\n",
        error->message, argv[0]);
    g_warning ("Error in empathy-call init: %s", error->message);
    return EXIT_FAILURE;
  }

  g_option_context_free (optcontext);

  clutter_gst_init (&argc, &argv);

  empathy_gtk_init ();
  g_set_application_name (_("Empathy Audio/Video Client"));

  /* Make empathy and empathy-call appear as the same app in gnome-shell */
  gdk_set_program_class ("Empathy");
  gtk_window_set_default_icon_name ("empathy");
  textdomain (GETTEXT_PACKAGE);

  gtk_settings = gtk_settings_get_default ();
  g_object_set (G_OBJECT (gtk_settings), "gtk-application-prefer-dark-theme",
      TRUE, NULL);

  app = gtk_application_new (EMPATHY_CALL_DBUS_NAME, G_APPLICATION_FLAGS_NONE);
  g_signal_connect (app, "activate", G_CALLBACK (activate_cb), NULL);

#ifdef ENABLE_DEBUG
  /* Set up debug sender */
  debug_sender = tp_debug_sender_dup ();
  g_log_set_default_handler (tp_debug_sender_log_handler, G_LOG_DOMAIN);
#endif

  if (g_getenv ("EMPATHY_PERSIST") != NULL)
    {
      DEBUG ("Disable timer");

      use_timer = FALSE;
    }

  call_windows = g_hash_table_new_full (g_direct_hash, g_direct_equal,
      g_object_unref, NULL);

  /* the inactivity timeout can only be set while the application is held */
  g_application_hold (G_APPLICATION (app));
  g_application_set_inactivity_timeout (G_APPLICATION (app), TIMEOUT * 1000);
  g_application_release (G_APPLICATION (app));

  retval = g_application_run (G_APPLICATION (app), argc, argv);

  g_hash_table_unref (call_windows);
  g_object_unref (app);
  tp_clear_object (&call_factory);

#ifdef ENABLE_DEBUG
  g_object_unref (debug_sender);
#endif

  return retval;
}
Example #9
0
int
main (int argc, char *argv[])
{
  ClutterActor *video;

  /* So we can fade out at the end. */
  clutter_x11_set_use_argb_visual (TRUE);

  if (clutter_gst_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
    return EXIT_FAILURE;

  if (argc < 2)
    {
      g_print ("Usage: %s [OPTIONS] <video file>\n", argv[0]);
      return EXIT_FAILURE;
    }

  if (!clutter_color_from_string (&bg_color, BG_COLOR))
    {
      g_warning ("Invalid BG_COLOR");
      exit (1);
    }

  stage = clutter_stage_new ();

  /* Clutter's full-screening code does not allow us to
   * set both that and _NET_WM_STATE_ABOVE, so do the state
   * management ourselves for now. */
#if 0
  clutter_stage_set_fullscreen (CLUTTER_STAGE (stage), TRUE);
#endif

  /* Clutter will set maximum size restrictions (meaning not
   * full screen) unless I set this. */
  clutter_stage_set_user_resizable (CLUTTER_STAGE (stage), TRUE);

  clutter_stage_set_use_alpha (CLUTTER_STAGE (stage), TRUE);

  clutter_actor_set_background_color (stage, &bg_color);
  clutter_actor_set_layout_manager (stage,
                                    clutter_bin_layout_new (CLUTTER_BIN_ALIGNMENT_FIXED,
                                                            CLUTTER_BIN_ALIGNMENT_FIXED));

  clutter_actor_realize (stage);
  set_above_and_fullscreen ();

  video = clutter_gst_video_texture_new ();
  clutter_actor_set_x_expand (video, TRUE);
  clutter_actor_set_y_expand (video, TRUE);
  clutter_actor_set_x_align (video, CLUTTER_ACTOR_ALIGN_CENTER);
  clutter_actor_set_y_align (video, CLUTTER_ACTOR_ALIGN_CENTER);
  set_idle_material (CLUTTER_GST_VIDEO_TEXTURE (video));

  g_signal_connect (video,
                    "eos",
                    G_CALLBACK (on_video_texture_eos),
                    NULL);

  g_signal_connect (stage,
                    "destroy",
                    G_CALLBACK (clutter_main_quit),
                    NULL);

  clutter_media_set_filename (CLUTTER_MEDIA (video), argv[1]);
  clutter_stage_hide_cursor (CLUTTER_STAGE (stage));

  clutter_actor_add_child (stage, video);

  g_signal_connect (stage, "key-press-event", G_CALLBACK (key_press_cb), NULL);

  clutter_media_set_playing (CLUTTER_MEDIA (video), TRUE);
  clutter_actor_show (stage);
  clutter_main ();

  return EXIT_SUCCESS;
}
Example #10
0
int
main (int    argc,
      char **argv)
{
    PinPointRenderer *renderer;
    GOptionContext   *context;
    GError *error = NULL;
    char   *text  = NULL;

    memcpy (&default_point, &pin_default_point, sizeof (default_point));
    renderer = pp_clutter_renderer ();

    context = g_option_context_new ("- Presentations made easy");
    g_option_context_add_main_entries (context, entries, NULL);
    g_option_context_add_group (context, clutter_get_option_group_without_init ());
    g_option_context_add_group (context, cogl_get_option_group ());
    if (!g_option_context_parse (context, &argc, &argv, &error))
    {
        g_print ("option parsing failed: %s\n", error->message);
        return EXIT_FAILURE;
    }

    pinfile = argv[1];

    if (!pinfile)
    {
        g_print ("usage: %s [options] <presentation>\n", argv[0]);
        text = g_strdup ("[no-markup][transition=sheet][red]\n"
                         "--\n"
                         "usage: pinpoint [options] <presentation.txt>\n");
    }
    else
    {
        if (!g_file_get_contents (pinfile, &text, NULL, NULL))
        {
            g_print ("failed to load presentation from %s\n", pinfile);
            return -1;
        }
    }

#ifdef USE_CLUTTER_GST
    clutter_gst_init (&argc, &argv);
#else
    clutter_init (&argc, &argv);
#endif
#ifdef USE_DAX
    dax_init (&argc, &argv);
#endif

    /* select the cairo renderer if we have requested pdf output */
    if (pp_output_filename && g_str_has_suffix (pp_output_filename, ".pdf"))
    {
#ifdef HAVE_PDF
        renderer = pp_cairo_renderer ();
        /* makes more sense to default to a white "stage" colour in PDFs*/
        default_point.stage_color = "white";
#else
        g_warning ("Pinpoint was built without PDF support");
        return EXIT_FAILURE;
#endif
    }

    if (!pinfile)
        pp_rehearse = FALSE;

    if (pinfile)
    {
        GFile *file;

        file = g_file_new_for_commandline_arg (pinfile);
        pp_basedir = g_file_get_parent (file);
        g_object_unref (file);
    }

    renderer->init (renderer, pinfile);
    pp_parse_slides (renderer, text);
    g_free (text);

    if (pp_rehearse)
    {
        pp_rehearse_init ();
        printf ("Running in rehearsal mode, press ctrl+C to abort without saving timings back to %s\n", pinfile);
    }
    renderer->run (renderer);
    renderer->finalize (renderer);
    if (renderer->source)
        g_free (renderer->source);
#if 0
    if (pp_rehearse)
        pp_rehearse_save ();
#endif

    g_list_free (pp_slides);

    return 0;
}
Example #11
0
int
main (int argc, char *argv[])
{
  UserInterface *ui = NULL;
  GstEngine *engine = NULL;
  ClutterActor *video_texture;
  GstElement *sink;

  gboolean ok, fullscreen = FALSE;
  gint ret = 0;
  guint c, index, pos = 0;
  gchar *fileuri, *uri;
  gchar *file_list[argc];
  GOptionContext *context;

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

  context = g_option_context_new ("<media file> - Play movie files");

  ok = process_args (argc, argv, file_list, &fullscreen, context);
  if (!ok)
    goto quit;
  config_load ();

  // User Interface
  ui = g_new0 (UserInterface, 1);
  ui->fullscreen = fullscreen;
  video_texture = clutter_texture_new ();

  clutter_gst_init (&argc, &argv);

  // Gstreamer
  engine = g_new0 (GstEngine, 1);
  ui->engine = engine;
  sink = clutter_gst_video_sink_new (CLUTTER_TEXTURE (video_texture));

  ok = engine_init (engine, sink);
  if (!ok)
    goto quit;
  ui->texture = video_texture;
  gst_bus_add_watch (engine->bus, bus_call, ui);
  gst_object_unref (engine->bus);

  if (gst_uri_is_valid (file_list[0]))
    uri = g_strdup (file_list[0]);
  else {
    fileuri = clean_uri (file_list[0]);
    uri = g_strdup_printf ("file://%s", fileuri);
  }

  engine_load_uri (engine, uri);
  interface_load_uri (ui, uri);
  load_user_interface (ui);

  change_state (engine, "Paused");
  change_state (engine, "Playing");

  clutter_main ();

  close_down (ui, engine);

quit:
  g_option_context_free (context);

  return ret;
}
Example #12
0
/*            snappy's main function             */
int
main (int argc, char *argv[])
{
  UserInterface *ui = NULL;
  GstEngine *engine = NULL;
  ClutterActor *video_texture;
  GstElement *sink;

  gboolean ok, blind = FALSE, fullscreen = FALSE, hide = FALSE, loop = FALSE;
  gboolean secret = FALSE, tags = FALSE;
  gint ret = 0;
  guint c, index, pos = 0;
  gchar *uri;
  gchar *suburi = NULL;
  gchar *version_str;
  GList *uri_list;
  GOptionContext *context;
  gchar *data_dir;

#ifdef ENABLE_DBUS
  SnappyMP *mp_obj = NULL;
#endif


  /* Try to find the path for our resources in case snappy was relocated */
  data_dir = g_strdup(SNAPPY_DATA_DIR);
  if (!g_file_test(data_dir, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) {
    gchar *root_dir;

#ifdef G_OS_WIN32
    root_dir = g_win32_get_package_installation_directory_of_module(NULL);
#elif !defined(G_OS_UNIX)
    gchar *exec_path;
    gchar *bin_dir;

    exec_path = g_file_read_link("/proc/self/exe", NULL);
    bin_dir = g_path_get_dirname(exec_path);
    root_dir = g_build_filename(bin_dir, "..", NULL);
    g_free(exec_path);
    g_free(bin_dir);
#else
    root_dir = NULL;
#endif
    if (root_dir != NULL) {
      data_dir = g_build_filename(root_dir, "share", "snappy", NULL);
      g_free(root_dir);
    }
  }

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

  context = g_option_context_new ("<media file> - Play movie files");

  /* Process command arguments */
  uri_list = process_args (argc, argv, &blind, &fullscreen, &hide,
      &loop, &secret, &suburi, &tags, context);
  if (uri_list == NULL)
    goto quit;

  /* User Interface */
  ui = g_new (UserInterface, 1);
  ui->uri_list = uri_list;
  ui->blind = blind;
  ui->fullscreen = fullscreen;
  ui->hide = hide;
  ui->tags = tags;
  ui->data_dir = data_dir;
  interface_init (ui);
  video_texture = clutter_texture_new ();

  clutter_gst_init (&argc, &argv);

  version_str = gst_version_string ();
  GST_DEBUG_CATEGORY_INIT (_snappy_gst_debug, "snappy", 0,
      "snappy media player");
  GST_DEBUG ("Initialised %s", version_str);

  /* Gstreamer engine */
  engine = g_new (GstEngine, 1);
  sink = gst_element_factory_make ("autocluttersink", "cluttersink");
  if (sink == NULL) {
    GST_DEBUG ("autocluttersink not found, falling back to cluttersink\n");
    sink = gst_element_factory_make ("cluttersink", "cluttersink");
  }
  g_object_set (G_OBJECT (sink), "texture", CLUTTER_TEXTURE (video_texture),
      NULL);

  ok = engine_init (engine, sink);
  if (!ok)
    goto quit;

  engine->secret = secret;
  engine->loop = loop;

  ui->engine = engine;
  ui->texture = video_texture;

  gst_bus_add_watch (engine->bus, bus_call, ui);
  gst_object_unref (engine->bus);

  /* Get uri to load */
  uri = g_list_first (uri_list)->data;

  /* Load engine and start interface */
  engine_load_uri (engine, uri);
  interface_start (ui, uri);

  /* Load subtitle file if available */
  if (suburi != NULL) {
    suburi = clean_uri (suburi);
    set_subtitle_uri (engine, suburi);
  }

  /* Start playing */
  change_state (engine, "Paused");
  change_state (engine, "Playing");

#ifdef ENABLE_DBUS
  /* Start MPRIS Dbus object */
  mp_obj = g_new (SnappyMP, 1);
  mp_obj->engine = engine;
  mp_obj->ui = ui;
  load_dlna (mp_obj);
#endif

  /* Main loop */
  clutter_main ();

  /* Close snappy */
  close_down (ui, engine);
#ifdef ENABLE_DBUS
  close_dlna (mp_obj);
#endif

quit:
  g_list_free (uri_list);
  g_option_context_free (context);

  return ret;
}
Example #13
0
/*            snappy's main function             */
int
main (int argc, char *argv[])
{
  UserInterface *ui = NULL;
  GstEngine *engine = NULL;
  ClutterActor *video_texture;
  ClutterGstVideoSink *sink;

  gboolean ok, blind = FALSE, fullscreen = FALSE, hide = FALSE, loop = FALSE;
  gboolean secret = FALSE, tags = FALSE;
  gint ret = 0;
  gchar *uri = NULL;
  gchar *suburi = NULL;
  GList *uri_list;
  GOptionContext *context;
  gchar *data_dir;

  ClutterInitError ci_err;

#ifdef ENABLE_DBUS
  SnappyMP *mp_obj = NULL;
#endif

  context = g_option_context_new ("<media file> - Play movie files");

  clutter_set_windowing_backend (CLUTTER_WINDOWING_X11);
  ci_err = gtk_clutter_init (&argc, &argv);
  if (ci_err != CLUTTER_INIT_SUCCESS)
    goto quit;

  /* Try to find the path for our resources in case snappy was relocated */
  data_dir = g_strdup (SNAPPY_DATA_DIR);
  if (!g_file_test (data_dir, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) {
    gchar *root_dir;

#ifdef G_OS_WIN32
    root_dir = g_win32_get_package_installation_directory_of_module (NULL);
#elif !defined(G_OS_UNIX)
    gchar *exec_path;
    gchar *bin_dir;

    exec_path = g_file_read_link ("/proc/self/exe", NULL);
    bin_dir = g_path_get_dirname (exec_path);
    root_dir = g_build_filename (bin_dir, "..", NULL);
    g_free (exec_path);
    g_free (bin_dir);
#else
    root_dir = NULL;
#endif
    if (root_dir != NULL) {
      data_dir = g_build_filename (root_dir, "share", "snappy", NULL);
      g_free (root_dir);
    }
  }

  /* Process command arguments */
  uri_list = process_args (argc, argv, &blind, &fullscreen, &hide,
      &loop, &secret, &suburi, &tags, context);

  gst_init (&argc, &argv);
  clutter_gst_init (NULL, NULL);

  /* User Interface */
  ui = g_new (UserInterface, 1);
  ui->uri_list = uri_list;
  ui->blind = blind;
  ui->fullscreen = fullscreen;
  ui->hide = hide;
  ui->tags = tags;
  ui->data_dir = data_dir;
  interface_init (ui);

  /* Gstreamer engine */
  engine = g_new (GstEngine, 1);
  sink = clutter_gst_video_sink_new ();
  if (sink == NULL) {
    g_print ("ERROR: Failed to create clutter-gst sink element\n");
    return FALSE;
  }
  video_texture = g_object_new (CLUTTER_TYPE_ACTOR, "content",
      g_object_new (CLUTTER_GST_TYPE_CONTENT, "sink", sink, NULL),
      "name", "texture", NULL);

  ok = engine_init (engine, sink);
  if (!ok)
    goto quit;

  engine->secret = secret;
  engine->loop = loop;

  ui->engine = engine;
  ui->texture = video_texture;

  gst_bus_add_watch (engine->bus, bus_call, ui);
  gst_object_unref (engine->bus);

  /* Get uri to load */
  if (uri_list) {
    uri = g_list_first (uri_list)->data;
    /* based on video filename we can guess subtitle file (.srt files only) */
    if (NULL == suburi) {
      gchar suburi_path_guessing[1024]; //buffer
      gchar *uri_no_extension = strip_filename_extension (uri);

      sprintf (suburi_path_guessing, "%s.srt", uri_no_extension);
      /* subtitle file exists, defaults for it */
      if (g_file_test (g_filename_from_uri (suburi_path_guessing, NULL, NULL),
              G_FILE_TEST_EXISTS))
        suburi = suburi_path_guessing;
    }
  }

  /* Load engine and start interface */
  engine_load_uri (engine, uri);
  interface_start (ui, uri);

  /* Load subtitle file if available */
  if (suburi != NULL) {
    suburi = clean_uri (suburi);
    set_subtitle_uri (engine, suburi);
  }

  /* Start playing if we have a URI to play */
  if (uri) {
    change_state (engine, "Paused");
    change_state (engine, "Playing");
  }
#ifdef ENABLE_DBUS
  /* Start MPRIS Dbus object */
  mp_obj = g_new (SnappyMP, 1);
  mp_obj->engine = engine;
  mp_obj->ui = ui;
  load_dlna (mp_obj);
#endif

  /* Main loop */
  gtk_main ();

  /* Close snappy */
  close_down (ui, engine);
#ifdef ENABLE_DBUS
  close_dlna (mp_obj);
#endif

quit:
  g_list_free (uri_list);
  g_option_context_free (context);

  return ret;
}
Example #14
0
int
main (int argc,
    char *argv[])
{
  GOptionContext *optcontext;
  GOptionEntry options[] = {
      { NULL }
  };
#ifdef ENABLE_DEBUG
  TpDebugSender *debug_sender;
#endif
  GError *error = NULL;
  gint retval;

  /* Init */
  g_thread_init (NULL);

  optcontext = g_option_context_new (N_("- Empathy Audio/Video Client"));
  g_option_context_add_group (optcontext, gst_init_get_option_group ());
  g_option_context_add_group (optcontext, gtk_get_option_group (TRUE));
  g_option_context_add_main_entries (optcontext, options, GETTEXT_PACKAGE);

  if (!g_option_context_parse (optcontext, &argc, &argv, &error)) {
    g_print ("%s\nRun '%s --help' to see a full list of available command "
        "line options.\n",
        error->message, argv[0]);
    g_warning ("Error in empathy-av init: %s", error->message);
    return EXIT_FAILURE;
  }

  g_option_context_free (optcontext);

  clutter_gst_init (&argc, &argv);

  empathy_gtk_init ();
  g_set_application_name (_("Empathy Audio/Video Client"));
  g_setenv ("PULSE_PROP_media.role", "phone", TRUE);

  /* Make empathy and empathy-av appear as the same app in gnome-shell */
  gdk_set_program_class ("Empathy");
  gtk_window_set_default_icon_name ("empathy");
  textdomain (GETTEXT_PACKAGE);

  app = gtk_application_new (EMPATHY_AV_DBUS_NAME, G_APPLICATION_FLAGS_NONE);
  g_signal_connect (app, "activate", G_CALLBACK (activate_cb), NULL);

#ifdef ENABLE_DEBUG
  /* Set up debug sender */
  debug_sender = tp_debug_sender_dup ();
  g_log_set_default_handler (tp_debug_sender_log_handler, G_LOG_DOMAIN);
#endif

  if (g_getenv ("EMPATHY_PERSIST") != NULL)
    {
      DEBUG ("Disable timer");

      use_timer = FALSE;
    }

  /* the inactivity timeout can only be set while the application is held */
  g_application_hold (G_APPLICATION (app));
  g_application_set_inactivity_timeout (G_APPLICATION (app), TIMEOUT * 1000);
  g_application_release (G_APPLICATION (app));

  retval = g_application_run (G_APPLICATION (app), argc, argv);

  g_object_unref (app);
  tp_clear_object (&call_factory);

#ifdef ENABLE_DEBUG
  g_object_unref (debug_sender);
#endif

  return retval;
}
Example #15
0
int main(int argc, char **argv)
{
  GtkWidget *window;
  GtkWidget *stage;
  ClutterColor stage_color = { 0xff, 0xff, 0xff, 0xff };
  ClutterTimeline *timeline, *clock;
  GError *error = NULL;
  HandCar *all;

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

  all = handcar_new ();
  window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title (GTK_WINDOW(window), "Clutter Player");
  g_signal_connect(G_OBJECT(window), "delete-event",
                   G_CALLBACK(gtk_main_quit), NULL);

  stage = gtk_clutter_embed_new();
  gtk_widget_set_size_request(stage, STAGE_WIDTH, STAGE_HEIGHT);
  gtk_container_add(GTK_CONTAINER(window), stage);

  all->stage_actor = gtk_clutter_embed_get_stage(GTK_CLUTTER_EMBED(stage));

  clutter_container_add_actor(CLUTTER_CONTAINER(all->stage_actor), all->rect1);
  clutter_container_add_actor(CLUTTER_CONTAINER(all->stage_actor), all->rect2);
  clutter_container_add_actor(CLUTTER_CONTAINER(all->stage_actor), all->rect3);
  clutter_container_add_actor(CLUTTER_CONTAINER(all->stage_actor), all->btn_actor_play);
  clutter_container_add_actor(CLUTTER_CONTAINER(all->stage_actor), all->btn_actor_previous);
  clutter_container_add_actor(CLUTTER_CONTAINER(all->stage_actor), all->btn_actor_next);
  clutter_container_add_actor(CLUTTER_CONTAINER(all->stage_actor), all->label_actor);
  clutter_container_add_actor(CLUTTER_CONTAINER(all->stage_actor), all->label_time);
  clutter_container_add_actor(CLUTTER_CONTAINER(all->stage_actor), all->video);
  clutter_container_add_actor(CLUTTER_CONTAINER(all->stage_actor), all->entry_actor);

  clutter_stage_set_color(CLUTTER_STAGE(all->stage_actor), &stage_color);

  timeline = clutter_timeline_new (100, 5);
  g_signal_connect(G_OBJECT(timeline), "new-frame",
                   G_CALLBACK(on_timeline_new_frame),
                   (gpointer)all);
  clutter_timeline_set_loop(timeline, TRUE);
  clutter_timeline_start(timeline);

  clock = clutter_timeline_new (60, 2);
  g_signal_connect(G_OBJECT(clock), "new-frame",
                   G_CALLBACK(on_update_clock),
                   (gpointer)all);
  clutter_timeline_set_loop(clock, TRUE);
  clutter_timeline_start(clock);

  g_signal_connect (all->stage_actor, "motion-event", G_CALLBACK(mouse_over_lighten), (gpointer) all);
  g_signal_connect (all->stage_actor, "button-press-event", G_CALLBACK(on_click), (gpointer) all);
  clutter_actor_raise_top (all->entry_actor);
  gtk_widget_show_all(window);
  gtk_main();

  return 0;
}