[rygel-gst-0-10-media-engine] Get rid of other _construct functions.



commit 5c800fdd819f42643bfb438a36835946a07c7b78
Author: Krzesimir Nowak <qdlacz gmail com>
Date:   Wed Jan 9 20:11:48 2013 +0100

    Get rid of other _construct functions.

 src/rygel-gst-data-source.c  |   87 +++++++++++++++++++--------
 src/rygel-gst-media-engine.c |  118 +++++++++++++++++--------------------
 src/rygel-gst-sink.c         |  133 ++++++++++++++++++++++++++++++-----------
 src/rygel-gst-sink.h         |    6 +-
 tests/test_simple.c          |    3 +-
 5 files changed, 218 insertions(+), 129 deletions(-)
---
diff --git a/src/rygel-gst-data-source.c b/src/rygel-gst-data-source.c
index febe1b6..caa23ae 100644
--- a/src/rygel-gst-data-source.c
+++ b/src/rygel-gst-data-source.c
@@ -26,10 +26,17 @@
 #include <glib/gi18n-lib.h>
 
 static void rygel_gst_data_source_rygel_data_source_interface_init (RygelDataSourceIface *iface);
+static void rygel_gst_data_source_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec);
+static void rygel_gst_data_source_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec);
 
 G_DEFINE_TYPE_WITH_CODE (RygelGstDataSource, rygel_gst_data_source, G_TYPE_OBJECT,
   G_IMPLEMENT_INTERFACE (RYGEL_TYPE_DATA_SOURCE, rygel_gst_data_source_rygel_data_source_interface_init))
 
+enum  {
+  RYGEL_GST_DATA_SOURCE_DUMMY_PROPERTY,
+  RYGEL_GST_DATA_SOURCE_SOURCE
+};
+
 typedef enum  {
   RYGEL_GST_DATA_SOURCE_ERROR_NOT_COMPATIBLE
 } RygelGstDataSourceError;
@@ -71,40 +78,32 @@ GQuark rygel_gst_data_source_error_quark (void) {
   return g_quark_from_static_string ("rygel_gst_data_source_error-quark");
 }
 
+RygelGstDataSource *
+rygel_gst_data_source_new (const gchar *uri, GError **error) {
+  GstElement *source = rygel_gst_utils_create_source_for_uri (uri);
+  RygelGstDataSource *data_source;
 
-RygelGstDataSource*
-rygel_gst_data_source_construct (GType object_type, const gchar *uri, GError **error) {
-  RygelGstDataSource *self = RYGEL_GST_DATA_SOURCE (g_object_new (object_type, NULL));
-
-  self->priv->src = rygel_gst_utils_create_source_for_uri (uri);
-  if (self->priv->src == NULL) {
+  if (source == NULL) {
     g_set_error (error,
-      RYGEL_GST_DATA_SOURCE_ERROR,
-      RYGEL_GST_DATA_SOURCE_ERROR_NOT_COMPATIBLE,
-      "Could not create GstElement for URI %s", uri);
+                 RYGEL_GST_DATA_SOURCE_ERROR,
+                 RYGEL_GST_DATA_SOURCE_ERROR_NOT_COMPATIBLE,
+                 "Could not create GstElement for URI %s",
+                 uri);
+
     return NULL;
   }
 
-  return self;
-}
+  data_source = rygel_gst_data_source_new_from_element (source);
+  gst_object_unref (source);
 
-RygelGstDataSource*
-rygel_gst_data_source_new (const gchar *uri, GError **error) {
-  return rygel_gst_data_source_construct (RYGEL_TYPE_GST_DATA_SOURCE, uri, error);
-}
-
-RygelGstDataSource*
-rygel_gst_data_source_construct_from_element (GType object_type, GstElement* element) {
-  RygelGstDataSource *self = RYGEL_GST_DATA_SOURCE (g_object_new (object_type, NULL));
-
-  self->priv->src = element;
-
-  return self;
+  return data_source;
 }
 
 RygelGstDataSource*
 rygel_gst_data_source_new_from_element (GstElement* element) {
-  return rygel_gst_data_source_construct_from_element (RYGEL_TYPE_GST_DATA_SOURCE, element);
+  return RYGEL_GST_DATA_SOURCE (g_object_new (RYGEL_TYPE_GST_DATA_SOURCE,
+                                              "source", element,
+                                              NULL));
 }
 
 static void
@@ -152,7 +151,7 @@ rygel_gst_data_source_real_stop (RygelDataSource *base) {
   RygelGstDataSource *self = RYGEL_GST_DATA_SOURCE (base);
 
   if (self->priv->sink) {
-    g_cancellable_cancel (self->priv->sink->cancellable);
+    g_cancellable_cancel (rygel_gst_sink_get_cancellable (self->priv->sink));
   }
 
   if (self->priv->pipeline) {
@@ -404,6 +403,9 @@ rygel_gst_data_source_class_init (RygelGstDataSourceClass *klass) {
   rygel_gst_data_source_parent_class = g_type_class_peek_parent (klass);
   g_type_class_add_private (klass, sizeof (RygelGstDataSourcePrivate));
   G_OBJECT_CLASS (klass)->finalize = rygel_gst_data_source_finalize;
+  G_OBJECT_CLASS (klass)->get_property = rygel_gst_data_source_get_property;
+  G_OBJECT_CLASS (klass)->set_property = rygel_gst_data_source_set_property;
+  g_object_class_install_property (G_OBJECT_CLASS (klass), RYGEL_GST_DATA_SOURCE_SOURCE, g_param_spec_object ("source", "souce", "source", GST_TYPE_ELEMENT, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
 }
 
 static void
@@ -426,7 +428,7 @@ rygel_gst_data_source_finalize (GObject* obj) {
   RygelGstDataSource *self = RYGEL_GST_DATA_SOURCE (obj);
 
   if (self->priv->sink) {
-    g_cancellable_cancel (self->priv->sink->cancellable);
+    g_cancellable_cancel (rygel_gst_sink_get_cancellable (self->priv->sink));
   }
 
   if (self->priv->pipeline) {
@@ -456,3 +458,36 @@ rygel_gst_data_source_get_gst_element (RygelGstDataSource *self)
 
   return self->priv->src;
 }
+
+static void
+rygel_gst_data_source_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec) {
+  RygelGstDataSource *self = RYGEL_GST_DATA_SOURCE (object);
+  RygelGstDataSourcePrivate *priv = self->priv;
+
+  switch (property_id) {
+    case RYGEL_GST_DATA_SOURCE_SOURCE:
+      g_value_set_object (value, priv->src);
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+      break;
+  }
+}
+
+static void
+rygel_gst_data_source_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) {
+  RygelGstDataSource *self = RYGEL_GST_DATA_SOURCE (object);
+  RygelGstDataSourcePrivate *priv = self->priv;
+
+  switch (property_id) {
+    case RYGEL_GST_DATA_SOURCE_SOURCE:
+      if (priv->src) {
+        g_object_unref (priv->src);
+      }
+      priv->src = g_value_dup_object (value);
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+      break;
+  }
+}
diff --git a/src/rygel-gst-media-engine.c b/src/rygel-gst-media-engine.c
index e9efc5c..2ac5f7a 100644
--- a/src/rygel-gst-media-engine.c
+++ b/src/rygel-gst-media-engine.c
@@ -40,18 +40,61 @@ struct _RygelGstMediaEnginePrivate {
 
 static void rygel_gst_media_engine_finalize (GObject *obj);
 
-static RygelGstMediaEngine*
-rygel_gst_media_engine_construct (GType object_type) {
-  RygelGstMediaEngine *self = NULL;
+RygelGstMediaEngine*
+rygel_gst_media_engine_new (void) {
+  return RYGEL_GST_MEDIA_ENGINE (g_object_new (RYGEL_TYPE_GST_MEDIA_ENGINE, NULL));
+}
+
+static GList*
+rygel_gst_media_engine_real_get_dlna_profiles (RygelMediaEngine *base) {
+  RygelGstMediaEngine *self = RYGEL_GST_MEDIA_ENGINE (base);
+  return self->priv->dlna_profiles;
+}
+
+static GList*
+rygel_gst_media_engine_real_get_transcoders (RygelMediaEngine *base) {
+  RygelGstMediaEngine *self = RYGEL_GST_MEDIA_ENGINE (base);
+  return self->priv->transcoders;
+}
+
+
+static RygelDataSource*
+rygel_gst_media_engine_real_create_data_source (RygelMediaEngine *base G_GNUC_UNUSED,
+                                                const gchar *uri) {
+  RygelDataSource *result = NULL;
+  GError *error = NULL;
+
+  g_return_val_if_fail (uri != NULL, NULL);
+
+  result = RYGEL_DATA_SOURCE (rygel_gst_data_source_new (uri, &error));
+  if (error) {
+    g_warning ("rygel_gst_data_source_new() failed: %s", error->message);
+    g_error_free (error);
+  }
+
+  return result;
+}
+
+static void
+rygel_gst_media_engine_class_init (RygelGstMediaEngineClass *klass) {
+  g_type_class_add_private (klass, sizeof (RygelGstMediaEnginePrivate));
+  RYGEL_MEDIA_ENGINE_CLASS (klass)->get_dlna_profiles = rygel_gst_media_engine_real_get_dlna_profiles;
+  RYGEL_MEDIA_ENGINE_CLASS (klass)->get_transcoders = rygel_gst_media_engine_real_get_transcoders;
+  RYGEL_MEDIA_ENGINE_CLASS (klass)->create_data_source = rygel_gst_media_engine_real_create_data_source;
+  G_OBJECT_CLASS (klass)->finalize = rygel_gst_media_engine_finalize;
+}
+
+static void
+rygel_gst_media_engine_init (RygelGstMediaEngine *self) {
   GUPnPDLNADiscoverer *discoverer;
   const GList *profile_collection;
   GeeArrayList *transcoder_list = NULL;
   RygelMetaConfig *config;
   GError *error = NULL;
+  const GList *profile_it;
 
-  self = RYGEL_GST_MEDIA_ENGINE (rygel_media_engine_construct (object_type));
+  self->priv = RYGEL_GST_MEDIA_ENGINE_GET_PRIVATE (self);
 
-  gst_init (NULL, NULL);
   gst_preset_set_app_dir (PRESET_DIR);
 
   /* Get the possible DLNA profiles
@@ -64,7 +107,6 @@ rygel_gst_media_engine_construct (GType object_type) {
   discoverer = gupnp_dlna_discoverer_new ((GstClockTime) GST_SECOND, TRUE, FALSE);
   profile_collection = gupnp_dlna_discoverer_list_profiles (discoverer);
 
-  const GList *profile_it = NULL;
   for (profile_it = profile_collection; profile_it != NULL; profile_it = profile_it->next) {
     GUPnPDLNAProfile *profile = GUPNP_DLNA_PROFILE (profile_it->data);
     const gchar *name = gupnp_dlna_profile_get_name (profile);
@@ -74,7 +116,10 @@ rygel_gst_media_engine_construct (GType object_type) {
      * instead of just claiming to support everything.
      */
     RygelDLNAProfile *rygel_profile = rygel_dlna_profile_new (name, mime);
-    self->priv->dlna_profiles = g_list_prepend (self->priv->dlna_profiles, rygel_profile);
+
+    if (rygel_profile) {
+      self->priv->dlna_profiles = g_list_prepend (self->priv->dlna_profiles, rygel_profile);
+    }
   }
 
   self->priv->dlna_profiles = g_list_reverse (self->priv->dlna_profiles);
@@ -153,68 +198,13 @@ rygel_gst_media_engine_construct (GType object_type) {
   g_object_unref (config);
   g_object_unref (transcoder_list);
   g_object_unref (discoverer);
-
-  return self;
-}
-
-RygelGstMediaEngine*
-rygel_gst_media_engine_new (void) {
-  return rygel_gst_media_engine_construct (RYGEL_TYPE_GST_MEDIA_ENGINE);
-}
-
-static GList*
-rygel_gst_media_engine_real_get_dlna_profiles (RygelMediaEngine *base) {
-  RygelGstMediaEngine *self = RYGEL_GST_MEDIA_ENGINE (base);
-  return self->priv->dlna_profiles;
-}
-
-static GList*
-rygel_gst_media_engine_real_get_transcoders (RygelMediaEngine *base) {
-  RygelGstMediaEngine *self = RYGEL_GST_MEDIA_ENGINE (base);
-  return self->priv->transcoders;
-}
-
-
-static RygelDataSource*
-rygel_gst_media_engine_real_create_data_source (RygelMediaEngine *base G_GNUC_UNUSED,
-                                                const gchar *uri) {
-  RygelDataSource *result = NULL;
-  GError *error = NULL;
-
-  g_return_val_if_fail (uri != NULL, NULL);
-
-  result = RYGEL_DATA_SOURCE (rygel_gst_data_source_new (uri, &error));
-  if (error) {
-    g_warning ("rygel_gst_data_source_new() failed: %s", error->message);
-    g_error_free (error);
-  }
-
-  return result;
-}
-
-static void
-rygel_gst_media_engine_class_init (RygelGstMediaEngineClass *klass) {
-  rygel_gst_media_engine_parent_class = g_type_class_peek_parent (klass);
-
-  g_type_class_add_private (klass, sizeof (RygelGstMediaEnginePrivate));
-  RYGEL_MEDIA_ENGINE_CLASS (klass)->get_dlna_profiles = rygel_gst_media_engine_real_get_dlna_profiles;
-  RYGEL_MEDIA_ENGINE_CLASS (klass)->get_transcoders = rygel_gst_media_engine_real_get_transcoders;
-  RYGEL_MEDIA_ENGINE_CLASS (klass)->create_data_source = rygel_gst_media_engine_real_create_data_source;
-  G_OBJECT_CLASS (klass)->finalize = rygel_gst_media_engine_finalize;
-}
-
-static void
-rygel_gst_media_engine_init (RygelGstMediaEngine *self) {
-  self->priv = RYGEL_GST_MEDIA_ENGINE_GET_PRIVATE (self);
-  self->priv->dlna_profiles = NULL;
-  self->priv->transcoders = NULL;
 }
 
 static void
 rygel_gst_media_engine_finalize (GObject *obj) {
   RygelGstMediaEngine *self = RYGEL_GST_MEDIA_ENGINE (obj);
 
-  g_list_free_full (self->priv->dlna_profiles, (GDestroyNotify) g_object_unref);
+  g_list_free_full (self->priv->dlna_profiles, (GDestroyNotify) rygel_dlna_profile_unref);
   g_list_free_full (self->priv->transcoders, (GDestroyNotify) g_object_unref);
 
   G_OBJECT_CLASS (rygel_gst_media_engine_parent_class)->finalize (obj);
@@ -222,5 +212,7 @@ rygel_gst_media_engine_finalize (GObject *obj) {
 
 RygelMediaEngine*
 module_get_instance (void) {
+  gst_init (NULL, NULL);
+
   return RYGEL_MEDIA_ENGINE (rygel_gst_media_engine_new ());
 }
diff --git a/src/rygel-gst-sink.c b/src/rygel-gst-sink.c
index d1b4f40..7ad88f7 100644
--- a/src/rygel-gst-sink.c
+++ b/src/rygel-gst-sink.c
@@ -26,8 +26,16 @@
 
 #include "rygel-gst-sink.h"
 
+
 G_DEFINE_TYPE (RygelGstSink, rygel_gst_sink, GST_TYPE_BASE_SINK)
 
+enum
+{
+  RYGEL_GST_SINK_DUMMY_PROPERTY,
+  RYGEL_GST_SINK_SOURCE,
+  RYGEL_GST_SINK_OFFSETS
+};
+
 struct _RygelGstSinkPrivate {
   gint priority;
   gint64 chunks_buffered;
@@ -38,6 +46,7 @@ struct _RygelGstSinkPrivate {
   RygelDataSource* source;
   RygelHTTPSeek* offsets;
   gboolean frozen;
+  GCancellable* cancellable;
 };
 
 typedef struct _CallbackData CallbackData;
@@ -58,9 +67,12 @@ struct _CallbackData {
 static void rygel_gst_sink_on_cancelled (RygelGstSink* self);
 static void on_cancelled (GCancellable* sender, gpointer user_data);
 static GstFlowReturn rygel_gst_sink_real_render (GstBaseSink *base, GstBuffer* buffer);
-gboolean rygel_gst_sink_push_data (RygelGstSink* self, GstBuffer* buffer);
+static gboolean rygel_gst_sink_push_data (RygelGstSink* self, GstBuffer* buffer);
 static gboolean on_idle_push_data (gpointer self);
 static void rygel_gst_sink_finalize (GObject* obj);
+static void rygel_gst_sink_constructed (GObject* obj);
+static void rygel_gst_sink_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec);
+static void rygel_gst_sink_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec);
 static void clear_gmutex (GMutex *mutex);
 static void clear_gcond (GCond *mutex);
 
@@ -73,34 +85,11 @@ on_cancelled (GCancellable* sender G_GNUC_UNUSED,
 }
 
 RygelGstSink*
-rygel_gst_sink_construct (GType object_type, RygelDataSource* source, RygelHTTPSeek* offsets) {
-  RygelGstSink *self = RYGEL_GST_SINK (g_object_new (object_type, NULL));
-
-  self->priv->chunks_buffered = (gint64) 0;
-  self->priv->bytes_sent = (gint64) 0;
-  self->priv->max_bytes = G_MAXINT64;
-  self->priv->source = source;
-  self->priv->offsets = g_object_ref (offsets);
-
-  self->cancellable = g_cancellable_new ();
-
-  gst_base_sink_set_sync (GST_BASE_SINK (self), FALSE);
-  gst_object_set_name (GST_OBJECT (self), RYGEL_GST_SINK_NAME);
-  self->priv->frozen = FALSE;
-
-  if (self->priv->offsets) {
-    if (rygel_http_seek_get_seek_type (self->priv->offsets) == RYGEL_HTTP_SEEK_TYPE_BYTE) {
-      self->priv->max_bytes = rygel_http_seek_get_length (self->priv->offsets);
-    }
-  }
-
-  g_signal_connect_object (self->cancellable, "cancelled", (GCallback) on_cancelled, self, 0);
-  return self;
-}
-
-RygelGstSink*
 rygel_gst_sink_new (RygelDataSource* source, RygelHTTPSeek* offsets) {
-  return rygel_gst_sink_construct (RYGEL_TYPE_GST_SINK, source, offsets);
+  return RYGEL_GST_SINK (g_object_new (RYGEL_TYPE_GST_SINK,
+                                       "source", source,
+                                       "offsets", offsets,
+                                       NULL));
 }
 
 
@@ -159,14 +148,14 @@ static GstFlowReturn rygel_gst_sink_real_render (GstBaseSink *base, GstBuffer* b
   CallbackData* callback_data;
 
   g_mutex_lock (&self->priv->buffer_mutex);
-  while (!g_cancellable_is_cancelled (self->cancellable) &&
+  while (!g_cancellable_is_cancelled (self->priv->cancellable) &&
     self->priv->frozen) {
     /* Client is either not reading (Paused) or not fast enough */
     g_cond_wait (&self->priv->buffer_condition, &self->priv->buffer_mutex);
   }
   g_mutex_unlock (&self->priv->buffer_mutex);
 
-  if(g_cancellable_is_cancelled (self->cancellable)) {
+  if(g_cancellable_is_cancelled (self->priv->cancellable)) {
     return GST_FLOW_OK;
   }
 
@@ -182,19 +171,19 @@ static GstFlowReturn rygel_gst_sink_real_render (GstBaseSink *base, GstBuffer* b
 }
 
 /* Runs in application thread */
-gboolean
+static gboolean
 rygel_gst_sink_push_data (RygelGstSink* self, GstBuffer* buffer) {
 
   gint64 left = self->priv->max_bytes - self->priv->bytes_sent;
 
-  if(g_cancellable_is_cancelled (self->cancellable) ||
+  if(g_cancellable_is_cancelled (self->priv->cancellable) ||
     left <= 0) {
     return FALSE;
   }
 
   guint bufsize = buffer->size;
   gint64 to_send = MIN ((gint64) bufsize, left);
-  
+
   g_signal_emit_by_name (self->priv->source, "data-available", buffer->data, to_send);
   self->priv->chunks_buffered++;
   self->priv->bytes_sent += to_send;
@@ -215,14 +204,18 @@ rygel_gst_sink_class_init (RygelGstSinkClass *klass) {
   GstCaps* caps;
   GstPadTemplate* template;
 
-  rygel_gst_sink_parent_class = g_type_class_peek_parent (klass);
   g_type_class_add_private (klass, sizeof (RygelGstSinkPrivate));
 
   GST_BASE_SINK_CLASS (klass)->render = rygel_gst_sink_real_render;
   G_OBJECT_CLASS (klass)->finalize = rygel_gst_sink_finalize;
+  G_OBJECT_CLASS (klass)->constructed = rygel_gst_sink_constructed;
+  G_OBJECT_CLASS (klass)->get_property = rygel_gst_sink_get_property;
+  G_OBJECT_CLASS (klass)->set_property = rygel_gst_sink_set_property;
+  g_object_class_install_property (G_OBJECT_CLASS (klass), RYGEL_GST_SINK_SOURCE, g_param_spec_object ("source", "source", "source", RYGEL_TYPE_DATA_SOURCE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_CONSTRUCT_ONLY | G_PARAM_READABLE | G_PARAM_WRITABLE));
+  g_object_class_install_property (G_OBJECT_CLASS (klass), RYGEL_GST_SINK_OFFSETS, g_param_spec_object ("offsets", "offsets", "offsets", RYGEL_TYPE_HTTP_SEEK, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_CONSTRUCT_ONLY | G_PARAM_READABLE | G_PARAM_WRITABLE));
 
   caps = gst_caps_new_any ();
-  template =  gst_pad_template_new (RYGEL_GST_SINK_PAD_NAME, 
+  template =  gst_pad_template_new (RYGEL_GST_SINK_PAD_NAME,
     GST_PAD_SINK, GST_PAD_ALWAYS, caps);
   gst_element_class_add_pad_template (GST_ELEMENT_CLASS (klass), template);
   gst_object_unref (template);
@@ -246,7 +239,7 @@ static void
 rygel_gst_sink_finalize (GObject* obj) {
   RygelGstSink *self = RYGEL_GST_SINK (obj);
 
-  g_object_unref (self->cancellable);
+  g_object_unref (self->priv->cancellable);
   clear_gmutex (&self->priv->buffer_mutex);
   clear_gcond (&self->priv->buffer_condition);
   g_object_unref (self->priv->offsets);
@@ -272,3 +265,71 @@ clear_gcond (GCond *mutex) {
   }
 }
 
+static void
+rygel_gst_sink_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec) {
+  RygelGstSink *self = RYGEL_GST_SINK (object);
+  RygelGstSinkPrivate *priv = self->priv;
+
+  switch (property_id) {
+    case RYGEL_GST_SINK_SOURCE:
+      g_value_set_object (value, priv->source);
+      break;
+    case RYGEL_GST_SINK_OFFSETS:
+      g_value_set_object (value, priv->offsets);
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+      break;
+  }
+}
+
+static void
+rygel_gst_sink_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) {
+  RygelGstSink *self = RYGEL_GST_SINK (object);
+  RygelGstSinkPrivate *priv = self->priv;
+
+  switch (property_id) {
+    case RYGEL_GST_SINK_SOURCE:
+      priv->source = g_value_get_object (value);
+      break;
+    case RYGEL_GST_SINK_OFFSETS:
+      if (priv->offsets) {
+        g_object_unref (priv->offsets);
+      }
+      priv->offsets = g_value_dup_object (value);
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+      break;
+  }
+}
+
+static void rygel_gst_sink_constructed (GObject* object)
+{
+  RygelGstSink *self = RYGEL_GST_SINK (object);
+
+  self->priv->chunks_buffered = (gint64) 0;
+  self->priv->bytes_sent = (gint64) 0;
+  self->priv->max_bytes = G_MAXINT64;
+  self->priv->cancellable = g_cancellable_new ();
+
+  gst_base_sink_set_sync (GST_BASE_SINK (self), FALSE);
+  gst_object_set_name (GST_OBJECT (self), RYGEL_GST_SINK_NAME);
+  self->priv->frozen = FALSE;
+
+  if (self->priv->offsets) {
+    if (rygel_http_seek_get_seek_type (self->priv->offsets) == RYGEL_HTTP_SEEK_TYPE_BYTE) {
+      self->priv->max_bytes = rygel_http_seek_get_length (self->priv->offsets);
+    }
+  }
+
+  g_signal_connect_object (self->priv->cancellable, "cancelled", (GCallback) on_cancelled, self, 0);
+}
+
+GCancellable *
+rygel_gst_sink_get_cancellable (RygelGstSink *sink)
+{
+  g_return_val_if_fail (RYGEL_IS_GST_SINK (sink), NULL);
+
+  return sink->priv->cancellable;
+}
diff --git a/src/rygel-gst-sink.h b/src/rygel-gst-sink.h
index 46dde31..97f962e 100644
--- a/src/rygel-gst-sink.h
+++ b/src/rygel-gst-sink.h
@@ -49,9 +49,6 @@ typedef struct _RygelGstSinkPrivate RygelGstSinkPrivate;
 struct _RygelGstSink {
   GstBaseSink parent_instance;
   RygelGstSinkPrivate *priv;
-
-  /* TODO: Put this in priv? */
-  GCancellable* cancellable;
 };
 
 struct _RygelGstSinkClass {
@@ -70,6 +67,9 @@ rygel_gst_sink_freeze (RygelGstSink* self);
 void
 rygel_gst_sink_thaw (RygelGstSink* self);
 
+GCancellable *
+rygel_gst_sink_get_cancellable (RygelGstSink *sink);
+
 G_END_DECLS
 
 #endif /* __RYGEL_GST_0_10_MEDIA_ENGINE_GST_SINK_H__ */
diff --git a/tests/test_simple.c b/tests/test_simple.c
index 8c8a773..232485d 100644
--- a/tests/test_simple.c
+++ b/tests/test_simple.c
@@ -44,7 +44,8 @@ int main(int argc, char *argv[])
   GList* transcoders = rygel_media_engine_get_transcoders (media_engine);
   g_assert (transcoders);
 
-  g_object_unref (data_source);
+  if (data_source)
+    g_object_unref (data_source);
   g_object_unref (media_engine);
 
   return 0;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]