BUILT_SOURCES = rygel-folder-root-container.c \
rygel-folder-container.c \
rygel-folder-directory-search-result.c \
- rygel-folder-gio-media-item.c \
rygel-folder-plugin.c
$(BUILT_SOURCES) : rygel-media-folder.stamp
rygel-folder-container.c \
rygel-folder-container.vala \
rygel-folder-directory-search-result.c \
- rygel-folder-directory-search-result.vala \
- rygel-folder-gio-media-item.c \
- rygel-folder-gio-media-item.vala
+ rygel-folder-directory-search-result.vala
rygel-media-folder.stamp: $(filter %.vala,$(librygel_media_folder_la_SOURCES))
$(VALAC) -g -C --vapidir=$(top_srcdir)/src/rygel \
f);
} else {
- try {
- item = FolderGioMediaItem.create (
- (MediaContainer) source_object,
- f,
- file_info);
- } catch (Error error) {
- }
+ item = get_media_item ((MediaContainer) source_object,
+ f,
+ file_info);
}
if (item != null) {
null,
enumerator_closed);
}
- }
- catch (Error e) {
+ } catch (Error e) {
this.error = e;
this.complete ();
}
return children;
}
+
+ private MediaItem? get_media_item (MediaContainer parent,
+ File file,
+ FileInfo info) {
+ string content_type = info.get_content_type ();
+ string item_class = null;
+ string id = Checksum.compute_for_string (ChecksumType.MD5,
+ info.get_name ());
+
+ // use heuristics based on content type; will use MediaHarvester
+ // when it's ready
+
+ if (content_type.has_prefix ("video/")) {
+ item_class = MediaItem.VIDEO_CLASS;
+ } else if (content_type.has_prefix ("audio/")) {
+ item_class = MediaItem.AUDIO_CLASS;
+ } else if (content_type.has_prefix ("image/")) {
+ item_class = MediaItem.IMAGE_CLASS;
+ }
+
+ if (null == item_class) {
+ return null;
+ }
+
+ MediaItem item = new Rygel.MediaItem (id,
+ parent,
+ info.get_name (),
+ item_class);
+ item.mime_type = content_type;
+ item.uris.add (GLib.Markup.escape_text (file.get_uri ()));
+
+ return item;
+ }
}
+++ /dev/null
-/*
- * Copyright (C) 2009 Jens Georg <mail@jensge.org>.
- *
- * This file is part of Rygel.
- *
- * Rygel is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Rygel is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-using GLib;
-using Rygel;
-using Gst;
-
-/**
- * Very simple media item.
- */
-public class Rygel.FolderGioMediaItem : Rygel.MediaItem {
- private bool need_source;
- private string raw_uri;
-
- private static string? get_upnp_class (string content_type) {
- if (content_type.has_prefix ("video/")) {
- return MediaItem.VIDEO_CLASS;
- } else if (content_type.has_prefix ("audio/")) {
- return MediaItem.AUDIO_CLASS;
- } else if (content_type.has_prefix ("image/")) {
- return MediaItem.IMAGE_CLASS;
- }
-
- return null;
- }
-
-
- public static FolderGioMediaItem? create(MediaContainer parent,
- File file,
- FileInfo file_info) {
- var upnp_class = get_upnp_class (file_info.get_content_type ());
- if (upnp_class != null) {
- return new FolderGioMediaItem (parent,
- file,
- upnp_class,
- file_info);
- }
-
- return null;
- }
-
- public FolderGioMediaItem(MediaContainer parent,
- File file,
- string item_class,
- FileInfo file_info) {
-
- base (Checksum.compute_for_string (ChecksumType.MD5,
- file_info.get_name ()),
- parent,
- file_info.get_name (),
- item_class);
-
- var content_type = file_info.get_content_type ();
- need_source = false;
-
-
- this.mime_type = content_type;
- // check if rygel can handle this uri type itself
- if (file.get_uri ().has_prefix ("file:") ||
- file.get_uri ().has_prefix ("http:")) {
- this.uris.add (GLib.Markup.escape_text (file.get_uri ()));
- }
- else {
- need_source = true;
- raw_uri = file.get_uri ();
- }
- }
-
- public override Gst.Element? create_stream_source () {
- if (need_source) {
- dynamic Element src = ElementFactory.make ("giosrc", null);
- if (src != null) {
- src.location = raw_uri;
- }
-
- return src;
- }
-
- return null;
- }
-}