[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: Fri, 21 Dec 2012 08:50:02 +0000 (UTC)
commit a4a4bd0f6ffb5e89914fcbafe71ac16976a60e55
Author: Murray Cumming <murrayc murrayc com>
Date: Fri Dec 21 09:49:49 2012 +0100
cleanup
src/rygel-l16-transcoder.c | 334 +++++++++-----------------------------------
1 files changed, 63 insertions(+), 271 deletions(-)
---
diff --git a/src/rygel-l16-transcoder.c b/src/rygel-l16-transcoder.c
index 4786997..272a35d 100644
--- a/src/rygel-l16-transcoder.c
+++ b/src/rygel-l16-transcoder.c
@@ -28,309 +28,102 @@ G_DEFINE_TYPE (RygelL16Transcoder, rygel_l16_transcoder, RYGEL_TYPE_AUDIO_TRANSC
#define RYGEL_L16_TRANSCODER_SIGNED TRUE
#define RYGEL_L16_TRANSCODER_ENDIANNESS ((gint) G_BIG_ENDIAN)
-RygelL16Transcoder* rygel_l16_transcoder_new (void);
-RygelL16Transcoder* rygel_l16_transcoder_construct (GType object_type);
-
static GUPnPDIDLLiteResource* rygel_l16_transcoder_real_add_resource (RygelTranscoder* base, GUPnPDIDLLiteItem* didl_item, RygelMediaItem* item, RygelTranscodeManager* manager, GError** error);
static guint rygel_l16_transcoder_real_get_distance (RygelTranscoder* base, RygelMediaItem* item);
-
-static gchar* bool_to_string (gboolean self) {
- gchar* result = NULL;
- if (self) {
- gchar* _tmp0_;
- _tmp0_ = g_strdup ("true");
- result = _tmp0_;
- return result;
- } else {
- gchar* _tmp1_;
- _tmp1_ = g_strdup ("false");
- result = _tmp1_;
- return result;
- }
-}
-
-
RygelL16Transcoder*
rygel_l16_transcoder_construct (GType object_type) {
- RygelL16Transcoder * self = NULL;
- gchar* _tmp0_ = NULL;
- gchar* _tmp1_;
- gchar* _tmp2_;
- gchar* _tmp3_;
- gchar* _tmp4_;
- gchar* _tmp5_;
- gchar* _tmp6_ = NULL;
- gchar* _tmp7_;
- gchar* _tmp8_;
- gchar* _tmp9_;
- gchar* _tmp10_;
- gchar* _tmp11_;
- gchar* _tmp12_ = NULL;
- gchar* _tmp13_;
- gchar* _tmp14_;
- gchar* _tmp15_;
- gchar* mime_type;
- gchar* _tmp16_ = NULL;
- gchar* _tmp17_;
- gchar* _tmp18_;
- gchar* _tmp19_;
- gchar* _tmp20_;
- gchar* _tmp21_;
- gchar* _tmp22_ = NULL;
- gchar* _tmp23_;
- gchar* _tmp24_;
- gchar* _tmp25_;
- gchar* _tmp26_;
- gchar* _tmp27_;
- gchar* _tmp28_ = NULL;
- gchar* _tmp29_;
- gchar* _tmp30_;
- gchar* _tmp31_;
- gchar* _tmp32_;
- gchar* _tmp33_;
- gchar* _tmp34_ = NULL;
- gchar* _tmp35_;
- gchar* _tmp36_;
- gchar* _tmp37_;
- gchar* _tmp38_;
- gchar* _tmp39_;
- gchar* _tmp40_ = NULL;
- gchar* _tmp41_;
- gchar* _tmp42_;
- gchar* _tmp43_;
- gchar* _tmp44_;
- gchar* _tmp45_;
- gchar* _tmp46_ = NULL;
- gchar* _tmp47_;
- gchar* _tmp48_;
- gchar* _tmp49_;
- gchar* caps_str;
- _tmp0_ = g_strdup_printf ("%i", RYGEL_L16_TRANSCODER_WIDTH);
- _tmp1_ = _tmp0_;
- _tmp2_ = g_strconcat ("audio/L", _tmp1_, NULL);
- _tmp3_ = _tmp2_;
- _tmp4_ = g_strconcat (_tmp3_, ";rate=", NULL);
- _tmp5_ = _tmp4_;
- _tmp6_ = g_strdup_printf ("%i", RYGEL_L16_TRANSCODER_FREQUENCY);
- _tmp7_ = _tmp6_;
- _tmp8_ = g_strconcat (_tmp5_, _tmp7_, NULL);
- _tmp9_ = _tmp8_;
- _tmp10_ = g_strconcat (_tmp9_, ";channels=", NULL);
- _tmp11_ = _tmp10_;
- _tmp12_ = g_strdup_printf ("%i", RYGEL_L16_TRANSCODER_CHANNELS);
- _tmp13_ = _tmp12_;
- _tmp14_ = g_strconcat (_tmp11_, _tmp13_, NULL);
- _tmp15_ = _tmp14_;
- _g_free0 (_tmp13_);
- _g_free0 (_tmp11_);
- _g_free0 (_tmp9_);
- _g_free0 (_tmp7_);
- _g_free0 (_tmp5_);
- _g_free0 (_tmp3_);
- _g_free0 (_tmp1_);
- mime_type = _tmp15_;
- _tmp16_ = g_strdup_printf ("%i", RYGEL_L16_TRANSCODER_CHANNELS);
- _tmp17_ = _tmp16_;
- _tmp18_ = g_strconcat ("audio/x-raw-int" ",channels=", _tmp17_, NULL);
- _tmp19_ = _tmp18_;
- _tmp20_ = g_strconcat (_tmp19_, ",rate=", NULL);
- _tmp21_ = _tmp20_;
- _tmp22_ = g_strdup_printf ("%i", RYGEL_L16_TRANSCODER_FREQUENCY);
- _tmp23_ = _tmp22_;
- _tmp24_ = g_strconcat (_tmp21_, _tmp23_, NULL);
- _tmp25_ = _tmp24_;
- _tmp26_ = g_strconcat (_tmp25_, ",width=", NULL);
- _tmp27_ = _tmp26_;
- _tmp28_ = g_strdup_printf ("%i", RYGEL_L16_TRANSCODER_WIDTH);
- _tmp29_ = _tmp28_;
- _tmp30_ = g_strconcat (_tmp27_, _tmp29_, NULL);
- _tmp31_ = _tmp30_;
- _tmp32_ = g_strconcat (_tmp31_, ",depth=", NULL);
- _tmp33_ = _tmp32_;
- _tmp34_ = g_strdup_printf ("%i", RYGEL_L16_TRANSCODER_DEPTH);
- _tmp35_ = _tmp34_;
- _tmp36_ = g_strconcat (_tmp33_, _tmp35_, NULL);
- _tmp37_ = _tmp36_;
- _tmp38_ = g_strconcat (_tmp37_, ",signed=", NULL);
- _tmp39_ = _tmp38_;
- _tmp40_ = bool_to_string (RYGEL_L16_TRANSCODER_SIGNED);
- _tmp41_ = _tmp40_;
- _tmp42_ = g_strconcat (_tmp39_, _tmp41_, NULL);
- _tmp43_ = _tmp42_;
- _tmp44_ = g_strconcat (_tmp43_, ",endianness=", NULL);
- _tmp45_ = _tmp44_;
- _tmp46_ = g_strdup_printf ("%i", RYGEL_L16_TRANSCODER_ENDIANNESS);
- _tmp47_ = _tmp46_;
- _tmp48_ = g_strconcat (_tmp45_, _tmp47_, NULL);
- _tmp49_ = _tmp48_;
- _g_free0 (_tmp47_);
- _g_free0 (_tmp45_);
- _g_free0 (_tmp43_);
- _g_free0 (_tmp41_);
- _g_free0 (_tmp39_);
- _g_free0 (_tmp37_);
- _g_free0 (_tmp35_);
- _g_free0 (_tmp33_);
- _g_free0 (_tmp31_);
- _g_free0 (_tmp29_);
- _g_free0 (_tmp27_);
- _g_free0 (_tmp25_);
- _g_free0 (_tmp23_);
- _g_free0 (_tmp21_);
- _g_free0 (_tmp19_);
- _g_free0 (_tmp17_);
- caps_str = _tmp49_;
- self = (RygelL16Transcoder*) rygel_audio_transcoder_construct (object_type, mime_type, "LPCM", 0, RYGEL_AUDIO_TRANSCODER_NO_CONTAINER, caps_str, "lpcm");
- _g_free0 (caps_str);
- _g_free0 (mime_type);
+ RygelL16Transcoder * self;
+
+ gchar* mime_type = g_strdup_printf ("audio/L%i"
+ ";rate=%i"
+ ";channels=%i",
+ RYGEL_L16_TRANSCODER_WIDTH, RYGEL_L16_TRANSCODER_FREQUENCY, RYGEL_L16_TRANSCODER_CHANNELS);
+
+ gchar* caps_str = g_strdup_printf ("audio/format=S16BE"
+ ",rate=%i"
+ ",width=%i"
+ ",depth=%i"
+ ",signed=%s"
+ ",endianness=%i",
+ RYGEL_L16_TRANSCODER_FREQUENCY,
+ RYGEL_L16_TRANSCODER_WIDTH,
+ RYGEL_L16_TRANSCODER_DEPTH,
+ (RYGEL_L16_TRANSCODER_SIGNED ? "true" : "false"),
+ RYGEL_L16_TRANSCODER_ENDIANNESS);
+
+ self = RYGEL_L16_TRANSCODER (rygel_audio_transcoder_construct (object_type, mime_type, "LPCM", 0, RYGEL_AUDIO_TRANSCODER_NO_CONTAINER, caps_str, "lpcm"));
+
+ g_free (caps_str);
+ g_free (mime_type);
return self;
}
-
-RygelL16Transcoder* rygel_l16_transcoder_new (void) {
+RygelL16Transcoder*
+rygel_l16_transcoder_new (void) {
return rygel_l16_transcoder_construct (RYGEL_TYPE_L16_TRANSCODER);
}
-
static GUPnPDIDLLiteResource*
rygel_l16_transcoder_real_add_resource (RygelTranscoder* base, GUPnPDIDLLiteItem* didl_item, RygelMediaItem* item, RygelTranscodeManager* manager, GError** error) {
- RygelL16Transcoder * self;
- GUPnPDIDLLiteResource* result = NULL;
- GUPnPDIDLLiteItem* _tmp0_;
- RygelMediaItem* _tmp1_;
- RygelTranscodeManager* _tmp2_;
- GUPnPDIDLLiteResource* _tmp3_ = NULL;
- GUPnPDIDLLiteResource* resource;
+ RygelL16Transcoder * self = RYGEL_L16_TRANSCODER (base);
GError * inner_error = NULL;
- self = (RygelL16Transcoder*) 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_l16_transcoder_parent_class)->add_resource ((RygelTranscoder*) G_TYPE_CHECK_INSTANCE_CAST (self, RYGEL_TYPE_AUDIO_TRANSCODER, RygelAudioTranscoder), _tmp0_, _tmp1_, _tmp2_, &inner_error);
- resource = _tmp3_;
- if (inner_error != NULL) {
+
+ GUPnPDIDLLiteResource* resource =
+ RYGEL_TRANSCODER_CLASS (rygel_l16_transcoder_parent_class)->add_resource (RYGEL_TRANSCODER (self), didl_item, item, manager, &inner_error);
+ if (!inner_error) {
g_propagate_error (error, inner_error);
return NULL;
}
- if (resource == NULL) {
- result = NULL;
- _g_object_unref0 (resource);
- return result;
+
+ if (!resource) {
+ return resource;
}
+
gupnp_didl_lite_resource_set_sample_freq (resource, RYGEL_L16_TRANSCODER_FREQUENCY);
gupnp_didl_lite_resource_set_audio_channels (resource, RYGEL_L16_TRANSCODER_CHANNELS);
gupnp_didl_lite_resource_set_bits_per_sample (resource, RYGEL_L16_TRANSCODER_WIDTH);
- gupnp_didl_lite_resource_set_bitrate (resource, ((RYGEL_L16_TRANSCODER_FREQUENCY * RYGEL_L16_TRANSCODER_CHANNELS) * RYGEL_L16_TRANSCODER_WIDTH) / 8);
- result = resource;
- return result;
-}
-
+ gupnp_didl_lite_resource_set_bitrate (resource,
+ ((RYGEL_L16_TRANSCODER_FREQUENCY * RYGEL_L16_TRANSCODER_CHANNELS) * RYGEL_L16_TRANSCODER_WIDTH) / 8);
-static gpointer _g_object_ref0 (gpointer self) {
- return self ? g_object_ref (self) : NULL;
+ return resource;
}
-
static guint
rygel_l16_transcoder_real_get_distance (RygelTranscoder* base, RygelMediaItem* item) {
- RygelL16Transcoder * self;
- guint result = 0U;
- gboolean _tmp0_ = FALSE;
- RygelMediaItem* _tmp1_;
- gboolean _tmp3_;
- RygelMediaItem* _tmp5_;
- RygelAudioItem* _tmp6_;
+ RygelL16Transcoder * self = RYGEL_L16_TRANSCODER (base);
RygelAudioItem* audio_item;
- guint _tmp7_;
guint distance;
- RygelAudioItem* _tmp8_;
- gint _tmp9_;
- gint _tmp10_;
- RygelAudioItem* _tmp16_;
- gint _tmp17_;
- gint _tmp18_;
- RygelAudioItem* _tmp24_;
- gint _tmp25_;
- gint _tmp26_;
- self = (RygelL16Transcoder*) base;
+ guint sample_freq;
+ guint channels;
+ guint bits_per_sample;
+
g_return_val_if_fail (item != NULL, 0U);
- _tmp1_ = item;
- if (!RYGEL_IS_AUDIO_ITEM (_tmp1_)) {
- _tmp0_ = TRUE;
- } else {
- RygelMediaItem* _tmp2_;
- _tmp2_ = item;
- _tmp0_ = RYGEL_IS_VIDEO_ITEM (_tmp2_);
- }
- _tmp3_ = _tmp0_;
- if (_tmp3_) {
- guint _tmp4_;
- _tmp4_ = G_MAXUINT;
- result = _tmp4_;
- return result;
- }
- _tmp5_ = item;
- _tmp6_ = _g_object_ref0 (RYGEL_IS_AUDIO_ITEM (_tmp5_) ? ((RygelAudioItem*) _tmp5_) : NULL);
- audio_item = _tmp6_;
- _tmp7_ = 0;
- distance = _tmp7_;
- _tmp8_ = audio_item;
- _tmp9_ = rygel_audio_item_get_sample_freq (_tmp8_);
- _tmp10_ = _tmp9_;
- if (_tmp10_ > 0) {
- guint _tmp11_;
- RygelAudioItem* _tmp12_;
- gint _tmp13_;
- gint _tmp14_;
- gint _tmp15_ = 0;
- _tmp11_ = distance;
- _tmp12_ = audio_item;
- _tmp13_ = rygel_audio_item_get_sample_freq (_tmp12_);
- _tmp14_ = _tmp13_;
- _tmp15_ = abs (_tmp14_ - RYGEL_L16_TRANSCODER_FREQUENCY);
- distance = _tmp11_ + _tmp15_;
+
+ if (!RYGEL_IS_AUDIO_ITEM (item) || RYGEL_IS_VIDEO_ITEM (item)) {
+ return G_MAXUINT;
}
- _tmp16_ = audio_item;
- _tmp17_ = rygel_audio_item_get_channels (_tmp16_);
- _tmp18_ = _tmp17_;
- if (_tmp18_ > 0) {
- guint _tmp19_;
- RygelAudioItem* _tmp20_;
- gint _tmp21_;
- gint _tmp22_;
- gint _tmp23_ = 0;
- _tmp19_ = distance;
- _tmp20_ = audio_item;
- _tmp21_ = rygel_audio_item_get_channels (_tmp20_);
- _tmp22_ = _tmp21_;
- _tmp23_ = abs (_tmp22_ - RYGEL_L16_TRANSCODER_CHANNELS);
- distance = _tmp19_ + _tmp23_;
+
+ audio_item = RYGEL_AUDIO_ITEM (item);
+ distance = 0;
+
+ sample_freq = rygel_audio_item_get_sample_freq (audio_item);
+ if(sample_freq > 0) {
+ distance += abs(sample_freq - RYGEL_L16_TRANSCODER_FREQUENCY);
}
- _tmp24_ = audio_item;
- _tmp25_ = rygel_audio_item_get_bits_per_sample (_tmp24_);
- _tmp26_ = _tmp25_;
- if (_tmp26_ > 0) {
- guint _tmp27_;
- RygelAudioItem* _tmp28_;
- gint _tmp29_;
- gint _tmp30_;
- gint _tmp31_ = 0;
- _tmp27_ = distance;
- _tmp28_ = audio_item;
- _tmp29_ = rygel_audio_item_get_bits_per_sample (_tmp28_);
- _tmp30_ = _tmp29_;
- _tmp31_ = abs (_tmp30_ - RYGEL_L16_TRANSCODER_WIDTH);
- distance = _tmp27_ + _tmp31_;
+
+ channels = rygel_audio_item_get_channels (audio_item);
+ if(channels > 0) {
+ distance += abs(channels - RYGEL_L16_TRANSCODER_CHANNELS);
}
- result = distance;
- _g_object_unref0 (audio_item);
- return result;
-}
+ bits_per_sample = rygel_audio_item_get_bits_per_sample (audio_item);
+ if(bits_per_sample > 0) {
+ distance += abs(bits_per_sample - RYGEL_L16_TRANSCODER_WIDTH);
+ }
+
+ return distance;
+}
static void
rygel_l16_transcoder_class_init (RygelL16TranscoderClass * klass) {
@@ -339,7 +132,6 @@ rygel_l16_transcoder_class_init (RygelL16TranscoderClass * klass) {
RYGEL_TRANSCODER_CLASS (klass)->get_distance = rygel_l16_transcoder_real_get_distance;
}
-
static void
rygel_l16_transcoder_init (RygelL16Transcoder * self) {
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]