[rygel-gst-0-10-media-engine] cleanup



commit 7cd78db505aa2dfffbb2662da3b61806c8158877
Author: Murray Cumming <murrayc murrayc com>
Date:   Fri Dec 21 12:03:30 2012 +0100

    cleanup

 src/rygel-gst-utils.c        |   11 ---
 src/rygel-video-transcoder.c |  187 ++++++++++++++----------------------------
 2 files changed, 61 insertions(+), 137 deletions(-)
---
diff --git a/src/rygel-gst-utils.c b/src/rygel-gst-utils.c
index 7b143c7..dedc943 100644
--- a/src/rygel-gst-utils.c
+++ b/src/rygel-gst-utils.c
@@ -114,17 +114,6 @@ rygel_gst_utils_dump_encoding_profile (GstEncodingProfile* profile, gint indent)
   g_free (indent_s);
 }
 
-static void _gst_object_unref0_ (gpointer var) {
-  (var == NULL) ? NULL : (var = (gst_object_unref (var), NULL));
-}
-
-
-static void _g_list_free__gst_object_unref0_ (GList* self) {
-  g_list_foreach (self, (GFunc) _gst_object_unref0_, NULL);
-  g_list_free (self);
-}
-
-
 GstElement* rygel_gst_utils_get_rtp_depayloader (GstCaps* caps) {
   GList* features;
   GList* temp;
diff --git a/src/rygel-video-transcoder.c b/src/rygel-video-transcoder.c
index 014494c..628ce13 100644
--- a/src/rygel-video-transcoder.c
+++ b/src/rygel-video-transcoder.c
@@ -64,149 +64,85 @@ rygel_video_transcoder_new (const gchar *content_type, gint audio_bitrate, gint
 
 static GUPnPDIDLLiteResource* rygel_video_transcoder_real_add_resource (RygelTranscoder *base, GUPnPDIDLLiteItem *didl_item, RygelMediaItem *item, RygelTranscodeManager *manager, GError **error) {
   RygelVideoTranscoder *self;
-  GUPnPDIDLLiteResource* result = NULL;
-  GUPnPDIDLLiteItem *_tmp0_;
-  RygelMediaItem *_tmp1_;
-  RygelTranscodeManager *_tmp2_;
-  GUPnPDIDLLiteResource* _tmp3_ = NULL;
-  GUPnPDIDLLiteResource* resource;
-  RygelMediaItem *_tmp4_;
-  RygelVideoItem *_tmp5_;
   RygelVideoItem *video_item;
-  RygelVideoItem *_tmp6_;
-  gint _tmp7_;
-  gint _tmp8_;
-  RygelVideoItem *_tmp9_;
-  gint _tmp10_;
-  gint _tmp11_;
-  gint _tmp12_;
-  gint _tmp13_;
+  GUPnPDIDLLiteResource* resource;
   GError *inner_error = NULL;
-  self = (RygelVideoTranscoder*) base;
+
   g_return_val_if_fail (didl_item != NULL, NULL);
   g_return_val_if_fail (item != NULL, NULL);
   g_return_val_if_fail (manager != NULL, NULL);
-  _tmp0_ = didl_item;
-  _tmp1_ = item;
-  _tmp2_ = manager;
-  _tmp3_ = RYGEL_TRANSCODER_CLASS (rygel_video_transcoder_parent_class)->add_resource ((RygelTranscoder*) G_TYPE_CHECK_INSTANCE_CAST (self, RYGEL_TYPE_AUDIO_TRANSCODER, RygelVideoTranscoder), _tmp0_, _tmp1_, _tmp2_, &inner_error);
-  resource = _tmp3_;
+
+  self = RYGEL_VIDEO_TRANSCODER (base);
+
+  resource = RYGEL_TRANSCODER_CLASS (rygel_video_transcoder_parent_class)->add_resource (RYGEL_TRANSCODER (self), didl_item, item, manager, &inner_error);
   if (inner_error != NULL) {
     g_propagate_error (error, inner_error);
     return NULL;
   }
-  if (resource == NULL) {
-    result = NULL;
-    _g_object_unref0 (resource);
-    return result;
+
+  if (!resource) {
+    return NULL;
   }
-  _tmp4_ = item;
-  _tmp5_ = g_object_ref (RYGEL_IS_VIDEO_ITEM (_tmp4_) ? ((RygelVideoItem*) _tmp4_) : NULL);
-  video_item = _tmp5_;
-  _tmp6_ = video_item;
-  _tmp7_ = rygel_visual_item_get_width ((RygelVisualItem*) _tmp6_);
-  _tmp8_ = _tmp7_;
-  gupnp_didl_lite_resource_set_width (resource, _tmp8_);
-  _tmp9_ = video_item;
-  _tmp10_ = rygel_visual_item_get_height ((RygelVisualItem*) _tmp9_);
-  _tmp11_ = _tmp10_;
-  gupnp_didl_lite_resource_set_height (resource, _tmp11_);
-  _tmp12_ = self->priv->video_bitrate;
-  _tmp13_ = ((RygelAudioTranscoder*) self)->audio_bitrate;
-  gupnp_didl_lite_resource_set_bitrate (resource, ((_tmp12_ + _tmp13_) * 1000) / 8);
-  result = resource;
-  _g_object_unref0 (video_item);
-  return result;
-}
 
+  gupnp_didl_lite_resource_set_width (resource,
+    rygel_visual_item_get_width (RYGEL_VISUAL_ITEM (video_item)));
+  gupnp_didl_lite_resource_set_height (resource,
+    rygel_visual_item_get_height (RYGEL_VISUAL_ITEM (video_item)));
+  gupnp_didl_lite_resource_set_bitrate (resource,
+    (self->priv->video_bitrate + RYGEL_AUDIO_TRANSCODER (self)->audio_bitrate) * 1000 / 8);
+ 
+  return resource;
+}
 
-static guint rygel_video_transcoder_real_get_distance (RygelTranscoder *base, RygelMediaItem *item) {
-  
+static guint
+rygel_video_transcoder_real_get_distance (RygelTranscoder *base, RygelMediaItem *item) {
   RygelVideoTranscoder *self;
-  guint result = 0U;
-  RygelMediaItem *_tmp0_;
-  RygelMediaItem *_tmp2_;
-  RygelVideoItem *_tmp3_;
   RygelVideoItem *video_item;
-  guint _tmp4_;
   guint distance;
-  RygelVideoItem *_tmp5_;
-  gint _tmp6_;
-  gint _tmp7_;
-  self = (RygelVideoTranscoder*) base;
-  g_return_val_if_fail (item != NULL, 0U);
-  _tmp0_ = item;
-  if (!RYGEL_IS_VIDEO_ITEM (_tmp0_)) {
-    guint _tmp1_;
-    _tmp1_ = G_MAXUINT;
-    result = _tmp1_;
-    return result;
+  guint bitrate;
+
+  g_return_val_if_fail (item, NULL);
+
+  self = RYGEL_VIDEO_TRANSCODER (base);
+
+  if (!RYGEL_IS_VIDEO_ITEM (item)) {
+    return G_MAXUINT;
   }
-  _tmp2_ = item;
-  _tmp3_ = g_object_ref (RYGEL_IS_VIDEO_ITEM (_tmp2_) ? ((RygelVideoItem*) _tmp2_) : NULL);
-  video_item = _tmp3_;
-  _tmp4_ = 0;
-  distance = _tmp4_;
-  _tmp5_ = video_item;
-  _tmp6_ = rygel_audio_item_get_bitrate ((RygelAudioItem*) _tmp5_);
-  _tmp7_ = _tmp6_;
-  if (_tmp7_ > 0) {
-    guint _tmp8_;
-    RygelVideoItem *_tmp9_;
-    gint _tmp10_;
-    gint _tmp11_;
-    gint _tmp12_;
-    gint _tmp13_ = 0;
-    _tmp8_ = distance;
-    _tmp9_ = video_item;
-    _tmp10_ = rygel_audio_item_get_bitrate ((RygelAudioItem*) _tmp9_);
-    _tmp11_ = _tmp10_;
-    _tmp12_ = self->priv->video_bitrate;
-    _tmp13_ = abs (_tmp11_ - _tmp12_);
-    distance = _tmp8_ + _tmp13_;
+
+  video_item = RYGEL_VIDEO_ITEM (item);
+
+  bitrate = rygel_audio_item_get_bitrate (RYGEL_AUDIO_ITEM (video_item));
+  distance = 0;
+  if(bitrate > 0) {
+    distance += abs(bitrate - self->priv->video_bitrate);
   }
-  result = distance;
-  _g_object_unref0 (video_item);
-  return result;
+
+  return distance;
 }
 
+static GstEncodingProfile*
+rygel_video_transcoder_real_get_encoding_profile (RygelGstTranscoder *base) {
+  RygelVideoTranscoder *self;
+  GstEncodingContainerProfile *enc_container_profile;
+  GstEncodingProfile *enc_video_profile;
 
-static gpointer _gst_encoding_profile_ref0 (gpointer self) {
-  return self ? gst_encoding_profile_ref (self) : NULL;
-}
+  self = RYGEL_VIDEO_TRANSCODER (base);
 
+  enc_container_profile = RYGEL_GST_TRANSCODER_CLASS (rygel_video_transcoder_parent_class)->get_encoding_profile (RYGEL_GST_TRANSCODER (self));
+  enc_video_profile = gst_encoding_video_profile_new (self->priv->video_codec_format,
+    rygel_gst_transcoder_get_preset (RYGEL_GST_TRANSCODER (self)),
+    self->priv->video_restrictions,
+    (guint) 1);
+  
+  gst_encoding_profile_set_name (enc_video_profile, "video");
+  gst_encoding_container_profile_add_profile (enc_container_profile, enc_video_profile);
+  gst_encoding_profile_unref (enc_video_profile);
 
-static GstEncodingProfile* rygel_video_transcoder_real_get_encoding_profile (RygelGstTranscoder *base) {
-  RygelVideoTranscoder *self;
-  GstEncodingProfile* result = NULL;
-  GstEncodingProfile* _tmp0_ = NULL;
-  GstEncodingContainerProfile* enc_container_profile;
-  GstCaps* _tmp1_;
-  const gchar *_tmp2_;
-  const gchar *_tmp3_;
-  GstCaps* _tmp4_;
-  GstEncodingVideoProfile* _tmp5_;
-  GstEncodingVideoProfile* enc_video_profile;
-  GstEncodingProfile* _tmp6_;
-  self = (RygelVideoTranscoder*) base;
-  _tmp0_ = RYGEL_GST_TRANSCODER_CLASS (rygel_video_transcoder_parent_class)->get_encoding_profile ((RygelGstTranscoder*) G_TYPE_CHECK_INSTANCE_CAST (self, RYGEL_TYPE_AUDIO_TRANSCODER, RygelVideoTranscoder));
-  enc_container_profile = GST_IS_ENCODING_CONTAINER_PROFILE (_tmp0_) ? ((GstEncodingContainerProfile*) _tmp0_) : NULL;
-  _tmp1_ = self->priv->video_codec_format;
-  _tmp2_ = rygel_gst_transcoder_get_preset (RYGEL_GST_TRANSCODER (self));
-  _tmp3_ = _tmp2_;
-  _tmp4_ = self->priv->video_restrictions;
-  _tmp5_ = gst_encoding_video_profile_new (_tmp1_, _tmp3_, _tmp4_, (guint) 1);
-  enc_video_profile = _tmp5_;
-  gst_encoding_profile_set_name ((GstEncodingProfile*) enc_video_profile, "video");
-  _tmp6_ = _gst_encoding_profile_ref0 ((GstEncodingProfile*) enc_video_profile);
-  gst_encoding_container_profile_add_profile (enc_container_profile, _tmp6_);
-  result = (GstEncodingProfile*) enc_container_profile;
-  _gst_encoding_profile_unref0 (enc_video_profile);
-  return result;
+  return enc_container_profile;
 }
 
-
-static void rygel_video_transcoder_class_init (RygelVideoTranscoderClass *klass) {
+static void
+rygel_video_transcoder_class_init (RygelVideoTranscoderClass *klass) {
   rygel_video_transcoder_parent_class = g_type_class_peek_parent (klass);
   g_type_class_add_private (klass, sizeof (RygelVideoTranscoderPrivate));
   RYGEL_TRANSCODER_CLASS (klass)->add_resource = rygel_video_transcoder_real_add_resource;
@@ -215,19 +151,18 @@ static void rygel_video_transcoder_class_init (RygelVideoTranscoderClass *klass)
   G_OBJECT_CLASS (klass)->finalize = rygel_video_transcoder_finalize;
 }
 
-
-static void rygel_video_transcoder_init (RygelVideoTranscoder *self) {
+static void
+rygel_video_transcoder_init (RygelVideoTranscoder *self) {
   self->priv = RYGEL_VIDEO_TRANSCODER_GET_PRIVATE (self);
   self->priv->video_restrictions = NULL;
 }
 
-
-static void rygel_video_transcoder_finalize (GObject* obj) {
+static void
+rygel_video_transcoder_finalize (GObject* obj) {
   RygelVideoTranscoder *self;
   self = RYGEL_VIDEO_TRANSCODER (obj);
-  _gst_caps_unref0 (self->priv->video_codec_format);
-  _gst_caps_unref0 (self->priv->video_restrictions);
+  gst_caps_unref (self->priv->video_codec_format);
+  gst_caps_unref (self->priv->video_restrictions);
   G_OBJECT_CLASS (rygel_video_transcoder_parent_class)->finalize (obj);
 }
 
-



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