summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJens Georg <mail@jensge.org>2015-05-23 13:42:47 +0200
committerJens Georg <mail@jensge.org>2015-05-23 14:42:57 +0200
commitf848be8f6815e9197e09336a75f26c41f9d3ebba (patch)
tree469837715e5bf601ece435962c0cc8cacb260b2d /src
parent7c94302218f2ba6f944674ae80b1b3f32af23632 (diff)
downloadrygel-f848be8f6815e9197e09336a75f26c41f9d3ebba.tar.gz
engine-gst: Style fixes
Signed-off-by: Jens Georg <mail@jensge.org>
Diffstat (limited to 'src')
-rw-r--r--src/media-engines/gstreamer/rygel-gst-media-engine.vala81
-rw-r--r--src/media-engines/gstreamer/rygel-gst-transcoder.vala4
2 files changed, 50 insertions, 35 deletions
diff --git a/src/media-engines/gstreamer/rygel-gst-media-engine.vala b/src/media-engines/gstreamer/rygel-gst-media-engine.vala
index e4704b63..f14d448e 100644
--- a/src/media-engines/gstreamer/rygel-gst-media-engine.vala
+++ b/src/media-engines/gstreamer/rygel-gst-media-engine.vala
@@ -57,10 +57,11 @@ public class Rygel.GstMediaEngine : Rygel.MediaEngine {
var transcoding = true;
var transcoder_list = new ArrayList<string> ();
- /* Allow some transcoders to be disabled by the Rygel Server configuration.
- * For instance, some DLNA Renderers might incorrectly prefer inferior transcoded formats,
- * sometimes even preferring transcoded formats over the original data,
- * so this forces them to use other formats.
+ /* Allow some transcoders to be disabled by the Rygel Server
+ * configuration. For instance, some DLNA Renderers might incorrectly
+ * prefer inferior transcoded formats, sometimes even preferring
+ * transcoded formats over the original data, so this forces them to
+ * use other formats.
*/
var config = MetaConfig.get_default ();
try {
@@ -109,37 +110,41 @@ public class Rygel.GstMediaEngine : Rygel.MediaEngine {
return this.dlna_profiles;
}
- public override async Gee.List<MediaResource> ? get_resources_for_item (MediaObject object) {
- if (! (object is MediaFileItem)) {
+ public override async Gee.List<MediaResource>? get_resources_for_item
+ (MediaObject object) {
+ if (!(object is MediaFileItem)) {
warning ("Can only process file-based MediaObjects (MediaFileItems)");
+
return null;
}
var item = object as MediaFileItem;
// For MediaFileItems, the primary URI refers directly to the content
- string source_uri = item.get_primary_uri ();
+ var source_uri = item.get_primary_uri ();
debug ("get_resources_for_item(%s)", source_uri);
if (!source_uri.has_prefix ("file://")) {
warning ("Can't process non-file uri " + source_uri);
+
return null;
}
- Gee.List<MediaResource> resources = new Gee.ArrayList<MediaResource> ();
-
+ var resources = new Gee.ArrayList<MediaResource> ();
var primary_res = item.get_primary_resource ();
- // The GstMediaEngine only supports byte-based seek on the primary resource currently
+ // The GstMediaEngine only supports byte-based seek on the primary
+ // resource currently
primary_res.dlna_operation = DLNAOperation.RANGE;
- // The GstMediaEngine supports connection stalling on the primary resource
+ // The GstMediaEngine supports connection stalling on the primary
+ // resource
primary_res.dlna_flags |= DLNAFlags.CONNECTION_STALL;
// Add a resource for http consumption
- MediaResource http_res = new MediaResource.from_resource ("primary_http",
- primary_res);
+ var http_res = new MediaResource.from_resource ("primary_http",
+ primary_res);
http_res.uri = ""; // The URI needs to be assigned by the MediaServer
resources.add (http_res);
@@ -150,15 +155,16 @@ public class Rygel.GstMediaEngine : Rygel.MediaEngine {
}
}
list.sort_with_data( (transcoder_1, transcoder_2) => {
- return (int) ( transcoder_1.get_distance (item)
- - transcoder_2.get_distance (item) );
- } );
+ return (int) (transcoder_1.get_distance (item) -
+ transcoder_2.get_distance (item));
+ });
// Put all Transcoders in the list according to their sorted rank
foreach (var transcoder in list) {
- MediaResource res = transcoder.get_resource_for_item (item);
- if (res != null)
+ var res = transcoder.get_resource_for_item (item);
+ if (res != null) {
resources.add (res);
+ }
}
// Put the primary resource as most-preferred (front of the list)
@@ -167,40 +173,49 @@ public class Rygel.GstMediaEngine : Rygel.MediaEngine {
return resources;
}
- public override DataSource? create_data_source_for_resource ( MediaObject object,
- MediaResource resource)
- throws Error {
- if (! (object is MediaFileItem)) {
+ public override DataSource? create_data_source_for_resource
+ (MediaObject object,
+ MediaResource resource)
+ throws Error {
+ if (!(object is MediaFileItem)) {
warning ("Can only process file-based MediaObjects (MediaFileItems)");
+
return null;
}
var item = object as MediaFileItem;
// For MediaFileItems, the primary URI refers directly to the content
- string source_uri = item.get_primary_uri ();
+ var source_uri = item.get_primary_uri ();
debug ("creating data source for %s", source_uri);
- DataSource ds = new GstDataSource (source_uri, resource);
- debug ("MediaResource %s, profile %s, mime_type %s", resource.get_name (),
- resource.dlna_profile, resource.mime_type);
+ var data_source = new GstDataSource (source_uri, resource);
+ debug ("MediaResource %s, profile %s, mime_type %s",
+ resource.get_name (),
+ resource.dlna_profile,
+ resource.mime_type);
+
if (resource.dlna_conversion == DLNAConversion.TRANSCODED) {
foreach (var transcoder in transcoders) {
- if (transcoder.name == resource.get_name()) {
- debug ("creating data source from transcoder %s (profile %s)",
- transcoder.name, transcoder.dlna_profile );
- ds = transcoder.create_source (item, ds);
+ if (transcoder.name == resource.get_name ()) {
+ debug ("Creating data source from transcoder %s " +
+ "with DLNA profile %s",
+ transcoder.name,
+ transcoder.dlna_profile);
+ data_source = transcoder.create_source (item, data_source);
+
break;
}
}
}
- return ds;
+
+ return data_source;
}
public override DataSource? create_data_source_for_uri (string source_uri) {
try {
debug("creating data source for %s", source_uri);
- DataSource ds = new GstDataSource (source_uri, null);
- return ds;
+
+ return new GstDataSource (source_uri, null);
} catch (Error error) {
warning (_("Failed to create GStreamer data source for %s: %s"),
source_uri,
diff --git a/src/media-engines/gstreamer/rygel-gst-transcoder.vala b/src/media-engines/gstreamer/rygel-gst-transcoder.vala
index 521f32b7..0ae81998 100644
--- a/src/media-engines/gstreamer/rygel-gst-transcoder.vala
+++ b/src/media-engines/gstreamer/rygel-gst-transcoder.vala
@@ -38,7 +38,7 @@ public errordomain Rygel.GstTranscoderError {
* Each implementation derives from it and must
* implement get_resources_for_item and get_encoding_profile methods.
*/
-public abstract class Rygel.GstTranscoder : GLib.Object {
+internal abstract class Rygel.GstTranscoder : GLib.Object {
public string name { get; construct; }
public string mime_type { get; construct; }
public string dlna_profile { get; construct; }
@@ -122,7 +122,7 @@ public abstract class Rygel.GstTranscoder : GLib.Object {
*
* @return the new transcoding source
*/
- public DataSource create_source (MediaFileItem item, DataSource src) throws Error {
+ public GstDataSource create_source (MediaFileItem item, DataSource src) throws Error {
// We can only link GStreamer data sources together
assert (src is GstDataSource);