1e0e9324cSopenharmony_ci/* 2e0e9324cSopenharmony_ci * Copyright (c) 2023 Shenzhen Kaihong Digital Industry Development Co., Ltd. 3e0e9324cSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4e0e9324cSopenharmony_ci * you may not use this file except in compliance with the License. 5e0e9324cSopenharmony_ci * You may obtain a copy of the License at 6e0e9324cSopenharmony_ci * 7e0e9324cSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8e0e9324cSopenharmony_ci * 9e0e9324cSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10e0e9324cSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11e0e9324cSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12e0e9324cSopenharmony_ci * See the License for the specific language governing permissions and 13e0e9324cSopenharmony_ci * limitations under the License. 14e0e9324cSopenharmony_ci */ 15e0e9324cSopenharmony_ci 16e0e9324cSopenharmony_ci#ifndef OHOS_SHARING_ADPATER_H 17e0e9324cSopenharmony_ci#define OHOS_SHARING_ADPATER_H 18e0e9324cSopenharmony_ci 19e0e9324cSopenharmony_ci#include "common/event_comm.h" 20e0e9324cSopenharmony_ci 21e0e9324cSopenharmony_cinamespace OHOS { 22e0e9324cSopenharmony_cinamespace Sharing { 23e0e9324cSopenharmony_ci 24e0e9324cSopenharmony_ciclass ISharingAdapter { 25e0e9324cSopenharmony_cipublic: 26e0e9324cSopenharmony_ci virtual ~ISharingAdapter() = default; 27e0e9324cSopenharmony_ci 28e0e9324cSopenharmony_ci /** 29e0e9324cSopenharmony_ci * @brief Notify framework to release the scene. 30e0e9324cSopenharmony_ci * 31e0e9324cSopenharmony_ci * @param sceneId Indicates the scene ID. 32e0e9324cSopenharmony_ci */ 33e0e9324cSopenharmony_ci virtual void ReleaseScene(uint32_t sceneId) = 0; 34e0e9324cSopenharmony_ci virtual void OnSceneNotifyDestroyed(uint32_t sceneId) = 0; 35e0e9324cSopenharmony_ci 36e0e9324cSopenharmony_ci /** 37e0e9324cSopenharmony_ci * @brief Forward events synchronously or asynchronously. 38e0e9324cSopenharmony_ci * 39e0e9324cSopenharmony_ci * @param contextId Indicates the context ID. 40e0e9324cSopenharmony_ci * @param agentId Indicates the agent ID. 41e0e9324cSopenharmony_ci * @param event Event struct. 42e0e9324cSopenharmony_ci * @param isSync Indicates whether synchronous mode is used. 43e0e9324cSopenharmony_ci * @return Returns 0 if forward the event successfully; returns -1 otherwise. 44e0e9324cSopenharmony_ci */ 45e0e9324cSopenharmony_ci virtual int32_t ForwardEvent(uint32_t contextId, uint32_t agentId, SharingEvent &event, bool isSync) = 0; 46e0e9324cSopenharmony_ci 47e0e9324cSopenharmony_ci /** 48e0e9324cSopenharmony_ci * @brief Forward the domain msg to the interaction manager. 49e0e9324cSopenharmony_ci * 50e0e9324cSopenharmony_ci * @param msg msg to forward. 51e0e9324cSopenharmony_ci */ 52e0e9324cSopenharmony_ci virtual void ForwardDomainMsg(std::shared_ptr<BaseDomainMsg> &msg) = 0; 53e0e9324cSopenharmony_ci 54e0e9324cSopenharmony_ci /** 55e0e9324cSopenharmony_ci * @brief Create a context to contain agents. 56e0e9324cSopenharmony_ci * 57e0e9324cSopenharmony_ci * @param contextId Indicates the context ID. The value <b>0</b> indicates an invalid ID and the creation fails. 58e0e9324cSopenharmony_ci * @return Returns 0 if the context is created; returns -1 otherwise. 59e0e9324cSopenharmony_ci */ 60e0e9324cSopenharmony_ci virtual int32_t CreateContext(uint32_t &contextId) = 0; 61e0e9324cSopenharmony_ci 62e0e9324cSopenharmony_ci /** 63e0e9324cSopenharmony_ci * @brief Create an agent in the context by specifying a business implementation class. 64e0e9324cSopenharmony_ci * 65e0e9324cSopenharmony_ci * @param contextId Indicates the context ID. If contextId is 0, a new context will be created with an agent. 66e0e9324cSopenharmony_ci * @param agentId Indicates the created agent ID. The value <b>0</b> indicates an invalid ID and the creation fails. 67e0e9324cSopenharmony_ci * @param agentType Indicates the agent type {@link AgentType} defined in {@link agent_def.h}. 68e0e9324cSopenharmony_ci * @param sessionName Indicates the business implementation class's name. 69e0e9324cSopenharmony_ci * @return Returns 0 if the agent is created; returns -1 otherwise. 70e0e9324cSopenharmony_ci */ 71e0e9324cSopenharmony_ci virtual int32_t CreateAgent(uint32_t &contextId, uint32_t &agentId, AgentType agentType, 72e0e9324cSopenharmony_ci std::string sessionName) = 0; 73e0e9324cSopenharmony_ci 74e0e9324cSopenharmony_ci /** 75e0e9324cSopenharmony_ci * @brief Delete all agents in this context, then delete the context. 76e0e9324cSopenharmony_ci * 77e0e9324cSopenharmony_ci * @param contextId Indicates context ID. 78e0e9324cSopenharmony_ci * @return Returns 0 if the context is destroyed; returns -1 otherwise. 79e0e9324cSopenharmony_ci */ 80e0e9324cSopenharmony_ci virtual int32_t DestroyContext(uint32_t contextId) = 0; 81e0e9324cSopenharmony_ci 82e0e9324cSopenharmony_ci /** 83e0e9324cSopenharmony_ci * @brief Delete the agent. 84e0e9324cSopenharmony_ci * 85e0e9324cSopenharmony_ci * @param contextId Indicates the context ID. 86e0e9324cSopenharmony_ci * @param agentId Indicates the agent ID. 87e0e9324cSopenharmony_ci * @return Returns 0 if the agent is destroyed; returns -1 otherwise. 88e0e9324cSopenharmony_ci */ 89e0e9324cSopenharmony_ci virtual int32_t DestroyAgent(uint32_t contextId, uint32_t agentId) = 0; 90e0e9324cSopenharmony_ci 91e0e9324cSopenharmony_ci /** 92e0e9324cSopenharmony_ci * @brief Stop operating business agent. 93e0e9324cSopenharmony_ci * 94e0e9324cSopenharmony_ci * @param contextId Indicates the context ID. 95e0e9324cSopenharmony_ci * @param agentId Indicates the agent ID. 96e0e9324cSopenharmony_ci * @return Returns 0 if stop sending or receiving streams; returns -1 otherwise. 97e0e9324cSopenharmony_ci */ 98e0e9324cSopenharmony_ci virtual int32_t Stop(uint32_t contextId, uint32_t agentId) = 0; 99e0e9324cSopenharmony_ci 100e0e9324cSopenharmony_ci /** 101e0e9324cSopenharmony_ci * @brief Start operating business agent. 102e0e9324cSopenharmony_ci * 103e0e9324cSopenharmony_ci * @param contextId Indicates the context ID. 104e0e9324cSopenharmony_ci * @param agentId Indicates the agent ID. 105e0e9324cSopenharmony_ci * @return Returns 0 if the interaction starts; returns -1 otherwise. 106e0e9324cSopenharmony_ci */ 107e0e9324cSopenharmony_ci virtual int32_t Start(uint32_t contextId, uint32_t agentId) = 0; 108e0e9324cSopenharmony_ci 109e0e9324cSopenharmony_ci /** 110e0e9324cSopenharmony_ci * @brief Pause operating business agent. 111e0e9324cSopenharmony_ci * 112e0e9324cSopenharmony_ci * @param contextId Indicates the context ID. 113e0e9324cSopenharmony_ci * @param agentId Indicates the agent ID. 114e0e9324cSopenharmony_ci * @param mediaType the media type {@link MediaType} defined in {@link const_def.h}. 115e0e9324cSopenharmony_ci * @return Returns 0 if the stream is paused; returns -1 otherwise. 116e0e9324cSopenharmony_ci */ 117e0e9324cSopenharmony_ci virtual int32_t Pause(uint32_t contextId, uint32_t agentId, MediaType mediaType) = 0; 118e0e9324cSopenharmony_ci 119e0e9324cSopenharmony_ci /** 120e0e9324cSopenharmony_ci * @brief Resume operating business agent. 121e0e9324cSopenharmony_ci * 122e0e9324cSopenharmony_ci * @param contextId Indicates the context ID. 123e0e9324cSopenharmony_ci * @param agentId Indicates the agent ID. 124e0e9324cSopenharmony_ci * @param mediaType the media type {@link MediaType} defined in {@link const_def.h}. 125e0e9324cSopenharmony_ci * @return Returns 0 if the stream is resumed; returns -1 otherwise. 126e0e9324cSopenharmony_ci */ 127e0e9324cSopenharmony_ci virtual int32_t Resume(uint32_t contextId, uint32_t agentId, MediaType mediaType) = 0; 128e0e9324cSopenharmony_ci 129e0e9324cSopenharmony_ci /** 130e0e9324cSopenharmony_ci * @brief Preview Media Resources. 131e0e9324cSopenharmony_ci * 132e0e9324cSopenharmony_ci * @param contextId Indicates the context ID. 133e0e9324cSopenharmony_ci * @param agentId Indicates the agent ID. 134e0e9324cSopenharmony_ci * @return Returns 0 if starts playing; returns -1 otherwise. 135e0e9324cSopenharmony_ci */ 136e0e9324cSopenharmony_ci virtual int32_t Play(uint32_t contextId, uint32_t agentId) = 0; 137e0e9324cSopenharmony_ci 138e0e9324cSopenharmony_ci /** 139e0e9324cSopenharmony_ci * @brief Close the window for previewing media sources. 140e0e9324cSopenharmony_ci * 141e0e9324cSopenharmony_ci * @param contextId Indicates the context ID. 142e0e9324cSopenharmony_ci * @param agentId Indicates the agent ID. 143e0e9324cSopenharmony_ci * @return Returns 0 if stops playing; returns -1 otherwise. 144e0e9324cSopenharmony_ci */ 145e0e9324cSopenharmony_ci virtual int32_t Close(uint32_t contextId, uint32_t agentId) = 0; 146e0e9324cSopenharmony_ci 147e0e9324cSopenharmony_ci /** 148e0e9324cSopenharmony_ci * @brief Set the keyframe playback mode. 149e0e9324cSopenharmony_ci * 150e0e9324cSopenharmony_ci * @param contextId Indicates the context ID. 151e0e9324cSopenharmony_ci * @param agentId Indicates the agent ID. 152e0e9324cSopenharmony_ci * @param surfaceId Indicates the surface ID. 153e0e9324cSopenharmony_ci * @param keyFrame Indicates whether it is keyframe playback mode. 154e0e9324cSopenharmony_ci * @return Returns 0 if keyframe mode is set; returns -1 otherwise. 155e0e9324cSopenharmony_ci */ 156e0e9324cSopenharmony_ci virtual int32_t SetKeyPlay(uint32_t contextId, uint32_t agentId, uint64_t surfaceId, bool keyFrame) = 0; 157e0e9324cSopenharmony_ci 158e0e9324cSopenharmony_ci /** 159e0e9324cSopenharmony_ci * @brief Set the keyframe playback mode. 160e0e9324cSopenharmony_ci * 161e0e9324cSopenharmony_ci * @param contextId Indicates the context ID. 162e0e9324cSopenharmony_ci * @param agentId Indicates the agent ID. 163e0e9324cSopenharmony_ci * @param surfaceId Indicates the surface ID. 164e0e9324cSopenharmony_ci * @param keyRedirect Indicates whether it is keyframe rapid redirect. 165e0e9324cSopenharmony_ci * @return Returns 0 if keyframe mode is set; returns -1 otherwise. 166e0e9324cSopenharmony_ci */ 167e0e9324cSopenharmony_ci virtual int32_t SetKeyRedirect(uint32_t contextId, uint32_t agentId, uint64_t surfaceId, bool keyRedirect) = 0; 168e0e9324cSopenharmony_ci 169e0e9324cSopenharmony_ci /** 170e0e9324cSopenharmony_ci * @brief Set the playback volume of audio resources. 171e0e9324cSopenharmony_ci * 172e0e9324cSopenharmony_ci * @param contextId Indicates the context ID. 173e0e9324cSopenharmony_ci * @param agentId Indicates the agent ID. 174e0e9324cSopenharmony_ci * @param volume Indicates the target volume of the audio to set, ranging from 0 to 1. 175e0e9324cSopenharmony_ci * @return Returns 0 if the volume is set; returns -1 otherwise. 176e0e9324cSopenharmony_ci */ 177e0e9324cSopenharmony_ci virtual int32_t SetVolume(uint32_t contextId, uint32_t agentId, float volume) = 0; 178e0e9324cSopenharmony_ci 179e0e9324cSopenharmony_ci /** 180e0e9324cSopenharmony_ci * @brief Append the surface for the preview window. 181e0e9324cSopenharmony_ci * 182e0e9324cSopenharmony_ci * @param contextId Indicates the context ID. 183e0e9324cSopenharmony_ci * @param agentId Indicates the agent ID. 184e0e9324cSopenharmony_ci * @param surface Pointer of the surface. 185e0e9324cSopenharmony_ci * @return Returns 0 if the surface is set; returns -1 otherwise. 186e0e9324cSopenharmony_ci */ 187e0e9324cSopenharmony_ci virtual int32_t AppendSurface(uint32_t contextId, uint32_t agentId, sptr<Surface> surface, 188e0e9324cSopenharmony_ci SceneType sceneType = FOREGROUND) = 0; 189e0e9324cSopenharmony_ci 190e0e9324cSopenharmony_ci /** 191e0e9324cSopenharmony_ci * @brief del the surface for the preview window. 192e0e9324cSopenharmony_ci * 193e0e9324cSopenharmony_ci * @param contextId Indicates the context ID. 194e0e9324cSopenharmony_ci * @param agentId Indicates the agent ID. 195e0e9324cSopenharmony_ci * @param surfaceId Indicates the surface ID. 196e0e9324cSopenharmony_ci * @return Returns 0 if the surface is del; returns -1 otherwise. 197e0e9324cSopenharmony_ci */ 198e0e9324cSopenharmony_ci virtual int32_t RemoveSurface(uint32_t contextId, uint32_t agentId, uint64_t surfaceId) = 0; 199e0e9324cSopenharmony_ci 200e0e9324cSopenharmony_ci /** 201e0e9324cSopenharmony_ci * @brief Destroy the window. 202e0e9324cSopenharmony_ci * 203e0e9324cSopenharmony_ci * @param windowId Indicates the window ID. 204e0e9324cSopenharmony_ci * @return Returns 0 if the window is destroyed; returns -1 otherwise. 205e0e9324cSopenharmony_ci */ 206e0e9324cSopenharmony_ci virtual int32_t DestroyWindow(int32_t windowId) = 0; 207e0e9324cSopenharmony_ci 208e0e9324cSopenharmony_ci /** 209e0e9324cSopenharmony_ci * @brief Create a preview window inside the framework. 210e0e9324cSopenharmony_ci * 211e0e9324cSopenharmony_ci * @param windowId Indicates the window ID. The value <b>-1</b> indicates an invalid ID and the creation fails. 212e0e9324cSopenharmony_ci * @param windowProperty Indicated initialization for window. For details, see {@link windowProperty} defined in 213e0e9324cSopenharmony_ci * {@link event_comm.h}. 214e0e9324cSopenharmony_ci * @return Returns 0 if the window is created; returns -1 otherwise. 215e0e9324cSopenharmony_ci */ 216e0e9324cSopenharmony_ci virtual int32_t CreateWindow(int32_t &windowId, WindowProperty &windowProperty) = 0; 217e0e9324cSopenharmony_ci 218e0e9324cSopenharmony_ci /** 219e0e9324cSopenharmony_ci * @brief Hide the window. 220e0e9324cSopenharmony_ci * 221e0e9324cSopenharmony_ci * @param windowId Indicates the window ID. 222e0e9324cSopenharmony_ci * @return Returns 0 if the window is hidden; returns -1 otherwise. 223e0e9324cSopenharmony_ci */ 224e0e9324cSopenharmony_ci virtual int32_t Hide(int32_t windowId) = 0; 225e0e9324cSopenharmony_ci 226e0e9324cSopenharmony_ci /** 227e0e9324cSopenharmony_ci * @brief Show the window. 228e0e9324cSopenharmony_ci * 229e0e9324cSopenharmony_ci * @param windowId Indicates the window ID. 230e0e9324cSopenharmony_ci * @return Returns 0 if the window is shown; returns -1 otherwise. 231e0e9324cSopenharmony_ci */ 232e0e9324cSopenharmony_ci virtual int32_t Show(int32_t windowId) = 0; 233e0e9324cSopenharmony_ci 234e0e9324cSopenharmony_ci /** 235e0e9324cSopenharmony_ci * @brief Set the full-screen property of the window. 236e0e9324cSopenharmony_ci * 237e0e9324cSopenharmony_ci * @param windowId Indicates the window ID. 238e0e9324cSopenharmony_ci * @return Returns 0 if the window is to be full screen; returns -1 otherwise. 239e0e9324cSopenharmony_ci */ 240e0e9324cSopenharmony_ci virtual int32_t SetFullScreen(int32_t windowId, bool isFull) = 0; 241e0e9324cSopenharmony_ci 242e0e9324cSopenharmony_ci /** 243e0e9324cSopenharmony_ci * @brief Move the window to the specified coordinates. 244e0e9324cSopenharmony_ci * 245e0e9324cSopenharmony_ci * @param windowId Indicates the window ID. 246e0e9324cSopenharmony_ci * @param x The starting x-axis position of the window 247e0e9324cSopenharmony_ci * @param y The starting y-axis position of the window 248e0e9324cSopenharmony_ci * @return Returns 0 if the window is moved successfully; returns -1 otherwise. 249e0e9324cSopenharmony_ci */ 250e0e9324cSopenharmony_ci virtual int32_t MoveTo(int32_t windowId, int32_t x, int32_t y) = 0; 251e0e9324cSopenharmony_ci 252e0e9324cSopenharmony_ci /** 253e0e9324cSopenharmony_ci * @brief Get surface of the window. 254e0e9324cSopenharmony_ci * 255e0e9324cSopenharmony_ci * @param windowId Indicates the window ID. 256e0e9324cSopenharmony_ci * @param surface Pointer of surface. 257e0e9324cSopenharmony_ci * @return Returns 0 if gets the surface successfully; returns -1 otherwise. 258e0e9324cSopenharmony_ci */ 259e0e9324cSopenharmony_ci virtual int32_t GetSurface(int32_t windowId, sptr<Surface> &surface) = 0; 260e0e9324cSopenharmony_ci 261e0e9324cSopenharmony_ci /** 262e0e9324cSopenharmony_ci * @brief Resize the window. 263e0e9324cSopenharmony_ci * 264e0e9324cSopenharmony_ci * @param windowId Indicates the window ID. 265e0e9324cSopenharmony_ci * @param width Indicates the windows'width you set. 266e0e9324cSopenharmony_ci * @param height Indicates the window's height you set. 267e0e9324cSopenharmony_ci * @return Returns 0 if the window is resized; returns -1 otherwise. 268e0e9324cSopenharmony_ci */ 269e0e9324cSopenharmony_ci virtual int32_t ReSize(int32_t windowId, int32_t width, int32_t height) = 0; 270e0e9324cSopenharmony_ci}; 271e0e9324cSopenharmony_ci 272e0e9324cSopenharmony_ci} // namespace Sharing 273e0e9324cSopenharmony_ci} // namespace OHOS 274e0e9324cSopenharmony_ci#endif