Add LIBMTP_Get_Thumbnail_Format to get thumbnail format of a file.
This CL is created for manually committing http://crrev.com/898023002.

BUG=451930
R=thestig@chromium.org

Review URL: https://codereview.chromium.org/900383002

git-svn-id: http://src.chromium.org/svn/trunk/deps/third_party/libmtp@293974 4ff67af0-8c30-449e-8e8b-ad334ec8d88c
diff --git a/patches/20_get_thumbnail_format.patch b/patches/20_get_thumbnail_format.patch
new file mode 100644
index 0000000..e30cda0
--- /dev/null
+++ b/patches/20_get_thumbnail_format.patch
@@ -0,0 +1,68 @@
+diff --git a/src/libmtp.c b/src/libmtp.c
+index bbe2642..b8f856b 100644
+--- a/src/libmtp.c
++++ b/src/libmtp.c
+@@ -8962,6 +8962,27 @@ int LIBMTP_Get_Thumbnail(LIBMTP_mtpdevice_t *device, uint32_t const id,
+ }
+ 
+ /**
++ * Get thumbnail format of a file.
++ * @param device a pointer to the device to get thumbnail format of.
++ * @param id the object ID of the file to get thumbnail format of.
++ * @return 0 on success, any other value means failure.
++ */
++int LIBMTP_Get_Thumbnail_Format(LIBMTP_mtpdevice_t *device, uint32_t const id,
++                                uint16_t *format)
++{
++  PTPParams *params = (PTPParams *) device->params;
++  uint16_t ret;
++
++  PTPObjectInfo object_info;
++  ret = ptp_getobjectinfo(params, id, &object_info);
++  if (ret != PTP_RC_OK)
++    return -1;
++
++  *format = object_info.ThumbFormat;
++  return 0;
++}
++
++/**
+  * This routine updates an album based on the metadata
+  * supplied. If the <code>tracks</code> field of the metadata
+  * contains a track listing, these tracks will be added to the
+diff --git a/src/libmtp.h b/src/libmtp.h
+index f923cc1..07aa273 100644
+--- a/src/libmtp.h
++++ b/src/libmtp.h
+@@ -924,6 +924,8 @@ int LIBMTP_Get_Representative_Sample(LIBMTP_mtpdevice_t *, uint32_t const,
+                           LIBMTP_filesampledata_t *);
+ int LIBMTP_Get_Thumbnail(LIBMTP_mtpdevice_t *, uint32_t const,
+                          unsigned char **data, unsigned int *size);
++int LIBMTP_Get_Thumbnail_Format(LIBMTP_mtpdevice_t *device, uint32_t const id,
++                                uint16_t *format);
+ 
+ /**
+  * @}
+diff --git a/src/libmtp.h.in b/src/libmtp.h.in
+index 2b2f0bb..49edd3c 100644
+--- a/src/libmtp.h.in
++++ b/src/libmtp.h.in
+@@ -924,6 +924,8 @@ int LIBMTP_Get_Representative_Sample(LIBMTP_mtpdevice_t *, uint32_t const,
+                           LIBMTP_filesampledata_t *);
+ int LIBMTP_Get_Thumbnail(LIBMTP_mtpdevice_t *, uint32_t const,
+                          unsigned char **data, unsigned int *size);
++int LIBMTP_Get_Thumbnail_Format(LIBMTP_mtpdevice_t *device, uint32_t const id,
++                                uint16_t *format);
+ 
+ /**
+  * @}
+diff --git a/src/libmtp.sym b/src/libmtp.sym
+index 4130fe8..1148edd 100644
+--- a/src/libmtp.sym
++++ b/src/libmtp.sym
+@@ -103,4 +103,5 @@ LIBMTP_Set_Playlist_Name
+ LIBMTP_Set_Album_Name
+ LIBMTP_Set_Object_Filename
+ LIBMTP_Get_Thumbnail
++LIBMTP_Get_Thumbnail_Format
+ LIBMTP_Read_Event
diff --git a/src/libmtp.c b/src/libmtp.c
index bbe2642..b8f856b 100644
--- a/src/libmtp.c
+++ b/src/libmtp.c
@@ -8962,6 +8962,27 @@
 }
 
 /**
+ * Get thumbnail format of a file.
+ * @param device a pointer to the device to get thumbnail format of.
+ * @param id the object ID of the file to get thumbnail format of.
+ * @return 0 on success, any other value means failure.
+ */
+int LIBMTP_Get_Thumbnail_Format(LIBMTP_mtpdevice_t *device, uint32_t const id,
+                                uint16_t *format)
+{
+  PTPParams *params = (PTPParams *) device->params;
+  uint16_t ret;
+
+  PTPObjectInfo object_info;
+  ret = ptp_getobjectinfo(params, id, &object_info);
+  if (ret != PTP_RC_OK)
+    return -1;
+
+  *format = object_info.ThumbFormat;
+  return 0;
+}
+
+/**
  * This routine updates an album based on the metadata
  * supplied. If the <code>tracks</code> field of the metadata
  * contains a track listing, these tracks will be added to the
diff --git a/src/libmtp.h b/src/libmtp.h
index f923cc1..07aa273 100644
--- a/src/libmtp.h
+++ b/src/libmtp.h
@@ -924,6 +924,8 @@
                           LIBMTP_filesampledata_t *);
 int LIBMTP_Get_Thumbnail(LIBMTP_mtpdevice_t *, uint32_t const,
                          unsigned char **data, unsigned int *size);
+int LIBMTP_Get_Thumbnail_Format(LIBMTP_mtpdevice_t *device, uint32_t const id,
+                                uint16_t *format);
 
 /**
  * @}
diff --git a/src/libmtp.h.in b/src/libmtp.h.in
index 2b2f0bb..49edd3c 100644
--- a/src/libmtp.h.in
+++ b/src/libmtp.h.in
@@ -924,6 +924,8 @@
                           LIBMTP_filesampledata_t *);
 int LIBMTP_Get_Thumbnail(LIBMTP_mtpdevice_t *, uint32_t const,
                          unsigned char **data, unsigned int *size);
+int LIBMTP_Get_Thumbnail_Format(LIBMTP_mtpdevice_t *device, uint32_t const id,
+                                uint16_t *format);
 
 /**
  * @}
diff --git a/src/libmtp.sym b/src/libmtp.sym
index 4130fe8..1148edd 100644
--- a/src/libmtp.sym
+++ b/src/libmtp.sym
@@ -103,4 +103,5 @@
 LIBMTP_Set_Album_Name
 LIBMTP_Set_Object_Filename
 LIBMTP_Get_Thumbnail
+LIBMTP_Get_Thumbnail_Format
 LIBMTP_Read_Event