diff options
-rw-r--r-- | .gitignore | 4 | ||||
-rw-r--r-- | configure.ac | 14 | ||||
-rw-r--r-- | src/Makefile.am | 108 | ||||
-rw-r--r-- | src/client/context.c (renamed from src/client/pv-context.c) | 301 | ||||
-rw-r--r-- | src/client/context.h | 113 | ||||
-rw-r--r-- | src/client/introspect.c (renamed from src/client/pv-introspect.c) | 30 | ||||
-rw-r--r-- | src/client/introspect.h (renamed from src/client/pv-introspect.h) | 60 | ||||
-rw-r--r-- | src/client/pinos.c | 9 | ||||
-rw-r--r-- | src/client/pinos.h | 20 | ||||
-rw-r--r-- | src/client/private.h (renamed from src/client/pv-private.h) | 10 | ||||
-rw-r--r-- | src/client/pv-context.h | 113 | ||||
-rw-r--r-- | src/client/pv-stream.h | 125 | ||||
-rw-r--r-- | src/client/pv-subscribe.h | 106 | ||||
-rw-r--r-- | src/client/stream.c (renamed from src/client/pv-stream.c) | 427 | ||||
-rw-r--r-- | src/client/stream.h | 125 | ||||
-rw-r--r-- | src/client/subscribe.c (renamed from src/client/pv-subscribe.c) | 301 | ||||
-rw-r--r-- | src/client/subscribe.h | 106 | ||||
-rw-r--r-- | src/daemon/main.c | 14 | ||||
-rw-r--r-- | src/gst/gstpinos.c (renamed from src/gst/gstpv.c) | 8 | ||||
-rw-r--r-- | src/gst/gstpinossink.c (renamed from src/gst/gstpvsink.c) | 138 | ||||
-rw-r--r-- | src/gst/gstpinossink.h (renamed from src/gst/gstpvsink.h) | 10 | ||||
-rw-r--r-- | src/gst/gstpinossrc.c (renamed from src/gst/gstpvsrc.c) | 146 | ||||
-rw-r--r-- | src/gst/gstpinossrc.h (renamed from src/gst/gstpvsrc.h) | 10 | ||||
-rw-r--r-- | src/modules/gst/gst-manager.c (renamed from src/modules/gst/pv-gst-manager.c) | 100 | ||||
-rw-r--r-- | src/modules/gst/gst-manager.h | 60 | ||||
-rw-r--r-- | src/modules/gst/gst-source.c (renamed from src/modules/gst/pv-gst-source.c) | 109 | ||||
-rw-r--r-- | src/modules/gst/gst-source.h | 63 | ||||
-rw-r--r-- | src/modules/gst/pv-gst-manager.h | 60 | ||||
-rw-r--r-- | src/modules/gst/pv-gst-source.h | 61 | ||||
-rw-r--r-- | src/server/client-source.c (renamed from src/server/pv-client-source.c) | 124 | ||||
-rw-r--r-- | src/server/client-source.h | 77 | ||||
-rw-r--r-- | src/server/client.c (renamed from src/server/pv-client.c) | 242 | ||||
-rw-r--r-- | src/server/client.h | 76 | ||||
-rw-r--r-- | src/server/daemon.c (renamed from src/server/pv-daemon.c) | 228 | ||||
-rw-r--r-- | src/server/daemon.h | 89 | ||||
-rw-r--r-- | src/server/pv-client-source.h | 77 | ||||
-rw-r--r-- | src/server/pv-client.h | 76 | ||||
-rw-r--r-- | src/server/pv-daemon.h | 87 | ||||
-rw-r--r-- | src/server/pv-source-output.h | 70 | ||||
-rw-r--r-- | src/server/pv-source.h | 101 | ||||
-rw-r--r-- | src/server/source-output.c (renamed from src/server/pv-source-output.c) | 135 | ||||
-rw-r--r-- | src/server/source-output.h | 70 | ||||
-rw-r--r-- | src/server/source.c (renamed from src/server/pv-source.c) | 237 | ||||
-rw-r--r-- | src/server/source.h | 102 | ||||
-rw-r--r-- | src/tests/test-client.c | 36 | ||||
-rw-r--r-- | src/tests/test-subscribe.c | 24 |
46 files changed, 2334 insertions, 2268 deletions
@@ -35,3 +35,7 @@ missing mkinstalldirs stamp-* .dirstamp +pkgconfig/libpinos.pc +src/client/enumtypes.c +src/client/enumtypes.h + diff --git a/configure.ac b/configure.ac index 7db05678..7c026565 100644 --- a/configure.ac +++ b/configure.ac @@ -11,15 +11,15 @@ AS_IF([! test -n "$VERSION"], [ AC_MSG_ERROR([git-version-gen failed]) ]) -m4_define(pa_major, `echo $VERSION | cut -d. -f1 | cut -d- -f1`) -m4_define(pa_minor, `echo $VERSION | cut -d. -f2 | cut -d- -f1`) +m4_define(pinos_major, `echo $VERSION | cut -d. -f1 | cut -d- -f1`) +m4_define(pinos_minor, `echo $VERSION | cut -d. -f2 | cut -d- -f1`) -AC_SUBST(PV_MAJOR, pa_major) -AC_SUBST(PV_MINOR, pa_minor) -AC_SUBST(PV_MAJORMINOR, pa_major.pa_minor) +AC_SUBST(PINOS_MAJOR, pinos_major) +AC_SUBST(PINOS_MINOR, pinos_minor) +AC_SUBST(PINOS_MAJORMINOR, pinos_major.pinos_minor) -AC_SUBST(PV_API_VERSION, 0) -AC_SUBST(PV_PROTOCOL_VERSION, 0) +AC_SUBST(PINOS_API_VERSION, 0) +AC_SUBST(PINOS_PROTOCOL_VERSION, 0) # The stable ABI for client applications, for the version info x:y:z # always will hold y=z diff --git a/src/Makefile.am b/src/Makefile.am index 3374c1f7..211ea9ce 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -32,8 +32,8 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/src \ -I$(top_srcdir)/src/modules \ -I$(top_builddir)/src/modules \ - -DPV_SRCDIR=\"$(abs_srcdir)\" \ - -DPV_BUILDDIR=\"$(abs_builddir)\" + -DPINOS_SRCDIR=\"$(abs_srcdir)\" \ + -DPINOS_BUILDDIR=\"$(abs_builddir)\" AM_CFLAGS = $(GLIB_CFLAGS) $(GST_CFLAGS) AM_CXXFLAGS = $(AM_CFLAGS) SERVER_CFLAGS = -D__INCLUDED_FROM_PINOS @@ -59,27 +59,27 @@ dbuspolicy_DATA = \ # Includes # ################################### -enumtypesincludes = client/pv-context.h \ - client/pv-introspect.h \ - client/pv-stream.h \ - client/pv-subscribe.h +enumtypesincludes = client/context.h \ + client/introspect.h \ + client/stream.h \ + client/subscribe.h -client/pv-enumtypes.h: $(enumtypesincludes) +client/enumtypes.h: $(enumtypesincludes) $(AM_V_GEN)$(GLIB_MKENUMS) \ - --fhead "#ifndef __PV_ENUM_TYPES_H__\n#define __PV_ENUM_TYPES_H__\n\n#include <glib-object.h>\n\nG_BEGIN_DECLS\n" \ + --fhead "#ifndef __PINOS_ENUM_TYPES_H__\n#define __PINOS_ENUM_TYPES_H__\n\n#include <glib-object.h>\n\nG_BEGIN_DECLS\n" \ --fprod "\n/* enumerations from \"@filename@\" */\n" \ - --vhead "GType @enum_name@_get_type (void);\n#define PV_TYPE_@ENUMSHORT@ (@enum_name@_get_type())\n" \ - --ftail "G_END_DECLS\n\n#endif /* __PV_ENUM_TYPES_H__ */" \ - $^ > client/pv-enumtypes.h + --vhead "GType @enum_name@_get_type (void);\n#define PINOS_TYPE_@ENUMSHORT@ (@enum_name@_get_type())\n" \ + --ftail "G_END_DECLS\n\n#endif /* __PINOS_ENUM_TYPES_H__ */" \ + $^ > client/enumtypes.h -client/pv-enumtypes.c: $(enumtypesincludes) client/pv-enumtypes.h +client/enumtypes.c: $(enumtypesincludes) client/enumtypes.h $(AM_V_GEN)$(GLIB_MKENUMS) \ - --fhead "#include \"pv-enumtypes.h\"\n#include <client/pinos.h>\n#define C_ENUM(v) ((gint) v)\n#define C_FLAGS(v) ((guint) v)\n " \ + --fhead "#include \"enumtypes.h\"\n#include <client/pinos.h>\n#define C_ENUM(v) ((gint) v)\n#define C_FLAGS(v) ((guint) v)\n " \ --fprod "\n/* enumerations from \"@filename@\" */" \ --vhead "GType\n@enum_name@_get_type (void)\n{\n static gsize id = 0;\n static const G@Type@Value values[] = {" \ --vprod " { C_@TYPE@(@VALUENAME@), \"@VALUENAME@\", \"@valuenick@\" }," \ --vtail " { 0, NULL, NULL }\n };\n\n if (g_once_init_enter (&id)) {\n GType tmp = g_@type@_register_static (\"@EnumName@\", values);\n g_once_init_leave (&id, tmp);\n }\n\n return (GType) id;\n}" \ - $^ > client/pv-enumtypes.c + $^ > client/enumtypes.c dbus/org-pinos.c: dbus/org-pinos.h @@ -88,12 +88,12 @@ dbus/org-pinos.h: dbus/org.pinos.xml --interface-prefix org.pinos. \ --generate-c-code dbus/org-pinos \ --generate-docbook ../doc/org-pinos \ - --c-namespace Pv dbus/org.pinos.xml \ + --c-namespace Pinos dbus/org.pinos.xml \ --c-generate-object-manager -built_header_make = client/pv-enumtypes.h dbus/org-pinos.h -built_source_make = client/pv-enumtypes.c dbus/org-pinos.c +built_header_make = client/enumtypes.h dbus/org-pinos.h +built_source_make = client/enumtypes.c dbus/org-pinos.c BUILT_SOURCES = $(built_header_make) \ $(built_source_make) @@ -110,9 +110,9 @@ pinos_SOURCES = \ daemon/main.c pinos_CFLAGS = $(AM_CFLAGS) -pinos_LDADD = $(AM_LDADD) libpinoscore-@PV_MAJORMINOR@.la libpinos-@PV_MAJORMINOR@.la $(LIBLTDL) +pinos_LDADD = $(AM_LDADD) libpinoscore-@PINOS_MAJORMINOR@.la libpinos-@PINOS_MAJORMINOR@.la $(LIBLTDL) # This is needed because automake doesn't properly expand the foreach below -pinos_DEPENDENCIES = libpinoscore-@PV_MAJORMINOR@.la libpinos-@PV_MAJORMINOR@.la +pinos_DEPENDENCIES = libpinoscore-@PINOS_MAJORMINOR@.la libpinos-@PINOS_MAJORMINOR@.la pinos_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS) $(IMMEDIATE_LDFLAGS) ################################### @@ -132,12 +132,12 @@ noinst_PROGRAMS = $(TESTS_default) $(TESTS_norun) $(TESTS_daemon) test_client_SOURCES = tests/test-client.c test_client_CFLAGS = $(AM_CFLAGS) -test_client_LDADD = $(AM_LDADD) libpinos-@PV_MAJORMINOR@.la +test_client_LDADD = $(AM_LDADD) libpinos-@PINOS_MAJORMINOR@.la test_client_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS) test_subscribe_SOURCES = tests/test-subscribe.c test_subscribe_CFLAGS = $(AM_CFLAGS) -test_subscribe_LDADD = $(AM_LDADD) libpinos-@PV_MAJORMINOR@.la +test_subscribe_LDADD = $(AM_LDADD) libpinos-@PINOS_MAJORMINOR@.la test_subscribe_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS) ################################### @@ -151,51 +151,51 @@ pinosgstsource = gst/gstfdpay.h gst/gstfdpay.c \ pinosinclude_HEADERS = \ client/pinos.h \ - client/pv-context.h \ - client/pv-enumtypes.h \ - client/pv-introspect.h \ - client/pv-stream.h \ - client/pv-subscribe.h + client/context.h \ + client/enumtypes.h \ + client/introspect.h \ + client/stream.h \ + client/subscribe.h lib_LTLIBRARIES = \ - libpinos-@PV_MAJORMINOR@.la + libpinos-@PINOS_MAJORMINOR@.la # Public interface -libpinos_@PV_MAJORMINOR@_la_SOURCES = \ - client/pv-context.h client/pv-context.c \ - client/pv-enumtypes.h client/pv-enumtypes.c \ - client/pv-introspect.h client/pv-introspect.c \ - client/pv-stream.h client/pv-stream.c \ +libpinos_@PINOS_MAJORMINOR@_la_SOURCES = \ + client/context.h client/context.c \ + client/enumtypes.h client/enumtypes.c \ + client/introspect.h client/introspect.c \ + client/stream.h client/stream.c \ client/pinos.c client/pinos.h \ - client/pv-subscribe.c client/pv-subscribe.h \ + client/subscribe.c client/subscribe.h \ $(pinosgstsource) -libpinos_@PV_MAJORMINOR@_la_CFLAGS = $(AM_CFLAGS) $(GST_CFLAGS) -libpinos_@PV_MAJORMINOR@_la_LDFLAGS = $(AM_LDFLAGS) -avoid-version -libpinos_@PV_MAJORMINOR@_la_LIBADD = $(AM_LIBADD) $(LTLIBICONV) $(GST_LIBS) +libpinos_@PINOS_MAJORMINOR@_la_CFLAGS = $(AM_CFLAGS) $(GST_CFLAGS) +libpinos_@PINOS_MAJORMINOR@_la_LDFLAGS = $(AM_LDFLAGS) -avoid-version +libpinos_@PINOS_MAJORMINOR@_la_LIBADD = $(AM_LIBADD) $(LTLIBICONV) $(GST_LIBS) ################################### # Daemon core library # ################################### -lib_LTLIBRARIES += libpinoscore-@PV_MAJORMINOR@.la +lib_LTLIBRARIES += libpinoscore-@PINOS_MAJORMINOR@.la # Pure core stuff -libpinoscore_@PV_MAJORMINOR@_la_SOURCES = \ - server/pv-client.c server/pv-client.h \ - server/pv-daemon.c server/pv-daemon.h \ - server/pv-source.c server/pv-source.h \ - server/pv-client-source.c server/pv-client-source.h \ - server/pv-source-output.c server/pv-source-output.h \ - modules/gst/pv-gst-manager.c \ - modules/gst/pv-gst-source.c \ +libpinoscore_@PINOS_MAJORMINOR@_la_SOURCES = \ + server/client.c server/client.h \ + server/daemon.c server/daemon.h \ + server/source.c server/source.h \ + server/client-source.c server/client-source.h \ + server/source-output.c server/source-output.h \ + modules/gst/gst-manager.c \ + modules/gst/gst-source.c \ dbus/org-pinos.c dbus/org-pinos.h -libpinoscore_@PV_MAJORMINOR@_la_CFLAGS = $(AM_CFLAGS) $(SERVER_CFLAGS) -libpinoscore_@PV_MAJORMINOR@_la_LDFLAGS = $(AM_LDFLAGS) -avoid-version -libpinoscore_@PV_MAJORMINOR@_la_LIBADD = $(AM_LIBADD) $(LIBLTDL) $(LTLIBICONV) \ - libpinos-@PV_MAJORMINOR@.la +libpinoscore_@PINOS_MAJORMINOR@_la_CFLAGS = $(AM_CFLAGS) $(SERVER_CFLAGS) +libpinoscore_@PINOS_MAJORMINOR@_la_LDFLAGS = $(AM_LDFLAGS) -avoid-version +libpinoscore_@PINOS_MAJORMINOR@_la_LIBADD = $(AM_LIBADD) $(LIBLTDL) $(LTLIBICONV) \ + libpinos-@PINOS_MAJORMINOR@.la ################################### # GStreamer Plugin # @@ -206,19 +206,19 @@ plugindir = $(libdir)/gstreamer-1.0 plugin_LTLIBRARIES = libgstpinos.la libgstpinos_la_SOURCES = \ - gst/gstpv.c \ + gst/gstpinos.c \ gst/gstfdpay.c \ gst/gstfddepay.c \ - gst/gstpvsrc.c \ - gst/gstpvsink.c + gst/gstpinossrc.c \ + gst/gstpinossink.c libgstpinos_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS) $(GLIB_CFLAGS) libgstpinos_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) libgstpinos_la_LIBADD = $(GST_BASE_LIBS) $(GST_LIBS) $(GLIB_LIBS) $(LIBM) -lgstvideo-1.0 \ - libpinos-@PV_MAJORMINOR@.la libpinoscore-@PV_MAJORMINOR@.la + libpinos-@PINOS_MAJORMINOR@.la libpinoscore-@PINOS_MAJORMINOR@.la libgstpinos_la_LIBTOOLFLAGS = $(GST_PLUGIN_LIBTOOLFLAGS) -noinst_HEADERS = gst/gstpvsrc.h gst/gstpvsink.h gst/gstfdpay.h gst/gstfddepay.h +noinst_HEADERS = gst/gstpinossrc.h gst/gstpinossink.h gst/gstfdpay.h gst/gstfddepay.h ################################### # Some minor stuff # diff --git a/src/client/pv-context.c b/src/client/context.c index e95df656..4f539ce2 100644 --- a/src/client/pv-context.c +++ b/src/client/context.c @@ -19,24 +19,23 @@ #include "client/pinos.h" -#include "client/pv-context.h" -#include "client/pv-enumtypes.h" -#include "client/pv-subscribe.h" +#include "client/context.h" +#include "client/enumtypes.h" +#include "client/subscribe.h" -#include "client/pv-private.h" +#include "client/private.h" -#define PV_CONTEXT_GET_PRIVATE(obj) \ - (G_TYPE_INSTANCE_GET_PRIVATE ((obj), PV_TYPE_CONTEXT, PvContextPrivate)) +#define PINOS_CONTEXT_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE ((obj), PINOS_TYPE_CONTEXT, PinosContextPrivate)) -G_DEFINE_TYPE (PvContext, pv_context, G_TYPE_OBJECT); +G_DEFINE_TYPE (PinosContext, pinos_context, G_TYPE_OBJECT); static void subscription_state (GObject *object, GParamSpec *pspec, gpointer user_data); -static void -subscription_cb (PvSubscribe *subscribe, - PvSubscriptionEvent event, - PvSubscriptionFlags flags, - GDBusProxy *object, - gpointer user_data); +static void subscription_cb (PinosSubscribe *subscribe, + PinosSubscriptionEvent event, + PinosSubscriptionFlags flags, + GDBusProxy *object, + gpointer user_data); enum { @@ -58,13 +57,13 @@ enum static guint signals[LAST_SIGNAL] = { 0 }; static void -pv_context_get_property (GObject *_object, - guint prop_id, - GValue *value, - GParamSpec *pspec) +pinos_context_get_property (GObject *_object, + guint prop_id, + GValue *value, + GParamSpec *pspec) { - PvContext *context = PV_CONTEXT (_object); - PvContextPrivate *priv = context->priv; + PinosContext *context = PINOS_CONTEXT (_object); + PinosContextPrivate *priv = context->priv; switch (prop_id) { case PROP_MAIN_CONTEXT: @@ -98,13 +97,13 @@ pv_context_get_property (GObject *_object, } static void -pv_context_set_property (GObject *_object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) +pinos_context_set_property (GObject *_object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) { - PvContext *context = PV_CONTEXT (_object); - PvContextPrivate *priv = context->priv; + PinosContext *context = PINOS_CONTEXT (_object); + PinosContextPrivate *priv = context->priv; switch (prop_id) { case PROP_MAIN_CONTEXT: @@ -133,10 +132,10 @@ pv_context_set_property (GObject *_object, } static void -pv_context_finalize (GObject * object) +pinos_context_finalize (GObject * object) { - PvContext *context = PV_CONTEXT (object); - PvContextPrivate *priv = context->priv; + PinosContext *context = PINOS_CONTEXT (object); + PinosContextPrivate *priv = context->priv; g_clear_pointer (&priv->context, g_main_context_unref); g_free (priv->name); @@ -146,22 +145,22 @@ pv_context_finalize (GObject * object) g_clear_object (&priv->subscribe); g_clear_error (&priv->error); - G_OBJECT_CLASS (pv_context_parent_class)->finalize (object); + G_OBJECT_CLASS (pinos_context_parent_class)->finalize (object); } static void -pv_context_class_init (PvContextClass * klass) +pinos_context_class_init (PinosContextClass * klass) { GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - g_type_class_add_private (klass, sizeof (PvContextPrivate)); + g_type_class_add_private (klass, sizeof (PinosContextPrivate)); - gobject_class->finalize = pv_context_finalize; - gobject_class->set_property = pv_context_set_property; - gobject_class->get_property = pv_context_get_property; + gobject_class->finalize = pinos_context_finalize; + gobject_class->set_property = pinos_context_set_property; + gobject_class->get_property = pinos_context_get_property; /** - * PvContext:main-context + * PinosContext:main-context * * The main context to use */ @@ -175,7 +174,7 @@ pv_context_class_init (PvContextClass * klass) G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS)); /** - * PvContext:name + * PinosContext:name * * The application name of the context. */ @@ -188,7 +187,7 @@ pv_context_class_init (PvContextClass * klass) G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); /** - * PvContext:properties + * PinosContext:properties * * Properties of the context. */ @@ -202,7 +201,7 @@ pv_context_class_init (PvContextClass * klass) G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); /** - * PvContext:state + * PinosContext:state * * The state of the context. */ @@ -211,12 +210,12 @@ pv_context_class_init (PvContextClass * klass) g_param_spec_enum ("state", "State", "The context state", - PV_TYPE_CONTEXT_STATE, - PV_CONTEXT_STATE_UNCONNECTED, + PINOS_TYPE_CONTEXT_STATE, + PINOS_CONTEXT_STATE_UNCONNECTED, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); /** - * PvContext:connection + * PinosContext:connection * * The connection of the context. */ @@ -229,7 +228,7 @@ pv_context_class_init (PvContextClass * klass) G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); /** - * PvContext:subscription-mask + * PinosContext:subscription-mask * * The subscription mask */ @@ -238,15 +237,15 @@ pv_context_class_init (PvContextClass * klass) g_param_spec_flags ("subscription-mask", "Subscription Mask", "The object to receive subscription events of", - PV_TYPE_SUBSCRIPTION_FLAGS, + PINOS_TYPE_SUBSCRIPTION_FLAGS, 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); /** - * PvContext:subscription-event - * @subscribe: The #PvContext emitting the signal. - * @event: A #PvSubscriptionEvent - * @flags: #PvSubscriptionFlags indicating the object + * PinosContext:subscription-event + * @subscribe: The #PinosContext emitting the signal. + * @event: A #PinosSubscriptionEvent + * @flags: #PinosSubscriptionFlags indicating the object * @object: the GDBusProxy object * * Notify about a new object that was added/removed/modified. @@ -260,35 +259,37 @@ pv_context_class_init (PvContextClass * klass) g_cclosure_marshal_generic, G_TYPE_NONE, 3, - PV_TYPE_SUBSCRIPTION_EVENT, - PV_TYPE_SUBSCRIPTION_FLAGS, + PINOS_TYPE_SUBSCRIPTION_EVENT, + PINOS_TYPE_SUBSCRIPTION_FLAGS, G_TYPE_DBUS_PROXY); } static void -pv_context_init (PvContext * context) +pinos_context_init (PinosContext * context) { - PvContextPrivate *priv = context->priv = PV_CONTEXT_GET_PRIVATE (context); + PinosContextPrivate *priv = context->priv = PINOS_CONTEXT_GET_PRIVATE (context); - priv->state = PV_CONTEXT_STATE_UNCONNECTED; - priv->subscribe = pv_subscribe_new (); - g_object_set (priv->subscribe, "subscription-mask", PV_SUBSCRIPTION_FLAGS_ALL, NULL); + priv->state = PINOS_CONTEXT_STATE_UNCONNECTED; + priv->subscribe = pinos_subscribe_new (); + g_object_set (priv->subscribe, "subscription-mask", PINOS_SUBSCRIPTION_FLAGS_ALL, NULL); g_signal_connect (priv->subscribe, "subscription-event", (GCallback) subscription_cb, context); g_signal_connect (priv->subscribe, "notify::state", (GCallback) subscription_state, context); } /** - * pv_context_new: + * pinos_context_new: * @name: an application name * @properties: optional properties * - * Make a new unconnected #PvContext + * Make a new unconnected #PinosContext * - * Returns: a new unconnected #PvContext + * Returns: a new unconnected #PinosContext */ -PvContext * -pv_context_new (GMainContext *context, const gchar *name, GVariant *properties) +PinosContext * +pinos_context_new (GMainContext *context, + const gchar *name, + GVariant *properties) { g_return_val_if_fail (name != NULL, NULL); @@ -299,11 +300,11 @@ pv_context_new (GMainContext *context, const gchar *name, GVariant *properties) g_variant_builder_add (&builder, "{sv}", "name", g_variant_new_string (name)); properties = g_variant_builder_end (&builder); } - return g_object_new (PV_TYPE_CONTEXT, "main-context", context, "name", name, "properties", properties, NULL); + return g_object_new (PINOS_TYPE_CONTEXT, "main-context", context, "name", name, "properties", properties, NULL); } static gboolean -do_notify_state (PvContext *context) +do_notify_state (PinosContext *context) { g_object_notify (G_OBJECT (context), "state"); g_object_unref (context); @@ -311,7 +312,8 @@ do_notify_state (PvContext *context) } static void -context_set_state (PvContext *context, PvContextState state) +context_set_state (PinosContext *context, + PinosContextState state) { if (context->priv->state != state) { context->priv->state = state; @@ -321,40 +323,40 @@ context_set_state (PvContext *context, PvContextState state) } } static void -on_client_proxy (GObject *source_object, +on_client_proxy (GObject *source_object, GAsyncResult *res, - gpointer user_data) + gpointer user_data) { - PvContext *context = user_data; - PvContextPrivate *priv = context->priv; + PinosContext *context = user_data; + PinosContextPrivate *priv = context->priv; GError *error = NULL; - priv->client = pv_subscribe_get_proxy_finish (priv->subscribe, + priv->client = pinos_subscribe_get_proxy_finish (priv->subscribe, res, &error); if (priv->client == NULL) goto client_failed; - context_set_state (context, PV_CONTEXT_STATE_READY); + context_set_state (context, PINOS_CONTEXT_STATE_READY); return; client_failed: { priv->error = error; - context_set_state (context, PV_STREAM_STATE_ERROR); + context_set_state (context, PINOS_STREAM_STATE_ERROR); g_warning ("failed to get client proxy: %s", error->message); return; } } static void -on_client_connected (GObject *source_object, +on_client_connected (GObject *source_object, GAsyncResult *res, - gpointer user_data) + gpointer user_data) { - PvContext *context = user_data; - PvContextPrivate *priv = context->priv; + PinosContext *context = user_data; + PinosContextPrivate *priv = context->priv; GVariant *ret; GError *error = NULL; const gchar *client_path; @@ -363,14 +365,14 @@ on_client_connected (GObject *source_object, if (ret == NULL) { g_warning ("failed to connect client: %s", error->message); priv->error = error; - context_set_state (context, PV_CONTEXT_STATE_ERROR); + context_set_state (context, PINOS_CONTEXT_STATE_ERROR); return; } g_variant_get (ret, "(&o)", &client_path); - pv_subscribe_get_proxy (priv->subscribe, - PV_DBUS_SERVICE, + pinos_subscribe_get_proxy (priv->subscribe, + PINOS_DBUS_SERVICE, client_path, "org.pinos.Client1", NULL, @@ -380,14 +382,14 @@ on_client_connected (GObject *source_object, } static void -on_daemon_connected (GObject *source_object, +on_daemon_connected (GObject *source_object, GAsyncResult *res, - gpointer user_data) + gpointer user_data) { - PvContext *context = user_data; - PvContextPrivate *priv = context->priv; + PinosContext *context = user_data; + PinosContextPrivate *priv = context->priv; - context_set_state (context, PV_CONTEXT_STATE_REGISTERING); + context_set_state (context, PINOS_CONTEXT_STATE_REGISTERING); g_dbus_proxy_call (priv->daemon, "ConnectClient", @@ -400,37 +402,37 @@ on_daemon_connected (GObject *source_object, } static void -subscription_cb (PvSubscribe *subscribe, - PvSubscriptionEvent event, - PvSubscriptionFlags flags, - GDBusProxy *object, - gpointer user_data) +subscription_cb (PinosSubscribe *subscribe, + PinosSubscriptionEvent event, + PinosSubscriptionFlags flags, + GDBusProxy *object, + gpointer user_data) { - PvContext *context = user_data; - PvContextPrivate *priv = context->priv; + PinosContext *context = user_data; + PinosContextPrivate *priv = context->priv; switch (flags) { - case PV_SUBSCRIPTION_FLAGS_DAEMON: + case PINOS_SUBSCRIPTION_FLAGS_DAEMON: priv->daemon = g_object_ref (object); break; - case PV_SUBSCRIPTION_FLAGS_CLIENT: - if (event == PV_SUBSCRIPTION_EVENT_REMOVE) { + case PINOS_SUBSCRIPTION_FLAGS_CLIENT: + if (event == PINOS_SUBSCRIPTION_EVENT_REMOVE) { if (object == priv->client) { priv->error = g_error_new_literal (G_IO_ERROR, G_IO_ERROR_CLOSED, "Client disappeared"); - context_set_state (context, PV_CONTEXT_STATE_ERROR); + context_set_state (context, PINOS_CONTEXT_STATE_ERROR); } } break; - case PV_SUBSCRIPTION_FLAGS_SOURCE: - if (event == PV_SUBSCRIPTION_EVENT_NEW) + case PINOS_SUBSCRIPTION_FLAGS_SOURCE: + if (event == PINOS_SUBSCRIPTION_EVENT_NEW) priv->sources = g_list_prepend (priv->sources, object); - else if (event == PV_SUBSCRIPTION_EVENT_REMOVE) + else if (event == PINOS_SUBSCRIPTION_EVENT_REMOVE) priv->sources = g_list_remove (priv->sources, object); break; - case PV_SUBSCRIPTION_FLAGS_SOURCE_OUTPUT: + case PINOS_SUBSCRIPTION_FLAGS_SOURCE_OUTPUT: break; } @@ -449,16 +451,16 @@ subscription_state (GObject *object, GParamSpec *pspec, gpointer user_data) { - PvContext *context = user_data; - PvContextPrivate *priv = context->priv; - PvSubscriptionState state; + PinosContext *context = user_data; + PinosContextPrivate *priv = context->priv; + PinosSubscriptionState state; g_assert (object == G_OBJECT (priv->subscribe)); - state = pv_subscribe_get_state (priv->subscribe); + state = pinos_subscribe_get_state (priv->subscribe); switch (state) { - case PV_SUBSCRIPTION_STATE_READY: + case PINOS_SUBSCRIPTION_STATE_READY: on_daemon_connected (NULL, NULL, context); break; @@ -470,12 +472,12 @@ subscription_state (GObject *object, static void on_name_appeared (GDBusConnection *connection, - const gchar *name, - const gchar *name_owner, - gpointer user_data) + const gchar *name, + const gchar *name_owner, + gpointer user_data) { - PvContext *context = user_data; - PvContextPrivate *priv = context->priv; + PinosContext *context = user_data; + PinosContextPrivate *priv = context->priv; priv->connection = connection; @@ -485,36 +487,36 @@ on_name_appeared (GDBusConnection *connection, static void on_name_vanished (GDBusConnection *connection, - const gchar *name, - gpointer user_data) + const gchar *name, + gpointer user_data) { - PvContext *context = user_data; - PvContextPrivate *priv = context->priv; + PinosContext *context = user_data; + PinosContextPrivate *priv = context->priv; priv->connection = connection; g_object_set (priv->subscribe, "connection", connection, NULL); - if (priv->flags & PV_CONTEXT_FLAGS_NOFAIL) { - context_set_state (context, PV_CONTEXT_STATE_CONNECTING); + if (priv->flags & PINOS_CONTEXT_FLAGS_NOFAIL) { + context_set_state (context, PINOS_CONTEXT_STATE_CONNECTING); } else { priv->error = g_error_new_literal (G_IO_ERROR, G_IO_ERROR_CLOSED, "Connection closed"); - context_set_state (context, PV_CONTEXT_STATE_ERROR); + context_set_state (context, PINOS_CONTEXT_STATE_ERROR); } } static gboolean -do_connect (PvContext *context) +do_connect (PinosContext *context) { - PvContextPrivate *priv = context->priv; + PinosContextPrivate *priv = context->priv; GBusNameWatcherFlags nw_flags; nw_flags = G_BUS_NAME_WATCHER_FLAGS_NONE; - if (!(priv->flags & PV_CONTEXT_FLAGS_NOAUTOSPAWN)) + if (!(priv->flags & PINOS_CONTEXT_FLAGS_NOAUTOSPAWN)) nw_flags = G_BUS_NAME_WATCHER_FLAGS_AUTO_START; priv->id = g_bus_watch_name (G_BUS_TYPE_SESSION, - PV_DBUS_SERVICE, + PINOS_DBUS_SERVICE, nw_flags, on_name_appeared, on_name_vanished, @@ -524,27 +526,28 @@ do_connect (PvContext *context) } /** - * pv_context_connect: - * @context: a #PvContext - * @flags: #PvContextFlags + * pinos_context_connect: + * @context: a #PinosContext + * @flags: #PinosContextFlags * * Connect to the daemon with @flags * * Returns: %TRUE on success. */ gboolean -pv_context_connect (PvContext *context, PvContextFlags flags) +pinos_context_connect (PinosContext *context, + PinosContextFlags flags) { - PvContextPrivate *priv; + PinosContextPrivate *priv; - g_return_val_if_fail (PV_IS_CONTEXT (context), FALSE); + g_return_val_if_fail (PINOS_IS_CONTEXT (context), FALSE); priv = context->priv; g_return_val_if_fail (priv->connection == NULL, FALSE); priv->flags = flags; - context_set_state (context, PV_CONTEXT_STATE_CONNECTING); + context_set_state (context, PINOS_CONTEXT_STATE_CONNECTING); g_main_context_invoke (priv->context, (GSourceFunc) do_connect, g_object_ref (context)); @@ -553,12 +556,12 @@ pv_context_connect (PvContext *context, PvContextFlags flags) } static void -on_client_disconnected (GObject *source_object, +on_client_disconnected (GObject *source_object, GAsyncResult *res, - gpointer user_data) + gpointer user_data) { - PvContext *context = user_data; - PvContextPrivate *priv = context->priv; + PinosContext *context = user_data; + PinosContextPrivate *priv = context->priv; GError *error = NULL; GVariant *ret; @@ -566,7 +569,7 @@ on_client_disconnected (GObject *source_object, if (ret == NULL) { g_warning ("failed to disconnect client: %s", error->message); priv->error = error; - context_set_state (context, PV_CONTEXT_STATE_ERROR); + context_set_state (context, PINOS_CONTEXT_STATE_ERROR); g_object_unref (context); return; } @@ -577,14 +580,14 @@ on_client_disconnected (GObject *source_object, g_bus_unwatch_name(priv->id); priv->id = 0; - context_set_state (context, PV_CONTEXT_STATE_UNCONNECTED); + context_set_state (context, PINOS_CONTEXT_STATE_UNCONNECTED); g_object_unref (context); } static gboolean -do_disconnect (PvContext *context) +do_disconnect (PinosContext *context) { - PvContextPrivate *priv = context->priv; + PinosContextPrivate *priv = context->priv; g_dbus_proxy_call (priv->client, "Disconnect", @@ -599,19 +602,19 @@ do_disconnect (PvContext *context) } /** - * pv_context_disconnect: - * @context: a #PvContext + * pinos_context_disconnect: + * @context: a #PinosContext * * Disonnect from the daemon. * * Returns: %TRUE on success. */ gboolean -pv_context_disconnect (PvContext *context) +pinos_context_disconnect (PinosContext *context) { - PvContextPrivate *priv; + PinosContextPrivate *priv; - g_return_val_if_fail (PV_IS_CONTEXT (context), FALSE); + g_return_val_if_fail (PINOS_IS_CONTEXT (context), FALSE); priv = context->priv; g_return_val_if_fail (priv->client != NULL, FALSE); @@ -624,39 +627,39 @@ pv_context_disconnect (PvContext *context) } /** - * pv_context_get_state: - * @context: a #PvContext + * pinos_context_get_state: + * @context: a #PinosContext * * Get the state of @context. * * Returns: the state of @context */ -PvContextState -pv_context_get_state (PvContext *context) +PinosContextState +pinos_context_get_state (PinosContext *context) { - PvContextPrivate *priv; + PinosContextPrivate *priv; - g_return_val_if_fail (PV_IS_CONTEXT (context), PV_CONTEXT_STATE_ERROR); + g_return_val_if_fail (PINOS_IS_CONTEXT (context), PINOS_CONTEXT_STATE_ERROR); priv = context->priv; return priv->state; } /** - * pv_context_get_error: - * @context: a #PvContext + * pinos_context_get_error: + * @context: a #PinosContext * * Get the current error of @context or %NULL when the context state - * is not #PV_CONTEXT_STATE_ERROR + * is not #PINOS_CONTEXT_STATE_ERROR * * Returns: the last error or %NULL */ const GError * -pv_context_get_error (PvContext *context) +pinos_context_get_error (PinosContext *context) { - PvContextPrivate *priv; + PinosContextPrivate *priv; - g_return_val_if_fail (PV_IS_CONTEXT (context), NULL); + g_return_val_if_fail (PINOS_IS_CONTEXT (context), NULL); priv = context->priv; return priv->error; diff --git a/src/client/context.h b/src/client/context.h new file mode 100644 index 00000000..8e4bee7b --- /dev/null +++ b/src/client/context.h @@ -0,0 +1,113 @@ +/* Pinos + * Copyright (C) 2015 Wim Taymans <wim.taymans@gmail.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef __PINOS_CONTEXT_H__ +#define __PINOS_CONTEXT_H__ + +#include <glib-object.h> +#include <gio/gio.h> + +#include <client/subscribe.h> + +G_BEGIN_DECLS + +#define PINOS_TYPE_CONTEXT (pinos_context_get_type ()) +#define PINOS_IS_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PINOS_TYPE_CONTEXT)) +#define PINOS_IS_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PINOS_TYPE_CONTEXT)) +#define PINOS_CONTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PINOS_TYPE_CONTEXT, PinosContextClass)) +#define PINOS_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PINOS_TYPE_CONTEXT, PinosContext)) +#define PINOS_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PINOS_TYPE_CONTEXT, PinosContextClass)) +#define PINOS_CONTEXT_CAST(obj) ((PinosContext*)(obj)) +#define PINOS_CONTEXT_CLASS_CAST(klass) ((PinosContextClass*)(klass)) + +typedef struct _PinosContext PinosContext; +typedef struct _PinosContextClass PinosContextClass; +typedef struct _PinosContextPrivate PinosContextPrivate; + +/** + * PinosContextFlags: + * @PINOS_CONTEXT_FLAGS_NONE: no flags + * @PINOS_CONTEXT_FLAGS_NOAUTOSPAWN: disable autostart of the daemon + * @PINOS_CONTEXT_FLAGS_NOFAIL: Don't fail if the daemon is not available, + * instead enter PINOS_CONTEXT_CONNECTING state and wait for the daemon + * to appear. + * + * Context flags passed to pinos_context_connect() + */ +typedef enum { + PINOS_CONTEXT_FLAGS_NONE = 0, + PINOS_CONTEXT_FLAGS_NOAUTOSPAWN = (1 << 0), + PINOS_CONTEXT_FLAGS_NOFAIL = (1 << 1) +} PinosContextFlags; + +/** + * PinosContextState: + * @PINOS_CONTEXT_STATE_UNCONNECTED: not connected + * @PINOS_CONTEXT_STATE_CONNECTING: connecting to daemon + * @PINOS_CONTEXT_STATE_REGISTERING: registering with daemon + * @PINOS_CONTEXT_STATE_READY: context is ready + * @PINOS_CONTEXT_STATE_ERROR: context is in error + * + * The state of a #PinosContext + */ +typedef enum { + PINOS_CONTEXT_STATE_UNCONNECTED = 0, + PINOS_CONTEXT_STATE_CONNECTING = 1, + PINOS_CONTEXT_STATE_REGISTERING = 2, + PINOS_CONTEXT_STATE_READY = 3, + PINOS_CONTEXT_STATE_ERROR = 4 +} PinosContextState; + +/** + * PinosContext: + * + * Pinos context object class. + */ +struct _PinosContext { + GObject object; + + PinosContextPrivate *priv; +}; + +/** + * PinosContextClass: + * + * Pinos context object class. + */ +struct _PinosContextClass { + GObjectClass parent_class; +}; + +/* normal GObject stuff */ +GType pinos_context_get_type (void); + +PinosContext * pinos_context_new (GMainContext *ctx, + const gchar *name, + GVariant *properties); + +gboolean pinos_context_connect (PinosContext *context, PinosContextFlags flags); +gboolean pinos_context_disconnect (PinosContext *context); + +PinosContextState pinos_context_get_state (PinosContext *context); +const GError * pinos_context_get_error (PinosContext *context); + +G_END_DECLS + +#endif /* __PINOS_CONTEXT_H__ */ + diff --git a/src/client/pv-introspect.c b/src/client/introspect.c index 3ce93f93..5bb66f68 100644 --- a/src/client/pv-introspect.c +++ b/src/client/introspect.c @@ -19,35 +19,35 @@ #include "client/pinos.h" -#include "client/pv-context.h" -#include "client/pv-enumtypes.h" -#include "client/pv-subscribe.h" +#include "client/context.h" +#include "client/enumtypes.h" +#include "client/subscribe.h" -#include "client/pv-private.h" +#include "client/private.h" /** - * pv_context_list_source_info: - * @context: a connected #PvContext - * @flags: extra #PvSourceInfoFlags - * @cb: a #PvSourceInfoCallback + * pinos_context_list_source_info: + * @context: a connected #PinosContext + * @flags: extra #PinosSourceInfoFlags + * @cb: a #PinosSourceInfoCallback * @cancelable: a #GCancellable * @user_data: user data passed to @cb * * Call @cb for each source. */ void -pv_context_list_source_info (PvContext *context, - PvSourceInfoFlags flags, - PvSourceInfoCallback cb, - GCancellable *cancellable, - gpointer user_data) +pinos_context_list_source_info (PinosContext *context, + PinosSourceInfoFlags flags, + PinosSourceInfoCallback cb, + GCancellable *cancellable, + gpointer user_data) { GList *walk; - PvContextPrivate *priv = context->priv; + PinosContextPrivate *priv = context->priv; for (walk = priv->sources; walk; walk = g_list_next (walk)) { GDBusProxy *proxy = walk->data; - PvSourceInfo info; + PinosSourceInfo info; info.name = "gst"; diff --git a/src/client/pv-introspect.h b/src/client/introspect.h index 4ece0fa2..4f2f27d2 100644 --- a/src/client/pv-introspect.h +++ b/src/client/introspect.h @@ -17,39 +17,39 @@ * Boston, MA 02110-1301, USA. */ -#ifndef __PV_INTROSPECT_H__ -#define __PV_INTROSPECT_H__ +#ifndef __PINOS_INTROSPECT_H__ +#define __PINOS_INTROSPECT_H__ #include <gio/gio.h> #include <glib-object.h> -#include <client/pv-context.h> +#include <client/context.h> G_BEGIN_DECLS /** - * PvSourceState: - * @PV_SOURCE_STATE_ERROR: the source is in error - * @PV_SOURCE_STATE_SUSPENDED: the source is suspended, the device might + * PinosSourceState: + * @PINOS_SOURCE_STATE_ERROR: the source is in error + * @PINOS_SOURCE_STATE_SUSPENDED: the source is suspended, the device might * be closed - * @PV_SOURCE_STATE_INIT: the source is initializing, it opens the device + * @PINOS_SOURCE_STATE_INIT: the source is initializing, it opens the device * and gets the device capabilities - * @PV_SOURCE_STATE_IDLE: the source is running but there is no active + * @PINOS_SOURCE_STATE_IDLE: the source is running but there is no active * source-output - * @PV_SOURCE_STATE_RUNNING: the source is running. + * @PINOS_SOURCE_STATE_RUNNING: the source is running. * * The different source states */ typedef enum { - PV_SOURCE_STATE_ERROR = 0, - PV_SOURCE_STATE_SUSPENDED = 1, - PV_SOURCE_STATE_INIT = 2, - PV_SOURCE_STATE_IDLE = 3, - PV_SOURCE_STATE_RUNNING = 4, -} PvSourceState; + PINOS_SOURCE_STATE_ERROR = 0, + PINOS_SOURCE_STATE_SUSPENDED = 1, + PINOS_SOURCE_STATE_INIT = 2, + PINOS_SOURCE_STATE_IDLE = 3, + PINOS_SOURCE_STATE_RUNNING = 4, +} PinosSourceState; /** - * PvSourceInfo: + * PinosSourceInfo: * @name: the name of the source * @properties: the properties of the source * @state: the current state of the source @@ -60,31 +60,31 @@ typedef enum { typedef struct { const char *name; GVariant *properties; - PvSourceState state; + PinosSourceState state; GBytes *formats; -} PvSourceInfo; +} PinosSourceInfo; /** - * PvSourceInfoFlags: - * @PV_SOURCE_INFO_FLAGS_NONE: no flags - * @PV_SOURCE_INFO_FLAGS_FORMATS: include formats + * PinosSourceInfoFlags: + * @PINOS_SOURCE_INFO_FLAGS_NONE: no flags + * @PINOS_SOURCE_INFO_FLAGS_FORMATS: include formats * - * Extra flags to pass to pv_context_get_source_info_list. + * Extra flags to pass to pinos_context_get_source_info_list. */ typedef enum { - PV_SOURCE_INFO_FLAGS_NONE = 0, - PV_SOURCE_INFO_FLAGS_FORMATS = (1 << 0) -} PvSourceInfoFlags; + PINOS_SOURCE_INFO_FLAGS_NONE = 0, + PINOS_SOURCE_INFO_FLAGS_FORMATS = (1 << 0) +} PinosSourceInfoFlags; -typedef gboolean (*PvSourceInfoCallback) (PvContext *c, const PvSourceInfo *info, gpointer userdata); +typedef gboolean (*PinosSourceInfoCallback) (PinosContext *c, const PinosSourceInfo *info, gpointer userdata); -void pv_context_list_source_info (PvContext *context, - PvSourceInfoFlags flags, - PvSourceInfoCallback cb, +void pinos_context_list_source_info (PinosContext *context, + PinosSourceInfoFlags flags, + PinosSourceInfoCallback cb, GCancellable *cancellable, gpointer user_data); G_END_DECLS -#endif /* __PV_INTROSPECT_H__ */ +#endif /* __PINOS_INTROSPECT_H__ */ diff --git a/src/client/pinos.c b/src/client/pinos.c index 0d761bad..85be697b 100644 --- a/src/client/pinos.c +++ b/src/client/pinos.c @@ -17,13 +17,12 @@ * Boston, MA 02110-1301, USA. */ -#include "client/pinos.h" +#include <gst/gst.h> -#include "gst/gstfdpay.h" -#include "gst/gstfddepay.h" +#include "client/pinos.h" /** - * pv_init: + * pinos_init: * @argc: pointer to argc * @argv: pointer to argv * @@ -31,7 +30,7 @@ * by @argc and @argv. */ void -pv_init (int *argc, char **argv[]) +pinos_init (int *argc, char **argv[]) { gst_init (argc, argv); } diff --git a/src/client/pinos.h b/src/client/pinos.h index 2e0b3816..576a5070 100644 --- a/src/client/pinos.h +++ b/src/client/pinos.h @@ -20,17 +20,17 @@ #ifndef __PINOS_H__ #define __PINOS_H__ -#include <client/pv-stream.h> -#include <client/pv-context.h> -#include <client/pv-subscribe.h> -#include <client/pv-introspect.h> +#include <client/stream.h> +#include <client/context.h> +#include <client/subscribe.h> +#include <client/introspect.h> -#define PV_DBUS_SERVICE "org.pinos" -#define PV_DBUS_OBJECT_PREFIX "/org/pinos" -#define PV_DBUS_OBJECT_SERVER PV_DBUS_OBJECT_PREFIX "/server" -#define PV_DBUS_OBJECT_SOURCE PV_DBUS_OBJECT_PREFIX "/source" -#define PV_DBUS_OBJECT_CLIENT PV_DBUS_OBJECT_PREFIX "/client" +#define PINOS_DBUS_SERVICE "org.pinos" +#define PINOS_DBUS_OBJECT_PREFIX "/org/pinos" +#define PINOS_DBUS_OBJECT_SERVER PINOS_DBUS_OBJECT_PREFIX "/server" +#define PINOS_DBUS_OBJECT_SOURCE PINOS_DBUS_OBJECT_PREFIX "/source" +#define PINOS_DBUS_OBJECT_CLIENT PINOS_DBUS_OBJECT_PREFIX "/client" -void pv_init (int *argc, char **argv[]); +void pinos_init (int *argc, char **argv[]); #endif /* __PINOS_H__ */ diff --git a/src/client/pv-private.h b/src/client/private.h index 3be1617c..9b681bfe 100644 --- a/src/client/pv-private.h +++ b/src/client/private.h @@ -17,7 +17,7 @@ * Boston, MA 02110-1301, USA. */ -struct _PvContextPrivate +struct _PinosContextPrivate { GMainContext *context; @@ -27,16 +27,16 @@ struct _PvContextPrivate guint id; GDBusConnection *connection; - PvContextFlags flags; + PinosContextFlags flags; - PvContextState state; + PinosContextState state; GError *error; GDBusProxy *daemon; GDBusProxy *client; - PvSubscriptionFlags subscription_mask; - PvSubscribe *subscribe; + PinosSubscriptionFlags subscription_mask; + PinosSubscribe *subscribe; GList *sources; }; diff --git a/src/client/pv-context.h b/src/client/pv-context.h deleted file mode 100644 index fc0da865..00000000 --- a/src/client/pv-context.h +++ /dev/null @@ -1,113 +0,0 @@ -/* Pinos - * Copyright (C) 2015 Wim Taymans <wim.taymans@gmail.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef __PV_CONTEXT_H__ -#define __PV_CONTEXT_H__ - -#include <glib-object.h> -#include <gio/gio.h> - -#include <client/pv-subscribe.h> - -G_BEGIN_DECLS - -#define PV_TYPE_CONTEXT (pv_context_get_type ()) -#define PV_IS_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PV_TYPE_CONTEXT)) -#define PV_IS_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PV_TYPE_CONTEXT)) -#define PV_CONTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PV_TYPE_CONTEXT, PvContextClass)) -#define PV_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PV_TYPE_CONTEXT, PvContext)) -#define PV_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PV_TYPE_CONTEXT, PvContextClass)) -#define PV_CONTEXT_CAST(obj) ((PvContext*)(obj)) -#define PV_CONTEXT_CLASS_CAST(klass) ((PvContextClass*)(klass)) - -typedef struct _PvContext PvContext; -typedef struct _PvContextClass PvContextClass; -typedef struct _PvContextPrivate PvContextPrivate; - -/** - * PvContextFlags: - * @PV_CONTEXT_FLAGS_NONE: no flags - * @PV_CONTEXT_FLAGS_NOAUTOSPAWN: disable autostart of the daemon - * @PV_CONTEXT_FLAGS_NOFAIL: Don't fail if the daemon is not available, - * instead enter PV_CONTEXT_CONNECTING state and wait for the daemon - * to appear. - * - * Context flags passed to pv_context_connect() - */ -typedef enum { - PV_CONTEXT_FLAGS_NONE = 0, - PV_CONTEXT_FLAGS_NOAUTOSPAWN = (1 << 0), - PV_CONTEXT_FLAGS_NOFAIL = (1 << 1) -} PvContextFlags; - -/** - * PvContextState: - * @PV_CONTEXT_STATE_UNCONNECTED: not connected - * @PV_CONTEXT_STATE_CONNECTING: connecting to daemon - * @PV_CONTEXT_STATE_REGISTERING: registering with daemon - * @PV_CONTEXT_STATE_READY: context is ready - * @PV_CONTEXT_STATE_ERROR: context is in error - * - * The state of a #PvContext - */ -typedef enum { - PV_CONTEXT_STATE_UNCONNECTED = 0, - PV_CONTEXT_STATE_CONNECTING = 1, - PV_CONTEXT_STATE_REGISTERING = 2, - PV_CONTEXT_STATE_READY = 3, - PV_CONTEXT_STATE_ERROR = 4 -} PvContextState; - -/** - * PvContext: - * - * Pinos context object class. - */ -struct _PvContext { - GObject object; - - PvContextPrivate *priv; -}; - -/** - * PvContextClass: - * - * Pinos context object class. - */ -struct _PvContextClass { - GObjectClass parent_class; -}; - -/* normal GObject stuff */ -GType pv_context_get_type (void); - -PvContext * pv_context_new (GMainContext *ctx, - const gchar *name, - GVariant *properties); - -gboolean pv_context_connect (PvContext *context, PvContextFlags flags); -gboolean pv_context_disconnect (PvContext *context); - -PvContextState pv_context_get_state (PvContext *context); -const GError * pv_context_get_error (PvContext *context); - -G_END_DECLS - -#endif /* __PV_CONTEXT_H__ */ - diff --git a/src/client/pv-stream.h b/src/client/pv-stream.h deleted file mode 100644 index 55f31de4..00000000 --- a/src/client/pv-stream.h +++ /dev/null @@ -1,125 +0,0 @@ -/* Pinos - * Copyright (C) 2015 Wim Taymans <wim.taymans@gmail.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef __PV_STREAM_H__ -#define __PV_STREAM_H__ - -#include <gio/gio.h> -#include <glib-object.h> - -#include "pv-context.h" - -G_BEGIN_DECLS - -#define PV_TYPE_STREAM (pv_stream_get_type ()) -#define PV_IS_STREAM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PV_TYPE_STREAM)) -#define PV_IS_STREAM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PV_TYPE_STREAM)) -#define PV_STREAM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PV_TYPE_STREAM, PvStreamClass)) -#define PV_STREAM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PV_TYPE_STREAM, PvStream)) -#define PV_STREAM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PV_TYPE_STREAM, PvStreamClass)) -#define PV_STREAM_CAST(obj) ((PvStream*)(obj)) -#define PV_STREAM_CLASS_CAST(klass) ((PvStreamClass*)(klass)) - -typedef struct _PvStream PvStream; -typedef struct _PvStreamClass PvStreamClass; -typedef struct _PvStreamPrivate PvStreamPrivate; - -typedef enum { - PV_STREAM_STATE_UNCONNECTED = 0, - PV_STREAM_STATE_CONNECTING = 1, - PV_STREAM_STATE_READY = 2, - PV_STREAM_STATE_STARTING = 3, - PV_STREAM_STATE_STREAMING = 4, - PV_STREAM_STATE_ERROR = 5 -} PvStreamState; - - -typedef enum { - PV_STREAM_FLAGS_NONE = 0, -} PvStreamFlags; - -typedef struct { - guint32 flags; - guint32 seq; - gint64 pts; - gint64 dts_offset; - guint64 offset; - guint64 size; - GSocketControlMessage *message; -} PvBufferInfo; - -typedef enum { - PV_STREAM_MODE_SOCKET = 0, - PV_STREAM_MODE_BUFFER = 1, -} PvStreamMode; - -/** - * PvStream: - * - * Pinos stream object class. - */ -struct _PvStream { - GObject object; - - PvStreamPrivate *priv; -}; - -/** - * PvStreamClass: - * - * Pinos stream object class. - */ -struct _PvStreamClass { - GObjectClass parent_class; -}; - -/* normal GObject stuff */ -GType pv_stream_get_type (void); - - -PvStream * pv_stream_new (PvContext * context, - const gchar *name, - GVariant * props); - -PvStreamState pv_stream_get_state (PvStream *stream); -const GError * pv_stream_get_error (PvStream *stream); - -gboolean pv_stream_connect_capture (PvStream *stream, - const gchar *source, - PvStreamFlags flags, - GBytes *accepted_formats); -gboolean pv_stream_connect_provide (PvStream *stream, - PvStreamFlags flags, - GBytes *possible_formats); -gboolean pv_stream_disconnect (PvStream *stream); - -gboolean pv_stream_start (PvStream *stream, - GBytes *format, - PvStreamMode mode); -gboolean pv_stream_stop (PvStream *stream); - -gboolean pv_stream_capture_buffer (PvStream *stream, - PvBufferInfo *info); -gboolean pv_stream_provide_buffer (PvStream *stream, - PvBufferInfo *info); - -G_END_DECLS - -#endif /* __PV_STREAM_H__ */ - diff --git a/src/client/pv-subscribe.h b/src/client/pv-subscribe.h deleted file mode 100644 index c527160a..00000000 --- a/src/client/pv-subscribe.h +++ /dev/null @@ -1,106 +0,0 @@ -/* Pinos - * Copyright (C) 2015 Wim Taymans <wim.taymans@gmail.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef __PV_SUBSCRIBE_H__ -#define __PV_SUBSCRIBE_H__ - -#include <glib.h> - -G_BEGIN_DECLS - -#define PV_TYPE_SUBSCRIBE (pv_subscribe_get_type ()) -#define PV_IS_SUBSCRIBE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PV_TYPE_SUBSCRIBE)) -#define PV_IS_SUBSCRIBE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PV_TYPE_SUBSCRIBE)) -#define PV_SUBSCRIBE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PV_TYPE_SUBSCRIBE, PvSubscribeClass)) -#define PV_SUBSCRIBE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PV_TYPE_SUBSCRIBE, PvSubscribe)) -#define PV_SUBSCRIBE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PV_TYPE_SUBSCRIBE, PvSubscribeClass)) -#define PV_SUBSCRIBE_CAST(obj) ((PvSubscribe*)(obj)) -#define PV_SUBSCRIBE_CLASS_CAST(klass) ((PvSubscribeClass*)(klass)) - -typedef struct _PvSubscribe PvSubscribe; -typedef struct _PvSubscribeClass PvSubscribeClass; -typedef struct _PvSubscribePrivate PvSubscribePrivate; - -typedef enum { - PV_SUBSCRIPTION_STATE_UNCONNECTED = 0, - PV_SUBSCRIPTION_STATE_CONNECTING = 1, - PV_SUBSCRIPTION_STATE_READY = 2, - PV_SUBSCRIPTION_STATE_ERROR = 3, -} PvSubscriptionState; - -typedef enum { - PV_SUBSCRIPTION_FLAGS_DAEMON = (1 << 0), - PV_SUBSCRIPTION_FLAGS_CLIENT = (1 << 1), - PV_SUBSCRIPTION_FLAGS_SOURCE = (1 << 2), - PV_SUBSCRIPTION_FLAGS_SOURCE_OUTPUT = (1 << 3), -} PvSubscriptionFlags; - -#define PV_SUBSCRIPTION_FLAGS_ALL 0xf - -typedef enum { - PV_SUBSCRIPTION_EVENT_NEW = 0, - PV_SUBSCRIPTION_EVENT_CHANGE = 1, - PV_SUBSCRIPTION_EVENT_REMOVE = 2, -} PvSubscriptionEvent; - -/** - * PvSubscribe: - * - * Pinos subscribe object class. - */ -struct _PvSubscribe { - GObject object; - - PvSubscribePrivate *priv; -}; - -/** - * PvSubscribeClass: - * - * Pinos subscribe object class. - */ -struct _PvSubscribeClass { - GObjectClass parent_class; -}; - -/* normal GObject stuff */ -GType pv_subscribe_get_type (void); - -PvSubscribe * pv_subscribe_new (void); - -PvSubscriptionState pv_subscribe_get_state (PvSubscribe *subscribe); -GError * pv_subscribe_get_error (PvSubscribe *subscribe); - -void pv_subscribe_get_proxy (PvSubscribe *subscribe, - const gchar *name, - const gchar *object_path, - const gchar *interface_name, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data); -GDBusProxy * pv_subscribe_get_proxy_finish (PvSubscribe *subscribe, - GAsyncResult *res, - GError **error); - - - -G_END_DECLS - -#endif /* __PV_SUBSCRIBE_H__ */ - diff --git a/src/client/pv-stream.c b/src/client/stream.c index 782e65fb..8c5a5747 100644 --- a/src/client/pv-stream.c +++ b/src/client/stream.c @@ -20,23 +20,23 @@ #include <string.h> #include <gio/gunixfdlist.h> -#include "server/pv-daemon.h" +#include "server/daemon.h" #include "client/pinos.h" -#include "client/pv-context.h" -#include "client/pv-stream.h" -#include "client/pv-enumtypes.h" +#include "client/context.h" +#include "client/stream.h" +#include "client/enumtypes.h" -#include "client/pv-private.h" +#include "client/private.h" -struct _PvStreamPrivate +struct _PinosStreamPrivate { - PvContext *context; + PinosContext *context; gchar *name; GVariant *properties; guint id; - PvStreamState state; + PinosStreamState state; GError *error; gchar *target; @@ -48,17 +48,17 @@ struct _PvStreamPrivate GDBusProxy *source_output; - PvStreamMode mode; + PinosStreamMode mode; GSocket *socket; GSource *socket_source; - PvBufferInfo info; + PinosBufferInfo info; }; -#define PV_STREAM_GET_PRIVATE(obj) \ - (G_TYPE_INSTANCE_GET_PRIVATE ((obj), PV_TYPE_STREAM, PvStreamPrivate)) +#define PINOS_STREAM_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE ((obj), PINOS_TYPE_STREAM, PinosStreamPrivate)) -G_DEFINE_TYPE (PvStream, pv_stream, G_TYPE_OBJECT); +G_DEFINE_TYPE (PinosStream, pinos_stream, G_TYPE_OBJECT); enum { @@ -81,13 +81,13 @@ enum static guint signals[LAST_SIGNAL] = { 0 }; static void -pv_stream_get_property (GObject *_object, - guint prop_id, - GValue *value, - GParamSpec *pspec) +pinos_stream_get_property (GObject *_object, + guint prop_id, + GValue *value, + GParamSpec *pspec) { - PvStream *stream = PV_STREAM (_object); - PvStreamPrivate *priv = stream->priv; + PinosStream *stream = PINOS_STREAM (_object); + PinosStreamPrivate *priv = stream->priv; switch (prop_id) { case PROP_CONTEXT: @@ -125,13 +125,13 @@ pv_stream_get_property (GObject *_object, } static void -pv_stream_set_property (GObject *_object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) +pinos_stream_set_property (GObject *_object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) { - PvStream *stream = PV_STREAM (_object); - PvStreamPrivate *priv = stream->priv; + PinosStream *stream = PINOS_STREAM (_object); + PinosStreamPrivate *priv = stream->priv; switch (prop_id) { case PROP_CONTEXT: @@ -155,7 +155,7 @@ pv_stream_set_property (GObject *_object, } static gboolean -do_notify_state (PvStream *stream) +do_notify_state (PinosStream *stream) { g_object_notify (G_OBJECT (stream), "state"); g_object_unref (stream); @@ -163,7 +163,8 @@ do_notify_state (PvStream *stream) } static void -stream_set_state (PvStream *stream, PvStreamState state) +stream_set_state (PinosStream *stream, + PinosStreamState state) { if (stream->priv->state != state) { stream->priv->state = state; @@ -174,21 +175,21 @@ stream_set_state (PvStream *stream, PvStreamState state) } static void -subscription_cb (PvSubscribe *subscribe, - PvSubscriptionEvent event, - PvSubscriptionFlags flags, - GDBusProxy *object, - gpointer user_data) +subscription_cb (PinosSubscribe *subscribe, + PinosSubscriptionEvent event, + PinosSubscriptionFlags flags, + GDBusProxy *object, + gpointer user_data) { - PvStream *stream = PV_STREAM (user_data); - PvStreamPrivate *priv = stream->priv; + PinosStream *stream = PINOS_STREAM (user_data); + PinosStreamPrivate *priv = stream->priv; switch (flags) { - case PV_SUBSCRIPTION_FLAGS_SOURCE_OUTPUT: - if (event == PV_SUBSCRIPTION_EVENT_REMOVE) { + case PINOS_SUBSCRIPTION_FLAGS_SOURCE_OUTPUT: + if (event == PINOS_SUBSCRIPTION_EVENT_REMOVE) { if (object == priv->source_output) { priv->error = g_error_new_literal (G_IO_ERROR, G_IO_ERROR_CLOSED, "output disappeared"); - stream_set_state (stream, PV_STREAM_STATE_ERROR); + stream_set_state (stream, PINOS_STREAM_STATE_ERROR); } } break; @@ -199,24 +200,24 @@ subscription_cb (PvSubscribe *subscribe, } static void -pv_stream_constructed (GObject * object) +pinos_stream_constructed (GObject * object) { - PvStream *stream = PV_STREAM (object); - PvStreamPrivate *priv = stream->priv; + PinosStream *stream = PINOS_STREAM (object); + PinosStreamPrivate *priv = stream->priv; priv->id = g_signal_connect (priv->context->priv->subscribe, "subscription-event", (GCallback) subscription_cb, stream); - G_OBJECT_CLASS (pv_stream_parent_class)->constructed (object); + G_OBJECT_CLASS (pinos_stream_parent_class)->constructed (object); } static void -pv_stream_finalize (GObject * object) +pinos_stream_finalize (GObject * object) { - PvStream *stream = PV_STREAM (object); - PvStreamPrivate *priv = stream->priv; + PinosStream *stream = PINOS_STREAM (object); + PinosStreamPrivate *priv = stream->priv; g_clear_object (&priv->source_output); @@ -237,23 +238,23 @@ pv_stream_finalize (GObject * object) g_clear_object (&priv->context); g_free (priv->name); - G_OBJECT_CLASS (pv_stream_parent_class)->finalize (object); + G_OBJECT_CLASS (pinos_stream_parent_class)->finalize (object); } static void -pv_stream_class_init (PvStreamClass * klass) +pinos_stream_class_init (PinosStreamClass * klass) { GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - g_type_class_add_private (klass, sizeof (PvStreamPrivate)); + g_type_class_add_private (klass, sizeof (PinosStreamPrivate)); - gobject_class->constructed = pv_stream_constructed; - gobject_class->finalize = pv_stream_finalize; - gobject_class->set_property = pv_stream_set_property; - gobject_class->get_property = pv_stream_get_property; + gobject_class->constructed = pinos_stream_constructed; + gobject_class->finalize = pinos_stream_finalize; + gobject_class->set_property = pinos_stream_set_property; + gobject_class->get_property = pinos_stream_get_property; /** - * PvStream:context + * PinosStream:context * * The context of the stream. */ @@ -262,12 +263,12 @@ pv_stream_class_init (PvStreamClass * klass) g_param_spec_object ("context", "Context", "The context", - PV_TYPE_CONTEXT, + PINOS_TYPE_CONTEXT, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS)); /** - * PvStream:name + * PinosStream:name * * The name of the stream as specified at construction time. */ @@ -281,7 +282,7 @@ pv_stream_class_init (PvStreamClass * klass) G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS)); /** - * PvStream:properties + * PinosStream:properties * * The properties of the stream as specified at construction time. */ @@ -296,7 +297,7 @@ pv_stream_class_init (PvStreamClass * klass) G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS)); /** - * PvStream:state + * PinosStream:state * * The state of the stream. Use the notify::state signal to be notified * of state changes. @@ -306,12 +307,12 @@ pv_stream_class_init (PvStreamClass * klass) g_param_spec_enum ("state", "State", "The stream state", - PV_TYPE_STREAM_STATE, - PV_STREAM_STATE_UNCONNECTED, + PINOS_TYPE_STREAM_STATE, + PINOS_STREAM_STATE_UNCONNECTED, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); /** - * PvStream:possible-formats + * PinosStream:possible-formats * * The possible formats for the stream. this can only be used after connecting * the stream for capture or provide. @@ -325,7 +326,7 @@ pv_stream_class_init (PvStreamClass * klass) G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); /** - * PvStream:formats + * PinosStream:formats * * The format of the stream. This will be set after starting the stream. */ @@ -338,10 +339,10 @@ pv_stream_class_init (PvStreamClass * klass) G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); /** - * PvStream:socket + * PinosStream:socket * - * The socket of the stream. When doing pv_stream_start() with - * #PV_STREAM_MODE_SOCKET, the socket will contain a data stream with + * The socket of the stream. When doing pinos_stream_start() with + * #PINOS_STREAM_MODE_SOCKET, the socket will contain a data stream with * meta data and anciliary data containing fds with the data. */ g_object_class_install_property (gobject_class, @@ -355,11 +356,11 @@ pv_stream_class_init (PvStreamClass * klass) /** - * PvStream:new-buffer + * PinosStream:new-buffer * - * When doing pv_stream_start() with #PV_STREAM_MODE_BUFFER, this signal + * When doing pinos_stream_start() with #PINOS_STREAM_MODE_BUFFER, this signal * will be fired whenever a new buffer can be obtained with - * pv_stream_capture_buffer(). + * pinos_stream_capture_buffer(). */ signals[SIGNAL_NEW_BUFFER] = g_signal_new ("new-buffer", G_TYPE_FROM_CLASS (klass), @@ -374,77 +375,79 @@ pv_stream_class_init (PvStreamClass * klass) } static void -pv_stream_init (PvStream * stream) +pinos_stream_init (PinosStream * stream) { - PvStreamPrivate *priv = stream->priv = PV_STREAM_GET_PRIVATE (stream); + PinosStreamPrivate *priv = stream->priv = PINOS_STREAM_GET_PRIVATE (stream); - priv->state = PV_STREAM_STATE_UNCONNECTED; + priv->state = PINOS_STREAM_STATE_UNCONNECTED; } /** - * pv_stream_new: - * @context: a #PvContext + * pinos_stream_new: + * @context: a #PinosContext * @name: a stream name * @properties: stream properties * - * Make a new unconnected #PvStream + * Make a new unconnected #PinosStream * - * Returns: a new unconnected #PvStream + * Returns: a new unconnected #PinosStream */ -PvStream * -pv_stream_new (PvContext * context, const gchar *name, GVariant *props) +PinosStream * +pinos_stream_new (PinosContext *context, + const gchar *name, + GVariant *props) { - g_return_val_if_fail (PV_IS_CONTEXT (context), NULL); + g_return_val_if_fail (PINOS_IS_CONTEXT (context), NULL); g_return_val_if_fail (name != NULL, NULL); - return g_object_new (PV_TYPE_STREAM, "context", context, "name", name, "properties", props, NULL); + return g_object_new (PINOS_TYPE_STREAM, "context", context, "name", name, "properties", props, NULL); } /** - * pv_stream_get_state: - * @stream: a #PvStream + * pinos_stream_get_state: + * @stream: a #PinosStream * * Get the state of @stream. * * Returns: the state of @stream */ -PvStreamState -pv_stream_get_state (PvStream *stream) +PinosStreamState +pinos_stream_get_state (PinosStream *stream) { - g_return_val_if_fail (PV_IS_STREAM (stream), PV_STREAM_STATE_ERROR); + g_return_val_if_fail (PINOS_IS_STREAM (stream), PINOS_STREAM_STATE_ERROR); return stream->priv->state; } /** - * pv_stream_get_error: - * @stream: a #PvStream + * pinos_stream_get_error: + * @stream: a #PinosStream * * Get the error of @stream. * * Returns: the error of @stream or %NULL when there is no error */ const GError * -pv_stream_get_error (PvStream *stream) +pinos_stream_get_error (PinosStream *stream) { - g_return_val_if_fail (PV_IS_STREAM (stream), NULL); + g_return_val_if_fail (PINOS_IS_STREAM (stream), NULL); return stream->priv->error; } static void -on_source_output_proxy (GObject *source_object, +on_source_output_proxy (GObject *source_object, GAsyncResult *res, - gpointer user_data) + gpointer user_data) { - PvStream *stream = user_data; - PvStreamPrivate *priv = stream->priv; - PvContext *context = priv->context; + PinosStream *stream = user_data; + PinosStreamPrivate *priv = stream->priv; + PinosContext *context = priv->context; GVariant *v; gchar *str; GError *error = NULL; - priv->source_output = pv_subscribe_get_proxy_finish (context->priv->subscribe, + priv->source_output = pinos_subscribe_get_proxy_finish (context->priv->subscribe, res, &error); if (priv->source_output == NULL) @@ -462,7 +465,7 @@ on_source_output_proxy (GObject *source_object, g_object_notify (G_OBJECT (stream), "possible-formats"); } - stream_set_state (stream, PV_STREAM_STATE_READY); + stream_set_state (stream, PINOS_STREAM_STATE_READY); g_object_unref (stream); return; @@ -470,7 +473,7 @@ on_source_output_proxy (GObject *source_object, source_output_failed: { priv->error = error; - stream_set_state (stream, PV_STREAM_STATE_ERROR); + stream_set_state (stream, PINOS_STREAM_STATE_ERROR); g_warning ("failed to get source output proxy: %s", error->message); g_object_unref (stream); return; @@ -478,13 +481,13 @@ source_output_failed: } static void -on_source_output_created (GObject *source_object, +on_source_output_created (GObject *source_object, GAsyncResult *res, - gpointer user_data) + gpointer user_data) { - PvStream *stream = user_data; - PvStreamPrivate *priv = stream->priv; - PvContext *context = priv->context; + PinosStream *stream = user_data; + PinosStreamPrivate *priv = stream->priv; + PinosContext *context = priv->context; GVariant *ret; GError *error = NULL; const gchar *source_output_path; @@ -495,8 +498,8 @@ on_source_output_created (GObject *source_object, g_variant_get (ret, "(o)", &source_output_path); - pv_subscribe_get_proxy (context->priv->subscribe, - PV_DBUS_SERVICE, + pinos_subscribe_get_proxy (context->priv->subscribe, + PINOS_DBUS_SERVICE, source_output_path, "org.pinos.SourceOutput1", NULL, @@ -510,7 +513,7 @@ on_source_output_created (GObject *source_object, create_failed: { priv->error = error; - stream_set_state (stream, PV_STREAM_STATE_ERROR); + stream_set_state (stream, PINOS_STREAM_STATE_ERROR); g_warning ("failed to get connect capture: %s", error->message); g_object_unref (stream); return; @@ -518,10 +521,10 @@ create_failed: } static gboolean -do_connect_capture (PvStream *stream) +do_connect_capture (PinosStream *stream) { - PvStreamPrivate *priv = stream->priv; - PvContext *context = priv->context; + PinosStreamPrivate *priv = stream->priv; + PinosContext *context = priv->context; g_dbus_proxy_call (context->priv->client, "CreateSourceOutput", @@ -538,10 +541,10 @@ do_connect_capture (PvStream *stream) } /** - * pv_stream_connect_capture: - * @stream: a #PvStream + * pinos_stream_connect_capture: + * @stream: a #PinosStream * @source: the source name to connect to - * @flags: a #PvStreamFlags + * @flags: a #PinosStreamFlags * @spec: a #GVariant * * Connect @stream for capturing from @source. @@ -549,20 +552,20 @@ do_connect_capture (PvStream *stream) * Returns: %TRUE on success. */ gboolean -pv_stream_connect_capture (PvStream *stream, - const gchar *source, - PvStreamFlags flags, - GBytes *accepted_formats) +pinos_stream_connect_capture (PinosStream *stream, + const gchar *source, + PinosStreamFlags flags, + GBytes *accepted_formats) { - PvStreamPrivate *priv; - PvContext *context; + PinosStreamPrivate *priv; + PinosContext *context; - g_return_val_if_fail (PV_IS_STREAM (stream), FALSE); + g_return_val_if_fail (PINOS_IS_STREAM (stream), FALSE); g_return_val_if_fail (accepted_formats != NULL, FALSE); priv = stream->priv; context = priv->context; - g_return_val_if_fail (pv_context_get_state (context) == PV_CONTEXT_STATE_READY, FALSE); + g_return_val_if_fail (pinos_context_get_state (context) == PINOS_CONTEXT_STATE_READY, FALSE); g_free (priv->target); priv->target = g_strdup (source); @@ -571,7 +574,7 @@ pv_stream_connect_capture (PvStream *stream, priv->accepted_formats = g_bytes_ref (accepted_formats); priv->provide = FALSE; - stream_set_state (stream, PV_STREAM_STATE_CONNECTING); + stream_set_state (stream, PINOS_STREAM_STATE_CONNECTING); g_main_context_invoke (context->priv->context, (GSourceFunc) do_connect_capture, @@ -581,10 +584,10 @@ pv_stream_connect_capture (PvStream *stream, } static gboolean -do_connect_provide (PvStream *stream) +do_connect_provide (PinosStream *stream) { - PvStreamPrivate *priv = stream->priv; - PvContext *context = priv->context; + PinosStreamPrivate *priv = stream->priv; + PinosContext *context = priv->context; g_dbus_proxy_call (context->priv->client, "CreateSourceInput", @@ -599,9 +602,9 @@ do_connect_provide (PvStream *stream) } /** - * pv_stream_connect_provide: - * @stream: a #PvStream - * @flags: a #PvStreamFlags + * pinos_stream_connect_provide: + * @stream: a #PinosStream + * @flags: a #PinosStreamFlags * @spec: a #GVariant * * Connect @stream for providing data for a new source. @@ -609,28 +612,28 @@ do_connect_provide (PvStream *stream) * Returns: %TRUE on success. */ gboolean -pv_stream_connect_provide (PvStream *stream, - PvStreamFlags flags, - GBytes *possible_formats) +pinos_stream_connect_provide (PinosStream *stream, + PinosStreamFlags flags, + GBytes *possible_formats) { - PvStreamPrivate *priv; - PvContext *context; + PinosStreamPrivate *priv; + PinosContext *context; - g_return_val_if_fail (PV_IS_STREAM (stream), FALSE); + g_return_val_if_fail (PINOS_IS_STREAM (stream), FALSE); g_return_val_if_fail (possible_formats != NULL, FALSE); priv = stream->priv; context = priv->context; - g_return_val_if_fail (pv_context_get_state (context) == PV_CONTEXT_STATE_READY, FALSE); + g_return_val_if_fail (pinos_context_get_state (context) == PINOS_CONTEXT_STATE_READY, FALSE); if (priv->possible_formats) g_bytes_unref (priv->possible_formats); priv->possible_formats = g_bytes_ref (possible_formats); priv->provide = TRUE; - stream_set_state (stream, PV_STREAM_STATE_CONNECTING); + stream_set_state (stream, PINOS_STREAM_STATE_CONNECTING); - g_main_context_invoke (context->priv->context, + g_main_context_invoke (context->priv->context, (GSourceFunc) do_connect_provide, g_object_ref (stream)); @@ -638,33 +641,33 @@ pv_stream_connect_provide (PvStream *stream, } static void -on_source_output_removed (GObject *source_object, +on_source_output_removed (GObject *source_object, GAsyncResult *res, - gpointer user_data) + gpointer user_data) { - PvStream *stream = user_data; - PvStreamPrivate *priv = stream->priv; + PinosStream *stream = user_data; + PinosStreamPrivate *priv = stream->priv; GVariant *ret; GError *error = NULL; ret = g_dbus_proxy_call_finish (priv->source_output, res, &error); if (ret == NULL) { priv->error = error; - stream_set_state (stream, PV_STREAM_STATE_ERROR); + stream_set_state (stream, PINOS_STREAM_STATE_ERROR); g_warning ("failed to disconnect: %s", error->message); g_object_unref (stream); return; } g_clear_object (&priv->source_output); - stream_set_state (stream, PV_STREAM_STATE_UNCONNECTED); + stream_set_state (stream, PINOS_STREAM_STATE_UNCONNECTED); g_object_unref (stream); } static gboolean -do_disconnect (PvStream *stream) +do_disconnect (PinosStream *stream) { - PvStreamPrivate *priv = stream->priv; + PinosStreamPrivate *priv = stream->priv; g_dbus_proxy_call (priv->source_output, "Remove", @@ -679,25 +682,25 @@ do_disconnect (PvStream *stream) } /** - * pv_stream_disconnect: - * @stream: a #PvStream + * pinos_stream_disconnect: + * @stream: a #PinosStream * * Disconnect @stream. * * Returns: %TRUE on success */ gboolean -pv_stream_disconnect (PvStream *stream) +pinos_stream_disconnect (PinosStream *stream) { - PvStreamPrivate *priv; - PvContext *context; + PinosStreamPrivate *priv; + PinosContext *context; - g_return_val_if_fail (PV_IS_STREAM (stream), FALSE); + g_return_val_if_fail (PINOS_IS_STREAM (stream), FALSE); priv = stream->priv; - g_return_val_if_fail (priv->state >= PV_STREAM_STATE_READY, FALSE); + g_return_val_if_fail (priv->state >= PINOS_STREAM_STATE_READY, FALSE); g_return_val_if_fail (priv->source_output != NULL, FALSE); context = priv->context; - g_return_val_if_fail (pv_context_get_state (context) >= PV_CONTEXT_STATE_READY, FALSE); + g_return_val_if_fail (pinos_context_get_state (context) >= PINOS_CONTEXT_STATE_READY, FALSE); g_main_context_invoke (context->priv->context, (GSourceFunc) do_disconnect, @@ -709,12 +712,12 @@ pv_stream_disconnect (PvStream *stream) #include <gst/wire-protocol.h> static gboolean -on_socket_condition (GSocket *socket, - GIOCondition condition, - gpointer user_data) +on_socket_condition (GSocket *socket, + GIOCondition condition, + gpointer user_data) { - PvStream *stream = user_data; - PvStreamPrivate *priv = stream->priv; + PinosStream *stream = user_data; + PinosStreamPrivate *priv = stream->priv; switch (condition) { case G_IO_IN: @@ -771,9 +774,9 @@ on_socket_condition (GSocket *socket, static void -handle_socket (PvStream *stream, gint fd) +handle_socket (PinosStream *stream, gint fd) { - PvStreamPrivate *priv = stream->priv; + PinosStreamPrivate *priv = stream->priv; GError *error = NULL; priv->socket = g_socket_new_from_fd (fd, &error); @@ -781,11 +784,11 @@ handle_socket (PvStream *stream, gint fd) goto socket_failed; switch (priv->mode) { - case PV_STREAM_MODE_SOCKET: + case PINOS_STREAM_MODE_SOCKET: g_object_notify (G_OBJECT (stream), "socket"); break; - case PV_STREAM_MODE_BUFFER: + case PINOS_STREAM_MODE_BUFFER: { if (!priv->provide) { priv->socket_source = g_socket_create_source (priv->socket, G_IO_IN, NULL); @@ -804,24 +807,24 @@ handle_socket (PvStream *stream, gint fd) socket_failed: { priv->error = error; - stream_set_state (stream, PV_STREAM_STATE_ERROR); + stream_set_state (stream, PINOS_STREAM_STATE_ERROR); g_warning ("failed to create socket: %s", error->message); return; } } static void -unhandle_socket (PvStream *stream) +unhandle_socket (PinosStream *stream) { - PvStreamPrivate *priv = stream->priv; + PinosStreamPrivate *priv = stream->priv; switch (priv->mode) { - case PV_STREAM_MODE_SOCKET: + case PINOS_STREAM_MODE_SOCKET: g_clear_object (&priv->socket); g_object_notify (G_OBJECT (stream), "socket"); break; - case PV_STREAM_MODE_BUFFER: + case PINOS_STREAM_MODE_BUFFER: if (priv->socket_source) { g_source_destroy (priv->socket_source); g_clear_pointer (&priv->socket_source, g_source_unref); @@ -834,12 +837,12 @@ unhandle_socket (PvStream *stream) } static void -on_stream_started (GObject *source_object, +on_stream_started (GObject *source_object, GAsyncResult *res, - gpointer user_data) + gpointer user_data) { - PvStream *stream = user_data; - PvStreamPrivate *priv = stream->priv; + PinosStream *stream = user_data; + PinosStreamPrivate *priv = stream->priv; GUnixFDList *out_fd_list; gint fd_idx, fd; gchar *format; @@ -871,7 +874,7 @@ on_stream_started (GObject *source_object, handle_socket (stream, fd); - stream_set_state (stream, PV_STREAM_STATE_STREAMING); + stream_set_state (stream, PINOS_STREAM_STATE_STREAMING); return; @@ -889,15 +892,15 @@ fd_failed: exit_error: { priv->error = error; - stream_set_state (stream, PV_STREAM_STATE_ERROR); + stream_set_state (stream, PINOS_STREAM_STATE_ERROR); return; } } static gboolean -do_start (PvStream *stream) +do_start (PinosStream *stream) { - PvStreamPrivate *priv = stream->priv; + PinosStreamPrivate *priv = stream->priv; g_dbus_proxy_call (priv->source_output, "Start", @@ -912,35 +915,37 @@ do_start (PvStream *stream) } /** - * pv_stream_start: - * @stream: a #PvStream - * @mode: a #PvStreamMode + * pinos_stream_start: + * @stream: a #PinosStream + * @mode: a #PinosStreamMode * * Start capturing from @stream. * - * When @mode is #PV_STREAM_MODE_SOCKET, you should connect to the notify::socket + * When @mode is #PINOS_STREAM_MODE_SOCKET, you should connect to the notify::socket * signal to obtain a readable socket with metadata and data. * - * When @mode is #PV_STREAM_MODE_BUFFER, you should connect to the new-buffer - * signal and use pv_stream_capture_buffer() to get the latest metadata and + * When @mode is #PINOS_STREAM_MODE_BUFFER, you should connect to the new-buffer + * signal and use pinos_stream_capture_buffer() to get the latest metadata and * data. * * Returns: %TRUE on success. */ gboolean -pv_stream_start (PvStream *stream, GBytes *format, PvStreamMode mode) +pinos_stream_start (PinosStream *stream, + GBytes *format, + PinosStreamMode mode) { - PvStreamPrivate *priv; + PinosStreamPrivate *priv; - g_return_val_if_fail (PV_IS_STREAM (stream), FALSE); + g_return_val_if_fail (PINOS_IS_STREAM (stream), FALSE); priv = stream->priv; - g_return_val_if_fail (priv->state == PV_STREAM_STATE_READY, FALSE); + g_return_val_if_fail (priv->state == PINOS_STREAM_STATE_READY, FALSE); priv->mode = mode; priv->format = g_bytes_ref (format); - stream_set_state (stream, PV_STREAM_STATE_STARTING); + stream_set_state (stream, PINOS_STREAM_STATE_STARTING); g_main_context_invoke (priv->context->priv->context, (GSourceFunc) do_start, stream); @@ -948,12 +953,12 @@ pv_stream_start (PvStream *stream, GBytes *format, PvStreamMode mode) } static void -on_stream_stopped (GObject *source_object, +on_stream_stopped (GObject *source_object, GAsyncResult *res, - gpointer user_data) + gpointer user_data) { - PvStream *stream = user_data; - PvStreamPrivate *priv = stream->priv; + PinosStream *stream = user_data; + PinosStreamPrivate *priv = stream->priv; GVariant *ret; GError *error = NULL; @@ -967,7 +972,7 @@ on_stream_stopped (GObject *source_object, g_clear_pointer (&priv->format, g_free); g_object_notify (G_OBJECT (stream), "format"); - stream_set_state (stream, PV_STREAM_STATE_READY); + stream_set_state (stream, PINOS_STREAM_STATE_READY); return; @@ -975,16 +980,16 @@ on_stream_stopped (GObject *source_object, call_failed: { priv->error = error; - stream_set_state (stream, PV_STREAM_STATE_ERROR); + stream_set_state (stream, PINOS_STREAM_STATE_ERROR); g_warning ("failed to release: %s", error->message); return; } } static gboolean -do_stop (PvStream *stream) +do_stop (PinosStream *stream) { - PvStreamPrivate *priv = stream->priv; + PinosStreamPrivate *priv = stream->priv; g_dbus_proxy_call (priv->source_output, "Stop", @@ -999,22 +1004,22 @@ do_stop (PvStream *stream) return FALSE; } /** - * pv_stream_stop: - * @stream: a #PvStream + * pinos_stream_stop: + * @stream: a #PinosStream * * Stop capturing from @stream. * * Returns: %TRUE on success. */ gboolean -pv_stream_stop (PvStream *stream) +pinos_stream_stop (PinosStream *stream) { - PvStreamPrivate *priv; + PinosStreamPrivate *priv; - g_return_val_if_fail (PV_IS_STREAM (stream), FALSE); + g_return_val_if_fail (PINOS_IS_STREAM (stream), FALSE); priv = stream->priv; - g_return_val_if_fail (priv->state == PV_STREAM_STATE_STREAMING, FALSE); + g_return_val_if_fail (priv->state == PINOS_STREAM_STATE_STREAMING, FALSE); g_main_context_invoke (priv->context->priv->context, (GSourceFunc) do_stop, stream); @@ -1022,9 +1027,9 @@ pv_stream_stop (PvStream *stream) } /** - * pv_stream_capture_buffer: - * @stream: a #PvStream - * @info: a #PvBufferInfo + * pinos_stream_capture_buffer: + * @stream: a #PinosStream + * @info: a #PinosBufferInfo * * Capture the next buffer from @stream. This function should be called every * time after the new-buffer callback has been emitted. @@ -1032,15 +1037,16 @@ pv_stream_stop (PvStream *stream) * Returns: %TRUE when @info contains valid information */ gboolean -pv_stream_capture_buffer (PvStream *stream, PvBufferInfo *info) +pinos_stream_capture_buffer (PinosStream *stream, + PinosBufferInfo *info) { - PvStreamPrivate *priv; + PinosStreamPrivate *priv; - g_return_val_if_fail (PV_IS_STREAM (stream), FALSE); + g_return_val_if_fail (PINOS_IS_STREAM (stream), FALSE); g_return_val_if_fail (info != NULL, FALSE); priv = stream->priv; - g_return_val_if_fail (priv->state == PV_STREAM_STATE_STREAMING, FALSE); + g_return_val_if_fail (priv->state == PINOS_STREAM_STATE_STREAMING, FALSE); *info = priv->info; @@ -1048,9 +1054,9 @@ pv_stream_capture_buffer (PvStream *stream, PvBufferInfo *info) } /** - * pv_stream_provide_buffer: - * @stream: a #PvStream - * @info: a #PvBufferInfo + * pinos_stream_provide_buffer: + * @stream: a #PinosStream + * @info: a #PinosBufferInfo * * Provide the next buffer from @stream. This function should be called every * time a new frame becomes available. @@ -1058,20 +1064,21 @@ pv_stream_capture_buffer (PvStream *stream, PvBufferInfo *info) * Returns: %TRUE when @info was handled */ gboolean -pv_stream_provide_buffer (PvStream *stream, PvBufferInfo *info) +pinos_stream_provide_buffer (PinosStream *stream, + PinosBufferInfo *info) { - PvStreamPrivate *priv; + PinosStreamPrivate *priv; gssize len; GOutputVector ovec; FDMessage msg; gint flags = 0; GError *error = NULL; - g_return_val_if_fail (PV_IS_STREAM (stream), FALSE); + g_return_val_if_fail (PINOS_IS_STREAM (stream), FALSE); g_return_val_if_fail (info != NULL, FALSE); priv = stream->priv; - g_return_val_if_fail (priv->state == PV_STREAM_STATE_STREAMING, FALSE); + g_return_val_if_fail (priv->state == PINOS_STREAM_STATE_STREAMING, FALSE); msg.flags = info->flags; msg.seq = info->seq; @@ -1107,7 +1114,7 @@ pv_stream_provide_buffer (PvStream *stream, PvBufferInfo *info) send_error: { priv->error = error; - stream_set_state (stream, PV_STREAM_STATE_ERROR); + stream_set_state (stream, PINOS_STREAM_STATE_ERROR); g_warning ("failed to send_message: %s", error->message); return FALSE; } diff --git a/src/client/stream.h b/src/client/stream.h new file mode 100644 index 00000000..118324eb --- /dev/null +++ b/src/client/stream.h @@ -0,0 +1,125 @@ +/* Pinos + * Copyright (C) 2015 Wim Taymans <wim.taymans@gmail.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef __PINOS_STREAM_H__ +#define __PINOS_STREAM_H__ + +#include <gio/gio.h> +#include <glib-object.h> + +#include "context.h" + +G_BEGIN_DECLS + +#define PINOS_TYPE_STREAM (pinos_stream_get_type ()) +#define PINOS_IS_STREAM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PINOS_TYPE_STREAM)) +#define PINOS_IS_STREAM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PINOS_TYPE_STREAM)) +#define PINOS_STREAM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PINOS_TYPE_STREAM, PinosStreamClass)) +#define PINOS_STREAM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PINOS_TYPE_STREAM, PinosStream)) +#define PINOS_STREAM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PINOS_TYPE_STREAM, PinosStreamClass)) +#define PINOS_STREAM_CAST(obj) ((PinosStream*)(obj)) +#define PINOS_STREAM_CLASS_CAST(klass) ((PinosStreamClass*)(klass)) + +typedef struct _PinosStream PinosStream; +typedef struct _PinosStreamClass PinosStreamClass; +typedef struct _PinosStreamPrivate PinosStreamPrivate; + +typedef enum { + PINOS_STREAM_STATE_UNCONNECTED = 0, + PINOS_STREAM_STATE_CONNECTING = 1, + PINOS_STREAM_STATE_READY = 2, + PINOS_STREAM_STATE_STARTING = 3, + PINOS_STREAM_STATE_STREAMING = 4, + PINOS_STREAM_STATE_ERROR = 5 +} PinosStreamState; + + +typedef enum { + PINOS_STREAM_FLAGS_NONE = 0, +} PinosStreamFlags; + +typedef struct { + guint32 flags; + guint32 seq; + gint64 pts; + gint64 dts_offset; + guint64 offset; + guint64 size; + GSocketControlMessage *message; +} PinosBufferInfo; + +typedef enum { + PINOS_STREAM_MODE_SOCKET = 0, + PINOS_STREAM_MODE_BUFFER = 1, +} PinosStreamMode; + +/** + * PinosStream: + * + * Pinos stream object class. + */ +struct _PinosStream { + GObject object; + + PinosStreamPrivate *priv; +}; + +/** + * PinosStreamClass: + * + * Pinos stream object class. + */ +struct _PinosStreamClass { + GObjectClass parent_class; +}; + +/* normal GObject stuff */ +GType pinos_stream_get_type (void); + + +PinosStream * pinos_stream_new (PinosContext * context, + const gchar *name, + GVariant * props); + +PinosStreamState pinos_stream_get_state (PinosStream *stream); +const GError * pinos_stream_get_error (PinosStream *stream); + +gboolean pinos_stream_connect_capture (PinosStream *stream, + const gchar *source, + PinosStreamFlags flags, + GBytes *accepted_formats); +gboolean pinos_stream_connect_provide (PinosStream *stream, + PinosStreamFlags flags, + GBytes *possible_formats); +gboolean pinos_stream_disconnect (PinosStream *stream); + +gboolean pinos_stream_start (PinosStream *stream, + GBytes *format, + PinosStreamMode mode); +gboolean pinos_stream_stop (PinosStream *stream); + +gboolean pinos_stream_capture_buffer (PinosStream *stream, + PinosBufferInfo *info); +gboolean pinos_stream_provide_buffer (PinosStream *stream, + PinosBufferInfo *info); + +G_END_DECLS + +#endif /* __PINOS_STREAM_H__ */ + diff --git a/src/client/pv-subscribe.c b/src/client/subscribe.c index 58c0e223..bab65b11 100644 --- a/src/client/pv-subscribe.c +++ b/src/client/subscribe.c @@ -20,12 +20,12 @@ #include <gio/gio.h> #include "client/pinos.h" -#include "client/pv-enumtypes.h" +#include "client/enumtypes.h" -struct _PvSubscribePrivate +struct _PinosSubscribePrivate { gchar *service; - PvSubscriptionFlags subscription_mask; + PinosSubscriptionFlags subscription_mask; GDBusConnection *connection; GCancellable *cancellable; @@ -35,13 +35,13 @@ struct _PvSubscribePrivate guint pending_proxies; GList *objects; - PvSubscriptionState state; + PinosSubscriptionState state; GError *error; }; typedef struct { - PvSubscribe *subscribe; + PinosSubscribe *subscribe; gchar *sender_name; gchar *object_path; gchar *interface_name; @@ -49,13 +49,13 @@ typedef struct GDBusProxy *proxy; GList *tasks; gboolean removed; -} PvObjectData; +} PinosObjectData; -#define PV_SUBSCRIBE_GET_PRIVATE(obj) \ - (G_TYPE_INSTANCE_GET_PRIVATE ((obj), PV_TYPE_SUBSCRIBE, PvSubscribePrivate)) +#define PINOS_SUBSCRIBE_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE ((obj), PINOS_TYPE_SUBSCRIBE, PinosSubscribePrivate)) -G_DEFINE_TYPE (PvSubscribe, pv_subscribe, G_TYPE_OBJECT); +G_DEFINE_TYPE (PinosSubscribe, pinos_subscribe, G_TYPE_OBJECT); enum { @@ -75,9 +75,10 @@ enum static guint signals[LAST_SIGNAL] = { 0 }; static void -subscription_set_state (PvSubscribe *subscribe, PvSubscriptionState state) +subscription_set_state (PinosSubscribe *subscribe, + PinosSubscriptionState state) { - PvSubscribePrivate *priv = subscribe->priv; + PinosSubscribePrivate *priv = subscribe->priv; if (state != priv->state) { priv->state = state; @@ -86,25 +87,25 @@ subscription_set_state (PvSubscribe *subscribe, PvSubscriptionState state) } static void -notify_event (PvSubscribe *subscribe, - PvObjectData *data, - PvSubscriptionEvent event) +notify_event (PinosSubscribe *subscribe, + PinosObjectData *data, + PinosSubscriptionEvent event) { const gchar *interface_name; - PvSubscriptionFlags flags = 0; + PinosSubscriptionFlags flags = 0; interface_name = g_dbus_proxy_get_interface_name (data->proxy); if (g_strcmp0 (interface_name, "org.pinos.Daemon1") == 0) { - flags = PV_SUBSCRIPTION_FLAGS_DAEMON; + flags = PINOS_SUBSCRIPTION_FLAGS_DAEMON; } else if (g_strcmp0 (interface_name, "org.pinos.Client1") == 0) { - flags = PV_SUBSCRIPTION_FLAGS_CLIENT; + flags = PINOS_SUBSCRIPTION_FLAGS_CLIENT; } else if (g_strcmp0 (interface_name, "org.pinos.Source1") == 0) { - flags = PV_SUBSCRIPTION_FLAGS_SOURCE; + flags = PINOS_SUBSCRIPTION_FLAGS_SOURCE; } else if (g_strcmp0 (interface_name, "org.pinos.SourceOutput1") == 0) { - flags = PV_SUBSCRIPTION_FLAGS_SOURCE_OUTPUT; + flags = PINOS_SUBSCRIPTION_FLAGS_SOURCE_OUTPUT; } g_signal_emit (subscribe, signals[SIGNAL_SUBSCRIPTION_EVENT], 0, event, flags, data->proxy); @@ -116,13 +117,13 @@ on_proxy_properties_changed (GDBusProxy *proxy, GStrv invalidated_properties, gpointer user_data) { - PvObjectData *data = user_data; + PinosObjectData *data = user_data; - notify_event (data->subscribe, data, PV_SUBSCRIPTION_EVENT_CHANGE); + notify_event (data->subscribe, data, PINOS_SUBSCRIPTION_EVENT_CHANGE); } static void -object_data_free (PvObjectData *data) +object_data_free (PinosObjectData *data) { g_object_unref (data->proxy); g_free (data->sender_name); @@ -132,24 +133,25 @@ object_data_free (PvObjectData *data) } static void -remove_data (PvSubscribe *subscribe, PvObjectData *data) +remove_data (PinosSubscribe *subscribe, + PinosObjectData *data) { if (data->pending) { data->removed = TRUE; } else { - notify_event (subscribe, data, PV_SUBSCRIPTION_EVENT_REMOVE); + notify_event (subscribe, data, PINOS_SUBSCRIPTION_EVENT_REMOVE); object_data_free (data); } } static void -remove_all_data (PvSubscribe *subscribe) +remove_all_data (PinosSubscribe *subscribe) { - PvSubscribePrivate *priv = subscribe->priv; + PinosSubscribePrivate *priv = subscribe->priv; GList *walk; for (walk = priv->objects; walk; walk = g_list_next (walk)) { - PvObjectData *data = walk->data; + PinosObjectData *data = walk->data; remove_data (subscribe, data); } g_list_free (priv->objects); @@ -157,13 +159,13 @@ remove_all_data (PvSubscribe *subscribe) } static void -on_proxy_created (GObject *source_object, +on_proxy_created (GObject *source_object, GAsyncResult *res, - gpointer user_data) + gpointer user_data) { - PvObjectData *data = user_data; - PvSubscribe *subscribe = data->subscribe; - PvSubscribePrivate *priv = subscribe->priv; + PinosObjectData *data = user_data; + PinosSubscribe *subscribe = data->subscribe; + PinosSubscribePrivate *priv = subscribe->priv; GError *error = NULL; GList *walk; @@ -173,7 +175,7 @@ on_proxy_created (GObject *source_object, if (data->proxy == NULL) { priv->objects = g_list_remove (priv->objects, data); g_warning ("could not create proxy: %s", error->message); - subscription_set_state (subscribe, PV_SUBSCRIPTION_STATE_ERROR); + subscription_set_state (subscribe, PINOS_SUBSCRIPTION_STATE_ERROR); priv->error = error; return; } @@ -183,7 +185,7 @@ on_proxy_created (GObject *source_object, (GCallback) on_proxy_properties_changed, data); - notify_event (subscribe, data, PV_SUBSCRIPTION_EVENT_NEW); + notify_event (subscribe, data, PINOS_SUBSCRIPTION_EVENT_NEW); for (walk = data->tasks; walk; walk = g_list_next (walk)) { GTask *task = walk->data; @@ -194,7 +196,7 @@ on_proxy_created (GObject *source_object, data->tasks = NULL; if (--priv->pending_proxies == 0) - subscription_set_state (subscribe, PV_SUBSCRIPTION_STATE_READY); + subscription_set_state (subscribe, PINOS_SUBSCRIPTION_STATE_READY); if (data->removed) { priv->objects = g_list_remove (priv->objects, data); @@ -204,15 +206,15 @@ on_proxy_created (GObject *source_object, static void -add_interface (PvSubscribe *subscribe, - const gchar *object_path, - const gchar *interface_name, - GVariant *properties) +add_interface (PinosSubscribe *subscribe, + const gchar *object_path, + const gchar *interface_name, + GVariant *properties) { - PvSubscribePrivate *priv = subscribe->priv; - PvObjectData *data; + PinosSubscribePrivate *priv = subscribe->priv; + PinosObjectData *data; - data = g_new0 (PvObjectData, 1); + data = g_new0 (PinosObjectData, 1); data->subscribe = subscribe; data->sender_name = g_strdup (priv->service); data->object_path = g_strdup (object_path); @@ -234,15 +236,15 @@ add_interface (PvSubscribe *subscribe, } static void -remove_interface (PvSubscribe *subscribe, - const gchar *object_path, - const gchar *interface_name) +remove_interface (PinosSubscribe *subscribe, + const gchar *object_path, + const gchar *interface_name) { - PvSubscribePrivate *priv = subscribe->priv; + PinosSubscribePrivate *priv = subscribe->priv; GList *walk; for (walk = priv->objects; walk; walk = g_list_next (walk)) { - PvObjectData *data = walk->data; + PinosObjectData *data = walk->data; if (g_strcmp0 (data->object_path, object_path) == 0 && g_strcmp0 (data->interface_name, interface_name) == 0) { @@ -254,9 +256,9 @@ remove_interface (PvSubscribe *subscribe, } static void -add_ifaces_and_properties (PvSubscribe *subscribe, - const gchar *object_path, - GVariant *ifaces_and_properties) +add_ifaces_and_properties (PinosSubscribe *subscribe, + const gchar *object_path, + GVariant *ifaces_and_properties) { GVariantIter iter; const gchar *interface_name; @@ -275,9 +277,9 @@ add_ifaces_and_properties (PvSubscribe *subscribe, } static void -remove_ifaces (PvSubscribe *subscribe, - const gchar *object_path, - const gchar **ifaces) +remove_ifaces (PinosSubscribe *subscribe, + const gchar *object_path, + const gchar **ifaces) { while (*ifaces) { remove_interface (subscribe, object_path, *ifaces); @@ -293,7 +295,7 @@ on_manager_proxy_signal (GDBusProxy *proxy, GVariant *parameters, gpointer user_data) { - PvSubscribe *subscribe = user_data; + PinosSubscribe *subscribe = user_data; const gchar *object_path; if (g_strcmp0 (signal_name, "InterfacesAdded") == 0) { @@ -321,12 +323,12 @@ on_manager_proxy_signal (GDBusProxy *proxy, } static void -on_managed_objects_ready (GObject *source_object, +on_managed_objects_ready (GObject *source_object, GAsyncResult *res, - gpointer user_data) + gpointer user_data) { - PvSubscribe *subscribe = user_data; - PvSubscribePrivate *priv = subscribe->priv; + PinosSubscribe *subscribe = user_data; + PinosSubscribePrivate *priv = subscribe->priv; GError *error = NULL; GVariant *objects; GVariant *arg0; @@ -337,7 +339,7 @@ on_managed_objects_ready (GObject *source_object, objects = g_dbus_proxy_call_finish (priv->manager_proxy, res, &error); if (objects == NULL) { g_warning ("could not get objects: %s", error->message); - subscription_set_state (subscribe, PV_SUBSCRIPTION_STATE_ERROR); + subscription_set_state (subscribe, PINOS_SUBSCRIPTION_STATE_ERROR); priv->error = error; return; } @@ -357,13 +359,13 @@ on_managed_objects_ready (GObject *source_object, g_variant_unref (objects); if (priv->pending_proxies == 0) - subscription_set_state (subscribe, PV_SUBSCRIPTION_STATE_READY); + subscription_set_state (subscribe, PINOS_SUBSCRIPTION_STATE_READY); } static void -manager_proxy_appeared (PvSubscribe *subscribe) +manager_proxy_appeared (PinosSubscribe *subscribe) { - PvSubscribePrivate *priv = subscribe->priv; + PinosSubscribePrivate *priv = subscribe->priv; g_dbus_proxy_call (priv->manager_proxy, "GetManagedObjects", @@ -376,7 +378,7 @@ manager_proxy_appeared (PvSubscribe *subscribe) } static void -manager_proxy_disappeared (PvSubscribe *subscribe) +manager_proxy_disappeared (PinosSubscribe *subscribe) { remove_all_data (subscribe); } @@ -386,8 +388,8 @@ on_manager_proxy_name_owner (GObject *object, GParamSpec *pspec, gpointer user_data) { - PvSubscribe *subscribe = user_data; - PvSubscribePrivate *priv = subscribe->priv; + PinosSubscribe *subscribe = user_data; + PinosSubscribePrivate *priv = subscribe->priv; gchar *name_owner; g_object_get (priv->manager_proxy, "g-name-owner", &name_owner, NULL); @@ -402,9 +404,9 @@ on_manager_proxy_name_owner (GObject *object, static void -connect_client_signals (PvSubscribe *subscribe) +connect_client_signals (PinosSubscribe *subscribe) { - PvSubscribePrivate *priv = subscribe->priv; + PinosSubscribePrivate *priv = subscribe->priv; g_signal_connect (priv->manager_proxy, "notify::g-name-owner", (GCallback) on_manager_proxy_name_owner, subscribe); @@ -414,12 +416,12 @@ connect_client_signals (PvSubscribe *subscribe) } static void -on_manager_proxy_ready (GObject *source_object, +on_manager_proxy_ready (GObject *source_object, GAsyncResult *res, - gpointer user_data) + gpointer user_data) { - PvSubscribe *subscribe = user_data; - PvSubscribePrivate *priv = subscribe->priv; + PinosSubscribe *subscribe = user_data; + PinosSubscribePrivate *priv = subscribe->priv; GError *error = NULL; priv->manager_proxy = g_dbus_proxy_new_finish (res, &error); @@ -437,7 +439,7 @@ on_manager_proxy_ready (GObject *source_object, manager_error: { g_warning ("could not create client manager: %s", error->message); - subscription_set_state (subscribe, PV_SUBSCRIPTION_STATE_ERROR); + subscription_set_state (subscribe, PINOS_SUBSCRIPTION_STATE_ERROR); priv->error = error; g_object_unref (subscribe); return; @@ -445,17 +447,17 @@ manager_error: } static void -install_subscription (PvSubscribe *subscribe) +install_subscription (PinosSubscribe *subscribe) { - PvSubscribePrivate *priv = subscribe->priv; + PinosSubscribePrivate *priv = subscribe->priv; - subscription_set_state (subscribe, PV_SUBSCRIPTION_STATE_CONNECTING); + subscription_set_state (subscribe, PINOS_SUBSCRIPTION_STATE_CONNECTING); g_dbus_proxy_new (priv->connection, G_DBUS_PROXY_FLAGS_NONE, NULL, /* GDBusInterfaceInfo* */ priv->service, - PV_DBUS_OBJECT_PREFIX, + PINOS_DBUS_OBJECT_PREFIX, "org.freedesktop.DBus.ObjectManager", priv->cancellable, on_manager_proxy_ready, @@ -463,23 +465,23 @@ install_subscription (PvSubscribe *subscribe) } static void -uninstall_subscription (PvSubscribe *subscribe) +uninstall_subscription (PinosSubscribe *subscribe) { - PvSubscribePrivate *priv = subscribe->priv; + PinosSubscribePrivate *priv = subscribe->priv; g_clear_object (&priv->manager_proxy); g_clear_error (&priv->error); - subscription_set_state (subscribe, PV_SUBSCRIPTION_STATE_UNCONNECTED); + subscription_set_state (subscribe, PINOS_SUBSCRIPTION_STATE_UNCONNECTED); } static void -pv_subscribe_get_property (GObject *_object, - guint prop_id, - GValue *value, - GParamSpec *pspec) +pinos_subscribe_get_property (GObject *_object, + guint prop_id, + GValue *value, + GParamSpec *pspec) { - PvSubscribe *subscribe = PV_SUBSCRIBE (_object); - PvSubscribePrivate *priv = subscribe->priv; + PinosSubscribe *subscribe = PINOS_SUBSCRIBE (_object); + PinosSubscribePrivate *priv = subscribe->priv; switch (prop_id) { case PROP_CONNECTION: @@ -505,13 +507,13 @@ pv_subscribe_get_property (GObject *_object, } static void -pv_subscribe_set_property (GObject *_object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) +pinos_subscribe_set_property (GObject *_object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) { - PvSubscribe *subscribe = PV_SUBSCRIBE (_object); - PvSubscribePrivate *priv = subscribe->priv; + PinosSubscribe *subscribe = PINOS_SUBSCRIBE (_object); + PinosSubscribePrivate *priv = subscribe->priv; switch (prop_id) { case PROP_CONNECTION: @@ -541,10 +543,10 @@ pv_subscribe_set_property (GObject *_object, } static void -pv_subscribe_finalize (GObject * object) +pinos_subscribe_finalize (GObject * object) { - PvSubscribe *subscribe = PV_SUBSCRIBE (object); - PvSubscribePrivate *priv = subscribe->priv; + PinosSubscribe *subscribe = PINOS_SUBSCRIBE (object); + PinosSubscribePrivate *priv = subscribe->priv; g_cancellable_cancel (priv->cancellable); if (priv->manager_proxy) @@ -552,22 +554,22 @@ pv_subscribe_finalize (GObject * object) g_object_unref (priv->cancellable); g_free (priv->service); - G_OBJECT_CLASS (pv_subscribe_parent_class)->finalize (object); + G_OBJECT_CLASS (pinos_subscribe_parent_class)->finalize (object); } static void -pv_subscribe_class_init (PvSubscribeClass * klass) +pinos_subscribe_class_init (PinosSubscribeClass * klass) { GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - g_type_class_add_private (klass, sizeof (PvSubscribePrivate)); + g_type_class_add_private (klass, sizeof (PinosSubscribePrivate)); - gobject_class->finalize = pv_subscribe_finalize; - gobject_class->set_property = pv_subscribe_set_property; - gobject_class->get_property = pv_subscribe_get_property; + gobject_class->finalize = pinos_subscribe_finalize; + gobject_class->set_property = pinos_subscribe_set_property; + gobject_class->get_property = pinos_subscribe_get_property; /** - * PvSubscribe:connection + * PinosSubscribe:connection * * The connection of the subscribe. */ @@ -580,7 +582,7 @@ pv_subscribe_class_init (PvSubscribeClass * klass) G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); /** - * PvSubscribe:service + * PinosSubscribe:service * * The service of the subscribe. */ @@ -589,26 +591,26 @@ pv_subscribe_class_init (PvSubscribeClass * klass) g_param_spec_string ("service", "Service", "The service", - PV_DBUS_SERVICE, + PINOS_DBUS_SERVICE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); /** - * PvSubscribe:subscription-mask + * PinosSubscribe:subscription-mask * * A mask for what object notifications will be signaled with - * PvSubscribe:subscription-event + * PinosSubscribe:subscription-event */ g_object_class_install_property (gobject_class, PROP_SUBSCRIPTION_MASK, g_param_spec_flags ("subscription-mask", "Subscription Mask", "The object to receive subscription events of", - PV_TYPE_SUBSCRIPTION_FLAGS, + PINOS_TYPE_SUBSCRIPTION_FLAGS, 0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); /** - * PvSubscribe:state + * PinosSubscribe:state * * The state of the subscription */ @@ -617,15 +619,15 @@ pv_subscribe_class_init (PvSubscribeClass * klass) g_param_spec_enum ("state", "State", "The state", - PV_TYPE_SUBSCRIPTION_STATE, - PV_SUBSCRIPTION_STATE_UNCONNECTED, + PINOS_TYPE_SUBSCRIPTION_STATE, + PINOS_SUBSCRIPTION_STATE_UNCONNECTED, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); /** - * PvSubscribe:subscription-event - * @subscribe: The #PvSubscribe emitting the signal. - * @event: A #PvSubscriptionEvent - * @flags: #PvSubscriptionFlags indicating the object + * PinosSubscribe:subscription-event + * @subscribe: The #PinosSubscribe emitting the signal. + * @event: A #PinosSubscriptionEvent + * @flags: #PinosSubscriptionFlags indicating the object * @path: the object path * * Notify about a new object that was added/removed/modified. @@ -639,62 +641,63 @@ pv_subscribe_class_init (PvSubscribeClass * klass) g_cclosure_marshal_generic, G_TYPE_NONE, 3, - PV_TYPE_SUBSCRIPTION_EVENT, - PV_TYPE_SUBSCRIPTION_FLAGS, + PINOS_TYPE_SUBSCRIPTION_EVENT, + PINOS_TYPE_SUBSCRIPTION_FLAGS, G_TYPE_DBUS_PROXY); } static void -pv_subscribe_init (PvSubscribe * subscribe) +pinos_subscribe_init (PinosSubscribe * subscribe) { - PvSubscribePrivate *priv = subscribe->priv = PV_SUBSCRIBE_GET_PRIVATE (subscribe); + PinosSubscribePrivate *priv = subscribe->priv = PINOS_SUBSCRIBE_GET_PRIVATE (subscribe); - priv->service = g_strdup (PV_DBUS_SERVICE); - priv->state = PV_SUBSCRIPTION_STATE_UNCONNECTED; + priv->service = g_strdup (PINOS_DBUS_SERVICE); + priv->state = PINOS_SUBSCRIPTION_STATE_UNCONNECTED; priv->cancellable = g_cancellable_new (); } /** - * pv_subscribe_new: + * pinos_subscribe_new: * @name: an application name * @properties: optional properties * - * Make a new unconnected #PvSubscribe + * Make a new unconnected #PinosSubscribe * - * Returns: a new unconnected #PvSubscribe + * Returns: a new unconnected #PinosSubscribe */ -PvSubscribe * -pv_subscribe_new (void) +PinosSubscribe * +pinos_subscribe_new (void) { - return g_object_new (PV_TYPE_SUBSCRIBE, NULL); + return g_object_new (PINOS_TYPE_SUBSCRIBE, NULL); } -PvSubscriptionState -pv_subscribe_get_state (PvSubscribe *subscribe) +PinosSubscriptionState +pinos_subscribe_get_state (PinosSubscribe *subscribe) { - PvSubscribePrivate *priv; + PinosSubscribePrivate *priv; - g_return_val_if_fail (PV_IS_SUBSCRIBE (subscribe), PV_SUBSCRIPTION_STATE_ERROR); + g_return_val_if_fail (PINOS_IS_SUBSCRIBE (subscribe), PINOS_SUBSCRIPTION_STATE_ERROR); priv = subscribe->priv; return priv->state; } GError * -pv_subscribe_get_error (PvSubscribe *subscribe) +pinos_subscribe_get_error (PinosSubscribe *subscribe) { - PvSubscribePrivate *priv; + PinosSubscribePrivate *priv; - g_return_val_if_fail (PV_IS_SUBSCRIBE (subscribe), NULL); + g_return_val_if_fail (PINOS_IS_SUBSCRIBE (subscribe), NULL); priv = subscribe->priv; return priv->error; } static gint -compare_data (PvObjectData *data, const gchar *name, - const gchar *object_path, - const gchar *interface_name) +compare_data (PinosObjectData *data, + const gchar *name, + const gchar *object_path, + const gchar *interface_name) { gint res; @@ -708,22 +711,22 @@ compare_data (PvObjectData *data, const gchar *name, } void -pv_subscribe_get_proxy (PvSubscribe *subscribe, - const gchar *name, - const gchar *object_path, - const gchar *interface_name, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data) -{ - PvSubscribePrivate *priv; +pinos_subscribe_get_proxy (PinosSubscribe *subscribe, + const gchar *name, + const gchar *object_path, + const gchar *interface_name, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + PinosSubscribePrivate *priv; GList *walk; - g_return_if_fail (PV_IS_SUBSCRIBE (subscribe)); + g_return_if_fail (PINOS_IS_SUBSCRIBE (subscribe)); priv = subscribe->priv; for (walk = priv->objects; walk; walk = g_list_next (walk)) { - PvObjectData *data = walk->data; + PinosObjectData *data = walk->data; if (compare_data (data, name, object_path, interface_name) == 0) { GTask *task; @@ -746,9 +749,9 @@ pv_subscribe_get_proxy (PvSubscribe *subscribe, } GDBusProxy * -pv_subscribe_get_proxy_finish (PvSubscribe *subscribe, - GAsyncResult *res, - GError **error) +pinos_subscribe_get_proxy_finish (PinosSubscribe *subscribe, + GAsyncResult *res, + GError **error) { return g_task_propagate_pointer (G_TASK (res), error); } diff --git a/src/client/subscribe.h b/src/client/subscribe.h new file mode 100644 index 00000000..382eb994 --- /dev/null +++ b/src/client/subscribe.h @@ -0,0 +1,106 @@ +/* Pinos + * Copyright (C) 2015 Wim Taymans <wim.taymans@gmail.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef __PINOS_SUBSCRIBE_H__ +#define __PINOS_SUBSCRIBE_H__ + +#include <glib.h> + +G_BEGIN_DECLS + +#define PINOS_TYPE_SUBSCRIBE (pinos_subscribe_get_type ()) +#define PINOS_IS_SUBSCRIBE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PINOS_TYPE_SUBSCRIBE)) +#define PINOS_IS_SUBSCRIBE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PINOS_TYPE_SUBSCRIBE)) +#define PINOS_SUBSCRIBE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PINOS_TYPE_SUBSCRIBE, PinosSubscribeClass)) +#define PINOS_SUBSCRIBE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PINOS_TYPE_SUBSCRIBE, PinosSubscribe)) +#define PINOS_SUBSCRIBE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PINOS_TYPE_SUBSCRIBE, PinosSubscribeClass)) +#define PINOS_SUBSCRIBE_CAST(obj) ((PinosSubscribe*)(obj)) +#define PINOS_SUBSCRIBE_CLASS_CAST(klass) ((PinosSubscribeClass*)(klass)) + +typedef struct _PinosSubscribe PinosSubscribe; +typedef struct _PinosSubscribeClass PinosSubscribeClass; +typedef struct _PinosSubscribePrivate PinosSubscribePrivate; + +typedef enum { + PINOS_SUBSCRIPTION_STATE_UNCONNECTED = 0, + PINOS_SUBSCRIPTION_STATE_CONNECTING = 1, + PINOS_SUBSCRIPTION_STATE_READY = 2, + PINOS_SUBSCRIPTION_STATE_ERROR = 3, +} PinosSubscriptionState; + +typedef enum { + PINOS_SUBSCRIPTION_FLAGS_DAEMON = (1 << 0), + PINOS_SUBSCRIPTION_FLAGS_CLIENT = (1 << 1), + PINOS_SUBSCRIPTION_FLAGS_SOURCE = (1 << 2), + PINOS_SUBSCRIPTION_FLAGS_SOURCE_OUTPUT = (1 << 3), +} PinosSubscriptionFlags; + +#define PINOS_SUBSCRIPTION_FLAGS_ALL 0xf + +typedef enum { + PINOS_SUBSCRIPTION_EVENT_NEW = 0, + PINOS_SUBSCRIPTION_EVENT_CHANGE = 1, + PINOS_SUBSCRIPTION_EVENT_REMOVE = 2, +} PinosSubscriptionEvent; + +/** + * PinosSubscribe: + * + * Pinos subscribe object class. + */ +struct _PinosSubscribe { + GObject object; + + PinosSubscribePrivate *priv; +}; + +/** + * PinosSubscribeClass: + * + * Pinos subscribe object class. + */ +struct _PinosSubscribeClass { + GObjectClass parent_class; +}; + +/* normal GObject stuff */ +GType pinos_subscribe_get_type (void); + +PinosSubscribe * pinos_subscribe_new (void); + +PinosSubscriptionState pinos_subscribe_get_state (PinosSubscribe *subscribe); +GError * pinos_subscribe_get_error (PinosSubscribe *subscribe); + +void pinos_subscribe_get_proxy (PinosSubscribe *subscribe, + const gchar *name, + const gchar *object_path, + const gchar *interface_name, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +GDBusProxy * pinos_subscribe_get_proxy_finish (PinosSubscribe *subscribe, + GAsyncResult *res, + GError **error); + + + +G_END_DECLS + +#endif /* __PINOS_SUBSCRIBE_H__ */ + diff --git a/src/daemon/main.c b/src/daemon/main.c index f61d268b..7bfca22e 100644 --- a/src/daemon/main.c +++ b/src/daemon/main.c @@ -21,23 +21,23 @@ #include <gst/gst.h> #include <client/pinos.h> -#include <server/pv-daemon.h> -#include <modules/gst/pv-gst-manager.h> +#include <server/daemon.h> +#include <modules/gst/gst-manager.h> gint main (gint argc, gchar *argv[]) { - PvDaemon *daemon; + PinosDaemon *daemon; GMainLoop *loop; - pv_init (&argc, &argv); + pinos_init (&argc, &argv); loop = g_main_loop_new (NULL, FALSE); - daemon = pv_daemon_new (); + daemon = pinos_daemon_new (); - pv_gst_manager_new (daemon); - pv_daemon_start (daemon); + pinos_gst_manager_new (daemon); + pinos_daemon_start (daemon); g_main_loop_run (loop); diff --git a/src/gst/gstpv.c b/src/gst/gstpinos.c index b9eda8c7..44f95dfa 100644 --- a/src/gst/gstpv.c +++ b/src/gst/gstpinos.c @@ -32,17 +32,17 @@ #include "config.h" #endif -#include "gstpvsrc.h" -#include "gstpvsink.h" +#include "gstpinossrc.h" +#include "gstpinossink.h" #include "gstfdpay.h" #include "gstfddepay.h" static gboolean plugin_init (GstPlugin * plugin) { - gst_element_register (plugin, "pvfdpay", GST_RANK_NONE, + gst_element_register (plugin, "pinosfdpay", GST_RANK_NONE, GST_TYPE_FDPAY); - gst_element_register (plugin, "pvfddepay", GST_RANK_NONE, + gst_element_register (plugin, "pinosfddepay", GST_RANK_NONE, GST_TYPE_FDDEPAY); gst_element_register (plugin, "pinossrc", GST_RANK_PRIMARY + 1, GST_TYPE_PINOS_SRC); diff --git a/src/gst/gstpvsink.c b/src/gst/gstpinossink.c index 55ebc535..cf784836 100644 --- a/src/gst/gstpvsink.c +++ b/src/gst/gstpinossink.c @@ -31,7 +31,7 @@ #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include "gstpvsink.h" +#include "gstpinossink.h" #include <string.h> #include <stdlib.h> @@ -55,7 +55,7 @@ enum }; -#define PVS_VIDEO_CAPS GST_VIDEO_CAPS_MAKE (GST_VIDEO_FORMATS_ALL) +#define PINOSS_VIDEO_CAPS GST_VIDEO_CAPS_MAKE (GST_VIDEO_FORMATS_ALL) static GstStaticPadTemplate gst_pinos_sink_template = GST_STATIC_PAD_TEMPLATE ("sink", @@ -196,9 +196,9 @@ static void on_new_buffer (GObject *gobject, gpointer user_data) { - GstPinosSink *pvsink = user_data; + GstPinosSink *pinossink = user_data; - g_cond_signal (&pvsink->cond); + g_cond_signal (&pinossink->cond); } static void @@ -206,17 +206,17 @@ on_stream_notify (GObject *gobject, GParamSpec *pspec, gpointer user_data) { - PvStreamState state; - GstPinosSink *pvsink = user_data; + PinosStreamState state; + GstPinosSink *pinossink = user_data; - state = pv_stream_get_state (pvsink->stream); + state = pinos_stream_get_state (pinossink->stream); g_print ("got stream state %d\n", state); - g_cond_broadcast (&pvsink->cond); + g_cond_broadcast (&pinossink->cond); - if (state == PV_STREAM_STATE_ERROR) { - GST_ELEMENT_ERROR (pvsink, RESOURCE, FAILED, + if (state == PINOS_STREAM_STATE_ERROR) { + GST_ELEMENT_ERROR (pinossink, RESOURCE, FAILED, ("Failed to connect stream: %s", - pv_stream_get_error (pvsink->stream)->message), (NULL)); + pinos_stream_get_error (pinossink->stream)->message), (NULL)); } } @@ -229,56 +229,56 @@ gst_pinos_sink_getcaps (GstBaseSink * bsink, GstCaps * filter) static gboolean gst_pinos_sink_setcaps (GstBaseSink * bsink, GstCaps * caps) { - GstPinosSink *pvsink; + GstPinosSink *pinossink; gchar *str; GBytes *format; - pvsink = GST_PINOS_SINK (bsink); + pinossink = GST_PINOS_SINK (bsink); str = gst_caps_to_string (caps); format = g_bytes_new_take (str, strlen (str) + 1); - g_mutex_lock (&pvsink->lock); - pvsink->stream = pv_stream_new (pvsink->ctx, "test", NULL); - g_signal_connect (pvsink->stream, "notify::state", (GCallback) on_stream_notify, pvsink); - g_signal_connect (pvsink->stream, "new-buffer", (GCallback) on_new_buffer, pvsink); + g_mutex_lock (&pinossink->lock); + pinossink->stream = pinos_stream_new (pinossink->ctx, "test", NULL); + g_signal_connect (pinossink->stream, "notify::state", (GCallback) on_stream_notify, pinossink); + g_signal_connect (pinossink->stream, "new-buffer", (GCallback) on_new_buffer, pinossink); - pv_stream_connect_provide (pvsink->stream, 0, format); + pinos_stream_connect_provide (pinossink->stream, 0, format); while (TRUE) { - PvStreamState state = pv_stream_get_state (pvsink->stream); + PinosStreamState state = pinos_stream_get_state (pinossink->stream); - if (state == PV_STREAM_STATE_READY) + if (state == PINOS_STREAM_STATE_READY) break; - if (state == PV_STREAM_STATE_ERROR) + if (state == PINOS_STREAM_STATE_ERROR) goto connect_error; - g_cond_wait (&pvsink->cond, &pvsink->lock); + g_cond_wait (&pinossink->cond, &pinossink->lock); } - pv_stream_start (pvsink->stream, format, PV_STREAM_MODE_BUFFER); + pinos_stream_start (pinossink->stream, format, PINOS_STREAM_MODE_BUFFER); while (TRUE) { - PvStreamState state = pv_stream_get_state (pvsink->stream); + PinosStreamState state = pinos_stream_get_state (pinossink->stream); - if (state == PV_STREAM_STATE_STREAMING) + if (state == PINOS_STREAM_STATE_STREAMING) break; - if (state == PV_STREAM_STATE_ERROR) + if (state == PINOS_STREAM_STATE_ERROR) goto connect_error; - g_cond_wait (&pvsink->cond, &pvsink->lock); + g_cond_wait (&pinossink->cond, &pinossink->lock); } - g_mutex_unlock (&pvsink->lock); + g_mutex_unlock (&pinossink->lock); - pvsink->negotiated = TRUE; + pinossink->negotiated = TRUE; return TRUE; connect_error: { - g_mutex_unlock (&pvsink->lock); + g_mutex_unlock (&pinossink->lock); return FALSE; } } @@ -286,14 +286,14 @@ connect_error: static GstFlowReturn gst_pinos_sink_render (GstBaseSink * bsink, GstBuffer * buffer) { - GstPinosSink *pvsink; - PvBufferInfo info; + GstPinosSink *pinossink; + PinosBufferInfo info; GSocketControlMessage *mesg; GstMemory *mem = NULL; - pvsink = GST_PINOS_SINK (bsink); + pinossink = GST_PINOS_SINK (bsink); - if (!pvsink->negotiated) + if (!pinossink->negotiated) goto not_negotiated; info.flags = 0; @@ -313,7 +313,7 @@ gst_pinos_sink_render (GstBaseSink * bsink, GstBuffer * buffer) GST_INFO_OBJECT (bsink, "Buffer cannot be payloaded without copying"); - mem = gst_allocator_alloc (pvsink->allocator, info.size, ¶ms); + mem = gst_allocator_alloc (pinossink->allocator, info.size, ¶ms); if (!gst_memory_map (mem, &minfo, GST_MAP_WRITE)) goto map_error; gst_buffer_extract (buffer, 0, minfo.data, info.size); @@ -323,11 +323,11 @@ gst_pinos_sink_render (GstBaseSink * bsink, GstBuffer * buffer) gst_memory_unref (mem); info.message = mesg; - g_mutex_lock (&pvsink->lock); - if (pv_stream_get_state (pvsink->stream) != PV_STREAM_STATE_STREAMING) + g_mutex_lock (&pinossink->lock); + if (pinos_stream_get_state (pinossink->stream) != PINOS_STREAM_STATE_STREAMING) goto streaming_error; - pv_stream_provide_buffer (pvsink->stream, &info); - g_mutex_unlock (&pvsink->lock); + pinos_stream_provide_buffer (pinossink->stream, &info); + g_mutex_unlock (&pinossink->lock); return GST_FLOW_OK; @@ -341,7 +341,7 @@ map_error: } streaming_error: { - g_mutex_unlock (&pvsink->lock); + g_mutex_unlock (&pinossink->lock); return GST_FLOW_ERROR; } } @@ -403,76 +403,76 @@ on_state_notify (GObject *gobject, GParamSpec *pspec, gpointer user_data) { - GstPinosSink *pvsink = user_data; - PvContextState state; + GstPinosSink *pinossink = user_data; + PinosContextState state; - state = pv_context_get_state (pvsink->ctx); + state = pinos_context_get_state (pinossink->ctx); g_print ("got context state %d\n", state); - g_cond_broadcast (&pvsink->cond); + g_cond_broadcast (&pinossink->cond); - if (state == PV_CONTEXT_STATE_ERROR) { - GST_ELEMENT_ERROR (pvsink, RESOURCE, FAILED, + if (state == PINOS_CONTEXT_STATE_ERROR) { + GST_ELEMENT_ERROR (pinossink, RESOURCE, FAILED, ("Failed to connect stream: %s", - pv_context_get_error (pvsink->ctx)->message), (NULL)); + pinos_context_get_error (pinossink->ctx)->message), (NULL)); } } static gboolean -gst_pinos_sink_open (GstPinosSink * pvsink) +gst_pinos_sink_open (GstPinosSink * pinossink) { - g_mutex_lock (&pvsink->lock); - pvsink->ctx = pv_context_new (pvsink->context, "test-client", NULL); - g_signal_connect (pvsink->ctx, "notify::state", (GCallback) on_state_notify, pvsink); + g_mutex_lock (&pinossink->lock); + pinossink->ctx = pinos_context_new (pinossink->context, "test-client", NULL); + g_signal_connect (pinossink->ctx, "notify::state", (GCallback) on_state_notify, pinossink); - pv_context_connect(pvsink->ctx, PV_CONTEXT_FLAGS_NONE); + pinos_context_connect(pinossink->ctx, PINOS_CONTEXT_FLAGS_NONE); while (TRUE) { - PvContextState state = pv_context_get_state (pvsink->ctx); + PinosContextState state = pinos_context_get_state (pinossink->ctx); - if (state == PV_CONTEXT_STATE_READY) + if (state == PINOS_CONTEXT_STATE_READY) break; - if (state == PV_CONTEXT_STATE_ERROR) + if (state == PINOS_CONTEXT_STATE_ERROR) goto connect_error; - g_cond_wait (&pvsink->cond, &pvsink->lock); + g_cond_wait (&pinossink->cond, &pinossink->lock); } - g_mutex_unlock (&pvsink->lock); + g_mutex_unlock (&pinossink->lock); return TRUE; /* ERRORS */ connect_error: { - g_mutex_unlock (&pvsink->lock); + g_mutex_unlock (&pinossink->lock); return FALSE; } } static gboolean -gst_pinos_sink_close (GstPinosSink * pvsink) +gst_pinos_sink_close (GstPinosSink * pinossink) { - g_mutex_lock (&pvsink->lock); - if (pvsink->stream) { - pv_stream_disconnect (pvsink->stream); + g_mutex_lock (&pinossink->lock); + if (pinossink->stream) { + pinos_stream_disconnect (pinossink->stream); } - if (pvsink->ctx) { - pv_context_disconnect(pvsink->ctx); + if (pinossink->ctx) { + pinos_context_disconnect(pinossink->ctx); while (TRUE) { - PvContextState state = pv_context_get_state (pvsink->ctx); + PinosContextState state = pinos_context_get_state (pinossink->ctx); - if (state == PV_CONTEXT_STATE_UNCONNECTED) + if (state == PINOS_CONTEXT_STATE_UNCONNECTED) break; - if (state == PV_CONTEXT_STATE_ERROR) + if (state == PINOS_CONTEXT_STATE_ERROR) break; - g_cond_wait (&pvsink->cond, &pvsink->lock); + g_cond_wait (&pinossink->cond, &pinossink->lock); } } - g_mutex_unlock (&pvsink->lock); + g_mutex_unlock (&pinossink->lock); return TRUE; } diff --git a/src/gst/gstpvsink.h b/src/gst/gstpinossink.h index 24c74bd3..ac6998ab 100644 --- a/src/gst/gstpvsink.h +++ b/src/gst/gstpinossink.h @@ -23,9 +23,9 @@ #include <gst/gst.h> #include <gst/base/gstbasesink.h> -#include <client/pv-context.h> -#include <client/pv-stream.h> -#include <client/pv-introspect.h> +#include <client/context.h> +#include <client/stream.h> +#include <client/introspect.h> G_BEGIN_DECLS @@ -61,8 +61,8 @@ struct _GstPinosSink { GMainContext *context; GMainLoop *loop; GThread *thread; - PvContext *ctx; - PvStream *stream; + PinosContext *ctx; + PinosStream *stream; GstAllocator *allocator; GPollFunc poll_func; diff --git a/src/gst/gstpvsrc.c b/src/gst/gstpinossrc.c index c81c3f57..a951ce9c 100644 --- a/src/gst/gstpvsrc.c +++ b/src/gst/gstpinossrc.c @@ -31,7 +31,7 @@ #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include "gstpvsrc.h" +#include "gstpinossrc.h" #include <string.h> #include <stdlib.h> @@ -54,7 +54,7 @@ enum }; -#define PVS_VIDEO_CAPS GST_VIDEO_CAPS_MAKE (GST_VIDEO_FORMATS_ALL) +#define PINOSS_VIDEO_CAPS GST_VIDEO_CAPS_MAKE (GST_VIDEO_FORMATS_ALL) static GstStaticPadTemplate gst_pinos_src_template = GST_STATIC_PAD_TEMPLATE ("src", @@ -84,12 +84,12 @@ static void gst_pinos_src_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec) { - GstPinosSrc *pvsrc = GST_PINOS_SRC (object); + GstPinosSrc *pinossrc = GST_PINOS_SRC (object); switch (prop_id) { case PROP_SOURCE: - g_free (pvsrc->source); - pvsrc->source = g_value_dup_string (value); + g_free (pinossrc->source); + pinossrc->source = g_value_dup_string (value); break; default: @@ -102,11 +102,11 @@ static void gst_pinos_src_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec) { - GstPinosSrc *pvsrc = GST_PINOS_SRC (object); + GstPinosSrc *pinossrc = GST_PINOS_SRC (object); switch (prop_id) { case PROP_SOURCE: - g_value_set_string (value, pvsrc->source); + g_value_set_string (value, pinossrc->source); break; default: @@ -118,12 +118,12 @@ gst_pinos_src_get_property (GObject * object, guint prop_id, static void gst_pinos_src_finalize (GObject * object) { - GstPinosSrc *pvsrc = GST_PINOS_SRC (object); + GstPinosSrc *pinossrc = GST_PINOS_SRC (object); - g_object_unref (pvsrc->fd_allocator); - g_mutex_clear (&pvsrc->lock); - g_cond_clear (&pvsrc->cond); - g_free (pvsrc->source); + g_object_unref (pinossrc->fd_allocator); + g_mutex_clear (&pinossrc->lock); + g_cond_clear (&pinossrc->cond); + g_free (pinossrc->source); G_OBJECT_CLASS (parent_class)->finalize (object); } @@ -237,9 +237,9 @@ static void on_new_buffer (GObject *gobject, gpointer user_data) { - GstPinosSrc *pvsrc = user_data; + GstPinosSrc *pinossrc = user_data; - g_cond_signal (&pvsrc->cond); + g_cond_signal (&pinossrc->cond); } static void @@ -247,24 +247,24 @@ on_stream_notify (GObject *gobject, GParamSpec *pspec, gpointer user_data) { - PvStreamState state; - GstPinosSrc *pvsrc = user_data; + PinosStreamState state; + GstPinosSrc *pinossrc = user_data; - state = pv_stream_get_state (pvsrc->stream); + state = pinos_stream_get_state (pinossrc->stream); g_print ("got stream state %d\n", state); - g_cond_broadcast (&pvsrc->cond); + g_cond_broadcast (&pinossrc->cond); - if (state == PV_STREAM_STATE_ERROR) { - GST_ELEMENT_ERROR (pvsrc, RESOURCE, FAILED, + if (state == PINOS_STREAM_STATE_ERROR) { + GST_ELEMENT_ERROR (pinossrc, RESOURCE, FAILED, ("Failed to connect stream: %s", - pv_stream_get_error (pvsrc->stream)->message), (NULL)); + pinos_stream_get_error (pinossrc->stream)->message), (NULL)); } } static gboolean gst_pinos_src_negotiate (GstBaseSrc * basesrc) { - GstPinosSrc *pvsrc = GST_PINOS_SRC (basesrc); + GstPinosSrc *pinossrc = GST_PINOS_SRC (basesrc); GstCaps *thiscaps; GstCaps *caps = NULL; GstCaps *peercaps = NULL; @@ -300,23 +300,23 @@ gst_pinos_src_negotiate (GstBaseSrc * basesrc) str = gst_caps_to_string (caps); accepted = g_bytes_new_take (str, strlen (str) + 1); - g_mutex_lock (&pvsrc->lock); - pv_stream_connect_capture (pvsrc->stream, pvsrc->source, 0, accepted); + g_mutex_lock (&pinossrc->lock); + pinos_stream_connect_capture (pinossrc->stream, pinossrc->source, 0, accepted); while (TRUE) { - PvStreamState state = pv_stream_get_state (pvsrc->stream); + PinosStreamState state = pinos_stream_get_state (pinossrc->stream); - if (state == PV_STREAM_STATE_READY) + if (state == PINOS_STREAM_STATE_READY) break; - if (state == PV_STREAM_STATE_ERROR) + if (state == PINOS_STREAM_STATE_ERROR) goto connect_error; - g_cond_wait (&pvsrc->cond, &pvsrc->lock); + g_cond_wait (&pinossrc->cond, &pinossrc->lock); } - g_mutex_unlock (&pvsrc->lock); + g_mutex_unlock (&pinossrc->lock); - g_object_get (pvsrc->stream, "possible-formats", &possible, NULL); + g_object_get (pinossrc->stream, "possible-formats", &possible, NULL); if (possible) { GstCaps *newcaps; @@ -346,7 +346,7 @@ gst_pinos_src_negotiate (GstBaseSrc * basesrc) gst_caps_unref (caps); GST_DEBUG_OBJECT (basesrc, "no common caps"); } - pvsrc->negotiated = result; + pinossrc->negotiated = result; return result; no_nego_needed: @@ -367,7 +367,7 @@ no_caps: } connect_error: { - g_mutex_unlock (&pvsrc->lock); + g_mutex_unlock (&pinossrc->lock); return FALSE; } } @@ -381,19 +381,19 @@ gst_pinos_src_getcaps (GstBaseSrc * bsrc, GstCaps * filter) static gboolean gst_pinos_src_setcaps (GstBaseSrc * bsrc, GstCaps * caps) { - GstPinosSrc *pvsrc; + GstPinosSrc *pinossrc; gchar *str; GBytes *format; gboolean res; - pvsrc = GST_PINOS_SRC (bsrc); + pinossrc = GST_PINOS_SRC (bsrc); str = gst_caps_to_string (caps); format = g_bytes_new_take (str, strlen (str) + 1); - g_mutex_lock (&pvsrc->lock); - res = pv_stream_start (pvsrc->stream, format, PV_STREAM_MODE_BUFFER); - g_mutex_unlock (&pvsrc->lock); + g_mutex_lock (&pinossrc->lock); + res = pinos_stream_start (pinossrc->stream, format, PINOS_STREAM_MODE_BUFFER); + g_mutex_unlock (&pinossrc->lock); return res; } @@ -401,35 +401,35 @@ gst_pinos_src_setcaps (GstBaseSrc * bsrc, GstCaps * caps) static GstFlowReturn gst_pinos_src_create (GstPushSrc * psrc, GstBuffer ** buffer) { - GstPinosSrc *pvsrc; - PvBufferInfo info; + GstPinosSrc *pinossrc; + PinosBufferInfo info; gint *fds, n_fds; GstMemory *fdmem = NULL; - pvsrc = GST_PINOS_SRC (psrc); + pinossrc = GST_PINOS_SRC (psrc); - if (!pvsrc->negotiated) + if (!pinossrc->negotiated) goto not_negotiated; again: - g_mutex_lock (&pvsrc->lock); + g_mutex_lock (&pinossrc->lock); while (TRUE) { - PvStreamState state; + PinosStreamState state; - g_cond_wait (&pvsrc->cond, &pvsrc->lock); + g_cond_wait (&pinossrc->cond, &pinossrc->lock); - state = pv_stream_get_state (pvsrc->stream); - if (state == PV_STREAM_STATE_ERROR) + state = pinos_stream_get_state (pinossrc->stream); + if (state == PINOS_STREAM_STATE_ERROR) goto streaming_error; - if (state != PV_STREAM_STATE_STREAMING) + if (state != PINOS_STREAM_STATE_STREAMING) goto streaming_stopped; - pv_stream_capture_buffer (pvsrc->stream, &info); + pinos_stream_capture_buffer (pinossrc->stream, &info); if (info.message != NULL) break; } - g_mutex_unlock (&pvsrc->lock); + g_mutex_unlock (&pinossrc->lock); if (g_socket_control_message_get_msg_type (info.message) != SCM_RIGHTS) goto again; @@ -438,7 +438,7 @@ again: if (n_fds < 1 || fds[0] < 0) goto again; - fdmem = gst_fd_allocator_alloc (pvsrc->fd_allocator, fds[0], + fdmem = gst_fd_allocator_alloc (pinossrc->fd_allocator, fds[0], info.offset + info.size, GST_FD_MEMORY_FLAG_NONE); gst_memory_resize (fdmem, info.offset, info.size); @@ -453,12 +453,12 @@ not_negotiated: } streaming_error: { - g_mutex_unlock (&pvsrc->lock); + g_mutex_unlock (&pinossrc->lock); return GST_FLOW_ERROR; } streaming_stopped: { - g_mutex_unlock (&pvsrc->lock); + g_mutex_unlock (&pinossrc->lock); return GST_FLOW_FLUSHING; } } @@ -512,53 +512,53 @@ on_state_notify (GObject *gobject, GParamSpec *pspec, gpointer user_data) { - GstPinosSrc *pvsrc = user_data; - PvContextState state; + GstPinosSrc *pinossrc = user_data; + PinosContextState state; - state = pv_context_get_state (pvsrc->ctx); + state = pinos_context_get_state (pinossrc->ctx); g_print ("got context state %d\n", state); - g_cond_broadcast (&pvsrc->cond); + g_cond_broadcast (&pinossrc->cond); - if (state == PV_CONTEXT_STATE_ERROR) { - GST_ELEMENT_ERROR (pvsrc, RESOURCE, FAILED, + if (state == PINOS_CONTEXT_STATE_ERROR) { + GST_ELEMENT_ERROR (pinossrc, RESOURCE, FAILED, ("Failed to connect stream: %s", - pv_context_get_error (pvsrc->ctx)->message), (NULL)); + pinos_context_get_error (pinossrc->ctx)->message), (NULL)); } } static gboolean -gst_pinos_src_open (GstPinosSrc * pvsrc) +gst_pinos_src_open (GstPinosSrc * pinossrc) { - g_mutex_lock (&pvsrc->lock); - pvsrc->ctx = pv_context_new (pvsrc->context, "test-client", NULL); - g_signal_connect (pvsrc->ctx, "notify::state", (GCallback) on_state_notify, pvsrc); + g_mutex_lock (&pinossrc->lock); + pinossrc->ctx = pinos_context_new (pinossrc->context, "test-client", NULL); + g_signal_connect (pinossrc->ctx, "notify::state", (GCallback) on_state_notify, pinossrc); - pv_context_connect(pvsrc->ctx, PV_CONTEXT_FLAGS_NONE); + pinos_context_connect(pinossrc->ctx, PINOS_CONTEXT_FLAGS_NONE); while (TRUE) { - PvContextState state = pv_context_get_state (pvsrc->ctx); + PinosContextState state = pinos_context_get_state (pinossrc->ctx); - if (state == PV_CONTEXT_STATE_READY) + if (state == PINOS_CONTEXT_STATE_READY) break; - if (state == PV_CONTEXT_STATE_ERROR) + if (state == PINOS_CONTEXT_STATE_ERROR) goto connect_error; - g_cond_wait (&pvsrc->cond, &pvsrc->lock); + g_cond_wait (&pinossrc->cond, &pinossrc->lock); } - pvsrc->stream = pv_stream_new (pvsrc->ctx, "test", NULL); - g_signal_connect (pvsrc->stream, "notify::state", (GCallback) on_stream_notify, pvsrc); - g_signal_connect (pvsrc->stream, "new-buffer", (GCallback) on_new_buffer, pvsrc); - g_mutex_unlock (&pvsrc->lock); + pinossrc->stream = pinos_stream_new (pinossrc->ctx, "test", NULL); + g_signal_connect (pinossrc->stream, "notify::state", (GCallback) on_stream_notify, pinossrc); + g_signal_connect (pinossrc->stream, "new-buffer", (GCallback) on_new_buffer, pinossrc); + g_mutex_unlock (&pinossrc->lock); return TRUE; /* ERRORS */ connect_error: { - g_mutex_unlock (&pvsrc->lock); + g_mutex_unlock (&pinossrc->lock); return FALSE; } } diff --git a/src/gst/gstpvsrc.h b/src/gst/gstpinossrc.h index 4567d5b4..59b8673f 100644 --- a/src/gst/gstpvsrc.h +++ b/src/gst/gstpinossrc.h @@ -23,9 +23,9 @@ #include <gst/gst.h> #include <gst/base/gstpushsrc.h> -#include <client/pv-context.h> -#include <client/pv-stream.h> -#include <client/pv-introspect.h> +#include <client/context.h> +#include <client/stream.h> +#include <client/introspect.h> G_BEGIN_DECLS @@ -61,8 +61,8 @@ struct _GstPinosSrc { GMainContext *context; GMainLoop *loop; GThread *thread; - PvContext *ctx; - PvStream *stream; + PinosContext *ctx; + PinosStream *stream; GstAllocator *fd_allocator; GPollFunc poll_func; diff --git a/src/modules/gst/pv-gst-manager.c b/src/modules/gst/gst-manager.c index 699b71f8..6ed68d00 100644 --- a/src/modules/gst/pv-gst-manager.c +++ b/src/modules/gst/gst-manager.c @@ -21,15 +21,15 @@ #include <gst/gst.h> #include <gio/gio.h> -#include "pv-gst-manager.h" -#include "pv-gst-source.h" +#include "gst-manager.h" +#include "gst-source.h" -#define PV_GST_MANAGER_GET_PRIVATE(obj) \ - (G_TYPE_INSTANCE_GET_PRIVATE ((obj), PV_TYPE_GST_MANAGER, PvGstManagerPrivate)) +#define PINOS_GST_MANAGER_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE ((obj), PINOS_TYPE_GST_MANAGER, PinosGstManagerPrivate)) -struct _PvGstManagerPrivate +struct _PinosGstManagerPrivate { - PvDaemon *daemon; + PinosDaemon *daemon; GstDeviceMonitor *monitor; }; @@ -40,43 +40,47 @@ enum PROP_DAEMON }; -G_DEFINE_TYPE (PvGstManager, pv_gst_manager, G_TYPE_OBJECT); +G_DEFINE_TYPE (PinosGstManager, pinos_gst_manager, G_TYPE_OBJECT); static void -device_added (PvGstManager *manager, GstDevice *device) +device_added (PinosGstManager *manager, + GstDevice *device) { - PvGstManagerPrivate *priv = manager->priv; + PinosGstManagerPrivate *priv = manager->priv; gchar *name; GstElement *element; - PvSource *source; + PinosSource *source; name = gst_device_get_display_name (device); g_print("Device added: %s\n", name); element = gst_device_create_element (device, NULL); - source = pv_gst_source_new (priv->daemon, name, element); - g_object_set_data (G_OBJECT (device), "PvSource", source); + source = pinos_gst_source_new (priv->daemon, name, element); + g_object_set_data (G_OBJECT (device), "PinosSource", source); g_free (name); } static void -device_removed (PvGstManager *manager, GstDevice *device) +device_removed (PinosGstManager *manager, + GstDevice *device) { gchar *name; - PvSource *source; + PinosSource *source; name = gst_device_get_display_name (device); g_print("Device removed: %s\n", name); - source = g_object_steal_data (G_OBJECT (device), "PvSource"); + source = g_object_steal_data (G_OBJECT (device), "PinosSource"); g_object_unref (source); g_free (name); } static gboolean -bus_handler (GstBus * bus, GstMessage * message, gpointer user_data) +bus_handler (GstBus *bus, + GstMessage *message, + gpointer user_data) { - PvGstManager *manager = user_data; - PvGstManagerPrivate *priv = manager->priv; + PinosGstManager *manager = user_data; + PinosGstManagerPrivate *priv = manager->priv; GstDevice *device; switch (GST_MESSAGE_TYPE (message)) { @@ -95,9 +99,9 @@ bus_handler (GstBus * bus, GstMessage * message, gpointer user_data) } static void -start_monitor (PvGstManager *manager) +start_monitor (PinosGstManager *manager) { - PvGstManagerPrivate *priv = manager->priv; + PinosGstManagerPrivate *priv = manager->priv; GstBus *bus; GList *devices; @@ -122,9 +126,9 @@ start_monitor (PvGstManager *manager) } static void -stop_monitor (PvGstManager *manager) +stop_monitor (PinosGstManager *manager) { - PvGstManagerPrivate *priv = manager->priv; + PinosGstManagerPrivate *priv = manager->priv; if (priv->monitor) { gst_device_monitor_stop (priv->monitor); @@ -134,13 +138,13 @@ stop_monitor (PvGstManager *manager) } static void -pv_gst_manager_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) +pinos_gst_manager_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) { - PvGstManager *manager = PV_GST_MANAGER (object); - PvGstManagerPrivate *priv = manager->priv; + PinosGstManager *manager = PINOS_GST_MANAGER (object); + PinosGstManagerPrivate *priv = manager->priv; switch (prop_id) { case PROP_DAEMON: @@ -154,13 +158,13 @@ pv_gst_manager_get_property (GObject *object, } static void -pv_gst_manager_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) +pinos_gst_manager_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) { - PvGstManager *manager = PV_GST_MANAGER (object); - PvGstManagerPrivate *priv = manager->priv; + PinosGstManager *manager = PINOS_GST_MANAGER (object); + PinosGstManagerPrivate *priv = manager->priv; switch (prop_id) { case PROP_DAEMON: @@ -176,54 +180,54 @@ pv_gst_manager_set_property (GObject *object, static void gst_manager_constructed (GObject * object) { - PvGstManager *manager = PV_GST_MANAGER (object); + PinosGstManager *manager = PINOS_GST_MANAGER (object); start_monitor (manager); - G_OBJECT_CLASS (pv_gst_manager_parent_class)->constructed (object); + G_OBJECT_CLASS (pinos_gst_manager_parent_class)->constructed (object); } static void gst_manager_finalize (GObject * object) { - PvGstManager *manager = PV_GST_MANAGER (object); + PinosGstManager *manager = PINOS_GST_MANAGER (object); stop_monitor (manager); - G_OBJECT_CLASS (pv_gst_manager_parent_class)->finalize (object); + G_OBJECT_CLASS (pinos_gst_manager_parent_class)->finalize (object); } static void -pv_gst_manager_class_init (PvGstManagerClass * klass) +pinos_gst_manager_class_init (PinosGstManagerClass * klass) { GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - g_type_class_add_private (klass, sizeof (PvGstManagerPrivate)); + g_type_class_add_private (klass, sizeof (PinosGstManagerPrivate)); gobject_class->constructed = gst_manager_constructed; gobject_class->finalize = gst_manager_finalize; - gobject_class->set_property = pv_gst_manager_set_property; - gobject_class->get_property = pv_gst_manager_get_property; + gobject_class->set_property = pinos_gst_manager_set_property; + gobject_class->get_property = pinos_gst_manager_get_property; g_object_class_install_property (gobject_class, PROP_DAEMON, g_param_spec_object ("daemon", "Daemon", "The daemon", - PV_TYPE_DAEMON, + PINOS_TYPE_DAEMON, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS)); } static void -pv_gst_manager_init (PvGstManager * manager) +pinos_gst_manager_init (PinosGstManager * manager) { - manager->priv = PV_GST_MANAGER_GET_PRIVATE (manager); + manager->priv = PINOS_GST_MANAGER_GET_PRIVATE (manager); } -PvGstManager * -pv_gst_manager_new (PvDaemon *daemon) +PinosGstManager * +pinos_gst_manager_new (PinosDaemon *daemon) { - return g_object_new (PV_TYPE_GST_MANAGER, "daemon", daemon, NULL); + return g_object_new (PINOS_TYPE_GST_MANAGER, "daemon", daemon, NULL); } diff --git a/src/modules/gst/gst-manager.h b/src/modules/gst/gst-manager.h new file mode 100644 index 00000000..d970094d --- /dev/null +++ b/src/modules/gst/gst-manager.h @@ -0,0 +1,60 @@ +/* Pinos + * Copyright (C) 2015 Wim Taymans <wim.taymans@gmail.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef __PINOS_GST_MANAGER_H__ +#define __PINOS_GST_MANAGER_H__ + +#include <glib-object.h> + +#include <client/pinos.h> +#include <server/daemon.h> + +G_BEGIN_DECLS + +#define PINOS_TYPE_GST_MANAGER (pinos_gst_manager_get_type ()) +#define PINOS_IS_GST_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PINOS_TYPE_GST_MANAGER)) +#define PINOS_IS_GST_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PINOS_TYPE_GST_MANAGER)) +#define PINOS_GST_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PINOS_TYPE_GST_MANAGER, PinosGstManagerClass)) +#define PINOS_GST_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PINOS_TYPE_GST_MANAGER, PinosGstManager)) +#define PINOS_GST_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PINOS_TYPE_GST_MANAGER, PinosGstManagerClass)) +#define PINOS_GST_MANAGER_CAST(obj) ((PinosGstManager*)(obj)) +#define PINOS_GST_MANAGER_CLASS_CAST(klass) ((PinosGstManagerClass*)(klass)) + +typedef struct _PinosGstManager PinosGstManager; +typedef struct _PinosGstManagerClass PinosGstManagerClass; +typedef struct _PinosGstManagerPrivate PinosGstManagerPrivate; + +struct _PinosGstManager { + GObject object; + + PinosGstManagerPrivate *priv; +}; + +struct _PinosGstManagerClass { + GObjectClass parent_class; +}; + +GType pinos_gst_manager_get_type (void); + +PinosGstManager * pinos_gst_manager_new (PinosDaemon *daemon); + +G_END_DECLS + +#endif /* __PINOS_GST_MANAGER_H__ */ + diff --git a/src/modules/gst/pv-gst-source.c b/src/modules/gst/gst-source.c index 6fd7bc83..ac0a6b66 100644 --- a/src/modules/gst/pv-gst-source.c +++ b/src/modules/gst/gst-source.c @@ -21,12 +21,12 @@ #include <gst/gst.h> #include <gio/gio.h> -#include "pv-gst-source.h" +#include "gst-source.h" -#define PV_GST_SOURCE_GET_PRIVATE(obj) \ - (G_TYPE_INSTANCE_GET_PRIVATE ((obj), PV_TYPE_GST_SOURCE, PvGstSourcePrivate)) +#define PINOS_GST_SOURCE_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE ((obj), PINOS_TYPE_GST_SOURCE, PinosGstSourcePrivate)) -struct _PvGstSourcePrivate +struct _PinosGstSourcePrivate { GstElement *pipeline; GstElement *element; @@ -41,13 +41,15 @@ enum { PROP_ELEMENT, }; -G_DEFINE_TYPE (PvGstSource, pv_gst_source, PV_TYPE_SOURCE); +G_DEFINE_TYPE (PinosGstSource, pinos_gst_source, PINOS_TYPE_SOURCE); static gboolean -bus_handler (GstBus * bus, GstMessage * message, gpointer user_data) +bus_handler (GstBus *bus, + GstMessage *message, + gpointer user_data) { - PvSource *source = user_data; - PvGstSourcePrivate *priv = PV_GST_SOURCE (source)->priv; + PinosSource *source = user_data; + PinosGstSourcePrivate *priv = PINOS_GST_SOURCE (source)->priv; switch (GST_MESSAGE_TYPE (message)) { case GST_MESSAGE_ERROR: @@ -59,7 +61,7 @@ bus_handler (GstBus * bus, GstMessage * message, gpointer user_data) g_warning ("got error %s (%s)\n", error->message, debug); g_free (debug); - pv_source_report_error (source, error); + pinos_source_report_error (source, error); gst_element_set_state (priv->pipeline, GST_STATE_NULL); break; } @@ -70,9 +72,9 @@ bus_handler (GstBus * bus, GstMessage * message, gpointer user_data) } static void -setup_pipeline (PvGstSource *source) +setup_pipeline (PinosGstSource *source) { - PvGstSourcePrivate *priv = source->priv; + PinosGstSourcePrivate *priv = source->priv; GstBus *bus; GstElement *elem; @@ -84,7 +86,7 @@ setup_pipeline (PvGstSource *source) gst_bin_add (GST_BIN (priv->pipeline), priv->filter); gst_element_link (priv->element, priv->filter); - elem = gst_element_factory_make ("pvfdpay", NULL); + elem = gst_element_factory_make ("pinosfdpay", NULL); gst_bin_add (GST_BIN (priv->pipeline), elem); gst_element_link (priv->filter, elem); @@ -107,9 +109,9 @@ setup_pipeline (PvGstSource *source) } static void -destroy_pipeline (PvGstSource *source) +destroy_pipeline (PinosGstSource *source) { - PvGstSourcePrivate *priv = source->priv; + PinosGstSourcePrivate *priv = source->priv; if (priv->pipeline) { gst_element_set_state (priv->pipeline, GST_STATE_NULL); @@ -119,9 +121,10 @@ destroy_pipeline (PvGstSource *source) } static GstCaps * -collect_caps (PvSource * source, GstCaps *filter) +collect_caps (PinosSource *source, + GstCaps *filter) { - PvGstSourcePrivate *priv = PV_GST_SOURCE (source)->priv; + PinosGstSourcePrivate *priv = PINOS_GST_SOURCE (source)->priv; GstCaps *res; GstQuery *query; @@ -135,36 +138,38 @@ collect_caps (PvSource * source, GstCaps *filter) } static gboolean -set_state (PvSource *source, PvSourceState state) +set_state (PinosSource *source, + PinosSourceState state) { - PvGstSourcePrivate *priv = PV_GST_SOURCE (source)->priv; + PinosGstSourcePrivate *priv = PINOS_GST_SOURCE (source)->priv; switch (state) { - case PV_SOURCE_STATE_SUSPENDED: + case PINOS_SOURCE_STATE_SUSPENDED: gst_element_set_state (priv->pipeline, GST_STATE_NULL); break; - case PV_SOURCE_STATE_INIT: + case PINOS_SOURCE_STATE_INIT: gst_element_set_state (priv->pipeline, GST_STATE_READY); break; - case PV_SOURCE_STATE_IDLE: + case PINOS_SOURCE_STATE_IDLE: gst_element_set_state (priv->pipeline, GST_STATE_PAUSED); break; - case PV_SOURCE_STATE_RUNNING: + case PINOS_SOURCE_STATE_RUNNING: gst_element_set_state (priv->pipeline, GST_STATE_PLAYING); break; - case PV_SOURCE_STATE_ERROR: + case PINOS_SOURCE_STATE_ERROR: break; } - pv_source_update_state (source, state); + pinos_source_update_state (source, state); return TRUE; } static GBytes * -get_formats (PvSource *source, GBytes *filter) +get_formats (PinosSource *source, + GBytes *filter) { GstCaps *caps, *cfilter; gchar *str; @@ -187,8 +192,8 @@ on_socket_notify (GObject *gobject, GParamSpec *pspec, gpointer user_data) { - PvGstSource *source = user_data; - PvGstSourcePrivate *priv = source->priv; + PinosGstSource *source = user_data; + PinosGstSourcePrivate *priv = source->priv; GSocket *socket; guint num_handles; GstCaps *caps; @@ -243,14 +248,14 @@ on_socket_notify (GObject *gobject, } } -static PvSourceOutput * -create_source_output (PvSource *source, +static PinosSourceOutput * +create_source_output (PinosSource *source, const gchar *client_path, GBytes *format_filter, const gchar *prefix, GError **error) { - PvSourceOutput *output; + PinosSourceOutput *output; GstCaps *caps, *filtered; gchar *str; @@ -266,7 +271,7 @@ create_source_output (PvSource *source, str = gst_caps_to_string (filtered); format_filter = g_bytes_new_take (str, strlen (str) + 1); - output = PV_SOURCE_CLASS (pv_gst_source_parent_class) + output = PINOS_SOURCE_CLASS (pinos_gst_source_parent_class) ->create_source_output (source, client_path, format_filter, @@ -299,9 +304,10 @@ no_format: } static gboolean -release_source_output (PvSource *source, PvSourceOutput *output) +release_source_output (PinosSource *source, + PinosSourceOutput *output) { - return PV_SOURCE_CLASS (pv_gst_source_parent_class)->release_source_output (source, output); + return PINOS_SOURCE_CLASS (pinos_gst_source_parent_class)->release_source_output (source, output); } static void @@ -310,8 +316,8 @@ get_property (GObject *object, GValue *value, GParamSpec *pspec) { - PvGstSource *source = PV_GST_SOURCE (object); - PvGstSourcePrivate *priv = source->priv; + PinosGstSource *source = PINOS_GST_SOURCE (object); + PinosGstSourcePrivate *priv = source->priv; switch (prop_id) { case PROP_ELEMENT: @@ -330,8 +336,8 @@ set_property (GObject *object, const GValue *value, GParamSpec *pspec) { - PvGstSource *source = PV_GST_SOURCE (object); - PvGstSourcePrivate *priv = source->priv; + PinosGstSource *source = PINOS_GST_SOURCE (object); + PinosGstSourcePrivate *priv = source->priv; switch (prop_id) { case PROP_ELEMENT: @@ -347,30 +353,30 @@ set_property (GObject *object, static void source_constructed (GObject * object) { - PvGstSource *source = PV_GST_SOURCE (object); + PinosGstSource *source = PINOS_GST_SOURCE (object); setup_pipeline (source); - G_OBJECT_CLASS (pv_gst_source_parent_class)->constructed (object); + G_OBJECT_CLASS (pinos_gst_source_parent_class)->constructed (object); } static void source_finalize (GObject * object) { - PvGstSource *source = PV_GST_SOURCE (object); + PinosGstSource *source = PINOS_GST_SOURCE (object); destroy_pipeline (source); - G_OBJECT_CLASS (pv_gst_source_parent_class)->finalize (object); + G_OBJECT_CLASS (pinos_gst_source_parent_class)->finalize (object); } static void -pv_gst_source_class_init (PvGstSourceClass * klass) +pinos_gst_source_class_init (PinosGstSourceClass * klass) { GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - PvSourceClass *source_class = PV_SOURCE_CLASS (klass); + PinosSourceClass *source_class = PINOS_SOURCE_CLASS (klass); - g_type_class_add_private (klass, sizeof (PvGstSourcePrivate)); + g_type_class_add_private (klass, sizeof (PinosGstSourcePrivate)); gobject_class->constructed = source_constructed; gobject_class->finalize = source_finalize; @@ -395,13 +401,18 @@ pv_gst_source_class_init (PvGstSourceClass * klass) } static void -pv_gst_source_init (PvGstSource * source) +pinos_gst_source_init (PinosGstSource * source) { - source->priv = PV_GST_SOURCE_GET_PRIVATE (source); + source->priv = PINOS_GST_SOURCE_GET_PRIVATE (source); } -PvSource * -pv_gst_source_new (PvDaemon *daemon, const gchar *name, GstElement *element) +PinosSource * +pinos_gst_source_new (PinosDaemon *daemon, + const gchar *name, + GstElement *element) { - return g_object_new (PV_TYPE_GST_SOURCE, "daemon", daemon, "name", name, "element", element, NULL); + return g_object_new (PINOS_TYPE_GST_SOURCE, + "daemon", daemon, + "name", name, + "element", element, NULL); } diff --git a/src/modules/gst/gst-source.h b/src/modules/gst/gst-source.h new file mode 100644 index 00000000..4cc678ab --- /dev/null +++ b/src/modules/gst/gst-source.h @@ -0,0 +1,63 @@ +/* Pinos + * Copyright (C) 2015 Wim Taymans <wim.taymans@gmail.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef __PINOS_GST_SOURCE_H__ +#define __PINOS_GST_SOURCE_H__ + +#include <glib-object.h> + +#include <client/pinos.h> +#include <server/daemon.h> +#include <server/source.h> + +G_BEGIN_DECLS + +#define PINOS_TYPE_GST_SOURCE (pinos_gst_source_get_type ()) +#define PINOS_IS_GST_SOURCE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PINOS_TYPE_GST_SOURCE)) +#define PINOS_IS_GST_SOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PINOS_TYPE_GST_SOURCE)) +#define PINOS_GST_SOURCE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PINOS_TYPE_GST_SOURCE, PinosGstSourceClass)) +#define PINOS_GST_SOURCE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PINOS_TYPE_GST_SOURCE, PinosGstSource)) +#define PINOS_GST_SOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PINOS_TYPE_GST_SOURCE, PinosGstSourceClass)) +#define PINOS_GST_SOURCE_CAST(obj) ((PinosGstSource*)(obj)) +#define PINOS_GST_SOURCE_CLASS_CAST(klass) ((PinosGstSourceClass*)(klass)) + +typedef struct _PinosGstSource PinosGstSource; +typedef struct _PinosGstSourceClass PinosGstSourceClass; +typedef struct _PinosGstSourcePrivate PinosGstSourcePrivate; + +struct _PinosGstSource { + PinosSource object; + + PinosGstSourcePrivate *priv; +}; + +struct _PinosGstSourceClass { + PinosSourceClass parent_class; +}; + +GType pinos_gst_source_get_type (void); + +PinosSource * pinos_gst_source_new (PinosDaemon *daemon, + const gchar *name, + GstElement *element); + +G_END_DECLS + +#endif /* __PINOS_GST_SOURCE_H__ */ + diff --git a/src/modules/gst/pv-gst-manager.h b/src/modules/gst/pv-gst-manager.h deleted file mode 100644 index 17b9df4e..00000000 --- a/src/modules/gst/pv-gst-manager.h +++ /dev/null @@ -1,60 +0,0 @@ -/* Pinos - * Copyright (C) 2015 Wim Taymans <wim.taymans@gmail.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef __PV_GST_MANAGER_H__ -#define __PV_GST_MANAGER_H__ - -#include <glib-object.h> - -#include <client/pinos.h> -#include <server/pv-daemon.h> - -G_BEGIN_DECLS - -#define PV_TYPE_GST_MANAGER (pv_gst_manager_get_type ()) -#define PV_IS_GST_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PV_TYPE_GST_MANAGER)) -#define PV_IS_GST_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PV_TYPE_GST_MANAGER)) -#define PV_GST_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PV_TYPE_GST_MANAGER, PvGstManagerClass)) -#define PV_GST_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PV_TYPE_GST_MANAGER, PvGstManager)) -#define PV_GST_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PV_TYPE_GST_MANAGER, PvGstManagerClass)) -#define PV_GST_MANAGER_CAST(obj) ((PvGstManager*)(obj)) -#define PV_GST_MANAGER_CLASS_CAST(klass) ((PvGstManagerClass*)(klass)) - -typedef struct _PvGstManager PvGstManager; -typedef struct _PvGstManagerClass PvGstManagerClass; -typedef struct _PvGstManagerPrivate PvGstManagerPrivate; - -struct _PvGstManager { - GObject object; - - PvGstManagerPrivate *priv; -}; - -struct _PvGstManagerClass { - GObjectClass parent_class; -}; - -GType pv_gst_manager_get_type (void); - -PvGstManager * pv_gst_manager_new (PvDaemon *daemon); - -G_END_DECLS - -#endif /* __PV_GST_MANAGER_H__ */ - diff --git a/src/modules/gst/pv-gst-source.h b/src/modules/gst/pv-gst-source.h deleted file mode 100644 index c7c1ebfa..00000000 --- a/src/modules/gst/pv-gst-source.h +++ /dev/null @@ -1,61 +0,0 @@ -/* Pinos - * Copyright (C) 2015 Wim Taymans <wim.taymans@gmail.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef __PV_GST_SOURCE_H__ -#define __PV_GST_SOURCE_H__ - -#include <glib-object.h> - -#include <client/pinos.h> -#include <server/pv-daemon.h> -#include <server/pv-source.h> - -G_BEGIN_DECLS - -#define PV_TYPE_GST_SOURCE (pv_gst_source_get_type ()) -#define PV_IS_GST_SOURCE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PV_TYPE_GST_SOURCE)) -#define PV_IS_GST_SOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PV_TYPE_GST_SOURCE)) -#define PV_GST_SOURCE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PV_TYPE_GST_SOURCE, PvGstSourceClass)) -#define PV_GST_SOURCE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PV_TYPE_GST_SOURCE, PvGstSource)) -#define PV_GST_SOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PV_TYPE_GST_SOURCE, PvGstSourceClass)) -#define PV_GST_SOURCE_CAST(obj) ((PvGstSource*)(obj)) -#define PV_GST_SOURCE_CLASS_CAST(klass) ((PvGstSourceClass*)(klass)) - -typedef struct _PvGstSource PvGstSource; -typedef struct _PvGstSourceClass PvGstSourceClass; -typedef struct _PvGstSourcePrivate PvGstSourcePrivate; - -struct _PvGstSource { - PvSource object; - - PvGstSourcePrivate *priv; -}; - -struct _PvGstSourceClass { - PvSourceClass parent_class; -}; - -GType pv_gst_source_get_type (void); - -PvSource * pv_gst_source_new (PvDaemon *daemon, const gchar *name, GstElement *element); - -G_END_DECLS - -#endif /* __PV_GST_SOURCE_H__ */ - diff --git a/src/server/pv-client-source.c b/src/server/client-source.c index f17cda64..32e9405f 100644 --- a/src/server/pv-client-source.c +++ b/src/server/client-source.c @@ -21,13 +21,13 @@ #include <gst/gst.h> #include <gio/gio.h> -#include <server/pv-daemon.h> -#include "pv-client-source.h" +#include <server/daemon.h> +#include <server/client-source.h> -#define PV_CLIENT_SOURCE_GET_PRIVATE(obj) \ - (G_TYPE_INSTANCE_GET_PRIVATE ((obj), PV_TYPE_CLIENT_SOURCE, PvClientSourcePrivate)) +#define PINOS_CLIENT_SOURCE_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE ((obj), PINOS_TYPE_CLIENT_SOURCE, PinosClientSourcePrivate)) -struct _PvClientSourcePrivate +struct _PinosClientSourcePrivate { GstElement *pipeline; GstElement *src; @@ -37,16 +37,18 @@ struct _PvClientSourcePrivate GSocket *socket; - PvSourceOutput *input; + PinosSourceOutput *input; }; -G_DEFINE_TYPE (PvClientSource, pv_client_source, PV_TYPE_SOURCE); +G_DEFINE_TYPE (PinosClientSource, pinos_client_source, PINOS_TYPE_SOURCE); static gboolean -bus_handler (GstBus * bus, GstMessage * message, gpointer user_data) +bus_handler (GstBus *bus, + GstMessage *message, + gpointer user_data) { - PvSource *source = user_data; - PvClientSourcePrivate *priv = PV_CLIENT_SOURCE (source)->priv; + PinosSource *source = user_data; + PinosClientSourcePrivate *priv = PINOS_CLIENT_SOURCE (source)->priv; switch (GST_MESSAGE_TYPE (message)) { case GST_MESSAGE_ERROR: @@ -58,7 +60,7 @@ bus_handler (GstBus * bus, GstMessage * message, gpointer user_data) g_print ("got error %s (%s)\n", error->message, debug); g_free (debug); - pv_source_report_error (source, error); + pinos_source_report_error (source, error); gst_element_set_state (priv->pipeline, GST_STATE_NULL); break; } @@ -69,9 +71,9 @@ bus_handler (GstBus * bus, GstMessage * message, gpointer user_data) } static void -setup_pipeline (PvClientSource *source) +setup_pipeline (PinosClientSource *source) { - PvClientSourcePrivate *priv = source->priv; + PinosClientSourcePrivate *priv = source->priv; GstBus *bus; priv->pipeline = gst_parse_launch ("socketsrc name=src ! " @@ -95,9 +97,10 @@ setup_pipeline (PvClientSource *source) } static GstCaps * -collect_caps (PvSource * source, GstCaps *filter) +collect_caps (PinosSource *source, + GstCaps *filter) { - PvClientSourcePrivate *priv = PV_CLIENT_SOURCE (source)->priv; + PinosClientSourcePrivate *priv = PINOS_CLIENT_SOURCE (source)->priv; GstCaps *res; GstQuery *query; @@ -111,36 +114,39 @@ collect_caps (PvSource * source, GstCaps *filter) } static gboolean -client_set_state (PvSource *source, PvSourceState state) +client_set_state (PinosSource *source, + PinosSourceState state) { - PvClientSourcePrivate *priv = PV_CLIENT_SOURCE (source)->priv; + PinosClientSourcePrivate *priv = PINOS_CLIENT_SOURCE (source)->priv; switch (state) { - case PV_SOURCE_STATE_SUSPENDED: + case PINOS_SOURCE_STATE_SUSPENDED: gst_element_set_state (priv->pipeline, GST_STATE_NULL); break; - case PV_SOURCE_STATE_INIT: + case PINOS_SOURCE_STATE_INIT: gst_element_set_state (priv->pipeline, GST_STATE_READY); break; - case PV_SOURCE_STATE_IDLE: + case PINOS_SOURCE_STATE_IDLE: gst_element_set_state (priv->pipeline, GST_STATE_PAUSED); break; - case PV_SOURCE_STATE_RUNNING: + case PINOS_SOURCE_STATE_RUNNING: gst_element_set_state (priv->pipeline, GST_STATE_PLAYING); break; - case PV_SOURCE_STATE_ERROR: + case PINOS_SOURCE_STATE_ERROR: break; } - pv_source_update_state (source, state); + pinos_source_update_state (source, state); + return TRUE; } static GBytes * -client_get_formats (PvSource *source, GBytes *filter) +client_get_formats (PinosSource *source, + GBytes *filter) { GstCaps *caps, *cfilter; gchar *str; @@ -163,8 +169,8 @@ on_socket_notify (GObject *gobject, GParamSpec *pspec, gpointer user_data) { - PvClientSource *source = user_data; - PvClientSourcePrivate *priv = source->priv; + PinosClientSource *source = user_data; + PinosClientSourcePrivate *priv = source->priv; GSocket *socket; guint num_handles; @@ -195,20 +201,20 @@ on_socket_notify (GObject *gobject, } } -static PvSourceOutput * -client_create_source_output (PvSource *source, +static PinosSourceOutput * +client_create_source_output (PinosSource *source, const gchar *client_path, GBytes *format_filter, const gchar *prefix, GError **error) { - PvClientSourcePrivate *priv = PV_CLIENT_SOURCE (source)->priv; - PvSourceOutput *output; + PinosClientSourcePrivate *priv = PINOS_CLIENT_SOURCE (source)->priv; + PinosSourceOutput *output; /* propose format of input */ g_object_get (priv->input, "format", &format_filter, NULL); - output = PV_SOURCE_CLASS (pv_client_source_parent_class) + output = PINOS_SOURCE_CLASS (pinos_client_source_parent_class) ->create_source_output (source, client_path, format_filter, @@ -226,26 +232,27 @@ client_create_source_output (PvSource *source, } static gboolean -client_release_source_output (PvSource *source, PvSourceOutput *output) +client_release_source_output (PinosSource *source, + PinosSourceOutput *output) { - return PV_SOURCE_CLASS (pv_client_source_parent_class)->release_source_output (source, output); + return PINOS_SOURCE_CLASS (pinos_client_source_parent_class)->release_source_output (source, output); } static void client_source_dispose (GObject * object) { - PvClientSourcePrivate *priv = PV_CLIENT_SOURCE (object)->priv; + PinosClientSourcePrivate *priv = PINOS_CLIENT_SOURCE (object)->priv; g_source_remove (priv->id); gst_element_set_state (priv->pipeline, GST_STATE_NULL); - G_OBJECT_CLASS (pv_client_source_parent_class)->dispose (object); + G_OBJECT_CLASS (pinos_client_source_parent_class)->dispose (object); } static void client_source_finalize (GObject * object) { - PvClientSourcePrivate *priv = PV_CLIENT_SOURCE (object)->priv; + PinosClientSourcePrivate *priv = PINOS_CLIENT_SOURCE (object)->priv; g_clear_object (&priv->input); g_clear_object (&priv->filter); @@ -253,7 +260,7 @@ client_source_finalize (GObject * object) g_clear_object (&priv->src); g_clear_object (&priv->pipeline); - G_OBJECT_CLASS (pv_client_source_parent_class)->finalize (object); + G_OBJECT_CLASS (pinos_client_source_parent_class)->finalize (object); } @@ -262,8 +269,8 @@ on_input_socket_notify (GObject *gobject, GParamSpec *pspec, gpointer user_data) { - PvClientSource *source = user_data; - PvClientSourcePrivate *priv = source->priv; + PinosClientSource *source = user_data; + PinosClientSourcePrivate *priv = source->priv; GSocket *socket; GBytes *requested_format; GstCaps *caps; @@ -293,21 +300,21 @@ on_input_socket_notify (GObject *gobject, gst_element_set_state (priv->pipeline, GST_STATE_READY); } -PvSourceOutput * -pv_client_source_get_source_input (PvClientSource *source, - const gchar *client_path, - GBytes *format_filter, - const gchar *prefix, - GError **error) +PinosSourceOutput * +pinos_client_source_get_source_input (PinosClientSource *source, + const gchar *client_path, + GBytes *format_filter, + const gchar *prefix, + GError **error) { - PvClientSourcePrivate *priv; + PinosClientSourcePrivate *priv; - g_return_val_if_fail (PV_IS_CLIENT_SOURCE (source), NULL); + g_return_val_if_fail (PINOS_IS_CLIENT_SOURCE (source), NULL); priv = source->priv; if (priv->input == NULL) { - priv->input = PV_SOURCE_CLASS (pv_client_source_parent_class) - ->create_source_output (PV_SOURCE (source), + priv->input = PINOS_SOURCE_CLASS (pinos_client_source_parent_class) + ->create_source_output (PINOS_SOURCE (source), client_path, format_filter, prefix, @@ -321,12 +328,12 @@ pv_client_source_get_source_input (PvClientSource *source, } static void -pv_client_source_class_init (PvClientSourceClass * klass) +pinos_client_source_class_init (PinosClientSourceClass * klass) { GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - PvSourceClass *source_class = PV_SOURCE_CLASS (klass); + PinosSourceClass *source_class = PINOS_SOURCE_CLASS (klass); - g_type_class_add_private (klass, sizeof (PvClientSourcePrivate)); + g_type_class_add_private (klass, sizeof (PinosClientSourcePrivate)); gobject_class->dispose = client_source_dispose; gobject_class->finalize = client_source_finalize; @@ -338,15 +345,18 @@ pv_client_source_class_init (PvClientSourceClass * klass) } static void -pv_client_source_init (PvClientSource * source) +pinos_client_source_init (PinosClientSource * source) { - source->priv = PV_CLIENT_SOURCE_GET_PRIVATE (source); + source->priv = PINOS_CLIENT_SOURCE_GET_PRIVATE (source); setup_pipeline (source); } -PvSource * -pv_client_source_new (PvDaemon *daemon) +PinosSource * +pinos_client_source_new (PinosDaemon *daemon) { - return g_object_new (PV_TYPE_CLIENT_SOURCE, "daemon", daemon, "name", "client-source", NULL); + return g_object_new (PINOS_TYPE_CLIENT_SOURCE, + "daemon", daemon, + "name", "client-source", + NULL); } diff --git a/src/server/client-source.h b/src/server/client-source.h new file mode 100644 index 00000000..437b8d4e --- /dev/null +++ b/src/server/client-source.h @@ -0,0 +1,77 @@ +/* Pinos + * Copyright (C) 2015 Wim Taymans <wim.taymans@gmail.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef __PINOS_CLIENT_SOURCE_H__ +#define __PINOS_CLIENT_SOURCE_H__ + +#include <glib-object.h> +#include <gio/gio.h> + +G_BEGIN_DECLS + +typedef struct _PinosClientSource PinosClientSource; +typedef struct _PinosClientSourceClass PinosClientSourceClass; +typedef struct _PinosClientSourcePrivate PinosClientSourcePrivate; + +#include "server/source.h" + +#define PINOS_TYPE_CLIENT_SOURCE (pinos_client_source_get_type ()) +#define PINOS_IS_CLIENT_SOURCE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PINOS_TYPE_SOURCE)) +#define PINOS_IS_CLIENT_SOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PINOS_TYPE_SOURCE)) +#define PINOS_CLIENT_SOURCE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PINOS_TYPE_SOURCE, PinosClientSourceClass)) +#define PINOS_CLIENT_SOURCE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PINOS_TYPE_SOURCE, PinosClientSource)) +#define PINOS_CLIENT_SOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PINOS_TYPE_SOURCE, PinosClientSourceClass)) +#define PINOS_CLIENT_SOURCE_CAST(obj) ((PinosClientSource*)(obj)) +#define PINOS_CLIENT_SOURCE_CLASS_CAST(klass) ((PinosClientSourceClass*)(klass)) + +/** + * PinosClientSource: + * + * Pinos client source object class. + */ +struct _PinosClientSource { + PinosSource object; + + PinosClientSourcePrivate *priv; +}; + +/** + * PinosClientSourceClass: + * + * Pinos client source object class. + */ +struct _PinosClientSourceClass { + PinosSourceClass parent_class; +}; + +/* normal GObject stuff */ +GType pinos_client_source_get_type (void); + +PinosSource * pinos_client_source_new (PinosDaemon *daemon); + +PinosSourceOutput * pinos_client_source_get_source_input (PinosClientSource *source, + const gchar *client_path, + GBytes *format_filter, + const gchar *prefix, + GError **error); + +G_END_DECLS + +#endif /* __PINOS_CLIENT_SOURCE_H__ */ + diff --git a/src/server/pv-client.c b/src/server/client.c index acf23b1e..51bed495 100644 --- a/src/server/pv-client.c +++ b/src/server/client.c @@ -20,29 +20,29 @@ #include <string.h> #include "client/pinos.h" -#include "client/pv-enumtypes.h" +#include "client/enumtypes.h" -#include "server/pv-client.h" -#include "server/pv-client-source.h" +#include "server/client.h" +#include "server/client-source.h" #include "dbus/org-pinos.h" -struct _PvClientPrivate +struct _PinosClientPrivate { - PvDaemon *daemon; + PinosDaemon *daemon; gchar *sender; gchar *object_path; GVariant *properties; - PvClient1 *client1; + PinosClient1 *client1; GList *outputs; }; -#define PV_CLIENT_GET_PRIVATE(obj) \ - (G_TYPE_INSTANCE_GET_PRIVATE ((obj), PV_TYPE_CLIENT, PvClientPrivate)) +#define PINOS_CLIENT_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE ((obj), PINOS_TYPE_CLIENT, PinosClientPrivate)) -G_DEFINE_TYPE (PvClient, pv_client, G_TYPE_OBJECT); +G_DEFINE_TYPE (PinosClient, pinos_client, G_TYPE_OBJECT); enum { @@ -62,13 +62,13 @@ enum static guint signals[LAST_SIGNAL] = { 0 }; static void -pv_client_get_property (GObject *_object, - guint prop_id, - GValue *value, - GParamSpec *pspec) +pinos_client_get_property (GObject *_object, + guint prop_id, + GValue *value, + GParamSpec *pspec) { - PvClient *client = PV_CLIENT (_object); - PvClientPrivate *priv = client->priv; + PinosClient *client = PINOS_CLIENT (_object); + PinosClientPrivate *priv = client->priv; switch (prop_id) { case PROP_DAEMON: @@ -94,13 +94,13 @@ pv_client_get_property (GObject *_object, } static void -pv_client_set_property (GObject *_object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) +pinos_client_set_property (GObject *_object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) { - PvClient *client = PV_CLIENT (_object); - PvClientPrivate *priv = client->priv; + PinosClient *client = PINOS_CLIENT (_object); + PinosClientPrivate *priv = client->priv; switch (prop_id) { case PROP_DAEMON: @@ -128,54 +128,54 @@ pv_client_set_property (GObject *_object, } static void -handle_remove_source_output (PvSourceOutput *output, - gpointer user_data) +handle_remove_source_output (PinosSourceOutput *output, + gpointer user_data) { - PvClient *client = user_data; - PvClientPrivate *priv = client->priv; + PinosClient *client = user_data; + PinosClientPrivate *priv = client->priv; priv->outputs = g_list_remove (priv->outputs, output); g_object_unref (output); } static gboolean -handle_create_source_output (PvClient1 *interface, +handle_create_source_output (PinosClient1 *interface, GDBusMethodInvocation *invocation, const gchar *arg_source, const gchar *arg_accepted_formats, gpointer user_data) { - PvClient *client = user_data; - PvClientPrivate *priv = client->priv; - PvSource *source; - PvSourceOutput *output; + PinosClient *client = user_data; + PinosClientPrivate *priv = client->priv; + PinosSource *source; + PinosSourceOutput *output; const gchar *object_path, *sender; GBytes *formats; GError *error = NULL; sender = g_dbus_method_invocation_get_sender (invocation); - if (g_strcmp0 (pv_client_get_sender (client), sender) != 0) + if (g_strcmp0 (pinos_client_get_sender (client), sender) != 0) goto not_allowed; formats = g_bytes_new (arg_accepted_formats, strlen (arg_accepted_formats) + 1); - source = pv_daemon_find_source (priv->daemon, - arg_source, - priv->properties, - formats, - &error); + source = pinos_daemon_find_source (priv->daemon, + arg_source, + priv->properties, + formats, + &error); if (source == NULL) goto no_source; - output = pv_source_create_source_output (source, - priv->object_path, - formats, - priv->object_path, - &error); + output = pinos_source_create_source_output (source, + priv->object_path, + formats, + priv->object_path, + &error); if (output == NULL) goto no_output; - object_path = pv_source_output_get_object_path (output); + object_path = pinos_source_output_get_object_path (output); priv->outputs = g_list_prepend (priv->outputs, output); @@ -213,29 +213,29 @@ no_output: } static gboolean -handle_create_source_input (PvClient1 *interface, +handle_create_source_input (PinosClient1 *interface, GDBusMethodInvocation *invocation, const gchar *arg_possible_formats, gpointer user_data) { - PvClient *client = user_data; - PvClientPrivate *priv = client->priv; - PvSource *source; - PvSourceOutput *input; + PinosClient *client = user_data; + PinosClientPrivate *priv = client->priv; + PinosSource *source; + PinosSourceOutput *input; const gchar *source_input_path, *sender; GBytes *formats; GError *error = NULL; sender = g_dbus_method_invocation_get_sender (invocation); - if (g_strcmp0 (pv_client_get_sender (client), sender) != 0) + if (g_strcmp0 (pinos_client_get_sender (client), sender) != 0) goto not_allowed; - source = pv_client_source_new (priv->daemon); + source = pinos_client_source_new (priv->daemon); if (source == NULL) goto no_source; g_object_set_data_full (G_OBJECT (client), - pv_source_get_object_path (PV_SOURCE (source)), + pinos_source_get_object_path (PINOS_SOURCE (source)), source, g_object_unref); @@ -243,15 +243,15 @@ handle_create_source_input (PvClient1 *interface, formats = g_bytes_new (arg_possible_formats, strlen (arg_possible_formats) + 1); - input = pv_client_source_get_source_input (PV_CLIENT_SOURCE (source), - priv->object_path, - formats, - priv->object_path, - &error); + input = pinos_client_source_get_source_input (PINOS_CLIENT_SOURCE (source), + priv->object_path, + formats, + priv->object_path, + &error); if (input == NULL) goto no_input; - source_input_path = pv_source_output_get_object_path (input); + source_input_path = pinos_source_output_get_object_path (input); priv->outputs = g_list_prepend (priv->outputs, input); @@ -288,11 +288,11 @@ no_input: } } static gboolean -handle_disconnect (PvClient1 *interface, +handle_disconnect (PinosClient1 *interface, GDBusMethodInvocation *invocation, gpointer user_data) { - PvClient *client = user_data; + PinosClient *client = user_data; g_signal_emit (client, signals[SIGNAL_DISCONNECT], 0, NULL); @@ -302,19 +302,20 @@ handle_disconnect (PvClient1 *interface, } static void -client_register_object (PvClient *client, const gchar *prefix) +client_register_object (PinosClient *client, + const gchar *prefix) { - PvClientPrivate *priv = client->priv; - PvDaemon *daemon = priv->daemon; - PvObjectSkeleton *skel; + PinosClientPrivate *priv = client->priv; + PinosDaemon *daemon = priv->daemon; + PinosObjectSkeleton *skel; gchar *name; name = g_strdup_printf ("%s/client", prefix); - skel = pv_object_skeleton_new (name); + skel = pinos_object_skeleton_new (name); g_free (name); - priv->client1 = pv_client1_skeleton_new (); - pv_client1_set_name (priv->client1, priv->sender); + priv->client1 = pinos_client1_skeleton_new (); + pinos_client1_set_name (priv->client1, priv->sender); g_signal_connect (priv->client1, "handle-create-source-output", (GCallback) handle_create_source_output, client); @@ -324,83 +325,84 @@ client_register_object (PvClient *client, const gchar *prefix) g_signal_connect (priv->client1, "handle-disconnect", (GCallback) handle_disconnect, client); - pv_object_skeleton_set_client1 (skel, priv->client1); + pinos_object_skeleton_set_client1 (skel, priv->client1); g_free (priv->object_path); - priv->object_path = pv_daemon_export_uniquely (daemon, G_DBUS_OBJECT_SKELETON (skel)); + priv->object_path = pinos_daemon_export_uniquely (daemon, G_DBUS_OBJECT_SKELETON (skel)); } static void -client_unregister_object (PvClient *client) +client_unregister_object (PinosClient *client) { - PvClientPrivate *priv = client->priv; - PvDaemon *daemon = priv->daemon; + PinosClientPrivate *priv = client->priv; + PinosDaemon *daemon = priv->daemon; g_clear_object (&priv->client1); - pv_daemon_unexport (daemon, priv->object_path); + pinos_daemon_unexport (daemon, priv->object_path); g_free (priv->object_path); } static void -do_remove_output (PvSourceOutput *output, PvClient *client) +do_remove_output (PinosSourceOutput *output, + PinosClient *client) { - pv_source_output_remove (output); + pinos_source_output_remove (output); } static void -pv_client_dispose (GObject * object) +pinos_client_dispose (GObject * object) { - PvClient *client = PV_CLIENT (object); - PvClientPrivate *priv = client->priv; + PinosClient *client = PINOS_CLIENT (object); + PinosClientPrivate *priv = client->priv; g_list_foreach (priv->outputs, (GFunc) do_remove_output, client); client_unregister_object (client); - G_OBJECT_CLASS (pv_client_parent_class)->dispose (object); + G_OBJECT_CLASS (pinos_client_parent_class)->dispose (object); } static void -pv_client_finalize (GObject * object) +pinos_client_finalize (GObject * object) { - PvClient *client = PV_CLIENT (object); - PvClientPrivate *priv = client->priv; + PinosClient *client = PINOS_CLIENT (object); + PinosClientPrivate *priv = client->priv; if (priv->properties) g_variant_unref (priv->properties); - G_OBJECT_CLASS (pv_client_parent_class)->finalize (object); + G_OBJECT_CLASS (pinos_client_parent_class)->finalize (object); } static void -pv_client_constructed (GObject * object) +pinos_client_constructed (GObject * object) { - PvClient *client = PV_CLIENT (object); - PvClientPrivate *priv = client->priv; + PinosClient *client = PINOS_CLIENT (object); + PinosClientPrivate *priv = client->priv; client_register_object (client, priv->object_path); - G_OBJECT_CLASS (pv_client_parent_class)->constructed (object); + G_OBJECT_CLASS (pinos_client_parent_class)->constructed (object); } static void -pv_client_class_init (PvClientClass * klass) +pinos_client_class_init (PinosClientClass * klass) { GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - g_type_class_add_private (klass, sizeof (PvClientPrivate)); + g_type_class_add_private (klass, sizeof (PinosClientPrivate)); - gobject_class->constructed = pv_client_constructed; - gobject_class->dispose = pv_client_dispose; - gobject_class->finalize = pv_client_finalize; - gobject_class->set_property = pv_client_set_property; - gobject_class->get_property = pv_client_get_property; + gobject_class->constructed = pinos_client_constructed; + gobject_class->dispose = pinos_client_dispose; + gobject_class->finalize = pinos_client_finalize; + gobject_class->set_property = pinos_client_set_property; + gobject_class->get_property = pinos_client_get_property; g_object_class_install_property (gobject_class, PROP_DAEMON, g_param_spec_object ("daemon", "Daemon", "The daemon", - PV_TYPE_DAEMON, + PINOS_TYPE_DAEMON, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS)); @@ -448,70 +450,70 @@ pv_client_class_init (PvClientClass * klass) } static void -pv_client_init (PvClient * client) +pinos_client_init (PinosClient * client) { - client->priv = PV_CLIENT_GET_PRIVATE (client); + client->priv = PINOS_CLIENT_GET_PRIVATE (client); } /** - * pv_client_new: - * @daemon: a #PvDaemon + * pinos_client_new: + * @daemon: a #PinosDaemon * @prefix: a prefix * - * Make a new #PvClient object and register it to @daemon under the @prefix. + * Make a new #PinosClient object and register it to @daemon under the @prefix. * - * Returns: a new #PvClient + * Returns: a new #PinosClient */ -PvClient * -pv_client_new (PvDaemon *daemon, - const gchar *sender, - const gchar *prefix, - GVariant *properties) +PinosClient * +pinos_client_new (PinosDaemon *daemon, + const gchar *sender, + const gchar *prefix, + GVariant *properties) { - g_return_val_if_fail (PV_IS_DAEMON (daemon), NULL); + g_return_val_if_fail (PINOS_IS_DAEMON (daemon), NULL); g_return_val_if_fail (g_variant_is_object_path (prefix), NULL); - return g_object_new (PV_TYPE_CLIENT, "daemon", daemon, - "sender", sender, - "object-path", prefix, - "properties", properties, - NULL); + return g_object_new (PINOS_TYPE_CLIENT, "daemon", daemon, + "sender", sender, + "object-path", prefix, + "properties", properties, + NULL); } /** - * pv_client_get_sender: - * @client: a #PvClient + * pinos_client_get_sender: + * @client: a #PinosClient * * Get the sender of @client. * * Returns: the sender of @client */ const gchar * -pv_client_get_sender (PvClient *client) +pinos_client_get_sender (PinosClient *client) { - PvClientPrivate *priv; + PinosClientPrivate *priv; - g_return_val_if_fail (PV_IS_CLIENT (client), NULL); + g_return_val_if_fail (PINOS_IS_CLIENT (client), NULL); priv = client->priv; return priv->sender; } /** - * pv_client_get_object_path: - * @client: a #PvClient + * pinos_client_get_object_path: + * @client: a #PinosClient * * Get the object path of @client. * * Returns: the object path of @client */ const gchar * -pv_client_get_object_path (PvClient *client) +pinos_client_get_object_path (PinosClient *client) { - PvClientPrivate *priv; + PinosClientPrivate *priv; - g_return_val_if_fail (PV_IS_CLIENT (client), NULL); + g_return_val_if_fail (PINOS_IS_CLIENT (client), NULL); priv = client->priv; return priv->object_path; diff --git a/src/server/client.h b/src/server/client.h new file mode 100644 index 00000000..968916e8 --- /dev/null +++ b/src/server/client.h @@ -0,0 +1,76 @@ +/* Pinos + * Copyright (C) 2015 Wim Taymans <wim.taymans@gmail.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef __PINOS_CLIENT_H__ +#define __PINOS_CLIENT_H__ + +#include <glib-object.h> + +#include "daemon.h" + +G_BEGIN_DECLS + +#define PINOS_TYPE_CLIENT (pinos_client_get_type ()) +#define PINOS_IS_CLIENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PINOS_TYPE_CLIENT)) +#define PINOS_IS_CLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PINOS_TYPE_CLIENT)) +#define PINOS_CLIENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PINOS_TYPE_CLIENT, PinosClientClass)) +#define PINOS_CLIENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PINOS_TYPE_CLIENT, PinosClient)) +#define PINOS_CLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PINOS_TYPE_CLIENT, PinosClientClass)) +#define PINOS_CLIENT_CAST(obj) ((PinosClient*)(obj)) +#define PINOS_CLIENT_CLASS_CAST(klass) ((PinosClientClass*)(klass)) + +typedef struct _PinosClient PinosClient; +typedef struct _PinosClientClass PinosClientClass; +typedef struct _PinosClientPrivate PinosClientPrivate; + +/** + * PinosClient: + * + * Pinos client object class. + */ +struct _PinosClient { + GObject object; + + PinosClientPrivate *priv; +}; + +/** + * PinosClientClass: + * + * Pinos client object class. + */ +struct _PinosClientClass { + GObjectClass parent_class; +}; + +/* normal GObject stuff */ +GType pinos_client_get_type (void); + +PinosClient * pinos_client_new (PinosDaemon *daemon, + const gchar *sender, + const gchar *prefix, + GVariant *properties); + +const gchar * pinos_client_get_sender (PinosClient *client); +const gchar * pinos_client_get_object_path (PinosClient *client); + +G_END_DECLS + +#endif /* __PINOS_CLIENT_H__ */ + diff --git a/src/server/pv-daemon.c b/src/server/daemon.c index 5862887f..1cbf223c 100644 --- a/src/server/pv-daemon.c +++ b/src/server/daemon.c @@ -23,15 +23,15 @@ #include "client/pinos.h" -#include "server/pv-daemon.h" -#include "server/pv-client.h" +#include "server/daemon.h" +#include "server/client.h" #include "dbus/org-pinos.h" -#define PV_DAEMON_GET_PRIVATE(obj) \ - (G_TYPE_INSTANCE_GET_PRIVATE ((obj), PV_TYPE_DAEMON, PvDaemonPrivate)) +#define PINOS_DAEMON_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE ((obj), PINOS_TYPE_DAEMON, PinosDaemonPrivate)) -struct _PvDaemonPrivate +struct _PinosDaemonPrivate { guint id; GDBusConnection *connection; @@ -45,18 +45,18 @@ struct _PvDaemonPrivate typedef struct { guint id; gchar *sender; - PvDaemon *daemon; + PinosDaemon *daemon; GList *objects; } SenderData; static void client_name_appeared_handler (GDBusConnection *connection, - const gchar *name, - const gchar *name_owner, - gpointer user_data) + const gchar *name, + const gchar *name_owner, + gpointer user_data) { SenderData *data = user_data; - PvDaemonPrivate *priv = data->daemon->priv; + PinosDaemonPrivate *priv = data->daemon->priv; g_hash_table_insert (priv->senders, data->sender, data); @@ -66,8 +66,8 @@ client_name_appeared_handler (GDBusConnection *connection, static void client_name_vanished_handler (GDBusConnection *connection, - const gchar *name, - gpointer user_data) + const gchar *name, + gpointer user_data) { SenderData *data = user_data; @@ -84,9 +84,10 @@ data_free (SenderData *data) } static SenderData * -sender_data_new (PvDaemon *daemon, const gchar *sender) +sender_data_new (PinosDaemon *daemon, + const gchar *sender) { - PvDaemonPrivate *priv = daemon->priv; + PinosDaemonPrivate *priv = daemon->priv; SenderData *data; data = g_new0 (SenderData, 1); @@ -106,15 +107,15 @@ sender_data_new (PvDaemon *daemon, const gchar *sender) } static void -handle_disconnect_client (PvClient *client, - gpointer user_data) +handle_disconnect_client (PinosClient *client, + gpointer user_data) { - PvDaemon *daemon = user_data; - PvDaemonPrivate *priv = daemon->priv; + PinosDaemon *daemon = user_data; + PinosDaemonPrivate *priv = daemon->priv; const gchar *sender; SenderData *data; - sender = pv_client_get_sender (client); + sender = pinos_client_get_sender (client); data = g_hash_table_lookup (priv->senders, sender); if (data == NULL) @@ -125,23 +126,23 @@ handle_disconnect_client (PvClient *client, } static gboolean -handle_connect_client (PvDaemon1 *interface, +handle_connect_client (PinosDaemon1 *interface, GDBusMethodInvocation *invocation, GVariant *arg_properties, gpointer user_data) { - PvDaemon *daemon = user_data; - PvClient *client; + PinosDaemon *daemon = user_data; + PinosClient *client; const gchar *sender, *object_path; sender = g_dbus_method_invocation_get_sender (invocation); - client = pv_client_new (daemon, sender, PV_DBUS_OBJECT_PREFIX, arg_properties); + client = pinos_client_new (daemon, sender, PINOS_DBUS_OBJECT_PREFIX, arg_properties); g_signal_connect (client, "disconnect", (GCallback) handle_disconnect_client, daemon); - pv_daemon_track_object (daemon, sender, G_OBJECT (client)); + pinos_daemon_track_object (daemon, sender, G_OBJECT (client)); - object_path = pv_client_get_object_path (client); + object_path = pinos_client_get_object_path (client); g_dbus_method_invocation_return_value (invocation, g_variant_new ("(o)", object_path)); @@ -149,21 +150,22 @@ handle_connect_client (PvDaemon1 *interface, } static void -export_server_object (PvDaemon *daemon, GDBusObjectManagerServer *manager) +export_server_object (PinosDaemon *daemon, + GDBusObjectManagerServer *manager) { - PvObjectSkeleton *skel; + PinosObjectSkeleton *skel; - skel = pv_object_skeleton_new (PV_DBUS_OBJECT_SERVER); + skel = pinos_object_skeleton_new (PINOS_DBUS_OBJECT_SERVER); { - PvDaemon1 *iface; + PinosDaemon1 *iface; - iface = pv_daemon1_skeleton_new (); + iface = pinos_daemon1_skeleton_new (); g_signal_connect (iface, "handle-connect-client", (GCallback) handle_connect_client, daemon); - pv_daemon1_set_user_name (iface, g_get_user_name ()); - pv_daemon1_set_host_name (iface, g_get_host_name ()); - pv_daemon1_set_version (iface, PACKAGE_VERSION); - pv_daemon1_set_name (iface, PACKAGE_NAME); - pv_object_skeleton_set_daemon1 (skel, iface); + pinos_daemon1_set_user_name (iface, g_get_user_name ()); + pinos_daemon1_set_host_name (iface, g_get_host_name ()); + pinos_daemon1_set_version (iface, PACKAGE_VERSION); + pinos_daemon1_set_name (iface, PACKAGE_NAME); + pinos_object_skeleton_set_daemon1 (skel, iface); g_object_unref (iface); } g_dbus_object_manager_server_export (manager, G_DBUS_OBJECT_SKELETON (skel)); @@ -172,11 +174,11 @@ export_server_object (PvDaemon *daemon, GDBusObjectManagerServer *manager) static void bus_acquired_handler (GDBusConnection *connection, - const gchar *name, - gpointer user_data) + const gchar *name, + gpointer user_data) { - PvDaemon *daemon = user_data; - PvDaemonPrivate *priv = daemon->priv; + PinosDaemon *daemon = user_data; + PinosDaemonPrivate *priv = daemon->priv; GDBusObjectManagerServer *manager = priv->server_manager; priv->connection = connection; @@ -188,56 +190,56 @@ bus_acquired_handler (GDBusConnection *connection, static void name_acquired_handler (GDBusConnection *connection, - const gchar *name, - gpointer user_data) + const gchar *name, + gpointer user_data) { } static void name_lost_handler (GDBusConnection *connection, - const gchar *name, - gpointer user_data) + const gchar *name, + gpointer user_data) { - PvDaemon *daemon = user_data; - PvDaemonPrivate *priv = daemon->priv; + PinosDaemon *daemon = user_data; + PinosDaemonPrivate *priv = daemon->priv; GDBusObjectManagerServer *manager = priv->server_manager; - g_dbus_object_manager_server_unexport (manager, PV_DBUS_OBJECT_SERVER); + g_dbus_object_manager_server_unexport (manager, PINOS_DBUS_OBJECT_SERVER); g_dbus_object_manager_server_set_connection (manager, connection); priv->connection = connection; } /** - * pv_daemon_new: + * pinos_daemon_new: * - * Make a new #PvDaemon object + * Make a new #PinosDaemon object * - * Returns: a new #PvDaemon + * Returns: a new #PinosDaemon */ -PvDaemon * -pv_daemon_new (void) +PinosDaemon * +pinos_daemon_new (void) { - return g_object_new (PV_TYPE_DAEMON, NULL); + return g_object_new (PINOS_TYPE_DAEMON, NULL); } /** - * pv_daemon_start: - * @daemon: a #PvDaemon + * pinos_daemon_start: + * @daemon: a #PinosDaemon * * Start the @daemon. */ void -pv_daemon_start (PvDaemon *daemon) +pinos_daemon_start (PinosDaemon *daemon) { - PvDaemonPrivate *priv; + PinosDaemonPrivate *priv; - g_return_if_fail (PV_IS_DAEMON (daemon)); + g_return_if_fail (PINOS_IS_DAEMON (daemon)); priv = daemon->priv; g_return_if_fail (priv->id == 0); priv->id = g_bus_own_name (G_BUS_TYPE_SESSION, - PV_DBUS_SERVICE, + PINOS_DBUS_SERVICE, G_BUS_NAME_OWNER_FLAGS_REPLACE, bus_acquired_handler, name_acquired_handler, @@ -247,17 +249,17 @@ pv_daemon_start (PvDaemon *daemon) } /** - * pv_daemon_stop: - * @daemon: a #PvDaemon + * pinos_daemon_stop: + * @daemon: a #PinosDaemon * * Stop the @daemon. */ void -pv_daemon_stop (PvDaemon *daemon) +pinos_daemon_stop (PinosDaemon *daemon) { - PvDaemonPrivate *priv = daemon->priv; + PinosDaemonPrivate *priv = daemon->priv; - g_return_if_fail (PV_IS_DAEMON (daemon)); + g_return_if_fail (PINOS_IS_DAEMON (daemon)); if (priv->id != 0) { g_bus_unown_name (priv->id); @@ -266,8 +268,8 @@ pv_daemon_stop (PvDaemon *daemon) } /** - * pv_daemon_export_uniquely: - * @daemon: a #PvDaemon + * pinos_daemon_export_uniquely: + * @daemon: a #PinosDaemon * @skel: a #GDBusObjectSkeleton * * Export @skel with @daemon with a unique name @@ -275,9 +277,10 @@ pv_daemon_stop (PvDaemon *daemon) * Returns: the unique named used to export @skel. */ gchar * -pv_daemon_export_uniquely (PvDaemon *daemon, GDBusObjectSkeleton *skel) +pinos_daemon_export_uniquely (PinosDaemon *daemon, + GDBusObjectSkeleton *skel) { - g_return_val_if_fail (PV_IS_DAEMON (daemon), NULL); + g_return_val_if_fail (PINOS_IS_DAEMON (daemon), NULL); g_return_val_if_fail (G_IS_DBUS_OBJECT_SKELETON (skel), NULL); g_dbus_object_manager_server_export_uniquely (daemon->priv->server_manager, skel); @@ -286,30 +289,31 @@ pv_daemon_export_uniquely (PvDaemon *daemon, GDBusObjectSkeleton *skel) } /** - * pv_daemon_unexport: - * @daemon: a #PvDaemon + * pinos_daemon_unexport: + * @daemon: a #PinosDaemon * @object_path: an object path * * Unexport the object on @object_path */ void -pv_daemon_unexport (PvDaemon *daemon, const gchar *object_path) +pinos_daemon_unexport (PinosDaemon *daemon, + const gchar *object_path) { - g_return_if_fail (PV_IS_DAEMON (daemon)); + g_return_if_fail (PINOS_IS_DAEMON (daemon)); g_return_if_fail (g_variant_is_object_path (object_path)); g_dbus_object_manager_server_unexport (daemon->priv->server_manager, object_path); } void -pv_daemon_track_object (PvDaemon *daemon, - const gchar *sender, - GObject *object) +pinos_daemon_track_object (PinosDaemon *daemon, + const gchar *sender, + GObject *object) { - PvDaemonPrivate *priv; + PinosDaemonPrivate *priv; SenderData *data; - g_return_if_fail (PV_IS_DAEMON (daemon)); + g_return_if_fail (PINOS_IS_DAEMON (daemon)); g_return_if_fail (sender != NULL); g_return_if_fail (G_IS_OBJECT (object)); @@ -323,51 +327,53 @@ pv_daemon_track_object (PvDaemon *daemon, } void -pv_daemon_add_source (PvDaemon *daemon, PvSource *source) +pinos_daemon_add_source (PinosDaemon *daemon, + PinosSource *source) { - PvDaemonPrivate *priv; + PinosDaemonPrivate *priv; - g_return_if_fail (PV_IS_DAEMON (daemon)); - g_return_if_fail (PV_IS_SOURCE (source)); + g_return_if_fail (PINOS_IS_DAEMON (daemon)); + g_return_if_fail (PINOS_IS_SOURCE (source)); priv = daemon->priv; priv->sources = g_list_prepend (priv->sources, source); } void -pv_daemon_remove_source (PvDaemon *daemon, PvSource *source) +pinos_daemon_remove_source (PinosDaemon *daemon, + PinosSource *source) { - PvDaemonPrivate *priv; + PinosDaemonPrivate *priv; - g_return_if_fail (PV_IS_DAEMON (daemon)); - g_return_if_fail (PV_IS_SOURCE (source)); + g_return_if_fail (PINOS_IS_DAEMON (daemon)); + g_return_if_fail (PINOS_IS_SOURCE (source)); priv = daemon->priv; priv->sources = g_list_remove (priv->sources, source); } -PvSource * -pv_daemon_find_source (PvDaemon *daemon, - const gchar *name, - GVariant *props, - GBytes *format_filter, - GError **error) +PinosSource * +pinos_daemon_find_source (PinosDaemon *daemon, + const gchar *name, + GVariant *props, + GBytes *format_filter, + GError **error) { - PvDaemonPrivate *priv; - PvSource *best = NULL; + PinosDaemonPrivate *priv; + PinosSource *best = NULL; GList *walk; - g_return_val_if_fail (PV_IS_DAEMON (daemon), NULL); + g_return_val_if_fail (PINOS_IS_DAEMON (daemon), NULL); priv = daemon->priv; for (walk = priv->sources; walk; walk = g_list_next (walk)) { - PvSource *s = walk->data; + PinosSource *s = walk->data; if (name == NULL) { best = s; break; } - else if (g_str_has_suffix (pv_source_get_object_path (s), name)) + else if (g_str_has_suffix (pinos_source_get_object_path (s), name)) best = s; } @@ -380,46 +386,46 @@ pv_daemon_find_source (PvDaemon *daemon, return best; } -G_DEFINE_TYPE (PvDaemon, pv_daemon, G_TYPE_OBJECT); +G_DEFINE_TYPE (PinosDaemon, pinos_daemon, G_TYPE_OBJECT); static void -pv_daemon_dispose (GObject * object) +pinos_daemon_dispose (GObject * object) { - PvDaemon *daemon = PV_DAEMON_CAST (object); + PinosDaemon *daemon = PINOS_DAEMON_CAST (object); - pv_daemon_stop (daemon); + pinos_daemon_stop (daemon); - G_OBJECT_CLASS (pv_daemon_parent_class)->dispose (object); + G_OBJECT_CLASS (pinos_daemon_parent_class)->dispose (object); } static void -pv_daemon_finalize (GObject * object) +pinos_daemon_finalize (GObject * object) { - PvDaemon *daemon = PV_DAEMON_CAST (object); - PvDaemonPrivate *priv = daemon->priv; + PinosDaemon *daemon = PINOS_DAEMON_CAST (object); + PinosDaemonPrivate *priv = daemon->priv; g_clear_object (&priv->server_manager); - G_OBJECT_CLASS (pv_daemon_parent_class)->finalize (object); + G_OBJECT_CLASS (pinos_daemon_parent_class)->finalize (object); } static void -pv_daemon_class_init (PvDaemonClass * klass) +pinos_daemon_class_init (PinosDaemonClass * klass) { GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - g_type_class_add_private (klass, sizeof (PvDaemonPrivate)); + g_type_class_add_private (klass, sizeof (PinosDaemonPrivate)); - gobject_class->dispose = pv_daemon_dispose; - gobject_class->finalize = pv_daemon_finalize; + gobject_class->dispose = pinos_daemon_dispose; + gobject_class->finalize = pinos_daemon_finalize; } static void -pv_daemon_init (PvDaemon * daemon) +pinos_daemon_init (PinosDaemon * daemon) { - PvDaemonPrivate *priv = daemon->priv = PV_DAEMON_GET_PRIVATE (daemon); + PinosDaemonPrivate *priv = daemon->priv = PINOS_DAEMON_GET_PRIVATE (daemon); - priv->server_manager = g_dbus_object_manager_server_new (PV_DBUS_OBJECT_PREFIX); + priv->server_manager = g_dbus_object_manager_server_new (PINOS_DBUS_OBJECT_PREFIX); priv->senders = g_hash_table_new (g_str_hash, g_str_equal); } diff --git a/src/server/daemon.h b/src/server/daemon.h new file mode 100644 index 00000000..4f160e7e --- /dev/null +++ b/src/server/daemon.h @@ -0,0 +1,89 @@ +/* Pinos + * Copyright (C) 2015 Wim Taymans <wim.taymans@gmail.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef __PINOS_DAEMON_H__ +#define __PINOS_DAEMON_H__ + +#include <glib-object.h> +#include <gio/gio.h> + +G_BEGIN_DECLS + +#define PINOS_TYPE_DAEMON (pinos_daemon_get_type ()) +#define PINOS_IS_DAEMON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PINOS_TYPE_DAEMON)) +#define PINOS_IS_DAEMON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PINOS_TYPE_DAEMON)) +#define PINOS_DAEMON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PINOS_TYPE_DAEMON, PinosDaemonClass)) +#define PINOS_DAEMON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PINOS_TYPE_DAEMON, PinosDaemon)) +#define PINOS_DAEMON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PINOS_TYPE_DAEMON, PinosDaemonClass)) +#define PINOS_DAEMON_CAST(obj) ((PinosDaemon*)(obj)) +#define PINOS_DAEMON_CLASS_CAST(klass) ((PinosDaemonClass*)(klass)) + +typedef struct _PinosDaemon PinosDaemon; +typedef struct _PinosDaemonClass PinosDaemonClass; +typedef struct _PinosDaemonPrivate PinosDaemonPrivate; + +#include <server/source.h> + +/** + * PinosDaemon: + * + * Pinos daemon object class. + */ +struct _PinosDaemon { + GObject object; + + PinosDaemonPrivate *priv; +}; + +/** + * PinosDaemonClass: + * + * Pinos daemon object class. + */ +struct _PinosDaemonClass { + GObjectClass parent_class; +}; + +/* normal GObject stuff */ +GType pinos_daemon_get_type (void); + +PinosDaemon * pinos_daemon_new (void); + +void pinos_daemon_start (PinosDaemon *daemon); +void pinos_daemon_stop (PinosDaemon *daemon); + +gchar * pinos_daemon_export_uniquely (PinosDaemon *daemon, GDBusObjectSkeleton *skel); +void pinos_daemon_unexport (PinosDaemon *daemon, const gchar *name); + +void pinos_daemon_track_object (PinosDaemon *daemon, + const gchar *sender, + GObject *object); + +void pinos_daemon_add_source (PinosDaemon *daemon, PinosSource *source); +void pinos_daemon_remove_source (PinosDaemon *daemon, PinosSource *source); +PinosSource * pinos_daemon_find_source (PinosDaemon *daemon, + const gchar *name, + GVariant *props, + GBytes *format_filter, + GError **error); + +G_END_DECLS + +#endif /* __PINOS_DAEMON_H__ */ + diff --git a/src/server/pv-client-source.h b/src/server/pv-client-source.h deleted file mode 100644 index 2ffd1be6..00000000 --- a/src/server/pv-client-source.h +++ /dev/null @@ -1,77 +0,0 @@ -/* Pinos - * Copyright (C) 2015 Wim Taymans <wim.taymans@gmail.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef __PV_CLIENT_SOURCE_H__ -#define __PV_CLIENT_SOURCE_H__ - -#include <glib-object.h> -#include <gio/gio.h> - -G_BEGIN_DECLS - -typedef struct _PvClientSource PvClientSource; -typedef struct _PvClientSourceClass PvClientSourceClass; -typedef struct _PvClientSourcePrivate PvClientSourcePrivate; - -#include "server/pv-source.h" - -#define PV_TYPE_CLIENT_SOURCE (pv_client_source_get_type ()) -#define PV_IS_CLIENT_SOURCE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PV_TYPE_SOURCE)) -#define PV_IS_CLIENT_SOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PV_TYPE_SOURCE)) -#define PV_CLIENT_SOURCE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PV_TYPE_SOURCE, PvClientSourceClass)) -#define PV_CLIENT_SOURCE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PV_TYPE_SOURCE, PvClientSource)) -#define PV_CLIENT_SOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PV_TYPE_SOURCE, PvClientSourceClass)) -#define PV_CLIENT_SOURCE_CAST(obj) ((PvClientSource*)(obj)) -#define PV_CLIENT_SOURCE_CLASS_CAST(klass) ((PvClientSourceClass*)(klass)) - -/** - * PvClientSource: - * - * Pinos client source object class. - */ -struct _PvClientSource { - PvSource object; - - PvClientSourcePrivate *priv; -}; - -/** - * PvClientSourceClass: - * - * Pinos client source object class. - */ -struct _PvClientSourceClass { - PvSourceClass parent_class; -}; - -/* normal GObject stuff */ -GType pv_client_source_get_type (void); - -PvSource * pv_client_source_new (PvDaemon *daemon); - -PvSourceOutput * pv_client_source_get_source_input (PvClientSource *source, - const gchar *client_path, - GBytes *format_filter, - const gchar *prefix, - GError **error); - -G_END_DECLS - -#endif /* __PV_CLIENT_SOURCE_H__ */ - diff --git a/src/server/pv-client.h b/src/server/pv-client.h deleted file mode 100644 index 6c4fea47..00000000 --- a/src/server/pv-client.h +++ /dev/null @@ -1,76 +0,0 @@ -/* Pinos - * Copyright (C) 2015 Wim Taymans <wim.taymans@gmail.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef __PV_CLIENT_H__ -#define __PV_CLIENT_H__ - -#include <glib-object.h> - -#include "pv-daemon.h" - -G_BEGIN_DECLS - -#define PV_TYPE_CLIENT (pv_client_get_type ()) -#define PV_IS_CLIENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PV_TYPE_CLIENT)) -#define PV_IS_CLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PV_TYPE_CLIENT)) -#define PV_CLIENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PV_TYPE_CLIENT, PvClientClass)) -#define PV_CLIENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PV_TYPE_CLIENT, PvClient)) -#define PV_CLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PV_TYPE_CLIENT, PvClientClass)) -#define PV_CLIENT_CAST(obj) ((PvClient*)(obj)) -#define PV_CLIENT_CLASS_CAST(klass) ((PvClientClass*)(klass)) - -typedef struct _PvClient PvClient; -typedef struct _PvClientClass PvClientClass; -typedef struct _PvClientPrivate PvClientPrivate; - -/** - * PvClient: - * - * Pinos client object class. - */ -struct _PvClient { - GObject object; - - PvClientPrivate *priv; -}; - -/** - * PvClientClass: - * - * Pinos client object class. - */ -struct _PvClientClass { - GObjectClass parent_class; -}; - -/* normal GObject stuff */ -GType pv_client_get_type (void); - -PvClient * pv_client_new (PvDaemon *daemon, - const gchar *sender, - const gchar *prefix, - GVariant *properties); - -const gchar * pv_client_get_sender (PvClient *client); -const gchar * pv_client_get_object_path (PvClient *client); - -G_END_DECLS - -#endif /* __PV_CLIENT_H__ */ - diff --git a/src/server/pv-daemon.h b/src/server/pv-daemon.h deleted file mode 100644 index edcd9a37..00000000 --- a/src/server/pv-daemon.h +++ /dev/null @@ -1,87 +0,0 @@ -/* Pinos - * Copyright (C) 2015 Wim Taymans <wim.taymans@gmail.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef __PV_DAEMON_H__ -#define __PV_DAEMON_H__ - -#include <glib-object.h> -#include <gio/gio.h> - -G_BEGIN_DECLS - -#define PV_TYPE_DAEMON (pv_daemon_get_type ()) -#define PV_IS_DAEMON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PV_TYPE_DAEMON)) -#define PV_IS_DAEMON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PV_TYPE_DAEMON)) -#define PV_DAEMON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PV_TYPE_DAEMON, PvDaemonClass)) -#define PV_DAEMON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PV_TYPE_DAEMON, PvDaemon)) -#define PV_DAEMON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PV_TYPE_DAEMON, PvDaemonClass)) -#define PV_DAEMON_CAST(obj) ((PvDaemon*)(obj)) -#define PV_DAEMON_CLASS_CAST(klass) ((PvDaemonClass*)(klass)) - -typedef struct _PvDaemon PvDaemon; -typedef struct _PvDaemonClass PvDaemonClass; -typedef struct _PvDaemonPrivate PvDaemonPrivate; - -#include <server/pv-source.h> - -/** - * PvDaemon: - * - * Pinos daemon object class. - */ -struct _PvDaemon { - GObject object; - - PvDaemonPrivate *priv; -}; - -/** - * PvDaemonClass: - * - * Pinos daemon object class. - */ -struct _PvDaemonClass { - GObjectClass parent_class; -}; - -/* normal GObject stuff */ -GType pv_daemon_get_type (void); - -PvDaemon * pv_daemon_new (void); - -void pv_daemon_start (PvDaemon *daemon); -void pv_daemon_stop (PvDaemon *daemon); - -gchar * pv_daemon_export_uniquely (PvDaemon *daemon, GDBusObjectSkeleton *skel); -void pv_daemon_unexport (PvDaemon *daemon, const gchar *name); - -void pv_daemon_track_object (PvDaemon *daemon, const gchar *sender, GObject *object); - -void pv_daemon_add_source (PvDaemon *daemon, PvSource *source); -void pv_daemon_remove_source (PvDaemon *daemon, PvSource *source); -PvSource * pv_daemon_find_source (PvDaemon *daemon, - const gchar *name, - GVariant *props, - GBytes *format_filter, - GError **error); - -G_END_DECLS - -#endif /* __PV_DAEMON_H__ */ - diff --git a/src/server/pv-source-output.h b/src/server/pv-source-output.h deleted file mode 100644 index 97f225f8..00000000 --- a/src/server/pv-source-output.h +++ /dev/null @@ -1,70 +0,0 @@ -/* Pinos - * Copyright (C) 2015 Wim Taymans <wim.taymans@gmail.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef __PV_SOURCE_OUTPUT_H__ -#define __PV_SOURCE_OUTPUT_H__ - -#include <glib-object.h> - -G_BEGIN_DECLS - -#define PV_TYPE_SOURCE_OUTPUT (pv_source_output_get_type ()) -#define PV_IS_SOURCE_OUTPUT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PV_TYPE_SOURCE_OUTPUT)) -#define PV_IS_SOURCE_OUTPUT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PV_TYPE_SOURCE_OUTPUT)) -#define PV_SOURCE_OUTPUT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PV_TYPE_SOURCE_OUTPUT, PvSourceOutputClass)) -#define PV_SOURCE_OUTPUT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PV_TYPE_SOURCE_OUTPUT, PvSourceOutput)) -#define PV_SOURCE_OUTPUT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PV_TYPE_SOURCE_OUTPUT, PvSourceOutputClass)) -#define PV_SOURCE_OUTPUT_CAST(obj) ((PvSourceOutput*)(obj)) -#define PV_SOURCE_OUTPUT_CLASS_CAST(klass) ((PvSourceOutputClass*)(klass)) - -typedef struct _PvSourceOutput PvSourceOutput; -typedef struct _PvSourceOutputClass PvSourceOutputClass; -typedef struct _PvSourceOutputPrivate PvSourceOutputPrivate; - -/** - * PvSourceOutput: - * - * Pinos source output object class. - */ -struct _PvSourceOutput { - GObject object; - - PvSourceOutputPrivate *priv; -}; - -/** - * PvSourceOutputClass: - * - * Pinos source output object class. - */ -struct _PvSourceOutputClass { - GObjectClass parent_class; -}; - -/* normal GObject stuff */ -GType pv_source_output_get_type (void); - -void pv_source_output_remove (PvSourceOutput *output); - -const gchar * pv_source_output_get_object_path (PvSourceOutput *output); - -G_END_DECLS - -#endif /* __PV_SOURCE_OUTPUT_H__ */ - diff --git a/src/server/pv-source.h b/src/server/pv-source.h deleted file mode 100644 index 33aecdd8..00000000 --- a/src/server/pv-source.h +++ /dev/null @@ -1,101 +0,0 @@ -/* Pinos - * Copyright (C) 2015 Wim Taymans <wim.taymans@gmail.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef __PV_SOURCE_H__ -#define __PV_SOURCE_H__ - -#include <glib-object.h> -#include <gio/gio.h> - -G_BEGIN_DECLS - -typedef struct _PvSource PvSource; -typedef struct _PvSourceClass PvSourceClass; -typedef struct _PvSourcePrivate PvSourcePrivate; - -#include "client/pv-introspect.h" -#include "server/pv-source-output.h" - -#define PV_TYPE_SOURCE (pv_source_get_type ()) -#define PV_IS_SOURCE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PV_TYPE_SOURCE)) -#define PV_IS_SOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PV_TYPE_SOURCE)) -#define PV_SOURCE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PV_TYPE_SOURCE, PvSourceClass)) -#define PV_SOURCE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PV_TYPE_SOURCE, PvSource)) -#define PV_SOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PV_TYPE_SOURCE, PvSourceClass)) -#define PV_SOURCE_CAST(obj) ((PvSource*)(obj)) -#define PV_SOURCE_CLASS_CAST(klass) ((PvSourceClass*)(klass)) - -/** - * PvSource: - * - * Pinos source object class. - */ -struct _PvSource { - GObject object; - - PvSourcePrivate *priv; -}; - -/** - * PvSourceClass: - * @get_formats: called to get a list of supported formats from the source - * @set_state: called to change the current state of the source - * @create_source_output: called to create a new source-output object - * @release_source_output: called to release a source-output object - * - * Pinos source object class. - */ -struct _PvSourceClass { - GObjectClass parent_class; - - GBytes * (*get_formats) (PvSource *source, GBytes *filter); - - gboolean (*set_state) (PvSource *source, PvSourceState); - - PvSourceOutput * (*create_source_output) (PvSource *source, - const gchar *client_path, - GBytes *format_filter, - const gchar *prefix, - GError **error); - gboolean (*release_source_output) (PvSource *source, - PvSourceOutput *output); -}; - -/* normal GObject stuff */ -GType pv_source_get_type (void); - -const gchar * pv_source_get_object_path (PvSource *source); - -GBytes * pv_source_get_formats (PvSource *source, GBytes *filter); - -gboolean pv_source_set_state (PvSource *source, PvSourceState state); -void pv_source_update_state (PvSource *source, PvSourceState state); -void pv_source_report_error (PvSource *source, GError *error); - -PvSourceOutput * pv_source_create_source_output (PvSource *source, - const gchar *client_path, - GBytes *format_filter, - const gchar *prefix, - GError **error); -gboolean pv_source_release_source_output (PvSource *source, PvSourceOutput *output); - -G_END_DECLS - -#endif /* __PV_SOURCE_H__ */ - diff --git a/src/server/pv-source-output.c b/src/server/source-output.c index 83241966..d403695a 100644 --- a/src/server/pv-source-output.c +++ b/src/server/source-output.c @@ -22,17 +22,17 @@ #include <gio/gunixfdlist.h> -#include "client/pv-enumtypes.h" +#include "client/enumtypes.h" -#include "server/pv-daemon.h" -#include "server/pv-source-output.h" +#include "server/daemon.h" +#include "server/source-output.h" #include "dbus/org-pinos.h" -struct _PvSourceOutputPrivate +struct _PinosSourceOutputPrivate { - PvDaemon *daemon; - PvSourceOutput1 *iface; + PinosDaemon *daemon; + PinosSourceOutput1 *iface; gchar *object_path; gchar *client_path; @@ -45,10 +45,10 @@ struct _PvSourceOutputPrivate GSocket *socket; }; -#define PV_SOURCE_OUTPUT_GET_PRIVATE(obj) \ - (G_TYPE_INSTANCE_GET_PRIVATE ((obj), PV_TYPE_SOURCE_OUTPUT, PvSourceOutputPrivate)) +#define PINOS_SOURCE_OUTPUT_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE ((obj), PINOS_TYPE_SOURCE_OUTPUT, PinosSourceOutputPrivate)) -G_DEFINE_TYPE (PvSourceOutput, pv_source_output, G_TYPE_OBJECT); +G_DEFINE_TYPE (PinosSourceOutput, pinos_source_output, G_TYPE_OBJECT); enum { @@ -72,13 +72,13 @@ enum static guint signals[LAST_SIGNAL] = { 0 }; static void -pv_source_output_get_property (GObject *_object, - guint prop_id, - GValue *value, - GParamSpec *pspec) +pinos_source_output_get_property (GObject *_object, + guint prop_id, + GValue *value, + GParamSpec *pspec) { - PvSourceOutput *output = PV_SOURCE_OUTPUT (_object); - PvSourceOutputPrivate *priv = output->priv; + PinosSourceOutput *output = PINOS_SOURCE_OUTPUT (_object); + PinosSourceOutputPrivate *priv = output->priv; switch (prop_id) { case PROP_DAEMON: @@ -120,13 +120,13 @@ pv_source_output_get_property (GObject *_object, } static void -pv_source_output_set_property (GObject *_object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) +pinos_source_output_set_property (GObject *_object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) { - PvSourceOutput *output = PV_SOURCE_OUTPUT (_object); - PvSourceOutputPrivate *priv = output->priv; + PinosSourceOutput *output = PINOS_SOURCE_OUTPUT (_object); + PinosSourceOutputPrivate *priv = output->priv; switch (prop_id) { case PROP_DAEMON: @@ -168,13 +168,13 @@ pv_source_output_set_property (GObject *_object, } static gboolean -handle_start (PvSourceOutput1 *interface, +handle_start (PinosSourceOutput1 *interface, GDBusMethodInvocation *invocation, const gchar *arg_requested_format, gpointer user_data) { - PvSourceOutput *output = user_data; - PvSourceOutputPrivate *priv = output->priv; + PinosSourceOutput *output = user_data; + PinosSourceOutputPrivate *priv = output->priv; GUnixFDList *fdlist; gint fd[2]; @@ -212,9 +212,9 @@ no_format: } static void -clear_socket (PvSourceOutput *output) +clear_socket (PinosSourceOutput *output) { - PvSourceOutputPrivate *priv = output->priv; + PinosSourceOutputPrivate *priv = output->priv; g_clear_object (&priv->socket); g_clear_pointer (&priv->requested_format, g_bytes_unref); @@ -223,9 +223,9 @@ clear_socket (PvSourceOutput *output) static void -stop_transfer (PvSourceOutput *output) +stop_transfer (PinosSourceOutput *output) { - PvSourceOutputPrivate *priv = output->priv; + PinosSourceOutputPrivate *priv = output->priv; if (priv->socket) { clear_socket (output); @@ -234,11 +234,11 @@ stop_transfer (PvSourceOutput *output) } static gboolean -handle_stop (PvSourceOutput1 *interface, +handle_stop (PinosSourceOutput1 *interface, GDBusMethodInvocation *invocation, gpointer user_data) { - PvSourceOutput *output = user_data; + PinosSourceOutput *output = user_data; stop_transfer (output); @@ -248,11 +248,11 @@ handle_stop (PvSourceOutput1 *interface, } static gboolean -handle_remove (PvSourceOutput1 *interface, +handle_remove (PinosSourceOutput1 *interface, GDBusMethodInvocation *invocation, gpointer user_data) { - PvSourceOutput *output = user_data; + PinosSourceOutput *output = user_data; stop_transfer (output); @@ -264,46 +264,47 @@ handle_remove (PvSourceOutput1 *interface, } static void -output_register_object (PvSourceOutput *output, const gchar *prefix) +output_register_object (PinosSourceOutput *output, + const gchar *prefix) { - PvSourceOutputPrivate *priv = output->priv; - PvObjectSkeleton *skel; + PinosSourceOutputPrivate *priv = output->priv; + PinosObjectSkeleton *skel; gchar *name; name = g_strdup_printf ("%s/output", prefix); - skel = pv_object_skeleton_new (name); + skel = pinos_object_skeleton_new (name); g_free (name); - pv_object_skeleton_set_source_output1 (skel, priv->iface); + pinos_object_skeleton_set_source_output1 (skel, priv->iface); g_free (priv->object_path); - priv->object_path = pv_daemon_export_uniquely (priv->daemon, G_DBUS_OBJECT_SKELETON (skel)); + priv->object_path = pinos_daemon_export_uniquely (priv->daemon, G_DBUS_OBJECT_SKELETON (skel)); } static void -output_unregister_object (PvSourceOutput *output) +output_unregister_object (PinosSourceOutput *output) { - PvSourceOutputPrivate *priv = output->priv; + PinosSourceOutputPrivate *priv = output->priv; - pv_daemon_unexport (priv->daemon, priv->object_path); + pinos_daemon_unexport (priv->daemon, priv->object_path); } static void -pv_source_output_dispose (GObject * object) +pinos_source_output_dispose (GObject * object) { - PvSourceOutput *output = PV_SOURCE_OUTPUT (object); + PinosSourceOutput *output = PINOS_SOURCE_OUTPUT (object); clear_socket (output); output_unregister_object (output); - G_OBJECT_CLASS (pv_source_output_parent_class)->dispose (object); + G_OBJECT_CLASS (pinos_source_output_parent_class)->dispose (object); } static void -pv_source_output_finalize (GObject * object) +pinos_source_output_finalize (GObject * object) { - PvSourceOutput *output = PV_SOURCE_OUTPUT (object); - PvSourceOutputPrivate *priv = output->priv; + PinosSourceOutput *output = PINOS_SOURCE_OUTPUT (object); + PinosSourceOutputPrivate *priv = output->priv; g_clear_object (&priv->daemon); g_clear_object (&priv->iface); @@ -311,39 +312,39 @@ pv_source_output_finalize (GObject * object) g_free (priv->object_path); g_free (priv->source_path); - G_OBJECT_CLASS (pv_source_output_parent_class)->finalize (object); + G_OBJECT_CLASS (pinos_source_output_parent_class)->finalize (object); } static void -pv_source_output_constructed (GObject * object) +pinos_source_output_constructed (GObject * object) { - PvSourceOutput *output = PV_SOURCE_OUTPUT (object); - PvSourceOutputPrivate *priv = output->priv; + PinosSourceOutput *output = PINOS_SOURCE_OUTPUT (object); + PinosSourceOutputPrivate *priv = output->priv; output_register_object (output, priv->object_path); - G_OBJECT_CLASS (pv_source_output_parent_class)->constructed (object); + G_OBJECT_CLASS (pinos_source_output_parent_class)->constructed (object); } static void -pv_source_output_class_init (PvSourceOutputClass * klass) +pinos_source_output_class_init (PinosSourceOutputClass * klass) { GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - g_type_class_add_private (klass, sizeof (PvSourceOutputPrivate)); + g_type_class_add_private (klass, sizeof (PinosSourceOutputPrivate)); - gobject_class->constructed = pv_source_output_constructed; - gobject_class->dispose = pv_source_output_dispose; - gobject_class->finalize = pv_source_output_finalize; - gobject_class->set_property = pv_source_output_set_property; - gobject_class->get_property = pv_source_output_get_property; + gobject_class->constructed = pinos_source_output_constructed; + gobject_class->dispose = pinos_source_output_dispose; + gobject_class->finalize = pinos_source_output_finalize; + gobject_class->set_property = pinos_source_output_set_property; + gobject_class->get_property = pinos_source_output_get_property; g_object_class_install_property (gobject_class, PROP_DAEMON, g_param_spec_object ("daemon", "Daemon", "The Daemon", - PV_TYPE_DAEMON, + PINOS_TYPE_DAEMON, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS)); @@ -427,18 +428,18 @@ pv_source_output_class_init (PvSourceOutputClass * klass) } static void -pv_source_output_init (PvSourceOutput * output) +pinos_source_output_init (PinosSourceOutput * output) { - PvSourceOutputPrivate *priv = output->priv = PV_SOURCE_OUTPUT_GET_PRIVATE (output); + PinosSourceOutputPrivate *priv = output->priv = PINOS_SOURCE_OUTPUT_GET_PRIVATE (output); - priv->iface = pv_source_output1_skeleton_new (); + priv->iface = pinos_source_output1_skeleton_new (); g_signal_connect (priv->iface, "handle-start", (GCallback) handle_start, output); g_signal_connect (priv->iface, "handle-stop", (GCallback) handle_stop, output); g_signal_connect (priv->iface, "handle-remove", (GCallback) handle_remove, output); } void -pv_source_output_remove (PvSourceOutput *output) +pinos_source_output_remove (PinosSourceOutput *output) { stop_transfer (output); @@ -446,11 +447,11 @@ pv_source_output_remove (PvSourceOutput *output) } const gchar * -pv_source_output_get_object_path (PvSourceOutput *output) +pinos_source_output_get_object_path (PinosSourceOutput *output) { - PvSourceOutputPrivate *priv; + PinosSourceOutputPrivate *priv; - g_return_val_if_fail (PV_IS_SOURCE_OUTPUT (output), NULL); + g_return_val_if_fail (PINOS_IS_SOURCE_OUTPUT (output), NULL); priv = output->priv; return priv->object_path; diff --git a/src/server/source-output.h b/src/server/source-output.h new file mode 100644 index 00000000..6c66fd4a --- /dev/null +++ b/src/server/source-output.h @@ -0,0 +1,70 @@ +/* Pinos + * Copyright (C) 2015 Wim Taymans <wim.taymans@gmail.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef __PINOS_SOURCE_OUTPUT_H__ +#define __PINOS_SOURCE_OUTPUT_H__ + +#include <glib-object.h> + +G_BEGIN_DECLS + +#define PINOS_TYPE_SOURCE_OUTPUT (pinos_source_output_get_type ()) +#define PINOS_IS_SOURCE_OUTPUT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PINOS_TYPE_SOURCE_OUTPUT)) +#define PINOS_IS_SOURCE_OUTPUT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PINOS_TYPE_SOURCE_OUTPUT)) +#define PINOS_SOURCE_OUTPUT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PINOS_TYPE_SOURCE_OUTPUT, PinosSourceOutputClass)) +#define PINOS_SOURCE_OUTPUT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PINOS_TYPE_SOURCE_OUTPUT, PinosSourceOutput)) +#define PINOS_SOURCE_OUTPUT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PINOS_TYPE_SOURCE_OUTPUT, PinosSourceOutputClass)) +#define PINOS_SOURCE_OUTPUT_CAST(obj) ((PinosSourceOutput*)(obj)) +#define PINOS_SOURCE_OUTPUT_CLASS_CAST(klass) ((PinosSourceOutputClass*)(klass)) + +typedef struct _PinosSourceOutput PinosSourceOutput; +typedef struct _PinosSourceOutputClass PinosSourceOutputClass; +typedef struct _PinosSourceOutputPrivate PinosSourceOutputPrivate; + +/** + * PinosSourceOutput: + * + * Pinos source output object class. + */ +struct _PinosSourceOutput { + GObject object; + + PinosSourceOutputPrivate *priv; +}; + +/** + * PinosSourceOutputClass: + * + * Pinos source output object class. + */ +struct _PinosSourceOutputClass { + GObjectClass parent_class; +}; + +/* normal GObject stuff */ +GType pinos_source_output_get_type (void); + +void pinos_source_output_remove (PinosSourceOutput *output); + +const gchar * pinos_source_output_get_object_path (PinosSourceOutput *output); + +G_END_DECLS + +#endif /* __PINOS_SOURCE_OUTPUT_H__ */ + diff --git a/src/server/pv-source.c b/src/server/source.c index 7647c22b..d66c4e4a 100644 --- a/src/server/pv-source.c +++ b/src/server/source.c @@ -20,33 +20,33 @@ #include <gio/gio.h> #include "client/pinos.h" -#include "client/pv-enumtypes.h" +#include "client/enumtypes.h" -#include "server/pv-source.h" -#include "server/pv-daemon.h" +#include "server/source.h" +#include "server/daemon.h" #include "dbus/org-pinos.h" -#define PV_SOURCE_GET_PRIVATE(obj) \ - (G_TYPE_INSTANCE_GET_PRIVATE ((obj), PV_TYPE_SOURCE, PvSourcePrivate)) +#define PINOS_SOURCE_GET_PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE ((obj), PINOS_TYPE_SOURCE, PinosSourcePrivate)) -struct _PvSourcePrivate +struct _PinosSourcePrivate { - PvDaemon *daemon; - PvSource1 *iface; + PinosDaemon *daemon; + PinosSource1 *iface; gchar *object_path; gchar *name; GVariant *properties; - PvSourceState state; + PinosSourceState state; GError *error; GList *outputs; }; -G_DEFINE_ABSTRACT_TYPE (PvSource, pv_source, G_TYPE_OBJECT); +G_DEFINE_ABSTRACT_TYPE (PinosSource, pinos_source, G_TYPE_OBJECT); enum { @@ -59,13 +59,13 @@ enum }; static void -pv_source_get_property (GObject *_object, - guint prop_id, - GValue *value, - GParamSpec *pspec) +pinos_source_get_property (GObject *_object, + guint prop_id, + GValue *value, + GParamSpec *pspec) { - PvSource *source = PV_SOURCE (_object); - PvSourcePrivate *priv = source->priv; + PinosSource *source = PINOS_SOURCE (_object); + PinosSourcePrivate *priv = source->priv; switch (prop_id) { case PROP_DAEMON: @@ -95,13 +95,13 @@ pv_source_get_property (GObject *_object, } static void -pv_source_set_property (GObject *_object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) +pinos_source_set_property (GObject *_object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) { - PvSource *source = PV_SOURCE (_object); - PvSourcePrivate *priv = source->priv; + PinosSource *source = PINOS_SOURCE (_object); + PinosSourcePrivate *priv = source->priv; switch (prop_id) { case PROP_DAEMON: @@ -131,124 +131,130 @@ pv_source_set_property (GObject *_object, } static void -source_register_object (PvSource *source) +source_register_object (PinosSource *source) { - PvSourcePrivate *priv = source->priv; - PvDaemon *daemon = priv->daemon; - PvObjectSkeleton *skel; + PinosSourcePrivate *priv = source->priv; + PinosDaemon *daemon = priv->daemon; + PinosObjectSkeleton *skel; - skel = pv_object_skeleton_new (PV_DBUS_OBJECT_SOURCE); + skel = pinos_object_skeleton_new (PINOS_DBUS_OBJECT_SOURCE); - priv->iface = pv_source1_skeleton_new (); + priv->iface = pinos_source1_skeleton_new (); g_object_set (priv->iface, "name", priv->name, "state", priv->state, "properties", priv->properties, NULL); - pv_object_skeleton_set_source1 (skel, priv->iface); + pinos_object_skeleton_set_source1 (skel, priv->iface); g_free (priv->object_path); - priv->object_path = pv_daemon_export_uniquely (daemon, G_DBUS_OBJECT_SKELETON (skel)); - pv_daemon_add_source (daemon, source); + priv->object_path = pinos_daemon_export_uniquely (daemon, G_DBUS_OBJECT_SKELETON (skel)); + pinos_daemon_add_source (daemon, source); return; } static void -source_unregister_object (PvSource *source) +source_unregister_object (PinosSource *source) { - PvSourcePrivate *priv = source->priv; + PinosSourcePrivate *priv = source->priv; - pv_daemon_remove_source (priv->daemon, source); - pv_daemon_unexport (priv->daemon, priv->object_path); + pinos_daemon_remove_source (priv->daemon, source); + pinos_daemon_unexport (priv->daemon, priv->object_path); g_clear_object (&priv->iface); } static void -pv_source_constructed (GObject * object) +pinos_source_constructed (GObject * object) { - PvSource *source = PV_SOURCE (object); + PinosSource *source = PINOS_SOURCE (object); source_register_object (source); - G_OBJECT_CLASS (pv_source_parent_class)->constructed (object); + G_OBJECT_CLASS (pinos_source_parent_class)->constructed (object); } static void -do_remove_output (PvSourceOutput *output, +do_remove_output (PinosSourceOutput *output, gpointer user_data) { - pv_source_output_remove (output); + pinos_source_output_remove (output); } static void -pv_source_dispose (GObject * object) +pinos_source_dispose (GObject * object) { - PvSource *source = PV_SOURCE (object); - PvSourcePrivate *priv = source->priv; + PinosSource *source = PINOS_SOURCE (object); + PinosSourcePrivate *priv = source->priv; g_list_foreach (priv->outputs, (GFunc) do_remove_output, source); source_unregister_object (source); - G_OBJECT_CLASS (pv_source_parent_class)->dispose (object); + G_OBJECT_CLASS (pinos_source_parent_class)->dispose (object); } static void -pv_source_finalize (GObject * object) +pinos_source_finalize (GObject * object) { - PvSource *source = PV_SOURCE (object); - PvSourcePrivate *priv = source->priv; + PinosSource *source = PINOS_SOURCE (object); + PinosSourcePrivate *priv = source->priv; g_free (priv->object_path); g_free (priv->name); if (priv->properties) g_variant_unref (priv->properties); - G_OBJECT_CLASS (pv_source_parent_class)->finalize (object); + G_OBJECT_CLASS (pinos_source_parent_class)->finalize (object); } static gboolean -default_set_state (PvSource *source, PvSourceState state) +default_set_state (PinosSource *source, + PinosSourceState state) { - pv_source_update_state (source, state); + pinos_source_update_state (source, state); return TRUE; } static void -handle_remove_output (PvSourceOutput *output, - gpointer user_data) +handle_remove_output (PinosSourceOutput *output, + gpointer user_data) { - PvSource *source = user_data; + PinosSource *source = user_data; - pv_source_release_source_output (source, output); + pinos_source_release_source_output (source, output); } -static PvSourceOutput * -default_create_source_output (PvSource *source, +static PinosSourceOutput * +default_create_source_output (PinosSource *source, const gchar *client_path, GBytes *format_filter, const gchar *prefix, GError **error) { - PvSourcePrivate *priv = source->priv; - PvSourceOutput *output; + PinosSourcePrivate *priv = source->priv; + PinosSourceOutput *output; - output = g_object_new (PV_TYPE_SOURCE_OUTPUT, "daemon", priv->daemon, - "object-path", prefix, - "client-path", client_path, - "source-path", priv->object_path, - "possible-formats", format_filter, - NULL); + output = g_object_new (PINOS_TYPE_SOURCE_OUTPUT, "daemon", priv->daemon, + "object-path", prefix, + "client-path", client_path, + "source-path", priv->object_path, + "possible-formats", format_filter, + NULL); + + g_signal_connect (output, + "remove", + (GCallback) handle_remove_output, + source); - g_signal_connect (output, "remove", (GCallback) handle_remove_output, source); priv->outputs = g_list_prepend (priv->outputs, output); return g_object_ref (output); } static gboolean -default_release_source_output (PvSource *source, PvSourceOutput *output) +default_release_source_output (PinosSource *source, + PinosSourceOutput *output) { - PvSourcePrivate *priv = source->priv; + PinosSourcePrivate *priv = source->priv; GList *find; find = g_list_find (priv->outputs, output); @@ -262,24 +268,24 @@ default_release_source_output (PvSource *source, PvSourceOutput *output) } static void -pv_source_class_init (PvSourceClass * klass) +pinos_source_class_init (PinosSourceClass * klass) { GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - g_type_class_add_private (klass, sizeof (PvSourcePrivate)); + g_type_class_add_private (klass, sizeof (PinosSourcePrivate)); - gobject_class->constructed = pv_source_constructed; - gobject_class->dispose = pv_source_dispose; - gobject_class->finalize = pv_source_finalize; - gobject_class->set_property = pv_source_set_property; - gobject_class->get_property = pv_source_get_property; + gobject_class->constructed = pinos_source_constructed; + gobject_class->dispose = pinos_source_dispose; + gobject_class->finalize = pinos_source_finalize; + gobject_class->set_property = pinos_source_set_property; + gobject_class->get_property = pinos_source_get_property; g_object_class_install_property (gobject_class, PROP_DAEMON, g_param_spec_object ("daemon", "Daemon", "The Daemon", - PV_TYPE_DAEMON, + PINOS_TYPE_DAEMON, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS)); @@ -308,8 +314,8 @@ pv_source_class_init (PvSourceClass * klass) g_param_spec_enum ("state", "State", "The state of the source", - PV_TYPE_SOURCE_STATE, - PV_SOURCE_STATE_INIT, + PINOS_TYPE_SOURCE_STATE, + PINOS_SOURCE_STATE_INIT, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); @@ -330,20 +336,21 @@ pv_source_class_init (PvSourceClass * klass) } static void -pv_source_init (PvSource * source) +pinos_source_init (PinosSource * source) { - source->priv = PV_SOURCE_GET_PRIVATE (source); + source->priv = PINOS_SOURCE_GET_PRIVATE (source); } GBytes * -pv_source_get_formats (PvSource *source, GBytes *filter) +pinos_source_get_formats (PinosSource *source, + GBytes *filter) { - PvSourceClass *klass; + PinosSourceClass *klass; GBytes *res; - g_return_val_if_fail (PV_IS_SOURCE (source), NULL); + g_return_val_if_fail (PINOS_IS_SOURCE (source), NULL); - klass = PV_SOURCE_GET_CLASS (source); + klass = PINOS_SOURCE_GET_CLASS (source); if (klass->get_formats) res = klass->get_formats (source, filter); @@ -354,14 +361,15 @@ pv_source_get_formats (PvSource *source, GBytes *filter) } gboolean -pv_source_set_state (PvSource *source, PvSourceState state) +pinos_source_set_state (PinosSource *source, + PinosSourceState state) { - PvSourceClass *klass; + PinosSourceClass *klass; gboolean res; - g_return_val_if_fail (PV_IS_SOURCE (source), FALSE); + g_return_val_if_fail (PINOS_IS_SOURCE (source), FALSE); - klass = PV_SOURCE_GET_CLASS (source); + klass = PINOS_SOURCE_GET_CLASS (source); if (klass->set_state) res = klass->set_state (source, state); @@ -372,47 +380,49 @@ pv_source_set_state (PvSource *source, PvSourceState state) } void -pv_source_update_state (PvSource *source, PvSourceState state) +pinos_source_update_state (PinosSource *source, + PinosSourceState state) { - PvSourcePrivate *priv; + PinosSourcePrivate *priv; - g_return_if_fail (PV_IS_SOURCE (source)); + g_return_if_fail (PINOS_IS_SOURCE (source)); priv = source->priv; if (priv->state != state) { priv->state = state; - pv_source1_set_state (priv->iface, state); + pinos_source1_set_state (priv->iface, state); g_object_notify (G_OBJECT (source), "state"); } } void -pv_source_report_error (PvSource *source, GError *error) +pinos_source_report_error (PinosSource *source, + GError *error) { - PvSourcePrivate *priv; + PinosSourcePrivate *priv; - g_return_if_fail (PV_IS_SOURCE (source)); + g_return_if_fail (PINOS_IS_SOURCE (source)); priv = source->priv; g_clear_error (&priv->error); priv->error = error; - priv->state = PV_SOURCE_STATE_ERROR; + priv->state = PINOS_SOURCE_STATE_ERROR; g_object_notify (G_OBJECT (source), "state"); } -PvSourceOutput * -pv_source_create_source_output (PvSource *source, - const gchar *client_path, - GBytes *format_filter, - const gchar *prefix, - GError **error) +PinosSourceOutput * +pinos_source_create_source_output (PinosSource *source, + const gchar *client_path, + GBytes *format_filter, + const gchar *prefix, + GError **error) { - PvSourceClass *klass; - PvSourceOutput *res; + PinosSourceClass *klass; + PinosSourceOutput *res; - g_return_val_if_fail (PV_IS_SOURCE (source), NULL); + g_return_val_if_fail (PINOS_IS_SOURCE (source), NULL); - klass = PV_SOURCE_GET_CLASS (source); + klass = PINOS_SOURCE_GET_CLASS (source); if (klass->create_source_output) { res = klass->create_source_output (source, client_path, format_filter, prefix, error); @@ -429,15 +439,16 @@ pv_source_create_source_output (PvSource *source, } gboolean -pv_source_release_source_output (PvSource *source, PvSourceOutput *output) +pinos_source_release_source_output (PinosSource *source, + PinosSourceOutput *output) { - PvSourceClass *klass; + PinosSourceClass *klass; gboolean res; - g_return_val_if_fail (PV_IS_SOURCE (source), FALSE); - g_return_val_if_fail (PV_IS_SOURCE_OUTPUT (output), FALSE); + g_return_val_if_fail (PINOS_IS_SOURCE (source), FALSE); + g_return_val_if_fail (PINOS_IS_SOURCE_OUTPUT (output), FALSE); - klass = PV_SOURCE_GET_CLASS (source); + klass = PINOS_SOURCE_GET_CLASS (source); if (klass->release_source_output) res = klass->release_source_output (source, output); @@ -448,11 +459,11 @@ pv_source_release_source_output (PvSource *source, PvSourceOutput *output) } const gchar * -pv_source_get_object_path (PvSource *source) +pinos_source_get_object_path (PinosSource *source) { - PvSourcePrivate *priv; + PinosSourcePrivate *priv; - g_return_val_if_fail (PV_IS_SOURCE (source), NULL); + g_return_val_if_fail (PINOS_IS_SOURCE (source), NULL); priv = source->priv; return priv->object_path; diff --git a/src/server/source.h b/src/server/source.h new file mode 100644 index 00000000..05b6b7c6 --- /dev/null +++ b/src/server/source.h @@ -0,0 +1,102 @@ +/* Pinos + * Copyright (C) 2015 Wim Taymans <wim.taymans@gmail.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef __PINOS_SOURCE_H__ +#define __PINOS_SOURCE_H__ + +#include <glib-object.h> +#include <gio/gio.h> + +G_BEGIN_DECLS + +typedef struct _PinosSource PinosSource; +typedef struct _PinosSourceClass PinosSourceClass; +typedef struct _PinosSourcePrivate PinosSourcePrivate; + +#include "client/introspect.h" +#include "server/source-output.h" + +#define PINOS_TYPE_SOURCE (pinos_source_get_type ()) +#define PINOS_IS_SOURCE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PINOS_TYPE_SOURCE)) +#define PINOS_IS_SOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PINOS_TYPE_SOURCE)) +#define PINOS_SOURCE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PINOS_TYPE_SOURCE, PinosSourceClass)) +#define PINOS_SOURCE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PINOS_TYPE_SOURCE, PinosSource)) +#define PINOS_SOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PINOS_TYPE_SOURCE, PinosSourceClass)) +#define PINOS_SOURCE_CAST(obj) ((PinosSource*)(obj)) +#define PINOS_SOURCE_CLASS_CAST(klass) ((PinosSourceClass*)(klass)) + +/** + * PinosSource: + * + * Pinos source object class. + */ +struct _PinosSource { + GObject object; + + PinosSourcePrivate *priv; +}; + +/** + * PinosSourceClass: + * @get_formats: called to get a list of supported formats from the source + * @set_state: called to change the current state of the source + * @create_source_output: called to create a new source-output object + * @release_source_output: called to release a source-output object + * + * Pinos source object class. + */ +struct _PinosSourceClass { + GObjectClass parent_class; + + GBytes * (*get_formats) (PinosSource *source, GBytes *filter); + + gboolean (*set_state) (PinosSource *source, PinosSourceState); + + PinosSourceOutput * (*create_source_output) (PinosSource *source, + const gchar *client_path, + GBytes *format_filter, + const gchar *prefix, + GError **error); + gboolean (*release_source_output) (PinosSource *source, + PinosSourceOutput *output); +}; + +/* normal GObject stuff */ +GType pinos_source_get_type (void); + +const gchar * pinos_source_get_object_path (PinosSource *source); + +GBytes * pinos_source_get_formats (PinosSource *source, GBytes *filter); + +gboolean pinos_source_set_state (PinosSource *source, PinosSourceState state); +void pinos_source_update_state (PinosSource *source, PinosSourceState state); +void pinos_source_report_error (PinosSource *source, GError *error); + +PinosSourceOutput * pinos_source_create_source_output (PinosSource *source, + const gchar *client_path, + GBytes *format_filter, + const gchar *prefix, + GError **error); +gboolean pinos_source_release_source_output (PinosSource *source, + PinosSourceOutput *output); + +G_END_DECLS + +#endif /* __PINOS_SOURCE_H__ */ + diff --git a/src/tests/test-client.c b/src/tests/test-client.c index 8a1b096a..bde8b525 100644 --- a/src/tests/test-client.c +++ b/src/tests/test-client.c @@ -38,7 +38,7 @@ on_socket_notify (GObject *gobject, GstCaps *caps; GError *error = NULL; - pipeline = gst_parse_launch ("socketsrc name=src ! pvfddepay ! capsfilter name=filter ! videoconvert ! xvimagesink", &error); + pipeline = gst_parse_launch ("socketsrc name=src ! pinosfddepay ! capsfilter name=filter ! videoconvert ! xvimagesink", &error); if (error != NULL) { g_warning ("error creating pipeline: %s", error->message); g_clear_error (&error); @@ -68,18 +68,18 @@ on_stream_notify (GObject *gobject, GParamSpec *pspec, gpointer user_data) { - PvStreamState state; - PvStream *s = user_data; + PinosStreamState state; + PinosStream *s = user_data; g_object_get (gobject, "state", &state, NULL); g_print ("got stream state %d\n", state); switch (state) { - case PV_STREAM_STATE_ERROR: + case PINOS_STREAM_STATE_ERROR: g_main_loop_quit (loop); break; - case PV_STREAM_STATE_READY: + case PINOS_STREAM_STATE_READY: { GBytes *possible, *format; GstCaps *caps; @@ -106,12 +106,12 @@ on_stream_notify (GObject *gobject, gst_caps_unref (caps); format = g_bytes_new_static (str, strlen (str) + 1); - pv_stream_start (s, format, PV_STREAM_MODE_SOCKET); + pinos_stream_start (s, format, PINOS_STREAM_MODE_SOCKET); g_bytes_unref (format); break; } - case PV_STREAM_STATE_STREAMING: + case PINOS_STREAM_STATE_STREAMING: break; default: @@ -124,27 +124,27 @@ on_state_notify (GObject *gobject, GParamSpec *pspec, gpointer user_data) { - PvContextState state; - PvContext *c = user_data; + PinosContextState state; + PinosContext *c = user_data; g_object_get (gobject, "state", &state, NULL); g_print ("got context state %d\n", state); switch (state) { - case PV_CONTEXT_STATE_ERROR: + case PINOS_CONTEXT_STATE_ERROR: g_main_loop_quit (loop); break; - case PV_CONTEXT_STATE_READY: + case PINOS_CONTEXT_STATE_READY: { - PvStream *stream; + PinosStream *stream; GBytes *format; - stream = pv_stream_new (c, "test", NULL); + stream = pinos_stream_new (c, "test", NULL); g_signal_connect (stream, "notify::state", (GCallback) on_stream_notify, stream); g_signal_connect (stream, "notify::socket", (GCallback) on_socket_notify, stream); format = g_bytes_new_static (ANY_CAPS, strlen (ANY_CAPS) + 1); - pv_stream_connect_capture (stream, NULL, 0, format); + pinos_stream_connect_capture (stream, NULL, 0, format); g_bytes_unref (format); break; } @@ -156,15 +156,15 @@ on_state_notify (GObject *gobject, gint main (gint argc, gchar *argv[]) { - PvContext *c; + PinosContext *c; - pv_init (&argc, &argv); + pinos_init (&argc, &argv); loop = g_main_loop_new (NULL, FALSE); - c = pv_context_new (NULL, "test-client", NULL); + c = pinos_context_new (NULL, "test-client", NULL); g_signal_connect (c, "notify::state", (GCallback) on_state_notify, c); - pv_context_connect(c, PV_CONTEXT_FLAGS_NONE); + pinos_context_connect(c, PINOS_CONTEXT_FLAGS_NONE); g_main_loop_run (loop); diff --git a/src/tests/test-subscribe.c b/src/tests/test-subscribe.c index f230b525..a0a81423 100644 --- a/src/tests/test-subscribe.c +++ b/src/tests/test-subscribe.c @@ -30,21 +30,21 @@ dump_object (GDBusProxy *proxy) } static void -subscription_cb (PvContext *context, PvSubscriptionEvent type, PvSubscriptionFlags flags, +subscription_cb (PinosContext *context, PinosSubscriptionEvent type, PinosSubscriptionFlags flags, GDBusProxy *object, gpointer user_data) { switch (type) { - case PV_SUBSCRIPTION_EVENT_NEW: + case PINOS_SUBSCRIPTION_EVENT_NEW: g_print ("object added %s\n", g_dbus_proxy_get_object_path (object)); dump_object (object); break; - case PV_SUBSCRIPTION_EVENT_CHANGE: + case PINOS_SUBSCRIPTION_EVENT_CHANGE: g_print ("object changed %s\n", g_dbus_proxy_get_object_path (object)); dump_object (object); break; - case PV_SUBSCRIPTION_EVENT_REMOVE: + case PINOS_SUBSCRIPTION_EVENT_REMOVE: g_print ("object removed %s\n", g_dbus_proxy_get_object_path (object)); break; } @@ -55,17 +55,17 @@ on_state_notify (GObject *gobject, GParamSpec *pspec, gpointer user_data) { - PvContextState state; + PinosContextState state; g_object_get (gobject, "state", &state, NULL); g_print ("got context state %d\n", state); switch (state) { - case PV_CONTEXT_STATE_ERROR: + case PINOS_CONTEXT_STATE_ERROR: g_main_loop_quit (loop); break; - case PV_CONTEXT_STATE_READY: + case PINOS_CONTEXT_STATE_READY: break; default: @@ -76,17 +76,17 @@ on_state_notify (GObject *gobject, gint main (gint argc, gchar *argv[]) { - PvContext *c; + PinosContext *c; - pv_init (&argc, &argv); + pinos_init (&argc, &argv); loop = g_main_loop_new (NULL, FALSE); - c = pv_context_new (NULL, "test-client", NULL); + c = pinos_context_new (NULL, "test-client", NULL); g_signal_connect (c, "notify::state", (GCallback) on_state_notify, c); - g_object_set (c, "subscription-mask", PV_SUBSCRIPTION_FLAGS_ALL, NULL); + g_object_set (c, "subscription-mask", PINOS_SUBSCRIPTION_FLAGS_ALL, NULL); g_signal_connect (c, "subscription-event", (GCallback) subscription_cb, NULL); - pv_context_connect(c, PV_CONTEXT_FLAGS_NOFAIL); + pinos_context_connect(c, PINOS_CONTEXT_FLAGS_NOFAIL); g_main_loop_run (loop); |