Commit 95e40b47 authored by Luis de Bethencourt's avatar Luis de Bethencourt

dlna: opening and playing media files

Method calls OpenUri, Play and Stop work in a very rudimentary
parent 22f28d2f
<interface name='org.mpris.MediaPlayer2'>
<method name='Raise'/>
<method name='Quit'/>
<property name='CanQuit' type='b' access='read'/>
<property name='CanRaise' type='b' access='read'/>
<property name='HasTrackList' type='b' access='read'/>
<property name='Identity' type='s' access='read'/>
<property name='DesktopEntry' type='s' access='read'/>
<property name='SupportedUriSchemes' type='as' access='read'/>
<property name='SupportedMimeTypes' type='as' access='read'/>
<interface name='org.mpris.MediaPlayer2.Player'>
<method name='Next'/>
<method name='Previous'/>
<method name='Pause'/>
<method name='PlayPause'/>
<method name='Stop'/>
<method name='Play'/>
<method name='Seek'>
<arg direction='in' name='Offset' type='x'/>
<method name='SetPosition'>
<arg direction='in' name='TrackId' type='o'/>
<arg direction='in' name='Position' type='x'/>
<method name='OpenUri'>
<arg direction='in' name='Uri' type='s'/>
<signal name='Seeked'>
<arg name='Position' type='x'/>
<property name='PlaybackStatus' type='s' access='read'/>
<property name='LoopStatus' type='s' access='readwrite'/>
<property name='Rate' type='d' access='readwrite'/>
<property name='Shuffle' type='b' access='readwrite'/>
<property name='Metadata' type='a{sv}' access='read'/>
<property name='Volume' type='d' access='readwrite'/>
<property name='Position' type='x' access='read'/>
<property name='MinimumRate' type='d' access='read'/>
<property name='MaximumRate' type='d' access='read'/>
<property name='CanGoNext' type='b' access='read'/>
<property name='CanGoPrevious' type='b' access='read'/>
<property name='CanPlay' type='b' access='read'/>
<property name='CanPause' type='b' access='read'/>
<property name='CanSeek' type='b' access='read'/>
<property name='CanControl' type='b' access='read'/>
<interface name='org.mpris.MediaPlayer2.TrackList'>
<method name='GetTracksMetadata'>
<arg direction='in' name='TrackIds' type='ao'/>
<arg direction='out' name='Metadata' type='aa{sv}'/>
<method name='AddTrack'>
<arg direction='in' name='Uri' type='s'/>
<arg direction='in' name='AfterTrack' type='o'/>
<arg direction='in' name='SetAsCurrent' type='b'/>
<method name='RemoveTrack'>
<arg direction='in' name='TrackId' type='o'/>
<method name='GoTo'>
<arg direction='in' name='TrackId' type='o'/>
<signal name='TrackListReplaced'>
<arg name='Tracks' type='ao'/>
<arg name='CurrentTrack' type='o'/>
<signal name='TrackAdded'>
<arg name='Metadata' type='a{sv}'/>
<arg name='AfterTrack' type='o'/>
<signal name='TrackRemoved'>
<arg name='TrackId' type='o'/>
<signal name='TrackMetadataChanged'>
<arg name='TrackId' type='o'/>
<arg name='Metadata' type='a{sv}'/>
<property name='Tracks' type='ao' access='read'/>
<property name='CanEditTracks' type='b' access='read'/>
<interface name='org.mpris.MediaPlayer2.Playlists'>
<method name='ActivatePlaylist'>
<arg direction='in' name='PlaylistId' type='o'/>
<method name='GetPlaylists'>
<arg direction='in' name='Index' type='u'/>
<arg direction='in' name='MaxCount' type='u'/>
<arg direction='in' name='Order' type='s'/>
<arg direction='in' name='ReverseOrder' type='b'/>
<arg direction='out' type='a(oss)'/>
<property name='PlaylistCount' type='u' access='read'/>
<property name='Orderings' type='as' access='read'/>
<property name='ActivePlaylist' type='(b(oss))' access='read'/>
......@@ -399,6 +399,37 @@ engine_load_uri (GstEngine * engine, gchar * uri)
return TRUE;
engine_open_uri (GstEngine * engine, gchar * uri)
g_print ("opennning uriii! %s \n", uri);
g_object_set (G_OBJECT (engine->player), "uri", uri, NULL);
gst_element_set_state (engine->player, GST_STATE_READY);
return TRUE;
engine_play (GstEngine * engine)
g_print ("Plaaayingg\n");
gst_element_set_state (engine->player, GST_STATE_PLAYING);
return TRUE;
engine_stop (GstEngine * engine)
g_print ("Stopping\n");
gst_element_set_state (engine->player, GST_STATE_READY);
return TRUE;
frame_stepping (GstEngine * engine, gboolean foward)
......@@ -23,6 +23,8 @@
#ifndef __GST_ENGINE_H__
#define __GST_ENGINE_H__
#include <gst/gst.h>
typedef struct _GstEngine GstEngine;
......@@ -51,6 +53,9 @@ gboolean at_the_eos (GstEngine * engine);
gboolean bus_call (GstBus * bus, GstMessage * msg, gpointer data);
gboolean engine_init (GstEngine * engine, GstElement * sink);
gboolean engine_load_uri (GstEngine * engine, gchar * uri);
gboolean engine_open_uri (GstEngine * engine, gchar * uri);
gboolean engine_play (GstEngine * engine);
gboolean engine_stop (GstEngine * engine);
gboolean frame_stepping (GstEngine * engine, gboolean foward);
gchar **get_recently_played ();
GstState get_state (GstEngine * engine);
......@@ -238,9 +238,9 @@ my_object_change_uri (SnappyMP * myobj, gchar * uri)
myobj->uri = uri;
g_print ("changing uri: %s\n", uri);
g_object_notify (G_OBJECT (myobj), "uri");
g_signal_emit (myobj, mediaplayer_signals[OPEN_URI], 0);
g_object_set (G_OBJECT (myobj), "uri", uri, NULL);
engine_open_uri (myobj->engine, uri);
static void
......@@ -292,30 +292,21 @@ handle_method_call (GDBusConnection * connection,
if (g_strcmp0 (method_name, "OpenUri") == 0) {
gchar *uri;
g_print ("name: %s\n", myobj->name);
g_variant_get (parameters, "(s)", &uri);
my_object_change_uri (myobj, uri);
g_dbus_method_invocation_return_value (invocation, NULL);
} else if (g_strcmp0 (method_name, "Next") == 0) {
g_print ("next\n");
/// ToDo: next track call
g_print ("name: %s\n", myobj->name);
handle_result (invocation, ret, error);
} else if (g_strcmp0 (method_name, "Play") == 0) {
// send play signal
g_print ("name: %s\n", myobj->name);
engine_play (myobj->engine);
handle_result (invocation, ret, error);
} else if (g_strcmp0 (method_name, "Stop") == 0) {
// send stop signal
g_print ("name: %s\n", myobj->name);
engine_stop (myobj->engine);
handle_result (invocation, ret, error);
......@@ -332,7 +323,7 @@ handle_get_property (GDBusConnection * connection,
GVariant *ret;
SnappyMP *myobj = user_data;
g_print ("handle_get_property: %s\n", property_name);
// g_print ("handle_get_property: %s\n", property_name);
ret = NULL;
if (g_strcmp0 (property_name, "Name") == 0) {
......@@ -26,6 +26,8 @@
#include <gio/gio.h>
#include <glib-object.h>
#include "gst_engine.h"
#define MPRIS_BUS_NAME_PREFIX "org.mpris.MediaPlayer2"
......@@ -70,6 +72,8 @@ struct _SnappyMP
gint64 last_elapsed;
gchar *uri;
GstEngine *engine;
struct _SnappyMPClass
* snappy - 0.1
* snappy - 0.2 beta
* Copyright (C) 2011 Collabora Multimedia Ltd.
* <>
* <>
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -20,7 +20,7 @@
#define VERSION "0.1"
#define VERSION "0.2 beta"
#include <stdlib.h>
#include <unistd.h>
......@@ -29,8 +29,8 @@
#include <clutter-gst/clutter-gst.h>
#include "user_interface.h"
#include "gst_engine.h"
#include "mpris.h"
#include "gst_engine.h"
#include "utils.h"
......@@ -160,14 +160,16 @@ main (int argc, char *argv[])
config_load ();
// User Interface
ui = g_new0 (UserInterface, 1);
ui = g_new (UserInterface, 1);
ui->fullscreen = fullscreen;
video_texture = clutter_texture_new ();
clutter_gst_init (&argc, &argv);
// Gstreamer
engine = g_new0 (GstEngine, 1);
engine = g_new (GstEngine, 1);
engine->media_width = -1;
engine->media_height = -1;
ui->engine = engine;
sink = clutter_gst_video_sink_new (CLUTTER_TEXTURE (video_texture));
......@@ -192,10 +194,11 @@ main (int argc, char *argv[])
change_state (engine, "Paused");
change_state (engine, "Playing");
mp_obj = g_new0 (SnappyMP, 1);
mp_obj = g_new (SnappyMP, 1);
mp_obj->engine = engine;
load_mpris (mp_obj);
g_signal_connect (mp_obj, "open-uri",
G_CALLBACK (open_uri_callback), engine);
// g_signal_connect (mp_obj, "open-uri",
// G_CALLBACK (open_uri_callback), engine);
clutter_main ();
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment