#define VIDEO_PREFIX "video/"
#define VIDEO_PREFIX_LEN 6
-#define MEDIA_SVC_DEFAULT_GPS_VALUE -200 /**< Default GPS Value*/
-
#define MEDIA_SVC_PDF_TAG_TAIL_LEN 12
#define MEDIA_SVC_PDF_BUF_SIZE 256
return g_strdup(uuid_unparsed);
}
-/* GPS information is not ExifTag member */
-static int __media_svc_get_exif_gps_double(ExifData *ed, double *value, long tagtype)
-{
- ExifEntry *entry;
- char gps_buf[MEDIA_SVC_METADATA_LEN_MAX + 1] = {0, };
- double tmp_arr[3] = { 0.0, 0.0, 0.0 };
- int i = 0;
- char **tmp_split = NULL;
-
- media_svc_retv_if(!ed, MS_MEDIA_ERR_INVALID_PARAMETER);
- media_svc_retv_if(!value, MS_MEDIA_ERR_INVALID_PARAMETER);
-
- entry = exif_data_get_entry(ed, tagtype);
- media_svc_retv_if(!entry, MS_MEDIA_ERR_INTERNAL);
-
- exif_entry_get_value(entry, gps_buf, sizeof(gps_buf));
- gps_buf[strlen(gps_buf)] = '\0';
-
- tmp_split = g_strsplit(gps_buf, ",", -1);
- if (g_strv_length(tmp_split) != 3) {
- g_strfreev(tmp_split);
- media_svc_error("Wrong GPS format");
- return MS_MEDIA_ERR_INTERNAL;
- }
-
- for (i = 0; i < 3; i++)
- tmp_arr[i] = g_strtod(tmp_split[i], NULL);
-
- g_strfreev(tmp_split);
-
- *value = tmp_arr[0] + tmp_arr[1] / 60 + tmp_arr[2] / 3600;
-
- return MS_MEDIA_ERR_NONE;
-}
-
-static int __media_svc_get_exif_gps_str(ExifData *ed, char *value, long tagtype)
-{
- ExifEntry *entry;
-
- media_svc_retv_if(!ed, MS_MEDIA_ERR_INVALID_PARAMETER);
- media_svc_retv_if(!value, MS_MEDIA_ERR_INVALID_PARAMETER);
-
- entry = exif_data_get_entry(ed, tagtype);
- if (entry) {
- exif_entry_get_value(entry, value, MEDIA_SVC_METADATA_LEN_MAX);
- value[strlen(value)] = '\0';
- }
-
- return MS_MEDIA_ERR_NONE;
-}
-
-static int __media_svc_get_exif_info(ExifData *ed, char *buf, int *i_value, double *d_value, ExifTag tagtype)
+static int __media_svc_get_exif_info(ExifData *ed, char *buf, int *i_value, ExifTag tagtype)
{
ExifEntry *entry;
ExifByteOrder mByteOrder;
- ExifRational mRational;
- long numerator, denominator;
media_svc_retv_if(!ed, MS_MEDIA_ERR_INVALID_PARAMETER);
case EXIF_TAG_ORIENTATION:
case EXIF_TAG_PIXEL_X_DIMENSION:
case EXIF_TAG_PIXEL_Y_DIMENSION:
- case EXIF_TAG_ISO_SPEED_RATINGS:
media_svc_retvm_if(!i_value, MS_MEDIA_ERR_INVALID_PARAMETER, "i_value is NULL");
mByteOrder = exif_data_get_byte_order(ed);
short exif_value = exif_get_short(entry->data, mByteOrder);
*i_value = (int)exif_value;
break;
- case EXIF_TAG_EXPOSURE_TIME:
- media_svc_retvm_if(!buf, MS_MEDIA_ERR_INVALID_PARAMETER, "buf is NULL");
-
- mByteOrder = exif_data_get_byte_order(ed);
- mRational = exif_get_rational(entry->data, mByteOrder);
- numerator = mRational.numerator;
- denominator = mRational.denominator;
- snprintf(buf, MEDIA_SVC_METADATA_LEN_MAX, "%ld/%ld", numerator, denominator);
- break;
- case EXIF_TAG_FNUMBER:
- media_svc_retvm_if(!d_value, MS_MEDIA_ERR_INVALID_PARAMETER, "d_value is NULL");
-
- mByteOrder = exif_data_get_byte_order(ed);
- mRational = exif_get_rational(entry->data, mByteOrder);
- numerator = mRational.numerator;
- denominator = mRational.denominator;
-
- *d_value = ((numerator*1.0)/(denominator*1.0));
- break;
default:
media_svc_retvm_if(!buf, MS_MEDIA_ERR_INVALID_PARAMETER, "buf is NULL");
return MS_MEDIA_ERR_NONE;
}
-static int __image_360_check(const char *path)
-{
- FILE *fp = NULL;
- size_t size = 0, app1_size = 0, exif_app1_xmp_size = 0;
- unsigned char exif_header[4] = {0, };
- unsigned char exif_app1[2] = {0, };
- unsigned char exif_app1_xmp[2] = {0, };
- unsigned char exif_app1_xmp_t[2] = {0, };
- GString *xmp_data = NULL;
- int fdata = 0;
- int result = 0;
-
- memset(exif_header, 0x00, sizeof(exif_header));
- memset(exif_app1, 0x00, sizeof(exif_app1));
- memset(exif_app1_xmp, 0x00, sizeof(exif_app1_xmp));
- memset(exif_app1_xmp_t, 0x00, sizeof(exif_app1_xmp_t));
-
- fp = fopen(path, "rb");
- if (fp == NULL)
- goto ERROR;
-
- size = fread(exif_header, 1, sizeof(exif_header), fp);
- if (size != sizeof(exif_header))
- goto ERROR;
-
- if ((exif_header[0] == 0xff) && (exif_header[1] == 0xd8) && (exif_header[2] == 0xff) && (exif_header[3] == 0xe1)) {
- size = fread(exif_app1, 1, sizeof(exif_app1), fp);
- if (size != sizeof(exif_app1))
- goto ERROR;
-
- if ((size_t)((exif_app1[0] << 8) | (exif_app1[1])) <= 2)
- goto ERROR;
-
- app1_size = (size_t)((exif_app1[0] << 8) | (exif_app1[1])) - 2 ;
- if (fseek(fp, app1_size, SEEK_CUR) != 0)
- goto ERROR;
-
- size = fread(exif_app1_xmp, 1, sizeof(exif_app1_xmp), fp);
- if (size != sizeof(exif_app1_xmp))
- goto ERROR;
-
- if ((exif_app1_xmp[0] == 0xff) && (exif_app1_xmp[1] == 0xe1)) {
- size = fread(exif_app1_xmp_t, 1, sizeof(exif_app1_xmp_t), fp);
- if (size != sizeof(exif_app1_xmp_t))
- goto ERROR;
-
- if ((size_t)((exif_app1_xmp_t[0] << 8) | (exif_app1_xmp_t[1])) <= 2)
- goto ERROR;
-
- exif_app1_xmp_size = (size_t)((exif_app1_xmp_t[0] << 8) | (exif_app1_xmp_t[1])) - 2;
-
- xmp_data = g_string_sized_new(exif_app1_xmp_size);
-
- do {
- exif_app1_xmp_size--;
- fdata = fgetc(fp);
- if (fdata == EOF)
- continue;
- if (fdata == '\0')
- continue;
-
- xmp_data = g_string_append_c(xmp_data, (gchar)fdata);
- } while (exif_app1_xmp_size > 0);
-
- if (strstr(xmp_data->str, "UsePanoramaViewer") &&
- strstr(xmp_data->str, "True") &&
- strstr(xmp_data->str, "ProjectionType") &&
- strstr(xmp_data->str, "equirectangular"))
- result = 1;
-
- g_string_free(xmp_data, TRUE);
- }
- }
-
-ERROR:
- if (fp) {
- fclose(fp);
- fp = NULL;
- }
-
- return result;
-}
-
static char * __media_svc_get_title(MMHandleType tag, const char *path)
{
int ret = FILEINFO_ERROR_NONE;
int _media_svc_extract_image_metadata(media_svc_content_info_s *content_info)
{
- double value = 0.0;
int orient_value = 0;
int exif_width = 0;
int exif_height = 0;
ExifData *ed = NULL;
bool has_datetaken = false;
- double fnumber = 0.0;
- int iso = 0;
char *path = NULL;
char buf[MEDIA_SVC_METADATA_LEN_MAX + 1] = { '\0' };
path = content_info->path;
content_info->media_meta.title = __media_svc_get_title(NULL, path);
- content_info->media_meta.latitude = MEDIA_SVC_DEFAULT_GPS_VALUE;
- content_info->media_meta.longitude = MEDIA_SVC_DEFAULT_GPS_VALUE;
- content_info->media_meta.altitude = MEDIA_SVC_DEFAULT_GPS_VALUE;
-
/* Not used. But to preserved the behavior, set MEDIA_SVC_TAG_UNKNOWN. */
content_info->media_meta.album = g_strdup(MEDIA_SVC_TAG_UNKNOWN);
content_info->media_meta.artist = g_strdup(MEDIA_SVC_TAG_UNKNOWN);
goto GET_WIDTH_HEIGHT;
}
- content_info->media_meta.is_360 = __image_360_check(path);
-
- memset(buf, 0x00, sizeof(buf));
- if (__media_svc_get_exif_gps_double(ed, &value, EXIF_TAG_GPS_LATITUDE) == MS_MEDIA_ERR_NONE) {
- if (__media_svc_get_exif_gps_str(ed, buf, EXIF_TAG_GPS_LATITUDE_REF) == MS_MEDIA_ERR_NONE) {
- if (!g_strcmp0(buf, "S"))
- value *= -1;
- content_info->media_meta.latitude = value;
- }
- }
-
memset(buf, 0x00, sizeof(buf));
- if (__media_svc_get_exif_gps_double(ed, &value, EXIF_TAG_GPS_LONGITUDE) == MS_MEDIA_ERR_NONE) {
- if (__media_svc_get_exif_gps_str(ed, buf, EXIF_TAG_GPS_LONGITUDE_REF) == MS_MEDIA_ERR_NONE) {
- if (!g_strcmp0(buf, "W"))
- value *= -1;
-
- content_info->media_meta.longitude = value;
- }
- }
-
- memset(buf, 0x00, sizeof(buf));
- if (__media_svc_get_exif_info(ed, buf, NULL, NULL, EXIF_TAG_IMAGE_DESCRIPTION) == MS_MEDIA_ERR_NONE) {
+ if (__media_svc_get_exif_info(ed, buf, NULL, EXIF_TAG_IMAGE_DESCRIPTION) == MS_MEDIA_ERR_NONE) {
if (strlen(buf) > 0)
content_info->media_meta.description = g_strdup(buf);
else
}
memset(buf, 0x00, sizeof(buf));
- if (!has_datetaken && __media_svc_get_exif_info(ed, buf, NULL, NULL, EXIF_TAG_DATE_TIME_ORIGINAL) == MS_MEDIA_ERR_NONE) {
+ if (!has_datetaken && __media_svc_get_exif_info(ed, buf, NULL, EXIF_TAG_DATE_TIME_ORIGINAL) == MS_MEDIA_ERR_NONE) {
if (strlen(buf) > 0) {
has_datetaken = true;
content_info->media_meta.datetaken = g_strdup(buf);
}
memset(buf, 0x00, sizeof(buf));
- if (!has_datetaken && __media_svc_get_exif_info(ed, buf, NULL, NULL, EXIF_TAG_DATE_TIME) == MS_MEDIA_ERR_NONE) {
+ if (!has_datetaken && __media_svc_get_exif_info(ed, buf, NULL, EXIF_TAG_DATE_TIME) == MS_MEDIA_ERR_NONE) {
if (strlen(buf) > 0) {
has_datetaken = true;
content_info->media_meta.datetaken = g_strdup(buf);
media_svc_debug("Timeline : %ld", content_info->timeline);
}
- memset(buf, 0x00, sizeof(buf));
- /* Get exposure_time value from exif. */
- if (__media_svc_get_exif_info(ed, buf, NULL, NULL, EXIF_TAG_EXPOSURE_TIME) == MS_MEDIA_ERR_NONE) {
- if (strlen(buf) > 0)
- content_info->media_meta.exposure_time = g_strdup(buf);
- }
-
- /* Get fnumber value from exif. */
- if (__media_svc_get_exif_info(ed, NULL, NULL, &fnumber, EXIF_TAG_FNUMBER) == MS_MEDIA_ERR_NONE)
- content_info->media_meta.fnumber = fnumber;
-
- /* Get iso value from exif. */
- if (__media_svc_get_exif_info(ed, NULL, &iso, NULL, EXIF_TAG_ISO_SPEED_RATINGS) == MS_MEDIA_ERR_NONE)
- content_info->media_meta.iso = iso;
-
- memset(buf, 0x00, sizeof(buf));
- /* Get model value from exif. */
- if (__media_svc_get_exif_info(ed, buf, NULL, NULL, EXIF_TAG_MODEL) == MS_MEDIA_ERR_NONE) {
- if (strlen(buf) > 0)
- content_info->media_meta.model = g_strdup(buf);
- }
-
/* Get orientation value from exif. */
- if (__media_svc_get_exif_info(ed, NULL, &orient_value, NULL, EXIF_TAG_ORIENTATION) == MS_MEDIA_ERR_NONE) {
+ if (__media_svc_get_exif_info(ed, NULL, &orient_value, EXIF_TAG_ORIENTATION) == MS_MEDIA_ERR_NONE) {
if (orient_value >= NOT_AVAILABLE && orient_value <= ROT_270)
content_info->media_meta.orientation = orient_value;
}
/* Get width value from exif. */
- if (__media_svc_get_exif_info(ed, NULL, &exif_width, NULL, EXIF_TAG_PIXEL_X_DIMENSION) == MS_MEDIA_ERR_NONE) {
+ if (__media_svc_get_exif_info(ed, NULL, &exif_width, EXIF_TAG_PIXEL_X_DIMENSION) == MS_MEDIA_ERR_NONE) {
if (exif_width > 0)
content_info->media_meta.width = exif_width;
}
/* Get height value from exif. */
- if (__media_svc_get_exif_info(ed, NULL, &exif_height, NULL, EXIF_TAG_PIXEL_Y_DIMENSION) == MS_MEDIA_ERR_NONE) {
+ if (__media_svc_get_exif_info(ed, NULL, &exif_height, EXIF_TAG_PIXEL_Y_DIMENSION) == MS_MEDIA_ERR_NONE) {
if (exif_height > 0)
content_info->media_meta.height = exif_height;
}
content_info->media_meta.rating = 0;
}
- mmf_error = mm_file_get_attrs(tag, MM_FILE_TAG_SPHERICAL, &content_info->media_meta.is_360, NULL);
-
/*Do not extract artwork for the USB Storage content*/
if (support_albumart) {
mmf_error = mm_file_get_attrs(tag, MM_FILE_TAG_ARTWORK, &image, &size, NULL);
content_info->album_id = album_id;
}
- content_info->media_meta.longitude = MEDIA_SVC_DEFAULT_GPS_VALUE;
- content_info->media_meta.latitude = MEDIA_SVC_DEFAULT_GPS_VALUE;
- content_info->media_meta.altitude = MEDIA_SVC_DEFAULT_GPS_VALUE;
-
if (content_info->media_type == MEDIA_SVC_MEDIA_TYPE_VIDEO) {
- double longitude = 0.0;
- double latitude = 0.0;
- double altitude = 0.0;
-
- mm_file_get_attrs(tag, MM_FILE_TAG_LONGITUDE, &longitude,
- MM_FILE_TAG_LATIDUE, &latitude,
- MM_FILE_TAG_ALTIDUE, &altitude,
- NULL);
-
- content_info->media_meta.longitude = (longitude == 0.0) ? MEDIA_SVC_DEFAULT_GPS_VALUE : longitude;
- content_info->media_meta.latitude = (latitude == 0.0) ? MEDIA_SVC_DEFAULT_GPS_VALUE : latitude;
- content_info->media_meta.altitude = (altitude == 0.0) ? MEDIA_SVC_DEFAULT_GPS_VALUE : altitude;
-
mmf_error = mm_file_get_attrs(tag, MM_FILE_TAG_ROTATE, &p, &size, NULL);
if ((mmf_error == FILEINFO_ERROR_NONE) && (size > 0)) {
content_info->media_meta.orientation = atoi(p);
g_free(content_info->media_meta.track_num);
g_free(content_info->media_meta.description);
g_free(content_info->media_meta.datetaken);
- g_free(content_info->media_meta.exposure_time);
- g_free(content_info->media_meta.model);
}
int _media_svc_create_thumbnail(const char *path, char *thumb_path, media_svc_media_type_e media_type, uid_t uid)