diff --git a/arkui/ace_engine/native/drag_and_drop.h b/arkui/ace_engine/native/drag_and_drop.h index c8dc147263247f5ea57e28e1d466c75494e08361..2f68d95b0f7affd5a6d626e7bd425d6513752183 100644 --- a/arkui/ace_engine/native/drag_and_drop.h +++ b/arkui/ace_engine/native/drag_and_drop.h @@ -80,22 +80,22 @@ typedef enum { */ typedef enum { /** Unknown. */ - ARKUI_PREVIEW_DRAG_STATUS_UNKNOWN = -1, + ARKUI_PRE_DRAG_STATUS_UNKNOWN = -1, /** A drag gesture is being detected. */ - ARKUI_PREVIEW_DRAG_STATUS_ACTION_DETECTING, + ARKUI_PRE_DRAG_STATUS_ACTION_DETECTING, /** The component is ready to be dragged. */ - ARKUI_PREVIEW_DRAG_STATUS_READY_TO_TRIGGER_DRAG, + ARKUI_PRE_DRAG_STATUS_READY_TO_TRIGGER_DRAG, /** A lift animation is started. */ - ARKUI_PREVIEW_DRAG_STATUS_PREVIEW_LIFT_STARTED, + ARKUI_PRE_DRAG_STATUS_PREVIEW_LIFT_STARTED, /** A lift animation is finished. */ - ARKUI_PREVIEW_DRAG_STATUS_PREVIEW_LIFT_FINISHED, + ARKUI_PRE_DRAG_STATUS_PREVIEW_LIFT_FINISHED, /** A drop animation is started. */ - ARKUI_PREVIEW_DRAG_STATUS_PREVIEW_LANDING_STARTED, + ARKUI_PRE_DRAG_STATUS_PREVIEW_LANDING_STARTED, /** A drop animation is finished. */ - ARKUI_PREVIEW_DRAG_STATUS_PREVIEW_LANDING_FINISHED, + ARKUI_PRE_DRAG_STATUS_PREVIEW_LANDING_FINISHED, /** A drop animation is terminated. */ - ARKUI_PREVIEW_DRAG_STATUS_CANCELED_BEFORE_DRAG, -} ArkUI_PreviewDragStatus; + ARKUI_PRE_DRAG_STATUS_CANCELED_BEFORE_DRAG, +} ArkUI_PreDragStatus; /** * @brief Defines an enum for drag preview scale modes. @@ -192,7 +192,7 @@ ArkUI_DragEvent* OH_ArkUI_NodeEvent_GetDragEvent(ArkUI_NodeEvent* nodeEvent); * @return Returns the interaction state prior to the drop and drop operation. * @since 12 */ -ArkUI_PreviewDragStatus OH_ArkUI_NodeEvent_GetPreviewDragStatus(ArkUI_NodeEvent* nodeEvent); +ArkUI_PreDragStatus OH_ArkUI_NodeEvent_GetPreDragStatus(ArkUI_NodeEvent* nodeEvent); /** * @brief Sets whether to disable the default drop animation. diff --git a/arkui/ace_engine/native/libace.ndk.json b/arkui/ace_engine/native/libace.ndk.json index 250a1c13d40a618dadb08cfd7cf34f8066cc1f83..774365f3bc51c01e71b1a4120f857864f4e42fc7 100644 --- a/arkui/ace_engine/native/libace.ndk.json +++ b/arkui/ace_engine/native/libace.ndk.json @@ -247,6 +247,70 @@ "first_introduced": "12", "name": "OH_ArkUI_GestureInterruptInfo_GetSystemRecognizerType" }, + { + "first_introduced": "12", + "name": "OH_ArkUI_GetResponseRecognizersFromInterruptInfo" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_SetGestureRecognizerEnabled" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_GetGestureRecognizerEnabled" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_GetGestureRecognizerState" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_GetGestureEventTargetInfo" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_GestureEventTargetInfo_IsScrollBegin" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_GestureEventTargetInfo_IsScrollEnd" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_GetPanGestureDirectionMask" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_IsBuiltInGesture" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_GetGestureTag" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_GetGestureBindNodeId" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_IsGestureRecognizerValid" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_ParallelInnerGestureEvent_GetUserData" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_ParallelInnerGestureEvent_GetCurrentRecognizer" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_ParallelInnerGestureEvent_GetConflictRecognizers" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_SetArkUIGestureRecognizerDisposeNotify" + }, { "first_introduced": "12", "name": "OH_NativeXComponent_SetNeedSoftKeyboard" @@ -1765,7 +1829,7 @@ }, { "first_introduced": "12", - "name": "OH_ArkUI_NodeEvent_GetPreviewDragStatus" + "name": "OH_ArkUI_NodeEvent_GetPreDragStatus" }, { "first_introduced": "12", @@ -1982,5 +2046,93 @@ { "first_introduced": "12", "name": "OH_ArkUI_DialogDismissEvent_GetDismissReason" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_NodeCustomEvent_GetCustomSpanMeasureInfo" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_NodeCustomEvent_SetCustomSpanMetrics" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_NodeCustomEvent_GetCustomSpanDrawInfo" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_CustomSpanMeasureInfo_Create" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_CustomSpanMeasureInfo_Dispose" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_CustomSpanMeasureInfo_GetFontSize" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_CustomSpanMetrics_Create" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_CustomSpanMetrics_Dispose" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_CustomSpanMetrics_SetWidth" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_CustomSpanMetrics_SetHeight" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_CustomSpanDrawInfo_Create" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_CustomSpanDrawInfo_Dispose" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_CustomSpanDrawInfo_GetXOffset" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_CustomSpanDrawInfo_GetLineTop" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_CustomSpanDrawInfo_GetLineBottom" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_CustomSpanDrawInfo_GetBaseline" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_RegisterSystemColorModeChangeEvent" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_UnregisterSystemColorModeChangeEvent" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_RegisterSystemFontStyleChangeEvent" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_UnregisterSystemFontStyleChangeEvent" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_SystemFontStyleEvent_GetFontSize" + }, + { + "first_introduced": "12", + "name": "OH_ArkUI_SystemFontStyleEvent_GetFontWeight" } ] \ No newline at end of file diff --git a/arkui/ace_engine/native/native_gesture.h b/arkui/ace_engine/native/native_gesture.h index 35dac3924d75d777b705ff8a71685073e42edfd6..a3df8440136cbdddba3c8e5f8c01df46c9294a11 100644 --- a/arkui/ace_engine/native/native_gesture.h +++ b/arkui/ace_engine/native/native_gesture.h @@ -223,6 +223,65 @@ typedef enum { GESTURE_INTERRUPT_RESULT_REJECT, } ArkUI_GestureInterruptResult; +/** + * @brief Enumerates the gesture recognizer states. + * + * @since 12 + */ +typedef enum { + /** Ready. */ + ARKUI_GESTURE_RECOGNIZER_STATE_READY = 0, + + /** Detecting. */ + ARKUI_GESTURE_RECOGNIZER_STATE_DETECTING = 1, + + /** Pending. */ + ARKUI_GESTURE_RECOGNIZER_STATE_PENDING = 2, + + /** Blocked. */ + ARKUI_GESTURE_RECOGNIZER_STATE_BLOCKED = 3, + + /** Successful. */ + ARKUI_GESTURE_RECOGNIZER_STATE_SUCCESSFUL = 4, + + /** Failed. */ + ARKUI_GESTURE_RECOGNIZER_STATE_FAILED = 5, +} ArkUI_GestureRecognizerState; + +/** + * @brief Defines the gesture recognizer handle. + * + * @since 12 + */ +typedef ArkUI_GestureRecognizer* ArkUI_GestureRecognizerHandle; + +/** + * @brief Defines the gesture recognizer handle array. + * + * @since 12 + */ +typedef ArkUI_GestureRecognizerHandle* ArkUI_GestureRecognizerHandleArray; + +/** + * @brief Defines a GestureEventTargetInfo object that provides information about a gesture event target. + * + * @since 12 + */ +typedef struct ArkUI_GestureEventTargetInfo ArkUI_GestureEventTargetInfo; + +/** + * @brief Defines a parallel internal gesture event. + * + * @since 12 + */ +typedef struct ArkUI_ParallelInnerGestureEvent ArkUI_ParallelInnerGestureEvent; + +/** + * @brief Defines a callback function for notifying gesture recognizer destruction. + * @since 12 + */ +typedef void (*ArkUI_GestureRecognizerDisposeNotifyCallback)(ArkUI_GestureRecognizer* recognizer, void* userData); + /** * @brief Checks whether a gesture is a built-in gesture of the component. * @@ -408,6 +467,191 @@ float OH_ArkUI_PinchGesture_GetCenterY(const ArkUI_GestureEvent* event); * @since 12 */ ArkUI_NodeHandle OH_ArkUI_GestureEvent_GetNode(const ArkUI_GestureEvent* event); + +/** +* @brief Obtains information about a gesture response chain. +* +* @param event Indicates the pointer to the gesture interruption information. +* @param responseChain Indicates the pointer to an array of gesture recognizers on the response chain. +* @param count Indicates the pointer to the number of gesture recognizers on the response chain. +* @return Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if success. +* Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter exception occurs. +* @since 12 +*/ +int32_t OH_ArkUI_GetResponseRecognizersFromInterruptInfo(const ArkUI_GestureInterruptInfo* event, + ArkUI_GestureRecognizerHandleArray* responseChain, int32_t* count); + +/** +* @brief Sets the enabled state of a gesture recognizer. +* +* @param recognizer Indicates the pointer to a gesture recognizer. +* @param enabled Indicates the enabled state. +* @return Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if success. +* Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter exception occurs. +* @since 12 +*/ +int32_t OH_ArkUI_SetGestureRecognizerEnabled(ArkUI_GestureRecognizer* recognizer, bool enabled); + +/** +* @brief Obtains the enabled state of a gesture recognizer. +* +* @param recognizer Indicates the pointer to a gesture recognizer. +* @return Returns true if the gesture recognizer is enabled. +* Returns false if the gesture recognizer is disabled. +* @since 12 +*/ +bool OH_ArkUI_GetGestureRecognizerEnabled(ArkUI_GestureRecognizer* recognizer); + +/** +* @brief Obtains the state of a gesture recognizer. +* +* @param recognizer Indicates the pointer to a gesture recognizer. +* @param state Indicates the pointer to the state of the gesture recognizer. +* @return Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if success. +* Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter exception occurs. +* @since 12 +*/ +int32_t OH_ArkUI_GetGestureRecognizerState(ArkUI_GestureRecognizer* recognizer, ArkUI_GestureRecognizerState* state); + +/** +* @brief Obtains the information about a gesture event target. +* +* @param recognizer Indicates the pointer to a gesture recognizer. +* @param info Indicates the information about a gesture event target. +* @return Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if success. +* Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter exception occurs. +* @since 12 +*/ +int32_t OH_ArkUI_GetGestureEventTargetInfo(ArkUI_GestureRecognizer* recognizer, ArkUI_GestureEventTargetInfo** info); + +/** +* @brief Obtains whether this scroll container is scrolled to the top. +* +* @param info Indicates the information about a gesture event target. +* @param ret Indicates whether the scroll container is scrolled to the top. +* @return Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if success. +* Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter exception occurs. +* Returns {@link ARKUI_ERROR_CODE_NON_SCROLLABLE_CONTAINER} if the component is not a scroll container. +* @since 12 +*/ +int32_t OH_ArkUI_GestureEventTargetInfo_IsScrollBegin(ArkUI_GestureEventTargetInfo* info, bool* ret); + +/** +* @brief Obtains whether this scroll container is scrolled to the bottom. +* +* @param info Indicates the information about a gesture event target. +* @param ret Indicates whether the scroll container is scrolled to the bottom. +* @return Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if success. +* Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter exception occurs. +* Returns {@link ARKUI_ERROR_CODE_NON_SCROLLABLE_CONTAINER} if the component is not a scroll container. +* @since 12 +*/ +int32_t OH_ArkUI_GestureEventTargetInfo_IsScrollEnd(ArkUI_GestureEventTargetInfo* info, bool* ret); + +/** +* @brief Obtains the direction of a pan gesture. +* +* @param recognizer Indicates the pointer to a gesture recognizer. +* @param directionMask Indicates the pan direction. +* @return Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if success. +* Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter exception occurs. +* @since 12 +*/ +int32_t OH_ArkUI_GetPanGestureDirectionMask(ArkUI_GestureRecognizer* recognizer, + ArkUI_GestureDirectionMask* directionMask); + +/** +* @brief Obtains whether a gesture is a built-in gesture. +* +* @param recognizer Indicates the pointer to a gesture recognizer. +* @return Returns true if the gesture is a built-in gesture; returns false otherwise. +* @since 12 +*/ +bool OH_ArkUI_IsBuiltInGesture(ArkUI_GestureRecognizer* recognizer); + +/** +* @brief Obtains the tag of a gesture recognizer. +* +* @param recognizer Indicates the pointer to a gesture recognizer. +* @param buffer Indicates the buffer. +* @param bufferSize Indicates the buffer size. +* @param result Indicates the length of the string to be written to the buffer. +* @return Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if success. +* Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter exception occurs. +* Returns {@link ARKUI_ERROR_CODE_BUFFER_SIZE_NOT_ENOUGH} if the buffer is not large enough. +* @since 12 +*/ +int32_t OH_ArkUI_GetGestureTag(ArkUI_GestureRecognizer* recognizer, char* buffer, int32_t bufferSize, int32_t* result); + +/** +* @brief Obtains the ID of the component linked to a gesture recognizer. +* +* @param recognizer Indicates the pointer to a gesture recognizer. +* @param nodeId Indicates the component ID. +* @param size Indicates the buffer size. +* @param result Indicates the length of the string to be written to the buffer. +* @return Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if success. +* Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter exception occurs. +* Returns {@link ARKUI_ERROR_CODE_BUFFER_SIZE_NOT_ENOUGH} if the buffer is not large enough. +* @since 12 +*/ +int32_t OH_ArkUI_GetGestureBindNodeId(ArkUI_GestureRecognizer* recognizer, char* nodeId, int32_t size, + int32_t* result); + +/** +* @brief Obtains whether a gesture recognizer is valid. +* +* @param recognizer Indicates the pointer to a gesture recognizer. +* @return Returns true if the gesture recognizer is valid. +* Returns false if the gesture recognizer is invalid. +* @since 12 +*/ +bool OH_ArkUI_IsGestureRecognizerValid(ArkUI_GestureRecognizer* recognizer); + +/** +* @brief Obtains custom data in the parallel internal gesture event. +* +* @param event Indicates the pointer to a parallel internal gesture event. +* @return Returns the pointer to custom data. +* @since 12 +*/ +void* OH_ArkUI_ParallelInnerGestureEvent_GetUserData(ArkUI_ParallelInnerGestureEvent* event); + +/** +* @brief Obtains the current gesture recognizer in a parallel internal gesture event. +* +* @param event Indicates the pointer to a parallel internal gesture event. +* @return Returns the pointer to the current gesture recognizer. +* @since 12 +*/ +ArkUI_GestureRecognizer* OH_ArkUI_ParallelInnerGestureEvent_GetCurrentRecognizer( + ArkUI_ParallelInnerGestureEvent* event); + +/** +* @brief Obtains the conflicting gesture recognizers in a parallel internal gesture event. +* +* @param event Indicates the pointer to a parallel internal gesture event. +* @param array Indicates the pointer to the array of conflicting gesture recognizers. +* @param size Indicates the size of the array of conflicting gesture recognizers. +* @return Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if success. +* Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter exception occurs. +* @since 12 +*/ +int32_t OH_ArkUI_ParallelInnerGestureEvent_GetConflictRecognizers(ArkUI_ParallelInnerGestureEvent* event, + ArkUI_GestureRecognizerHandleArray* array, int32_t* size); + +/** +* @brief Sets a callback function for notifying gesture recognizer destruction. +* +* @param recognizer Indicates the pointer to a gesture recognizer. +* @param callback Indicates the callback function for notifying gesture recognizer destruction. +* @param userData Indicates the custom data. +* @return Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if success. +* Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter exception occurs. +*/ +int32_t OH_ArkUI_SetArkUIGestureRecognizerDisposeNotify(ArkUI_GestureRecognizer* recognizer, + ArkUI_GestureRecognizerDisposeNotifyCallback callback, void* userData); + /** * @brief Defines the gesture APIs. * @@ -625,6 +869,21 @@ typedef struct { * @return Returns the gesture type. */ ArkUI_GestureRecognizerType (*getGestureType)(ArkUI_GestureRecognizer* recognizer); + + /** + * @brief Sets the callback function for a parallel internal gesture event. + * + * @param node Indicates the ArkUI node for which the callback of a parallel internal gesture event is to be set. + * @param userData Indicates the custom data. + * @param parallelInnerGesture Indicates the parallel internal gesture event. event returns the data of the + * parallel internal gesture event; parallelInnerGesture returns the pointer to the gesture recognizer + * that requires parallel recognition. + * @return Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if success. + * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter exception occurs. + */ + int32_t (*setInnerGestureParallelTo)( + ArkUI_NodeHandle node, void* userData, ArkUI_GestureRecognizer* (*parallelInnerGesture)( + ArkUI_ParallelInnerGestureEvent* event)); } ArkUI_NativeGestureAPI_1; #ifdef __cplusplus diff --git a/arkui/ace_engine/native/native_node.h b/arkui/ace_engine/native/native_node.h index 1412a47cfb2a2994f5ec96280b8a77d1c811e5d2..8442784be9ac2186400c6cadc15c8694c3db2ad7 100644 --- a/arkui/ace_engine/native/native_node.h +++ b/arkui/ace_engine/native/native_node.h @@ -122,6 +122,8 @@ typedef enum { ARKUI_NODE_GRID, /** Grid item. */ ARKUI_NODE_GRID_ITEM, + /** Custom span. */ + ARKUI_NODE_CUSTOM_SPAN, } ArkUI_NodeType; /** @@ -494,15 +496,16 @@ typedef enum { */ NODE_VISIBILITY, /** - * @brief Defines the clip attribute, which can be set, reset, and obtained as required through APIs. + * @brief Defines the clipping and masking attribute, which can be set, reset, and obtained as required through + * APIs. * * Format of the {@link ArkUI_AttributeItem} parameter for setting the attribute:\n * .value[0].i32: whether to clip the component based on the parent container bounds. - * The value 0 means to clip the component, and 1 means the opposite. \n + * The value 1 means to clip the component, and 0 means the opposite. \n * \n * Format of the return value {@link ArkUI_AttributeItem}:\n * .value[0].i32: whether to clip the component based on the parent container bounds. - * The value 0 means to clip the component, and 1 means the opposite. \n + * The value 1 means to clip the component, and 0 means the opposite. \n * */ NODE_CLIP, @@ -1027,10 +1030,10 @@ typedef enum { * .string: command for drawing the path.\n * 5. Progress:\n * .value[0].i32: mask type. The parameter type is {@link ArkUI_MaskType}. - * The value is ARKUI_MASK_TYPE_PROSGRESS for the progress shape.\n + * The value is ARKUI_MASK_TYPE_PROGRESS for the progress shape.\n * .value[1].f32: current value of the progress indicator.\n * .value[2].f32: maximum value of the progress indicator.\n - * .value[3].u32: color of the progress indicator.\n + * .value[3].u32: color of the progress indicator, in 0xARGB format.\n * \n * Format of the return value {@link ArkUI_AttributeItem}, which supports five types of shapes:\n * 1. Rectangle:\n @@ -2172,6 +2175,18 @@ typedef enum { */ NODE_TEXT_CONTENT_WITH_STYLED_STRING, + /** + * @brief Sets whether to center text vertically in the text component. + * + * Format of the {@link ArkUI_AttributeItem} parameter for setting the attribute:\n + * .value[0].i32: whether to center text vertically. The default value is false. \n + * \n + * Format of the return value {@link ArkUI_AttributeItem}:\n + * .value[0].i32: whether to center text vertically. \n + * + */ + NODE_TEXT_HALF_LEADING = 1029, + /** * @brief Defines the text content attribute, which can be set, reset, and obtained as required through APIs. * @@ -5537,7 +5552,7 @@ typedef enum { * When the event callback occurs, the union type in the {@link ArkUI_NodeEvent} object is * {@link ArkUI_NodeComponentEvent}. \n * {@link ArkUI_NodeComponentEvent} contains one parameter:\n - * ArkUI_NodeComponentEvent.data[0].i32: corresponds to {@link ArkUI_PreViewDragStatus}. \n + * ArkUI_NodeComponentEvent.data[0].i32: corresponds to {@link ArkUI_PreDragStatus}. \n */ NODE_ON_PRE_DRAG = 14, /** @@ -7406,6 +7421,48 @@ ArkUI_NodeHandle OH_ArkUI_NodeCustomEvent_GetNodeHandle(ArkUI_NodeCustomEvent* e */ ArkUI_NodeCustomEventType OH_ArkUI_NodeCustomEvent_GetEventType(ArkUI_NodeCustomEvent* event); +/** +* @brief Obtains the measurement information of a custom span through a custom component event. +* +* @param event Indicates the pointer to the custom component event. +* @param info Indicates the measurement information to be obtained. +* @return Returns the result code. +* Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. +* Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs. +*
Possible causes: Parameter verification failed, the parameter should not be nullptr. +* @since 12 +*/ +int32_t OH_ArkUI_NodeCustomEvent_GetCustomSpanMeasureInfo( + ArkUI_NodeCustomEvent* event, ArkUI_CustomSpanMeasureInfo* info); + +/** +* @brief Sets the measurement metrics of a custom span through a custom component event. +* +* @param event Indicates the pointer to the custom component event. +* @param metrics Indicates the measurement metrics to set. +* @return Returns the result code. +* Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. +* Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs. +*
Possible causes: Parameter verification failed, the parameter should not be nullptr. +* @since 12 +*/ +int32_t OH_ArkUI_NodeCustomEvent_SetCustomSpanMetrics( + ArkUI_NodeCustomEvent* event, ArkUI_CustomSpanMetrics* metrics); + +/** +* @brief Obtains the drawing information of a custom span through a custom component event. +* +* @param event Indicates the pointer to the custom component event. +* @param info Indicates the drawing information to obtain. +* @return Returns the result code. +* Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. +* Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs. +*
Possible causes: Parameter verification failed, the parameter should not be nullptr. +* @since 12 +*/ +int32_t OH_ArkUI_NodeCustomEvent_GetCustomSpanDrawInfo( + ArkUI_NodeCustomEvent* event, ArkUI_CustomSpanDrawInfo* info); + /** * @brief Defines the node content event type. * @@ -7620,6 +7677,73 @@ int32_t OH_ArkUI_List_CloseAllSwipeActions(ArkUI_NodeHandle node, void* userData */ ArkUI_ContextHandle OH_ArkUI_GetContextByNode(ArkUI_NodeHandle node); +/** +* @brief The event called when the system color mode changes. +* Only one system color change callback can be registered for the same component. +* +* @param node Indicates the target node. +* @param userData Indicates the custom data to be saved. +* @param onColorModeChange Callback Events. +* @return Error code. +* {@link ARKUI_ERROR_CODE_NO_ERROR} Success. +* {@link ARKUI_ERROR_CODE_PARAM_INVALID} Function parameter exception. +* {@link ARKUI_ERROR_CODE_ATTRIBUTE_OR_EVENT_NOT_SUPPORTED} The component does not support this event. +* @since 12 +*/ +int32_t OH_ArkUI_RegisterSystemColorModeChangeEvent(ArkUI_NodeHandle node, + void* userData, void (*onColorModeChange)(ArkUI_SystemColorMode colorMode, void* userData)); + +/** +* @brief Unregister the event callback when the system color mode changes. +* +* @param node Indicates the target node. +* @since 12 +*/ +void OH_ArkUI_UnregisterSystemColorModeChangeEvent(ArkUI_NodeHandle node); + +/** +* @brief The event called when the system font style changes. +* Only one system font change callback can be registered for the same component. +* +* @param node Indicates the target node. +* @param userData Indicates the custom data to be saved. +* @param onFontStyleChange Callback Events. +* @return Error code. +* {@link ARKUI_ERROR_CODE_NO_ERROR} Success. +* {@link ARKUI_ERROR_CODE_PARAM_INVALID} Function parameter exception. +* {@link ARKUI_ERROR_CODE_ATTRIBUTE_OR_EVENT_NOT_SUPPORTED} The component does not support this event. +* @since 12 +*/ +int32_t OH_ArkUI_RegisterSystemFontStyleChangeEvent(ArkUI_NodeHandle node, + void* userData, void (*onFontStyleChange)(ArkUI_SystemFontStyleEvent* event, void* userData)); + +/** +* @brief Unregister the event callback when the system font style changes. +* +* @param node Indicates the target node. +* @since 12 +*/ +void OH_ArkUI_UnregisterSystemFontStyleChangeEvent(ArkUI_NodeHandle node); + +/** + * @brief Retrieve the font size value for system font change events. + * + * @param event Indicates a pointer to the current system font change event. + * @return Updated system font size. -1 indicates a retrieval error. + * @since 12 + */ +int32_t OH_ArkUI_SystemFontStyleEvent_GetFontSize(const ArkUI_SystemFontStyleEvent* event); + +/** + * @brief Retrieve the font thickness values for system font change events. + * + * @param event Indicates a pointer to the current system font change event. + * @return Updated system font thickness, return value type {@link ArkUI_fontWeight}, + * default value:ARKUI_FONT_WEIGHT_W100。 + * @since 12 + */ +int32_t OH_ArkUI_SystemFontStyleEvent_GetFontWeight(const ArkUI_SystemFontStyleEvent* event); + #ifdef __cplusplus }; #endif diff --git a/arkui/ace_engine/native/native_type.h b/arkui/ace_engine/native/native_type.h index f238b1d6ff91dc6be0bd1c0ec1e84c483909387f..6bf306990cf1e0567055392efa5de5741619e1b2 100644 --- a/arkui/ace_engine/native/native_type.h +++ b/arkui/ace_engine/native/native_type.h @@ -983,6 +983,18 @@ typedef enum { ARKUI_COLOR_MODE_DARK, } ArkUI_ColorMode; +/** + * @brief Enumerates the system color modes. + * + * @since 12 + */ +typedef enum { + /** Light color mode. */ + ARKUI_SYSTEM_COLOR_MODE_LIGHT = 0, + /** Dark color mode. */ + ARKUI_SYSTEM_COLOR_MODE_DARK, +} ArkUI_SystemColorMode; + /** * @brief Enumerates the blur styles. * @@ -1895,6 +1907,10 @@ typedef enum { ARKUI_ERROR_CODE_GET_INFO_FAILED = 106201, /** The buffer size is not large enough. */ ARKUI_ERROR_CODE_BUFFER_SIZE_ERROR = 106202, + /** The component is not a scroll container. */ + ARKUI_ERROR_CODE_NON_SCROLLABLE_CONTAINER = 180001, + /** The buffer is not large enough. */ + ARKUI_ERROR_CODE_BUFFER_SIZE_NOT_ENOUGH = 180002, } ArkUI_ErrorCode; /** @@ -2063,6 +2079,27 @@ typedef struct { float perspective; } ArkUI_RotationOptions; +/** + * @brief Defines a struct for the measurement information of a custom span. + * + * @since 12 + */ +typedef struct ArkUI_CustomSpanMeasureInfo ArkUI_CustomSpanMeasureInfo; + +/** + * @brief Defines a struct for the measurement metrics of a custom span. + * + * @since 12 + */ +typedef struct ArkUI_CustomSpanMetrics ArkUI_CustomSpanMetrics; + +/** + * @brief Defines a struct for the drawing information of a custom span. + * + * @since 12 + */ +typedef struct ArkUI_CustomSpanDrawInfo ArkUI_CustomSpanDrawInfo; + /** * @brief Defines the state of the NavDestination component. * @@ -2137,6 +2174,13 @@ typedef enum { ARKUI_SAFE_AREA_EDGE_END = 1 << 3, } ArkUI_SafeAreaEdge; +/** + * @brief Defines parameter used by the system font style callback event. + * + * @since 12 + */ +typedef struct ArkUI_SystemFontStyleEvent ArkUI_SystemFontStyleEvent; + /** * @brief Creates a size constraint. * @@ -3410,6 +3454,133 @@ int32_t OH_ArkUI_ListChildrenMainSizeOption_UpdateSize(ArkUI_ListChildrenMainSiz */ float OH_ArkUI_ListChildrenMainSizeOption_GetMainSize(ArkUI_ListChildrenMainSize* option, int32_t index); +/** + * @brief Creates measurement information for this custom span. + * + * @return Returns a CustomSpanMeasureInfo instance. + *
If the result returns nullptr, there may be out of memory. + * @since 12 +*/ +ArkUI_CustomSpanMeasureInfo* OH_ArkUI_CustomSpanMeasureInfo_Create(); + +/** + * @brief Disposes of measurement information of this custom span. + * + * @param info The CustomSpanMeasureInfo instance to be destroyed. + * @since 12 +*/ +void OH_ArkUI_CustomSpanMeasureInfo_Dispose(ArkUI_CustomSpanMeasureInfo* info); + +/** + * @brief Obtains the font size of a custom span. + * + * @param info Indicates the pointer to the measurement information of a custom span. + * @return Returns the font size. If a parameter error occurs, 0.0f is returned. + *
Possible causes: Parameter verification failed, the parameter should not be nullptr. + * @since 12 +*/ +float OH_ArkUI_CustomSpanMeasureInfo_GetFontSize(ArkUI_CustomSpanMeasureInfo* info); + +/** + * @brief Creates measurement metrics for this custom span. + * + * @return Returns a CustomSpanMetrics instance. + *
If the result returns nullptr, there may be out of memory. + * @since 12 +*/ +ArkUI_CustomSpanMetrics* OH_ArkUI_CustomSpanMetrics_Create(); + +/** + * @brief Disposes of measurement metrics of this custom span. + * + * @param info The CustomSpanMetrics instance to be destroyed. + * @since 12 +*/ +void OH_ArkUI_CustomSpanMetrics_Dispose(ArkUI_CustomSpanMetrics* metrics); + +/** + * @brief Sets the width for a custom span. + * + * @param metrics Indicates the pointer to a CustomSpanMetrics instance. + * @param width Indicates the width, in px. The width should be greater than 0. + * @return Returns the result code. + * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. + * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs. + *
Possible causes: Parameter verification failed, the parameter should not be nullptr. + * @since 12 +*/ +int32_t OH_ArkUI_CustomSpanMetrics_SetWidth(ArkUI_CustomSpanMetrics* metrics, float width); + +/** + * @brief Sets the height for a custom span. + * + * @param metrics Indicates the pointer to a CustomSpanMetrics instance. + * @param width Indicates the height, in px. The width should be greater than 0. + * @return Returns the result code. + * Returns {@link ARKUI_ERROR_CODE_NO_ERROR} if the operation is successful. + * Returns {@link ARKUI_ERROR_CODE_PARAM_INVALID} if a parameter error occurs. + *
Possible causes: Parameter verification failed, the parameter should not be nullptr. + * @since 12 +*/ +int32_t OH_ArkUI_CustomSpanMetrics_SetHeight(ArkUI_CustomSpanMetrics* metrics, float height); + +/** + * @brief Creates drawing information for this custom span. + * + * @return Returns a CustomSpanDrawInfo instance. + *
If the result returns nullptr, there may be out of memory. + * @since 12 +*/ +ArkUI_CustomSpanDrawInfo* OH_ArkUI_CustomSpanDrawInfo_Create(); + +/** + * @brief Disposes of drawing information for this custom span. + * + * @param info The CustomSpanDrawInfo instance to be destroyed. + * @since 12 +*/ +void OH_ArkUI_CustomSpanDrawInfo_Dispose(ArkUI_CustomSpanDrawInfo* info); + +/** + * @brief Obtains the x-axis offset of the custom span relative to the mounted component. + * + * @param info Indicates the pointer to the drawing information of a custom span. + * @return Returns the x-axis offset. If a parameter error occurs, 0.0f is returned. + *
Possible causes: Parameter verification failed, the parameter should not be nullptr. + * @since 12 +*/ +float OH_ArkUI_CustomSpanDrawInfo_GetXOffset(ArkUI_CustomSpanDrawInfo* info); + +/** + * @brief Obtains the top margin of the custom span relative to the mounted component. + * + * @param info Indicates the pointer to the drawing information of a custom span. + * @return Returns the top margin. If a parameter error occurs, 0.0f is returned. + *
Possible causes: Parameter verification failed, the parameter should not be nullptr. + * @since 12 +*/ +float OH_ArkUI_CustomSpanDrawInfo_GetLineTop(ArkUI_CustomSpanDrawInfo* info); + +/** + * @brief Obtains the bottom margin of the custom span relative to the mounted component. + * + * @param info Indicates the pointer to the drawing information of a custom span. + * @return Returns the bottom margin. If a parameter error occurs, 0.0f is returned. + *
Possible causes: Parameter verification failed, the parameter should not be nullptr. + * @since 12 +*/ +float OH_ArkUI_CustomSpanDrawInfo_GetLineBottom(ArkUI_CustomSpanDrawInfo* info); + +/** + * @brief Obtains the baseline offset of the custom span relative to the mounted component. + * + * @param info Indicates the pointer to the drawing information of a custom span. + * @return Returns the baseline offset. If a parameter error occurs, 0.0f is returned. + *
Possible causes: Parameter verification failed, the parameter should not be nullptr. + * @since 12 +*/ +float OH_ArkUI_CustomSpanDrawInfo_GetBaseline(ArkUI_CustomSpanDrawInfo* info); + /** * @brief Create a image frame from the image path. * @param src Indicates the image path. diff --git a/build-tools/capi_parser/src/bin/config.py b/build-tools/capi_parser/src/bin/config.py index cd015a7454ee76bd1df5f5461825af0a782618f3..d0bfeff8a9ba77bed676f98998eaa1fc4cfc8417 100644 --- a/build-tools/capi_parser/src/bin/config.py +++ b/build-tools/capi_parser/src/bin/config.py @@ -15,7 +15,7 @@ import enum from coreImpl.parser import parser -from coreImpl.check import check +from coreImpl.check import check, check_syntax from coreImpl.diff import diff @@ -25,6 +25,7 @@ class ToolNameType(enum.Enum): CHECK = 'check' COLLECT_H = 'collect_h' COLLECT_FILE = 'collect_file' + CHECK_SYNTAX = 'check_syntax' tool_name_type_set = [ @@ -57,6 +58,8 @@ def run_tools(options): parser.parser_direct(options.parser_path) elif tool_name == ToolNameType['COLLECT_FILE'].value: parser.parser_file_level(options.output_path) + elif tool_name == ToolNameType['CHECK_SYNTAX'].value: + check_syntax.check_syntax_entrance(options.parser_path, options.dependent_path, options.output_path) else: print("工具名称错误") @@ -89,6 +92,13 @@ class Config(object): "type": str, "help": "工具输出文件路径" }, + { + "name": "--dependent-path", + "abbr": "-D", + "required": False, + "type": str, + "help": "依赖文件路径" + }, { "name": "--codecheck--path", "abbr": "--path", diff --git a/build-tools/capi_parser/src/coreImpl/check/check_doc.py b/build-tools/capi_parser/src/coreImpl/check/check_doc.py index 4e95d50a799a73f8dc966f18d8d3325210391e49..99fbee69303f5644612ede5905e5ec7c94d9e864 100644 --- a/build-tools/capi_parser/src/coreImpl/check/check_doc.py +++ b/build-tools/capi_parser/src/coreImpl/check/check_doc.py @@ -21,7 +21,7 @@ import subprocess from clang.cindex import CursorKind -from typedef.check.check import DocInfo, FileDocInfo, TAGS, CheckErrorMessage, CheckOutPut +from typedef.check.check import DocInfo, FileDocInfo, TAGS, CheckErrorMessage, CheckOutPut, CommentStartEndValue current_file = os.path.dirname(__file__) # permission数据来源于https://gitee.com/openharmony/utils_system_resources/raw/master/systemres/main/config.json @@ -474,7 +474,7 @@ def process_file_doc_info(file_doc_info: FileDocInfo, file_info, comment_start_l api_result_info = set_value_to_result(file_info, CheckErrorMessage.API_DOC_GLOBAL_10.name, get_tage_start_and_end(None, comment_start_line, file_doc_info.group_comment_str, file_info)) - api_result_info.mainBuggyLine = -1 + api_result_info.mainBuggyLine = CommentStartEndValue.DEFAULT_END.value api_result_info_list.append(api_result_info) # 处理file说明 if file_doc_info.file_name is None: @@ -502,6 +502,5 @@ def set_value_to_result(api_info, command, comment_value_info): def get_main_buggy_code(api_info): - main_buggy_code = os.path.basename(api_info['name']) if (len(api_info['node_content']) - == 0) else api_info['node_content']['content'] + main_buggy_code = '' if (len(api_info['node_content']) == 0) else api_info['node_content']['content'] return main_buggy_code diff --git a/build-tools/capi_parser/src/coreImpl/check/check_name.py b/build-tools/capi_parser/src/coreImpl/check/check_name.py index b32636d4392e67ec1ff106866a7c8a32ba9e7f08..98690645c81b5a83266266e044e5fe6616a71b37 100644 --- a/build-tools/capi_parser/src/coreImpl/check/check_name.py +++ b/build-tools/capi_parser/src/coreImpl/check/check_name.py @@ -55,9 +55,14 @@ def check_function_name(api_info, kind, parent_kind): def set_value_to_result(api_info, command): + content = api_info['node_content']['content'] + node_name = api_info['name'] + if api_info['kind'] == 'MACRO_DEFINITION' and api_info.get('def_func_name'): + node_name = api_info.get('def_func_name') + descriptive_message = CheckErrorMessage.__getitem__(command).value.replace('$$', node_name) return CheckOutPut(os.path.abspath(os.path.join(api_info['gn_path'], api_info['location']['location_path'])), - api_info['location']['location_line'], command, CheckErrorMessage.__getitem__(command).value, - api_info['node_content']['content'], api_info['location']['location_line']) + api_info['location']['location_line'], command, descriptive_message, + content, api_info['location']['location_line']) def is_self_developed_function(function_name): @@ -124,10 +129,10 @@ def check_file_name(file_info): file_name = os.path.basename(file_info['name']) result = re.match(CheckName['FILE_NAME'].value, file_name) if result is None: - chck_output = CheckOutPut(os.path.abspath(os.path.join(file_info['gn_path'], file_info['name'])), 0, - CheckErrorMessage.API_NAME_UNIVERSAL_14.name, - CheckErrorMessage.API_NAME_UNIVERSAL_14.value, file_name, 0) - api_result_info_list.append(chck_output) + check_output = CheckOutPut(os.path.abspath(os.path.join(file_info['gn_path'], file_info['name'])), 0, + CheckErrorMessage.API_NAME_UNIVERSAL_14.name, + CheckErrorMessage.API_NAME_UNIVERSAL_14.value.replace('$$', file_name), '', 0) + api_result_info_list.append(check_output) return api_result_info_list diff --git a/build-tools/capi_parser/src/coreImpl/check/check_syntax.py b/build-tools/capi_parser/src/coreImpl/check/check_syntax.py index 70572b31a4b5267bdc0dbd5f14441b8d698a48e5..a54d7ff71a6e13cefcc842f96e19f8ca0e89d49a 100644 --- a/build-tools/capi_parser/src/coreImpl/check/check_syntax.py +++ b/build-tools/capi_parser/src/coreImpl/check/check_syntax.py @@ -16,7 +16,8 @@ import re import os import subprocess -from typedef.check.check import ApiResultInfo, ErrorMessage, ErrorType, LogType, ErrorLevel +import openpyxl as op +from typedef.check.check import ApiResultInfo, ErrorType, LogType, ErrorLevel def check_syntax(file_path): @@ -32,26 +33,110 @@ def check_syntax(file_path): return result_list -def processing_data(run_result, result_file): +def get_all_dependent_file_path(dependent_file_path): + link_path = [] + for dir_path, _, _ in os.walk(dependent_file_path): + if 'build-tools' not in dir_path: + link_path.append(dir_path) + + return link_path + + +def process_result_data(result_info_list): + syntax_info_data = [] + for syntax_info in result_info_list: + info_data = [ + syntax_info.api_name, + syntax_info.file_name, + syntax_info.error_info, + syntax_info.location_line, + syntax_info.error_content, + ] + syntax_info_data.append(info_data) + + return syntax_info_data + + +def general_syntax_excel(syntax_data_list, output_path): + data = process_result_data(syntax_data_list) + wb = op.Workbook() + ws = wb['Sheet'] + ws.title = '语法错误信息' + ws.append(['当前文件路径', '错误文件路径', '错误信息', '行号', '代码片段']) + for title in data: + d = title[0], title[1], title[2], title[3], title[4] + ws.append(d) + + wb.save(output_path) + + +def get_dir_file_path(file_path): + file_path_total = [] + for dir_path, _, filenames in os.walk(file_path): + for file_name in filenames: + if 'build-tools' not in dir_path and 'sysroot_myself' not in dir_path and file_name.endswith('.h'): + file_path_total.append(os.path.join(dir_path, file_name)) + + return file_path_total + + +def get_all_object_file_path(file_path): + file_path_total = [] + if os.path.isdir(file_path): + file_path_total = get_dir_file_path(file_path) + else: + if file_path.endswith('.h'): + file_path_total.append(file_path) + + return file_path_total + + +def check_syntax_entrance(file_path, dependent_file_path, output_path): + cmd_list = ['clang'] + link_path = get_all_dependent_file_path(dependent_file_path) + args = ['-I{}'.format(path) for path in link_path] + cmd_list.extend(args) + cmd_list.append('-std=c99') + cmd_list.append('--target=aarch64-linux-musl') + result_list = [] + all_files_list = get_all_object_file_path(file_path) + for element_file in all_files_list: + command = cmd_list + [element_file] + run_result = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + result_list.extend(processing_data(run_result, element_file)) + general_syntax_excel(result_list, output_path) + return result_list + + +def processing_data(run_result, current_file): api_result_info_list = [] for run_result_child in run_result.stderr.decode().split('^'): + split_error_message = run_result_child.split('\r\n') + error_content = ''.join(split_error_message[-2:-3:-1]) result_child = run_result_child.replace('~', '') ret = re.findall('\\d+:\\d+', result_child) + error_file_message = re.search(r'([^"]+):\d:\d:', result_child) + error_file_name = current_file + if error_file_message: + error_file_list = error_file_message.group(1).split('\r\n') + if len(error_file_list) >= 1: + error_file_name = os.path.normpath(error_file_list[len(error_file_list) - 1]) if len(ret) != 0: error_message = get_specified_string(result_child) if len(error_message) == 1: continue position = ret[0] api_result_info = ApiResultInfo(ErrorType.SYNTAX_ERRORS.value, - error_message[1], result_file) + error_message[1], current_file) line_column = get_line_and_column(position) api_result_info.set_location_line(line_column[0]) api_result_info.set_location_column(line_column[1]) - api_result_info.set_location(result_file) + api_result_info.set_location(current_file) api_result_info.set_type(LogType.LOG_API.value) api_result_info.set_level(ErrorLevel.LOW.value) - api_result_info.set_file_name(result_file) + api_result_info.set_file_name(error_file_name) api_result_info_list.append(api_result_info) + api_result_info.set_error_content(error_content) return api_result_info_list diff --git a/build-tools/capi_parser/src/coreImpl/diff/diff.py b/build-tools/capi_parser/src/coreImpl/diff/diff.py index 43f15d2cacb0b87ad2fe5b1d080b505f6adbd6df..375f7ab94be6ce616070cfe0d276a9b5125dadab 100644 --- a/build-tools/capi_parser/src/coreImpl/diff/diff.py +++ b/build-tools/capi_parser/src/coreImpl/diff/diff.py @@ -13,7 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -from coreImpl.parser.parser import parser_include_ast +from coreImpl.parser.parser import diff_parser_include_ast from coreImpl.diff.diff_file import start_diff_file @@ -42,5 +42,5 @@ def process_file_diff(old_file, new_file): def get_parser_data(file_path): root_start = file_path.split('sdk_c')[0] root_path = f'{root_start}sdk_c' - parser_data = parser_include_ast(root_path, [file_path]) + parser_data = diff_parser_include_ast(root_path, [file_path]) return parser_data diff --git a/build-tools/capi_parser/src/coreImpl/diff/diff_file.py b/build-tools/capi_parser/src/coreImpl/diff/diff_file.py index 0635db772b2671ede5285629946c7da01df24d34..2c4c0fb169ed2c0b71bed6886c5fd36873073477 100644 --- a/build-tools/capi_parser/src/coreImpl/diff/diff_file.py +++ b/build-tools/capi_parser/src/coreImpl/diff/diff_file.py @@ -19,14 +19,15 @@ import os import stat from collections import OrderedDict import openpyxl as op -from coreImpl.parser.parser import parser_include_ast +from coreImpl.parser.parser import diff_parser_include_ast from coreImpl.diff.diff_processor_node import judgment_entrance, change_data_total -from typedef.diff.diff import OutputJson, ApiChangeData +from typedef.diff.diff import OutputJson, ApiChangeData, IgnoreFileDirectory from bin.write_md import write_md_entrance global_old_dir = '' global_new_dir = '' diff_info_list = [] +syntax_file_list = [] def get_modification_type_dict(): @@ -67,13 +68,15 @@ def get_api_change_obj(api_data): change_data_obj.set_kit_name(element.kit_name) change_data_obj.set_sub_system(element.sub_system) change_data_obj.set_is_api_change(element.is_api_change) - change_data_obj.set_class_name(element.class_name) + change_data_obj.set_current_api_type(element.current_api_type) change_data_obj.set_diff_type(element.operation_diff_type) change_data_obj.set_change_type(element.api_modification_type) change_data_obj.set_old_all_text(element.old_api_full_text) change_data_obj.set_new_all_text(element.new_api_full_text) change_data_obj.set_compatible_total(element.is_compatible) change_data_obj.set_is_system_api(element.is_system_api) + change_data_obj.set_open_close_api(element.open_close_api) + change_data_obj.set_is_third_party_api(element.is_third_party_api) key = 1 else: old_all_text = '{}#&#{}'.format(change_data_obj.old_all_text, element.old_api_full_text) @@ -120,7 +123,7 @@ def collect_node_api_change(api_change_info_list): api_change_info.kit_name, api_change_info.sub_system, api_change_info.is_api_change, - api_change_info.class_name, + api_change_info.current_api_type, api_change_info.diff_type, api_change_info.change_type, api_change_info.compatible, @@ -129,18 +132,42 @@ def collect_node_api_change(api_change_info_list): api_change_info.new_all_text, api_change_info.compatible_total, api_change_info.unique_id, - api_change_info.is_system_api + api_change_info.is_system_api, + api_change_info.open_close_api, + api_change_info.is_third_party_api ] change_data.append(info_data) return change_data +def syntax_file_excel(output_path): + data = [] + if syntax_file_list: + for syntax_dict in syntax_file_list: + info_data = [ + syntax_dict.get('current_file'), + syntax_dict.get('error_message') + ] + data.append(info_data) + + wb = op.Workbook() + ws = wb['Sheet'] + ws.title = '语法错误文件信息' + ws.append(['当前文件', '错误信息']) + for element in data: + d = element[0], element[1] + ws.append(d) + output_path_xlsx = os.path.abspath(os.path.join(output_path, r'syntax_file_error.xlsx')) + wb.save(output_path_xlsx) + + def start_diff_file(old_dir, new_dir, output_path): result_info_list = global_assignment(old_dir, new_dir) total = change_data_total collect_api_change_data = collect_api_change(total) generate_excel(result_info_list, collect_api_change_data, output_path) + syntax_file_excel(output_path) write_md_entrance(result_info_list, output_path) result_json = result_to_json(result_info_list) diff_result_path = r'./diff_result.txt' @@ -179,11 +206,11 @@ def generate_excel(result_info_list, api_change_data, output_path): ws_of_change = wb.create_sheet('api变更次数统计') ws_of_change.append(['api名称', 'kit名称', '归属子系统', '是否是api', 'api类型', '操作标记', '变更类型', '兼容性', '变更次数', '差异项-旧版本', '差异项-新版本', '兼容性列表', '接口全路径', - '是否为系统API']) + '是否为系统API', '开源/闭源API', '是否是三方库api']) for element in change_data_list: change_data = element[0], element[1], element[2], element[3], element[4], element[5],\ element[6], element[7], element[8], element[9], element[10], element[11],\ - element[12], element[13] + element[12], element[13], element[14], element[15] ws_of_change.append(change_data) output_path_xlsx = os.path.abspath(os.path.join(output_path, 'diff.xlsx')) wb.save(output_path_xlsx) @@ -224,6 +251,14 @@ def get_file_ext(file_name): return os.path.splitext(file_name)[1] +def filter_ignore_file(file_path): + ignore_dict = IgnoreFileDirectory.ignore_file_dict + for key in ignore_dict.keys(): + if key in file_path: + return False + return True + + def diff_list(old_file_list, new_file_list, old_dir, new_dir): all_list = set(old_file_list + new_file_list) if len(all_list) == 0: @@ -246,8 +281,8 @@ def diff_list(old_file_list, new_file_list, old_dir, new_dir): def add_new_file(diff_file_path): if os.path.isdir(diff_file_path): add_file(diff_file_path) - else: - result_map = parse_file_result(parser_include_ast(global_new_dir, [diff_file_path], flag=1)) + elif filter_ignore_file(diff_file_path): + result_map = parse_file_result(diff_parser_include_ast(global_new_dir, [diff_file_path], flag=1)) for new_info in result_map.values(): diff_info_list.extend(judgment_entrance(None, new_info)) @@ -255,8 +290,8 @@ def add_new_file(diff_file_path): def del_old_file(diff_file_path): if os.path.isdir(diff_file_path): del_file(diff_file_path) - else: - result_map = parse_file_result(parser_include_ast(global_old_dir, [diff_file_path], flag=0)) + elif filter_ignore_file(diff_file_path): + result_map = parse_file_result(diff_parser_include_ast(global_old_dir, [diff_file_path], flag=0)) for old_info in result_map.values(): diff_info_list.extend(judgment_entrance(old_info, None)) @@ -278,12 +313,14 @@ def get_same_file_diff(target_file, old_file_list, new_file_list, old_dir, new_d def get_file_result_diff(old_target_file, new_target_file): - old_file_result_map = parse_file_result(parser_include_ast(global_old_dir, [old_target_file], flag=0)) - new_file_result_map = parse_file_result(parser_include_ast(global_new_dir, [new_target_file], flag=1)) - merged_dict = OrderedDict(list(old_file_result_map.items()) + list(new_file_result_map.items())) - all_key_list = merged_dict.keys() - for key in all_key_list: - diff_info_list.extend(judgment_entrance(old_file_result_map.get(key), new_file_result_map.get(key))) + if filter_ignore_file(old_target_file): + old_file_result_map = parse_file_result(diff_parser_include_ast(global_old_dir, [old_target_file], flag=0)) + new_file_result_map = parse_file_result(diff_parser_include_ast(global_new_dir, [new_target_file], flag=1)) + if old_file_result_map and new_file_result_map: + merged_dict = OrderedDict(list(old_file_result_map.items()) + list(new_file_result_map.items())) + all_key_list = merged_dict.keys() + for key in all_key_list: + diff_info_list.extend(judgment_entrance(old_file_result_map.get(key), new_file_result_map.get(key))) def del_file(dir_path): @@ -294,8 +331,8 @@ def del_file(dir_path): file_path = os.path.join(dir_path, i) if os.path.isdir(file_path): del_file(file_path) - if get_file_ext(i) == '.h': - result_map = parse_file_result(parser_include_ast(global_old_dir, [file_path], flag=0)) + if get_file_ext(i) == '.h' and filter_ignore_file(file_path): + result_map = parse_file_result(diff_parser_include_ast(global_old_dir, [file_path], flag=0)) for old_info in result_map.values(): diff_info_list.extend(judgment_entrance(old_info, None)) @@ -308,8 +345,8 @@ def add_file(dir_path): file_path = os.path.join(dir_path, i) if os.path.isdir(file_path): add_file(file_path) - if get_file_ext(i) == '.h': - result_map = parse_file_result(parser_include_ast(global_new_dir, [file_path], flag=1)) + if get_file_ext(i) == '.h' and filter_ignore_file(file_path): + result_map = parse_file_result(diff_parser_include_ast(global_new_dir, [file_path], flag=1)) for new_info in result_map.values(): diff_info_list.extend(judgment_entrance(None, new_info)) @@ -322,16 +359,36 @@ def parse_file_result(result, data_type=0): """ result_map = {} for root_node in result: + if root_node['syntax_error'] != 'NA': + error_file_path = os.path.abspath(os.path.join(root_node['gn_path'], root_node['name'])) + error_message_dict = { + 'current_file': error_file_path, + 'error_message': root_node['syntax_error'] + } + syntax_file_list.append(error_message_dict) + result_map.setdefault(f'{root_node["name"]}-{root_node["kind"]}', root_node) if data_type != 1: parse_file_result_by_child(result_map, root_node) - result_map.setdefault(f'{root_node["name"]}-{root_node["kind"]}', root_node) return result_map +def process_empty_name(data_info: dict, result_map): + data_current_file = os.path.split(data_info['location']['location_path'])[1] + if data_info['kind'] == 'ENUM_DECL' and 'members' in data_info and data_current_file in data_info['type']: + for element in data_info['members']: + result_map.setdefault(f'{data_current_file}-{element["name"]}', element) + elif data_info['kind'] == 'ENUM_DECL' and 'members' in data_info and (data_current_file not in data_info['type']): + result_map.setdefault(f'{data_current_file}-{data_info["type"]}', data_info) + elif (data_info['kind'] == 'STRUCT_DECL' or data_info['kind'] == 'UNION_DECL') and \ + (data_current_file not in data_info['type']): + result_map.setdefault(f'{data_current_file}-{data_info["type"]}', data_info) + + def parse_file_result_by_child(result_map, root_node): children_list = root_node['children'] for children in children_list: if children["name"] == '': + process_empty_name(children, result_map) continue result_map.setdefault(f'{children["name"]}-{children["kind"]}', children) del root_node['children'] diff --git a/build-tools/capi_parser/src/coreImpl/diff/diff_processor_node.py b/build-tools/capi_parser/src/coreImpl/diff/diff_processor_node.py index a0deb5b436a09cf167b02143a8dd66277d237017..c4c1b6a3a217036472d4d7b0f4e6c52cc9325157 100644 --- a/build-tools/capi_parser/src/coreImpl/diff/diff_processor_node.py +++ b/build-tools/capi_parser/src/coreImpl/diff/diff_processor_node.py @@ -749,6 +749,27 @@ def process_typedef_child(old_child, new_child, diff_typedef_list): diff_typedef_list.extend(special_data) +def process_anonymous_enum_member(old_info, new_info): + result_obj_list = [] + if old_info and new_info: + if old_info['name'] != new_info['name']: + change_message_obj = DiffInfo(DiffType.ENUM_MEMBER_NAME_CHANGE, old_info['name'], new_info['name']) + result_obj_list.append(wrap_diff_info(old_info, new_info, change_message_obj)) + if old_info['value'] != new_info['value']: + change_message_obj = DiffInfo(DiffType.ENUM_MEMBER_VALUE_CHANGE, old_info['value'], new_info['value']) + result_obj_list.append(wrap_diff_info(old_info, new_info, change_message_obj)) + else: + if old_info: + change_message_obj = DiffInfo(DiffType.ENUM_MEMBER_REDUCE, old_info['node_content']['content'], 'NA') + result_obj_list.append(wrap_diff_info(old_info, new_info, change_message_obj)) + + elif new_info: + change_message_obj = DiffInfo(DiffType.ENUM_MEMBER_ADD, 'NA', new_info['node_content']['content']) + result_obj_list.append(wrap_diff_info(old_info, new_info, change_message_obj)) + + return result_obj_list + + process_data = { Scene.FUNCTION_DECL.value: process_function, Scene.MACRO_DEFINITION.value: process_define, @@ -756,14 +777,38 @@ process_data = { Scene.UNION_DECL.value: process_union, Scene.ENUM_DECL.value: process_enum, Scene.VAR_DECL.value: process_variable_const, - Scene.TYPEDEF_DECL.value: process_typedef + Scene.TYPEDEF_DECL.value: process_typedef, + Scene.ENUM_CONSTANT_DECL.value: process_anonymous_enum_member, } +def get_ch_api_kind(dict_key): + if dict_key == Scene.ENUM_CONSTANT_DECL.value: + key = 'ENUM_DECL' + else: + key = dict_key + api_kind_dict = { + 'FUNCTION_DECL': '函数类型', + 'MACRO_DEFINITION': '宏定义类型', + 'STRUCT_DECL': '结构体类型', + 'UNION_DECL': '联合体类型', + 'ENUM_DECL': '枚举类型', + 'VAR_DECL': '常/变量类型', + 'TYPEDEF_DECL': '重命名类型', + 'TRANSLATION_UNIT': 'NA' + } + return api_kind_dict.get(key) + + def collect_change_data_total(data: dict, diff_info_list): for element in diff_info_list: element.set_api_node_name(data['name']) + if (data['kind'] == Scene.STRUCT_DECL.value or data['kind'] == Scene.UNION_DECL.value) and (not data['name']): + element.set_api_node_name(data['type']) element.set_current_api_unique_id(data['unique_id']) + element.set_open_close_api(data['open_close_api']) + element.set_is_third_party_api(data['is_third_party_api']) + element.set_current_api_type(get_ch_api_kind(data['kind'])) change_data_total.append(diff_info_list) @@ -780,17 +825,18 @@ def process_add_node(add_infor, key_extern, struct_union_enum): return diff_info_list if 'is_extern' in add_infor and add_infor['is_extern']: key_extern = True - diff_type = DiffType.ADD_API - old_api_content = 'NA' - if add_infor['kind'] in struct_union_enum: - new_api_content = add_infor['type'] + if add_infor['kind'] == Scene.ENUM_CONSTANT_DECL.value: + result_obj_list = process_anonymous_enum_member(old_infor, add_infor) + diff_info_list.extend(result_obj_list) else: - new_api_content = add_infor['node_content']['content'] - diff_info_list.append(wrap_diff_info(old_infor, add_infor, DiffInfo(diff_type, - old_api_content, new_api_content))) - if diff_type == DiffType.ADD_API: - set_is_api_change_result(diff_info_list, key_extern) - collect_change_data_total(add_infor, diff_info_list) + if add_infor['kind'] in struct_union_enum: + new_api_content = add_infor['type'] + else: + new_api_content = add_infor['node_content']['content'] + diff_info_list.append(wrap_diff_info(old_infor, add_infor, DiffInfo(DiffType.ADD_API, + 'NA', new_api_content))) + set_is_api_change_result(diff_info_list, key_extern) + collect_change_data_total(add_infor, diff_info_list) return diff_info_list @@ -802,14 +848,16 @@ def process_reduce_node(reduce_infor, key_extern, struct_union_enum): return diff_info_list if 'is_extern' in reduce_infor and reduce_infor['is_extern']: key_extern = True - diff_type = DiffType.REDUCE_API - new_api_content = 'NA' - if reduce_infor['kind'] in struct_union_enum: - old_api_content = reduce_infor['type'] + if reduce_infor['kind'] == Scene.ENUM_CONSTANT_DECL.value: + result_obj_list = process_anonymous_enum_member(reduce_infor, new_infor) + diff_info_list.extend(result_obj_list) else: - old_api_content = reduce_infor['node_content']['content'] - diff_info_list.append(wrap_diff_info(reduce_infor, new_infor, DiffInfo(diff_type, - old_api_content, new_api_content))) + if reduce_infor['kind'] in struct_union_enum: + old_api_content = reduce_infor['type'] + else: + old_api_content = reduce_infor['node_content']['content'] + diff_info_list.append(wrap_diff_info(reduce_infor, new_infor, DiffInfo(DiffType.REDUCE_API, + old_api_content, 'NA'))) set_is_api_change_result(diff_info_list, key_extern) collect_change_data_total(reduce_infor, diff_info_list) diff --git a/build-tools/capi_parser/src/coreImpl/parser/generating_tables.py b/build-tools/capi_parser/src/coreImpl/parser/generating_tables.py index 158d76bb828c789afb30e1a8d74fa2a1382b1a69..e109bfe95bdfd5aa02a9b379d9d05a90ca3a5245 100644 --- a/build-tools/capi_parser/src/coreImpl/parser/generating_tables.py +++ b/build-tools/capi_parser/src/coreImpl/parser/generating_tables.py @@ -85,8 +85,6 @@ def get_result_api(file_data, result_api): if 'children' in file_data: for item1 in file_data["children"]: # 抛开根节点 if (item1["kind"] == 'FUNCTION_DECL' or item1["kind"] == 'VAR_DECL') and item1["is_extern"]: - differ_infor = difference_api(item1) - item1['differ_infor'] = differ_infor item = filter_func(item1) result_api.append(item) @@ -151,7 +149,8 @@ def collated_api_data(api_data: list): api.get('location_path'), api.get('sub_system'), api.get('unique_id'), - api.get('differ_infor') + api.get('open_close_api'), + api.get('is_third_party_api') ] collated_data_total.append(collated_data) return collated_data_total @@ -161,7 +160,7 @@ def generate_excel(array, name, generate_json_unique, original_json_unique): first_line_infor = ['模块名', '类名', '方法名', '函数', '类型', '起始版本', '废弃版本', 'syscap', '错误码', '是否为系统API', '模型限制', '权限', '是否支持跨平台', '是否支持卡片应用', '是否支持高阶API', - '装饰器', 'kit', '文件路径', '子系统', '接口全路径', '开源/闭源/三方库API'] + '装饰器', 'kit', '文件路径', '子系统', '接口全路径', '开源/闭源API', '是否是三方库API'] workbook = openpyxl.Workbook() work_sheet1 = workbook.active work_sheet1.title = '对比结果' @@ -184,7 +183,7 @@ def write_information_to_worksheet(work_sheet, information_data): write_data = data[0], data[1], data[2], data[3], data[4], \ data[5], data[6], data[7], data[8], data[9], \ data[10], data[11], data[12], data[13], data[14], \ - data[15], data[16], data[17], data[18], data[19], data[20] + data[15], data[16], data[17], data[18], data[19], data[20], data[21] work_sheet.append(write_data) diff --git a/build-tools/capi_parser/src/coreImpl/parser/parse_include.py b/build-tools/capi_parser/src/coreImpl/parser/parse_include.py index a067d98afeea9306f53ebf43223e9c9579411467..841af8f8220d4df8713afd04c908953f8cfb8dc7 100644 --- a/build-tools/capi_parser/src/coreImpl/parser/parse_include.py +++ b/build-tools/capi_parser/src/coreImpl/parser/parse_include.py @@ -25,7 +25,7 @@ from clang.cindex import CursorKind from clang.cindex import TypeKind from utils.constants import StringConstant from utils.constants import RegularExpressions -from typedef.parser.parser import NodeKind +from typedef.parser.parser import NodeKind, DifferApiInfor, DifferApiRegular line_dist = {} @@ -149,13 +149,26 @@ def processing_def(cursor, data): # 处理宏定义 print('mar_define error, its content is none') if text: text = text.strip() # 删除两边的字符(默认是删除左右空格) - data['text'] = text - data["type"] = "def_no_type" + data['text'] = text + data["type"] = "" + + +def difference_api(api_data: dict): + api_name = api_data['name'] + closed_pattern = DifferApiRegular.CLOSED_SOURCE_API_REGULAR.value + open_pattern = DifferApiRegular.OPEN_SOURCE_API_REGULAR.value + if re.search(closed_pattern, api_name, flags=re.IGNORECASE): + api_data['open_close_api'] = DifferApiInfor.CLOSED_SOURCE_API.value + elif re.search(open_pattern, api_name, flags=re.IGNORECASE): + api_data['open_close_api'] = DifferApiInfor.OPEN_SOURCE_API.value + else: + api_data['is_third_party_api'] = True def processing_func(cursor, data): # 处理函数 data["return_type"] = cursor.result_type.spelling # 增加返回类型键值对 judgment_extern(cursor, data) + difference_api(data) def processing_type(cursor, data): # 没有类型的节点处理 @@ -197,6 +210,12 @@ special_node_process = { } +def process_members_class_name(data: dict, parent_cursor): + file_name = os.path.split(data['location']['location_path'])[1] + if (not data['name']) and (file_name not in parent_cursor.type.spelling): + data['class_name'] = '{}-{}'.format(file_name, parent_cursor.type.spelling) + + def get_api_unique_id(cursor, loc, data): unique_id = '' if cursor.kind == CursorKind.MACRO_DEFINITION: @@ -213,7 +232,7 @@ def get_api_unique_id(cursor, loc, data): parent_name_str = '' elif parent_of_cursor.kind.name in struct_union_enum: parent_name_str = parent_of_cursor.type.spelling - data['class_name'] = parent_of_cursor.spelling + process_members_class_name(data, parent_of_cursor) else: parent_name_str = parent_of_cursor.spelling except ValueError: @@ -227,6 +246,20 @@ def get_api_unique_id(cursor, loc, data): return unique_id +def get_node_class_name(data): + struct_union_enum = [NodeKind.STRUCT_DECL.value, NodeKind.UNION_DECL.value, + NodeKind.ENUM_DECL.value] + current_file_name = os.path.split(data["location"]["location_path"])[1] + if data.get('kind') in struct_union_enum and 'class_name' in data: + class_name = '{}-{}'.format(current_file_name, data["name"]) + if (not data["name"]) and (current_file_name not in data["type"]): + class_name = '{}-{}'.format(current_file_name, data["type"]) + else: + class_name = current_file_name + + return class_name + + def processing_special_node(cursor, data, key, gn_path): # 处理需要特殊处理的节点 if key == 0: location_path = cursor.spelling @@ -244,9 +277,12 @@ def processing_special_node(cursor, data, key, gn_path): # 处理需要特殊 relative_path = os.path.relpath(location_path, gn_path) # 获取头文件相对路 loc["location_path"] = relative_path data["location"] = loc + data["class_name"] = get_node_class_name(data) data["unique_id"] = get_api_unique_id(cursor, loc, data) if key == 0: data["unique_id"] = data["name"] + syntax_error_message = diagnostic_callback(cursor.translation_unit.diagnostics, gn_path) + data["syntax_error"] = syntax_error_message if kind_name in special_node_process.keys(): node_process = special_node_process[kind_name] node_process(cursor, data) # 调用对应节点处理函数 @@ -255,14 +291,20 @@ def processing_special_node(cursor, data, key, gn_path): # 处理需要特殊 def node_extent(cursor, current_file): start_offset = cursor.extent.start.offset end_offset = cursor.extent.end.offset + start_line = cursor.extent.start.line + end_line = cursor.extent.end.line with open(current_file, 'r', encoding='utf=8') as f: f.seek(start_offset) content = f.read(end_offset - start_offset) - + f.seek(0) + file_content_all = f.readlines() + line_content = file_content_all[start_line - 1: end_line] + line_content = ''.join(line_content) extent = { "start_offset": start_offset, "end_offset": end_offset, - "content": content + "content": content, + "line_content": line_content } f.close() return extent @@ -302,11 +344,36 @@ def get_default_node_data(cursor, gn_path): "form": 'NA', "atomic_service": 'NA', "decorator": 'NA', - "unique_id": '' + "unique_id": '', + "syntax_error": 'NA', + "open_close_api": 'NA', + "is_third_party_api": False } return data +def diagnostic_callback(diagnostic, dir_path): + # 获取诊断信息的详细内容 + syntax_error_message = 'NA' + key = 0 + for dig in diagnostic: + file_path = f"{dig.location.file}" + try: + file_path = os.path.relpath(os.path.normpath(file_path), dir_path) + except ValueError: + pass + line = dig.location.line + message = dig.spelling + # 输出诊断信息 + error_message = f"{file_path}:{line}\n错误信息:{message}" + if 0 == key: + syntax_error_message = error_message + key = 1 + else: + syntax_error_message = '{}\n{}'.format(syntax_error_message, error_message) + return syntax_error_message + + def parser_data_assignment(cursor, current_file, gn_path, comment=None, key=0): data = get_default_node_data(cursor, gn_path) get_comment(cursor, data) @@ -323,10 +390,6 @@ def parser_data_assignment(cursor, current_file, gn_path, comment=None, key=0): data["kind"] = cursor.kind.name if cursor.kind.name == CursorKind.MACRO_DEFINITION.name: define_comment(cursor, current_file, data) - struct_union_enum = [NodeKind.STRUCT_DECL.value, NodeKind.UNION_DECL.value, - NodeKind.ENUM_DECL.value] - if data.get('kind') in struct_union_enum and 'class_name' in data: - data['class_name'] = data.get('name') get_syscap_value(data) get_since_value(data) get_kit_value(data) @@ -564,6 +627,7 @@ def api_entrance(share_lib, include_path, gn_path, link_path): # 统计入口 # options赋值为如下,代表宏定义解析数据也要 args = ['-I{}'.format(path) for path in link_path] args.append('-std=c99') + args.append('--target=aarch64-linux-musl') options = clang.cindex.TranslationUnit.PARSE_DETAILED_PROCESSING_RECORD data_total = [] # 列表对象-用于统计 diff --git a/build-tools/capi_parser/src/coreImpl/parser/parser.py b/build-tools/capi_parser/src/coreImpl/parser/parser.py index 5ab20372e1dafd9f410fa0fbfd89c0bf1208ffb5..a0ecee8d2436e7df9fca2c75475c349947dd856f 100644 --- a/build-tools/capi_parser/src/coreImpl/parser/parser.py +++ b/build-tools/capi_parser/src/coreImpl/parser/parser.py @@ -267,10 +267,8 @@ def find_include(link_include_path): def copy_self_include(link_include_path, self_include_file): for dir_path, dir_name, file_name_list in os.walk(self_include_file): - for element in dir_name: - dir_path_name = os.path.abspath(os.path.join(dir_path, element)) - if 'sysroot_myself' not in dir_path and dir_path_name not in link_include_path: - link_include_path.append(dir_path_name) + if 'sysroot_myself' not in dir_path and 'build-tools' not in dir_path and dir_path not in link_include_path: + link_include_path.append(dir_path) def delete_typedef_child(child): @@ -294,19 +292,11 @@ def parser(directory_path): # 目录路径 return data_total -def parser_include_ast(dire_file_path, include_path: list, flag=-1): # 对于单独的.h解析接口 +def parser_include_ast(dire_file_path, include_path: list): # 对于单独的.h解析接口 correct_include_path = [] link_include_path = [dire_file_path] - # 针对check - if -1 == flag: - copy_std_lib(link_include_path, dire_file_path) - link_include(dire_file_path, StringConstant.FUNK_NAME.value, link_include_path) - # 针对diff - else: - copy_std_lib(link_include_path) - find_include(link_include_path) - if len(link_include_path) <= 2: - copy_self_include(link_include_path, dire_file_path) + copy_std_lib(link_include_path, dire_file_path) + copy_self_include(link_include_path, dire_file_path) for item in include_path: split_path = os.path.splitext(item) if split_path[1] == '.h': # 判断.h结尾 @@ -322,13 +312,25 @@ def parser_include_ast(dire_file_path, include_path: list, flag=-1): # return data +def diff_parser_include_ast(dire_file_path, include_path: list, flag=-1): # 对于单独的.h解析接口 + link_include_path = [dire_file_path] + copy_self_include(link_include_path, dire_file_path) + data = parse_include.get_include_file(include_path, link_include_path, dire_file_path) + + for item in data: + if 'children' in item: + for child in item['children']: + delete_typedef_child(child) + + return data + + def get_dir_file_path(dir_path): file_path_list = [] link_include_path = [] # 装链接头文件路径 for dir_path, dir_names, filenames in os.walk(dir_path): - for dir_name in dir_names: - if 'build-tools' not in dir_path and 'sysroot_myself' not in dir_path: - link_include_path.append(os.path.join(dir_path, dir_name)) + if 'sysroot_myself' not in dir_path and 'build-tools' not in dir_path and dir_path not in link_include_path: + link_include_path.append(dir_path) for file in filenames: if 'build-tools' not in dir_path and 'sysroot_myself' not in dir_path and file.endswith('.h'): file_path_list.append(os.path.join(dir_path, file)) @@ -406,7 +408,6 @@ def complete_kit_or_system(api_message: OneFileApiMessage, json_path): def parser_direct(path): # 目录路径 file_path_list = [] link_include_path = [] # 装链接头文件路径 - copy_std_lib(link_include_path) dir_path = '' if os.path.isdir(path): link_include_path.append(path) diff --git a/build-tools/capi_parser/src/typedef/check/check.py b/build-tools/capi_parser/src/typedef/check/check.py index 44f8e8248b534798c32f6ea02d5aa6ac9745042d..a77da9802f718ffb5c53b977d1c4ddf402039e3c 100644 --- a/build-tools/capi_parser/src/typedef/check/check.py +++ b/build-tools/capi_parser/src/typedef/check/check.py @@ -158,34 +158,34 @@ be reused please delete the extra tags.' class CheckErrorMessage(enum.Enum): - API_NAME_UNIVERSAL_01 = ('API check error of [naming errors]:The names of self-developed ' + API_NAME_UNIVERSAL_01 = ('API check error of [naming errors]:The [$$] of self-developed ' 'functions in APIs must start with OH_ or OS_ or HMS_ and comply ' 'with the large hump case format.') - API_NAME_UNIVERSAL_02 = ('API check error of [naming errors]:The names of constants in ' + API_NAME_UNIVERSAL_02 = ('API check error of [naming errors]:The [$$] of constants in ' 'APIs must be in uppercase and separated by underscores.') - API_NAME_UNIVERSAL_03 = ('API check error of [naming errors]:The naming of enumeration ' + API_NAME_UNIVERSAL_03 = ('API check error of [naming errors]:The [$$] of enumeration ' 'types should follow the big hump rule.') - API_NAME_UNIVERSAL_04 = ('API check error of [naming errors]:The naming of enumeration ' + API_NAME_UNIVERSAL_04 = ('API check error of [naming errors]:The [$$] of enumeration ' 'values should follow the all uppercase rule and separated by underscores.') - API_NAME_UNIVERSAL_05 = ('API check error of [naming errors]:The naming of struct should ' + API_NAME_UNIVERSAL_05 = ('API check error of [naming errors]:The [$$] of struct should ' 'follow the rules of the Great Hump.') - API_NAME_UNIVERSAL_06 = ('API check error of [naming errors]:The naming of members in the ' + API_NAME_UNIVERSAL_06 = ('API check error of [naming errors]:The [$$] of members in the ' 'structure should follow the small hump format.') - API_NAME_UNIVERSAL_07 = ('API check error of [naming errors]:The naming of the consortium ' - 'should follow the format of the large camel hump.') - API_NAME_UNIVERSAL_08 = ('API check error of [naming errors]:The naming of members in the ' + API_NAME_UNIVERSAL_07 = ('API check error of [naming errors]:The [$$] of the consortium ' + 'should follow the format of the Great hump.') + API_NAME_UNIVERSAL_08 = ('API check error of [naming errors]:The [$$] of members in the ' 'consortium should follow the small hump format.') - API_NAME_UNIVERSAL_09 = ('API check error of [naming errors]:The names of a global variable ' + API_NAME_UNIVERSAL_09 = ('API check error of [naming errors]:The [$$] of a global variable ' 'must be prefixed with g_ in the small camel case format.') - API_NAME_UNIVERSAL_10 = ('API check error of [naming errors]:The naming of general functions ' + API_NAME_UNIVERSAL_10 = ('API check error of [naming errors]:The [$$] of general functions ' 'should follow the big hump format.') - API_NAME_UNIVERSAL_11 = ('API check error of [naming errors]:Function parameter names should ' + API_NAME_UNIVERSAL_11 = ('API check error of [naming errors]:Function parameter [$$] should ' 'follow the small hump format.') - API_NAME_UNIVERSAL_12 = ('API check error of [naming errors]:Macro naming should follow all ' + API_NAME_UNIVERSAL_12 = ('API check error of [naming errors]:Macro [$$] should follow all ' 'uppercase format and separated by underscores.') - API_NAME_UNIVERSAL_13 = ('API check error of [naming errors]:Functional macro naming should ' + API_NAME_UNIVERSAL_13 = ('API check error of [naming errors]:Functional macro [$$] should ' 'follow all uppercase format and separated by underscores.') - API_NAME_UNIVERSAL_14 = ('API check error of [naming errors]:The file name should be all ' + API_NAME_UNIVERSAL_14 = ('API check error of [naming errors]:The [$$] file name should be all ' 'lowercase and separated by underscores.') API_DOC_GLOBAL_01 = ('API check error of [api doc errors]:The [file] tag is repeat. Please ' 'check the tag in file.') @@ -263,12 +263,16 @@ class CheckOutPut: main_buggy_code, main_buggy_line): self.analyzerName = 'apiengine' self.buggyFilePath = buggy_file_path + if code_context_start_line == -1: + code_context_start_line = 0 self.codeContextStartLine = code_context_start_line self.defectLevel = 2 self.defectType = defect_type self.description = description - self.language = 'c' + self.language = 'c++' self.mainBuggyCode = main_buggy_code + if main_buggy_line == -1: + main_buggy_line = 0 self.mainBuggyLine = main_buggy_line @@ -328,6 +332,7 @@ class OutputTxt: class ApiResultInfo: error_type: ErrorType = ErrorType.DEFAULT.value error_info = '' + error_content = '' level: ErrorLevel = -1 api_name = '' api_since = '' @@ -425,6 +430,12 @@ class ApiResultInfo: def set_location(self, location_param): self.location = location_param + def get_error_content(self): + return self.error_content + + def set_error_content(self, error_content): + self.error_content = error_content + class DocInfo: group = '' @@ -455,3 +466,9 @@ class FileDocInfo: file_since = False file_comment_str = '' curr_doc_info = DocInfo() + + +class CommentStartEndValue(enum.Enum): + DEFAULT_START = 0, + DEFAULT_END = 0 + diff --git a/build-tools/capi_parser/src/typedef/diff/diff.py b/build-tools/capi_parser/src/typedef/diff/diff.py index 897c320ba71011f093e2668d18c51f3106accf7e..d9a7b4b3db1052683c80f587685ad2b2070307ba 100644 --- a/build-tools/capi_parser/src/typedef/diff/diff.py +++ b/build-tools/capi_parser/src/typedef/diff/diff.py @@ -116,6 +116,7 @@ class Scene(enum.Enum): VAR_DECL = 'VAR_DECL' TYPEDEF_DECL = 'TYPEDEF_DECL' TRANSLATION_UNIT = 'TRANSLATION_UNIT' + ENUM_CONSTANT_DECL = 'ENUM_CONSTANT_DECL' class TAGS(enum.Enum): @@ -229,6 +230,7 @@ compatible_list = [ DiffType.ADD_API, DiffType.ADD_DOC, DiffType.ADD_DOC_TAG, + DiffType.ENUM_MEMBER_ADD, DiffType.FUNCTION_PARAM_NAME_CHANGE, DiffType.DOC_TAG_ADDTOGROUP_NA_TO_HAVE, DiffType.DOC_TAG_ADDTOGROUP_HAVE_TO_NA, @@ -386,6 +388,9 @@ class DiffInfo: operation_diff_type: str = '' old_differ_content: str = '' new_differ_content: str = '' + open_close_api: str = '' + is_third_party_api = False + current_api_type: str = '' def __init__(self, diff_type: DiffType, old_differ_content, new_differ_content): self.diff_type = diff_type @@ -540,6 +545,24 @@ class DiffInfo: def get_new_differ_content(self): return self.new_differ_content + def set_open_close_api(self, open_close_api): + self.open_close_api = open_close_api + + def get_open_close_api(self): + return self.open_close_api + + def set_is_third_party_api(self, is_third_party_api): + self.is_third_party_api = is_third_party_api + + def get_is_third_party_api(self): + return self.is_third_party_api + + def set_current_api_type(self, current_api_type): + self.current_api_type = current_api_type + + def get_current_api_type(self): + return self.current_api_type + class OutputJson: api_name: str = '' @@ -595,6 +618,10 @@ class ApiChangeData: compatible_total = False unique_id: str = '' is_system_api = False + open_close_api: str = '' + is_third_party_api = False + api_type: str = '' + current_api_type: str = '' def set_api_name(self, api_name): self.api_name = api_name @@ -679,3 +706,41 @@ class ApiChangeData: def get_is_system_api(self): return self.is_system_api + + def set_open_close_api(self, open_close_api): + self.open_close_api = open_close_api + + def get_open_close_api(self): + return self.open_close_api + + def set_is_third_party_api(self, is_third_party_api): + self.is_third_party_api = is_third_party_api + + def get_is_third_party_api(self): + return self.is_third_party_api + + def set_api_type(self, api_type): + self.api_type = api_type + + def get_api_type(self): + return self.api_type + + def set_current_api_type(self, current_api_type): + self.current_api_type = current_api_type + + def get_current_api_type(self): + return self.current_api_type + + +class IgnoreFileDirectory: + ignore_file_dict = { + 'arm-linux-ohos': '', + 'aarch64-linux-ohos': '', + 'x86_64-linux-ohos': '', + 'i686-linux-ohos': '', + 'tee': '', + 'linux': '' + } + + def get_ignore_file_dict(self): + return self.ignore_file_dict diff --git a/build-tools/capi_parser/src/utils/constants.py b/build-tools/capi_parser/src/utils/constants.py index 9c67d962b8669b9dda3a6868012349fb0d908c90..579737ce9a20acb19c77009a8558a2cc7aff7e5b 100644 --- a/build-tools/capi_parser/src/utils/constants.py +++ b/build-tools/capi_parser/src/utils/constants.py @@ -24,15 +24,15 @@ class StringConstant(enum.Enum): REPLACE_WAREHOUSE = '\\interface_sdk_c\\interface_sdk_c' # 拉到本地仓路径(去掉磁盘) # 拉到本地仓的三方库绝对路径 INCLUDE_LIB = r'.\third_party\musl\ndk_musl_include' - STD_INCLUDE = r'.\sysroot_myself\std_include_files' - CREATE_LIB_PATH = r'.\sysroot_myself\$is_headers_out_dir' - SELF_INCLUDE = r'.\sysroot_myself\self_include_files' - SELF_INCLUDE_OLD = r'.\sysroot_myself\self_include_files_old' - SELF_INCLUDE_NEW = r'.\sysroot_myself\self_include_files_new' - SYSROOT = r'.\sysroot_myself' + STD_INCLUDE = r'./sysroot_myself/std_include_files' + CREATE_LIB_PATH = r'./sysroot_myself/$is_headers_out_dir' + SELF_INCLUDE = r'./sysroot_myself/self_include_files' + SELF_INCLUDE_OLD = r'./sysroot_myself/self_include_files_old' + SELF_INCLUDE_NEW = r'./sysroot_myself/self_include_files_new' + SYSROOT = r'./sysroot_myself' RESULT_HEAD_NAME = "result_total.xlsx" PARSER_DIRECT_EXCEL_NAME = 'parser_direct_data.xlsx' - FILE_LEVEL_API_DATA = r'.\api_kit_c.json' + FILE_LEVEL_API_DATA = r'./api_kit_c.json' class RegularExpressions(enum.Enum): diff --git a/distributeddatamgr/relational_store/include/relational_store.h b/distributeddatamgr/relational_store/include/relational_store.h index 471e486498c2e19254dc14808b7a3727b72dd0fb..a48ed22eeaf4f8b58691728bf903192c21f7a27e 100644 --- a/distributeddatamgr/relational_store/include/relational_store.h +++ b/distributeddatamgr/relational_store/include/relational_store.h @@ -93,6 +93,13 @@ typedef enum Rdb_SecurityArea { * @brief Security Area 4. */ RDB_SECURITY_AREA_EL4, + + /** + * @brief Security Area 5. + * + * @since 12 + */ + RDB_SECURITY_AREA_EL5, } Rdb_SecurityArea; /** diff --git a/graphic/graphic_2d/native_vsync/libnative_vsync.ndk.json b/graphic/graphic_2d/native_vsync/libnative_vsync.ndk.json index b702a1d7a12bbc2fa3df403e0d1a21ee278e874d..196fab5242b37ac6412a7b28f14a277c3e549da6 100644 --- a/graphic/graphic_2d/native_vsync/libnative_vsync.ndk.json +++ b/graphic/graphic_2d/native_vsync/libnative_vsync.ndk.json @@ -2,5 +2,6 @@ { "name": "OH_NativeVSync_Create" }, { "name": "OH_NativeVSync_Destroy" }, { "name": "OH_NativeVSync_RequestFrame" }, + { "name": "OH_NativeVSync_RequestFrameWithMultiCallback" }, { "name": "OH_NativeVSync_GetPeriod" } ] \ No newline at end of file diff --git a/graphic/graphic_2d/native_vsync/native_vsync.h b/graphic/graphic_2d/native_vsync/native_vsync.h index 069d17689616c2a336e82da0ae3bb8c27af778c0..85627485c895b2d38cc06214efaf57a8fba60bda 100644 --- a/graphic/graphic_2d/native_vsync/native_vsync.h +++ b/graphic/graphic_2d/native_vsync/native_vsync.h @@ -65,7 +65,6 @@ OH_NativeVSync* OH_NativeVSync_Create(const char* name, unsigned int length); * * @syscap SystemCapability.Graphic.Graphic2D.NativeVsync * @param window Indicates the pointer to a NativeVsync instance. - * @return Returns int32_t, return value == 0, success, otherwise, failed. * @since 9 * @version 1.0 */ @@ -73,17 +72,37 @@ void OH_NativeVSync_Destroy(OH_NativeVSync* nativeVsync); /** * @brief Request next vsync with callback. + * If you call this interface multiple times in one frame, it will only call the last callback. * * @syscap SystemCapability.Graphic.Graphic2D.NativeVsync * @param nativeVsync Indicates the pointer to a NativeVsync. * @param callback Indicates the OH_NativeVSync_FrameCallback which will be called when next vsync coming. * @param data Indicates data whick will be used in callback. - * @return Returns int32_t, return value == 0, success, otherwise, failed. + * @return {@link NATIVE_ERROR_OK} 0 - Success. + * {@link NATIVE_ERROR_INVALID_ARGUMENTS} 40001000 - the parameter nativeVsync is NULL or callback is NULL. + * {@link NATIVE_ERROR_BINDER_ERROR} 50401000 - ipc send failed. * @since 9 * @version 1.0 */ int OH_NativeVSync_RequestFrame(OH_NativeVSync* nativeVsync, OH_NativeVSync_FrameCallback callback, void* data); +/** + * @brief Request next vsync with callback. + * If this function is called multiple times in one vsync period, all these callbacks and dataset will be called. + * + * @syscap SystemCapability.Graphic.Graphic2D.NativeVsync + * @param nativeVsync Indicates the pointer to a NativeVsync. + * @param callback Indicates the OH_NativeVSync_FrameCallback which will be called when next vsync coming. + * @param data Indicates data whick will be used in callback. + * @return {@link NATIVE_ERROR_OK} 0 - Success. + * {@link NATIVE_ERROR_INVALID_ARGUMENTS} 40001000 - the parameter nativeVsync is NULL or callback is NULL. + * {@link NATIVE_ERROR_BINDER_ERROR} 50401000 - ipc send failed. + * @since 12 + * @version 1.0 + */ +int OH_NativeVSync_RequestFrameWithMultiCallback( + OH_NativeVSync* nativeVsync, OH_NativeVSync_FrameCallback callback, void* data); + /** * @brief Get vsync period. * diff --git a/graphic/graphic_2d/native_window/graphic_error_code.h b/graphic/graphic_2d/native_window/graphic_error_code.h index cba61e5e8dbac4efa1b5f7f21a279592ed4be15c..8a24196811340761fbf7d29b8287b435d0a52f3b 100644 --- a/graphic/graphic_2d/native_window/graphic_error_code.h +++ b/graphic/graphic_2d/native_window/graphic_error_code.h @@ -80,6 +80,8 @@ typedef enum OHNativeErrorCode { NATIVE_ERROR_UNSUPPORTED = 50102000, /** @error unknown error, please check log */ NATIVE_ERROR_UNKNOWN = 50002000, + /** @error ipc send failed */ + NATIVE_ERROR_BINDER_ERROR = 50401000, /** @error the egl environment is abnormal */ NATIVE_ERROR_EGL_STATE_UNKNOWN = 60001000, /** @error egl interface invocation failed */ diff --git a/hiviewdfx/hitrace/include/hitrace/trace.h b/hiviewdfx/hitrace/include/hitrace/trace.h index 9142b26376133fecfc0b1a3823269a43fab6d8cc..fd6733c01c9abfc536b6937648478555eb556e3b 100644 --- a/hiviewdfx/hitrace/include/hitrace/trace.h +++ b/hiviewdfx/hitrace/include/hitrace/trace.h @@ -65,6 +65,7 @@ * @since 10 */ #include +#include #ifdef __cplusplus extern "C" { @@ -300,6 +301,7 @@ typedef enum HiTrace_Communication_Mode { * @since 12 */ typedef struct HiTraceId { +#ifdef __BYTE_ORDER #if __BYTE_ORDER == __LITTLE_ENDIAN /** Whether the HiTraceId instance is valid. */ uint64_t valid : 1; @@ -329,6 +331,7 @@ typedef struct HiTraceId { #else #error "ERROR: No BIG_LITTLE_ENDIAN defines." #endif +#endif } HiTraceId; /** diff --git a/multimedia/av_codec/native_avcodec_audiocodec.h b/multimedia/av_codec/native_avcodec_audiocodec.h index 4c683158024c649dc21404fbbd054aacf9a7ccd7..8ae03c4bb792d71f2707e9a3615c86b4a6dd3691 100644 --- a/multimedia/av_codec/native_avcodec_audiocodec.h +++ b/multimedia/av_codec/native_avcodec_audiocodec.h @@ -279,6 +279,7 @@ OH_AVErrCode OH_AudioCodec_IsValid(OH_AVCodec *codec, bool *isValid); * {@link AV_ERR_INVALID_VAL} 3 - If the codec instance is nullptr or invalid, * the mediaKeySession is nullptr or invalid. * {@link AV_ERR_INVALID_STATE} 8 - If the codec service is invalid. + * {@link AV_ERR_NO_MEMORY}, failed to request memory. * @since 12 * @version 1.0 */ diff --git a/multimedia/av_codec/native_avcodec_base.h b/multimedia/av_codec/native_avcodec_base.h index c5e35031cfa4005ba8484a54ad2014aec1e8fb86..cdaeeed5529c5e8ba9e60ece0735468ee59ed099 100644 --- a/multimedia/av_codec/native_avcodec_base.h +++ b/multimedia/av_codec/native_avcodec_base.h @@ -1198,6 +1198,9 @@ typedef enum OH_TemporalGopReferenceMode { ADJACENT_REFERENCE = 0, /** Refer to latest long-term reference frame. */ JUMP_REFERENCE = 1, + /** Uniformly scaled reference structure, which has even distribution of video frames after drop the highest + * enhance layer. The temporal group of pictures must be power of 2. */ + UNIFORMLY_SCALED_REFERENCE = 2, } OH_TemporalGopReferenceMode; #ifdef __cplusplus diff --git a/multimedia/av_codec/native_avcodec_videodecoder.h b/multimedia/av_codec/native_avcodec_videodecoder.h index c52df2c28f136c9543db3e4985336834473d8eb6..012329d4f1297d7a8f46cf8a65f2b4f413c95b6e 100644 --- a/multimedia/av_codec/native_avcodec_videodecoder.h +++ b/multimedia/av_codec/native_avcodec_videodecoder.h @@ -343,6 +343,8 @@ OH_AVErrCode OH_VideoDecoder_FreeOutputData(OH_AVCodec *codec, uint32_t index); * {@link AV_ERR_UNKNOWN}, unknown error. * {@link AV_ERR_SERVICE_DIED}, avcodec service is died. * {@link AV_ERR_INVALID_STATE}, this interface was called in invalid state. + * {@link AV_ERR_DRM_DECRYPT_FAILED}, the drm-protected video buffer is decrypted failed, + * it is recommended to check the logs. * @since 11 */ OH_AVErrCode OH_VideoDecoder_PushInputBuffer(OH_AVCodec *codec, uint32_t index); @@ -442,6 +444,7 @@ OH_AVErrCode OH_VideoDecoder_IsValid(OH_AVCodec *codec, bool *isValid); * @return {@link AV_ERR_OK} 0 - Success * {@link AV_ERR_OPERATE_NOT_PERMIT} 2 - If the codec service or the media key session * service is in wrong status. + * {@link AV_ERR_NO_MEMORY}, instance has already released or no memory. * {@link AV_ERR_INVALID_VAL} 3 - If the codec instance is nullptr or invalid, * the mediaKeySession is nullptr or invalid. * @since 11 diff --git a/multimedia/av_codec/native_avdemuxer.h b/multimedia/av_codec/native_avdemuxer.h index 7b2117ebceeeb3cf9ebab50c1a54fb4db73d18d3..4913528156683067fd92bbbbfa0a0bd1d6574b73 100644 --- a/multimedia/av_codec/native_avdemuxer.h +++ b/multimedia/av_codec/native_avdemuxer.h @@ -47,6 +47,12 @@ typedef struct OH_AVDemuxer OH_AVDemuxer; * @since 11 */ typedef struct DRM_MediaKeySystemInfo DRM_MediaKeySystemInfo; + +/** +* @brief Callback for getting media key system information from media source. +* @since 11 +* @version 1.0 +*/ typedef void (*DRM_MediaKeySystemInfoCallback)(DRM_MediaKeySystemInfo* mediaKeySystemInfo); /** @@ -210,6 +216,7 @@ OH_AVErrCode OH_AVDemuxer_SetDemuxerMediaKeySystemInfoCallback(OH_AVDemuxer *dem * @param mediaKeySystemInfo Indicates the media key system info which ram space allocated by callee and * released by caller. * @return {@link AV_ERR_OK} 0 - Success + * {@link AV_ERR_OPERATE_NOT_PERMIT} 2 - If the demuxer engine is not inited or init failed. * {@link AV_ERR_INVALID_VAL} 3 - If the demuxer instance is nullptr or invalid * or the mediaKeySystemInfo is nullptr. * @since 11 diff --git a/multimedia/drm_framework/common/native_drm_common.h b/multimedia/drm_framework/common/native_drm_common.h index 386f3162eb67f5fa563b7a2c4d5bb66eb2366f43..410a27f20e5a94d19d63d75dd861916d50f2b9bc 100644 --- a/multimedia/drm_framework/common/native_drm_common.h +++ b/multimedia/drm_framework/common/native_drm_common.h @@ -486,6 +486,11 @@ typedef struct DRM_MediaKeySystemInfo { DRM_PsshInfo psshInfo[MAX_PSSH_INFO_COUNT]; } DRM_MediaKeySystemInfo; +/** +* @brief Callback for getting media key system information from media source. +* @since 11 +* @version 1.0 +*/ typedef void (*DRM_MediaKeySystemInfoCallback)(DRM_MediaKeySystemInfo *mediaKeySystemInfo); /** diff --git a/multimedia/drm_framework/libnative_drm.ndk.json b/multimedia/drm_framework/libnative_drm.ndk.json index 0e453e4d5b3fbae7c6a4ecacf67c026dfcd97746..7e0949b810692dc6176a491497d44613a723de68 100644 --- a/multimedia/drm_framework/libnative_drm.ndk.json +++ b/multimedia/drm_framework/libnative_drm.ndk.json @@ -115,13 +115,17 @@ "first_introduced": "11", "name": "OH_MediaKeySession_Destroy" }, + { + "first_introduced": "11", + "name": "OH_MediaKeySession_SetMediaKeySessionCallback" + }, { "first_introduced": "12", "name": "OH_MediaKeySystem_GetMediaKeySystems" }, { "first_introduced": "12", - "name": "OH_MediaKeySession_SetMediaKeySessionCallback" + "name": "OH_MediaKeySession_SetCallback" }, { "first_introduced": "12", diff --git a/multimedia/drm_framework/native_mediakeysystem.h b/multimedia/drm_framework/native_mediakeysystem.h index 2a818346bb2e251fbfaabe5afc2ce9385c2906d3..966948a6459bf197d2a47e41e1c4f4a030ea7c75 100644 --- a/multimedia/drm_framework/native_mediakeysystem.h +++ b/multimedia/drm_framework/native_mediakeysystem.h @@ -135,8 +135,6 @@ bool OH_MediaKeySystem_IsSupported3(const char *name, const char *mimeType, * @brief Creates a media key system instance from the name. * @param name Secifies which drm system will be created by name. * @param mediaKeySystem Media key system instance. - * @return DRM_ERR_INVALID_VAL when the params checked failure, return DRM_ERR_OK when function called successfully, - * return DRM_ERR_MAX_SYSTEM_NUM_REACHED when max num media key system reached. * @return {@link DRM_ERR_OK} 0 - Success.  *         {@link DRM_ERR_INVALID_VAL} 24700503 - Probably caused by: * 1. the name is nullptr or the length of name is zero. @@ -155,6 +153,7 @@ Drm_ErrCode OH_MediaKeySystem_Create(const char *name, MediaKeySystem **mediaKey * @param value Configuration vaule string to be set. * @return {@link DRM_ERR_OK} 0 - Success.  *         {@link DRM_ERR_INVALID_VAL} 24700503 - The parameter passed in is a null pointer or invalid. + *         {@link DRM_ERR_UNKNOWN} 24700506 - Internal error occurred, it is recommended to check the logs. * @since 11 * @version 1.0 */ @@ -358,7 +357,6 @@ Drm_ErrCode OH_MediaKeySystem_GetCertificateStatus(MediaKeySystem *mediaKeySyste */ Drm_ErrCode OH_MediaKeySystem_Destroy(MediaKeySystem *mediaKeySystem); - #ifdef __cplusplus } #endif diff --git a/multimedia/image_effect/image_effect.h b/multimedia/image_effect/image_effect.h index 921d8a5b04daf0fe9269f0c0fca3cb201c0bb1f3..b1bb66de63423676604cee10543115654bc4ac69 100644 --- a/multimedia/image_effect/image_effect.h +++ b/multimedia/image_effect/image_effect.h @@ -40,6 +40,7 @@ #include "image_effect_filter.h" #include "native_buffer/native_buffer.h" #include "native_window/external_window.h" +#include "multimedia/image_framework/image/picture_native.h" #ifdef __cplusplus extern "C" { @@ -315,6 +316,33 @@ ImageEffect_ErrorCode OH_ImageEffect_SetInputUri(OH_ImageEffect *imageEffect, co */ ImageEffect_ErrorCode OH_ImageEffect_SetOutputUri(OH_ImageEffect *imageEffect, const char *uri); +/** + * @brief Set input picture that contains the image information. It should be noted that the input picture will be + * directly rendered and modified if the output is not set + * + * @syscap SystemCapability.Multimedia.ImageEffect.Core + * @param imageEffect Encapsulate OH_ImageEffect structure instance pointer + * @param picture Indicates the OH_PictureNative that contains the image information + * @return Returns EFFECT_SUCCESS if the execution is successful, otherwise returns a specific error code, refer to + * {@link ImageEffect_ErrorCode} + * {@link EFFECT_ERROR_PARAM_INVALID}, the input parameter is a null pointer. + * @since 12 + */ +ImageEffect_ErrorCode OH_ImageEffect_SetInputPicture(OH_ImageEffect *imageEffect, OH_PictureNative *picture); + +/** + * @brief Set output picture that contains the image information + * + * @syscap SystemCapability.Multimedia.ImageEffect.Core + * @param imageEffect Encapsulate OH_ImageEffect structure instance pointer + * @param picture Indicates the OH_PictureNative that contains the image information + * @return Returns EFFECT_SUCCESS if the execution is successful, otherwise returns a specific error code, refer to + * {@link ImageEffect_ErrorCode} + * {@link EFFECT_ERROR_PARAM_INVALID}, the input parameter is a null pointer. + * @since 12 + */ +ImageEffect_ErrorCode OH_ImageEffect_SetOutputPicture(OH_ImageEffect *imageEffect, OH_PictureNative *picture); + /** * @brief Render the filter effects that can be a single filter or a chain of filters * diff --git a/multimedia/image_effect/libimage_effect.ndk.json b/multimedia/image_effect/libimage_effect.ndk.json index 6b3c6abab74f8bc6e547aa7cd5837886a620affa..99226c04afd184f8bcfee595fd4836c084f0f53f 100644 --- a/multimedia/image_effect/libimage_effect.ndk.json +++ b/multimedia/image_effect/libimage_effect.ndk.json @@ -203,6 +203,14 @@ "first_introduced": "12", "name": "OH_ImageEffect_SetOutputUri" }, + { + "first_introduced": "12", + "name": "OH_ImageEffect_SetInputPicture" + }, + { + "first_introduced": "12", + "name": "OH_ImageEffect_SetOutputPicture" + }, { "first_introduced": "12", "name": "OH_ImageEffect_Start" diff --git a/multimedia/image_framework/BUILD.gn b/multimedia/image_framework/BUILD.gn index be2610e9773a09e7004b3e20972f49de5bd5f1f1..9b5e9895a0fb0a20addad953e0ad6bd519c57244 100644 --- a/multimedia/image_framework/BUILD.gn +++ b/multimedia/image_framework/BUILD.gn @@ -44,6 +44,38 @@ ohos_ndk_headers("libpixelmap_header") { sources = [ "./include/image/pixelmap_native.h" ] } +ohos_ndk_library("libpicture") { + ndk_description_file = "./libpicture.ndk.json" + output_name = "picture" + output_extension = "so" + min_compact_version = "12" + system_capability = "SystemCapability.Multimedia.Image.Core" + system_capability_headers = [ + "multimedia/image_framework/image/picture_native.h", + "multimedia/image_framework/image/image_common.h", + ] +} + +ohos_ndk_headers("libpicture_header") { + dest_dir = "$ndk_headers_out_dir/multimedia/image_framework/image" + sources = [ "./include/image/picture_native.h" ] +} + +ohos_ndk_library("libimage_common") { + ndk_description_file = "./libimage_common.ndk.json" + output_name = "image_common" + output_extension = "so" + min_compact_version = "12" + system_capability = "SystemCapability.Multimedia.Image.Core" + system_capability_headers = + [ "multimedia/image_framework/image/image_common.h" ] +} + +ohos_ndk_headers("libimage_common_header") { + dest_dir = "$ndk_headers_out_dir/multimedia/image_framework/image" + sources = [ "./include/image/image_common.h" ] +} + ohos_ndk_library("libimage_ndk") { ndk_description_file = "./libimage_ndk.ndk.json" min_compact_version = "1" @@ -119,10 +151,7 @@ ohos_ndk_library("libohimage") { ohos_ndk_headers("ohimage_header") { dest_dir = "$ndk_headers_out_dir/multimedia/image_framework/image" - sources = [ - "./include/image/image_common.h", - "./include/image/image_native.h", - ] + sources = [ "./include/image/image_native.h" ] } ohos_ndk_library("libimage_receiver") { diff --git a/multimedia/image_framework/include/image/image_common.h b/multimedia/image_framework/include/image/image_common.h index 6e50d776490653fff25f6c27627d47c82d32b817..f44cf9b9ab9d47d8dbcf585587468668bbfbc0e3 100644 --- a/multimedia/image_framework/include/image/image_common.h +++ b/multimedia/image_framework/include/image/image_common.h @@ -95,6 +95,20 @@ struct Image_String { size_t size = 0; }; +/** + * @brief Define a PictureMetadata struct type, used for picture metadata. + * + * @since 12 + */ +struct OH_PictureMetadata; + +/** + * @brief Define a PictureMetadata struct type, used for picture metadata. + * + * @since 12 + */ +typedef struct OH_PictureMetadata OH_PictureMetadata; + /** * @brief Defines the property string (in key-value format) of the image source. * @@ -147,6 +161,89 @@ typedef enum { IMAGE_ENCODE_FAILED = 7800301, } Image_ErrorCode; +/** + * @brief Define the metadata type. + * + * @since 12 + */ +typedef enum { + /* + * EXIF metadata. + */ + EXIF_METADATA = 1, + /* + * Fragment metadata. + */ + FRAGMENT_METADATA = 2, +} Image_MetadataType; + +/** + * @brief Creates a PictureMetadata object. + * + * @param metadataType The type of metadata. + * @param metadata The PictureMetadata pointer will be operated. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} metadata is nullptr. + * @since 12 + */ +Image_ErrorCode OH_PictureMetadata_Create(Image_MetadataType metadataType, OH_PictureMetadata **metadata); + +/** + * @brief Obtains the property of picture metadata. + * + * @param metadata The PictureMetadata pointer will be operated. + * @param key The property's key. + * @param value The property's value. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} metadata is nullptr, or key is nullptr, or value is nullptr. + * {@link IMAGE_UNSUPPORTED_METADATA} unsupported metadata type, or the metadata type does not match the + * auxiliary picture type. + * @since 12 + */ +Image_ErrorCode OH_PictureMetadata_GetProperty(OH_PictureMetadata *metadata, Image_String *key, Image_String *value); + +/** + * @brief Set picture metadata property. + * + * @param metadata The PictureMetadata pointer will be operated. + * @param key The property's key. + * @param value The property's value. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} metadata is nullptr, or key is nullptr, or value is nullptr. + * {@link IMAGE_UNSUPPORTED_METADATA} unsupported metadata type, or the metadata type does not match the + * auxiliary picture type. + * @since 12 + */ +Image_ErrorCode OH_PictureMetadata_SetProperty(OH_PictureMetadata *metadata, Image_String *key, Image_String *value); + +/** + * @brief Releases this PictureMetadata object. + * + * @param metadata The PictureMetadata pointer will be operated. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} metadata is nullptr. + * @since 12 + */ +Image_ErrorCode OH_PictureMetadata_Release(OH_PictureMetadata *metadata); + +/** + * @brief Obtains a clone of metadata. + * + * @param oldMetadata The PictureMetadata pointer will be operated. + * @param newMetadata The PictureMetadata pointer will be cloned. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} metadata is nullptr. + * {@link IMAGE_ALLOC_FAILED} memory alloc failed. + * {@link IMAGE_COPY_FAILED} memory copy failed. + * @since 12 + */ +Image_ErrorCode OH_PictureMetadata_Clone(OH_PictureMetadata *oldMetadata, OH_PictureMetadata **newMetadata); + /** * @brief Defines the bmp mime type. * @@ -1333,6 +1430,42 @@ static const char *OHOS_IMAGE_PROPERTY_WIND_SNAPSHOT_MODE = "HwMnoteWindSnapshot * @since 12 */ static const char *OHOS_IMAGE_PROPERTY_GIF_LOOP_COUNT = "GIFLoopCount"; + +/** + * @brief X in original + * It is used in {@link OH_ImageSource_GetImageProperty}. + * The top left corner of the fragment image is at the X-coordinate of the original image + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_X_IN_ORIGINAL = "XInOriginal"; + +/** + * @brief Y in original + * It is used in {@link OH_ImageSource_GetImageProperty}. + * The top left corner of the fragment image is at the Y-coordinate of the original image + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_Y_IN_ORIGINAL = "YInOriginal"; + +/** + * @brief Fragment map width + * It is used in {@link OH_ImageSource_GetImageProperty}. + * The width of the fragment image + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_FRAGMENT_WIDTH = "FragmentImageWidth"; + +/** + * @brief Fragment map height + * It is used in {@link OH_ImageSource_GetImageProperty}. + * The height of the fragment image + * + * @since 12 + */ +static const char *OHOS_IMAGE_PROPERTY_FRAGMENT_HEIGHT = "FragmentImageHeight"; #ifdef __cplusplus }; #endif diff --git a/multimedia/image_framework/include/image/image_packer_native.h b/multimedia/image_framework/include/image/image_packer_native.h index 6a5a4e9b54b4a05661efc659a3cf847dbc9358cd..ef2081b02397b812d948b9f09b2b29d202c70ca2 100644 --- a/multimedia/image_framework/include/image/image_packer_native.h +++ b/multimedia/image_framework/include/image/image_packer_native.h @@ -59,6 +59,20 @@ typedef struct OH_ImagePackerNative OH_ImagePackerNative; struct OH_PackingOptions; typedef struct OH_PackingOptions OH_PackingOptions; +/** + * @brief Defines the image sequence packing options. + * + * @since 12 + */ +struct OH_PackingOptionsForSequence; + +/** + * @brief Defines the image sequence packing options. + * + * @since 12 + */ +typedef struct OH_PackingOptionsForSequence OH_PackingOptionsForSequence; + /** * @brief Enumerates packing dynamic range. * @@ -182,6 +196,134 @@ Image_ErrorCode OH_PackingOptions_SetDesiredDynamicRange(OH_PackingOptions *opti */ Image_ErrorCode OH_PackingOptions_Release(OH_PackingOptions *options); +/** + * @brief Create a pointer for OH_PackingOptionsForSequence struct. + * + * @param options The OH_PackingOptionsForSequence pointer will be operated. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} options is nullptr. + * @since 12 + */ +Image_ErrorCode OH_PackingOptionsForSequence_Create(OH_PackingOptionsForSequence **options); + +/** + * @brief Set FrameCount number for OH_PackingOptionsForSequence struct. + * + * @param options The OH_PackingOptionsForSequence pointer will be operated. + * @param frameCount The number of image frameCount. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} options is nullptr. + * @since 12 + */ +Image_ErrorCode OH_PackingOptionsForSequence_SetFrameCount(OH_PackingOptionsForSequence *options, + uint32_t frameCount); + +/** + * @brief Get FrameCount number for OH_PackingOptionsForSequence struct. + * + * @param options The OH_PackingOptionsForSequence pointer will be operated. + * @param frameCount The number of image frameCount. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} options or frameCount is nullptr. + * @since 12 + */ +Image_ErrorCode OH_PackingOptionsForSequence_GetFrameCount(OH_PackingOptionsForSequence *options, + uint32_t *frameCount); + +/** + * @brief Set DelayTimeList number for OH_PackingOptionsForSequence struct. + * + * @param options The OH_PackingOptionsForSequence pointer will be operated. + * @param delayTimeList The pointer of image delayTime list. + * @param delayTimeListLength The number of image delayTimeListLength. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} options or delayTimeList is nullptr. + * @since 12 + */ +Image_ErrorCode OH_PackingOptionsForSequence_SetDelayTimeList(OH_PackingOptionsForSequence *options, + int32_t *delayTimeList, size_t delayTimeListLength); + +/** + * @brief Get DelayTimeList number for OH_PackingOptionsForSequence struct. + * + * @param options The OH_PackingOptionsForSequence pointer will be operated. + * @param delayTimeList The pointer of image delayTime list. + * @param delayTimeListLength The number of image delayTimeListLength. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} options or delayTimeList is nullptr. + * @since 12 + */ +Image_ErrorCode OH_PackingOptionsForSequence_GetDelayTimeList(OH_PackingOptionsForSequence *options, + int32_t *delayTimeList, size_t delayTimeListLength); + +/** + * @brief Set DisposalTypes number for OH_PackingOptionsForSequence struct. + * + * @param options The OH_PackingOptionsForSequence pointer will be operated. + * @param disposalTypes The pointer of image disposalTypes. + * @param disposalTypesLength The number of image disposalTypesLength. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} options or disposalTypes is nullptr. + * @since 12 + */ +Image_ErrorCode OH_PackingOptionsForSequence_SetDisposalTypes(OH_PackingOptionsForSequence *options, + uint32_t *disposalTypes, size_t disposalTypesLength); + +/** + * @brief Get DisposalTypes number for OH_PackingOptionsForSequence struct. + * + * @param options The OH_PackingOptionsForSequence pointer will be operated. + * @param disposalTypes The pointer of image disposalTypes. + * @param disposalTypesLength The number of image disposalTypesLength. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} options or disposalTypes is nullptr. + * @since 12 + */ +Image_ErrorCode OH_PackingOptionsForSequence_GetDisposalTypes(OH_PackingOptionsForSequence *options, + uint32_t *disposalTypes, size_t disposalTypesLength); + +/** + * @brief Set LoopCount number for OH_PackingOptionsForSequence struct. + * + * @param options The OH_PackingOptionsForSequence pointer will be operated. + * @param loopCount The number of image loopCount. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} options is nullptr. + * @since 12 + */ +Image_ErrorCode OH_PackingOptionsForSequence_SetLoopCount(OH_PackingOptionsForSequence *options, uint32_t loopCount); + +/** + * @brief Get LoopCount number for OH_PackingOptionsForSequence struct. + * + * @param options The OH_PackingOptionsForSequence pointer will be operated. + * @param loopCount The number of image loopCount. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} options or loopCount is nullptr. + * @since 12 + */ +Image_ErrorCode OH_PackingOptionsForSequence_GetLoopCount(OH_PackingOptionsForSequence *options, uint32_t *loopCount); + +/** + * @brief delete OH_PackingOptionsForSequence pointer. + * + * @param options The OH_PackingOptionsForSequence pointer will be operated. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} options is nullptr. + * @since 12 + */ +Image_ErrorCode OH_PackingOptionsForSequence_Release(OH_PackingOptionsForSequence *options); + /** * @brief Create a pointer for OH_ImagePackerNative struct. * @@ -219,6 +361,43 @@ Image_ErrorCode OH_ImagePackerNative_PackToDataFromImageSource(OH_ImagePackerNat Image_ErrorCode OH_ImagePackerNative_PackToDataFromPixelmap(OH_ImagePackerNative *imagePacker, OH_PackingOptions *options, OH_PixelmapNative *pixelmap, uint8_t *outData, size_t *size); +/** + * @brief Encoding a Picture into the data with required format. + * + * @param imagePacker The imagePacker to use for packing. + * @param options Indicates the encoding {@link OH_PackingOptions}. + * @param picture The picture to be packed. + * @param outData The output data buffer to store the packed image. + * @param size A pointer to the size of the output data buffer. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} imagePacker is nullptr, or picture is nullptr, or outData is nullptr, + * or size is invalid. + * {@link IMAGE_ENCODE_FAILED} encode failed. + * @since 12 + */ +Image_ErrorCode OH_ImagePackerNative_PackToDataFromPicture(OH_ImagePackerNative *imagePacker, + OH_PackingOptions *options, OH_PictureNative *picture, uint8_t *outData, size_t *size); + +/** + * @brief Encoding a PixelMap sequence into the data + * + * @param imagePacker The imagePacker to use for packing. + * @param options Indicates the encoding {@link OH_PackingOptionsForSequence}. + * @param pixelmapSequence The pixelmap sequence to be packed. + * @param sequenceLength The pixelmap sequence size to be packed. + * @param outData The output data buffer to store the packed image. + * @param outDataSize A pointer to the size of the output data buffer. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} one of the pointer type parameters is nullptr, or size/length is invalid + * {@link IMAGE_ENCODE_FAILED} encode failed. + * @since 12 + */ +Image_ErrorCode OH_ImagePackerNative_PackToDataFromPixelmapSequence(OH_ImagePackerNative *imagePacker, + OH_PackingOptionsForSequence *options, OH_PixelmapNative **pixelmapSequence, + size_t sequenceLength, uint8_t *outData, size_t *outDataSize); + /** * @brief Encoding an ImageSource into the a file with fd with required format. * @@ -245,6 +424,39 @@ Image_ErrorCode OH_ImagePackerNative_PackToFileFromImageSource(OH_ImagePackerNat Image_ErrorCode OH_ImagePackerNative_PackToFileFromPixelmap(OH_ImagePackerNative *imagePacker, OH_PackingOptions *options, OH_PixelmapNative *pixelmap, int32_t fd); +/** + * @brief Encoding a Picture into the a file with fd with required format. + * + * @param imagePacker The imagePacker to use for packing. + * @param options Indicates the encoding {@link OH_PackingOptions}. + * @param picture The picture to be packed. + * @param fd Indicates a writable file descriptor. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} imagePacker is nullptr, or picture is nullptr, or fd is invalid. + * {@link IMAGE_ENCODE_FAILED} encode failed. + * @since 12 + */ +Image_ErrorCode OH_ImagePackerNative_PackToFileFromPicture(OH_ImagePackerNative *imagePacker, + OH_PackingOptions *options, OH_PictureNative *picture, int32_t fd); + +/** + * @brief Encoding a PixelMap sequence into the a file with fd + * + * @param imagePacker The image packer to use for packing. + * @param options Indicates the encoding {@link OH_PackingOptionsForSequence}. + * @param pixelmapSequence The pixelmap sequence to be packed. + * @param sequenceLength The pixelmap sequence size to be packed. + * @param fd Indicates a writable file descriptor. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} one of the pointer type parameters is nullptr, or length is invalid + * {@link IMAGE_ENCODE_FAILED} encode failed. + * @since 12 + */ +Image_ErrorCode OH_ImagePackerNative_PackToFileFromPixelmapSequence(OH_ImagePackerNative *imagePacker, + OH_PackingOptionsForSequence *options, OH_PixelmapNative **pixelmapSequence, size_t sequenceLength, int32_t fd); + /** * @brief Releases an imagePacker object. * diff --git a/multimedia/image_framework/include/image/image_source_native.h b/multimedia/image_framework/include/image/image_source_native.h index 72cf4dae2dbda1887ee062ad4a346024551eb7bf..803fe4928ceb68756c73c1bfcf7a5d65d4800e1f 100644 --- a/multimedia/image_framework/include/image/image_source_native.h +++ b/multimedia/image_framework/include/image/image_source_native.h @@ -38,6 +38,7 @@ #include "image_common.h" #include "pixelmap_native.h" +#include "picture_native.h" #include "rawfile/raw_file.h" #ifdef __cplusplus @@ -61,6 +62,22 @@ typedef struct OH_ImageSourceNative OH_ImageSourceNative; struct OH_ImageSource_Info; typedef struct OH_ImageSource_Info OH_ImageSource_Info; +/** + * @brief Defines decoding options for picture + * {@link OH_DecodingOptionsForPicture_Create}. + * + * @since 12 + */ +struct OH_DecodingOptionsForPicture; + +/** + * @brief Defines decoding options for picture + * {@link OH_DecodingOptionsForPicture_Create}. + * + * @since 12 + */ +typedef struct OH_DecodingOptionsForPicture OH_DecodingOptionsForPicture; + /** * @brief Enumerates decoding dynamic range.. * @@ -360,6 +377,23 @@ Image_ErrorCode OH_ImageSourceNative_CreatePixelmap(OH_ImageSourceNative *source Image_ErrorCode OH_ImageSourceNative_CreatePixelmapList(OH_ImageSourceNative *source, OH_DecodingOptions *options, OH_PixelmapNative *resVecPixMap[], size_t size); +/** + * @brief Create Picture pointer from ImageSource + * based on the specified {@link OH_DecodingOptionsForPicture} struct. + * + * @param source Indicates a void pointer(from ImageSource pointer convert). + * @param options Indicates a pointer to the options for decoding the image source. + * For details, see {@link OH_DecodingOptionsForPicture}. + * @param picture Indicates a void pointer to the Picture object obtained at the C++ native layer. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} source is nullptr, or picture is nullptr. + * {@link IMAGE_DECODE_FAILED} decode failed. + * @since 12 + */ +Image_ErrorCode OH_ImageSourceNative_CreatePicture(OH_ImageSourceNative *source, OH_DecodingOptionsForPicture *options, + OH_PictureNative **picture); + /** * @brief Obtains the delay time list from some ImageSource objects (such as GIF image sources). * @@ -429,6 +463,57 @@ Image_ErrorCode OH_ImageSourceNative_GetFrameCount(OH_ImageSourceNative *source, */ Image_ErrorCode OH_ImageSourceNative_Release(OH_ImageSourceNative *source); +/** + * @brief Create a pointer for OH_DecodingOptionsForPicture struct. + * + * @param options The OH_DecodingOptionsForPicture pointer will be operated. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} options is nullptr. + * @since 12 + */ +Image_ErrorCode OH_DecodingOptionsForPicture_Create(OH_DecodingOptionsForPicture **options); + +/** + * @brief Obtains the desired auxiliary pictures of decoding options. + * + * @param options The OH_DecodingOptionsForPicture pointer will be operated. + * @param desiredAuxiliaryPictures The desired auxiliary pictures in DecodingOptionsForPicture. + * @param length The length of desired auxiliary pictures. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} options is nullptr, desiredAuxiliaryPictures is nullptr, + * or length is invalid. + * @since 12 + */ +Image_ErrorCode OH_DecodingOptionsForPicture_GetDesiredAuxiliaryPictures(OH_DecodingOptionsForPicture *options, + Image_AuxiliaryPictureType **desiredAuxiliaryPictures, size_t *length); + +/** + * @brief Set decoding options desired auxiliary pictures. + * + * @param options The OH_DecodingOptionsForPicture pointer will be operated. + * @param desiredAuxiliaryPictures The desired auxiliary pictures will be set. + * @param length The length of desired auxiliary pictures. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} options is nullptr, desiredAuxiliaryPictures is nullptr, + * or length is invalid. + * @since 12 + */ +Image_ErrorCode OH_DecodingOptionsForPicture_SetDesiredAuxiliaryPictures(OH_DecodingOptionsForPicture *options, + Image_AuxiliaryPictureType *desiredAuxiliaryPictures, size_t length); + +/** + * @brief Releases an DecodingOptionsForPicture object. + * + * @param options Indicates a DecodingOptionsForPicture pointer. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} options is nullptr. + * @since 12 + */ +Image_ErrorCode OH_DecodingOptionsForPicture_Release(OH_DecodingOptionsForPicture *options); #ifdef __cplusplus }; #endif diff --git a/multimedia/image_framework/include/image/picture_native.h b/multimedia/image_framework/include/image/picture_native.h new file mode 100644 index 0000000000000000000000000000000000000000..ddc402513050b346ac7faf6fdccc75b88b10798a --- /dev/null +++ b/multimedia/image_framework/include/image/picture_native.h @@ -0,0 +1,491 @@ +/* + * 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 image + * @{ + * + * @brief Provides APIs for obtaining picture data and information. + * + * @Syscap SystemCapability.Multimedia.Image.Core + * @since 12 + */ + +/** + * @file picture_native.h + * + * @brief Declares the APIs that can access a picture. + * + * @library libpicture.so + * @kit ImageKit + * @Syscap SystemCapability.Multimedia.Image.Core + * @since 12 + */ +#ifndef INTERFACES_KITS_NATIVE_INCLUDE_IMAGE_PICTURE_NATIVE_H_ +#define INTERFACES_KITS_NATIVE_INCLUDE_IMAGE_PICTURE_NATIVE_H_ +#include "image_common.h" +#include "pixelmap_native.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Define a Picture struct type, used for picture pointer controls. + * + * @since 12 + */ +struct OH_PictureNative; + +/** + * @brief Define a Picture struct type, used for picture pointer controls. + * + * @since 12 + */ +typedef struct OH_PictureNative OH_PictureNative; + +/** + * @brief Define a AuxiliaryPicture struct type, used for auxiliary + * picture pointer controls. + * + * @since 12 + */ +struct OH_AuxiliaryPictureNative; + +/** + * @brief Define a AuxiliaryPicture struct type, used for auxiliary + * picture pointer controls. + * + * @since 12 + */ +typedef struct OH_AuxiliaryPictureNative OH_AuxiliaryPictureNative; + +/** + * @brief Define a AuxiliaryPictureInfo struct type, used for auxiliary + * picture info controls. + * + * @since 12 + */ +struct OH_AuxiliaryPictureInfo; + +/** + * @brief Define a AuxiliaryPictureInfo struct type, used for auxiliary + * picture info controls. + * + * @since 12 + */ +typedef struct OH_AuxiliaryPictureInfo OH_AuxiliaryPictureInfo; + +/** + * @brief Define a auxiliary picture type. + * + * @since 12 + */ +typedef enum { + /* + * Gainmap + */ + AUXILIARY_PICTURE_TYPE_GAINMAP = 1, + /* + * Depth map + */ + AUXILIARY_PICTURE_TYPE_DEPTH_MAP = 2, + /* + * Unrefocus map + */ + AUXILIARY_PICTURE_TYPE_UNREFOCUS_MAP = 3, + /* + * Linear map + */ + AUXILIARY_PICTURE_TYPE_LINEAR_MAP = 4, + /* + * Fragment map + */ + AUXILIARY_PICTURE_TYPE_FRAGMENT_MAP = 5, +} Image_AuxiliaryPictureType; + +/** + * @brief Create a Picture object. + * + * @param mainPixelmap The pixel map of the main image. + * @param picture Picture pointer for created. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} mainPixelmap is nullptr, or picture is nullptr. + * @since 12 + */ +Image_ErrorCode OH_PictureNative_CreatePicture(OH_PixelmapNative *mainPixelmap, OH_PictureNative **picture); + +/** + * @brief Obtains the pixel map of the main image. + * + * @param picture The Picture pointer will be operated. + * @param mainPixelmap Main pixel map pointer for obtained. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} picture is nullptr, or mainPixelmap is nullptr. + * @since 12 + */ +Image_ErrorCode OH_PictureNative_GetMainPixelmap(OH_PictureNative *picture, OH_PixelmapNative **mainPixelmap); + +/** + * @brief Obtains the hdr pixel map. + * + * @param picture The Picture pointer will be operated. + * @param hdrPixelmap Hdr pixel map pointer for obtained. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} picture is nullptr, or hdrPixelmap is nullptr. + * {@link IMAGE_UNSUPPORTED_OPERATION} Unsupported operation, e.g. the picture does not has a gainmap + * @since 12 + */ +Image_ErrorCode OH_PictureNative_GetHdrComposedPixelmap(OH_PictureNative *picture, OH_PixelmapNative **hdrPixelmap); + +/** + * @brief Obtains the gainmap pixel map. + * + * @param picture The Picture pointer will be operated. + * @param gainmapPixelmap Gainmap pointer for obtained. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} picture is nullptr, or gainmapPixelmap is nullptr. + * @since 12 + */ +Image_ErrorCode OH_PictureNative_GetGainmapPixelmap(OH_PictureNative *picture, OH_PixelmapNative **gainmapPixelmap); + +/** + * @brief Set auxiliary picture. + * + * @param picture The Picture pointer will be operated. + * @param type The type of auxiliary picture. + * @param auxiliaryPicture AuxiliaryPicture object. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} picture is nullptr, or auxiliaryPicture is nullptr, or the type is invalid. + * @since 12 + */ +Image_ErrorCode OH_PictureNative_SetAuxiliaryPicture(OH_PictureNative *picture, Image_AuxiliaryPictureType type, + OH_AuxiliaryPictureNative *auxiliaryPicture); + +/** + * @brief Obtains the auxiliary picture based on type. + * + * @param picture The Picture pointer will be operated. + * @param type The type of auxiliary picture. + * @param auxiliaryPicture AuxiliaryPicture pointer for obtained. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} picture is nullptr, or auxiliaryPicture is nullptr, or the type is invalid. + * @since 12 + */ +Image_ErrorCode OH_PictureNative_GetAuxiliaryPicture(OH_PictureNative *picture, Image_AuxiliaryPictureType type, + OH_AuxiliaryPictureNative **auxiliaryPicture); + +/** + * @brief Obtains the metadata of main picture. + * + * @param picture The Picture pointer will be operated. + * @param metadataType The type of metadata. + * @param metadata The metadata of main picture. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} picture is nullptr, or metadata is nullptr. + * {@link IMAGE_UNSUPPORTED_METADATA} unsupported metadata type. + * @since 12 + */ +Image_ErrorCode OH_PictureNative_GetMetadata(OH_PictureNative *picture, Image_MetadataType metadataType, + OH_PictureMetadata **metadata); + +/** + * @brief Set main picture metadata. + * + * @param picture The Picture pointer will be operated. + * @param metadataType The type of metadata. + * @param metadata The metadata will be set. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} picture is nullptr, or metadata is nullptr. + * {@link IMAGE_UNSUPPORTED_METADATA} unsupported metadata type. + * @since 12 + */ +Image_ErrorCode OH_PictureNative_SetMetadata(OH_PictureNative *picture, Image_MetadataType metadataType, + OH_PictureMetadata *metadata); + +/** + * @brief Releases this Picture object. + * + * @param picture The Picture pointer will be operated. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} picture is nullptr. + * @since 12 + */ +Image_ErrorCode OH_PictureNative_Release(OH_PictureNative *picture); + +/** + * @brief Create a AuxiliaryPicture object. + * + * @param data The image data buffer. + * @param dataLength The length of data. + * @param size The size of auxiliary picture. + * @param type The type of auxiliary picture. + * @param auxiliaryPicture AuxiliaryPicture pointer for created. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} data is nullptr, or dataLength is invalid, or size is nullptr, or the type + * is invalid, or auxiliaryPicture is nullptr. + * @since 12 + */ +Image_ErrorCode OH_AuxiliaryPictureNative_Create(uint8_t *data, size_t dataLength, Image_Size *size, + Image_AuxiliaryPictureType type, OH_AuxiliaryPictureNative **auxiliaryPicture); + +/** + * @brief Write pixels to auxiliary picture. + * + * @param auxiliaryPicture The AuxiliaryPicture pointer will be operated. + * @param source The pixels will be written. + * @param bufferSize The size of pixels. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} auxiliaryPicture is nullptr, or source is nullptr, or the bufferSize is invalid. + * {@link IMAGE_ALLOC_FAILED} memory alloc failed. + * {@link IMAGE_COPY_FAILED} memory copy failed. + * @since 12 + */ +Image_ErrorCode OH_AuxiliaryPictureNative_WritePixels(OH_AuxiliaryPictureNative *auxiliaryPicture, uint8_t *source, + size_t bufferSize); + +/** + * @brief Read pixels from auxiliary picture. + * + * @param auxiliaryPicture The AuxiliaryPicture pointer will be operated. + * @param destination The pixels will be read. + * @param bufferSize The size of pixels for reading. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} auxiliaryPicture is nullptr, or destination is nullptr, + * or the bufferSize is invalid. + * {@link IMAGE_ALLOC_FAILED} memory alloc failed. + * {@link IMAGE_COPY_FAILED} memory copy failed. + * @since 12 + */ +Image_ErrorCode OH_AuxiliaryPictureNative_ReadPixels(OH_AuxiliaryPictureNative *auxiliaryPicture, uint8_t *destination, + size_t *bufferSize); + +/** + * @brief Obtains the type of auxiliary picture. + * + * @param auxiliaryPicture The AuxiliaryPicture pointer will be operated. + * @param type The type of auxiliary picture. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} auxiliaryPicture is nullptr, or type is nullptr. + * @since 12 + */ +Image_ErrorCode OH_AuxiliaryPictureNative_GetType(OH_AuxiliaryPictureNative *auxiliaryPicture, + Image_AuxiliaryPictureType *type); + +/** + * @brief Obtains the info of auxiliary picture. + * + * @param auxiliaryPicture The AuxiliaryPicture pointer will be operated. + * @param info The info of auxiliary picture. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} auxiliaryPicture is nullptr, or info is nullptr. + * @since 12 + */ +Image_ErrorCode OH_AuxiliaryPictureNative_GetInfo(OH_AuxiliaryPictureNative *auxiliaryPicture, + OH_AuxiliaryPictureInfo **info); + +/** + * @brief Set auxiliary picture info. + * + * @param auxiliaryPicture The AuxiliaryPicture pointer will be operated. + * @param info The info will be set. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} auxiliaryPicture is nullptr, or info is nullptr. + * @since 12 + */ +Image_ErrorCode OH_AuxiliaryPictureNative_SetInfo(OH_AuxiliaryPictureNative *auxiliaryPicture, + OH_AuxiliaryPictureInfo *info); + +/** + * @brief Obtains the metadata of auxiliary picture. + * + * @param auxiliaryPicture The AuxiliaryPicture pointer will be operated. + * @param metadataType The type of metadata. + * @param metadata The metadata of auxiliary picture. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} auxiliaryPicture is nullptr, or metadata is nullptr. + * {@link IMAGE_UNSUPPORTED_METADATA} unsupported metadata type, or the metadata type does not match the + * auxiliary picture type. + * @since 12 + */ +Image_ErrorCode OH_AuxiliaryPictureNative_GetMetadata(OH_AuxiliaryPictureNative *auxiliaryPicture, + Image_MetadataType metadataType, OH_PictureMetadata **metadata); + +/** + * @brief Set auxiliary picture metadata. + * + * @param auxiliaryPicture The AuxiliaryPicture pointer will be operated. + * @param metadataType The type of metadata. + * @param metadata The metadata will be set. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} auxiliaryPicture is nullptr, or metadata is nullptr. + * {@link IMAGE_UNSUPPORTED_METADATA} unsupported metadata type, or the metadata type does not match the + * auxiliary picture type. + * @since 12 + */ +Image_ErrorCode OH_AuxiliaryPictureNative_SetMetadata(OH_AuxiliaryPictureNative *auxiliaryPicture, + Image_MetadataType metadataType, OH_PictureMetadata *metadata); + +/** + * @brief Releases this AuxiliaryPicture object. + * + * @param picture The Picture pointer will be operated. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} picture is nullptr. + * @since 12 + */ +Image_ErrorCode OH_AuxiliaryPictureNative_Release(OH_AuxiliaryPictureNative *picture); + +/** + * @brief Create a AuxiliaryPictureInfo object. + * + * @param info The AuxiliaryPictureInfo pointer will be operated. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} info is nullptr. + * @since 12 + */ +Image_ErrorCode OH_AuxiliaryPictureInfo_Create(OH_AuxiliaryPictureInfo **info); + +/** + * @brief Obtains the type of auxiliary picture info. + * + * @param info The AuxiliaryPictureInfo pointer will be operated. + * @param type The type of auxiliary picture info. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} info is nullptr, or type is nullptr. + * @since 12 + */ +Image_ErrorCode OH_AuxiliaryPictureInfo_GetType(OH_AuxiliaryPictureInfo *info, Image_AuxiliaryPictureType *type); + +/** + * @brief Set auxiliary picture info type. + * + * @param info The AuxiliaryPictureInfo pointer will be operated. + * @param type The type will be set. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} info is nullptr, or type is invalid. + * @since 12 + */ +Image_ErrorCode OH_AuxiliaryPictureInfo_SetType(OH_AuxiliaryPictureInfo *info, Image_AuxiliaryPictureType type); + +/** + * @brief Obtains the size of auxiliary picture info. + * + * @param info The AuxiliaryPictureInfo pointer will be operated. + * @param size The size of auxiliary picture info. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} info is nullptr, or size is nullptr. + * @since 12 + */ +Image_ErrorCode OH_AuxiliaryPictureInfo_GetSize(OH_AuxiliaryPictureInfo *info, Image_Size *size); + +/** + * @brief Set auxiliary picture info size. + * + * @param info The AuxiliaryPictureInfo pointer will be operated. + * @param size The size will be set. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} info is nullptr, or size is nullptr. + * @since 12 + */ +Image_ErrorCode OH_AuxiliaryPictureInfo_SetSize(OH_AuxiliaryPictureInfo *info, Image_Size *size); + +/** + * @brief Obtains the rowStride of auxiliary picture info. + * + * @param info The AuxiliaryPictureInfo pointer will be operated. + * @param rowStride The rowStride of auxiliary picture info. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} info is nullptr, or rowStride is nullptr. + * @since 12 + */ +Image_ErrorCode OH_AuxiliaryPictureInfo_GetRowStride(OH_AuxiliaryPictureInfo *info, uint32_t *rowStride); + +/** + * @brief Set auxiliary picture info rowStride. + * + * @param info The AuxiliaryPictureInfo pointer will be operated. + * @param rowStride The rowStride will be set. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} info is nullptr, or rowStride is nullptr. + * @since 12 + */ +Image_ErrorCode OH_AuxiliaryPictureInfo_SetRowStride(OH_AuxiliaryPictureInfo *info, uint32_t rowStride); + +/** + * @brief Obtains the pixelFormat of auxiliary picture info. + * + * @param info The AuxiliaryPictureInfo pointer will be operated. + * @param pixelFormat The pixelFormat will be get. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} info is nullptr, or pixelFormat is nullptr. + * @since 12 + */ +Image_ErrorCode OH_AuxiliaryPictureInfo_GetPixelFormat(OH_AuxiliaryPictureInfo *info, PIXEL_FORMAT *pixelFormat); + +/** + * @brief Set auxiliary picture info pixelFormat. + * + * @param info The AuxiliaryPictureInfo pointer will be operated. + * @param pixelFormat The pixelFormat will be set. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} info is nullptr. + * @since 12 + */ +Image_ErrorCode OH_AuxiliaryPictureInfo_SetPixelFormat(OH_AuxiliaryPictureInfo *info, PIXEL_FORMAT pixelFormat); + +/** + * @brief Releases this AuxiliaryPictureInfo object. + * + * @param info The AuxiliaryPictureInfo pointer will be operated. + * @return Image functions result code. + * {@link IMAGE_SUCCESS} if the execution is successful. + * {@link IMAGE_BAD_PARAMETER} info is nullptr. + * @since 12 + */ +Image_ErrorCode OH_AuxiliaryPictureInfo_Release(OH_AuxiliaryPictureInfo *info); + +#ifdef __cplusplus +}; +#endif +/** @} */ +#endif //INTERFACES_KITS_NATIVE_INCLUDE_IMAGE_PICTURE_NATIVE_H_ \ No newline at end of file diff --git a/multimedia/image_framework/include/image/pixelmap_native.h b/multimedia/image_framework/include/image/pixelmap_native.h index 5f8be7c783e9671e7fd411d5ab276e6d0bd05a63..875bafe5bbd8162291976c018ac6eeb2926fe2aa 100644 --- a/multimedia/image_framework/include/image/pixelmap_native.h +++ b/multimedia/image_framework/include/image/pixelmap_native.h @@ -171,19 +171,19 @@ typedef enum { /** * No metadata. */ - NONE = 0, + HDR_METADATA_TYPE_NONE = 0, /** * Indicates that metadata will be used for the base image. */ - BASE = 1, + HDR_METADATA_TYPE_BASE = 1, /** * Indicates that metadata will be used for the gainmap image. */ - GAINMAP = 2, + HDR_METADATA_TYPE_GAINMAP = 2, /** * Indicates that metadata will be used for the alternate image. */ - ALTERNATE = 3, + HDR_METADATA_TYPE_ALTERNATE = 3, } OH_Pixelmap_HdrMetadataType; /** diff --git a/multimedia/image_framework/libimage_common.ndk.json b/multimedia/image_framework/libimage_common.ndk.json new file mode 100644 index 0000000000000000000000000000000000000000..9faa63b593d126950cc3f865dc2413ad7156f2bc --- /dev/null +++ b/multimedia/image_framework/libimage_common.ndk.json @@ -0,0 +1,22 @@ +[ + { + "first_introduced": "12", + "name": "OH_PictureMetadata_Create" + }, + { + "first_introduced": "12", + "name": "OH_PictureMetadata_GetProperty" + }, + { + "first_introduced": "12", + "name": "OH_PictureMetadata_SetProperty" + }, + { + "first_introduced": "12", + "name": "OH_PictureMetadata_Release" + }, + { + "first_introduced": "12", + "name": "OH_PictureMetadata_Clone" + } +] \ No newline at end of file diff --git a/multimedia/image_framework/libimage_packer.ndk.json b/multimedia/image_framework/libimage_packer.ndk.json index 0b5efcecfdb13f252a99694f011a200e24e884c6..694b6e2b82c30c858404ba3a5520dbfe8d88ed96 100644 --- a/multimedia/image_framework/libimage_packer.ndk.json +++ b/multimedia/image_framework/libimage_packer.ndk.json @@ -39,6 +39,46 @@ "first_introduced": "12", "name": "OH_PackingOptions_Release" }, + { + "first_introduced": "12", + "name": "OH_PackingOptionsForSequence_Create" + }, + { + "first_introduced": "12", + "name": "OH_PackingOptionsForSequence_SetFrameCount" + }, + { + "first_introduced": "12", + "name": "OH_PackingOptionsForSequence_GetFrameCount" + }, + { + "first_introduced": "12", + "name": "OH_PackingOptionsForSequence_SetDelayTimeList" + }, + { + "first_introduced": "12", + "name": "OH_PackingOptionsForSequence_GetDelayTimeList" + }, + { + "first_introduced": "12", + "name": "OH_PackingOptionsForSequence_SetDisposalTypes" + }, + { + "first_introduced": "12", + "name": "OH_PackingOptionsForSequence_GetDisposalTypes" + }, + { + "first_introduced": "12", + "name": "OH_PackingOptionsForSequence_SetLoopCount" + }, + { + "first_introduced": "12", + "name": "OH_PackingOptionsForSequence_GetLoopCount" + }, + { + "first_introduced": "12", + "name": "OH_PackingOptionsForSequence_Release" + }, { "first_introduced": "12", "name": "OH_ImagePackerNative_Create" @@ -51,6 +91,14 @@ "first_introduced": "12", "name": "OH_ImagePackerNative_PackToDataFromPixelmap" }, + { + "first_introduced": "12", + "name": "OH_ImagePackerNative_PackToDataFromPicture" + }, + { + "first_introduced": "12", + "name": "OH_ImagePackerNative_PackToDataFromPixelmapSequence" + }, { "first_introduced": "12", "name": "OH_ImagePackerNative_PackToFileFromImageSource" @@ -59,6 +107,14 @@ "first_introduced": "12", "name": "OH_ImagePackerNative_PackToFileFromPixelmap" }, + { + "first_introduced": "12", + "name": "OH_ImagePackerNative_PackToFileFromPicture" + }, + { + "first_introduced": "12", + "name": "OH_ImagePackerNative_PackToFileFromPixelmapSequence" + }, { "first_introduced": "12", "name": "OH_ImagePackerNative_Release" diff --git a/multimedia/image_framework/libimage_source.ndk.json b/multimedia/image_framework/libimage_source.ndk.json index 562ec53ca3b2468e6f7c9c70d68b944ff53c59a0..133bba8ecbb0a2240f96e20f66985b32ad80af6f 100644 --- a/multimedia/image_framework/libimage_source.ndk.json +++ b/multimedia/image_framework/libimage_source.ndk.json @@ -99,6 +99,10 @@ "first_introduced": "12", "name": "OH_ImageSourceNative_CreatePixelmapList" }, + { + "first_introduced": "12", + "name": "OH_ImageSourceNative_CreatePicture" + }, { "first_introduced": "12", "name": "OH_ImageSourceNative_GetDelayTimeList" @@ -122,5 +126,21 @@ { "first_introduced": "12", "name": "OH_ImageSourceNative_Release" + }, + { + "first_introduced": "12", + "name": "OH_DecodingOptionsForPicture_Create" + }, + { + "first_introduced": "12", + "name": "OH_DecodingOptionsForPicture_GetDesiredAuxiliaryPictures" + }, + { + "first_introduced": "12", + "name": "OH_DecodingOptionsForPicture_SetDesiredAuxiliaryPictures" + }, + { + "first_introduced": "12", + "name": "OH_DecodingOptionsForPicture_Release" } ] \ No newline at end of file diff --git a/multimedia/image_framework/libohimage.ndk.json b/multimedia/image_framework/libohimage.ndk.json index a9eefa5fbf460cbf00e0f714a491f9e2b330cc41..da613fb2ac170e64b6ec444011d7a8133d3da97b 100644 --- a/multimedia/image_framework/libohimage.ndk.json +++ b/multimedia/image_framework/libohimage.ndk.json @@ -23,6 +23,10 @@ "first_introduced": "12", "name": "OH_ImageNative_GetPixelStride" }, + { + "first_introduced": "12", + "name": "OH_ImageNative_GetTimestamp" + }, { "first_introduced": "12", "name": "OH_ImageNative_Release" diff --git a/multimedia/image_framework/libpicture.ndk.json b/multimedia/image_framework/libpicture.ndk.json new file mode 100644 index 0000000000000000000000000000000000000000..d74f9c0f25f5b9e854d3d914d81c85c3bde3402c --- /dev/null +++ b/multimedia/image_framework/libpicture.ndk.json @@ -0,0 +1,114 @@ +[ + { + "first_introduced": "12", + "name": "OH_PictureNative_CreatePicture" + }, + { + "first_introduced": "12", + "name": "OH_PictureNative_GetMainPixelmap" + }, + { + "first_introduced": "12", + "name": "OH_PictureNative_GetHdrComposedPixelmap" + }, + { + "first_introduced": "12", + "name": "OH_PictureNative_GetGainmapPixelmap" + }, + { + "first_introduced": "12", + "name": "OH_PictureNative_SetAuxiliaryPicture" + }, + { + "first_introduced": "12", + "name": "OH_PictureNative_GetAuxiliaryPicture" + }, + { + "first_introduced": "12", + "name": "OH_PictureNative_GetMetadata" + }, + { + "first_introduced": "12", + "name": "OH_PictureNative_SetMetadata" + }, + { + "first_introduced": "12", + "name": "OH_PictureNative_Release" + }, + { + "first_introduced": "12", + "name": "OH_AuxiliaryPictureNative_Create" + }, + { + "first_introduced": "12", + "name": "OH_AuxiliaryPictureNative_WritePixels" + }, + { + "first_introduced": "12", + "name": "OH_AuxiliaryPictureNative_ReadPixels" + }, + { + "first_introduced": "12", + "name": "OH_AuxiliaryPictureNative_GetType" + }, + { + "first_introduced": "12", + "name": "OH_AuxiliaryPictureNative_GetInfo" + }, + { + "first_introduced": "12", + "name": "OH_AuxiliaryPictureNative_SetInfo" + }, + { + "first_introduced": "12", + "name": "OH_AuxiliaryPictureNative_GetMetadata" + }, + { + "first_introduced": "12", + "name": "OH_AuxiliaryPictureNative_SetMetadata" + }, + { + "first_introduced": "12", + "name": "OH_AuxiliaryPictureNative_Release" + }, + { + "first_introduced": "12", + "name": "OH_AuxiliaryPictureInfo_Create" + }, + { + "first_introduced": "12", + "name": "OH_AuxiliaryPictureInfo_GetType" + }, + { + "first_introduced": "12", + "name": "OH_AuxiliaryPictureInfo_SetType" + }, + { + "first_introduced": "12", + "name": "OH_AuxiliaryPictureInfo_GetSize" + }, + { + "first_introduced": "12", + "name": "OH_AuxiliaryPictureInfo_SetSize" + }, + { + "first_introduced": "12", + "name": "OH_AuxiliaryPictureInfo_GetRowStride" + }, + { + "first_introduced": "12", + "name": "OH_AuxiliaryPictureInfo_SetRowStride" + }, + { + "first_introduced": "12", + "name": "OH_AuxiliaryPictureInfo_GetPixelFormat" + }, + { + "first_introduced": "12", + "name": "OH_AuxiliaryPictureInfo_SetPixelFormat" + }, + { + "first_introduced": "12", + "name": "OH_AuxiliaryPictureInfo_Release" + } + ] \ No newline at end of file diff --git a/multimedia/image_framework/libpixelmap.ndk.json b/multimedia/image_framework/libpixelmap.ndk.json index f06f6b1866994fabc7112dc3877870b99a9d044d..5a1af8e20dd8478b6e0f3480a38b88920347a618 100644 --- a/multimedia/image_framework/libpixelmap.ndk.json +++ b/multimedia/image_framework/libpixelmap.ndk.json @@ -149,10 +149,10 @@ }, { "first_introduced": "12", - "name": "OH_PixelmapNative_ConvertPixelmapToNapi" + "name": "OH_PixelmapNative_ConvertPixelmapNativeToNapi" }, { "first_introduced": "12", - "name": "OH_PixelmapNative_ConvertPixelmapFromNapi" + "name": "OH_PixelmapNative_ConvertPixelmapNativeFromNapi" } ] \ No newline at end of file diff --git a/multimedia/player_framework/avscreen_capture/libnative_avscreen_capture.ndk.json b/multimedia/player_framework/avscreen_capture/libnative_avscreen_capture.ndk.json index 645b3569dbcc1ec2f96b800754cda139bab903c6..1e53ae7d709c96066e430869fe0ca9439238991b 100644 --- a/multimedia/player_framework/avscreen_capture/libnative_avscreen_capture.ndk.json +++ b/multimedia/player_framework/avscreen_capture/libnative_avscreen_capture.ndk.json @@ -94,5 +94,9 @@ { "first_introduced": "12", "name": "OH_AVScreenCapture_ResizeCanvas" + }, + { + "first_introduced": "12", + "name": "OH_AVScreenCapture_SkipPrivacyMode" } ] \ No newline at end of file diff --git a/multimedia/player_framework/native_avscreen_capture.h b/multimedia/player_framework/native_avscreen_capture.h index 1264f7882a8286daa7996eb36bc167450e31542c..e993b8ef28ed0b8b9308d5786960c26f5e519987 100644 --- a/multimedia/player_framework/native_avscreen_capture.h +++ b/multimedia/player_framework/native_avscreen_capture.h @@ -398,6 +398,23 @@ OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_ContentFilter_AddWindowContent( */ OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_ResizeCanvas(struct OH_AVScreenCapture *capture, int32_t width, int32_t height); + +/** + * @brief skip some windows' privacy mode of current app during the screen recording + * @syscap SystemCapability.Multimedia.Media.AVScreenCapture + * @param capture Pointer to an OH_AVScreenCapture instance + * @param Pointer of windowID list + * @param length of windowID list + * @return Function result code. + * {@link AV_SCREEN_CAPTURE_ERR_OK} if the execution is successful. + * {@link AV_SCREEN_CAPTURE_ERR_INVALID_VAL} input capture is nullptr or input windowIDs are not belong current + * app. + * {@link AV_SCREEN_CAPTURE_ERR_OPERATE_NOT_PERMIT} opertation not be permitted. + * @since 12 + * @version 1.0 + */ +OH_AVSCREEN_CAPTURE_ErrCode OH_AVScreenCapture_SkipPrivacyMode(struct OH_AVScreenCapture *capture, + int32_t *windowIDs, int32_t windowCount); #ifdef __cplusplus } #endif diff --git a/multimedia/player_framework/native_avscreen_capture_base.h b/multimedia/player_framework/native_avscreen_capture_base.h index 34eb708d4b6a7807fa34bc18656325e2980ce34e..0d5b353871361e6d4fe8f043df90c82723a0173f 100644 --- a/multimedia/player_framework/native_avscreen_capture_base.h +++ b/multimedia/player_framework/native_avscreen_capture_base.h @@ -446,6 +446,8 @@ typedef enum OH_AVScreenCaptureStateCode { OH_SCREEN_CAPTURE_STATE_ENTER_PRIVATE_SCENE = 8, /* Private window disappeared on current captured screen*/ OH_SCREEN_CAPTURE_STATE_EXIT_PRIVATE_SCENE = 9, + /* ScreenCapture stopped by user switches */ + OH_SCREEN_CAPTURE_STATE_STOPPED_BY_USER_SWITCHES = 10, } OH_AVScreenCaptureStateCode; /** diff --git a/multimedia/video_processing_engine/image_processing.h b/multimedia/video_processing_engine/image_processing.h new file mode 100644 index 0000000000000000000000000000000000000000..81f503ecf3b6ed252ee9cb4e6335143853346532 --- /dev/null +++ b/multimedia/video_processing_engine/image_processing.h @@ -0,0 +1,314 @@ +/* + * 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 ImageProcessing + * @{ + * + * @brief Provide APIs for image quality processing. + * + * @since 12 + */ + +/** + * @file image_processing.h + * + * @brief Declare image processing functions. + * + * Provides SDR content processing for images, including color space conversion, metadata generation + * and image scaling. + * + * @library libimage_processing.so + * @syscap SystemCapability.Multimedia.VideoProcessingEngine + * @kit ImageKit + * @since 12 + */ + +#ifndef VIDEO_PROCESSING_ENGINE_C_API_IMAGE_PROCESSING_H +#define VIDEO_PROCESSING_ENGINE_C_API_IMAGE_PROCESSING_H + +#include +#include +#include "image_processing_types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Initialize global environment for image processing. + * + * This function is optional. \n + * Typically, this function is called once when the host process is started to initialize the global environment for + * image processing, which can reduce the time of {@link OH_ImageProcessing_Create}. \n + * To deinitialize global environment, call {@link OH_ImageProcessing_DeinitializeEnvironment}. + * + * @return {@link IMAGE_PROCESSING_SUCCESS} if initialization is successful. \n + * {@link IMAGE_PROCESSING_ERROR_INITIALIZE_FAILED} if initialization is failed. \n + * You can check if the device GPU is working properly. + * @since 12 + */ +ImageProcessing_ErrorCode OH_ImageProcessing_InitializeEnvironment(void); + +/** + * @brief Deinitialize global environment for image processing. + * + * This function is required if {@link OH_ImageProcessing_InitializeEnvironment} is called. Typically, this + * function is called when the host process is about to exit to deinitialize the global environment, which is + * initialized by calling {@link OH_ImageProcessing_InitializeEnvironment}. \n + * If there is some image processing instance existing, this function should not be called. \n + * If the {@link OH_ImageProcessing_InitializeEnvironment} is not called, this function should not be called. + * + * @return {@link IMAGE_PROCESSING_SUCCESS} if deinitialization is successful. \n + * {@link IMAGE_PROCESSING_ERROR_OPERATION_NOT_PERMITTED} if some image processing instance is not destroyed or + * {@link OH_ImageProcessing_InitializeEnvironment} is not called. \n + * @since 12 + */ +ImageProcessing_ErrorCode OH_ImageProcessing_DeinitializeEnvironment(void); + +/** + * @brief Query whether the image color space conversion is supported. + * + * @param sourceImageInfo Input image color space information pointer. + * @param destinationImageInfo Output image color space information pointer. + * @return true if the color space conversion is supported. \n + * false if the the color space conversion is unsupported. + * @since 12 + */ +bool OH_ImageProcessing_IsColorSpaceConversionSupported( + const ImageProcessing_ColorSpaceInfo* sourceImageInfo, + const ImageProcessing_ColorSpaceInfo* destinationImageInfo); + +/** + * @brief Query whether the image composition is supported. + * + * @param sourceImageInfo Input image color space information pointer. + * @param sourceGainmapInfo Input gainmap color space information pointer. + * @param destinationImageInfo Output image color space information pointer. + * @return true if the image composition is supported. \n + * false if the image composition is unsupported. + * @since 12 + */ +bool OH_ImageProcessing_IsCompositionSupported( + const ImageProcessing_ColorSpaceInfo* sourceImageInfo, + const ImageProcessing_ColorSpaceInfo* sourceGainmapInfo, + const ImageProcessing_ColorSpaceInfo* destinationImageInfo); + +/** + * @brief Query whether the image decomposition is supported. + * + * @param sourceImageInfo Input image color space information pointer. + * @param destinationImageInfo Output image color space information pointer. + * @param destinationGainmapInfo Output gainmap information pointer. + * @return true if the image decomposition is supported. \n + * false if the image decomposition is unsupported. + * @since 12 + */ +bool OH_ImageProcessing_IsDecompositionSupported( + const ImageProcessing_ColorSpaceInfo* sourceImageInfo, + const ImageProcessing_ColorSpaceInfo* destinationImageInfo, + const ImageProcessing_ColorSpaceInfo* destinationGainmapInfo); + +/** + * @brief Query whether the image metadata generation is supported. + * + * @param sourceImageInfo Input image color space information pointer. + * @return true if the image metadata generation is supported.. \n + * false if the image metadata generation is unsupported. + * @since 12 + */ +bool OH_ImageProcessing_IsMetadataGenerationSupported( + const ImageProcessing_ColorSpaceInfo* sourceImageInfo); + +/** + * @brief Create an image processing instance. + * + * @param imageProcessor Output parameter. The *imageProcessor points to a new image processing object. + * The *imageProcessor must be null before passed in. + * @param type Use IMAGE_PROCESSING_TYPE_XXX to specify the processing type. The processing type of the instance can not + * be changed. + * @return {@link IMAGE_PROCESSING_SUCCESS} if creating an image processing successfully. \n + * {@link IMAGE_PROCESSING_ERROR_UNSUPPORTED_PROCESSING} if the type is not supported. For example, if metadata + * generation is not supported by vendor, it returns unsupported processing. \n + * {@link IMAGE_PROCESSING_ERROR_CREATE_FAILED} if failed to create an image processing. \n + * {@link IMAGE_PROCESSING_ERROR_INVALID_INSTANCE} if instance is null or *instance is not null. \n + * {@link IMAGE_PROCESSING_ERROR_INVALID_PARAMETER} if type is invalid. \n + * @since 12 + */ +ImageProcessing_ErrorCode OH_ImageProcessing_Create(OH_ImageProcessing** imageProcessor, int32_t type); + +/** + * @brief Destroy the image processing instance. + * + * @param imageProcessor An image processing instance pointer. It is recommended setting the + * instance pointer to null after the instance is destroyed. + * @return {@link IMAGE_PROCESSING_SUCCESS} if the instance is destroyed successfully. \n + * {@link IMAGE_PROCESSING_ERROR_INVALID_INSTANCE} if instance is null or not an image processing instance. + * @since 12 + */ +ImageProcessing_ErrorCode OH_ImageProcessing_Destroy(OH_ImageProcessing* imageProcessor); + +/** + * @brief Set parameter for image processing. + * + * Add parameter identified by the specified parameter key. + * + * @param imageProcessor An image processing instance pointer. + * @param parameter The parameter for image processing. + * @return {@link IMAGE_PROCESSING_SUCCESS} if setting parameter is successful. \n + * {@link IMAGE_PROCESSING_ERROR_INVALID_INSTANCE} if instance is null or not an image processing instance. \n + * {@link IMAGE_PROCESSING_ERROR_INVALID_PARAMETER} if the parameter is null. \n + * {@link IMAGE_PROCESSING_ERROR_INVALID_VALUE} if some property of the parameter is invalid. For example, the parameter + * contains unsupported parameter key or value. \n + * {@link IMAGE_PROCESSING_ERROR_NO_MEMORY} if memory allocation failed. + * @since 12 + */ +ImageProcessing_ErrorCode OH_ImageProcessing_SetParameter(OH_ImageProcessing* imageProcessor, + const OH_AVFormat* parameter); + +/** + * @brief Get parameter of image processing. + * + * Get parameter identified by the specified parameter key. + * + * @param imageProcessor An image processing instance pointer. + * @param parameter The parameter used by the image processing instance. + * @return {@link IMAGE_PROCESSING_SUCCESS} if getting parameter is successful. \n + * {@link IMAGE_PROCESSING_ERROR_INVALID_INSTANCE} if instance is null or not an image processing instance. \n + * {@link IMAGE_PROCESSING_ERROR_INVALID_PARAMETER} if the parameter is null. \n + * @since 12 + */ +ImageProcessing_ErrorCode OH_ImageProcessing_GetParameter(OH_ImageProcessing* imageProcessor, + OH_AVFormat* parameter); + +/** + * @brief Conversion between single-layer images. + * + * The function generate the destinationImage from sourceImage. It include the colorspace conversion from + * HDR image to SDR image, SDR image to HDR image, SDR image to SDR image and HDR image to HDR image. + * + * @param imageProcessor An image processing instance pointer. The instance should be created with + * type {@link IMAGE_PROCESSING_TYPE_COLOR_SPACE_CONVERSION}. + * @param sourceImage Input image pointer. + * @param destinationImage Output image pointer. + * @return {@link IMAGE_PROCESSING_SUCCESS} if processing image is successful. \n + * {@link IMAGE_PROCESSING_ERROR_INVALID_INSTANCE} if instance is null or not an image processing instance. \n + * {@link IMAGE_PROCESSING_ERROR_INVALID_PARAMETER} if the image is null. \n + * {@link IMAGE_PROCESSING_ERROR_INVALID_VALUE} if some property of image is invalid. For example, the color space + * of the image is unsupported. \n + * {@link IMAGE_PROCESSING_ERROR_UNSUPPORTED_PROCESSING} if the processing is not supported. \n + * {@link IMAGE_PROCESSING_ERROR_PROCESS_FAILED} if processing error occurs. \n + * {@link IMAGE_PROCESSING_ERROR_NO_MEMORY} if memory allocation failed. + * @since 12 + */ +ImageProcessing_ErrorCode OH_ImageProcessing_ConvertColorSpace(OH_ImageProcessing* imageProcessor, + OH_PixelmapNative* sourceImage, OH_PixelmapNative* destinationImage); + +/** + * @brief Composition from dual-layer HDR images to single-layer HDR images. + * + * The function generate the destinationImage from sourceImage and sourceGainmap. + * + * @param imageProcessor An image processing instance pointer. The instance should be created with + * type {@link IMAGE_PROCESSING_TYPE_COMPOSITION}. + * @param sourceImage Input image pointer. + * @param sourceGainmap Input gainmap pointer. + * @param destinationImage Output image pointer. + * @return {@link IMAGE_PROCESSING_SUCCESS} if processing image is successful. \n + * {@link IMAGE_PROCESSING_ERROR_INVALID_INSTANCE} if instance is null or not an image processing instance. \n + * {@link IMAGE_PROCESSING_ERROR_INVALID_PARAMETER} if the image is null. \n + * {@link IMAGE_PROCESSING_ERROR_INVALID_VALUE} if some property of image is invalid. For example, the color space + * of the image is unsupported. \n + * {@link IMAGE_PROCESSING_ERROR_UNSUPPORTED_PROCESSING} if the processing is not supported. \n + * {@link IMAGE_PROCESSING_ERROR_PROCESS_FAILED} if processing error occurs. \n + * {@link IMAGE_PROCESSING_ERROR_NO_MEMORY} if memory allocation failed. + * @since 12 + */ +ImageProcessing_ErrorCode OH_ImageProcessing_Compose(OH_ImageProcessing* imageProcessor, + OH_PixelmapNative* sourceImage, OH_PixelmapNative* sourceGainmap, OH_PixelmapNative* destinationImage); + +/** + * @brief Decomposition from single-layer HDR images to dual-layer HDR images. + * + * The function generate the destinationImage and destinationGainmap from sourceImage. + * + * @param imageProcessor An image processing instance pointer. The instance should be created with + * type {@link IMAGE_PROCESSING_TYPE_DECOMPOSITION}. + * @param sourceImage Input image pointer. + * @param destinationImage Output image pointer. + * @param destinationGainmap Output gainmap pointer. + * @return {@link IMAGE_PROCESSING_SUCCESS} if processing image is successful. \n + * {@link IMAGE_PROCESSING_ERROR_INVALID_INSTANCE} if instance is null or not an image processing instance. \n + * {@link IMAGE_PROCESSING_ERROR_INVALID_PARAMETER} if the image is null. \n + * {@link IMAGE_PROCESSING_ERROR_INVALID_VALUE} if some property of image is invalid. For example, the color space + * of the image is unsupported. \n + * {@link IMAGE_PROCESSING_ERROR_UNSUPPORTED_PROCESSING} if the processing is not supported. \n + * {@link IMAGE_PROCESSING_ERROR_PROCESS_FAILED} if processing error occurs. \n + * {@link IMAGE_PROCESSING_ERROR_NO_MEMORY} if memory allocation failed. + * @since 12 + */ +ImageProcessing_ErrorCode OH_ImageProcessing_Decompose(OH_ImageProcessing* imageProcessor, + OH_PixelmapNative* sourceImage, OH_PixelmapNative* destinationImage, OH_PixelmapNative* destinationGainmap); + +/** + * @brief Metadata Generation for HDR images. + * + * The function generate metadata for the sourceImage. + * + * @param imageProcessor An image processing instance pointer. The instance should be created with + * type {@link IMAGE_PROCESSING_TYPE_METADATA_GENERATION}. + * @param sourceImage Input image pointer. + * @return {@link IMAGE_PROCESSING_SUCCESS} if processing image is successful. \n + * {@link IMAGE_PROCESSING_ERROR_INVALID_INSTANCE} if instance is null or not an image processing instance. \n + * {@link IMAGE_PROCESSING_ERROR_INVALID_PARAMETER} if the image is null. \n + * {@link IMAGE_PROCESSING_ERROR_INVALID_VALUE} if some property of image is invalid. For example, the color space + * of the image is unsupported. \n + * {@link IMAGE_PROCESSING_ERROR_UNSUPPORTED_PROCESSING} if the processing is not supported. \n + * {@link IMAGE_PROCESSING_ERROR_PROCESS_FAILED} if processing error occurs. \n + * {@link IMAGE_PROCESSING_ERROR_NO_MEMORY} if memory allocation failed. + * @since 12 + */ +ImageProcessing_ErrorCode OH_ImageProcessing_GenerateMetadata(OH_ImageProcessing* imageProcessor, + OH_PixelmapNative* sourceImage); + +/** + * @brief Clarity enhancement for images. + * + * The function generate the destinationImage from sourceImage with necessary scaling operation according to the size + * preset in the sourceImage and destinationImage. Different levels of scaling methonds are provided to balance + * performance and image quality. + * + * @param imageProcessor An image processing instance pointer. The instance should be created with + * type {@link IMAGE_PROCESSING_TYPE_DETAIL_ENHANCER}. + * @param sourceImage Input image pointer. + * @param destinationImage Output image pointer. + * @return {@link IMAGE_PROCESSING_SUCCESS} if processing image is successful. \n + * {@link IMAGE_PROCESSING_ERROR_INVALID_INSTANCE} if instance is null or not an image processing instance. \n + * {@link IMAGE_PROCESSING_ERROR_INVALID_PARAMETER} if the image is null. \n + * {@link IMAGE_PROCESSING_ERROR_INVALID_VALUE} if some property of image is invalid. For example, the color space + * of the image is unsupported. \n + * {@link IMAGE_PROCESSING_ERROR_UNSUPPORTED_PROCESSING} if the processing is not supported. \n + * {@link IMAGE_PROCESSING_ERROR_PROCESS_FAILED} if processing error occurs. \n + * {@link IMAGE_PROCESSING_ERROR_NO_MEMORY} if memory allocation failed. + * @since 12 + */ +ImageProcessing_ErrorCode OH_ImageProcessing_EnhanceDetail(OH_ImageProcessing* imageProcessor, + OH_PixelmapNative* sourceImage, OH_PixelmapNative* destinationImage); +#ifdef __cplusplus +} +#endif + +#endif // VIDEO_PROCESSING_ENGINE_C_API_IMAGE_PROCESSING_H +/** @} */ diff --git a/multimedia/video_processing_engine/image_processing/BUILD.gn b/multimedia/video_processing_engine/image_processing/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..d3c02809beebfde8424e31739f2463172e96f3d4 --- /dev/null +++ b/multimedia/video_processing_engine/image_processing/BUILD.gn @@ -0,0 +1,35 @@ +# 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. + +import("//build/ohos.gni") +import("//build/ohos/ndk/ndk.gni") + +ohos_ndk_headers("image_processing_ndk_headers") { + dest_dir = "$ndk_headers_out_dir/multimedia/video_processing_engine" + sources = [ + "../image_processing.h", + "../image_processing_types.h", + ] +} + +ohos_ndk_library("libimage_processing_ndk") { + ndk_description_file = "./libimage_processing.ndk.json" + output_name = "image_processing" + output_extension = "so" + min_compact_version = "12" + system_capability = "SystemCapability.Multimedia.VideoProcessingEngine" + system_capability_headers = [ + "multimedia/video_processing_engine/image_processing_types.h", + "multimedia/video_processing_engine/image_processing.h", + ] +} diff --git a/multimedia/video_processing_engine/image_processing/libimage_processing.ndk.json b/multimedia/video_processing_engine/image_processing/libimage_processing.ndk.json new file mode 100644 index 0000000000000000000000000000000000000000..8cb58693c7d4efcb153d0f9d74ed30f96a7911a2 --- /dev/null +++ b/multimedia/video_processing_engine/image_processing/libimage_processing.ndk.json @@ -0,0 +1,87 @@ +[ + { + "first_introduced": "12", + "name": "OH_ImageProcessing_InitializeEnvironment" + }, + { + "first_introduced": "12", + "name": "OH_ImageProcessing_DeinitializeEnvironment" + }, + { + "first_introduced": "12", + "name": "OH_ImageProcessing_IsColorSpaceConversionSupported" + }, + { + "first_introduced": "12", + "name": "OH_ImageProcessing_IsCompositionSupported" + }, + { + "first_introduced": "12", + "name": "OH_ImageProcessing_IsDecompositionSupported" + }, + { + "first_introduced": "12", + "name": "OH_ImageProcessing_IsMetadataGenerationSupported" + }, + { + "first_introduced": "12", + "name": "OH_ImageProcessing_Create" + }, + { + "first_introduced": "12", + "name": "OH_ImageProcessing_Destroy" + }, + { + "first_introduced": "12", + "name": "OH_ImageProcessing_SetParameter" + }, + { + "first_introduced": "12", + "name": "OH_ImageProcessing_GetParameter" + }, + { + "first_introduced": "12", + "name": "OH_ImageProcessing_ConvertColorSpace" + }, + { + "first_introduced": "12", + "name": "OH_ImageProcessing_Compose" + }, + { + "first_introduced": "12", + "name": "OH_ImageProcessing_Decompose" + }, + { + "first_introduced": "12", + "name": "OH_ImageProcessing_GenerateMetadata" + }, + { + "first_introduced": "12", + "name": "OH_ImageProcessing_EnhanceDetail" + }, + { + "first_introduced": "12", + "name": "IMAGE_PROCESSING_TYPE_COLOR_SPACE_CONVERSION", + "type": "variable" + }, + { + "first_introduced": "12", + "name": "IMAGE_PROCESSING_TYPE_COMPOSITION", + "type": "variable" + }, + { + "first_introduced": "12", + "name": "IMAGE_PROCESSING_TYPE_DECOMPOSITION", + "type": "variable" + }, + { + "first_introduced": "12", + "name": "IMAGE_PROCESSING_TYPE_METADATA_GENERATION", + "type": "variable" + }, + { + "first_introduced": "12", + "name": "IMAGE_PROCESSING_TYPE_DETAIL_ENHANCER", + "type": "variable" + } +] diff --git a/multimedia/video_processing_engine/image_processing_types.h b/multimedia/video_processing_engine/image_processing_types.h new file mode 100644 index 0000000000000000000000000000000000000000..cfd2a547398d0c158edb5a1d7ab7bcc0cd5e4c3f --- /dev/null +++ b/multimedia/video_processing_engine/image_processing_types.h @@ -0,0 +1,229 @@ +/* + * 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 ImageProcessing + * @{ + * + * @brief Provide image processing including color space conversion and metadata generation. + * + * @since 12 + */ + +/** + * @file image_processing_types.h + * + * @brief Type definitions for image processing. + * + * @library libimage_processing.so + * @syscap SystemCapability.Multimedia.VideoProcessingEngine + * @kit ImageKit + * @since 12 + */ + +#ifndef VIDEO_PROCESSING_ENGINE_C_API_IMAGE_PROCESSING_TYPES_H +#define VIDEO_PROCESSING_ENGINE_C_API_IMAGE_PROCESSING_TYPES_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Define the object for image processing. + * + * Define a null pointer of OH_ImageProcessing and call {@link OH_ImageProcessing_Create} to create an image processing + * instance. The pointer should be null before creating instance. + * User can create multiple image processing instances for different processing types. + * + * @since 12 + */ +typedef struct OH_ImageProcessing OH_ImageProcessing; + +/** + * @brief Forward declaration of OH_PixelmapNative. + * + * @since 12 + */ +typedef struct OH_PixelmapNative OH_PixelmapNative; + +/** + * @brief Forward declaration of OH_AVFormat. + * + * @since 12 + */ +typedef struct OH_AVFormat OH_AVFormat; + +/** + * @brief Used to create an image processing instance for color space conversion. + * + * Color space conversion includes the conversion of single-layer HDR images to SDR images, as well as + * the color space conversion of SDR images, and the conversion of SDR images to single-layer HDR images. Some + * capabilities are supported by vendor. Use {@link OH_ImageProcessing_IsColorSpaceConversionSupported} to query if + * the conversion is supported between single-layer images. + * + * @see OH_ImageProcessing_Create + * @since 12 + */ +extern const int32_t IMAGE_PROCESSING_TYPE_COLOR_SPACE_CONVERSION; + +/** + * @brief Used to create an image processing instance for HDR image composition. + * + * HDR image compose includes the conversion from dual-layer HDR images to single-layer HDR images. Some + * capabilities are supported by vendor. Use {@link OH_ImageProcessing_IsCompositionSupported} to + * query if the composition is supported from dual-layer HDR image to single-layer HDR image. + * + * @see OH_ImageProcessing_Create + * @since 12 + */ +extern const int32_t IMAGE_PROCESSING_TYPE_COMPOSITION; + +/** + * @brief Used to create an image processing instance for HDR image decomposition. + * + * HDR image decompose includes the conversion from single-layer HDR images to dual-layer HDR images. Some + * capabilities are supported by vendor. Use {@link OH_ImageProcessing_IsDecompositionSupported} to + * query if the decomposition is supported from single-layer image to dual-layer HDR image. + * + * @see OH_ImageProcessing_Create + * @since 12 + */ +extern const int32_t IMAGE_PROCESSING_TYPE_DECOMPOSITION; + +/** + * @brief Used to create an image processing instance for metadata generation. + * + * Generate HDR Vivid metadata for single-layer image. The capability is supported by vendor. If the capability is not + * supported, {@link OH_ImageProcessing_Create} returns {@link IMAGE_PROCESSING_ERROR_UNSUPPORTED_PROCESSING}. + * + * @see OH_ImageProcessing_Create + * @since 12 + */ +extern const int32_t IMAGE_PROCESSING_TYPE_METADATA_GENERATION; + +/** + * @brief Used to create an image processing instance for detail enhancement. + * + * Scale or resize images with the specified quality or just enhance details for rendering an image without changing + * its resolution. + * + * @see OH_ImageProcessing_Create + * @since 12 + */ +extern const int32_t IMAGE_PROCESSING_TYPE_DETAIL_ENHANCER; + +/** + * @brief The key is used to specify the quality level for image detail enhancement. + * + * See {@link ImageDetailEnhancer_QualityLevel} for its value. + * Use {@link OH_ImageProcessing_SetParameter} to set the quality level. + * Use {@link OH_ImageProcessing_GetParameter} to get the current quality level. + * + * @see OH_VideoProcessing_SetParameter + * @see OH_VideoProcessing_GetParameter + * @since 12 + */ +extern const char* IMAGE_DETAIL_ENHANCER_PARAMETER_KEY_QUALITY_LEVEL; + +/** + * @brief The color space information is used for color space conversion capability query. + * + * @see OH_ImageProcessing_IsColorSpaceConversionSupported + * @see OH_ImageProcessing_IsCompositionSupported + * @see OH_ImageProcessing_IsDecompositionSupported + * @since 12 + */ +typedef struct ImageProcessing_ColorSpaceInfo { + /** define metadata type */ + int32_t metadataType; + /** define color space, {@link enum OH_NativeBuffer_ColorSpace} */ + int32_t colorSpace; + /** define pixel format, {@link enum OH_NativeBuffer_Format} */ + int32_t pixelFormat; +} ImageProcessing_ColorSpaceInfo; + +/** + * @brief The quality level is used for detail enhancement. + * + * It is the value of the key parameter {@link IMAGE_DETAIL_ENHANCER_PARAMETER_KEY_QUALITY_LEVEL}. + * + * @see OH_ImageProcessing_SetParameter + * @see OH_ImageProcessing_GetParameter + * @since 12 + */ +typedef enum ImageDetailEnhancer_QualityLevel { + /** No detail enhancement */ + IMAGE_DETAIL_ENHANCER_QUALITY_LEVEL_NONE, + /** A low level of detail enhancement quality but with a fast speed. It's the default level */ + IMAGE_DETAIL_ENHANCER_QUALITY_LEVEL_LOW, + /** A medium level of detail enhancement quality. Its speed is between the low setting and high setting */ + IMAGE_DETAIL_ENHANCER_QUALITY_LEVEL_MEDIUM, + /** A high level of detail enhancement quality but with a relatively slow speed */ + IMAGE_DETAIL_ENHANCER_QUALITY_LEVEL_HIGH, +} ImageDetailEnhancer_QualityLevel; + +/** + * @brief Image processing error code. + * + * @since 12 + */ +typedef enum ImageProcessing_ErrorCode { + /** @error Operation is successful. */ + IMAGE_PROCESSING_SUCCESS, + /** @error Input parameter is invalid. This error is returned for all of the following error conditions: + * 1 - Invalid input or output image buffer - The image buffer is null. + * 2 - Invalid parameter - The parameter is null. + * 3 - Invalid type - The type passed in the create function does not exist. + */ + IMAGE_PROCESSING_ERROR_INVALID_PARAMETER = 401, + /** @error Some unknown error occurred, such as GPU calculation failure or memcpy failure. */ + IMAGE_PROCESSING_ERROR_UNKNOWN = 29200001, + /** @error The global environment initialization for image processing failed, such as failure to initialize + * the GPU environment. + */ + IMAGE_PROCESSING_ERROR_INITIALIZE_FAILED, + /** @error Failed to create image processing instance. For example, + * the number of instances exceeds the upper limit. + */ + IMAGE_PROCESSING_ERROR_CREATE_FAILED, + /** @error Failed to process image buffer. For example, the processing times out. */ + IMAGE_PROCESSING_ERROR_PROCESS_FAILED, + /** @error The processing is not supported. You may call OH_ImageProcessing_IsXXXSupported + * to check whether the capability is supported. + */ + IMAGE_PROCESSING_ERROR_UNSUPPORTED_PROCESSING, + /** @error The operation is not permitted. This may be caused by incorrect status. */ + IMAGE_PROCESSING_ERROR_OPERATION_NOT_PERMITTED, + /** @error Out of memory. */ + IMAGE_PROCESSING_ERROR_NO_MEMORY, + /** @error The image processing instance is invalid. This may be caused by null instance. */ + IMAGE_PROCESSING_ERROR_INVALID_INSTANCE, + /** @error Input value is invalid. This error is returned for all of the following error conditions: + * 1 - Invalid input or output image buffer - The image buffer width(height) + * is too large or colorspace is incorrect. + * 2 - Invalid parameter - The parameter does not contain valid information, + * such as detail enhancer level is incorrect. + */ + IMAGE_PROCESSING_ERROR_INVALID_VALUE +} ImageProcessing_ErrorCode; + +#ifdef __cplusplus +} +#endif + +#endif // VIDEO_PROCESSING_ENGINE_C_API_IMAGE_PROCESSING_TYPES_H +/** @} */ diff --git a/multimedia/video_processing_engine/video_processing.h b/multimedia/video_processing_engine/video_processing.h new file mode 100644 index 0000000000000000000000000000000000000000..7c22782c6d01d5773649fc92243826d753ad495c --- /dev/null +++ b/multimedia/video_processing_engine/video_processing.h @@ -0,0 +1,329 @@ +/* + * 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 VideoProcessing + * @{ + * + * @brief Provide APIs for video quality processing. + * + * @since 12 + */ + +/** + * @file video_processing.h + * + * @brief Declare video processing functions. + * + * Provides SDR content processing for videos, including color space conversion, metadata generation + * and video scaling. + * + * @library libvideo_processing.so + * @syscap SystemCapability.Multimedia.VideoProcessingEngine + * @kit MediaKit + * @since 12 + */ + +#ifndef VIDEO_PROCESSING_ENGINE_C_API_VIDEO_PROCESSING_H +#define VIDEO_PROCESSING_ENGINE_C_API_VIDEO_PROCESSING_H + +#include +#include +#include "video_processing_types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Initialize global environment for video processing. + * + * This function is optional. \n + * Typically, this function is called once when the host process is started to initialize the global environment for + * video processing, which can reduce the time of {@link OH_VideoProcessing_Create}. \n + * To deinitialize global environment, call {@link OH_VideoProcessing_DeinitializeEnvironment}. + * + * @return {@link VIDEO_PROCESSING_SUCCESS} if initialization is successful. \n + * {@link VIDEO_PROCESSING_ERROR_INITIALIZE_FAILED} if initialization is failed. \n + * You can check if the device GPU is working properly. + * @since 12 + */ +VideoProcessing_ErrorCode OH_VideoProcessing_InitializeEnvironment(void); + +/** + * @brief Deinitialize global environment for video processing. + * + * This function is required if {@link OH_VideoProcessing_InitializeEnvironment} is called. Typically, this + * function is called when the host process is about to exit to deinitialize the global environment, which is + * initialized by calling {@link OH_VideoProcessing_InitializeEnvironment}. \n + * If there is some video processing instance existing, this function should not be called. \n + * If the {@link OH_VideoProcessing_InitializeEnvironment} is not called, this function should not be called. + * + * @return {@link VIDEO_PROCESSING_SUCCESS} if deinitialization is successful. \n + * {@link VIDEO_PROCESSING_ERROR_OPERATION_NOT_PERMITTED} if some video processing instance is not destroyed or + * {@link OH_VideoProcessing_InitializeEnvironment} is not called. \n + * @since 12 + */ +VideoProcessing_ErrorCode OH_VideoProcessing_DeinitializeEnvironment(void); + +/** + * @brief Query if the video color space conversion is supported. + * + * @param sourceVideoInfo Source video color space information. + * @param destinationVideoInfo Destination video color space information. + * @return true if the video color space conversion is supported. \n + * false if the video color space conversion is not supported. + * @since 12 + */ +bool OH_VideoProcessing_IsColorSpaceConversionSupported( + const VideoProcessing_ColorSpaceInfo* sourceVideoInfo, + const VideoProcessing_ColorSpaceInfo* destinationVideoInfo); + +/** + * @brief Query if the video metadata generation is supported. + * + * @param sourceVideoInfo Source video color space information. + * @return true if the video metadata generation is supported. \n + * false if the video metadata generation is not supported. + * @since 12 + */ +bool OH_VideoProcessing_IsMetadataGenerationSupported( + const VideoProcessing_ColorSpaceInfo* sourceVideoInfo); + +/** + * @brief Create a video processing instance. + * + * @param videoProcessor Output parameter. The *videoProcessor points to a new video processing object. + * The *videoProcessor must be null before passed in. + * @param type Use VIDEO_PROCESSING_TYPE_XXX to specify the processing type. The processing type of the instance can not + * be changed. + * @return {@link VIDEO_PROCESSING_SUCCESS} if creating a video processing instance successfully. \n + * {@link VIDEO_PROCESSING_ERROR_UNSUPPORTED_PROCESSING} if the type is not supported. For example, if metadata + * generation is not supported by vendor, it returns unsupported processing. \n + * {@link VIDEO_PROCESSING_ERROR_CREATE_FAILED} if failed to create a video processing instance. \n + * {@link VIDEO_PROCESSING_ERROR_INVALID_INSTANCE} if instance is null or *instance is not null. \n + * {@link VIDEO_PROCESSING_ERROR_INVALID_PARAMETER} if type is invalid. + * @since 12 + */ +VideoProcessing_ErrorCode OH_VideoProcessing_Create(OH_VideoProcessing** videoProcessor, int type); + +/** + * @brief Destroy the video processing instance. + * + * Stop the instance before destroying it. see {@link OH_VideoProcessing_Stop}. \n + * + * @param videoProcessor The video processing instance pointer to be destroyed. It is recommended setting the + * instance pointer to null after the instance is destroyed. + * @return {@link VIDEO_PROCESSING_SUCCESS} if the instance is destroyed successfully . \n + * {@link VIDEO_PROCESSING_ERROR_INVALID_INSTANCE} if instance is null or not a video processing instance. \n + * {@link VIDEO_PROCESSING_ERROR_OPERATION_NOT_PERMITTED} if the instance is still running. + * @since 12 + */ +VideoProcessing_ErrorCode OH_VideoProcessing_Destroy(OH_VideoProcessing* videoProcessor); + +/** + * @brief Register callback object. + * + * Register the callback object before starting video processing. + * + * @param videoProcessor A video processing instance pointer. + * @param callback Callback pointer to be registered. + * @param userData User's custom data pointer. + * @return {@link VIDEO_PROCESSING_SUCCESS} if callback is registered successfully. \n + * {@link VIDEO_PROCESSING_ERROR_INVALID_INSTANCE} if instance is null or not a video processing instance. \n + * {@link VIDEO_PROCESSING_ERROR_INVALID_PARAMETER} if callback is null. \n + * {@link VIDEO_PROCESSING_ERROR_OPERATION_NOT_PERMITTED} if video processing instance is running. + * @since 12 + */ +VideoProcessing_ErrorCode OH_VideoProcessing_RegisterCallback(OH_VideoProcessing* videoProcessor, + const VideoProcessing_Callback* callback, void* userData); + +/** + * @brief Set the output surface for video processing. + * + * Set the output surface before starting video processing. + * + * @param videoProcessor A video processing instance pointer. + * @param window The output surface pointer. + * @return {@link VIDEO_PROCESSING_SUCCESS} if setting output surface successfully. \n + * {@link VIDEO_PROCESSING_ERROR_INVALID_INSTANCE} if instance is null or not a video processing instance. \n + * {@link VIDEO_PROCESSING_ERROR_INVALID_PARAMETER} if window is null. + * @since 12 + */ +VideoProcessing_ErrorCode OH_VideoProcessing_SetSurface(OH_VideoProcessing* videoProcessor, + const OHNativeWindow* window); + +/** + * @brief Create an input surface. + * + * Create the input surface before starting video processing. + * Call {@link OH_NativeWindow_DestroyNativeWindow} to destroy the input surface. + * + * @param videoProcessor A video processing instance pointer. + * @param window The input surface pointer. For example, it is the output surface of a video decoder. + * @return {@link VIDEO_PROCESSING_SUCCESS} if operation is successful. \n + * {@link VIDEO_PROCESSING_ERROR_INVALID_INSTANCE} if instance is null or not a video processing instance. \n + * {@link VIDEO_PROCESSING_ERROR_INVALID_PARAMETER} if window is null or *window is not null. \n + * {@link VIDEO_PROCESSING_ERROR_OPERATION_NOT_PERMITTED} if creating surface failed, input surface is already created + * or video processing instance is running. + * @since 12 + */ +VideoProcessing_ErrorCode OH_VideoProcessing_GetSurface(OH_VideoProcessing* videoProcessor, OHNativeWindow** window); + +/** + * @brief Set parameter for video processing. + * + * Add parameter identified by the specified parameter key. + * + * @param videoProcessor An video processing instance pointer. + * @param parameter The parameter for video processing. + * @return {@link VIDEO_PROCESSING_SUCCESS} if setting parameter is successful. \n + * {@link VIDEO_PROCESSING_ERROR_INVALID_INSTANCE} if instance is null or not an video processing instance. \n + * {@link VIDEO_PROCESSING_ERROR_INVALID_PARAMETER} if the parameter is null. \n + * {@link VIDEO_PROCESSING_ERROR_INVALID_VALUE} if some property of the parameter is invalid. For example, the parameter + * contains unsupported parameter key or value. \n + * {@link VIDEO_PROCESSING_ERROR_NO_MEMORY} if memory allocation failed. + * @since 12 + */ +VideoProcessing_ErrorCode OH_VideoProcessing_SetParameter(OH_VideoProcessing* videoProcessor, + const OH_AVFormat* parameter); + +/** + * @brief Get parameter of video processing. + * + * Get parameter identified by the specified parameter key. + * + * @param videoProcessor An video processing instance pointer. + * @param parameter The parameter used by the video processing instance. + * @return {@link VIDEO_PROCESSING_SUCCESS} if getting parameter is successful. \n + * {@link VIDEO_PROCESSING_ERROR_INVALID_INSTANCE} if instance is null or not an video processing instance. \n + * {@link VIDEO_PROCESSING_ERROR_INVALID_PARAMETER} if the parameter is null. \n + * @since 12 + */ +VideoProcessing_ErrorCode OH_VideoProcessing_GetParameter(OH_VideoProcessing* videoProcessor, OH_AVFormat* parameter); + +/** + * @brief Start video processing instance. + * + * After successfully calling this function, the state {@link VIDEO_PROCESSING_STATE_RUNNING} is reported by callback + * function {@link OH_VideoProcessingCallback_OnState}. + * + * @param videoProcessor A video processing instance pointer. + * @return {@link VIDEO_PROCESSING_SUCCESS} if the operation is successful. \n + * {@link VIDEO_PROCESSING_ERROR_INVALID_INSTANCE} if instance is null or not a video processing instance. \n + * {@link VIDEO_PROCESSING_ERROR_OPERATION_NOT_PERMITTED} if output surface is not set, input surface is not created or + * instance is already running. + * @since 12 + */ +VideoProcessing_ErrorCode OH_VideoProcessing_Start(OH_VideoProcessing* videoProcessor); + +/** + * @brief To stop video processing instance. + * + * After the video processing instance is stopped successfully, the state {@link VIDEO_PROCESSING_STATE_STOPPED} is + * reported by callback function {@link OH_VideoProcessing_OnState}. + * + * @param videoProcessor A video processing instance pointer. + * @return {@link VIDEO_PROCESSING_SUCCESS} if the operation is successful. \n + * {@link VIDEO_PROCESSING_ERROR_INVALID_INSTANCE} if instance is null or not a video processing instance. \n + * {@link VIDEO_PROCESSING_ERROR_OPERATION_NOT_PERMITTED} if instance is already stopped. + * @since 12 + */ +VideoProcessing_ErrorCode OH_VideoProcessing_Stop(OH_VideoProcessing* videoProcessor); + +/** + * @brief Send the output buffer out. + * + * If the callback function {@link OH_VideoProcessingCallback_OnNewOutputBuffer} is set, the buffer's index is reported + * to user by the callback function when an output buffer is ready. + * + * @param videoProcessor A video processing instance pointer. + * @param index The output buffer's index. + * @return {@link VIDEO_PROCESSING_SUCCESS} if the operation is successful. \n + * {@link VIDEO_PROCESSING_ERROR_INVALID_INSTANCE} if instance is null or not a video processing instance. \n + * {@link VIDEO_PROCESSING_ERROR_INVALID_PARAMETER} if index is invalid. \n + * {@link VIDEO_PROCESSING_ERROR_OPERATION_NOT_PERMITTED} if callback {@link OH_VideoProcessing_OnNewOutputBuffer} is + * not set or instance is stopped. + * @since 12 + */ +VideoProcessing_ErrorCode OH_VideoProcessing_RenderOutputBuffer(OH_VideoProcessing* videoProcessor, uint32_t index); + +/** + * @brief Create a video processing callback object. + * + * @param callback Output parameter. The *callback points to a new callback object. The *callback should be null before + * creating the callback object. + * @return {@link VIDEO_PROCESSING_SUCCESS} if callback object is created successfully. \n + * {@link VIDEO_PROCESSING_ERROR_INVALID_PARAMETER} if callback is null or *callback is not null. \n + * {@link VIDEO_PROCESSING_ERROR_NO_MEMORY} if out of memory. + * @since 12 + */ +VideoProcessing_ErrorCode OH_VideoProcessingCallback_Create(VideoProcessing_Callback** callback); + +/** + * @brief Destroy the callback object. + * + * The callback object can be destroyed after it is registered to video processing instance. + * + * @param callback The callback object pointer. It is recommended setting the callback pointer to null after the + * callback object is destroyed. + * @return {@link VIDEO_PROCESSING_SUCCESS} if callback is successfully destroyed. \n + * {@link VIDEO_PROCESSING_ERROR_INVALID_PARAMETER} if callback is null. + * @since 12 + */ +VideoProcessing_ErrorCode OH_VideoProcessingCallback_Destroy(VideoProcessing_Callback* callback); + +/** + * @brief Bind the {@link OH_VideoProcessingCallback_OnError} callback function to callback object. + * + * @param callback A callback object pointer. + * @param onError The callback function. + * @return {@link VIDEO_PROCESSING_SUCCESS} if the function is bound to callback object successfully. \n + * {@link VIDEO_PROCESSING_ERROR_INVALID_PARAMETER} if the callback is null or onError is null. + * @since 12 + */ +VideoProcessing_ErrorCode OH_VideoProcessingCallback_BindOnError(VideoProcessing_Callback* callback, + OH_VideoProcessingCallback_OnError onError); + +/** + * @brief Bind the {@link OH_VideoProcessingCallback_OnState} callback function to callback object. + * + * @param callback A callback object pointer. + * @param onState The callback function. + * @return {@link VIDEO_PROCESSING_SUCCESS} if the function is bound to callback object successfully. \n + * {@link VIDEO_PROCESSING_ERROR_INVALID_PARAMETER} if the callback is null or onState is null. + * @since 12 + */ +VideoProcessing_ErrorCode OH_VideoProcessingCallback_BindOnState(VideoProcessing_Callback* callback, + OH_VideoProcessingCallback_OnState onState); + +/** + * @brief Bind the {@link OH_VideoProcessingCallback_OnNewOutputBuffer} callback function to callback object. + * + * @param callback A callback object pointer. + * @param onNewOutputBuffer The callback function. + * @return {@link VIDEO_PROCESSING_SUCCESS} if the function is bound to callback object successfully. \n + * {@link VIDEO_PROCESSING_ERROR_INVALID_PARAMETER} if the callback is null. + * @since 12 + */ +VideoProcessing_ErrorCode OH_VideoProcessingCallback_BindOnNewOutputBuffer(VideoProcessing_Callback* callback, + OH_VideoProcessingCallback_OnNewOutputBuffer onNewOutputBuffer); + +#ifdef __cplusplus +} +#endif + +#endif // VIDEO_PROCESSING_ENGINE_C_API_VIDEO_PROCESSING_H +/** @} */ diff --git a/multimedia/video_processing_engine/video_processing/BUILD.gn b/multimedia/video_processing_engine/video_processing/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..0dc56d02583cefe8084b36cea30c3d8ef7455f0a --- /dev/null +++ b/multimedia/video_processing_engine/video_processing/BUILD.gn @@ -0,0 +1,35 @@ +# 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. + +import("//build/ohos.gni") +import("//build/ohos/ndk/ndk.gni") + +ohos_ndk_headers("video_processing_ndk_headers") { + dest_dir = "$ndk_headers_out_dir/multimedia/video_processing_engine" + sources = [ + "../video_processing.h", + "../video_processing_types.h", + ] +} + +ohos_ndk_library("libvideo_processing_ndk") { + ndk_description_file = "./libvideo_processing.ndk.json" + output_name = "video_processing" + output_extension = "so" + min_compact_version = "12" + system_capability = "SystemCapability.Multimedia.VideoProcessingEngine" + system_capability_headers = [ + "multimedia/video_processing_engine/video_processing_types.h", + "multimedia/video_processing_engine/video_processing.h", + ] +} diff --git a/multimedia/video_processing_engine/video_processing/libvideo_processing.ndk.json b/multimedia/video_processing_engine/video_processing/libvideo_processing.ndk.json new file mode 100644 index 0000000000000000000000000000000000000000..dd2fe35ab8f4213a5d7bb16038f621ffa9c8f74c --- /dev/null +++ b/multimedia/video_processing_engine/video_processing/libvideo_processing.ndk.json @@ -0,0 +1,93 @@ +[ + { + "first_introduced": "12", + "name": "OH_VideoProcessing_InitializeEnvironment" + }, + { + "first_introduced": "12", + "name": "OH_VideoProcessing_DeinitializeEnvironment" + }, + { + "first_introduced": "12", + "name": "OH_VideoProcessing_IsColorSpaceConversionSupported" + }, + { + "first_introduced": "12", + "name": "OH_VideoProcessing_IsMetadataGenerationSupported" + }, + { + "first_introduced": "12", + "name": "OH_VideoProcessing_Create" + }, + { + "first_introduced": "12", + "name": "OH_VideoProcessing_Destroy" + }, + { + "first_introduced": "12", + "name": "OH_VideoProcessing_RegisterCallback" + }, + { + "first_introduced": "12", + "name": "OH_VideoProcessing_SetSurface" + }, + { + "first_introduced": "12", + "name": "OH_VideoProcessing_GetSurface" + }, + { + "first_introduced": "12", + "name": "OH_VideoProcessing_SetParameter" + }, + { + "first_introduced": "12", + "name": "OH_VideoProcessing_GetParameter" + }, + { + "first_introduced": "12", + "name": "OH_VideoProcessing_Start" + }, + { + "first_introduced": "12", + "name": "OH_VideoProcessing_Stop" + }, + { + "first_introduced": "12", + "name": "OH_VideoProcessing_RenderOutputBuffer" + }, + { + "first_introduced": "12", + "name": "OH_VideoProcessingCallback_Create" + }, + { + "first_introduced": "12", + "name": "OH_VideoProcessingCallback_Destroy" + }, + { + "first_introduced": "12", + "name": "OH_VideoProcessingCallback_BindOnError" + }, + { + "first_introduced": "12", + "name": "OH_VideoProcessingCallback_BindOnState" + }, + { + "first_introduced": "12", + "name": "OH_VideoProcessingCallback_BindOnNewOutputBuffer" + }, + { + "first_introduced": "12", + "name": "VIDEO_PROCESSING_TYPE_COLOR_SPACE_CONVERSION", + "type": "variable" + }, + { + "first_introduced": "12", + "name": "VIDEO_PROCESSING_TYPE_METADATA_GENERATION", + "type": "variable" + }, + { + "first_introduced": "12", + "name": "VIDEO_PROCESSING_TYPE_DETAIL_ENHANCER", + "type": "variable" + } +] diff --git a/multimedia/video_processing_engine/video_processing_types.h b/multimedia/video_processing_engine/video_processing_types.h new file mode 100644 index 0000000000000000000000000000000000000000..d863e2cf37bcc7c1a1bf3c3dcd78bccf7d1c6d7a --- /dev/null +++ b/multimedia/video_processing_engine/video_processing_types.h @@ -0,0 +1,278 @@ +/* + * 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 VideoProcessing + * @{ + * + * @brief Provide video processing including color space conversion and metadata generation. + * + * @since 12 + */ + +/** + * @file video_processing_types.h + * + * @brief Type definitions for video processing. + * + * @library libvideo_processing.so + * @syscap SystemCapability.Multimedia.VideoProcessingEngine + * @kit MediaKit + * @since 12 + */ + +#ifndef VIDEO_PROCESSING_ENGINE_C_API_VIDEO_PROCESSING_TYPES_H +#define VIDEO_PROCESSING_ENGINE_C_API_VIDEO_PROCESSING_TYPES_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Define the video processing object. + * + * Define a null pointer of OH_VideoProcessing and call {@link OH_VideoProcessing_Create} to create a video processing + * instance. The pointer should be null before creating instance. + * User can create multiple video processing instances for different processing types. + * + * @since 12 + */ +typedef struct OH_VideoProcessing OH_VideoProcessing; + +/** + * @brief Forward declaration of NativeWindow. + * + * @since 12 + */ +typedef struct NativeWindow OHNativeWindow; + +/** + * @brief Forward declaration of OH_AVFormat. + * + * @since 12 + */ +typedef struct OH_AVFormat OH_AVFormat; + +/** + * @brief Used to create a video processing instance for color space conversion. + * + * Some capabilities are supported by vendor. Use {@link OH_VideoProcessing_IsColorSpaceConversionSupported} to query if + * the conversion is supported. + * + * @see OH_VideoProcessing_Create + * @since 12 + */ +extern const int32_t VIDEO_PROCESSING_TYPE_COLOR_SPACE_CONVERSION; + +/** + * @brief Used to create a video processing instance for metadata generation. + * + * Generate HDR vivid metadata for video. The capability is supported by vendor. If the capability is not supported, + * {@link OH_VideoProcessing_Create} returns {@link VIDEO_PROCESSING_ERROR_UNSUPPORTED_PROCESSING}. + * + * @see OH_VideoProcessing_Create + * @since 12 + */ +extern const int32_t VIDEO_PROCESSING_TYPE_METADATA_GENERATION; + +/** + * @brief Used to create an video processing instance of detail enhancement. + * + * Scale or resize video with the specified quality or just enhance details for rendering without changing its + * resolution. + * + * @see OH_ImageProcessing_Create + * @since 12 + */ +extern const int32_t VIDEO_PROCESSING_TYPE_DETAIL_ENHANCER; + +/** + * @brief The key is used to specify the quality level for video detail enhancement. + * + * See {@link VideoDetailEnhancer_QualityLevel} for its values. + * Use {@link OH_VideoProcessing_SetParameter} to set the quality level. + * Use {@link OH_VideoProcessing_GetParameter} to get the current quality level. + * + * @see OH_VideoProcessing_SetParameter + * @see OH_VideoProcessing_GetParameter + * @since 12 + */ +extern const char* VIDEO_DETAIL_ENHANCER_PARAMETER_KEY_QUALITY_LEVEL; + +/** + * @brief Video color space information structure of querying if video color space conversion is supported. + * + * @see OH_VideoProcessing_IsColorSpaceConversionSupported + * @since 12 + */ +typedef struct VideoProcessing_ColorSpaceInfo { + /** The metadata type of the video, see {@link enum OH_NativeBuffer_MetadataType} */ + int32_t metadataType; + /** The color space type of the video, see {@link enum OH_NativeBuffer_ColorSpace} */ + int32_t colorSpace; + /** The pixel format of the video, see {@link enum OH_NativeBuffer_Format} */ + int32_t pixelFormat; +} VideoProcessing_ColorSpaceInfo; + +/** + * @brief The quality level is used for detail enhancement. + * + * It is the value of the key parameter {@link VIDEO_DETAIL_ENHANCER_PARAMETER_KEY_QUALITY_LEVEL}. + * + * @see OH_VideoProcessing_SetParameter + * @see OH_VideoProcessing_GetParameter + * @since 12 + */ +typedef enum VideoDetailEnhancer_QualityLevel { + /** No detail enhancement */ + VIDEO_DETAIL_ENHANCER_QUALITY_LEVEL_NONE, + /** A low level of detail enhancement quality but with a fast speed. It's the default level */ + VIDEO_DETAIL_ENHANCER_QUALITY_LEVEL_LOW, + /** A medium level of detail enhancement quality. Its speed is between the low setting and high setting */ + VIDEO_DETAIL_ENHANCER_QUALITY_LEVEL_MEDIUM, + /** A high level of detail enhancement quality but with a relatively slow speed */ + VIDEO_DETAIL_ENHANCER_QUALITY_LEVEL_HIGH, +} VideoDetailEnhancer_QualityLevel; + +/** + * @brief Video processing error code. + * + * @since 12 + */ +typedef enum VideoProcessing_ErrorCode { + /** @error Operation is successful. */ + VIDEO_PROCESSING_SUCCESS, + /** @error Input parameter is invalid. This error is returned for all of the following error conditions: + * 1 - Invalid input or output video buffer - The video buffer is null. + * 2 - Invalid parameter - The parameter is null. + * 3 - Invalid type - The type passed in the create function does not exist. + */ + VIDEO_PROCESSING_ERROR_INVALID_PARAMETER = 401, + /** @error Some unknown error occurred, such as GPU calculation failure or memcpy failure. */ + VIDEO_PROCESSING_ERROR_UNKNOWN = 29210001, + /** @error The global environment initialization for video processing failed, such as failure to initialize + * the GPU environment. + */ + VIDEO_PROCESSING_ERROR_INITIALIZE_FAILED, + /** @error Failed to create video processing instance. For example, + * the number of instances exceeds the upper limit. + */ + VIDEO_PROCESSING_ERROR_CREATE_FAILED, + /** @error Failed to process video buffer. For example, the processing times out. */ + VIDEO_PROCESSING_ERROR_PROCESS_FAILED, + /** @error The processing is not supported. You may call OH_VideoProcessing_IsXXXSupported + * to check whether the capability is supported. + */ + VIDEO_PROCESSING_ERROR_UNSUPPORTED_PROCESSING, + /** @error The operation is not permitted. This may be caused by incorrect status. */ + VIDEO_PROCESSING_ERROR_OPERATION_NOT_PERMITTED, + /** @error Out of memory. */ + VIDEO_PROCESSING_ERROR_NO_MEMORY, + /** @error The video processing instance is invalid. This may be caused by null instance. */ + VIDEO_PROCESSING_ERROR_INVALID_INSTANCE, + /** @error Input value is invalid. This error is returned for all of the following error conditions: + * 1 - Invalid input or output video buffer - The video buffer width(height) + * is too large or colorspace is incorrect. + * 2 - Invalid parameter - The parameter does not contain valid information, + * such as detail enhancer level is incorrect. + */ + VIDEO_PROCESSING_ERROR_INVALID_VALUE +} VideoProcessing_ErrorCode; + +/** + * @brief Video processing states. + * + * The state is reported to user by callback function {@link OH_VideoProcessing_OnState}. + * + * @since 12 + */ +typedef enum VideoProcessing_State { + /** Video processing is running */ + VIDEO_PROCESSING_STATE_RUNNING, + /** Video processing is stopped */ + VIDEO_PROCESSING_STATE_STOPPED +} VideoProcessing_State; + +/** + * @brief Video processing asynchronous callback object type. + * + * Define a null pointer of VideoProcessing_Callback and call {@link OH_VideoProcessingCallback_Create} to create a + * callback object. The pointer should be null before creating the callback object. + * Register the callback to a video processing instance by calling {@link OH_VideoProcessing_RegisterCallback}. + * + * @since 12 + */ +typedef struct VideoProcessing_Callback VideoProcessing_Callback; + +/** + * @brief The callback function pointer definition for reporting error during video processing. + * + * Errors: \n + * {@link VIDEO_PROCESSING_ERROR_UNSUPPORTED_PROCESSING}, the processing is not supported. For example, the + * color space conversion according to the source and destination videos' properties is not supported. \n + * {@link VIDEO_PROCESSING_ERROR_INVALID_VALUE}, some property of the video is invalid. For example, the color space of + * the video is invalid. \n + * {@link VIDEO_PROCESSING_ERROR_NO_MEMORY}, out of memory. \n + * {@link VIDEO_PROCESSING_ERROR_PROCESS_FAILED}, some processing error occurs. \n + * For more errors, see {@link VideoProcessing_ErrorCode}. + * + * @param videoProcessor The video processing instance. + * @param error Error code reporting to user. + * @param userData User's custom data. + * @since 12 + */ +typedef void (*OH_VideoProcessingCallback_OnError)(OH_VideoProcessing* videoProcessor, + VideoProcessing_ErrorCode error, void* userData); + +/** + * @brief The callback function pointer definition for reporting video processing state. + * + * The state will be {@link VIDEO_PROCESSING_STATE_RUNNING} after {@link OH_VideoProcessing_Start} is called + * successfully. + * The state will be {@link VIDEO_PROCESSING_STATE_STOPPED} after all the buffers cached before + * {@link OH_VideoProcessing_Stop} is called are processed. + * + * @param videoProcessor The video processing instance. + * @param state see {@link VideoProcessing_State}. + * @param userData User's custom data. + * @since 12 + */ +typedef void (*OH_VideoProcessingCallback_OnState)(OH_VideoProcessing* videoProcessor, VideoProcessing_State state, + void* userData); + +/** + * @brief The callback function pointer definition for reporting a new output buffer is filled with processed data. + * + * Every new output buffer's index will report to user once the buffer is filled with processed data. Then call + * {@link OH_VideoProcessing_RenderOutputBuffer} with the buffer's index to send the output buffer out. + * If this function is not registered, the output buffer is sent out as soon as the buffer is filled with processed + * data without reporting. + * + * @param videoProcessor The video processing instance. + * @param index The index of the new output buffer. + * @param userData The user's custom data. + * @since 12 + */ +typedef void (*OH_VideoProcessingCallback_OnNewOutputBuffer)(OH_VideoProcessing* videoProcessor, uint32_t index, + void* userData); + +#ifdef __cplusplus +} +#endif + +#endif // VIDEO_PROCESSING_ENGINE_C_API_VIDEO_PROCESSING_TYPES_H +/** @} */ diff --git a/multimodalinput/kits/c/BUILD.gn b/multimodalinput/kits/c/BUILD.gn index 60f919ab132fe57ba9c3cdaf305e7f899264baff..1d53eb37c3208cc6c0570224f2ca4199d33616fd 100644 --- a/multimodalinput/kits/c/BUILD.gn +++ b/multimodalinput/kits/c/BUILD.gn @@ -18,6 +18,7 @@ import("//foundation/multimodalinput/input/multimodalinput_mini.gni") ohos_ndk_headers("ohinput_header") { dest_dir = "$ndk_headers_out_dir/multimodalinput" sources = [ + "./input/oh_axis_type.h", "./input/oh_input_manager.h", "./input/oh_key_code.h", ] @@ -29,6 +30,7 @@ ohos_ndk_library("libohinput_ndk") { ndk_description_file = "./ohinput.ndk.json" system_capability = "SystemCapability.MultimodalInput.Input.Core" system_capability_headers = [ + "multimodalinput/oh_axis_type.h", "multimodalinput/oh_input_manager.h", "multimodalinput/oh_key_code.h", ] diff --git a/multimodalinput/kits/c/input/oh_axis_type.h b/multimodalinput/kits/c/input/oh_axis_type.h new file mode 100644 index 0000000000000000000000000000000000000000..de141042d511c42e2db39f9958e409759985c5be --- /dev/null +++ b/multimodalinput/kits/c/input/oh_axis_type.h @@ -0,0 +1,144 @@ +/* + * 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 input + * @{ + * + * @brief Provides the C interface in the multi-modal input domain. + * + * @since 12 + */ + +/** + * @file oh_axis_type.h + * + * @brief Defines the axis event-specific structure and enumerations. + * @kit InputKit + * @syscap SystemCapability.MultimodalInput.Input.Core + * @library liboh_input.so + * @since 12 + */ + +#ifndef OH_AXIS_TYPE_H +#define OH_AXIS_TYPE_H + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Enumerates axis types. + * + * @since 12 + */ +typedef enum InputEvent_AxisType { + /** + * Indicates an unknown axis type. It is generally used as the initial value. + * + * @since 12 + */ + AXIS_TYPE_UNKNOWN, + + /** + * Indicates the vertical scroll axis. When you scroll the mouse wheel or make certain gestures on the touchpad, + * the status of the vertical scroll axis changes. + * + * @since 12 + */ + AXIS_TYPE_SCROLL_VERTICAL, + + /** + * Indicates the horizontal scroll axis. + * When you scroll the mouse wheel or make certain gestures on the touchpad, + * the status of the horizontal scroll axis changes. + * + * @since 12 + */ + AXIS_TYPE_SCROLL_HORIZONTAL, + + /** + * Indicates the pinch axis, which is used to describe a pinch gesture on the touchscreen or touchpad. + * + * @since 12 + */ + AXIS_TYPE_PINCH, + + /** + * Indicates the rotate axis, which is used to describe a rotate gesture on the touchpad. + * + * @since 12 + */ + AXIS_TYPE_ROTATE +} InputEvent_AxisType; + +/** + * @brief Enumerates axis event types. + * + * @since 12 + */ +typedef enum InputEvent_AxisEventType { + /** + * @brief Enumerates two-finger pinch events. The axis value can be AXIS_TYPE_PINCH or AXIS_TYPE_ROTATE. + * + * @since 12 + */ + AXIS_EVENT_TYPE_PINCH = 1, + /** + * @brief Enumerates scroll axis events. + * The axis value can be AXIS_TYPE_SCROLL_VERTICAL or AXIS_TYPE_SCROLL_HORIZONTAL. + * Wherein, the value of AXIS_TYPE_SCROLL_HORIZONTAL is 0 for a mouse wheel event. + * + * @since 12 + */ + AXIS_EVENT_TYPE_SCROLL = 2 +} InputEvent_AxisEventType; + +/** + * @brief Enumerates axis event actions. + * + * @since 12 + */ +typedef enum InputEvent_AxisAction { + /** + * Cancel action for the axis input event. + * + * @since 12 + */ + AXIS_ACTION_CANCEL = 0, + /** + * Start action for the axis input event. + * + * @since 12 + */ + AXIS_ACTION_BEGIN, + /** + * Update action for the axis input event. + * + * @since 12 + */ + AXIS_ACTION_UPDATE, + /** + * End action for the axis input event. + * + * @since 12 + */ + AXIS_ACTION_END, +} InputEvent_AxisAction; +#ifdef __cplusplus +} +#endif +/** @} */ +#endif \ No newline at end of file diff --git a/multimodalinput/kits/c/input/oh_input_manager.h b/multimodalinput/kits/c/input/oh_input_manager.h index 7506a28f9f85bc13507c452b224163cd1e88a31c..1e6c0dd85afc42c31ebb31b98521aa37e26ba92c 100644 --- a/multimodalinput/kits/c/input/oh_input_manager.h +++ b/multimodalinput/kits/c/input/oh_input_manager.h @@ -37,6 +37,7 @@ #include +#include "oh_axis_type.h" #include "oh_key_code.h" #ifdef __cplusplus @@ -48,7 +49,7 @@ extern "C" { * * @since 12 */ -enum Input_KeyStateAction { +typedef enum Input_KeyStateAction { /** Default */ KEY_DEFAULT = -1, /** Pressing of a key */ @@ -59,14 +60,14 @@ enum Input_KeyStateAction { KEY_SWITCH_ON = 2, /** Key switch disabled */ KEY_SWITCH_OFF = 3 -}; +} Input_KeyStateAction; /** * @brief Enumerates key event types. * * @since 12 */ -typedef enum { +typedef enum Input_KeyEventAction { /** Cancellation of a key action. */ KEY_ACTION_CANCEL = 0, /** Pressing of a key. */ @@ -80,7 +81,7 @@ typedef enum { * * @since 12 */ -typedef enum { +typedef enum Input_MouseEventAction { /** Cancel. */ MOUSE_ACTION_CANCEL = 0, /** Moving of the mouse pointer. */ @@ -102,19 +103,19 @@ typedef enum { * * @since 12 */ -enum InputEvent_MouseAxis { +typedef enum InputEvent_MouseAxis { /** Vertical scroll axis */ MOUSE_AXIS_SCROLL_VERTICAL = 0, /** Horizontal scroll axis */ MOUSE_AXIS_SCROLL_HORIZONTAL = 1, -}; +} InputEvent_MouseAxis; /** * @brief Enumerated values of mouse event button. * * @since 12 */ -typedef enum { +typedef enum Input_MouseEventButton { /** Invalid button */ MOUSE_BUTTON_NONE = -1, /** Left button on the mouse. */ @@ -134,7 +135,7 @@ typedef enum { * * @since 12 */ -typedef enum { +typedef enum Input_TouchEventAction { /** Touch cancelled. */ TOUCH_ACTION_CANCEL = 0, /** Touch pressed. */ @@ -145,56 +146,147 @@ typedef enum { TOUCH_ACTION_UP = 3, } Input_TouchEventAction; +/** + * @brief Enumerates event source types. + * + * @since 12 + */ +typedef enum InputEvent_SourceType { + /** + * Indicates that the input source generates events similar to mouse cursor movement, + * button press and release, and wheel scrolling. + * + * @since 12 + */ + SOURCE_TYPE_MOUSE = 1, + /** + * Indicates that the input source generates a touchscreen multi-touch event. + * + * @since 12 + */ + SOURCE_TYPE_TOUCHSCREEN = 2, + /** + * Indicates that the input source generates a touchpad multi-touch event. + * + * @since 12 + */ + SOURCE_TYPE_TOUCHPAD = 3 +} InputEvent_SourceType; + /** * @brief Defines key information, which identifies a key pressing behavior. For example, the Ctrl key information contains the key value and key type. * * @since 12 */ -struct Input_KeyState; +typedef struct Input_KeyState Input_KeyState; /** * @brief The key event to be injected. * * @since 12 */ -struct Input_KeyEvent; +typedef struct Input_KeyEvent Input_KeyEvent; /** * @brief The mouse event to be injected. * * @since 12 */ -struct Input_MouseEvent; +typedef struct Input_MouseEvent Input_MouseEvent; /** * @brief The touch event to be injected. * * @since 12 */ -struct Input_TouchEvent; +typedef struct Input_TouchEvent Input_TouchEvent; /** - * @brief Enumerates the error codes. + * @brief Enumerates axis events. * * @since 12 */ -typedef enum { - /** @error Success return code on sucess*/ +typedef struct Input_AxisEvent Input_AxisEvent; + +/** + * @brief Enumerates error codes. + * + * @since 12 + */ +typedef enum Input_Result { + /** @error Success return code on success*/ INPUT_SUCCESS = 0, /** @error Permission verification failed */ INPUT_PERMISSION_DENIED = 201, /** @error Non-system application */ INPUT_NOT_SYSTEM_APPLICATION = 202, /** @error Parameter check failed */ - INPUT_PARAMETER_ERROR = 401 + INPUT_PARAMETER_ERROR = 401, + /** @error Service error */ + INPUT_SERVICE_EXCEPTION = 3800001, + /** @error Interceptor repeatedly created for an application */ + INPUT_REPEAT_INTERCEPTOR = 4200001 } Input_Result; +/** + * @brief Defines a lifecycle callback for keyEvent. If the callback is triggered, keyEvent will be destroyed. + * + * @param keyEvent Key event object. + * @since 12 + */ +typedef void (*Input_KeyEventCallback)(const Input_KeyEvent* keyEvent); + +/** + * @brief Defines a lifecycle callback for mouseEvent. If the callback is triggered, mouseEvent will be destroyed. + * + * @param mouseEvent Mouse event object. + * @since 12 + */ +typedef void (*Input_MouseEventCallback)(const Input_MouseEvent* mouseEvent); + +/** + * @brief Defines a lifecycle callback for touchEvent. If the callback is triggered, touchEvent will be destroyed. + * + * @param touchEvent Touch event object. + * @since 12 + */ +typedef void (*Input_TouchEventCallback)(const Input_TouchEvent* touchEvent); + +/** + * @brief Defines a lifecycle callback for axisEvent. If the callback is triggered, axisEvent will be destroyed. + * + * @param axisEvent Axis event object. + * @since 12 + */ +typedef void (*Input_AxisEventCallback)(const Input_AxisEvent* axisEvent); + +/** + * @brief Defines the structure for the interceptor of event callbacks, + * including mouseCallback, touchCallback, and axisCallback. + * + * @since 12 + */ +typedef struct Input_InterceptorEventCallback { + /** Defines a lifecycle callback for **mouseEvent**. */ + Input_MouseEventCallback mouseCallback; + /** Defines a lifecycle callback for **touchEvent**. */ + Input_TouchEventCallback touchCallback; + /** Defines a lifecycle callback for **axisEvent**. */ + Input_AxisEventCallback axisCallback; +} Input_InterceptorEventCallback; + +/** + * @brief Defines event interceptor options. + * @since 12 + */ +typedef struct Input_InterceptorOptions Input_InterceptorOptions; + /** * @brief Queries the key state. * * @param keyState Key state. * @return OH_Input_GetKeyState function result code. - * {@link INPUT_SUCCESS} get KeyState sucess.\n + * {@link INPUT_SUCCESS} get KeyState success.\n * {@link INPUT_PARAMETER_ERROR} keyCode is invalid.\n * @syscap SystemCapability.MultimodalInput.Input.Core * @since 12 @@ -285,7 +377,7 @@ int32_t OH_Input_GetKeySwitch(const struct Input_KeyState* keyState); * * @param keyEvent - the key event to be injected. * @return OH_Input_InjectKeyEvent function result code. - * {@link INPUT_SUCCESS} inject keyEvent sucess.\n + * {@link INPUT_SUCCESS} inject keyEvent success.\n * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n * {@link INPUT_PARAMETER_ERROR} keyCode is less 0, can not process.\n * @syscap SystemCapability.MultimodalInput.Input.Core @@ -377,7 +469,7 @@ int64_t OH_Input_GetKeyEventActionTime(const struct Input_KeyEvent* keyEvent); * * @param mouseEvent - the mouse event to be injected. * @return OH_Input_InjectMouseEvent function result code. - * {@link INPUT_SUCCESS} inject mouseEvent sucess.\n + * {@link INPUT_SUCCESS} inject mouseEvent success.\n * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n * {@link INPUT_PARAMETER_ERROR} Parameter check failed.\n * @syscap SystemCapability.MultimodalInput.Input.Core @@ -508,7 +600,8 @@ int32_t OH_Input_GetMouseEventAxisType(const struct Input_MouseEvent* mouseEvent * @brief Sets the axis value for a mouse axis event. * * @param mouseEvent Mouse event object. - * @param axisType Axis value. A positive value means scrolling forward, and a negative number means scrolling backward. + * @param axisType Axis value. A positive value means scrolling forward, + * and a negative number means scrolling backward. * @syscap SystemCapability.MultimodalInput.Input.Core * @since 12 */ @@ -549,7 +642,7 @@ int64_t OH_Input_GetMouseEventActionTime(const struct Input_MouseEvent* mouseEve * * @param touchEvent - the touch event to be injected. * @return OH_Input_InjectTouchEvent function result code. - * {@link INPUT_SUCCESS} inject touchEvent sucess.\n + * {@link INPUT_SUCCESS} inject touchEvent success.\n * {@link INPUT_PARAMETER_ERROR} Parameter check failed.\n * @syscap SystemCapability.MultimodalInput.Input.Core * @since 12 @@ -683,6 +776,431 @@ int64_t OH_Input_GetTouchEventActionTime(const struct Input_TouchEvent* touchEve */ void OH_Input_CancelInjection(); +/** + * @brief Creates an axis event object. + * + * @return If the operation is successful, a {@Link Input_AxisEvent} object is returned. + * If the operation fails, null is returned. + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_AxisEvent* OH_Input_CreateAxisEvent(void); + +/** + * @brief Destroys an axis event object. + * + * @param axisEvent Pointer to the axis event object. + * @return OH_Input_DestroyAxisEvent function result code. + * {@link INPUT_SUCCESS} Destroys axisEvent success.\n + * {@link INPUT_PARAMETER_ERROR}The axisEvent is NULL or the *axisEvent is NULL.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_Result OH_Input_DestroyAxisEvent(Input_AxisEvent** axisEvent); + +/** + * @brief Sets the axis event action. + * + * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}. + * @param action Axis event action. The values are defined in {@link InputEvent_AxisAction}. + * @return OH_Input_SetAxisEventAction function result code. + * {@link INPUT_SUCCESS} Sets the axis event action success.\n + * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_Result OH_Input_SetAxisEventAction(Input_AxisEvent* axisEvent, InputEvent_AxisAction action); + +/** + * @brief Obtains the axis event action. + * + * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}. + * @param action Axis event action. The values are defined in {@link InputEvent_AxisAction}. + * @return OH_Input_GetAxisEventAction function result code. + * {@link INPUT_SUCCESS} Obtains the axis event action success.\n + * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL or the action is NULL.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_Result OH_Input_GetAxisEventAction(const Input_AxisEvent* axisEvent, InputEvent_AxisAction *action); + +/** + * @brief Sets the X coordinate of an axis event. + * + * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}. + * @param displayX X coordinate of the axis event. + * @return OH_Input_SetAxisEventDisplayX function result code. + * {@link INPUT_SUCCESS} Sets the X coordinate of the axis event success.\n + * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_Result OH_Input_SetAxisEventDisplayX(Input_AxisEvent* axisEvent, float displayX); + +/** + * @brief Obtains the X coordinate of an axis event. + * + * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}. + * @param displayX X coordinate of the axis event. + * @return OH_Input_GetAxisEventDisplayX function result code. + * {@link INPUT_SUCCESS} Obtains the X coordinate of the axis event success.\n + * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL or the displayX is NULL.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_Result OH_Input_GetAxisEventDisplayX(const Input_AxisEvent* axisEvent, float* displayX); + +/** + * @brief Sets the Y coordinate of an axis event. + * + * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}. + * @param displayY Y coordinate of the axis event. + * @return OH_Input_SetAxisEventDisplayY function result code. + * {@link INPUT_SUCCESS} Sets the Y coordinate of the axis event success.\n + * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_Result OH_Input_SetAxisEventDisplayY(Input_AxisEvent* axisEvent, float displayY); + +/** + * @brief Obtains the Y coordinate of an axis event. + * + * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}. + * @param displayY Y coordinate of the axis event. + * @return OH_Input_GetAxisEventDisplayY function result code. + * {@link INPUT_SUCCESS} Obtains the Y coordinate of the axis event success.\n + * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL or the displayY is NULL.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_Result OH_Input_GetAxisEventDisplayY(const Input_AxisEvent* axisEvent, float* displayY); + +/** + * @brief Sets the axis value of the axis type specified by the axis event. + * + * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}. + * @param axisType Axis type. The values are defined in {@link InputEvent_AxisType}. + * @param axisValue Axis value. + * @return OH_Input_SetAxisEventAxisValue function result code. + * {@link INPUT_SUCCESS} Sets the axis value of the axis event success.\n + * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_Result OH_Input_SetAxisEventAxisValue(Input_AxisEvent* axisEvent, + InputEvent_AxisType axisType, double axisValue); + +/** + * @brief Obtains the axis value for the specified axis type of the axis event. + * + * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}. + * @param axisType Axis type. The values are defined in {@link InputEvent_AxisType}. + * @param axisValue Axis value. + * @return OH_Input_GetAxisEventAxisValue function result code. + * {@link INPUT_SUCCESS} Obtains the axis value of the axis event success.\n + * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL or the axisValue is NULL, + * or the axisType not found in the axisEvent.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_Result OH_Input_GetAxisEventAxisValue(const Input_AxisEvent* axisEvent, + InputEvent_AxisType axisType, double* axisValue); + +/** + * @brief Sets the time when an axis event occurs. + * + * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}. + * @param actionTime Time when an axis event occurs. + * @return OH_Input_SetAxisEventActionTime function result code. + * {@link INPUT_SUCCESS} Sets the time when an axis event occurs success.\n + * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_Result OH_Input_SetAxisEventActionTime(Input_AxisEvent* axisEvent, int64_t actionTime); + +/** + * @brief Obtains the time when an axis event occurs. + * + * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}. + * @param actionTime Time when an axis event occurs. + * @return OH_Input_GetAxisEventActionTime function result code. + * {@link INPUT_SUCCESS} Obtains the time when an axis event occurs success.\n + * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL or the actionTime is NULL.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_Result OH_Input_GetAxisEventActionTime(const Input_AxisEvent* axisEvent, int64_t* actionTime); + +/** + * @brief Sets the axis event type. + * + * @param axisEvent Axis event object. For details, see {@Link Input_AxisEvent}. + * @param axisEventType Axis event type. The values are defined in {@link InputEvent_AxisEventType}. + * @return OH_Input_SetAxisEventType function result code. + * {@link INPUT_SUCCESS} Sets the axis event type success.\n + * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_Result OH_Input_SetAxisEventType(Input_AxisEvent* axisEvent, InputEvent_AxisEventType axisEventType); + +/** + * @brief Obtains the axis event type. + * + * @param axisEvent Axis event object. + * @param axisEventType Axis event type. The values are defined in {@link InputEvent_AxisEventType}. + * @return OH_Input_GetAxisEventType function result code. + * {@link INPUT_SUCCESS} Obtains the axis event type success.\n + * {@Link INPUT_PARAMETER_ERROR} The axisEvent is NULL or the axisEventType is NULL.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_Result OH_Input_GetAxisEventType(const Input_AxisEvent* axisEvent, InputEvent_AxisEventType* axisEventType); + +/** + * @brief Sets the axis event source type. + * + * @param axisEvent Axis event object. + * @param sourceType Axis event source type. The values are defined in {@link InputEvent_SourceType}. + * @return OH_Input_SetAxisEventSourceType function result code. + * {@link INPUT_SUCCESS} Sets the axis event source type success.\n + * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_Result OH_Input_SetAxisEventSourceType(Input_AxisEvent* axisEvent, InputEvent_SourceType sourceType); + +/** + * @brief Obtains the axis event source type. + * + * @param axisEvent Axis event object. + * @param axisEventType Axis event source type. The values are defined in {@link InputEvent_SourceType}. + * @return OH_Input_GetAxisEventSourceType function result code. + * {@link INPUT_SUCCESS} Obtains the axis event source type success.\n + * {@link INPUT_PARAMETER_ERROR} The axisEvent is NULL or the sourceType is NULL.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_Result OH_Input_GetAxisEventSourceType(const Input_AxisEvent* axisEvent, InputEvent_SourceType* sourceType); + +/** + * @brief Adds a listener of key events. + * + * @permission ohos.permission.INPUT_MONITORING + * @param callback - Callback used to receive key events. + * @return OH_Input_AddKeyEventMonitor function result code. + * {@link INPUT_SUCCESS} Adds a listener of key events success.\n + * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n + * {@link INPUT_PARAMETER_ERROR} The callback is NULL.\n + * {@link INPUT_SERVICE_EXCEPTION} Failed to add the monitor because the service is exception.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_Result OH_Input_AddKeyEventMonitor(Input_KeyEventCallback callback); + +/** + * @brief Adds a listener for mouse events, including mouse click and movement events, + * but not scroll wheel events. Scroll wheel events are axis events. + * + * @permission ohos.permission.INPUT_MONITORING + * @param callback - Callback used to receive mouse events. + * @return OH_Input_AddMouseEventMonitor function result code. + * {@link INPUT_SUCCESS} Adds a listener of mouse events success.\n + * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n + * {@link INPUT_PARAMETER_ERROR} The callback is NULL.\n + * {@link INPUT_SERVICE_EXCEPTION} Failed to add the monitor because the service is exception.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_Result OH_Input_AddMouseEventMonitor(Input_MouseEventCallback callback); + +/** + * @brief Add a listener for touch events. + * + * @permission ohos.permission.INPUT_MONITORING + * @param callback - Callback used to receive touch events. + * @return OH_Input_AddTouchEventMonitor function result code. + * {@link INPUT_SUCCESS} Adds a listener of touch events success.\n + * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n + * {@link INPUT_PARAMETER_ERROR} The callback is NULL.\n + * {@link INPUT_SERVICE_EXCEPTION} Failed to add the monitor because the service is exception.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_Result OH_Input_AddTouchEventMonitor(Input_TouchEventCallback callback); + +/** + * @brief Adds a listener for all types of axis events. + * The axis event types are defined in {@Link InputEvent_AxisEventType}. + * + * @permission ohos.permission.INPUT_MONITORING + * @param callback - Callback used to receive axis events. + * @return OH_Input_AddAxisEventMonitorForAll function result code. + * {@link INPUT_SUCCESS} Adds a listener for all types of axis events success.\n + * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n + * {@link INPUT_PARAMETER_ERROR} The callback is NULL.\n + * {@link INPUT_SERVICE_EXCEPTION} Failed to add the monitor because the service is exception.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_Result OH_Input_AddAxisEventMonitorForAll(Input_AxisEventCallback callback); + +/** + * @brief Adds a listener for the specified type of axis events. + * + * @permission ohos.permission.INPUT_MONITORING + * @param axisEventType - Axis event type. The values are defined in {@Link InputEvent_AxisEventType}. + * @param callback - Callback used to receive the specified type of axis events. + * @return OH_Input_AddAxisEventMonitor function result code. + * {@link INPUT_SUCCESS} Adds a listener for the specified types of axis events success.\n + * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n + * {@link INPUT_PARAMETER_ERROR} The callback is NULL.\n + * {@link INPUT_SERVICE_EXCEPTION} Failed to add the monitor because the service is exception.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_Result OH_Input_AddAxisEventMonitor(InputEvent_AxisEventType axisEventType, Input_AxisEventCallback callback); + +/** + * @brief Removes a key event listener. + * + * @permission ohos.permission.INPUT_MONITORING + * @param callback - Callback for the key event listener. + * @return OH_Input_RemoveKeyEventMonitor function result code. + * {@link INPUT_SUCCESS} Removes a key event listener success.\n + * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n + * {@link INPUT_PARAMETER_ERROR} The callback is NULL or has not been added.\n + * {@link INPUT_SERVICE_EXCEPTION} Fail to remove the monitor because the service is exception.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_Result OH_Input_RemoveKeyEventMonitor(Input_KeyEventCallback callback); + +/** + * @brief Removes a mouse event listener. + * + * @permission ohos.permission.INPUT_MONITORING + * @param callback - Callback for the mouse event listener. + * @return OH_Input_RemoveMouseEventMonitor function result code. + * {@link INPUT_SUCCESS} Removes a mouse event listener success.\n + * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n + * {@link INPUT_PARAMETER_ERROR} The callback is NULL or has not been added.\n + * {@link INPUT_SERVICE_EXCEPTION} Fail to remove the monitor because the service is exception.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_Result OH_Input_RemoveMouseEventMonitor(Input_MouseEventCallback callback); + +/** + * @brief Removes a touch event listener. + * + * @permission ohos.permission.INPUT_MONITORING + * @param callback - Callback for the touch event listener. + * @return OH_Input_RemoveTouchEventMonitor function result code. + * {@link INPUT_SUCCESS} Removes a touch event listener success.\n + * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n + * {@link INPUT_PARAMETER_ERROR} The callback is NULL or has not been added.\n + * {@link INPUT_SERVICE_EXCEPTION} Fail to remove the monitor because the service is exception.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_Result OH_Input_RemoveTouchEventMonitor(Input_TouchEventCallback callback); + +/** + * @brief Removes the listener for all types of axis events. + * + * @permission ohos.permission.INPUT_MONITORING + * @param callback - Callback for the listener used to listen for all types of axis events. + * @return OH_Input_RemoveAxisEventMonitorForAll function result code. + * {@link INPUT_SUCCESS} Removes the listener for all types of axis events success.\n + * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n + * {@link INPUT_PARAMETER_ERROR} The callback is NULL or has not been added.\n + * {@link INPUT_SERVICE_EXCEPTION} Fail to remove the monitor because the service is exception.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_Result OH_Input_RemoveAxisEventMonitorForAll(Input_AxisEventCallback callback); + +/** + * @brief Removes the listener for the specified type of axis events. + * + * @permission ohos.permission.INPUT_MONITORING + * @param axisEventType - Axis event type. The axis event type is defined in {@Link InputEvent_AxisEventType}. + * @param callback - Callback for the listener used to listen for the specified type of axis events. + * @return OH_Input_RemoveAxisEventMonitor function result code. + * {@link INPUT_SUCCESS} Removes the listener for the specified type of axis events success.\n + * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n + * {@link INPUT_PARAMETER_ERROR} The callback is NULL or has not been added.\n + * {@link INPUT_SERVICE_EXCEPTION} Fail to remove the monitor because the service is exception.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_Result OH_Input_RemoveAxisEventMonitor(InputEvent_AxisEventType axisEventType, Input_AxisEventCallback callback); + +/** + * @brief Adds a key event interceptor. If multiple interceptors are added, only the first one takes effect. + * + * @permission ohos.permission.INTERCEPT_INPUT_EVENT + * @param callback - Callback used to receive key events. + * @param option - Options for event interception. If **null** is passed, the default value is used. + * @return OH_Input_AddKeyEventInterceptor function result code. + * {@link INPUT_SUCCESS} Adds a key event interceptor success.\n + * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n + * {@link INPUT_PARAMETER_ERROR} The callback is NULL.\n + * {@link INPUT_REPEAT_INTERCEPTOR} Interceptor repeatedly created for an application.\n + * {@link INPUT_SERVICE_EXCEPTION} Failed to add the interceptor because the service is exception.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_Result OH_Input_AddKeyEventInterceptor(Input_KeyEventCallback callback, Input_InterceptorOptions *option); + +/** + * @brief Adds an interceptor for input events, including mouse, touch, and axis events. + * If multiple interceptors are added, only the first one takes effect. + * + * @permission ohos.permission.INTERCEPT_INPUT_EVENT + * @param callback - Pointer to the structure of the callback for the input event interceptor. + * For details, see {@Link Input_InterceptorEventCallback}. + * @param option - Options for event interception. If **null** is passed, the default value is used. + * @return OH_Input_AddInputEventInterceptor function result code. + * {@link INPUT_SUCCESS} Adds an interceptor for input events success.\n + * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n + * {@link INPUT_PARAMETER_ERROR} The callback is NULL.\n + * {@link INPUT_REPEAT_INTERCEPTOR} Interceptor repeatedly created for an application.\n + * {@link INPUT_SERVICE_EXCEPTION} Failed to add the interceptor because the service is exception.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_Result OH_Input_AddInputEventInterceptor(Input_InterceptorEventCallback *callback, + Input_InterceptorOptions *option); + +/** + * @brief Removes a key event interceptor. + * + * @permission ohos.permission.INTERCEPT_INPUT_EVENT + * @return OH_Input_RemoveKeyEventInterceptor function result code. + * {@link INPUT_SUCCESS}Removes a key event interceptor success.\n + * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n + * {@link INPUT_SERVICE_EXCEPTION} Failed to remove the interceptor because the service is exception.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_Result OH_Input_RemoveKeyEventInterceptor(); + +/** + * @brief Removes an interceptor for input events, including mouse, touch, and axis events. + * + * @permission ohos.permission.INTERCEPT_INPUT_EVENT + * @return OH_Input_RemoveInputEventInterceptor function result code. + * {@link INPUT_SUCCESS} Removes an interceptor for input events success.\n + * {@link INPUT_PERMISSION_DENIED} Permission verification failed.\n + * {@link INPUT_SERVICE_EXCEPTION} Failed to remove the interceptor because the service is exception.\n + * @syscap SystemCapability.MultimodalInput.Input.Core + * @since 12 + */ +Input_Result OH_Input_RemoveInputEventInterceptor(); #ifdef __cplusplus } #endif diff --git a/multimodalinput/kits/c/ohinput.ndk.json b/multimodalinput/kits/c/ohinput.ndk.json index cc28eac475c5554d3edf45fa448698accea8275e..cfbe993aee96320e1a73e14d8367836b29bd1ad1 100644 --- a/multimodalinput/kits/c/ohinput.ndk.json +++ b/multimodalinput/kits/c/ohinput.ndk.json @@ -194,5 +194,125 @@ { "first_introduced": "12", "name": "OH_Input_CancelInjection" + }, + { + "first_introduced": "12", + "name": "OH_Input_CreateAxisEvent" + }, + { + "first_introduced": "12", + "name": "OH_Input_DestroyAxisEvent" + }, + { + "first_introduced": "12", + "name": "OH_Input_SetAxisEventAction" + }, + { + "first_introduced": "12", + "name": "OH_Input_GetAxisEventAction" + }, + { + "first_introduced": "12", + "name": "OH_Input_SetAxisEventDisplayX" + }, + { + "first_introduced": "12", + "name": "OH_Input_GetAxisEventDisplayX" + }, + { + "first_introduced": "12", + "name": "OH_Input_SetAxisEventDisplayY" + }, + { + "first_introduced": "12", + "name": "OH_Input_GetAxisEventDisplayY" + }, + { + "first_introduced": "12", + "name": "OH_Input_SetAxisEventAxisValue" + }, + { + "first_introduced": "12", + "name": "OH_Input_GetAxisEventAxisValue" + }, + { + "first_introduced": "12", + "name": "OH_Input_SetAxisEventActionTime" + }, + { + "first_introduced": "12", + "name": "OH_Input_GetAxisEventActionTime" + }, + { + "first_introduced": "12", + "name": "OH_Input_SetAxisEventType" + }, + { + "first_introduced": "12", + "name": "OH_Input_GetAxisEventType" + }, + { + "first_introduced": "12", + "name": "OH_Input_SetAxisEventSourceType" + }, + { + "first_introduced": "12", + "name": "OH_Input_GetAxisEventSourceType" + }, + { + "first_introduced": "12", + "name": "OH_Input_AddKeyEventMonitor" + }, + { + "first_introduced": "12", + "name": "OH_Input_AddMouseEventMonitor" + }, + { + "first_introduced": "12", + "name": "OH_Input_AddTouchEventMonitor" + }, + { + "first_introduced": "12", + "name": "OH_Input_AddAxisEventMonitor" + }, + { + "first_introduced": "12", + "name": "OH_Input_AddAxisEventMonitorForAll" + }, + { + "first_introduced": "12", + "name": "OH_Input_RemoveKeyEventMonitor" + }, + { + "first_introduced": "12", + "name": "OH_Input_RemoveMouseEventMonitor" + }, + { + "first_introduced": "12", + "name": "OH_Input_RemoveTouchEventMonitor" + }, + { + "first_introduced": "12", + "name": "OH_Input_RemoveAxisEventMonitor" + }, + { + "first_introduced": "12", + "name": "OH_Input_RemoveAxisEventMonitorForAll" + }, + { + "first_introduced": "12", + "name": "OH_Input_AddKeyEventInterceptor" + }, + { + "first_introduced": "12", + "name": "OH_Input_AddInputEventInterceptor" + }, + { + "first_introduced": "12", + "name": "OH_Input_RemoveKeyEventInterceptor" + }, + { + "first_introduced": "12", + "name": "OH_Input_RemoveInputEventInterceptor" } ] \ No newline at end of file diff --git a/network/netmanager/include/net_connection_type.h b/network/netmanager/include/net_connection_type.h index 1698a65934337983703a44216501d0af4ea5ed42..32a8118c8f3764d7685bb8dd679de9938b309e79 100644 --- a/network/netmanager/include/net_connection_type.h +++ b/network/netmanager/include/net_connection_type.h @@ -69,6 +69,11 @@ typedef enum NetConn_NetCap { NETCONN_NET_CAPABILITY_NOT_VPN = 15, /** Validated */ NETCONN_NET_CAPABILITY_VALIDATED = 16, + /** + * Portal + * @since 12 + */ + NETCONN_NET_CAPABILITY_PORTAL = 17 } NetConn_NetCap; /** diff --git a/third_party/musl/ndk_script/BUILD.gn b/third_party/musl/ndk_script/BUILD.gn index 683b2e30d6224b58904d935640e356d7d8f01ff9..a71e33565ab354dd49bfb34bdfa2de31e336bbe8 100644 --- a/third_party/musl/ndk_script/BUILD.gn +++ b/third_party/musl/ndk_script/BUILD.gn @@ -208,7 +208,7 @@ group("musl_sysroot") { action("copy_ndk_uapi") { outputs = [ "${musl_target_out_dir}/${ndk_musl_include}/linux" ] script = "${musl_dir}/scripts/copy_uapi.sh" - args = [ "-i" ] + [ rebase_path("${uapi_dir}") ] + args = [ "-i" ] + [ rebase_path("${musl_uapi_dir}") ] args += [ "-o" ] + [ rebase_path("${musl_target_out_dir}/${ndk_musl_include}") ] args += [ "-t" ] + [ "${musl_arch}" ]