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_PLAYER 25 #include "i_player_service.h" 26 #endif 27 #ifdef SUPPORT_METADATA 28 #include "i_avmetadatahelper_service.h" 29 #endif 30 #ifdef SUPPORT_CODEC 31 #include "i_avcodec_service.h" 32 #include "i_avcodeclist_service.h" 33 #endif 34 #ifdef SUPPORT_SCREEN_CAPTURE 35 #include "i_screen_capture_service.h" 36 #endif 37 #include "i_standard_monitor_service.h" 38 39 namespace OHOS { 40 namespace Media { 41 class IMediaService { 42 public: 43 virtual ~IMediaService() = default; 44 45 #ifdef SUPPORT_RECORDER 46 /** 47 * @brief Create a recorder service. 48 * 49 * All recorder functions must be created and obtained first. 50 * 51 * @return Returns a valid pointer if the setting is successful; 52 * @since 1.0 53 * @version 1.0 54 */ 55 virtual std::shared_ptr<IRecorderService> CreateRecorderService() = 0; 56 57 /** 58 * @brief Destroy a recorder service. 59 * 60 * call the API to destroy the recorder service. 61 * 62 * @param pointer to the recorder service. 63 * @return Returns a valid pointer if the setting is successful; 64 * @since 1.0 65 * @version 1.0 66 */ 67 virtual int32_t DestroyRecorderService(std::shared_ptr<IRecorderService> recorder) = 0; 68 69 /** 70 * @brief Create a mediaprofile service. 71 * 72 * All player functions must be created and obtained first. 73 * 74 * @return Returns a valid pointer if the setting is successful; 75 * @since 3.2 76 * @version 3.2 77 */ 78 virtual std::shared_ptr<IRecorderProfilesService> CreateRecorderProfilesService() = 0; 79 80 /** 81 * @brief Destroy a mediaprofile service. 82 * 83 * call the API to destroy the mediaprofile service. 84 * 85 * @param pointer to the mediaprofile service. 86 * @return Returns a valid pointer if the setting is successful; 87 * @since 3.2 88 * @version 3.2 89 */ 90 virtual int32_t DestroyMediaProfileService(std::shared_ptr<IRecorderProfilesService> recorderProfiles) = 0; 91 #endif 92 93 #ifdef SUPPORT_PLAYER 94 /** 95 * @brief Create a player service. 96 * 97 * All player functions must be created and obtained first. 98 * 99 * @return Returns a valid pointer if the setting is successful; 100 * @since 1.0 101 * @version 1.0 102 */ 103 virtual std::shared_ptr<IPlayerService> CreatePlayerService() = 0; 104 105 /** 106 * @brief Destroy a player service. 107 * 108 * call the API to destroy the player service. 109 * 110 * @param pointer to the player service. 111 * @return Returns a valid pointer if the setting is successful; 112 * @since 1.0 113 * @version 1.0 114 */ 115 virtual int32_t DestroyPlayerService(std::shared_ptr<IPlayerService> player) = 0; 116 #endif 117 118 #ifdef SUPPORT_CODEC 119 /** 120 * @brief Create a codeclist service. 121 * 122 * All player functions must be created and obtained first. 123 * 124 * @return Returns a valid pointer if the setting is successful; 125 * @since 1.0 126 * @version 1.0 127 */ 128 virtual std::shared_ptr<IAVCodecListService> CreateAVCodecListService() = 0; 129 130 /** 131 * @brief Destroy a codeclist service. 132 * 133 * call the API to destroy the codeclist service. 134 * 135 * @param pointer to the codeclist service. 136 * @return Returns a valid pointer if the setting is successful; 137 * @since 3.1 138 * @version 3.1 139 */ 140 virtual int32_t DestroyAVCodecListService(std::shared_ptr<IAVCodecListService> avCodecList) = 0; 141 142 /** 143 * @brief Create an avcodec service. 144 * 145 * All player functions must be created and obtained first. 146 * 147 * @return Returns a valid pointer if the setting is successful; 148 * @since 3.1 149 * @version 3.1 150 */ 151 virtual std::shared_ptr<IAVCodecService> CreateAVCodecService() = 0; 152 153 /** 154 * @brief Destroy a avcodec service. 155 * 156 * call the API to destroy the avcodec service. 157 * 158 * @param pointer to the avcodec service. 159 * @return Returns a valid pointer if the setting is successful; 160 * @since 3.1 161 * @version 3.1 162 */ 163 virtual int32_t DestroyAVCodecService(std::shared_ptr<IAVCodecService> avCodec) = 0; 164 #endif 165 166 #ifdef SUPPORT_METADATA 167 /** 168 * @brief Create an avmetadatahelper service. 169 * 170 * All player functions must be created and obtained first. 171 * 172 * @return Returns a valid pointer if the setting is successful; 173 * @since 1.0 174 * @version 1.0 175 */ 176 virtual std::shared_ptr<IAVMetadataHelperService> CreateAVMetadataHelperService() = 0; 177 178 /** 179 * @brief Destroy a avmetadatahelper service. 180 * 181 * call the API to destroy the avmetadatahelper service. 182 * 183 * @param pointer to the avmetadatahelper service. 184 * @return Returns a valid pointer if the setting is successful; 185 * @since 1.0 186 * @version 1.0 187 */ 188 virtual int32_t DestroyAVMetadataHelperService(std::shared_ptr<IAVMetadataHelperService> avMetadataHelper) = 0; 189 #endif 190 191 #ifdef SUPPORT_SCREEN_CAPTURE 192 /** 193 * @brief Create an screenCaptureHelper service. 194 * 195 * All player functions must be created and obtained first. 196 * 197 * @return Returns a valid pointer if the setting is successful; 198 * @since 1.0 199 * @version 1.0 200 */ 201 virtual std::shared_ptr<IScreenCaptureService> CreateScreenCaptureService() = 0; 202 203 /** 204 * @brief Destroy a screenCaptureHelper service. 205 * 206 * call the API to destroy the screenCaptureHelper service. 207 * 208 * @param pointer to the screenCaptureHelper service. 209 * @return Returns a valid pointer if the setting is successful; 210 * @since 1.0 211 * @version 1.0 212 */ 213 virtual int32_t DestroyScreenCaptureService(std::shared_ptr<IScreenCaptureService> screenCaptureHelper) = 0; 214 #endif 215 216 /** 217 * @brief Get an monitor proxy. 218 * 219 * To communicate with the server monitor, you must first obtain the monitor proxy. 220 * 221 * @return Returns a valid pointer if the setting is successful; 222 * @since 1.0 223 * @version 1.0 224 */ 225 virtual sptr<IStandardMonitorService> GetMonitorProxy() = 0; 226 }; 227 228 class __attribute__((visibility("default"))) MediaServiceFactory { 229 public: 230 /** 231 * @brief IMediaService singleton 232 * 233 * Create Recorder Service and Player Service Through the Media Service. 234 * 235 * @return Returns IMediaService singleton; 236 * @since 1.0 237 * @version 1.0 238 */ 239 static IMediaService &GetInstance(); 240 private: 241 MediaServiceFactory() = delete; 242 ~MediaServiceFactory() = delete; 243 }; 244 } // namespace Media 245 } // namespace OHOS 246 #endif // I_MEDIA_SERVICE_H 247