diff --git a/multimedia/camera_framework/BUILD.gn b/multimedia/camera_framework/BUILD.gn index 5193d84e080d5a418fdeeb2b85ed7668ce47e195..2773cb88b913c78a75810c6816b4c20ba429c49b 100644 --- a/multimedia/camera_framework/BUILD.gn +++ b/multimedia/camera_framework/BUILD.gn @@ -23,6 +23,7 @@ ohos_ndk_headers("camera_ndk_header") { "./camera_manager.h", "./capture_session.h", "./metadata_output.h", + "./photo_native.h", "./photo_output.h", "./preview_output.h", "./video_output.h", @@ -44,5 +45,6 @@ ohos_ndk_library("libohcamera") { "ohcamera/photo_output.h", "ohcamera/preview_output.h", "ohcamera/video_output.h", + "ohcamera/photo_native.h", ] } diff --git a/multimedia/camera_framework/camera.ndk.json b/multimedia/camera_framework/camera.ndk.json index cfd6120d91df7457549db081afa628ec9c5aa76e..50cc20db4e252cf0ed4fd270291ff047ad76448e 100644 --- a/multimedia/camera_framework/camera.ndk.json +++ b/multimedia/camera_framework/camera.ndk.json @@ -91,6 +91,10 @@ "first_introduced": "12", "name": "OH_CameraManager_CreatePhotoOutputUsedInPreconfig" }, + { + "first_introduced": "12", + "name": "OH_CameraManager_CreatePhotoOutputWithoutSurface" + }, { "first_introduced": "11", "name": "OH_CameraManager_CreateVideoOutput" @@ -439,6 +443,22 @@ "first_introduced": "11", "name": "OH_PhotoOutput_Capture" }, + { + "first_introduced": "12", + "name": "OH_PhotoOutput_RegisterPhotoAvailableCallback" + }, + { + "first_introduced": "12", + "name": "OH_PhotoOutput_UnregisterPhotoAvailableCallback" + }, + { + "first_introduced": "12", + "name": "OH_PhotoOutput_RegisterPhotoAssetAvailableCallback" + }, + { + "first_introduced": "12", + "name": "OH_PhotoOutput_UnregisterPhotoAssetAvailableCallback" + }, { "first_introduced": "11", "name": "OH_PhotoOutput_Capture_WithCaptureSetting" @@ -459,6 +479,14 @@ "first_introduced": "12", "name": "OH_PhotoOutput_DeleteProfile" }, + { + "first_introduced": "12", + "name": "OH_PhotoOutput_IsMovingPhotoSupported" + }, + { + "first_introduced": "12", + "name": "OH_PhotoOutput_EnableMovingPhoto" + }, { "first_introduced": "11", "name": "OH_PreviewOutput_RegisterCallback" @@ -550,5 +578,13 @@ { "first_introduced": "12", "name": "OH_CameraDevice_GetCameraOrientation" + }, + { + "first_introduced": "12", + "name": "OH_PhotoNative_GetMainImage" + }, + { + "first_introduced": "12", + "name": "OH_PhotoNative_Release" } ] diff --git a/multimedia/camera_framework/camera_manager.h b/multimedia/camera_framework/camera_manager.h index ed72fcff9a40e2579affe14c8b35804ce7ef0531..42bcc1aaaaec9ea5616078ab178ecdc4e2117cd0 100644 --- a/multimedia/camera_framework/camera_manager.h +++ b/multimedia/camera_framework/camera_manager.h @@ -315,6 +315,20 @@ Camera_ErrorCode OH_CameraManager_CreatePhotoOutput(Camera_Manager* cameraManage Camera_ErrorCode OH_CameraManager_CreatePhotoOutputUsedInPreconfig(Camera_Manager* cameraManager, const char* surfaceId, Camera_PhotoOutput** photoOutput); +/** + * @brief Create a photo output instance without surfaceId. + * + * @param cameraManager the {@link Camera_Manager} instance. + * @param profile the {@link Camera_Profile} to create {@link Camera_PhotoOutput}. + * @param photoOutput the {@link Camera_PhotoOutput} will be created if the method call succeeds. + * @return {@link #CAMERA_OK} if the method call succeeds. + * {@link #CAMERA_INVALID_ARGUMENT} if parameter missing or parameter type incorrect. + * {@link #CAMERA_SERVICE_FATAL_ERROR} if camera service fatal error. + * @since 12 + */ +Camera_ErrorCode OH_CameraManager_CreatePhotoOutputWithoutSurface(Camera_Manager *cameraManager, + const Camera_Profile *profile, Camera_PhotoOutput **photoOutput); + /** * @brief Create a video output instance. * diff --git a/multimedia/camera_framework/photo_native.h b/multimedia/camera_framework/photo_native.h new file mode 100644 index 0000000000000000000000000000000000000000..2168831191b813817109da2ea1ecc30285d5f267 --- /dev/null +++ b/multimedia/camera_framework/photo_native.h @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @addtogroup OH_Camera + * @{ + * + * @brief Provide the definition of the C interface for the camera module. + * + * @syscap SystemCapability.Multimedia.Camera.Core + * + * @since 12 + * @version 1.0 + */ + +/** + * @file photo_native.h + * + * @brief Declare the camera photo concepts. + * + * @library libohcamera.so + * @syscap SystemCapability.Multimedia.Camera.Core + * @since 12 + * @version 1.0 + */ + +#ifndef NATIVE_INCLUDE_PHOTO_NATIVE_H +#define NATIVE_INCLUDE_PHOTO_NATIVE_H + +#include +#include +#include "camera.h" +#include "multimedia/image_framework/image/image_native.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Camera photo object + * + * A pointer can be created using {@link OH_PhotoNative} method. + * + * @since 12 + * @version 1.0 + */ +typedef struct OH_PhotoNative OH_PhotoNative; + +/** + * @brief Get main image. + * + * @param photo the {@link OH_PhotoNative} instance. + * @param main the {@link OH_ImageNative} which use to get main image. + * @return {@link #CAMERA_OK} if the method call succeeds. + * {@link #INVALID_ARGUMENT} if parameter missing or parameter type incorrect. + * @since 12 + * @version 1.0 + */ +Camera_ErrorCode OH_PhotoNative_GetMainImage(OH_PhotoNative* photo, OH_ImageNative* mainImage); + +/** + * @brief Release camera photo. + * + * @param photo the {@link OH_PhotoNative} instance to released. + * @return {@link #CAMERA_OK} if the method call succeeds. + * {@link #INVALID_ARGUMENT} if parameter missing or parameter type incorrect. + * @since 12 + * @version 1.0 + */ +Camera_ErrorCode OH_PhotoNative_Release(OH_PhotoNative* photo); + +#ifdef __cplusplus +} +#endif + +#endif // NATIVE_INCLUDE_PHOTO_NATIVE_H +/** @} */ \ No newline at end of file diff --git a/multimedia/camera_framework/photo_output.h b/multimedia/camera_framework/photo_output.h index 941cef603282771134842230142d36c224756d62..2ec0654fe2ada52f20fa7ddefd02e805985d3724 100644 --- a/multimedia/camera_framework/photo_output.h +++ b/multimedia/camera_framework/photo_output.h @@ -43,6 +43,8 @@ #include #include #include "camera.h" +#include "photo_native.h" +#include "multimedia/media_library/media_asset_base_capi.h" #ifdef __cplusplus extern "C" { @@ -139,6 +141,24 @@ typedef void (*OH_PhotoOutput_CaptureReady) (Camera_PhotoOutput* photoOutput); */ typedef void (*OH_PhotoOutput_EstimatedCaptureDuration) (Camera_PhotoOutput* photoOutput, int64_t duration); +/** + * @brief Photo output available high-resolution images callback. + * + * @param photoOutput the {@link Camera_PhotoOutput} which deliver the callback. + * @param photo the {@link OH_PhotoNative} which delivered by the callback. + * @since 12 + */ +typedef void (*OH_PhotoOutput_PhotoAvailable)(Camera_PhotoOutput* photoOutput, OH_PhotoNative* photo); + +/** + * @brief Photo output photo asset available callback. + * + * @param photoOutput the {@link Camera_PhotoOutput} which deliver the callback. + * @param photoAsset the {@link OH_MediaAsset} which delivered by the callback. + * @since 12 + */ +typedef void (*OH_PhotoOutput_PhotoAssetAvailable)(Camera_PhotoOutput* photoOutput, OH_MediaAsset* photoAsset); + /** * @brief A listener for photo output. * @@ -310,6 +330,54 @@ Camera_ErrorCode OH_PhotoOutput_RegisterEstimatedCaptureDurationCallback(Camera_ Camera_ErrorCode OH_PhotoOutput_UnregisterEstimatedCaptureDurationCallback(Camera_PhotoOutput* photoOutput, OH_PhotoOutput_EstimatedCaptureDuration callback); +/** + * @brief Register photo output photo available callback. + * + * @param photoOutput the {@link Camera_PhotoOutput} instance. + * @param callback the {@link OH_PhotoOutput_PhotoAvailable} to be registered. + * @return {@link #CAMERA_OK} if the method call succeeds. + * {@link #INVALID_ARGUMENT} if parameter missing or parameter type incorrect. + * @since 12 + */ +Camera_ErrorCode OH_PhotoOutput_RegisterPhotoAvailableCallback(Camera_PhotoOutput* photoOutput, + OH_PhotoOutput_PhotoAvailable callback); + +/** + * @brief Unregister photo output photo available callback. + * + * @param photoOutput the {@link Camera_PhotoOutput} instance. + * @param callback the {@link PhotoOutput_Callbacks} to be unregistered. + * @return {@link #CAMERA_OK} if the method call succeeds. + * {@link #INVALID_ARGUMENT} if parameter missing or parameter type incorrect. + * @since 12 + */ +Camera_ErrorCode OH_PhotoOutput_UnregisterPhotoAvailableCallback(Camera_PhotoOutput* photoOutput, + OH_PhotoOutput_PhotoAvailable callback); + +/** + * @brief Register photo output photo asset available callback. + * + * @param photoOutput the {@link Camera_PhotoOutput} instance. + * @param callback the {@link OH_PhotoOutput_PhotoAssetAvailable} to be registered. + * @return {@link #CAMERA_OK} if the method call succeeds. + * {@link #INVALID_ARGUMENT} if parameter missing or parameter type incorrect. + * @since 12 + */ +Camera_ErrorCode OH_PhotoOutput_RegisterPhotoAssetAvailableCallback(Camera_PhotoOutput* photoOutput, + OH_PhotoOutput_PhotoAssetAvailable callback); + +/** + * @brief Unregister photo output photo asset available callback. + * + * @param photoOutput the {@link Camera_PhotoOutput} instance. + * @param callback the {@link OH_PhotoOutput_PhotoAssetAvailable} to be unregistered. + * @return {@link #CAMERA_OK} if the method call succeeds. + * {@link #INVALID_ARGUMENT} if parameter missing or parameter type incorrect. + * @since 12 + */ +Camera_ErrorCode OH_PhotoOutput_UnregisterPhotoAssetAvailableCallback(Camera_PhotoOutput* photoOutput, + OH_PhotoOutput_PhotoAssetAvailable callback); + /** * @brief Capture photo. * @@ -381,6 +449,30 @@ Camera_ErrorCode OH_PhotoOutput_GetActiveProfile(Camera_PhotoOutput* photoOutput */ Camera_ErrorCode OH_PhotoOutput_DeleteProfile(Camera_Profile* profile); +/** + * @brief Check whether to support moving photo. + * + * @param photoOutput the {@link Camera_PhotoOutput} instance which used to check whether moving photo supported. + * @param isSupported the result of whether moving photo supported. + * @return {@link #CAMERA_OK} if the method call succeeds. + * {@link #INVALID_ARGUMENT} if parameter missing or parameter type incorrect. + * {@link #CAMERA_SERVICE_FATAL_ERROR} if camera service fatal error. + * @since 12 + */ +Camera_ErrorCode OH_PhotoOutput_IsMovingPhotoSupported(Camera_PhotoOutput* photoOutput, bool* isSupported); + +/** + * @brief Enable moving photo or not. + * + * @param photoOutput the {@link Camera_PhotoOutput} instance which used to enable moving photo or not. + * @param enabled the flag of enable moving photo or not. + * @return {@link #CAMERA_OK} if the method call succeeds. + * {@link #INVALID_ARGUMENT} if parameter missing or parameter type incorrect. + * {@link #CAMERA_SERVICE_FATAL_ERROR} if camera service fatal error. + * @since 12 + */ +Camera_ErrorCode OH_PhotoOutput_EnableMovingPhoto(Camera_PhotoOutput* photoOutput, bool enabled); + #ifdef __cplusplus } #endif diff --git a/multimedia/media_library/media_access_helper_capi.h b/multimedia/media_library/media_access_helper_capi.h new file mode 100644 index 0000000000000000000000000000000000000000..776bc9e2c07607a32bb75f16d2bda3a2642f429c --- /dev/null +++ b/multimedia/media_library/media_access_helper_capi.h @@ -0,0 +1,68 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @addtogroup MediaAccessHelper + * @{ + * + * @brief Provides APIs of request capability for Media Source. + * + * @since 12 + */ + +/** + * @file media_access_helper_capi.h + * + * @brief Defines APIs related to media assess helper. + * + * Provides the ability to create photo albums, as well as access and modify media data information in the albums. + * + * @kit MediaLibraryKit + * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core + * @library libmedia_asset_manager.so + * @since 12 + */ + +#ifndef MULTIMEDIA_MEDIA_LIBRARY_NATIVE_MEDIA_ACCESS_HELPER_H +#define MULTIMEDIA_MEDIA_LIBRARY_NATIVE_MEDIA_ACCESS_HELPER_H + +#include "media_asset_base_capi.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Apply the change request of asset or album. + * + * @permission ohos.permission.WRITE_IMAGEVIDEO + * @param changeRequest the {@link OH_MediaAssetChangeRequest} instance to be applied. + * @return {@link #MEDIA_LIBRARY_OK} if the method call succeeds. + * {@link #MEDIA_LIBRARY_PARAMETER_ERROR} Parameter error. Possible causes: + * 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * 3. Parameter verification failed. + * {@link #MEDIA_LIBRARY_PERMISSION_DENIED} Permission is denied. + * {@link #MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR} if internal system error. + * @since 12 +*/ +MediaLibrary_ErrorCode OH_MediaAccessHelper_ApplyChanges(OH_MediaAssetChangeRequest* changeRequest); + +#ifdef __cplusplus +} +#endif + +#endif // MULTIMEDIA_MEDIA_LIBRARY_NATIVE_MEDIA_ACCESS_HELPER_H +/** @} */ \ No newline at end of file diff --git a/multimedia/media_library/media_asset_base_capi.h b/multimedia/media_library/media_asset_base_capi.h index 1648933242f2ffcfef6821638001700d294463b7..065495b86b338934ff86043a7a0fb365da6f969e 100644 --- a/multimedia/media_library/media_asset_base_capi.h +++ b/multimedia/media_library/media_asset_base_capi.h @@ -38,7 +38,7 @@ * MediaLibrary_RequestOptions structure: This structure provides options for requesting media library resources. \n * * @kit MediaLibraryKit - * @Syscap SystemCapability.FileManagement.PhotoAccessHelper.Core + * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core * @library libmedia_asset_manager.so * @since 12 */ @@ -48,6 +48,8 @@ #include +#include "multimedia/image_framework/image/image_source_native.h" + #ifdef __cplusplus extern "C" { #endif @@ -71,6 +73,33 @@ static const int32_t UUID_STR_MAX_LENGTH = 37; */ typedef struct OH_MediaAssetManager OH_MediaAssetManager; +/** + * @brief Define Media Asset Change Request + * + * This structure provides the ability to handle a media asset change request. + * + * @since 12 + */ +typedef struct OH_MediaAssetChangeRequest OH_MediaAssetChangeRequest; + +/** + * @brief Define Moving Photo + * + * This structure provides the ability to obtain information about moving photo. + * + * @since 12 + */ +typedef struct OH_MovingPhoto OH_MovingPhoto; + +/** + * @brief Define Media Asset + * + * This structure provides the ability to encapsulate file asset attributes. + * + * @since 12 + */ +typedef struct OH_MediaAsset OH_MediaAsset; + /** * @brief Define MediaLibrary_RequestId * @@ -85,6 +114,59 @@ typedef struct MediaLibrary_RequestId { char requestId[UUID_STR_MAX_LENGTH]; } MediaLibrary_RequestId; +/** + * @brief Enum for media library error code. + * + * @since 12 + */ +typedef enum MediaLibrary_ErrorCode { + /** + * @error Media library result is ok. + */ + MEDIA_LIBRARY_OK = 0, + + /** + * @error Permission is denied. + */ + MEDIA_LIBRARY_PERMISSION_DENIED = 201, + + /** + * @error Mandatory parameters are left unspecified + * or incorrect parameter types or parameter verification failed. + */ + MEDIA_LIBRARY_PARAMETER_ERROR = 401, + + /** + * @error File does not exist. + */ + MEDIA_LIBRARY_NO_SUCH_FILE = 23800101, + + /** + * @error Invalid display name. + */ + MEDIA_LIBRARY_INVALID_DISPLAY_NAME = 23800102, + + /** + * @error Invalid asset uri. + */ + MEDIA_LIBRARY_INVALID_ASSET_URI = 23800103, + + /** + * @error Member is not a valid PhotoKey. + */ + MEDIA_LIBRARY_INVALID_PHOTO_KEY = 23800104, + + /** + * @error Operation is not supported. + */ + MEDIA_LIBRARY_OPERATION_NOT_SUPPORTED = 23800201, + + /** + * @error Internal system error. + */ + MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR = 23800301, +} MediaLibrary_ErrorCode; + /** * @brief Delivery Mode * @@ -102,6 +184,90 @@ typedef enum MediaLibrary_DeliveryMode { MEDIA_LIBRARY_BALANCED_MODE = 2 } MediaLibrary_DeliveryMode; +/** + * @brief Request Options + * + * This structure provides options for requesting media library resources. + * + * @since 12 + */ +typedef struct MediaLibrary_RequestOptions { + /*delivery mode*/ + MediaLibrary_DeliveryMode deliveryMode; +} MediaLibrary_RequestOptions; + +/** + * @brief Enum for media type. + * + * @since 12 + */ +typedef enum MediaLibrary_MediaType { + /*image asset*/ + MEDIA_LIBRARY_IMAGE = 1, + /*video asset*/ + MEDIA_LIBRARY_VIDEO = 2 +} MediaLibrary_MediaType; + +/** + * @brief Enum for media asset subtype. + * + * @since 12 + */ +typedef enum MediaLibrary_MediaSubType { + /*default Photo Type*/ + MEDIA_LIBRARY_DEFAULT = 0, + /*moving Photo Type*/ + MEDIA_LIBRARY_MOVING_PHOTO = 3, + /*burst Photo Type*/ + MEDIA_LIBRARY_BURST = 4 +} MediaLibrary_MediaSubType; + +/** + * @brief Enum for resource types. + * + * @since 12 + */ +typedef enum MediaLibrary_ResourceType { + /*image resource*/ + MEDIA_LIBRARY_IMAGE_RESOURCE = 1, + /*video resource*/ + MEDIA_LIBRARY_VIDEO_RESOURCE = 2 +} MediaLibrary_ResourceType; + +/** + * @brief Enum for image file Type. + * + * @since 12 + */ +typedef enum MediaLibrary_ImageFileType { + /*JPEG type*/ + MEDIA_LIBRARY_IMAGE_JPEG = 1 +} MediaLibrary_ImageFileType; + +/** + * @brief Enum for media quality. + * + * @since 12 + */ +typedef enum MediaLibrary_MediaQuality { + /*fast quality*/ + MEDIA_LIBRARY_QUALITY_FAST = 1, + /*full quality*/ + MEDIA_LIBRARY_QUALITY_FULL = 2 +} MediaLibrary_MediaQuality; + +/** + * @brief Enum for media content type. + * + * @since 12 + */ +typedef enum MediaLibrary_MediaContentType { + /*compressed media content type*/ + MEDIA_LIBRARY_COMPRESSED = 1, + /*picture object media content type*/ + MEDIA_LIBRARY_PICTURE_OBJECT = 2 +} MediaLibrary_MediaContentType; + /** * @brief Called when a requested source is prepared. * @@ -114,18 +280,40 @@ typedef enum MediaLibrary_DeliveryMode { typedef void (*OH_MediaLibrary_OnDataPrepared)(int32_t result, MediaLibrary_RequestId requestId); /** - * @brief Request Options + * @brief Called when a requested image source is prepared. * - * This structure provides options for requesting media library resources. + * This function is called when the requested image source is prepared. * + * @param result results {@link MediaLibrary_ErrorCode} of the processing of the requested resources. + * @param requestId indicates the {@link MediaLibrary_RequestId} of the request. + * @param mediaQuality the {@link MediaLibrary_MediaQuality} of the requested source. + * @param type the {@link MediaLibrary_MediaContentType} of the requested source. + * @param imageSourceNative it used to obtain {@link OH_ImageSourceNative} information when image source is prepared. * @since 12 */ -typedef struct MediaLibrary_RequestOptions { - /*delivery mode*/ - MediaLibrary_DeliveryMode deliveryMode; -} MediaLibrary_RequestOptions; +typedef void (*OH_MediaLibrary_OnImageDataPrepared)(MediaLibrary_ErrorCode result, + MediaLibrary_RequestId requestId, MediaLibrary_MediaQuality mediaQuality, MediaLibrary_MediaContentType type, + OH_ImageSourceNative* imageSourceNative); + +/** + * @brief Called when a requested moving photo is prepared. + * + * This function is called when the requested moving photo is prepared. + * + * @param result results {@link MediaLibrary_ErrorCode} of the processing of the requested resources. + * @param requestId indicates the {@link MediaLibrary_RequestId} of the request. + * @param mediaQuality the {@link MediaLibrary_MediaQuality} of the requested source. + * @param type the {@link MediaLibrary_MediaContentType} of the requested source. + * @param movingPhoto it used to obtain {@link OH_MovingPhoto} information when the data is prepared. + * @since 12 + */ +typedef void (*OH_MediaLibrary_OnMovingPhotoDataPrepared)(MediaLibrary_ErrorCode result, + MediaLibrary_RequestId requestId, MediaLibrary_MediaQuality mediaQuality, MediaLibrary_MediaContentType type, + OH_MovingPhoto* movingPhoto); #ifdef __cplusplus } #endif -#endif // MULTIMEDIA_MEDIA_LIBRARY_NATIVE_MEDIA_ASSET_BASE_H \ No newline at end of file + +#endif // MULTIMEDIA_MEDIA_LIBRARY_NATIVE_MEDIA_ASSET_BASE_H +/** @} */ \ No newline at end of file diff --git a/multimedia/media_library/media_asset_capi.h b/multimedia/media_library/media_asset_capi.h new file mode 100644 index 0000000000000000000000000000000000000000..676458e62b2471fa44a639654cd29e74e5fe9b20 --- /dev/null +++ b/multimedia/media_library/media_asset_capi.h @@ -0,0 +1,308 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @addtogroup MediaAsset + * @{ + * + * @brief Provides APIs of request capability for Media Source. + * + * @since 12 + */ + +/** + * @file media_asset_capi.h + * + * @brief Defines APIs related to media asset. + * + * Provides the ability to obtain image or video information. + * + * @kit MediaLibraryKit + * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core + * @library libmedia_asset_manager.so + * @since 12 + */ + +#ifndef MULTIMEDIA_MEDIA_LIBRARY_NATIVE_MEDIA_ASSET_H +#define MULTIMEDIA_MEDIA_LIBRARY_NATIVE_MEDIA_ASSET_H + +#include "media_asset_base_capi.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Get the uri of the media asset. + * + * @param mediaAsset the {@link OH_MediaAsset} instance. + * @param uri the uri of the media asset. + * @return {@link #MEDIA_LIBRARY_OK} if the method call succeeds. + * {@link #MEDIA_LIBRARY_PARAMETER_ERROR} Parameter error. Possible causes: + * 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * 3. Parameter verification failed. + * {@link #MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR} if internal system error. + * @since 12 +*/ +MediaLibrary_ErrorCode OH_MediaAsset_GetUri(OH_MediaAsset* mediaAsset, const char** uri); + +/** + * @brief Get the media file type of the media asset. + * + * @param mediaAsset the {@link OH_MediaAsset} instance. + * @param mediaType the media file type of the media asset. + * @return {@link #MEDIA_LIBRARY_OK} if the method call succeeds. + * {@link #MEDIA_LIBRARY_PARAMETER_ERROR} Parameter error. Possible causes: + * 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * 3. Parameter verification failed. + * {@link #MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR} if internal system error. + * @since 12 +*/ +MediaLibrary_ErrorCode OH_MediaAsset_GetMediaType(OH_MediaAsset* mediaAsset, MediaLibrary_MediaType* mediaType); + +/** + * @brief Get the subtype of the media asset. + * + * @param mediaAsset the {@link OH_MediaAsset} instance. + * @param mediaSubType the subtype of the media asset. + * @return {@link #MEDIA_LIBRARY_OK} if the method call succeeds. + * {@link #MEDIA_LIBRARY_PARAMETER_ERROR} Parameter error. Possible causes: + * 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * 3. Parameter verification failed. + * {@link #MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR} if internal system error. + * @since 12 +*/ +MediaLibrary_ErrorCode OH_MediaAsset_GetMediaSubType(OH_MediaAsset* mediaAsset, + MediaLibrary_MediaSubType* mediaSubType); + +/** + * @brief Get the display name of the media asset. + * + * @param mediaAsset the {@link OH_MediaAsset} instance. + * @param displayName the display name of the media asset. + * @return {@link #MEDIA_LIBRARY_OK} if the method call succeeds. + * {@link #MEDIA_LIBRARY_PARAMETER_ERROR} Parameter error. Possible causes: + * 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * 3. Parameter verification failed. + * {@link #MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR} if internal system error. + * @since 12 +*/ +MediaLibrary_ErrorCode OH_MediaAsset_GetDisplayName(OH_MediaAsset* mediaAsset, const char** displayName); + +/** + * @brief Get the file size of the media asset + * + * @param mediaAsset the {@link OH_MediaAsset} instance. + * @param size the file size(in bytes) of the media asset. + * @return {@link #MEDIA_LIBRARY_OK} if the method call succeeds. + * {@link #MEDIA_LIBRARY_PARAMETER_ERROR} Parameter error. Possible causes: + * 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * 3. Parameter verification failed. + * {@link #MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR} if internal system error. + * @since 12 +*/ +MediaLibrary_ErrorCode OH_MediaAsset_GetSize(OH_MediaAsset* mediaAsset, uint32_t* size); + +/** + * @brief Get the date of asset creation. + * + * @param mediaAsset the {@link OH_MediaAsset} instance. + * @param dateAdded the creation date of the asset. + * The value is the number of seconds elapsed since the Epoch time (00:00:00 UTC on January 1, 1970). + * @return {@link #MEDIA_LIBRARY_OK} if the method call succeeds. + * {@link #MEDIA_LIBRARY_PARAMETER_ERROR} Parameter error. Possible causes: + * 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * 3. Parameter verification failed. + * {@link #MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR} if internal system error. + * @since 12 +*/ +MediaLibrary_ErrorCode OH_MediaAsset_GetDateAdded(OH_MediaAsset* mediaAsset, uint32_t* dateAdded); + +/** + * @brief Get the modified date of the asset. + * + * @param mediaAsset the {@link OH_MediaAsset} instance. + * @param dateModified the modified date of the asset. + * The value is the number of seconds elapsed since the Epoch time. + * @return {@link #MEDIA_LIBRARY_OK} if the method call succeeds. + * {@link #MEDIA_LIBRARY_PARAMETER_ERROR} Parameter error. Possible causes: + * 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * 3. Parameter verification failed. + * {@link #MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR} if internal system error. + * @since 12 +*/ +MediaLibrary_ErrorCode OH_MediaAsset_GetDateModified(OH_MediaAsset* mediaAsset, uint32_t* dateModified); + +/** + * @brief Get the date taken of the asset. + * + * @param mediaAsset the {@link OH_MediaAsset} instance. + * @param dateTaken the date taken of the asset. + * The value is the number of seconds elapsed since the Epoch time. + * @return {@link #MEDIA_LIBRARY_OK} if the method call succeeds. + * {@link #MEDIA_LIBRARY_PARAMETER_ERROR} Parameter error. Possible causes: + * 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * 3. Parameter verification failed. + * {@link #MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR} if internal system error. + * @since 12 +*/ +MediaLibrary_ErrorCode OH_MediaAsset_GetDateTaken(OH_MediaAsset* mediaAsset, uint32_t* dateTaken); + +/** + * @brief Get the creation time of the asset in milliseconds. + * + * @param mediaAsset the {@link OH_MediaAsset} instance. + * @param dateAddedMs the creation time of the asset in milliseconds. + * @return {@link #MEDIA_LIBRARY_OK} if the method call succeeds. + * {@link #MEDIA_LIBRARY_PARAMETER_ERROR} Parameter error. Possible causes: + * 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * 3. Parameter verification failed. + * {@link #MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR} if internal system error. + * @since 12 +*/ +MediaLibrary_ErrorCode OH_MediaAsset_GetDateAddedMs(OH_MediaAsset* mediaAsset, uint32_t* dateAddedMs); + +/** + * @brief Get the modified time of the asset in milliseconds. + * + * @param mediaAsset the {@link OH_MediaAsset} instance. + * @param dateModifiedMs the modified time of the asset in milliseconds. + * @return {@link #MEDIA_LIBRARY_OK} if the method call succeeds. + * {@link #MEDIA_LIBRARY_PARAMETER_ERROR} Parameter error. Possible causes: + * 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * 3. Parameter verification failed. + * {@link #MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR} if internal system error. + * @since 12 +*/ +MediaLibrary_ErrorCode OH_MediaAsset_GetDateModifiedMs(OH_MediaAsset* mediaAsset, uint32_t* dateModifiedMs); + +/** + * @brief Get the duration of the media asset in milliseconds. + * + * @param mediaAsset the {@link OH_MediaAsset} instance. + * @param duration the duration of the media asset in milliseconds. + * @return {@link #MEDIA_LIBRARY_OK} if the method call succeeds. + * {@link #MEDIA_LIBRARY_PARAMETER_ERROR} Parameter error. Possible causes: + * 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * 3. Parameter verification failed. + * {@link #MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR} if internal system error. + * @since 12 +*/ +MediaLibrary_ErrorCode OH_MediaAsset_GetDuration(OH_MediaAsset* mediaAsset, uint32_t* duration); + +/** + * @brief Get the image width(in pixels) of the media asset. + * + * @param mediaAsset the {@link OH_MediaAsset} instance. + * @param width the image width(in pixels) of the media asset. + * @return {@link #MEDIA_LIBRARY_OK} if the method call succeeds. + * {@link #MEDIA_LIBRARY_PARAMETER_ERROR} Parameter error. Possible causes: + * 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * 3. Parameter verification failed. + * {@link #MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR} if internal system error. + * @since 12 +*/ +MediaLibrary_ErrorCode OH_MediaAsset_GetWidth(OH_MediaAsset* mediaAsset, uint32_t* width); + +/** + * @brief Get the image height(in pixels) of the media asset. + * + * @param mediaAsset the {@link OH_MediaAsset} instance. + * @param height the image height(in pixels) of the media asset. + * @return {@link #MEDIA_LIBRARY_OK} if the method call succeeds. + * {@link #MEDIA_LIBRARY_PARAMETER_ERROR} Parameter error. Possible causes: + * 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * 3. Parameter verification failed. + * {@link #MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR} if internal system error. + * @since 12 +*/ +MediaLibrary_ErrorCode OH_MediaAsset_GetHeight(OH_MediaAsset* mediaAsset, uint32_t* height); + +/** + * @brief Get the orientation of the image. + * + * @param mediaAsset the {@link OH_MediaAsset} instance. + * @param orientation the orientation of the image. + * @return {@link #MEDIA_LIBRARY_OK} if the method call succeeds. + * {@link #MEDIA_LIBRARY_PARAMETER_ERROR} Parameter error. Possible causes: + * 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * 3. Parameter verification failed. + * {@link #MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR} if internal system error. +*/ +MediaLibrary_ErrorCode OH_MediaAsset_GetOrientation(OH_MediaAsset* mediaAsset, uint32_t* orientation); + +/** + * @brief Get the favorite state of the asset. + * + * @param mediaAsset the {@link OH_MediaAsset} instance. + * @param favorite the favorite state of the media asset. + * @return {@link #MEDIA_LIBRARY_OK} if the method call succeeds. + * {@link #MEDIA_LIBRARY_PARAMETER_ERROR} Parameter error. Possible causes: + * 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * 3. Parameter verification failed. + * {@link #MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR} if internal system error. + * @since 12 +*/ +MediaLibrary_ErrorCode OH_MediaAsset_IsFavorite(OH_MediaAsset* mediaAsset, uint32_t* favorite); + +/** + * @brief Get the title of the media asset. + * + * @param mediaAsset the {@link OH_MediaAsset} instance. + * @param title the title of the media asset. + * @return {@link #MEDIA_LIBRARY_OK} if the method call succeeds. + * {@link #MEDIA_LIBRARY_PARAMETER_ERROR} Parameter error. Possible causes: + * 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * 3. Parameter verification failed. + * {@link #MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR} if internal system error. + * @since 12 +*/ +MediaLibrary_ErrorCode OH_MediaAsset_GetTitle(OH_MediaAsset* mediaAsset, const char** title); + +/** + * @brief Release the media asset + * + * @param mediaAsset the {@link OH_MediaAsset} instance. + * @return {@link #MEDIA_LIBRARY_OK} if the method call succeeds. + * {@link #MEDIA_LIBRARY_PARAMETER_ERROR} Parameter error. Possible causes: + * 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * 3. Parameter verification failed. + * @since 12 +*/ +MediaLibrary_ErrorCode OH_MediaAsset_Release(OH_MediaAsset* mediaAsset); + +#ifdef __cplusplus +} +#endif + +#endif // MULTIMEDIA_MEDIA_LIBRARY_NATIVE_MEDIA_ASSET_H +/** @} */ \ No newline at end of file diff --git a/multimedia/media_library/media_asset_change_request_capi.h b/multimedia/media_library/media_asset_change_request_capi.h new file mode 100644 index 0000000000000000000000000000000000000000..decd62d3b770c52b45aef191c65a2bc4ea43d1e0 --- /dev/null +++ b/multimedia/media_library/media_asset_change_request_capi.h @@ -0,0 +1,168 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @addtogroup MediaAssetChangeRequest + * @{ + * + * @brief Provides APIs of request capability for Media Source. + * + * @since 12 + */ + +/** + * @file media_asset_change_request_capi.h + * + * @brief Defines APIs related to media asset change request. + * + * Provides the ability to change assets. + * + * @kit MediaLibraryKit + * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core + * @library libmedia_asset_manager.so + * @since 12 + */ + +#ifndef MULTIMEDIA_MEDIA_LIBRARY_NATIVE_MEDIA_ASSET_CHANGE_REQUEST_H +#define MULTIMEDIA_MEDIA_LIBRARY_NATIVE_MEDIA_ASSET_CHANGE_REQUEST_H + +#include "media_asset_base_capi.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Create a {@link OH_MediaAssetChangeRequest} instance. + * + * @param mediaAsset the {@link OH_MediaAsset} instance. + * @return {@link #MEDIA_LIBRARY_OK} if the method call succeeds. + * {@link #MEDIA_LIBRARY_PARAMETER_ERROR} Parameter error. Possible causes: + * 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * 3. Parameter verification failed. + * {@link #MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR} if internal system error. + * @since 12 +*/ +OH_MediaAssetChangeRequest* OH_MediaAssetChangeRequest_Create(OH_MediaAsset* mediaAsset); + +/** + * @brief Add resource of the asset using file uri. + * + * @param changeRequest the {@link OH_MediaAssetChangeRequest} instance. + * @param resourceType the {@link MediaLibrary_ResourceType} of the resource to add. + * @param fileUri the file uri. + * @return {@link #MEDIA_LIBRARY_OK} if the method call succeeds. + * {@link #MEDIA_LIBRARY_PARAMETER_ERROR} Parameter error. Possible causes: + * 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * 3. Parameter verification failed. + * {@link #MEDIA_LIBRARY_NO_SUCH_FILE} if file does not exist. + * {@link #MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR} if internal system error. + * {@link #MEDIA_LIBRARY_OPERATION_NOT_SUPPORTED} if operation is not supported. + * @since 12 +*/ +MediaLibrary_ErrorCode OH_MediaAssetChangeRequest_AddResourceWithUri(OH_MediaAssetChangeRequest* changeRequest, + MediaLibrary_ResourceType resourceType, char* fileUri); + +/** + * @brief Add resource of the asset using ArrayBuffer. + * + * @param changeRequest the {@link OH_MediaAssetChangeRequest} instance. + * @param resourceType the {@link MediaLibrary_ResourceType} of the resource to add. + * @param buffer the data buffer to add. + * @param length the length of the data buffer. + * @return {@link #MEDIA_LIBRARY_OK} if the method call succeeds. + * {@link #MEDIA_LIBRARY_PARAMETER_ERROR} Parameter error. Possible causes: + * 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * 3. Parameter verification failed. + * {@link #MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR} if internal system error. + * {@link #MEDIA_LIBRARY_OPERATION_NOT_SUPPORTED} if operation is not supported. + * @since 12 +*/ +MediaLibrary_ErrorCode OH_MediaAssetChangeRequest_AddResourceWithBuffer(OH_MediaAssetChangeRequest* changeRequest, + MediaLibrary_ResourceType resourceType, uint8_t* buffer, uint32_t length); + +/** + * @brief Get write cache handler. + * + * @permission ohos.permission.WRITE_IMAGEVIDEO + * @param changeRequest the {@link OH_MediaAssetChangeRequest} instance. + * @param fd the write cache handler. + * @return {@link #MEDIA_LIBRARY_OK} if the method call succeeds. + * {@link #MEDIA_LIBRARY_PARAMETER_ERROR} Parameter error. Possible causes: + * 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * 3. Parameter verification failed. + * {@link #MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR} if internal system error. + * {@link #MEDIA_LIBRARY_PERMISSION_DENIED} if permission is denied. + * {@link #MEDIA_LIBRARY_OPERATION_NOT_SUPPORTED} if operation is not supported. + * @since 12 +*/ +MediaLibrary_ErrorCode OH_MediaAssetChangeRequest_GetWriteCacheHandler(OH_MediaAssetChangeRequest* changeRequest, + int32_t* fd); + +/** + * @brief Save the photo asset captured by camera. + * + * @param changeRequest the {@link OH_MediaAssetChangeRequest} instance. + * @param imageFileType The {@link MediaLibrary_ImageFileType} of photo to be saved. + * @return {@link #MEDIA_LIBRARY_OK} if the method call succeeds. + * {@link #MEDIA_LIBRARY_PARAMETER_ERROR} Parameter error. Possible causes: + * 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * 3. Parameter verification failed. + * {@link #MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR} if internal system error. + * {@link #MEDIA_LIBRARY_OPERATION_NOT_SUPPORTED} if operation is not supported. + * @since 12 +*/ +MediaLibrary_ErrorCode OH_MediaAssetChangeRequest_SaveCameraPhoto(OH_MediaAssetChangeRequest* changeRequest, + MediaLibrary_ImageFileType imageFileType); + +/** + * @brief Discard the photo asset captured by camera. + * + * @param changeRequest the {@link OH_MediaAssetChangeRequest} instance. + * @return {@link #MEDIA_LIBRARY_OK} if the method call succeeds. + * {@link #MEDIA_LIBRARY_PARAMETER_ERROR} Parameter error. Possible causes: + * 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * 3. Parameter verification failed. + * {@link #MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR} if internal system error. + * {@link #MEDIA_LIBRARY_OPERATION_NOT_SUPPORTED} if operation is not supported. + * @since 12 +*/ +MediaLibrary_ErrorCode OH_MediaAssetChangeRequest_DiscardCameraPhoto(OH_MediaAssetChangeRequest* changeRequest); + +/** + * @brief Release the {@link OH_MediaAssetChangeRequest} instance. + * + * @param changeRequest the {@link OH_MediaAssetChangeRequest} instance. + * @return {@link #MEDIA_LIBRARY_OK} if the method call succeeds. + * {@link #MEDIA_LIBRARY_PARAMETER_ERROR} Parameter error. Possible causes: + * 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * 3. Parameter verification failed. + * @since 12 +*/ +MediaLibrary_ErrorCode OH_MediaAssetChangeRequest_Release(OH_MediaAssetChangeRequest* changeRequest); + +#ifdef __cplusplus +} +#endif + +#endif // MULTIMEDIA_MEDIA_LIBRARY_NATIVE_MEDIA_ASSET_CHANGE_REQUEST_H +/** @} */ diff --git a/multimedia/media_library/media_asset_manager/BUILD.gn b/multimedia/media_library/media_asset_manager/BUILD.gn index 57c7fb44c62b782a35a442c125e82836cd8a7fd9..9385e2e920edc04433238d19f530106638bfdb3f 100644 --- a/multimedia/media_library/media_asset_manager/BUILD.gn +++ b/multimedia/media_library/media_asset_manager/BUILD.gn @@ -18,8 +18,12 @@ import("//foundation/multimedia/media_library/media_library.gni") ohos_ndk_headers("media_asset_manager_header") { dest_dir = "$ndk_headers_out_dir/multimedia/media_library" sources = [ + "../media_access_helper_capi.h", "../media_asset_base_capi.h", + "../media_asset_capi.h", + "../media_asset_change_request_capi.h", "../media_asset_manager_capi.h", + "../moving_photo_capi.h", ] } @@ -31,5 +35,9 @@ ohos_ndk_library("libmedia_asset_manager") { system_capability_headers = [ "multimedia/media_library/media_asset_manager_capi.h", "multimedia/media_library/media_asset_base_capi.h", + "multimedia/media_library/media_access_helper_capi.h", + "multimedia/media_library/media_asset_capi.h", + "multimedia/media_library/moving_photo_capi.h", + "multimedia/media_library/media_asset_change_request_capi.h", ] } diff --git a/multimedia/media_library/media_asset_manager/lib_media_asset_namager_capi.ndk.json b/multimedia/media_library/media_asset_manager/lib_media_asset_namager_capi.ndk.json index 7e910b968fd298226c2da9cf3f49aa028b11dec4..f78edcc8b958ccd7bb5df318c6ea5cf7c1500602 100644 --- a/multimedia/media_library/media_asset_manager/lib_media_asset_namager_capi.ndk.json +++ b/multimedia/media_library/media_asset_manager/lib_media_asset_namager_capi.ndk.json @@ -14,5 +14,137 @@ { "first_introduced": "12", "name": "OH_MediaAssetManager_CancelRequest" + }, + { + "first_introduced": "12", + "name": "OH_MediaAssetManager_RequestMovingPhoto" + }, + { + "first_introduced": "12", + "name": "OH_MediaAssetManager_RequestImage" + }, + { + "first_introduced": "12", + "name": "OH_MediaAssetManager_Release" + }, + { + "first_introduced": "12", + "name": "OH_MediaAccessHelper_ApplyChanges" + }, + { + "first_introduced": "12", + "name": "OH_MediaAsset_GetUri" + }, + { + "first_introduced": "12", + "name": "OH_MediaAsset_GetMediaType" + }, + { + "first_introduced": "12", + "name": "OH_MediaAsset_GetMediaSubType" + }, + { + "first_introduced": "12", + "name": "OH_MediaAsset_GetDisplayName" + }, + { + "first_introduced": "12", + "name": "OH_MediaAsset_GetSize" + }, + { + "first_introduced": "12", + "name": "OH_MediaAsset_GetDateAdded" + }, + { + "first_introduced": "12", + "name": "OH_MediaAsset_GetDateModified" + }, + { + "first_introduced": "12", + "name": "OH_MediaAsset_GetDateTaken" + }, + { + "first_introduced": "12", + "name": "OH_MediaAsset_GetDateAddedMs" + }, + { + "first_introduced": "12", + "name": "OH_MediaAsset_GetDateModifiedMs" + }, + { + "first_introduced": "12", + "name": "OH_MediaAsset_GetDuration" + }, + { + "first_introduced": "12", + "name": "OH_MediaAsset_GetWidth" + }, + { + "first_introduced": "12", + "name": "OH_MediaAsset_GetHeight" + }, + { + "first_introduced": "12", + "name": "OH_MediaAsset_GetOrientation" + }, + { + "first_introduced": "12", + "name": "OH_MediaAsset_IsFavorite" + }, + { + "first_introduced": "12", + "name": "OH_MediaAsset_GetTitle" + }, + { + "first_introduced": "12", + "name": "OH_MediaAsset_Release" + }, + { + "first_introduced": "12", + "name": "OH_MovingPhoto_GetUri" + }, + { + "first_introduced": "12", + "name": "OH_MovingPhoto_RequestContentWithUris" + }, + { + "first_introduced": "12", + "name": "OH_MovingPhoto_RequestContentWithUri" + }, + { + "first_introduced": "12", + "name": "OH_MovingPhoto_RequestContentWithBuffer" + }, + { + "first_introduced": "12", + "name": "OH_MovingPhoto_Release" + }, + { + "first_introduced": "12", + "name": "OH_MediaAssetChangeRequest_Create" + }, + { + "first_introduced": "12", + "name": "OH_MediaAssetChangeRequest_AddResourceWithUri" + }, + { + "first_introduced": "12", + "name": "OH_MediaAssetChangeRequest_AddResourceWithBuffer" + }, + { + "first_introduced": "12", + "name": "OH_MediaAssetChangeRequest_GetWriteCacheHandler" + }, + { + "first_introduced": "12", + "name": "OH_MediaAssetChangeRequest_SaveCameraPhoto" + }, + { + "first_introduced": "12", + "name": "OH_MediaAssetChangeRequest_DiscardCameraPhoto" + }, + { + "first_introduced": "12", + "name": "OH_MediaAssetChangeRequest_Release" } ] \ No newline at end of file diff --git a/multimedia/media_library/media_asset_manager_capi.h b/multimedia/media_library/media_asset_manager_capi.h index 4b465e05e85bf54a21645fdd692f831704f395eb..9a9d8d536ce0cfe1db570d06ed991294fbd1d1a4 100644 --- a/multimedia/media_library/media_asset_manager_capi.h +++ b/multimedia/media_library/media_asset_manager_capi.h @@ -31,7 +31,7 @@ * to reqeust media source. * * @kit MediaLibraryKit - * @Syscap SystemCapability.FileManagement.PhotoAccessHelper.Core + * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core * @library libmedia_asset_manager.so * @since 12 */ @@ -94,7 +94,70 @@ MediaLibrary_RequestId OH_MediaAssetManager_RequestVideoForPath(OH_MediaAssetMan */ bool OH_MediaAssetManager_CancelRequest(OH_MediaAssetManager* manager, const MediaLibrary_RequestId requestId); +/** + * @brief Request moving photo object. + * + * @permission ohos.permission.READ_IMAGEVIDEO + * @param manager the pointer to {@link OH_MediaAssetManager} instance. + * @param mediaAsset the {@link OH_MediaAsset} instance of media file object to be requested. + * @param requestOptions the {@link MediaLibrary_RequestOptions} for image request strategy mode. + * @param requestId indicates the {@link MediaLibrary_RequestId} of the request, which is an output parameter. + * @param callback the {@link OH_MediaLibrary_OnMovingPhotoDataPrepared} that will be called + * when the requested source is prepared. + * @return {@link #MEDIA_LIBRARY_OK} if the method call succeeds. + * {@link #MEDIA_LIBRARY_PARAMETER_ERROR} Parameter error. Possible causes: + * 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * 3. Parameter verification failed. + * {@link #MEDIA_LIBRARY_OPERATION_NOT_SUPPORTED} if operation is not supported. + * {@link #MEDIA_LIBRARY_PERMISSION_DENIED} if permission is denied. + * {@link #MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR} if internal system error. + * @since 12 +*/ +MediaLibrary_ErrorCode OH_MediaAssetManager_RequestMovingPhoto(OH_MediaAssetManager* manager, + OH_MediaAsset* mediaAsset, MediaLibrary_RequestOptions requestOptions, MediaLibrary_RequestId* requestId, + OH_MediaLibrary_OnMovingPhotoDataPrepared callback); + +/** + * @brief Request image resources based on different strategy modes. + * + * @permission ohos.permission.READ_IMAGEVIDEO + * @param manager the pointer to {@link OH_MediaAssetManager} instance. + * @param mediaAsset the {@link OH_MediaAsset} instance of media file object to be requested. + * @param requestOptions the {@link MediaLibrary_RequestOptions} for image request strategy mode. + * @param requestId indicates the {@link MediaLibrary_RequestId} of the request, which is an output parameter. + * @param callback the {@link OH_MediaLibrary_OnImageDataPrepared} that will be called + * when the requested source is prepared. + * @return {@link #MEDIA_LIBRARY_OK} if the method call succeeds. + * {@link #MEDIA_LIBRARY_PARAMETER_ERROR} Parameter error. Possible causes: + * 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * 3. Parameter verification failed. + * {@link #MEDIA_LIBRARY_OPERATION_NOT_SUPPORTED} if operation is not supported. + * {@link #MEDIA_LIBRARY_PERMISSION_DENIED} if permission is denied. + * {@link #MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR} if internal system error. + * @since 12 +*/ +MediaLibrary_ErrorCode OH_MediaAssetManager_RequestImage(OH_MediaAssetManager* manager, OH_MediaAsset* mediaAsset, + MediaLibrary_RequestOptions requestOptions, MediaLibrary_RequestId* requestId, + OH_MediaLibrary_OnImageDataPrepared callback); + +/** + * @brief Release the {@link OH_MediaAssetManager} instance. + * + * @param manager the {@link OH_MediaAssetManager} instance. + * @return {@link #MEDIA_LIBRARY_OK} if the method call succeeds. + * {@link #MEDIA_LIBRARY_PARAMETER_ERROR} Parameter error. Possible causes: + * 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * 3. Parameter verification failed. + * @since 12 +*/ +MediaLibrary_ErrorCode OH_MediaAssetManager_Release(OH_MediaAssetManager* manager); + #ifdef __cplusplus } #endif -#endif // MULTIMEDIA_MEDIA_LIBRARY_NATIVE_MEDIA_ASSET_MANAGER_H \ No newline at end of file + +#endif // MULTIMEDIA_MEDIA_LIBRARY_NATIVE_MEDIA_ASSET_MANAGER_H +/** @} */ \ No newline at end of file diff --git a/multimedia/media_library/moving_photo_capi.h b/multimedia/media_library/moving_photo_capi.h new file mode 100644 index 0000000000000000000000000000000000000000..b895601456f0814e5d26125e2bcdc98476ae679a --- /dev/null +++ b/multimedia/media_library/moving_photo_capi.h @@ -0,0 +1,138 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @addtogroup MovingPhoto + * @{ + * + * @brief Provides APIs of request capability for Media Source. + * + * @since 12 + */ + +/** + * @file moving_photo_capi.h + * + * @brief Defines APIs related to moving photo. + * + * Provides the ability to obtain moving photo information. + * + * @kit MediaLibraryKit + * @syscap SystemCapability.FileManagement.PhotoAccessHelper.Core + * @library libmedia_asset_manager.so + * @since 12 + */ + +#ifndef MULTIMEDIA_MEDIA_LIBRARY_NATIVE_MOVING_PHOTO_H +#define MULTIMEDIA_MEDIA_LIBRARY_NATIVE_MOVING_PHOTO_H + +#include "media_asset_base_capi.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Get uri of the moving photo. + * + * @param movingPhoto the {@link OH_MovingPhoto} instance. + * @param uri the uri of the moving photo. + * @return {@link #MEDIA_LIBRARY_OK} if the method call succeeds. + * {@link #MEDIA_LIBRARY_PARAMETER_ERROR} Parameter error. Possible causes: + * 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * 3. Parameter verification failed. + * {@link #MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR} if internal system error. + * @since 12 +*/ +MediaLibrary_ErrorCode OH_MovingPhoto_GetUri(OH_MovingPhoto* movingPhoto, const char** uri); + +/** + * @brief Request the image and video content of the moving photo and write to destination uri. + * + * @permission ohos.permission.READ_IMAGEVIDEO + * @param movingPhoto the {@link OH_MovingPhoto} instance. + * @param imageUri the destination file uri to save the image data. + * @param videoUri the destination file uri to save the video data. + * @return {@link #MEDIA_LIBRARY_OK} if the method call succeeds. + * {@link #MEDIA_LIBRARY_PARAMETER_ERROR} Parameter error. Possible causes: + * 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * 3. Parameter verification failed. + * {@link #MEDIA_LIBRARY_PERMISSION_DENIED} if permission is denied. + * {@link #MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR} if internal system error. + * @since 12 +*/ +MediaLibrary_ErrorCode OH_MovingPhoto_RequestContentWithUris(OH_MovingPhoto* movingPhoto, char* imageUri, + char* videoUri); + +/** + * @brief Request the image or video content of the moving photo and write to destination uri. + * + * @permission ohos.permission.READ_IMAGEVIDEO + * @param movingPhoto the {@link OH_MovingPhoto} instance. + * @param resourceType the {@link MediaLibrary_ResourceType} of the moving photo content to request. + * @param uri the destination file uri to save the data. + * @return {@link #MEDIA_LIBRARY_OK} if the method call succeeds. + * {@link #MEDIA_LIBRARY_PARAMETER_ERROR} Parameter error. Possible causes: + * 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * 3. Parameter verification failed. + * {@link #MEDIA_LIBRARY_PERMISSION_DENIED} if permission is denied. + * {@link #MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR} if internal system error. + * @since 12 +*/ +MediaLibrary_ErrorCode OH_MovingPhoto_RequestContentWithUri(OH_MovingPhoto* movingPhoto, + MediaLibrary_ResourceType resourceType, char* uri); + +/** + * @brief Request data of the moving photo. + * + * @permission ohos.permission.READ_IMAGEVIDEO + * @param movingPhoto the {@link OH_MovingPhoto} instance. + * @param resourceType the {@link MediaLibrary_ResourceType} of the moving photo content to request. + * @param buffer the buffer of the content. + * @param size the size of the buffer. + * @return {@link #MEDIA_LIBRARY_OK} if the method call succeeds. + * {@link #MEDIA_LIBRARY_PARAMETER_ERROR} Parameter error. Possible causes: + * 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * 3. Parameter verification failed. + * {@link #MEDIA_LIBRARY_PERMISSION_DENIED} if permission is denied. + * {@link #MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR} if internal system error. + * @since 12 +*/ +MediaLibrary_ErrorCode OH_MovingPhoto_RequestContentWithBuffer(OH_MovingPhoto* movingPhoto, + MediaLibrary_ResourceType resourceType, const uint8_t** buffer, uint32_t* size); + +/** + * @brief Release the {@link OH_MovingPhoto} instance. + * + * @param movingPhoto the {@link OH_MovingPhoto} instance. + * @return {@link #MEDIA_LIBRARY_OK} if the method call succeeds. + * {@link #MEDIA_LIBRARY_PARAMETER_ERROR} Parameter error. Possible causes: + * 1. Mandatory parameters are left unspecified. + * 2. Incorrect parameter types. + * 3. Parameter verification failed. + * @since 12 +*/ +MediaLibrary_ErrorCode OH_MovingPhoto_Release(OH_MovingPhoto* movingPhoto); + +#ifdef __cplusplus +} +#endif + +#endif // MULTIMEDIA_MEDIA_LIBRARY_NATIVE_MOVING_PHOTO_H +/** @} */ \ No newline at end of file