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 PLATFORM_ADP_H 17 #define PLATFORM_ADP_H 18 19 #include <string> 20 #include "nocopyable.h" 21 #include "singleton.h" 22 #include "plugin_errors.h" 23 #ifdef _WIN32 24 #include <windows.h> 25 #else 26 #include <dlfcn.h> 27 #endif 28 29 namespace OHOS { 30 namespace MultimediaPlugin { 31 class PlatformAdp final : public NoCopyable { 32 public: 33 #ifdef _WIN32 34 HMODULE AdpLoadLibrary(const std::string &packageName); 35 void AdpFreeLibrary(HMODULE handle); 36 FARPROC AdpGetSymAddress(HMODULE handle, const std::string &symbol); 37 #else 38 void *LoadLibrary(const std::string &packageName); 39 void FreeLibrary(void *handle); 40 void *GetSymAddress(void *handle, const std::string &symbol); 41 #endif 42 43 uint32_t CheckAndNormalizePath(std::string &path); 44 DECLARE_DELAYED_REF_SINGLETON(PlatformAdp); 45 46 public: 47 static const std::string DIR_SEPARATOR; 48 static const std::string LIBRARY_FILE_SUFFIX; 49 }; 50 } // namespace MultimediaPlugin 51 } // namespace OHOS 52 53 #endif // PLATFORM_ADP_H 54