[rygel-gst-0-10-media-engine] cleanup
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel-gst-0-10-media-engine] cleanup
- Date: Wed, 19 Dec 2012 12:10:25 +0000 (UTC)
commit 14db43120df6a9c3db0a3103d0d8907bbb22fef6
Author: Murray Cumming <murrayc murrayc com>
Date: Wed Dec 19 13:10:13 2012 +0100
cleanup
src/rygel-audio-transcoder.c | 241 ++++++++++++------------------------------
1 files changed, 68 insertions(+), 173 deletions(-)
---
diff --git a/src/rygel-audio-transcoder.c b/src/rygel-audio-transcoder.c
index 142d7f9..3ee8631 100644
--- a/src/rygel-audio-transcoder.c
+++ b/src/rygel-audio-transcoder.c
@@ -34,78 +34,37 @@ static void rygel_audio_transcoder_finalize (GObject* obj);
RygelAudioTranscoder*
rygel_audio_transcoder_construct (GType object_type, const gchar* content_type, gint audio_bitrate, const gchar* container_caps, const gchar* audio_codec_caps, const gchar* extension) {
RygelAudioTranscoder * self = NULL;
- const gchar* _tmp0_;
- const gchar* _tmp1_;
- const gchar* _tmp2_;
- gint _tmp3_;
- const gchar* _tmp4_;
- const gchar* _tmp7_;
- GstCaps* _tmp8_ = NULL;
+
g_return_val_if_fail (content_type != NULL, NULL);
g_return_val_if_fail (audio_codec_caps != NULL, NULL);
g_return_val_if_fail (extension != NULL, NULL);
- _tmp0_ = content_type;
- _tmp2_ = extension;
- self = (RygelAudioTranscoder*) rygel_gst_transcoder_construct (object_type, _tmp0_, RYGEL_AUDIO_ITEM_UPNP_CLASS, _tmp2_);
- _tmp3_ = audio_bitrate;
- self->audio_bitrate = _tmp3_;
- _tmp4_ = container_caps;
- if (_tmp4_ != NULL) {
- const gchar* _tmp5_;
- GstCaps* _tmp6_ = NULL;
- _tmp5_ = container_caps;
- _tmp6_ = gst_caps_from_string (_tmp5_);
- _gst_caps_unref0 (self->container_format);
- self->container_format = _tmp6_;
- }
- _tmp7_ = audio_codec_caps;
- _tmp8_ = gst_caps_from_string (_tmp7_);
- _gst_caps_unref0 (self->audio_codec_format);
- self->audio_codec_format = _tmp8_;
+
+ self = RYGEL_AUDIO_TRANSCODER (rygel_gst_transcoder_construct (object_type, content_type, RYGEL_AUDIO_ITEM_UPNP_CLASS, extension));
+ self->audio_bitrate = audio_bitrate;
+ self->container_format = container_caps;
+ self->audio_codec_format = audio_codec_caps;
+
return self;
}
-
-RygelAudioTranscoder* rygel_audio_transcoder_new (const gchar* content_type, gint audio_bitrate, const gchar* container_caps, const gchar* audio_codec_caps, const gchar* extension) {
+RygelAudioTranscoder*
+rygel_audio_transcoder_new (const gchar* content_type, gint audio_bitrate, const gchar* container_caps, const gchar* audio_codec_caps, const gchar* extension) {
return rygel_audio_transcoder_construct (RYGEL_TYPE_AUDIO_TRANSCODER, content_type, audio_bitrate, container_caps, audio_codec_caps, extension);
}
-
RygelAudioTranscoder*
rygel_audio_transcoder_construct_with_class (GType object_type, const gchar* content_type, const gchar* upnp_class, gint audio_bitrate, const gchar* container_caps, const gchar* audio_codec_caps, const gchar* extension) {
RygelAudioTranscoder * self = NULL;
- const gchar* _tmp0_;
- const gchar* _tmp1_;
- const gchar* _tmp2_;
- const gchar* _tmp3_;
- gint _tmp4_;
- const gchar* _tmp5_;
- const gchar* _tmp8_;
- GstCaps* _tmp9_ = NULL;
+
g_return_val_if_fail (content_type != NULL, NULL);
g_return_val_if_fail (upnp_class != NULL, NULL);
g_return_val_if_fail (audio_codec_caps != NULL, NULL);
g_return_val_if_fail (extension != NULL, NULL);
- _tmp0_ = content_type;
- _tmp2_ = upnp_class;
- _tmp3_ = extension;
- self = (RygelAudioTranscoder*) rygel_gst_transcoder_construct (object_type, _tmp0_, _tmp2_, _tmp3_);
- _tmp4_ = audio_bitrate;
- self->audio_bitrate = _tmp4_;
- _tmp5_ = container_caps;
- if (_tmp5_ != NULL) {
- const gchar* _tmp6_;
- GstCaps* _tmp7_ = NULL;
- _tmp6_ = container_caps;
- _tmp7_ = gst_caps_from_string (_tmp6_);
- _gst_caps_unref0 (self->container_format);
- self->container_format = _tmp7_;
- }
- _tmp8_ = audio_codec_caps;
- _tmp9_ = gst_caps_from_string (_tmp8_);
- _gst_caps_unref0 (self->audio_codec_format);
- self->audio_codec_format = _tmp9_;
- return self;
+
+ self = RYGEL_AUDIO_TRANSCODER (rygel_gst_transcoder_construct (object_type, content_type, upnp_class, extension));
+ self->audio_bitrate = audio_bitrate;
+ self->container_format = container_caps;
+ self->audio_codec_format = audio_codec_caps;
}
RygelAudioTranscoder*
@@ -116,142 +75,71 @@ rygel_audio_transcoder_new_with_class (const gchar* content_type, const gchar* u
static GUPnPDIDLLiteResource*
rygel_audio_transcoder_real_add_resource (RygelTranscoder* base, GUPnPDIDLLiteItem* didl_item, RygelMediaItem* item, RygelTranscodeManager* manager, GError** error) {
RygelAudioTranscoder * self;
- GUPnPDIDLLiteResource* result = NULL;
- GUPnPDIDLLiteItem* _tmp0_;
- RygelMediaItem* _tmp1_;
- RygelTranscodeManager* _tmp2_;
- GUPnPDIDLLiteResource* _tmp3_ = NULL;
GUPnPDIDLLiteResource* resource;
- gint _tmp4_;
- GError * _inner_error_ = NULL;
- self = (RygelAudioTranscoder*) 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_audio_transcoder_parent_class)->add_resource ((RygelTranscoder*) G_TYPE_CHECK_INSTANCE_CAST (self, RYGEL_TYPE_GST_TRANSCODER, RygelGstTranscoder), _tmp0_, _tmp1_, _tmp2_, &_inner_error_);
- resource = _tmp3_;
+ GError *_inner_error_ = NULL;
+
+ self = RYGEL_AUDIO_TRANSCODER (base);
+
+ resource = RYGEL_TRANSCODER_CLASS (rygel_audio_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;
+ return NULL;
}
- _tmp4_ = self->audio_bitrate;
- gupnp_didl_lite_resource_set_bitrate (resource, (_tmp4_ * 1000) / 8);
- result = resource;
- return result;
+
+ gupnp_didl_lite_resource_set_bitrate (resource, (self->audio_bitrate * 1000) / 8);
+ return resource;
}
static guint
rygel_audio_transcoder_real_get_distance (RygelTranscoder* base, RygelMediaItem* item) {
RygelAudioTranscoder * self;
- guint result = 0U;
- gboolean _tmp0_ = FALSE;
- RygelMediaItem* _tmp1_;
- gboolean _tmp3_;
- RygelMediaItem* _tmp5_;
- RygelAudioItem* _tmp6_;
- RygelAudioItem* audio_item;
- guint _tmp7_;
+ RygelAudioItem *audio_item;
guint distance;
- RygelAudioItem* _tmp8_;
- gint _tmp9_;
- gint _tmp10_;
- self = (RygelAudioTranscoder*) base;
- g_return_val_if_fail (item != NULL, 0U);
- _tmp1_ = item;
- if (!G_TYPE_CHECK_INSTANCE_TYPE (_tmp1_, RYGEL_TYPE_AUDIO_ITEM)) {
- _tmp0_ = TRUE;
- } else {
- RygelMediaItem* _tmp2_;
- _tmp2_ = item;
- _tmp0_ = G_TYPE_CHECK_INSTANCE_TYPE (_tmp2_, RYGEL_TYPE_VIDEO_ITEM);
- }
- _tmp3_ = _tmp0_;
- if (_tmp3_) {
- guint _tmp4_;
- _tmp4_ = G_MAXUINT;
- result = _tmp4_;
- return result;
+ guint bitrate;
+
+ g_return_val_if_fail (item, NULL);
+
+ self = RYGEL_AUDIO_TRANSCODER (base);
+
+ if (!RYGEL_IS_AUDIO_ITEM (item) || RYGEL_IS_VIDEO_ITEM (item)) {
+ return 0U;
}
- _tmp5_ = item;
- _tmp6_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp5_, RYGEL_TYPE_AUDIO_ITEM) ? ((RygelAudioItem*) _tmp5_) : NULL);
- audio_item = _tmp6_;
- _tmp7_ = 0;
- distance = _tmp7_;
- _tmp8_ = audio_item;
- _tmp9_ = rygel_audio_item_get_bitrate (_tmp8_);
- _tmp10_ = _tmp9_;
- if (_tmp10_ > 0) {
- guint _tmp11_;
- RygelAudioItem* _tmp12_;
- gint _tmp13_;
- gint _tmp14_;
- gint _tmp15_;
- gint _tmp16_ = 0;
- _tmp11_ = distance;
- _tmp12_ = audio_item;
- _tmp13_ = rygel_audio_item_get_bitrate (_tmp12_);
- _tmp14_ = _tmp13_;
- _tmp15_ = self->audio_bitrate;
- _tmp16_ = abs (_tmp14_ - _tmp15_);
- distance = _tmp11_ + _tmp16_;
+
+ audio_item = RYGEL_AUDIO_ITEM (item);
+
+ bitrate = rygel_audio_item_get_bitrate (audio_item);
+ distance = 0;
+ if(bitrate > 0) {
+ distance += abs(bitrate - self->audio_bitrate);
}
- result = distance;
- _g_object_unref0 (audio_item);
- return result;
+
+ return distance;
}
static GstEncodingProfile*
rygel_audio_transcoder_real_get_encoding_profile (RygelGstTranscoder* base) {
RygelAudioTranscoder * self;
- GstEncodingProfile* result = NULL;
- GstCaps* _tmp0_;
- const gchar* _tmp1_;
- const gchar* _tmp2_;
- GstEncodingAudioProfile* _tmp3_;
- GstEncodingAudioProfile* enc_audio_profile;
- GstEncodingAudioProfile* _tmp4_;
- GstCaps* _tmp5_;
- self = (RygelAudioTranscoder*) base;
- _tmp0_ = self->audio_codec_format;
- _tmp1_ = rygel_gst_transcoder_get_preset ((RygelGstTranscoder*) self);
- _tmp2_ = _tmp1_;
- _tmp3_ = gst_encoding_audio_profile_new (_tmp0_, _tmp2_, NULL, (guint) 1);
- enc_audio_profile = _tmp3_;
- _tmp4_ = enc_audio_profile;
- gst_encoding_profile_set_name ((GstEncodingProfile*) _tmp4_, "audio");
- _tmp5_ = self->container_format;
- if (_tmp5_ != NULL) {
- GstCaps* _tmp6_;
- const gchar* _tmp7_;
- const gchar* _tmp8_;
- GstEncodingContainerProfile* _tmp9_;
- GstEncodingContainerProfile* enc_container_profile;
- GstEncodingContainerProfile* _tmp10_;
- GstEncodingAudioProfile* _tmp11_;
- GstEncodingProfile* _tmp12_;
- _tmp6_ = self->container_format;
- _tmp7_ = rygel_gst_transcoder_get_preset ((RygelGstTranscoder*) self);
- _tmp8_ = _tmp7_;
- _tmp9_ = gst_encoding_container_profile_new ("container", NULL, _tmp6_, _tmp8_);
- enc_container_profile = _tmp9_;
- _tmp10_ = enc_container_profile;
- _tmp11_ = enc_audio_profile;
- _tmp12_ = _gst_encoding_profile_ref0 ((GstEncodingProfile*) _tmp11_);
- gst_encoding_container_profile_add_profile (_tmp10_, _tmp12_);
- result = (GstEncodingProfile*) enc_container_profile;
- _gst_encoding_profile_unref0 (enc_audio_profile);
- return result;
+ GstEncodingProfile* enc_audio_profile = NULL;
+ const gchar* preset;
+
+ self = RYGEL_AUDIO_TRANSCODER (base);
+
+ preset = rygel_gst_transcoder_get_preset ((RygelGstTranscoder*) self);
+ enc_audio_profile = gst_encoding_audio_profile_new (self->audio_codec_format, preset, NULL, 1);
+ gst_encoding_profile_set_name (enc_audio_profile, "audio");
+
+ if (self->container_format) {
+ GstEncodingContainerProfile* enc_container_profile
+ = gst_encoding_container_profile_new ("container", NULL, self->container_format, preset);
+ gst_encoding_container_profile_add_profile (enc_container_profile, enc_audio_profile);
+ return enc_container_profile;
}
- result = (GstEncodingProfile*) enc_audio_profile;
- return result;
+
+ return enc_audio_profile;
}
static void
@@ -273,8 +161,15 @@ static void
rygel_audio_transcoder_finalize (GObject* obj) {
RygelAudioTranscoder * self;
self = RYGEL_AUDIO_TRANSCODER (obj);
- _gst_caps_unref0 (self->container_format);
- _gst_caps_unref0 (self->audio_codec_format);
+
+ if (self->container_format) {
+ gst_caps_unref (self->container_format);
+ }
+
+ if (self->audio_codec_format) {
+ gst_caps_unref (self->audio_codec_format);
+ }
+
G_OBJECT_CLASS (rygel_audio_transcoder_parent_class)->finalize (obj);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]