Ejemplo n.º 1
0
int
main (int    argc,
      char **argv)
{
  MexPluginManager *pmanager;
  MexMediaDBUSBridge *bridge;
  GMainLoop *loop;
  GError *error = NULL;
  gchar **plugin_directories;

  plugin_directories = g_new0 (gchar *, 2);
  plugin_directories[0] = g_strdup (MEX_PLAYER_PLUGIN_PATH);

  g_thread_init (NULL);

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

  /* Setup player and expose it to mex */
  media_player = mex_surface_player_new ();
  mex_player_set_media_player_callback (_get_media_player);

  bridge = mex_media_dbus_bridge_new (CLUTTER_MEDIA (media_player));

  /* Load player's plugins */
  pmanager = mex_plugin_manager_get_default ();
  g_object_set (G_OBJECT (pmanager), "search-paths", plugin_directories, NULL);
  mex_plugin_manager_refresh (pmanager);

  /* Export player's interface on d-bus */
  if (!mex_media_dbus_bridge_register (bridge, &error))
    {
      g_error ("Error registering on D-BUS: %s", error->message);
      g_clear_error (&error);
      return EXIT_SUCCESS;
    }

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

  return EXIT_SUCCESS;
}
Ejemplo n.º 2
0
static void
mex_player_init (MexPlayer *self)
{
  MexPlayerPrivate *priv;

  self->priv = priv = PLAYER_PRIVATE (self);

#ifdef USE_PLAYER_CLUTTER_GST
  priv->media = (ClutterMedia *) clutter_gst_video_texture_new ();

  /* We want to keep a reference to the media here to ensure consistency with
   * the D-BUS client interface behaviour
   */
  g_object_ref_sink (priv->media);

  clutter_container_add_actor (CLUTTER_CONTAINER (self),
                               CLUTTER_ACTOR (priv->media));
  clutter_texture_set_keep_aspect_ratio (CLUTTER_TEXTURE (priv->media), TRUE);
  clutter_container_child_set (CLUTTER_CONTAINER (self),
                               CLUTTER_ACTOR (priv->media),
                               "fit", TRUE, NULL);

  /* Use progressive download when possible. Don't enable that yet, the
   * behaviour of seeking in the non already downloaded part of the stream
   * is not great. Either disable seeking in that case or find out why.*/
#if 0
  video_texture = CLUTTER_GST_VIDEO_TEXTURE (priv->media);
  clutter_gst_video_texture_set_buffering_mode (video_texture,
						CLUTTER_GST_BUFFERING_MODE_DOWNLOAD);
#endif
#else
#ifdef USE_PLAYER_DBUS
  priv->media = (ClutterMedia *) mex_player_client_new ();
#else
#ifdef USE_PLAYER_SURFACE
  priv->media = (ClutterMedia *) mex_surface_player_new ();
#else
#error Unexpected player setup
#endif
#endif
#endif

  g_signal_connect (priv->media, "eos", G_CALLBACK (media_eos_cb), self);
  g_signal_connect (priv->media, "notify::playing",
                    G_CALLBACK (media_playing_cb), self);
  g_signal_connect (priv->media, "notify::progress",
                    G_CALLBACK (media_update_progress), self);


#if defined(USE_PLAYER_SURFACE) || defined (USE_PLAYER_CLUTTER_GST)
  {
    GError *error = NULL;
    priv->bridge = mex_media_dbus_bridge_new (priv->media);
    if (!mex_media_dbus_bridge_register (priv->bridge, &error))
      {
        g_warning (G_STRLOC ": Error registering player on D-BUS");
        g_clear_error (&error);
      }
  }
#endif

  /* add info panel */
  priv->info_panel = mex_info_panel_new (MEX_INFO_PANEL_MODE_FULL);
  mx_widget_set_disabled (MX_WIDGET (priv->info_panel), TRUE);
  clutter_container_add_actor (CLUTTER_CONTAINER (self), priv->info_panel);
  clutter_container_child_set (CLUTTER_CONTAINER (self), priv->info_panel,
                               "y-fill", FALSE, "y-align", MX_ALIGN_END,
                               NULL);
  clutter_actor_set_opacity (priv->info_panel, 0);

  /* add media controls */
  priv->controls = mex_media_controls_new ();
  g_signal_connect (priv->controls, "stopped", G_CALLBACK (controls_stopped_cb),
                    self);
  mex_media_controls_set_media (MEX_MEDIA_CONTROLS (priv->controls),
                                priv->media);
  clutter_container_add_actor (CLUTTER_CONTAINER (self), priv->controls);
  clutter_container_child_set (CLUTTER_CONTAINER (self), priv->controls,
                               "y-fill", FALSE, "y-align", MX_ALIGN_END,
                               NULL);

  priv->screensaver = mex_screensaver_new ();

  /* start in idle mode */
  mex_player_set_idle_mode (MEX_PLAYER (self), TRUE);
}