add media asset ndk

Signed-off-by: caochuan <caochuan@huawei.com>
This commit is contained in:
caochuan 2024-08-18 13:29:18 +08:00
parent 2ead6bcc4e
commit c988329755
12 changed files with 876 additions and 15 deletions

View File

@ -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",
]
}

View File

@ -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"
}
]

View File

@ -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.
*

View File

@ -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 <stdint.h>
#include <stdio.h>
#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
/** @} */

View File

@ -43,6 +43,8 @@
#include <stdint.h>
#include <stdio.h>
#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

View File

@ -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
/** @} */

View File

@ -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 <stdint.h>
#include "multimedia/image_framework/image/image_source_native.h"
#ifdef __cplusplus
extern "C" {
#endif
@ -71,6 +73,24 @@ 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 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 +105,64 @@ 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.
* It is recommended to retry and check the logs.
* Possible causes:
* 1. Database corrupted.
* 2. The file system is abnormal.
* 3. The IPC request timed out.
*/
MEDIA_LIBRARY_INTERNAL_SYSTEM_ERROR = 23800301,
} MediaLibrary_ErrorCode;
/**
* @brief Delivery Mode
*
@ -102,17 +180,6 @@ typedef enum MediaLibrary_DeliveryMode {
MEDIA_LIBRARY_BALANCED_MODE = 2
} MediaLibrary_DeliveryMode;
/**
* @brief Called when a requested source is prepared.
*
* This function is called when the requested source is prepared.
*
* @param result Results of the processing of the requested resources.
* @param requestId Request ID.
* @since 12
*/
typedef void (*OH_MediaLibrary_OnDataPrepared)(int32_t result, MediaLibrary_RequestId requestId);
/**
* @brief Request Options
*
@ -125,7 +192,108 @@ typedef struct MediaLibrary_RequestOptions {
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.
*
* This function is called when the requested source is prepared.
*
* @param result Results of the processing of the requested resources.
* @param requestId Request ID.
* @since 12
*/
typedef void (*OH_MediaLibrary_OnDataPrepared)(int32_t result, MediaLibrary_RequestId requestId);
/**
* @brief Called when a requested image source is prepared.
*
* 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 void (*OH_MediaLibrary_OnImageDataPrepared)(MediaLibrary_ErrorCode result,
MediaLibrary_RequestId requestId, MediaLibrary_MediaQuality mediaQuality, MediaLibrary_MediaContentType type,
OH_ImageSourceNative* imageSourceNative);
#ifdef __cplusplus
}
#endif
#endif // MULTIMEDIA_MEDIA_LIBRARY_NATIVE_MEDIA_ASSET_BASE_H
#endif // MULTIMEDIA_MEDIA_LIBRARY_NATIVE_MEDIA_ASSET_BASE_H
/** @} */

View File

@ -0,0 +1,170 @@
/*
* 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 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 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 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.
* @since 12
*/
MediaLibrary_ErrorCode OH_MediaAsset_GetOrientation(OH_MediaAsset* mediaAsset, uint32_t* orientation);
/**
* @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
/** @} */

View File

@ -0,0 +1,130 @@
/*
* 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 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 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
/** @} */

View File

@ -18,7 +18,10 @@ 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",
]
}
@ -31,5 +34,8 @@ 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/media_asset_change_request_capi.h",
]
}

View File

@ -14,5 +14,65 @@
{
"first_introduced": "12",
"name": "OH_MediaAssetManager_CancelRequest"
},
{
"first_introduced": "12",
"name": "OH_MediaAssetManager_RequestImage"
},
{
"first_introduced": "12",
"name": "OH_MediaAccessHelper_ApplyChanges"
},
{
"first_introduced": "12",
"name": "OH_MediaAsset_GetUri"
},
{
"first_introduced": "12",
"name": "OH_MediaAsset_GetDisplayName"
},
{
"first_introduced": "12",
"name": "OH_MediaAsset_GetSize"
},
{
"first_introduced": "12",
"name": "OH_MediaAsset_GetDateModifiedMs"
},
{
"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_Release"
},
{
"first_introduced": "12",
"name": "OH_MediaAssetChangeRequest_Create"
},
{
"first_introduced": "12",
"name": "OH_MediaAssetChangeRequest_AddResourceWithBuffer"
},
{
"first_introduced": "12",
"name": "OH_MediaAssetChangeRequest_SaveCameraPhoto"
},
{
"first_introduced": "12",
"name": "OH_MediaAssetChangeRequest_DiscardCameraPhoto"
},
{
"first_introduced": "12",
"name": "OH_MediaAssetChangeRequest_Release"
}
]

View File

@ -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,33 @@ MediaLibrary_RequestId OH_MediaAssetManager_RequestVideoForPath(OH_MediaAssetMan
*/
bool OH_MediaAssetManager_CancelRequest(OH_MediaAssetManager* manager, const MediaLibrary_RequestId requestId);
/**
* @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);
#ifdef __cplusplus
}
#endif
#endif // MULTIMEDIA_MEDIA_LIBRARY_NATIVE_MEDIA_ASSET_MANAGER_H
#endif // MULTIMEDIA_MEDIA_LIBRARY_NATIVE_MEDIA_ASSET_MANAGER_H
/** @} */