diff --git a/arkui/window_manager/BUILD.gn b/arkui/window_manager/BUILD.gn index 0e5b250e5e494a0366a7e09ed032b6baf44475dc..17fb43b1ddd6e3432b7f4dac602e05f9ba935794 100644 --- a/arkui/window_manager/BUILD.gn +++ b/arkui/window_manager/BUILD.gn @@ -24,6 +24,7 @@ ohos_ndk_library("native_window_manager") { "window_manager/oh_window.h", "window_manager/oh_window_comm.h", "window_manager/oh_window_event_filter.h", + "window_manager/oh_window_pip.h", ] } @@ -33,5 +34,6 @@ ohos_ndk_headers("window_manager_header") { "oh_window.h", "oh_window_comm.h", "oh_window_event_filter.h", + "oh_window_pip.h", ] } diff --git a/arkui/window_manager/libwm.ndk.json b/arkui/window_manager/libwm.ndk.json index d3791022bb88f9397ab80c56ba040cb5dce1f8f2..f0bc24c441e9bb1097765d668180cc8a6f45759d 100644 --- a/arkui/window_manager/libwm.ndk.json +++ b/arkui/window_manager/libwm.ndk.json @@ -86,5 +86,81 @@ { "first_instroduced":"17", "name":"OH_WindowManager_ReleaseAllWindowLayoutInfoList" + }, + { + "first_instroduced":"20", + "name":"OH_PictureInPicture_CreatePip" + }, + { + "first_instroduced":"20", + "name":"OH_PictureInPicture_DeletePip" + }, + { + "first_instroduced":"20", + "name":"OH_PictureInPicture_StartPip" + }, + { + "first_instroduced":"20", + "name":"OH_PictureInPicture_StopPip" + }, + { + "first_instroduced":"20", + "name":"OH_PictureInPicture_UpdatePipContentSize" + }, + { + "first_instroduced":"20", + "name":"OH_PictureInPicture_UpdatePipControlStatus" + }, + { + "first_instroduced":"20", + "name":"OH_PictureInPicture_SetPiPControlEnabled" + }, + { + "first_instroduced":"20", + "name":"OH_PictureInPicture_RegisterStartPipCallBack" + }, + { + "first_instroduced":"20", + "name":"OH_PictureInPicture_UnregisterStartPipCallBack" + }, + { + "first_instroduced":"20", + "name":"OH_PictureInPicture_UnregisterAllStartPipCallBack" + }, + { + "first_instroduced":"20", + "name":"OH_PictureInPicture_RegisterLifeCycleListener" + }, + { + "first_instroduced":"20", + "name":"OH_PictureInPicture_UnregisterLifeCycleListener" + }, + { + "first_instroduced":"20", + "name":"OH_PictureInPicture_UnregisterAllLifeCycleListener" + }, + { + "first_instroduced":"20", + "name":"OH_PictureInPicture_RegisterPanelActionListener" + }, + { + "first_instroduced":"20", + "name":"OH_PictureInPicture_UnregisterPanelActionListener" + }, + { + "first_instroduced":"20", + "name":"OH_PictureInPicture_UnregisterAllPanelActionListener" + }, + { + "first_instroduced":"20", + "name":"OH_PictureInPicture_RegisterResizeListener" + }, + { + "first_instroduced":"20", + "name":"OH_PictureInPicture_UnregisterResizeListener" + }, + { + "first_instroduced":"20", + "name":"OH_PictureInPicture_UnregisterAllResizeListener" } ] \ No newline at end of file diff --git a/arkui/window_manager/oh_window_comm.h b/arkui/window_manager/oh_window_comm.h index d015371a54cd8ad17a4bebfdeb62bc8d5eb57e4a..c794c00c221d94d256a19f52079acf3f1807a3ed 100644 --- a/arkui/window_manager/oh_window_comm.h +++ b/arkui/window_manager/oh_window_comm.h @@ -92,6 +92,41 @@ typedef enum { * @since 15 */ WINDOW_MANAGER_ERRORCODE_SYSTEM_ABNORMAL = 1300003, + /** + * @error Picture-In-Picture failed to destroy. + * + * @since 20 + */ + WINDOW_MANAGER_ERRORCODE_PIP_DESTROY_FAILED = 1300011, + /** + * @error Picture-In-Picture state is abnormal. + * + * @since 20 + */ + WINDOW_MANAGER_ERRORCODE_PIP_STATE_ABNORMAL = 1300012, + /** + * @error Picture-In-Picture failed to create. + * + * @since 20 + */ + WINDOW_MANAGER_ERRORCODE_PIP_CREATE_FAILED = 1300013, + /** + * @error Picture-In-Picture internal error. + * + * @since 20 + */ + WINDOW_MANAGER_ERRORCODE_PIP_INTERNAL_ERROR = 1300014, + /** + * @error Picture-In-Picture repeat operation. + * + * @since 20 + */ + WINDOW_MANAGER_ERRORCODE_PIP_REPEATED_OPERATION = 1300015, + /** + * @error Parameter is incorrect. + * @since 20 + */ + WINDOW_MANAGER_ERRORCODE_INCORRECT_PARAM = 1300016, } WindowManager_ErrorCode; /** diff --git a/arkui/window_manager/oh_window_pip.h b/arkui/window_manager/oh_window_pip.h new file mode 100644 index 0000000000000000000000000000000000000000..37bb616d0b29f703a60359e403e3168923bd95a2 --- /dev/null +++ b/arkui/window_manager/oh_window_pip.h @@ -0,0 +1,417 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @addtogroup OH_PictureInPicture + * @file oh_window_pip.h + * + * @brief Declares C APIs for picture in picture window + * + * @kit ArkUI + * @library libnative_window_manager.so + * @syscap SystemCapability.Window.SessionManager + * @since 20 + * @version 1.0 + */ +#ifndef OH_WINDOW_PIP_H +#define OH_WINDOW_PIP_H + +#include "napi/native_api.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Enumerates picture in picture template type. + * @since 20 + */ +typedef enum { + VIDEO_PLAY = 0, + VIDEO_CALL = 1, + VIDEO_MEETING = 2, + VIDEO_LIVE = 3, +} PictureInPicture_PipTemplateType; + +/** + * @brief Enumerates picture in picture control group. + * @since 20 + */ +typedef enum { + VIDEO_PLAY_VIDEO_PREVIOUS_NEXT = 101, + VIDEO_PLAY_FAST_FORWARD_BACKWARD = 102, + VIDEO_CALL_MICROPHONE_SWITCH = 201, + VIDEO_CALL_HANG_UP_BUTTON = 202, + VIDEO_CALL_CAMERA_SWITCH = 203, + VIDEO_CALL_MUTE_SWITCH = 204, + VIDEO_MEETING_HANG_UP_BUTTON = 301, + VIDEO_MEETING_CAMERA_SWITCH = 302, + VIDEO_MEETING_MUTE_SWITCH = 303, + VIDEO_MEETING_MICROPHONE_SWITCH = 304, + VIDEO_LIVE_VIDEO_PLAY_PAUSE = 401, + VIDEO_LIVE_MUTE_SWITCH = 402, +} PictureInPicture_PipControlGroup; + +/** + * @brief Enumerates picture in picture control type. + * @since 20 + */ +typedef enum { + VIDEO_PLAY_PAUSE = 0, + VIDEO_PREVIOUS = 1, + VIDEO_NEXT = 2, + FAST_FORWARD = 3, + FAST_BACKWARD = 4, + HANG_UP_BUTTON = 5, + MICROPHONE_SWITCH = 6, + CAMERA_SWITCH = 7, + MUTE_SWITCH = 8, + END, +} PictureInPicture_PiPControlType; + +/** + * @brief Enumerates picture in picture control status. + * @since 20 + */ +typedef enum { + PLAY = 1, + PAUSE = 0, + OPEN = 1, + CLOSE = 0, +} PictureInPicture_PiPControlStatus; + +/** + * @brief Enumerates picture in picture state. + * @since 20 + */ +typedef enum { + ABOUT_TO_START = 1, + STARTED = 2, + ABOUT_TO_STOP = 3, + STOPPED = 4, + ABOUT_TO_RESTORE = 5, + ERROR = 6, +} PictureInPicture_PipState; + +/** + * @brief Defines the PiP config structure. + * + * @since 20 + */ +typedef struct { + /** WindowId of Corresponding mainWindow. */ + uint32_t mainWindowId; + /** The picture-in-picture template type */ + PictureInPicture_PipTemplateType pipTemplateType; + /** The picture-in-picture content width */ + uint32_t width; + /** The picture-in-picture content height */ + uint32_t height; + /** The picture-in-picture control group */ + PictureInPicture_PipControlGroup* controlGroup; + /** The length of picture-in-picture control group */ + uint8_t controlGroupLength; + /** The application environment */ + napi_env env; +} PictureInPicture_PipConfig; + +/** + * @brief Start the picture-in-picture callback + * @param requestId The picture-in-picture requestId + * @param surfaceId The picture-in-picture surfaceId + * @since 20 + */ +typedef void (*WebPipStartPipCallback)(uint32_t controllerId, uint8_t requestId, uint64_t surfaceId); + +/** + * @brief The picture-in-picture lifecycle callback + * @param state The picture-in-picture state + * @since 20 + */ +typedef void (*WebPipLifecycleCallback)(uint32_t controllerId, PictureInPicture_PipState state, int32_t errcode); + +/** + * @brief The picture-in-picture control event callback + * @param controlType The picture-in-picture control type + * @param status The picture-in-picture control status + * @since 20 + */ +typedef void (*WebPipControlEventCallback)(uint32_t controllerId, PictureInPicture_PiPControlType controlType, + PictureInPicture_PiPControlStatus status); + +/** + * @brief The picture-in-picture size change callback + * @param width The picture-in-picture window width + * @param height The picture-in-picture window height + * @param scale The picture-in-picture window scale + * @since 20 + */ +typedef void (*WebPipResizeCallback)(uint32_t controllerId, uint32_t width, uint32_t height, double scale); + +/** + * @brief Create picture-in-picture controller. + * + * @param pipConfig The picture-in-picture configuration + * @param controllerId The picture-in-picture controller ID + * @return Return the result code. + * {@link OK} the function call is successful. + * {@link WINDOW_MANAGER_ERRORCODE_INCORRECT_PARAM} parameter error. + * {@link WINDOW_MANAGER_ERRORCODE_DEVICE_NOT_SUPPORTED} capability not supported. + * {@link WINDOW_MANAGER_ERRORCODE_PIP_INTERNAL_ERROR} pip internal error. + * @since 20 + */ +int32_t OH_PictureInPicture_CreatePip(PictureInPicture_PipConfig* pipConfig, uint32_t* controllerId); + +/** + * @brief Delete picture-in-picture controller. + * + * @param controllerId The picture-in-picture controller ID + * @return Return the result code. + * {@link OK} The function call is successful. + * {@link WINDOW_MANAGER_ERRORCODE_INCORRECT_PARAM} parameter error. + * @since 20 + */ +int32_t OH_PictureInPicture_DeletePip(uint32_t controllerId); + +/** + * @brief Start picture-in-picture. + * + * @param controllerId The picture-in-picture controller ID + * @return Return the result code. + * {@link OK} the function call is successful. + * {@link WINDOW_MANAGER_ERRORCODE_PIP_STATE_ABNORMAL} the PiP window state is abnormal. + * {@link WINDOW_MANAGER_ERRORCODE_PIP_CREATE_FAILED} failed to create the PiP window. + * {@link WINDOW_MANAGER_ERRORCODE_ERRORCODE_PIP_INTERNAL_ERROR} pip internal error. + * {@link WINDOW_MANAGER_ERRORCODE_PIP_REPEATED_OPERATION} repeated PiP operation. + * @since 20 + */ +int32_t OH_PictureInPicture_StartPip(uint32_t controllerId); + +/** + * @brief Stop picture-in-picture. + * + * @param controllerId The picture-in-picture controller ID + * @return Return the result code. + * {@link OK} the function call is successful. + * {@link WINDOW_MANAGER_ERRORCODE_PIP_DESTROY_FAILED} failed to destroy the PiP window. + * {@link WINDOW_MANAGER_ERRORCODE_PIP_STATE_ABNORMAL} the PiP window state is abnormal. + * {@link WINDOW_MANAGER_ERRORCODE_ERRORCODE_PIP_INTERNAL_ERROR} pip internal error. + * {@link WINDOW_MANAGER_ERRORCODE_PIP_REPEATED_OPERATION} repeated PiP operation. + * @since 20 + */ +int32_t OH_PictureInPicture_StopPip(uint32_t controllerId); + +/** + * @brief Update picture-in-picture content size. + * + * @param controllerId The picture-in-picture controller ID + * @param width The picture-in-picture content width + * @param height The picture-in-picture content height + * @since 20 + */ +void OH_PictureInPicture_UpdatePipContentSize(uint32_t controllerId, uint32_t width, uint32_t height); + + +/** + * @brief Update picture-in-picture control status. + * + * @param controllerId The picture-in-picture controller ID + * @param controlType The picture-in-picture control type. + * @param status The picture-in-picture control status. + * @since 20 + */ +void OH_PictureInPicture_UpdatePipControlStatus(uint32_t controllerId, PictureInPicture_PiPControlType controlType, + PictureInPicture_PiPControlStatus status); + +/** + * @brief Set picture-in-picture controll enable status. + * + * @param controllerId The picture-in-picture controller ID + * @param controlType The picture-in-picture control type. + * @param enabled Indicate the picture-in-picture control is enabled. + * @since 20 + */ +void OH_PictureInPicture_SetPiPControlEnabled(uint32_t controllerId, PictureInPicture_PiPControlType controlType, + bool enabled); + +/** + * @brief Register picture-in-picture controller start callback. + * + * @param controllerId The picture-in-picture controller ID + * @param callback Start the picture-in-picture callback + * @return Return the result code. + * {@link OK} the function call is successful. + * {@link WINDOW_MANAGER_ERRORCODE_INCORRECT_PARAM} parameter error. + * {@link WINDOW_MANAGER_ERRORCODE_DEVICE_NOT_SUPPORTED} capability not supported. + * {@link WINDOW_MANAGER_ERRORCODE_PIP_INTERNAL_ERROR} pip internal error. + * @since 20 + */ +int32_t OH_PictureInPicture_RegisterStartPipCallback(uint32_t controllerId, WebPipStartPipCallback callback); + +/** + * @brief Unregister picture-in-picture controller start callback. + * + * @param controllerId The picture-in-picture controller ID + * @param callback Start the picture-in-picture callback + * @return Return the result code. + * {@link OK} the function call is successful. + * {@link WINDOW_MANAGER_ERRORCODE_INCORRECT_PARAM} parameter error. + * {@link WINDOW_MANAGER_ERRORCODE_DEVICE_NOT_SUPPORTED} capability not supported. + * {@link WINDOW_MANAGER_ERRORCODE_PIP_INTERNAL_ERROR} pip internal error. + * @since 20 + */ +int32_t OH_PictureInPicture_UnregisterStartPipCallback(uint32_t controllerId, WebPipStartPipCallback callback); + +/** + * @brief Unregister all picture-in-picture controller start callbacks. + * + * @param controllerId The picture-in-picture controller ID + * @return Return the result code. + * {@link OK} the function call is successful. + * {@link WINDOW_MANAGER_ERRORCODE_INCORRECT_PARAM} parameter error. + * {@link WINDOW_MANAGER_ERRORCODE_DEVICE_NOT_SUPPORTED} capability not supported. + * {@link WINDOW_MANAGER_ERRORCODE_PIP_INTERNAL_ERROR} pip internal error. + * @since 20 + */ +int32_t OH_PictureInPicture_UnregisterAllStartPipCallbacks(uint32_t controllerId); + +/** + * @brief Register picture-in-picture life cycle listener callback. + * + * @param controllerId The picture-in-picture controller ID + * @param callback The picture-in-picture lifecycle callback. + * @return Return the result code. + * {@link OK} the function call is successful. + * {@link WINDOW_MANAGER_ERRORCODE_INCORRECT_PARAM} parameter error. + * {@link WINDOW_MANAGER_ERRORCODE_DEVICE_NOT_SUPPORTED} capability not supported. + * {@link WINDOW_MANAGER_ERRORCODE_PIP_INTERNAL_ERROR} pip internal error. + * @since 20 + */ +int32_t OH_PictureInPicture_RegisterLifecycleListener(uint32_t controllerId, WebPipLifecycleCallback callback); + +/** + * @brief Unregister picture-in-picture life cycle listener callback. + * + * @param controllerId The picture-in-picture controller ID + * @param callback The picture-in-picture lifecycle callback. + * @return Return the result code. + * {@link OK} the function call is successful. + * {@link WINDOW_MANAGER_ERRORCODE_INCORRECT_PARAM} parameter error. + * {@link WINDOW_MANAGER_ERRORCODE_DEVICE_NOT_SUPPORTED} capability not supported. + * {@link WINDOW_MANAGER_ERRORCODE_PIP_INTERNAL_ERROR} pip internal error. + * @since 20 + */ +int32_t OH_PictureInPicture_UnregisterLifecycleListener(uint32_t controllerId, WebPipLifecycleCallback callback); + +/** + * @brief Unregister all picture-in-picture life cycle listener callbacks. + * + * @param controllerId The picture-in-picture controller ID + * @return Return the result code. + * {@link OK} the function call is successful. + * {@link WINDOW_MANAGER_ERRORCODE_INCORRECT_PARAM} parameter error. + * {@link WINDOW_MANAGER_ERRORCODE_DEVICE_NOT_SUPPORTED} capability not supported. + * {@link WINDOW_MANAGER_ERRORCODE_PIP_INTERNAL_ERROR} pip internal error. + * @since 20 + */ +int32_t OH_PictureInPicture_UnregisterAllLifecycleListeners(uint32_t controllerId); + +/** + * @brief Register picture-in-picture control event listener callback. + * + * @param controllerId The picture-in-picture controller ID + * @param callback The picture-in-picture control event callback. + * @return Return the result code. + * {@link OK} the function call is successful. + * {@link WINDOW_MANAGER_ERRORCODE_INCORRECT_PARAM} parameter error. + * {@link WINDOW_MANAGER_ERRORCODE_DEVICE_NOT_SUPPORTED} capability not supported. + * {@link WINDOW_MANAGER_ERRORCODE_PIP_INTERNAL_ERROR} pip internal error. + * @since 20 + */ +int32_t OH_PictureInPicture_RegisterControlEventListener(uint32_t controllerId, WebPipControlEventCallback callback); + +/** + * @brief Unregister picture-in-picture control event listener callback. + * + * @param controllerId The picture-in-picture controller ID + * @param callback The picture-in-picture control event callback. + * @return Return the result code. + * {@link OK} the function call is successful. + * {@link WINDOW_MANAGER_ERRORCODE_INCORRECT_PARAM} parameter error. + * {@link WINDOW_MANAGER_ERRORCODE_DEVICE_NOT_SUPPORTED} capability not supported. + * {@link WINDOW_MANAGER_ERRORCODE_PIP_INTERNAL_ERROR} pip internal error. + * @since 20 + */ +int32_t OH_PictureInPicture_UnregisterControlEventListener(uint32_t controllerId, WebPipControlEventCallback callback); + +/** + * @brief Unregister all picture-in-picture control event listener callbacks. + * + * @param controllerId The picture-in-picture controller ID + * @return Return the result code. + * {@link OK} the function call is successful. + * {@link WINDOW_MANAGER_ERRORCODE_INCORRECT_PARAM} parameter error. + * {@link WINDOW_MANAGER_ERRORCODE_DEVICE_NOT_SUPPORTED} capability not supported. + * {@link WINDOW_MANAGER_ERRORCODE_PIP_INTERNAL_ERROR} pip internal error. + * @since 20 + */ +int32_t OH_PictureInPicture_UnregisterAllControlEventListeners(uint32_t controllerId); + +/** + * @brief Register picture-in-picture resize listener callback. + * + * @param controllerId The picture-in-picture controller ID + * @param callback The picture-in-picture size change callback. + * @return Return the result code. + * {@link OK} the function call is successful. + * {@link WINDOW_MANAGER_ERRORCODE_INCORRECT_PARAM} parameter error. + * {@link WINDOW_MANAGER_ERRORCODE_DEVICE_NOT_SUPPORTED} capability not supported. + * {@link WINDOW_MANAGER_ERRORCODE_PIP_INTERNAL_ERROR} pip internal error. + * @since 20 + */ +int32_t OH_PictureInPicture_RegisterResizeListener(uint32_t controllerId, WebPipResizeCallback callback); + +/** + * @brief Unregister picture-in-picture resize listener callback. + * + * @param controllerId The picture-in-picture controller ID + * @param callback The picture-in-picture size change callback. + * @return Return the result code. + * {@link OK} the function call is successful. + * {@link WINDOW_MANAGER_ERRORCODE_INCORRECT_PARAM} parameter error. + * {@link WINDOW_MANAGER_ERRORCODE_DEVICE_NOT_SUPPORTED} capability not supported. + * {@link WINDOW_MANAGER_ERRORCODE_PIP_INTERNAL_ERROR} pip internal error. + * @since 20 + */ +int32_t OH_PictureInPicture_UnregisterResizeListener(uint32_t controllerId, WebPipResizeCallback callback); + +/** + * @brief Unregister all picture-in-picture resize listener callbacks. + * + * @param controllerId The picture-in-picture controller ID + * @return Return the result code. + * {@link OK} the function call is successful. + * {@link WINDOW_MANAGER_ERRORCODE_INCORRECT_PARAM} parameter error. + * {@link WINDOW_MANAGER_ERRORCODE_DEVICE_NOT_SUPPORTED} capability not supported. + * {@link WINDOW_MANAGER_ERRORCODE_PIP_INTERNAL_ERROR} pip internal error. + * @since 20 + */ +int32_t OH_PictureInPicture_UnregisterAllResizeListeners(uint32_t controllerId); + +#ifdef __cplusplus +} +#endif + +#endif // OH_WINDOW_PIP_H \ No newline at end of file