• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023-2023 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 #if defined(VIDEO_SUPPORT)
16 #ifndef HISTREAMER_PLUGIN_HDI_CODEC_MANAGER_H
17 #define HISTREAMER_PLUGIN_HDI_CODEC_MANAGER_H
18 #include "codec_manager.h"
19 #include <unordered_map>
20 #include "codec_omx_ext.h"
21 #include "v4_0/icodec_component_manager.h"
22 #include "v4_0/codec_types.h"
23 
24 namespace OHOS {
25 namespace Media {
26 namespace Plugin {
27 namespace CodecAdapter {
28 namespace CodecHDI = OHOS::HDI::Codec::V4_0;
29 
30 class HdiCodecManager : public CodecManager {
31 public:
32     static HdiCodecManager& GetInstance();
33     ~HdiCodecManager() override;
34 
35     int32_t CreateComponent(const Plugin::Any& component, uint32_t& id, const std::string& name,
36                                  const Plugin::Any& appData, const Plugin::Any& callbacks) override;
37     int32_t DestroyComponent(const Plugin::Any& component, uint32_t id) override;
38 
39     Status RegisterCodecPlugins(const std::shared_ptr<OHOS::Media::Plugin::Register>& reg) override;
40     Status UnRegisterCodecPlugins() override;
41 private:
42     HdiCodecManager();
43     void Init();
44     void Reset();
45     void AddHdiCap(const CodecHDI::CodecCompCapability& hdiCap);
46     void InitCaps();
47     static std::vector<VideoPixelFormat> GetCodecFormats(const CodecHDI::CodecVideoPortCap& port);
48     static std::string GetCodecMime(const CodecHDI::AvCodecRole& role);
49     static PluginType GetCodecType(const CodecHDI::CodecType& hdiType);
50 
51     sptr<CodecHDI::ICodecComponentManager> mgr_ {nullptr};
52     std::vector<CodecCapability> codecCapabilitys_;
53 };
54 } // namespace CodecAdapter
55 } // namespace Plugin
56 } // namespace Media
57 } // namespace OHOS
58 #endif // HISTREAMER_PLUGIN_HDI_CODEC_MANAGER_H
59 #endif