1 /* 2 * Copyright (C) 2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 /** 17 * @addtogroup MediaAssetManager 18 * @{ 19 * 20 * @brief Provides APIs of request capability for Media Source. 21 * 22 * @since 12 23 */ 24 25 /** 26 * @file media_asset_change_request_capi.h 27 * 28 * @brief Defines APIs related to media asset change request. 29 * 30 * Provides the ability to change assets. 31 * 32 * @kit MediaLibraryKit 33 * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core 34 * @library libmedia_asset_manager.so 35 * @since 12 36 */ 37 38 #ifndef MULTIMEDIA_MEDIA_LIBRARY_NATIVE_MEDIA_ASSET_CHANGE_REQUEST_H 39 #define MULTIMEDIA_MEDIA_LIBRARY_NATIVE_MEDIA_ASSET_CHANGE_REQUEST_H 40 41 #include "media_asset_base_capi.h" 42 43 #ifdef __cplusplus 44 extern "C" { 45 #endif 46 47 /** 48 * @brief Create a {@link OH_MediaAssetChangeRequest} instance. 49 * 50 * @param mediaAsset the {@link OH_MediaAsset} instance. 51 * @return {@link #MEDIA_LIBRARY_OK} if the method call succeeds. 52 * {@link #MEDIA_LIBRARY_PARAMETER_ERROR} Parameter error. Possible causes: 53 * 1. Mandatory parameters are left unspecified. 54 * 2. Incorrect parameter types. 55 * 3. Parameter verification failed. 56 * {@link #MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR} if internal system error. 57 * @since 12 58 */ 59 OH_MediaAssetChangeRequest* OH_MediaAssetChangeRequest_Create(OH_MediaAsset* mediaAsset); 60 61 /** 62 * @brief Add resource of the asset using file uri. 63 * 64 * @param changeRequest the {@link OH_MediaAssetChangeRequest} instance. 65 * @param resourceType the {@link MediaLibrary_ResourceType} of the resource to add. 66 * @param fileUri the file uri. 67 * @return {@link #MEDIA_LIBRARY_OK} if the method call succeeds. 68 * {@link #MEDIA_LIBRARY_PARAMETER_ERROR} Parameter error. Possible causes: 69 * 1. Mandatory parameters are left unspecified. 70 * 2. Incorrect parameter types. 71 * 3. Parameter verification failed. 72 * {@link #MEDIA_LIBRARY_NO_SUCH_FILE} if file does not exist. 73 * {@link #MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR} if internal system error. 74 * {@link #MEDIA_LIBRARY_OPERATION_NOT_SUPPORTED} if operation is not supported. 75 * @since 13 76 */ 77 MediaLibrary_ErrorCode OH_MediaAssetChangeRequest_AddResourceWithUri(OH_MediaAssetChangeRequest* changeRequest, 78 MediaLibrary_ResourceType resourceType, char* fileUri); 79 80 /** 81 * @brief Add resource of the asset using ArrayBuffer. 82 * 83 * @param changeRequest the {@link OH_MediaAssetChangeRequest} instance. 84 * @param resourceType the {@link MediaLibrary_ResourceType} of the resource to add. 85 * @param buffer the data buffer to add. 86 * @param length the length of the data buffer. 87 * @return {@link #MEDIA_LIBRARY_OK} if the method call succeeds. 88 * {@link #MEDIA_LIBRARY_PARAMETER_ERROR} Parameter error. Possible causes: 89 * 1. Mandatory parameters are left unspecified. 90 * 2. Incorrect parameter types. 91 * 3. Parameter verification failed. 92 * {@link #MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR} if internal system error. 93 * {@link #MEDIA_LIBRARY_OPERATION_NOT_SUPPORTED} if operation is not supported. 94 * @since 12 95 */ 96 MediaLibrary_ErrorCode OH_MediaAssetChangeRequest_AddResourceWithBuffer(OH_MediaAssetChangeRequest* changeRequest, 97 MediaLibrary_ResourceType resourceType, uint8_t* buffer, uint32_t length); 98 99 /** 100 * @brief Get write cache handler. 101 * 102 * @permission ohos.permission.WRITE_IMAGEVIDEO 103 * @param changeRequest the {@link OH_MediaAssetChangeRequest} instance. 104 * @param fd the write cache handler. 105 * @return {@link #MEDIA_LIBRARY_OK} if the method call succeeds. 106 * {@link #MEDIA_LIBRARY_PARAMETER_ERROR} Parameter error. Possible causes: 107 * 1. Mandatory parameters are left unspecified. 108 * 2. Incorrect parameter types. 109 * 3. Parameter verification failed. 110 * {@link #MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR} if internal system error. 111 * {@link #MEDIA_LIBRARY_PERMISSION_DENIED} if permission is denied. 112 * {@link #MEDIA_LIBRARY_OPERATION_NOT_SUPPORTED} if operation is not supported. 113 * @since 13 114 */ 115 MediaLibrary_ErrorCode OH_MediaAssetChangeRequest_GetWriteCacheHandler(OH_MediaAssetChangeRequest* changeRequest, 116 int32_t* fd); 117 118 /** 119 * @brief Save the photo asset captured by camera. 120 * 121 * @param changeRequest the {@link OH_MediaAssetChangeRequest} instance. 122 * @param imageFileType The {@link MediaLibrary_ImageFileType} of photo to be saved. 123 * @return {@link #MEDIA_LIBRARY_OK} if the method call succeeds. 124 * {@link #MEDIA_LIBRARY_PARAMETER_ERROR} Parameter error. Possible causes: 125 * 1. Mandatory parameters are left unspecified. 126 * 2. Incorrect parameter types. 127 * 3. Parameter verification failed. 128 * {@link #MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR} if internal system error. 129 * {@link #MEDIA_LIBRARY_OPERATION_NOT_SUPPORTED} if operation is not supported. 130 * @since 12 131 */ 132 MediaLibrary_ErrorCode OH_MediaAssetChangeRequest_SaveCameraPhoto(OH_MediaAssetChangeRequest* changeRequest, 133 MediaLibrary_ImageFileType imageFileType); 134 135 /** 136 * @brief Discard the photo asset captured by camera. 137 * 138 * @param changeRequest the {@link OH_MediaAssetChangeRequest} instance. 139 * @return {@link #MEDIA_LIBRARY_OK} if the method call succeeds. 140 * {@link #MEDIA_LIBRARY_PARAMETER_ERROR} Parameter error. Possible causes: 141 * 1. Mandatory parameters are left unspecified. 142 * 2. Incorrect parameter types. 143 * 3. Parameter verification failed. 144 * {@link #MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR} if internal system error. 145 * {@link #MEDIA_LIBRARY_OPERATION_NOT_SUPPORTED} if operation is not supported. 146 * @since 12 147 */ 148 MediaLibrary_ErrorCode OH_MediaAssetChangeRequest_DiscardCameraPhoto(OH_MediaAssetChangeRequest* changeRequest); 149 150 /** 151 * @brief Release the {@link OH_MediaAssetChangeRequest} instance. 152 * 153 * @param changeRequest the {@link OH_MediaAssetChangeRequest} instance. 154 * @return {@link #MEDIA_LIBRARY_OK} if the method call succeeds. 155 * {@link #MEDIA_LIBRARY_PARAMETER_ERROR} Parameter error. Possible causes: 156 * 1. Mandatory parameters are left unspecified. 157 * 2. Incorrect parameter types. 158 * 3. Parameter verification failed. 159 * @since 12 160 */ 161 MediaLibrary_ErrorCode OH_MediaAssetChangeRequest_Release(OH_MediaAssetChangeRequest* changeRequest); 162 163 #ifdef __cplusplus 164 } 165 #endif 166 167 #endif // MULTIMEDIA_MEDIA_LIBRARY_NATIVE_MEDIA_ASSET_CHANGE_REQUEST_H 168 /** @} */ 169