1 /* 2 * Copyright (C) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef I_MEDIA_SERVICE_H 17 #define I_MEDIA_SERVICE_H 18 19 #include <memory> 20 #ifdef SUPPORT_RECORDER 21 #include "i_recorder_service.h" 22 #include "i_recorder_profiles_service.h" 23 #endif 24 #ifdef SUPPORT_TRANSCODER 25 #include "i_transcoder_service.h" 26 #endif 27 #ifdef SUPPORT_PLAYER 28 #include "i_player_service.h" 29 #endif 30 #ifdef SUPPORT_METADATA 31 #include "i_avmetadatahelper_service.h" 32 #endif 33 #ifdef SUPPORT_SCREEN_CAPTURE 34 #include "i_screen_capture_service.h" 35 #include "i_screen_capture_monitor_service.h" 36 #include "i_screen_capture_controller.h" 37 #endif 38 #include "i_standard_monitor_service.h" 39 #ifdef SUPPORT_LPP_AUDIO_STRAMER 40 #include "i_lpp_audio_streamer_service.h" 41 #endif 42 #ifdef SUPPORT_LPP_VIDEO_STRAMER 43 #include "i_lpp_video_streamer_service.h" 44 #endif 45 46 namespace OHOS { 47 namespace Media { 48 class IMediaService { 49 public: 50 virtual ~IMediaService() = default; 51 52 #ifdef SUPPORT_RECORDER 53 /** 54 * @brief Create a recorder service. 55 * 56 * All recorder functions must be created and obtained first. 57 * 58 * @return Returns a valid pointer if the setting is successful; 59 * @since 1.0 60 * @version 1.0 61 */ 62 virtual std::shared_ptr<IRecorderService> CreateRecorderService() = 0; 63 64 /** 65 * @brief Destroy a recorder service. 66 * 67 * call the API to destroy the recorder service. 68 * 69 * @param pointer to the recorder service. 70 * @return Returns a valid pointer if the setting is successful; 71 * @since 1.0 72 * @version 1.0 73 */ 74 virtual int32_t DestroyRecorderService(std::shared_ptr<IRecorderService> recorder) = 0; 75 76 /** 77 * @brief Create a mediaprofile service. 78 * 79 * All player functions must be created and obtained first. 80 * 81 * @return Returns a valid pointer if the setting is successful; 82 * @since 3.2 83 * @version 3.2 84 */ 85 virtual std::shared_ptr<IRecorderProfilesService> CreateRecorderProfilesService() = 0; 86 87 /** 88 * @brief Destroy a mediaprofile service. 89 * 90 * call the API to destroy the mediaprofile service. 91 * 92 * @param pointer to the mediaprofile service. 93 * @return Returns a valid pointer if the setting is successful; 94 * @since 3.2 95 * @version 3.2 96 */ 97 virtual int32_t DestroyMediaProfileService(std::shared_ptr<IRecorderProfilesService> recorderProfiles) = 0; 98 #endif 99 100 #ifdef SUPPORT_TRANSCODER 101 virtual std::shared_ptr<ITransCoderService> CreateTransCoderService() = 0; 102 virtual int32_t DestroyTransCoderService(std::shared_ptr<ITransCoderService> transCoder) = 0; 103 #endif 104 105 #ifdef SUPPORT_PLAYER 106 /** 107 * @brief Create a player service. 108 * 109 * All player functions must be created and obtained first. 110 * 111 * @return Returns a valid pointer if the setting is successful; 112 * @since 1.0 113 * @version 1.0 114 */ 115 virtual std::shared_ptr<IPlayerService> CreatePlayerService() = 0; 116 117 /** 118 * @brief Destroy a player service. 119 * 120 * call the API to destroy the player service. 121 * 122 * @param pointer to the player service. 123 * @return Returns a valid pointer if the setting is successful; 124 * @since 1.0 125 * @version 1.0 126 */ 127 virtual int32_t DestroyPlayerService(std::shared_ptr<IPlayerService> player) = 0; 128 #endif 129 130 #ifdef SUPPORT_METADATA 131 /** 132 * @brief Create an avmetadatahelper service. 133 * 134 * All player functions must be created and obtained first. 135 * 136 * @return Returns a valid pointer if the setting is successful; 137 * @since 1.0 138 * @version 1.0 139 */ 140 virtual std::shared_ptr<IAVMetadataHelperService> CreateAVMetadataHelperService() = 0; 141 142 /** 143 * @brief Destroy a avmetadatahelper service. 144 * 145 * call the API to destroy the avmetadatahelper service. 146 * 147 * @param pointer to the avmetadatahelper service. 148 * @return Returns a valid pointer if the setting is successful; 149 * @since 1.0 150 * @version 1.0 151 */ 152 virtual int32_t DestroyAVMetadataHelperService(std::shared_ptr<IAVMetadataHelperService> avMetadataHelper) = 0; 153 #endif 154 155 #ifdef SUPPORT_SCREEN_CAPTURE 156 /** 157 * @brief Create an screenCaptureHelper service. 158 * 159 * All player functions must be created and obtained first. 160 * 161 * @return Returns a valid pointer if the setting is successful; 162 * @since 1.0 163 * @version 1.0 164 */ 165 virtual std::shared_ptr<IScreenCaptureService> CreateScreenCaptureService() = 0; 166 167 /** 168 * @brief Destroy a screenCaptureHelper service. 169 * 170 * call the API to destroy the screenCaptureHelper service. 171 * 172 * @param pointer to the screenCaptureHelper service. 173 * @return Returns a valid pointer if the setting is successful; 174 * @since 1.0 175 * @version 1.0 176 */ 177 virtual int32_t DestroyScreenCaptureService(std::shared_ptr<IScreenCaptureService> screenCaptureHelper) = 0; 178 179 /** 180 * @brief Create an screenCaptureMonitor service. 181 * 182 * @return Returns a valid pointer if the setting is successful; 183 * @since 1.0 184 * @version 1.0 185 */ 186 virtual std::shared_ptr<IScreenCaptureMonitorService> CreateScreenCaptureMonitorService() = 0; 187 188 /** 189 * @brief Destroy a screenCaptureMonitor service. 190 * 191 * call the API to destroy the screenCaptureMonitor service. 192 * 193 * @param pointer to the screenCaptureMonitor service. 194 * @return Returns a valid pointer if the setting is successful; 195 * @since 1.0 196 * @version 1.0 197 */ 198 virtual int32_t DestroyScreenCaptureMonitorService( 199 std::shared_ptr<IScreenCaptureMonitorService> screenCaptureMonitor) = 0; 200 201 /** 202 * @brief Create an ScreenCaptureControllerClient service. 203 * 204 * All player functions must be created and obtained first. 205 * 206 * @return Returns a valid pointer if the setting is successful; 207 * @since 1.0 208 * @version 1.0 209 */ 210 virtual std::shared_ptr<IScreenCaptureController> CreateScreenCaptureControllerClient() = 0; 211 212 /** 213 * @brief Destroy a ScreenCaptureControllerClient service. 214 * 215 * call the API to destroy the ScreenCaptureControllerClient service. 216 * 217 * @param pointer to the ScreenCaptureControllerClient service. 218 * @return Returns a valid pointer if the setting is successful; 219 * @since 1.0 220 * @version 1.0 221 */ 222 virtual int32_t DestroyScreenCaptureControllerClient(std::shared_ptr<IScreenCaptureController> controller) = 0; 223 #endif 224 225 #ifdef SUPPORT_LPP_AUDIO_STRAMER 226 227 virtual std::shared_ptr<ILppAudioStreamerService> CreateLppAudioStreamerService() = 0; 228 229 virtual int32_t DestroyLppAudioStreamerService(std::shared_ptr<ILppAudioStreamerService> lppAudioPlayer) = 0; 230 #endif 231 232 #ifdef SUPPORT_LPP_AUDIO_STRAMER 233 234 virtual std::shared_ptr<ILppVideoStreamerService> CreateLppVideoStreamerService() = 0; 235 236 virtual int32_t DestroyLppVideoStreamerService(std::shared_ptr<ILppVideoStreamerService> lppVideoPlayer) = 0; 237 #endif 238 239 /** 240 * @brief Get an monitor proxy. 241 * 242 * To communicate with the server monitor, you must first obtain the monitor proxy. 243 * 244 * @return Returns a valid pointer if the setting is successful; 245 * @since 1.0 246 * @version 1.0 247 */ 248 virtual sptr<IStandardMonitorService> GetMonitorProxy() = 0; 249 250 /** 251 * @brief Release the (service-side) proxy object monitoring client aliveness 252 */ 253 virtual void ReleaseClientListener() = 0; 254 255 virtual bool CanKillMediaService() = 0; 256 257 virtual std::vector<pid_t> GetPlayerPids() = 0; 258 259 virtual int32_t ProxyForFreeze(const std::set<int32_t>& pidList, bool isProxy) = 0; 260 261 virtual int32_t ResetAllProxy() = 0; 262 }; 263 264 class __attribute__((visibility("default"))) MediaServiceFactory { 265 public: 266 /** 267 * @brief IMediaService singleton 268 * 269 * Create Recorder Service and Player Service Through the Media Service. 270 * 271 * @return Returns IMediaService singleton; 272 * @since 1.0 273 * @version 1.0 274 */ 275 static IMediaService &GetInstance(); 276 private: 277 MediaServiceFactory() = delete; 278 ~MediaServiceFactory() = delete; 279 }; 280 } // namespace Media 281 } // namespace OHOS 282 #endif // I_MEDIA_SERVICE_H 283