#include <lightmediascanner_plugin.h>
#include <lightmediascanner_utils.h>
#include <lightmediascanner_db.h>
+
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#include <strings.h>
+static const struct lms_string_size dlna_mime =
+ LMS_STATIC_STRING_SIZE("image/png");
+static const struct lms_string_size dlna_sm_ico =
+ LMS_STATIC_STRING_SIZE("PNG_SM_ICO");
+static const struct lms_string_size dlna_lrg_ico =
+ LMS_STATIC_STRING_SIZE("PNG_LRG_ICO");
+static const struct lms_string_size dlna_tn =
+ LMS_STATIC_STRING_SIZE("PNG_TN");
+static const struct lms_string_size dlna_lrg =
+ LMS_STATIC_STRING_SIZE("PNG_LRG");
+
+static void
+_fill_dlna_profile(struct lms_image_info *info)
+{
+ const unsigned short w = info->width;
+ const unsigned short h = info->height;
+
+ info->dlna_mime = dlna_mime;
+
+ if (w == 0 || h == 0)
+ return;
+
+ if (w == 48 && h == 48)
+ info->dlna_profile = dlna_sm_ico;
+ else if (w == 120 && h == 120)
+ info->dlna_profile = dlna_lrg_ico;
+ else if (w <= 160 && h <= 160)
+ info->dlna_profile = dlna_tn;
+ else if (w <= 4096 && h <= 4096)
+ info->dlna_profile = dlna_lrg;
+}
+
static inline unsigned int
_chunk_to_uint(unsigned char *buf)
{
if (info.date == 0)
info.date = finfo->mtime;
- if (!info.title.str) {
- long ext_idx;
-
- ext_idx = ((long)match) - 1;
- info.title.len = finfo->path_len - finfo->base - _exts[ext_idx].len;
- info.title.str = malloc((info.title.len + 1) * sizeof(char));
- memcpy(info.title.str, finfo->path + finfo->base, info.title.len);
- info.title.str[info.title.len] = '\0';
- }
-
+ if (!info.title.str)
+ lms_name_from_path(&info.title, finfo->path, finfo->path_len,
+ finfo->base, _exts[((long) match) - 1].len,
+ NULL);
if (info.title.str)
- lms_charset_conv(ctxt->cs_conv, &info.title.str, &info.title.len);
+ lms_charset_conv(ctxt->cs_conv, &info.title.str, &info.title.len);
if (info.artist.str)
lms_charset_conv(ctxt->cs_conv, &info.artist.str, &info.artist.len);
+ _fill_dlna_profile(&info);
+
info.id = finfo->id;
r = lms_db_image_add(plugin->img_db, &info);
plugin->plugin.setup = (lms_plugin_setup_fn_t)_setup;
plugin->plugin.start = (lms_plugin_start_fn_t)_start;
plugin->plugin.finish = (lms_plugin_finish_fn_t)_finish;
+ plugin->plugin.order = 0;
return (struct lms_plugin *)plugin;
}
"PNG images",
PACKAGE_VERSION,
_authors,
- "http://lms.garage.maemo.org"
+ "http://github.com/profusion/lightmediascanner"
};
return &info;