• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 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 HDI_INIT_H_
17 #define HDI_INIT_H_
18 
19 #include <gst/gst.h>
20 #include <memory>
21 #include <unordered_map>
22 #include <mutex>
23 #include "avcodec_info.h"
24 #include "codec_component_manager.h"
25 #include "hdf_remote_service.h"
26 #include "codec_internal.h"
27 #include "servmgr_hdi.h"
28 namespace OHOS {
29 namespace Media {
30 class HdiInit {
31 public:
32     static HdiInit &GetInstance();
33     ~HdiInit();
34     int32_t GetHandle(CodecComponentType **component, uint32_t &id, std::string name,
35         void *appData, CodecCallbackType *callbacks);
36     int32_t FreeHandle(CodecComponentType *component, uint32_t id);
37     std::vector<CapabilityData> GetCapabilitys();
38     void CodecComponentManagerReset();
39     void CodecComponentManagerInit();
40 
41 private:
42     HdiInit();
43     using GetProfileLevelsFunc = std::map<int32_t, std::vector<int32_t>> (*)(CodecCompCapability &hdiCap);
44     static std::string GetCodecName(std::string hdiName);
45     static int32_t GetCodecType(CodecType hdiType);
46     static std::string GetCodecMime(AvCodecRole &role);
47     static std::vector<int32_t> GetCodecFormats(CodecVideoPortCap &port);
48     static std::vector<int32_t> GetOmxFormats(CodecVideoPortCap &port);
49     static std::vector<int32_t> GetBitrateMode(CodecVideoPortCap &port);
50     static std::map<ImgSize, Range> GetMeasuredFrameRate(CodecVideoPortCap &port);
51     static std::map<int32_t, std::vector<int32_t>> GetH264ProfileLevels(CodecCompCapability &hdiCap);
52     static std::map<int32_t, std::vector<int32_t>> GetH265ProfileLevels(CodecCompCapability &hdiCap);
53     static std::map<int32_t, std::vector<int32_t>> GetCodecProfileLevels(CodecCompCapability &hdiCap);
54     void AddHdiCap(CodecCompCapability &hdiCap);
55     void InitCaps();
56     const static std::unordered_map<int32_t, GetProfileLevelsFunc> PROFILE_LEVEL_FUNC_MAP;
57     std::vector<CapabilityData> capabilitys_;
58     CodecComponentManager *mgr_ = nullptr;
59     std::mutex mutex_;
60     std::map<CodecComponentType *, uint32_t> handleMap_;
61 };
62 }
63 }
64 #endif /* HDI_INIT_H_ */
65