diff options
| author | hathach <[email protected]> | 2025-09-21 21:39:27 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2025-09-21 21:39:27 +0700 |
| commit | 4c818998d499a5a22c27ddfafc618e04ddcb823f (patch) | |
| tree | 0847555c60caf49730f84ba81dad1a853b7a8ceb /src | |
| parent | f5a3f25456bcfae65de9b60c8073986f4cdc8f16 (diff) | |
implement get object info
Diffstat (limited to 'src')
| -rw-r--r-- | src/class/mtp/mtp.h | 35 | ||||
| -rw-r--r-- | src/class/mtp/mtp_device.c | 25 | ||||
| -rw-r--r-- | src/class/mtp/mtp_device_storage.h | 4 |
3 files changed, 20 insertions, 44 deletions
diff --git a/src/class/mtp/mtp.h b/src/class/mtp/mtp.h index c6ff2946a..61adc29e4 100644 --- a/src/class/mtp/mtp.h +++ b/src/class/mtp/mtp.h @@ -647,11 +647,12 @@ typedef enum { typedef enum { MTP_ASSOCIATION_UNDEFINED = 0x0000u, MTP_ASSOCIATION_GENERIC_FOLDER = 0x0001u, - MTP_ASSOCIATION_GENERIC_ALBUM = 0x0002u, + MTP_ASSOCIATION_ALBUM = 0x0002u, MTP_ASSOCIATION_TIME_SEQUENCE = 0x0003u, MTP_ASSOCIATION_HORIZONTAL_PANORAMIC = 0x0004u, MTP_ASSOCIATION_VERTICAL_PANORAMIC = 0x0005u, MTP_ASSOCIATION_2D_PANORAMIC = 0x0006u, + MTP_ASSOCIATION_ANCILLARY_DATA = 0x0007u, } mtp_association_t; //--------------------------------------------------------------------+ @@ -705,7 +706,7 @@ typedef union TU_ATTR_PACKED { uint32_t id; } mtp_storage_id_t; -#define MTP_STORAGE_INFO_TYPEDEF(_storage_desc_chars, _volume_id_chars) \ +#define MTP_STORAGE_INFO_STRUCT(_storage_desc_chars, _volume_id_chars) \ struct TU_ATTR_PACKED { \ uint16_t storage_type; \ uint16_t filesystem_type; \ @@ -717,29 +718,24 @@ typedef union TU_ATTR_PACKED { mtp_string_t(_volume_id_chars) volume_identifier; \ } -// ObjectInfo Dataset +// Object Info Dataset without dynamic string: filename, date_created, date_modified, keywords typedef struct TU_ATTR_PACKED { uint32_t storage_id; uint16_t object_format; uint16_t protection_status; uint32_t object_compressed_size; - uint16_t thumb_format; // unused - uint32_t thumb_compressed_size; // unused - uint32_t thumb_pix_width; // unused - uint32_t thumb_pix_height; // unused - uint32_t image_pix_width; // unused - uint32_t image_pix_height; // unused - uint32_t image_bit_depth; // unused + uint16_t thumb_format; + uint32_t thumb_compressed_size; + uint32_t thumb_pix_width; + uint32_t thumb_pix_height; + uint32_t image_pix_width; + uint32_t image_pix_height; + uint32_t image_bit_depth; uint32_t parent_object; // 0: root uint16_t association_type; - uint32_t association_description; // not used - uint32_t sequence_number; // not used -} mtp_object_info_t; -// The following fields will be dynamically added to the struct at runtime: -// - wstring filename; -// - datetime_wstring date_created; -// - datetime_wstring date_modified; -// - wstring keywords; + uint32_t association_desc; + uint32_t sequence_number; +} mtp_object_info_header_t; // Device property desc up to get/set typedef struct TU_ATTR_PACKED { @@ -754,7 +750,7 @@ typedef struct TU_ATTR_PACKED { // - uint8_t form_flag; // no form -#define MTP_DEVICE_PROPERTIES_TYPEDEF(_type) \ +#define MTP_DEVICE_PROPERTIES_STRUCT(_type) \ struct TU_ATTR_PACKED { \ uint16_t device_property_code; \ uint16_t datatype; \ @@ -764,7 +760,6 @@ typedef struct TU_ATTR_PACKED { uint8_t form_flag; /* 0: none, 1: range, 2: enum */ \ }; - typedef struct TU_ATTR_PACKED { uint16_t wLength; uint16_t code; diff --git a/src/class/mtp/mtp_device.c b/src/class/mtp/mtp_device.c index 8e403f9ac..22ef45cd9 100644 --- a/src/class/mtp/mtp_device.c +++ b/src/class/mtp/mtp_device.c @@ -85,7 +85,6 @@ static mtp_phase_type_t mtpd_chk_session_open(const char *func_name); static mtp_phase_type_t mtpd_handle_cmd(mtpd_interface_t* p_mtp); static mtp_phase_type_t mtpd_handle_data(void); static mtp_phase_type_t mtpd_handle_cmd_close_session(void); -static mtp_phase_type_t mtpd_handle_cmd_get_object_info(void); static mtp_phase_type_t mtpd_handle_cmd_get_object(void); static mtp_phase_type_t mtpd_handle_dti_get_object(void); static mtp_phase_type_t mtpd_handle_cmd_delete_object(void); @@ -454,7 +453,8 @@ mtp_phase_type_t mtpd_handle_cmd(mtpd_interface_t* p_mtp) { case MTP_OP_GET_OBJECT_INFO: TU_LOG_DRV(" MTP command: MTP_OP_GET_OBJECT_INFO\n"); - return mtpd_handle_cmd_get_object_info(); + break; + case MTP_OP_GET_OBJECT: TU_LOG_DRV(" MTP command: MTP_OP_GET_OBJECT\n"); return mtpd_handle_cmd_get_object(); @@ -528,25 +528,6 @@ mtp_phase_type_t mtpd_handle_cmd_close_session(void) return MTP_PHASE_RESPONSE; } -mtp_phase_type_t mtpd_handle_cmd_get_object_info(void) -{ - TU_VERIFY_STATIC(sizeof(mtp_object_info_t) < MTP_MAX_PACKET_SIZE, "mtp_object_info_t shall fit in MTP_MAX_PACKET_SIZE"); - mtp_generic_container_t* p_container = &_mtpd_epbuf.container; - uint32_t object_handle = p_container->data[0]; - - p_container->len = MTP_CONTAINER_HEADER_LENGTH + sizeof(mtp_object_info_t); - p_container->type = MTP_CONTAINER_TYPE_DATA_BLOCK; - p_container->code = MTP_OP_GET_OBJECT_INFO; - mtp_response_t res = tud_mtp_storage_object_read_info(object_handle, (mtp_object_info_t *)p_container->data); - mtp_phase_type_t phase; - if ((phase = mtpd_chk_generic(__func__, (res != MTP_RESP_OK), res, "")) != MTP_PHASE_NONE) { - return phase; - } - - _mtpd_itf.queued_len = p_container->len; - return MTP_PHASE_DATA_IN; -} - mtp_phase_type_t mtpd_handle_cmd_get_object(void) { mtp_generic_container_t* p_container = &_mtpd_epbuf.container; @@ -634,7 +615,7 @@ mtp_phase_type_t mtpd_handle_dto_send_object_info(void) { mtp_generic_container_t* p_container = &_mtpd_epbuf.container; uint32_t new_object_handle = 0; - mtp_response_t res = tud_mtp_storage_object_write_info(_mtpd_soi.storage_id, _mtpd_soi.parent_object_handle, &new_object_handle, (mtp_object_info_t *)p_container->data); + mtp_response_t res = tud_mtp_storage_object_write_info(_mtpd_soi.storage_id, _mtpd_soi.parent_object_handle, &new_object_handle, (mtp_object_info_header_t *)p_container->data); mtp_phase_type_t phase; if ((phase = mtpd_chk_generic(__func__, (res != MTP_RESP_OK), res, "")) != MTP_PHASE_NONE) return phase; diff --git a/src/class/mtp/mtp_device_storage.h b/src/class/mtp/mtp_device_storage.h index 6c12d38e3..29d4b0bd5 100644 --- a/src/class/mtp/mtp_device_storage.h +++ b/src/class/mtp/mtp_device_storage.h @@ -77,7 +77,7 @@ mtp_response_t tud_mtp_storage_association_get_object_handle(uint32_t session_ha // The handle of the new object shall be returned in new_object_handle. // The structure info contains the information to be used for file creation, as passted by the host. // Note that the variable information (e.g. wstring file name, dates and tags shall be retrieved by using the library functions) -mtp_response_t tud_mtp_storage_object_write_info(uint32_t storage_id, uint32_t parent_object, uint32_t *new_object_handle, const mtp_object_info_t *info); +mtp_response_t tud_mtp_storage_object_write_info(uint32_t storage_id, uint32_t parent_object, uint32_t *new_object_handle, const mtp_object_info_header_t *info); // Get object information related to a given object handle // @@ -89,7 +89,7 @@ mtp_response_t tud_mtp_storage_object_write_info(uint32_t storage_id, uint32_t p // - Date modified (string, use tud_gct_append_date or empty string) // - Keywords (string containing list of kw, separated by space, use tud_mtp_gct_append_wstring) // Note that the variable information (e.g. wstring file name, dates and tags shall be written by using the library functions) -mtp_response_t tud_mtp_storage_object_read_info(uint32_t object_handle, mtp_object_info_t *info); +mtp_response_t tud_mtp_storage_object_read_info(uint32_t object_handle, mtp_object_info_header_t *info); // Get the object size. // |
