• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2022 Shenzhen Kaihong DID 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 COMPONENT_MGR_H
17 #define COMPONENT_MGR_H
18 #include <OMX_Component.h>
19 #include <OMX_Core.h>
20 #include <list>
21 #include <map>
22 #include <mutex>
23 #include <vector>
24 #include "codec_omx_core.h"
25 #include "icomponent_mgr.h"
26 namespace OHOS {
27 namespace Codec {
28 namespace Omx {
29 class ComponentMgr : public IComponentMgr {
30 public:
31     using OMXComponent = struct {
32         OMX_HANDLETYPE handle;
33         std::shared_ptr<CodecOMXCore> core;
34     };
35 
36 public:
37     ComponentMgr();
38     ~ComponentMgr();
39     ComponentMgr(const ComponentMgr &) = delete;
40     ComponentMgr &operator=(const ComponentMgr &) = delete;
41 
42     virtual int32_t CreateComponentInstance(const char *componentName, const OMX_CALLBACKTYPE *callbacks, void *appData,
43                                             OMX_COMPONENTTYPE **component);
44 
45     virtual int32_t DeleteComponentInstance(OMX_COMPONENTTYPE *component);
46 
47     virtual int32_t GetRolesForComponent(const char *componentName, std::vector<std::string> *roles);
48 
49 private:
50     void AddVendorComponent();
51     void AddSoftComponent();
52     void AddComponentByLibName(const char *libName);
53     void CleanComponent();
54 
55 private:
56     std::vector<std::shared_ptr<CodecOMXCore>> cores_;                    // save all the core
57     std::map<std::string, std::shared_ptr<CodecOMXCore>> compoentsCore_;  // save the compoentname<--> core
58     std::vector<OMXComponent> components_;                                // save the opened compoents
59     std::mutex mutex_;
60 };
61 }  // namespace Omx
62 }  // namespace Codec
63 }  // namespace OHOS
64 
65 #endif