sync with tizen branch for bug fix 47/309347/1 accepted/tizen_8.0_unified tizen_8.0 accepted/tizen/8.0/unified/20240412.062924
authorJihoon Jung <jh8801.jung@samsung.com>
Tue, 9 Apr 2024 05:44:12 +0000 (14:44 +0900)
committerJihoon Jung <jh8801.jung@samsung.com>
Tue, 9 Apr 2024 05:46:34 +0000 (14:46 +0900)
Change-Id: Ic4aaaa7c110487eb17ec1c2bc1876f0721f35277
Signed-off-by: Jihoon Jung <jh8801.jung@samsung.com>
packaging/libmtp.spec
src/libmtp.c

index 7558ea4..a33953a 100644 (file)
@@ -3,7 +3,7 @@
 Name:       libmtp
 Summary:    Library for media transfer protocol (mtp)
 Version:    1.1.11
-Release:    15
+Release:    16
 Group:      Network & Connectivity/Other
 License:    LGPL-2.1
 Source0:    libmtp-%{version}.tar.gz
index 859c99c..4a139d2 100644 (file)
@@ -5247,13 +5247,22 @@ int LIBMTP_Get_File_To_File_Descriptor(LIBMTP_mtpdevice_t *device,
   PTP_USB *ptp_usb = (PTP_USB*) device->usbinfo;
   PTPObject *ob;
 
+  int oldtimeout;
+
+  get_usb_device_timeout(ptp_usb, &oldtimeout);
+  set_usb_device_timeout(ptp_usb, 5000);
+
+  LIBMTP_INFO("priv set timeout value : %d, now, set timeout value to 5 sec", oldtimeout);
+
   ret = ptp_object_want (params, id, PTPOBJECT_OBJECTINFO_LOADED, &ob);
   if (ret != PTP_RC_OK) {
     add_error_to_errorstack(device, LIBMTP_ERROR_GENERAL, "LIBMTP_Get_File_To_File_Descriptor(): Could not get object info.");
+    set_usb_device_timeout(ptp_usb, oldtimeout);
     return -1;
   }
   if (ob->oi.ObjectFormat == PTP_OFC_Association) {
     add_error_to_errorstack(device, LIBMTP_ERROR_GENERAL, "LIBMTP_Get_File_To_File_Descriptor(): Bad object format.");
+    set_usb_device_timeout(ptp_usb, oldtimeout);
     return -1;
   }
 
@@ -5271,6 +5280,8 @@ int LIBMTP_Get_File_To_File_Descriptor(LIBMTP_mtpdevice_t *device,
   ptp_usb->current_transfer_callback = NULL;
   ptp_usb->current_transfer_callback_data = NULL;
 
+  set_usb_device_timeout(ptp_usb, oldtimeout);
+
   if (ret == PTP_ERROR_CANCEL) {
     add_error_to_errorstack(device, LIBMTP_ERROR_CANCELLED, "LIBMTP_Get_File_From_File_Descriptor(): Cancelled transfer.");
     return -1;
@@ -9389,6 +9400,29 @@ int LIBMTP_Get_Object_Handles(LIBMTP_mtpdevice_t *device, uint32_t storage,
        return 0;
 }
 
+static const char *__get_filename_ext(const char *filename) {
+       const char *dot = strrchr(filename, '.');
+       if(!dot || dot == filename) return "";
+       return dot + 1;
+}
+
+static int __is_high_efficiency_image(char *filename)
+{
+       if (filename == NULL)
+               return 0;
+
+       const char *ext = __get_filename_ext(filename);
+       if (ext == NULL)
+               return 0;
+
+       if (0 == strncmp(ext, "heic", strlen(ext))
+       || 0 == strncmp(ext, "heif", strlen(ext))) {
+               return 1;
+       }
+
+       return 0;
+}
+
 MTPObjectInfo *LIBMTP_Get_Object_Info(LIBMTP_mtpdevice_t *device, uint32_t object_id)
 {
        PTPParams *params = (PTPParams *)device->params;
@@ -9443,7 +9477,14 @@ MTPObjectInfo *LIBMTP_Get_Object_Info(LIBMTP_mtpdevice_t *device, uint32_t objec
        else
                object_info->Keywords = NULL;
 
-       object_info->ObjectFormat = map_ptp_type_to_libmtp_type(object_info->ObjectFormat);
+       LIBMTP_INFO("Filename : %s, Object Format : %hu", object_info->Filename, object_info->ObjectFormat);
+       if (object_info->ObjectFormat == PTP_OFC_Defined && __is_high_efficiency_image(object_info->Filename)) {
+               LIBMTP_INFO("It is HEIF image");
+               object_info->ObjectFormat = LIBMTP_FILETYPE_HEIF;
+       } else {
+               object_info->ObjectFormat = map_ptp_type_to_libmtp_type(object_info->ObjectFormat);
+       }
+
        object_info->ThumbFormat = map_ptp_type_to_libmtp_type(object_info->ThumbFormat);
 
        return object_info;