[rygel-gst-0-10-media-engine] Add rygel_gst_data_source_get_gst_element()



commit 2c1c759bf9cef05e588007086730aa83ef9ff3d6
Author: Murray Cumming <murrayc murrayc com>
Date:   Mon Jan 7 10:46:04 2013 +0100

    Add rygel_gst_data_source_get_gst_element()
    
    And use it instead of non-existant rygel_gst_data_source_get_source().

 src/rygel-gst-data-source.c |   36 +++++++++++++++++++++++++++---------
 src/rygel-gst-data-source.h |    2 +-
 src/rygel-gst-transcoder.c  |    8 ++++++--
 3 files changed, 34 insertions(+), 12 deletions(-)
---
diff --git a/src/rygel-gst-data-source.c b/src/rygel-gst-data-source.c
index c4dd320..cf40632 100644
--- a/src/rygel-gst-data-source.c
+++ b/src/rygel-gst-data-source.c
@@ -36,6 +36,7 @@ typedef enum  {
 #define RYGEL_GST_DATA_SOURCE_ERROR rygel_gst_data_source_error_quark ()
 
 struct _RygelGstDataSourcePrivate {
+  GstElement* src;
   GstPipeline* pipeline;
   RygelHTTPSeek* seek;
   RygelGstSink* sink;
@@ -74,8 +75,8 @@ 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->src = rygel_gst_utils_create_source_for_uri (uri);
-  if (self->src == NULL) {
+  self->priv->src = rygel_gst_utils_create_source_for_uri (uri);
+  if (self->priv->src == NULL) {
     g_set_error (error,
       RYGEL_GST_DATA_SOURCE_ERROR,
       RYGEL_GST_DATA_SOURCE_ERROR_NOT_COMPATIBLE,
@@ -95,7 +96,7 @@ 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->src = element;
+  self->priv->src = element;
 }
 
 RygelGstDataSource*
@@ -109,7 +110,7 @@ rygel_gst_data_source_real_start (RygelDataSource *base, RygelHTTPSeek* offsets,
   GError *inner_error = NULL;
 
   self->priv->seek = offsets;
-  rygel_gst_data_source_prepare_pipeline (self, "RygelGstDataSource", self->src, &inner_error);
+  rygel_gst_data_source_prepare_pipeline (self, "RygelGstDataSource", self->priv->src, &inner_error);
   if (inner_error) {
     g_propagate_error (error, inner_error);
     return;
@@ -317,16 +318,16 @@ rygel_gst_data_source_prepare_pipeline (RygelGstDataSource* self, const gchar *n
       _("Failed to create pipeline"));
   }
 
-  gst_bin_add_many (self->priv->pipeline, self->src, self->priv->sink, NULL);
+  gst_bin_add_many (self->priv->pipeline, self->priv->src, self->priv->sink, NULL);
 
   if (src->numsrcpads == 0) {
     // Seems source uses dynamic pads, so link when the pad is available
 
-    g_signal_connect_object (self->src, "pad-added", (GCallback) on_pad_added, self, 0);
+    g_signal_connect_object (self->priv->src, "pad-added", (GCallback) on_pad_added, self, 0);
   } else {
     // static pads? easy!
-    if (!gst_element_link (self->src, GST_ELEMENT (self->priv->sink))) {
-      gchar *src_name = gst_object_get_name (GST_OBJECT (self->src));
+    if (!gst_element_link (self->priv->src, GST_ELEMENT (self->priv->sink))) {
+      gchar *src_name = gst_object_get_name (GST_OBJECT (self->priv->src));
       gchar *sink_name = gst_object_get_name (GST_OBJECT (self->priv->sink));
       g_set_error (error,
         RYGEL_GST_ERROR,
@@ -430,7 +431,7 @@ rygel_gst_data_source_finalize (GObject* obj) {
     gst_element_set_state (GST_ELEMENT ( self->priv->pipeline), GST_STATE_NULL);
   }
 
-  gst_object_unref (self->src);
+  gst_object_unref (self->priv->src);
   gst_object_unref (self->priv->pipeline);
   g_object_unref (self->priv->seek);
   gst_object_unref (self->priv->sink);
@@ -438,3 +439,20 @@ rygel_gst_data_source_finalize (GObject* obj) {
   G_OBJECT_CLASS (rygel_gst_data_source_parent_class)->finalize (obj);
 }
 
+/**
+ * rygel_gst_data_source_get_gst_element:
+ * @self: A #RygelGstDataSource
+ *
+ * Retrieves the underyling GStreamer element, for use by 
+ * #RygelGstTranscoder's create_element() implementation.
+ *
+ * Return value: a #GstElement
+ */
+GstElement*
+rygel_gst_data_source_get_gst_element (RygelGstDataSource *self)
+{
+  g_return_val_if_fail (self, NULL);
+
+  return self->priv->src;
+}
+
diff --git a/src/rygel-gst-data-source.h b/src/rygel-gst-data-source.h
index 6db2c06..95061fd 100644
--- a/src/rygel-gst-data-source.h
+++ b/src/rygel-gst-data-source.h
@@ -47,7 +47,6 @@ typedef struct _RygelGstDataSourcePrivate RygelGstDataSourcePrivate;
 struct _RygelGstDataSource {
   GObject parent_instance;
   RygelGstDataSourcePrivate *priv;
-  GstElement* src; //TODO: Move this to priv?
 };
 
 struct _RygelGstDataSourceClass {
@@ -58,6 +57,7 @@ GType rygel_gst_data_source_get_type (void) G_GNUC_CONST;
 
 RygelGstDataSource* rygel_gst_data_source_new (const gchar *uri, GError **error);
 
+GstElement* rygel_gst_data_source_get_gst_element (RygelGstDataSource *self);
 
 typedef enum  {
   RYGEL_GST_ERROR_MISSING_PLUGIN,
diff --git a/src/rygel-gst-transcoder.c b/src/rygel-gst-transcoder.c
index ea26599..d683596 100644
--- a/src/rygel-gst-transcoder.c
+++ b/src/rygel-gst-transcoder.c
@@ -135,7 +135,9 @@ rygel_gst_transcoder_create_source (RygelTranscoder *base, RygelMediaItem *item,
   g_return_val_if_fail (item != NULL, NULL);
   g_return_val_if_fail (src != NULL, NULL);
   
-  /* We can only link GStreamer data sources together. */
+  /* We can only link GStreamer data sources together,
+   * so check that the RygelDataSource is of the expected type:
+   */
   g_return_val_if_fail (RYGEL_IS_GST_DATA_SOURCE (src), NULL);
   
   self = RYGEL_GST_TRANSCODER (self);
@@ -176,7 +178,9 @@ rygel_gst_transcoder_create_source (RygelTranscoder *base, RygelMediaItem *item,
   bin = GST_BIN (gst_bin_new ("transcoder-source"));
   gst_object_ref_sink (bin);
   
-  GstElement *element = rygel_gst_data_source_get_source (data_source);
+  /* Use the RygelGstDataSource-specific API to get the underlying Gstreamer element.
+   */ 
+  GstElement *element = rygel_gst_data_source_get_gst_element (data_source);
   gst_bin_add_many (bin, element, self->priv->decoder, self->priv->encoder, NULL);
   
   gst_element_link (element, self->priv->decoder);



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