[rygel] core: Don't transcode to different item class
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel] core: Don't transcode to different item class
- Date: Thu, 5 Aug 2010 16:38:23 +0000 (UTC)
commit c0239a2e245b74d9ab212d6c6810d35a05eb5d62
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Thu Aug 5 19:35:20 2010 +0300
core: Don't transcode to different item class
Don't offer transcoding from video to audio and viceversa. This makes
sense anyway, reduces network traffic and (last but not the least)
satisfies DLNA (7.3.25.1).
src/rygel/rygel-l16-transcoder.vala | 26 ++++++++++----------------
src/rygel/rygel-mp2ts-transcoder.vala | 26 ++++++++++----------------
src/rygel/rygel-mp3-transcoder.vala | 14 ++++----------
src/rygel/rygel-wma-transcoder.vala | 14 ++++----------
src/rygel/rygel-wmv-transcoder.vala | 14 ++++----------
5 files changed, 32 insertions(+), 62 deletions(-)
---
diff --git a/src/rygel/rygel-l16-transcoder.vala b/src/rygel/rygel-l16-transcoder.vala
index 49ba980..5032b06 100644
--- a/src/rygel/rygel-l16-transcoder.vala
+++ b/src/rygel/rygel-l16-transcoder.vala
@@ -83,28 +83,22 @@ internal class Rygel.L16Transcoder : Rygel.Transcoder {
}
public override uint get_distance (MediaItem item) {
- if (item.upnp_class.has_prefix (MediaItem.IMAGE_CLASS)) {
+ if (!item.upnp_class.has_prefix (MediaItem.AUDIO_CLASS)) {
return uint.MAX;
}
- uint distance;
+ var distance = uint.MIN;
- if (item.upnp_class.has_prefix (MediaItem.AUDIO_CLASS)) {
- distance = uint.MIN;
-
- if (item.sample_freq > 0) {
- distance += (item.sample_freq - FREQUENCY).abs ();
- }
+ if (item.sample_freq > 0) {
+ distance += (item.sample_freq - FREQUENCY).abs ();
+ }
- if (item.n_audio_channels > 0) {
- distance += (item.n_audio_channels - CHANNELS).abs ();
- }
+ if (item.n_audio_channels > 0) {
+ distance += (item.n_audio_channels - CHANNELS).abs ();
+ }
- if (item.bits_per_sample > 0) {
- distance += (item.bits_per_sample - WIDTH).abs ();
- }
- } else {
- distance = uint.MAX / 2;
+ if (item.bits_per_sample > 0) {
+ distance += (item.bits_per_sample - WIDTH).abs ();
}
return distance;
diff --git a/src/rygel/rygel-mp2ts-transcoder.vala b/src/rygel/rygel-mp2ts-transcoder.vala
index b53b6aa..12a5a94 100644
--- a/src/rygel/rygel-mp2ts-transcoder.vala
+++ b/src/rygel/rygel-mp2ts-transcoder.vala
@@ -78,28 +78,22 @@ internal class Rygel.MP2TSTranscoder : Rygel.Transcoder {
}
public override uint get_distance (MediaItem item) {
- if (item.upnp_class.has_prefix (MediaItem.IMAGE_CLASS)) {
+ if (!item.upnp_class.has_prefix (MediaItem.VIDEO_CLASS)) {
return uint.MAX;
}
- uint distance;
+ var distance = uint.MIN;
- if (item.upnp_class.has_prefix (MediaItem.VIDEO_CLASS)) {
- distance = uint.MIN;
-
- if (item.bitrate > 0) {
- distance += (item.bitrate - BITRATE).abs ();
- }
+ if (item.bitrate > 0) {
+ distance += (item.bitrate - BITRATE).abs ();
+ }
- if (item.width > 0) {
- distance += (item.width - WIDTH[this.profile]).abs ();
- }
+ if (item.width > 0) {
+ distance += (item.width - WIDTH[this.profile]).abs ();
+ }
- if (item.height > 0) {
- distance += (item.height - HEIGHT[this.profile]).abs ();
- }
- } else {
- distance = uint.MAX / 2;
+ if (item.height > 0) {
+ distance += (item.height - HEIGHT[this.profile]).abs ();
}
return distance;
diff --git a/src/rygel/rygel-mp3-transcoder.vala b/src/rygel/rygel-mp3-transcoder.vala
index 398725b..0c2f494 100644
--- a/src/rygel/rygel-mp3-transcoder.vala
+++ b/src/rygel/rygel-mp3-transcoder.vala
@@ -65,20 +65,14 @@ internal class Rygel.MP3Transcoder : Rygel.Transcoder {
}
public override uint get_distance (MediaItem item) {
- if (item.upnp_class.has_prefix (MediaItem.IMAGE_CLASS)) {
+ if (!item.upnp_class.has_prefix (MediaItem.AUDIO_CLASS)) {
return uint.MAX;
}
- uint distance;
+ var distance = uint.MIN;
- if (item.upnp_class.has_prefix (MediaItem.AUDIO_CLASS)) {
- distance = uint.MIN;
-
- if (item.bitrate > 0) {
- distance += (item.bitrate - BITRATE).abs ();
- }
- } else {
- distance = uint.MAX / 2;
+ if (item.bitrate > 0) {
+ distance += (item.bitrate - BITRATE).abs ();
}
return distance;
diff --git a/src/rygel/rygel-wma-transcoder.vala b/src/rygel/rygel-wma-transcoder.vala
index 22869e9..f356f6c 100644
--- a/src/rygel/rygel-wma-transcoder.vala
+++ b/src/rygel/rygel-wma-transcoder.vala
@@ -52,20 +52,14 @@ internal class Rygel.WMATranscoder : Rygel.Transcoder {
}
public override uint get_distance (MediaItem item) {
- if (item.upnp_class.has_prefix (MediaItem.IMAGE_CLASS)) {
+ if (!item.upnp_class.has_prefix (MediaItem.AUDIO_CLASS)) {
return uint.MAX;
}
- uint distance;
+ var distance = uint.MIN;
- if (item.upnp_class.has_prefix (MediaItem.AUDIO_CLASS)) {
- distance = uint.MIN;
-
- if (item.bitrate > 0) {
- distance += (item.bitrate - BITRATE).abs ();
- }
- } else {
- distance = uint.MAX / 2;
+ if (item.bitrate > 0) {
+ distance += (item.bitrate - BITRATE).abs ();
}
return distance;
diff --git a/src/rygel/rygel-wmv-transcoder.vala b/src/rygel/rygel-wmv-transcoder.vala
index 118e68f..d715c83 100644
--- a/src/rygel/rygel-wmv-transcoder.vala
+++ b/src/rygel/rygel-wmv-transcoder.vala
@@ -57,20 +57,14 @@ internal class Rygel.WMVTranscoder : Rygel.Transcoder {
}
public override uint get_distance (MediaItem item) {
- if (item.upnp_class.has_prefix (MediaItem.IMAGE_CLASS)) {
+ if (!item.upnp_class.has_prefix (MediaItem.VIDEO_CLASS)) {
return uint.MAX;
}
- uint distance;
+ var distance = uint.MIN;
- if (item.upnp_class.has_prefix (MediaItem.VIDEO_CLASS)) {
- distance = uint.MIN;
-
- if (item.bitrate > 0) {
- distance += (item.bitrate - BITRATE).abs ();
- }
- } else {
- distance = uint.MAX / 2;
+ if (item.bitrate > 0) {
+ distance += (item.bitrate - BITRATE).abs ();
}
return distance;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]