From d828f869258cbba6db169aca6c2c7ed3ba065969 Mon Sep 17 00:00:00 2001 From: Jens Georg Date: Mon, 9 Jul 2012 20:51:06 +0200 Subject: [PATCH] core,server,examples,doc: Add librygel-server https://bugzilla.gnome.org/show_bug.cgi?id=679648 --- configure.ac | 3 + doc/reference/Makefile.am | 2 +- doc/reference/librygel-server/Makefile.am | 62 +++++++++++++++++++ examples/Makefile.am | 9 ++- examples/standalone-server.c | 93 +++++++++++++++++++++++++++++ rygel-server-1.0.pc.in | 12 ++++ src/Makefile.am | 4 +- src/librygel-server/Makefile.am | 18 ++++++ src/librygel-server/filelist.am | 6 ++ src/librygel-server/rygel-media-server.vala | 32 ++++++++++ 10 files changed, 237 insertions(+), 4 deletions(-) create mode 100644 doc/reference/librygel-server/Makefile.am create mode 100644 examples/standalone-server.c create mode 100644 rygel-server-1.0.pc.in create mode 100644 src/librygel-server/Makefile.am create mode 100644 src/librygel-server/filelist.am create mode 100644 src/librygel-server/rygel-media-server.vala diff --git a/configure.ac b/configure.ac index 6e19f60..78071a4 100644 --- a/configure.ac +++ b/configure.ac @@ -223,6 +223,7 @@ Makefile src/Makefile src/librygel-core/Makefile src/librygel-renderer/Makefile +src/librygel-server/Makefile src/rygel/Makefile src/ui/Makefile src/plugins/Makefile @@ -240,9 +241,11 @@ doc/Makefile doc/reference/Makefile doc/reference/librygel-core/Makefile doc/reference/librygel-renderer/Makefile +doc/reference/librygel-server/Makefile po/Makefile.in rygel-core-1.0.pc rygel-renderer-1.0.pc +rygel-server-1.0.pc tests/Makefile examples/Makefile ]) diff --git a/doc/reference/Makefile.am b/doc/reference/Makefile.am index fc2a7f7..b911f1b 100644 --- a/doc/reference/Makefile.am +++ b/doc/reference/Makefile.am @@ -1 +1 @@ -SUBDIRS = librygel-core librygel-renderer +SUBDIRS = librygel-core librygel-renderer librygel-server diff --git a/doc/reference/librygel-server/Makefile.am b/doc/reference/librygel-server/Makefile.am new file mode 100644 index 0000000..689cae2 --- /dev/null +++ b/doc/reference/librygel-server/Makefile.am @@ -0,0 +1,62 @@ +if ENABLE_VALADOC + +include $(top_srcdir)/common.am +include $(top_srcdir)/src/librygel-server/filelist.am + +# Note that LIBRYGEL_RENDERER_NONVAPI_SOURCE_FILES all (should) use the internal keyword +# so they are not shown as part of the public API. +VALA_SOURCE_FILES = $(LIBRYGEL_RENDERER_VAPI_SOURCE_FILES) +# There are no LIBRYGEL_RENDERER_NONVAPI_SOURCE_FILES + +VALA_SOURCE_FILES_WITH_PATHS = $(addprefix $(top_srcdir)/src/librygel-server/, $(VALA_SOURCE_FILES)) + +#debug: +# echo $(VALA_SOURCE_FILES_WITH_PATHS); + +# TODO: The need for rygel-build-config here reminds us that we shouldn't need that in librygel-server either. +# TODO: Why is gstreamer-pbutils-0.10 needed here, but not needed in librygel-server/Makefile.am? +VALADOC_FLAGS = --force \ + --vapidir $(top_srcdir)/src/librygel-core \ + --pkg rygel-core-1.0 \ + --vapidir $(top_srcdir)/src/librygel-server \ + $(RYGEL_COMMON_VALAFLAGS_PKG) \ + $(LIBRYGEL_RENDERER_VALAFLAGS_PKG) \ + --pkg gstreamer-pbutils-0.10 \ + --target-glib=2.32 \ + --vapidir=$(rygeldir) \ + --pkg rygel-build-config \ + -b $(top_srcdir)/src/librygel-server \ + --package-name librygel-server \ + --package-version 1.0 \ + $(VALA_SOURCE_FILES_WITH_PATHS) + +valadoc: $(VALA_SOURCE_FILES_WITH_PATHS) + $(AM_V_GEN)$(VALADOC) \ + -o valadoc \ + $(VALADOC_FLAGS) 2>/dev/null + +gtkdoc: $(VALA_SOURCE_FILES_WITH_PATHS) + @rm -rf gtkdoc + $(AM_V_GEN)$(VALADOC) \ + -X $(top_builddir)/src/librygel-server/rygel-server.h \ + -X -l -X $(top_builddir)/src/librygel-server/.libs/librygel-server-1.0.so \ + -o gtkdoc \ + --doclet gtkdoc \ + $(VALADOC_FLAGS) 2>/dev/null + +clean-local: + rm -rf valadoc gtkdoc + +uninstall-hook: + rm -rf $(DESTDIR)$(datadir)/gtk-doc/html/librygel-server + +# The chmod corrects the directory permissions so that distcheck can remove the installed files. +install-data-hook: gtkdoc + cp -d -R $(srcdir)/gtkdoc/html $(DESTDIR)$(datadir)/gtk-doc/html/librygel-server + chmod -R u+w $(DESTDIR)$(datadir)/gtk-doc/html/librygel-server + +all: valadoc gtkdoc + +EXTRA_DIST = gtkdoc valadoc + +endif diff --git a/examples/Makefile.am b/examples/Makefile.am index fd97f3e..e7bb7dd 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -3,11 +3,18 @@ include ../common.am AM_CFLAGS += \ -I$(top_builddir)/src/librygel-renderer \ -I$(top_srcdir)/src/librygel-renderer \ + -I$(top_builddir)/src/librygel-server \ + -I$(top_srcdir)/src/librygel-server \ -I$(top_builddir)/src/rygel \ -I$(top_srcdir)/src/rygel -noinst_PROGRAMS = standalone-renderer +noinst_PROGRAMS = standalone-renderer standalone-server standalone_renderer_SOURCES = standalone-renderer.c standalone_renderer_LDADD = \ $(top_builddir)/src/librygel-renderer/librygel-renderer-1.0.la \ $(RYGEL_COMMON_LIBS) + +standalone_server_SOURCES = standalone-server.c +standalone_server_LDADD = \ + $(top_builddir)/src/librygel-server/librygel-server-1.0.la \ + $(RYGEL_COMMON_LIBS) diff --git a/examples/standalone-server.c b/examples/standalone-server.c new file mode 100644 index 0000000..726e92c --- /dev/null +++ b/examples/standalone-server.c @@ -0,0 +1,93 @@ + +#include +#include +#include + +int main (int argc, char *argv[]) +{ + RygelMediaServer *server; + RygelSimpleContainer *root_container; + char *path; + GFile *source_dir; + GFileEnumerator *enumerator; + GFileInfo *info; + int i; + GMainLoop *loop; + + g_type_init (); + + gst_init (&argc, &argv); + + g_set_application_name ("Standalone-Server"); + + root_container = rygel_simple_container_new_root ("Sample implementation"); + if (argc >= 2) { + path = g_strdup (argv[1]); + } else { + path = g_get_current_dir (); + } + + source_dir = g_file_new_for_commandline_arg (path); + g_free (path); + + enumerator = g_file_enumerate_children (source_dir, + G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME "," + G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE, + G_FILE_QUERY_INFO_NONE, + NULL, + NULL); + info = g_file_enumerator_next_file (enumerator, NULL, NULL); + i = 0; + while (info != NULL) { + GFile *file; + const char *display_name, *content_type; + char *uri, *id; + RygelMediaItem *item = NULL; + GError *error = NULL; + + display_name = g_file_info_get_display_name (info); + content_type = g_file_info_get_content_type (info); + file = g_file_get_child_for_display_name (source_dir, display_name, &error); + if (error != NULL) { + g_critical ("Failed to get child: %s", error->message); + + return 127; + } + uri = g_file_get_uri (file); + g_object_unref (file); + id = g_strdup_printf ("%06d", i); + + if (g_str_has_prefix (content_type, "audio/")) { + item = rygel_audio_item_new (id, + root_container, + display_name, + RYGEL_AUDIO_ITEM_UPNP_CLASS); + } else if (g_str_has_prefix (content_type, "video/")) { + item = rygel_video_item_new (id, + root_container, + display_name, + RYGEL_VIDEO_ITEM_UPNP_CLASS); + } else if (g_str_has_prefix (content_type, "image/")) { + item = rygel_image_item_new (id, + root_container, + display_name, + RYGEL_IMAGE_ITEM_UPNP_CLASS); + } + g_free (id); + + if (item != NULL) { + RYGEL_MEDIA_ITEM (item)->mime_type = g_strdup (content_type); + rygel_simple_container_add_child_item (root_container, item); + } + + i++; + info = g_file_enumerator_next_file (enumerator, NULL, NULL); + } + + server = rygel_media_server_new ("LibRygel sample server", root_container); + rygel_media_device_add_interface (RYGEL_MEDIA_DEVICE (server), "eth0"); + rygel_media_device_add_interface (RYGEL_MEDIA_DEVICE (server), "wlan0"); + + loop = g_main_loop_new (NULL, FALSE); + g_main_loop_run (loop); +} diff --git a/rygel-server-1.0.pc.in b/rygel-server-1.0.pc.in new file mode 100644 index 0000000..aeef7ef --- /dev/null +++ b/rygel-server-1.0.pc.in @@ -0,0 +1,12 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: rygel-server-1.0 +Description: GNOME (Mobile) UPnP/DLNA Media server library +Version: @VERSION@ +Libs: -L${libdir} -lrygel-server-1.0 +Cflags: -I${includedir}/rygel-1.0 +Requires: gupnp-av-1.0 gee-1.0 gstreamer-0.10 rygel-core-1.0 +Requires.Private: uuid gmodule-2.0 diff --git a/src/Makefile.am b/src/Makefile.am index 4c8c773..2426f6f 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,7 +1,7 @@ if BUILD_UI -SUBDIRS = librygel-core librygel-renderer rygel ui plugins +SUBDIRS = librygel-core librygel-renderer librygel-server rygel ui plugins else -SUBDIRS = librygel-core librygel-renderer rygel plugins +SUBDIRS = librygel-core librygel-renderer librygel-server rygel plugins endif MAINTAINERCLEANFILES = Makefile.in diff --git a/src/librygel-server/Makefile.am b/src/librygel-server/Makefile.am new file mode 100644 index 0000000..a35ce56 --- /dev/null +++ b/src/librygel-server/Makefile.am @@ -0,0 +1,18 @@ +include ../../common.am +include $(srcdir)/filelist.am + +lib_LTLIBRARIES = librygel-server-1.0.la + +LIBRYGEL_SERVER_VERSION=0:0:0 + +librygel_server_1_0_la_SOURCES = \ + $(LIBRYGEL_SERVER_VAPI_SOURCE_FILES) \ + $(LIBRYGEL_SERVER_NONVAPI_SOURCE_FILES) + +librygel_server_1_0_la_VALAFLAGS = \ + -H rygel-server.h --library=rygel-server-1.0 \ + $(RYGEL_COMMON_PLUGIN_VALAFLAGS) +librygel_server_1_0_la_LIBADD = $(RYGEL_COMMON_LIBS) +librygel_server_1_0_la_LDFLAGS = -version-info $(LIBRYGEL_SERVER_VERSION) + +rygel-server.h rygel-server-1.0.vapi: librygel_server_1_0_la_vala.stamp diff --git a/src/librygel-server/filelist.am b/src/librygel-server/filelist.am new file mode 100644 index 0000000..16ead91 --- /dev/null +++ b/src/librygel-server/filelist.am @@ -0,0 +1,6 @@ +LIBRYGEL_SERVER_VAPI_SOURCE_FILES = \ + rygel-media-server.vala + +LIBRYGEL_SERVER_NONVAPI_SOURCE_FILES = + +LIBRYGEL_SERVER_VALAFLAGS_PKG = diff --git a/src/librygel-server/rygel-media-server.vala b/src/librygel-server/rygel-media-server.vala new file mode 100644 index 0000000..cfd0e30 --- /dev/null +++ b/src/librygel-server/rygel-media-server.vala @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2012 Openismus GmbH. + * + * Author: Jens Georg + * + * Rygel is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Rygel 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +internal class Plugin : Rygel.MediaServerPlugin { + public Plugin (Rygel.MediaContainer root_container) { + base (root_container, _("LibRygelServer")); + } +} + +public class Rygel.MediaServer : MediaDevice { + public MediaServer (string title, MediaContainer root_container) { + base (); + this.plugin = new global::Plugin (root_container); + } +} -- 2.7.4