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_ENGINE_FACTORY_H 17 #define I_ENGINE_FACTORY_H 18 19 #include <string> 20 #include <memory> 21 #ifdef SUPPORT_PLAYER 22 #include "i_player_engine.h" 23 #endif 24 #ifdef SUPPORT_RECORDER 25 #include "i_recorder_engine.h" 26 #endif 27 #ifdef SUPPORT_METADATA 28 #include "i_avmetadatahelper_engine.h" 29 #endif 30 #ifdef SUPPORT_CODEC 31 #include "i_avcodec_engine.h" 32 #include "i_avcodeclist_engine.h" 33 #endif 34 35 namespace OHOS { 36 namespace Media { 37 class IEngineFactory { 38 public: 39 enum class Scene { 40 SCENE_PLAYBACK, 41 SCENE_AVMETADATA, 42 SCENE_RECORDER, 43 SCENE_AVCODEC, 44 SCENE_AVCODECLIST, 45 }; 46 47 virtual ~IEngineFactory() = default; 48 virtual int32_t Score(Scene scene, const std::string &uri = "") 49 { 50 (void)scene; 51 (void)uri; 52 return 0; 53 } 54 55 #ifdef SUPPORT_PLAYER 56 virtual std::unique_ptr<IPlayerEngine> CreatePlayerEngine(int32_t uid = 0, int32_t pid = 0, uint32_t tokenId = 0) 57 { 58 (void)uid; 59 (void)pid; 60 (void)tokenId; 61 return nullptr; 62 } 63 #endif 64 65 #ifdef SUPPORT_RECORDER CreateRecorderEngine(int32_t appUid,int32_t appPid,uint32_t appTokenId,uint64_t appFullTokenId)66 virtual std::unique_ptr<IRecorderEngine> CreateRecorderEngine(int32_t appUid, int32_t appPid, uint32_t appTokenId, 67 uint64_t appFullTokenId) 68 { 69 (void)appUid; 70 (void)appPid; 71 (void)appTokenId; 72 (void)appFullTokenId; 73 return nullptr; 74 } 75 #endif 76 77 #ifdef SUPPORT_METADATA CreateAVMetadataHelperEngine()78 virtual std::unique_ptr<IAVMetadataHelperEngine> CreateAVMetadataHelperEngine() 79 { 80 return nullptr; 81 } 82 #endif 83 84 #ifdef SUPPORT_CODEC CreateAVCodecEngine()85 virtual std::unique_ptr<IAVCodecEngine> CreateAVCodecEngine() 86 { 87 return nullptr; 88 } 89 CreateAVCodecListEngine()90 virtual std::unique_ptr<IAVCodecListEngine> CreateAVCodecListEngine() 91 { 92 return nullptr; 93 } 94 #endif 95 96 protected: 97 static constexpr int32_t MAX_SCORE = 100; 98 static constexpr int32_t MIN_SCORE = 0; 99 }; 100 } // namespace Media 101 } // namespace OHOS 102 #endif