[libdmapsharing] Work on Vala code, including start of dacplisten test application Signed-off-by: W. Michael Petullo
- From: W. Michael Petullo <wmpetullo src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libdmapsharing] Work on Vala code, including start of dacplisten test application Signed-off-by: W. Michael Petullo
- Date: Sat, 8 Jan 2011 02:43:22 +0000 (UTC)
commit 07b3a22a7b1c5b5e167364ac2406c7c4edc8e3b3
Author: W. Michael Petullo <mike flyn org>
Date: Thu Jan 6 21:27:22 2011 -0600
Work on Vala code, including start of dacplisten test application
Signed-off-by: W. Michael Petullo <mike flyn org>
libdmapsharing/dacp-player.h | 84 +++++++++++++++++++++++++++++++++++++----
tests/Makefile.am | 21 +++++++++-
tests/dacplisten.vala | 72 ++++++++++++++++++++++++++++++++++++
tests/dpapview.vala | 2 +-
tests/vala-dpap-record.vala | 9 ++--
vala/Makefile.am | 1 +
6 files changed, 171 insertions(+), 18 deletions(-)
---
diff --git a/libdmapsharing/dacp-player.h b/libdmapsharing/dacp-player.h
index 90eef01..b402075 100644
--- a/libdmapsharing/dacp-player.h
+++ b/libdmapsharing/dacp-player.h
@@ -27,27 +27,51 @@
G_BEGIN_DECLS
+/**
+ * DACP_TYPE_PLAYER:
+ *
+ * The type for #DACPPlayer.
+ */
#define DACP_TYPE_PLAYER (dacp_player_get_type ())
-#define DACP_PLAYER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DACP_TYPE_PLAYER, DACPPlayer))
-#define IS_DACP_PLAYER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DACP_TYPE_PLAYER))
-#define DACP_PLAYER_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), \
+
+/**
+ * DACP_PLAYER:
+ * @o: Object which is subject to casting.
+ *
+ * Casts a #DACPPlayer or derived pointer into a (DACPPlayer *) pointer.
+ * Depending on the current debugging level, this function may invoke
+ * certain runtime checks to identify invalid casts.
+ */
+#define DACP_PLAYER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), DACP_TYPE_PLAYER, DACPPlayer))
+
+/**
+ * IS_DACP_PLAYER:
+ * @o: Instance to check for being a %DACP_TYPE_PLAYER.
+ *
+ * Checks whether a valid #GTypeInstance pointer is of type %DACP_TYPE_PLAYER.
+ */
+#define IS_DACP_PLAYER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), DACP_TYPE_PLAYER))
+
+/**
+ * DACP_PLAYER_GET_INTERFACE:
+ * @o: a #DACPPlayer instance.
+ *
+ * Get the insterface structure associated to a #DACPPlayer instance.
+ *
+ * Returns: pointer to object interface structure.
+ */
+#define DACP_PLAYER_GET_INTERFACE(o) (G_TYPE_INSTANCE_GET_INTERFACE ((o), \
DACP_TYPE_PLAYER, DACPPlayerIface))
typedef struct _DACPPlayerIface DACPPlayerIface;
typedef struct _DACPPlayer DACPPlayer;
-/**
- * DACPRepeatState:
- */
typedef enum {
REPEAT_NONE = 0,
REPEAT_SINGLE = 1,
REPEAT_ALL = 2
} DACPRepeatState;
-/**
- * DACPPlayState:
- */
typedef enum {
PLAY_STOPPED = 2,
PLAY_PAUSED = 3,
@@ -71,14 +95,56 @@ struct _DACPPlayerIface
GType dacp_player_get_type (void);
+/**
+ * dacp_player_now_playing_record
+ * @player: a player
+ */
DAAPRecord *dacp_player_now_playing_record (DACPPlayer *player);
+
+/**
+ * dacp_player_now_playing_artwork
+ * @player: a player
+ * @width: width
+ * @height: height
+ */
gchar *dacp_player_now_playing_artwork (DACPPlayer *player, guint width, guint height);
+
+/**
+ * dacp_player_play_pause
+ * @player: a player
+ */
void dacp_player_play_pause (DACPPlayer *player);
+
+/**
+ * dacp_player_pause
+ * @player: a player
+ */
void dacp_player_pause (DACPPlayer *player);
+
+/**
+ * dacp_player_next_item
+ * @player: a player
+ */
void dacp_player_next_item (DACPPlayer *player);
+
+/**
+ * dacp_player_now_prev_item
+ * @player: a player
+ */
void dacp_player_prev_item (DACPPlayer *player);
+/**
+ * dacp_player_cue_clear
+ * @player: a player
+ */
void dacp_player_cue_clear (DACPPlayer *player);
+
+/**
+ * dacp_player_cue_play
+ * @player: a player
+ * @records : a list of records
+ * @index: an index
+ */
void dacp_player_cue_play (DACPPlayer *player, GList *records, guint index);
G_END_DECLS
diff --git a/tests/Makefile.am b/tests/Makefile.am
index d7db163..3c9b648 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,7 +1,7 @@
noinst_PROGRAMS = test-dmap-client test-dmap-server
if HAVE_VALA
-noinst_PROGRAMS += dpapview dmapcopy dmapserve
+noinst_PROGRAMS += dacplisten dpapview dmapcopy dmapserve
endif
test_dmap_client_SOURCES = \
@@ -45,7 +45,11 @@ test_dmap_server_LDADD = \
$(MDNS_LIBS)
if MAINTAINER_MODE
-BUILT_SOURCES = dpapview.stamp dmapcopy.stamp dmapserve.stamp
+BUILT_SOURCES = dacplisten.stamp dpapview.stamp dmapcopy.stamp dmapserve.stamp
+
+dacplisten.stamp: $(dacplisten_VALASOURCES)
+ $(VALAC) --vapidir=../vala --pkg gee-1.0 --pkg gstreamer-0.10 --pkg libdmapsharing-3.0 --pkg libsoup-2.4 --pkg glib-2.0 $^ -C
+ touch $@
dpapview.stamp: $(dpapview_VALASOURCES)
$(VALAC) --vapidir=../vala --pkg gee-1.0 --pkg gtk+-2.0 --pkg gstreamer-0.10 --pkg libdmapsharing-3.0 --pkg libsoup-2.4 --pkg glib-2.0 $^ -C
@@ -61,6 +65,18 @@ dmapserve.stamp: $(dmapserve_VALASOURCES)
endif
if HAVE_VALA
+dacplisten_VALASOURCES = \
+ dacplisten.vala
+
+dacplisten_VALABUILTSOURCES = $(dacplisten_VALASOURCES:.vala=.c)
+
+dacplisten_SOURCES = \
+ $(dacplisten_VALABUILTSOURCES)
+
+dacplisten_LDADD = \
+ $(top_builddir)/libdmapsharing/libdmapsharing-3.0.la \
+ $(GEE_LIBS)
+
dpapview_VALASOURCES = \
dpapview.vala \
vala-dmap-db.vala \
@@ -140,4 +156,3 @@ CLEANFILES = \
$(BUILT_SOURCES) \
$(dpapview_VALABUILTSOURCES)
endif
-
diff --git a/tests/dacplisten.vala b/tests/dacplisten.vala
new file mode 100644
index 0000000..1ff9bff
--- /dev/null
+++ b/tests/dacplisten.vala
@@ -0,0 +1,72 @@
+/* FILE: dacplisten.vala -- Listen to DACP remotes
+ * AUTHOR: W. Michael Petullo <mike flyn org>
+ * DATE: 06 January 2011
+ *
+ * Copyright (c) 2011 W. Michael Petullo <new flyn org>
+ * All rights reserved.
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+private class ValaDACPPlayer : DACP.Player {
+
+ unowned DAAP.Record now_playing_record () {
+ stdout.printf ("Now playing record request received");
+ return null;
+ }
+
+ /* FIXME: This should return uint8[], modify dacp-player.h? */
+ unowned string now_playing_artwork (uint width, uint heigth) {
+ stdout.printf ("Now playing artwork request received");
+ return null;
+ }
+
+ void play_pause () {
+ stdout.printf ("Play/pause request received");
+ }
+
+ void pause () {
+ stdout.printf ("Pause request received");
+ }
+
+ void next_item () {
+ stdout.printf ("Next item request received");
+ }
+
+ void prev_item () {
+ stdout.printf ("Previous item request received");
+ }
+
+ void cue_clear () {
+ stdout.printf ("Cue clear request received");
+ }
+
+ void cue_play (GLib.List records, uint index) {
+ stdout.printf ("Cue play request received");
+ }
+}
+
+private class DACPListener {
+}
+
+int main (string[] args) {
+ var loop = new GLib.MainLoop ();
+
+ var dacplistener = new DACPListener ();
+
+ loop.run ();
+
+ return 0;
+}
diff --git a/tests/dpapview.vala b/tests/dpapview.vala
index 57b4586..79394ba 100644
--- a/tests/dpapview.vala
+++ b/tests/dpapview.vala
@@ -35,7 +35,7 @@ private class DPAPViewer {
if (((ValaDPAPRecord) v).filesize > 0) {
string path;
int fd = GLib.FileUtils.open_tmp ("dpapview.XXXXXX", out path);
- GLib.FileUtils.set_contents (path, (string) ((ValaDPAPRecord) v).thumbnail, ((ValaDPAPRecord) v).filesize);
+ GLib.FileUtils.set_data (path, ((ValaDPAPRecord) v).thumbnail);
GLib.FileUtils.close (fd);
pixbuf = new Gdk.Pixbuf.from_file (path);
GLib.FileUtils.unlink (path);
diff --git a/tests/vala-dpap-record.vala b/tests/vala-dpap-record.vala
index c1c972d..c4185e6 100644
--- a/tests/vala-dpap-record.vala
+++ b/tests/vala-dpap-record.vala
@@ -26,7 +26,7 @@ private class ValaDPAPRecord : GLib.Object, DMAP.Record, DPAP.Record {
private string _aspect_ratio;
private string _format;
private string _comments;
- private string _thumbnail;
+ private uint8[] _thumbnail;
private int _filesize;
private int _large_filesize;
private int _pixel_height;
@@ -54,7 +54,7 @@ private class ValaDPAPRecord : GLib.Object, DMAP.Record, DPAP.Record {
set { _format = value; }
}
- public string thumbnail {
+ public uint8[] thumbnail {
get { return _thumbnail; }
set { _thumbnail = value; }
}
@@ -118,10 +118,9 @@ private class ValaDPAPRecord : GLib.Object, DMAP.Record, DPAP.Record {
_rating = 5;
_creation_date = 0;
- size_t size;
string path = GLib.Environment.get_current_dir () + "/media/test.jpeg";
- GLib.FileUtils.get_contents (path, out _thumbnail, out size);
- _filesize = (int) size;
+ GLib.FileUtils.get_data (path, out _thumbnail);
+ _filesize = _thumbnail.length;
}
}
diff --git a/vala/Makefile.am b/vala/Makefile.am
index 64eb36b..2eaef10 100644
--- a/vala/Makefile.am
+++ b/vala/Makefile.am
@@ -35,6 +35,7 @@ libdmapsharing- API_VERSION@.vapi: libdmapsharing- API_VERSION@-daap.vapi libdma
sed 's/DPAP\.DMAPDb/DMAP.Db/g' | \
sed 's/DAAP\.DMAPRecordFactory/DMAP.RecordFactory/g' | \
sed 's/DPAP\.DMAPRecordFactory/DMAP.RecordFactory/g' | \
+ sed 's/DACP\.DAAPRecord/DAAP.Record/g' | \
cat > libdmapsharing- API_VERSION@.vapi.tmp
mv libdmapsharing- API_VERSION@.vapi.tmp libdmapsharing- API_VERSION@.vapi
rm -f libdmapsharing- API_VERSION@-daap.vapi libdmapsharing- API_VERSION@-dacp.vapi libdmapsharing- API_VERSION@-dmap.vapi libdmapsharing- API_VERSION@-dpap.vapi
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]