• 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 #include "component_manager.h"
17 #include <hdf_log.h>
18 #include "codec_interface.h"
19 #include "hdf_base.h"
20 
21 #define HDF_LOG_TAG codec_hdi_passthrough
22 
23 namespace OHOS {
24 namespace Codec {
25 namespace CodecAdapter {
CreateComponentInstance(const char * componentName,CODEC_HANDLETYPE & component)26 int32_t ComponentManager::CreateComponentInstance(const char *componentName, CODEC_HANDLETYPE &component)
27 {
28     HDF_LOGI("ComponentManager::CreateComponentInstance:%{public}s", componentName);
29     int32_t ret = CodecCreate(componentName, &component);
30     if (ret != HDF_SUCCESS) {
31         HDF_LOGE("%{public}s error, CodecCreate failed errNo: %{public}x", __func__, ret);
32     }
33     return ret;
34 }
35 
DeleteComponentInstance(CODEC_HANDLETYPE component)36 int32_t ComponentManager::DeleteComponentInstance(CODEC_HANDLETYPE component)
37 {
38     if (component == nullptr) {
39         HDF_LOGE("%{public}s error, component is null ", __func__);
40         return HDF_ERR_INVALID_PARAM;
41     }
42     int32_t ret = CodecDestroy(component);
43     if (ret != HDF_SUCCESS) {
44         HDF_LOGE("%{public}s error, CodecDestroy failed errNo: %{public}x", __func__, ret);
45     }
46     return ret;
47 }
48 
Init()49 int32_t ComponentManager::Init()
50 {
51     int32_t ret = CodecInit();
52     if (ret != HDF_SUCCESS) {
53         HDF_LOGE("%{public}s error, CodecInit failed errNo: %{public}x", __func__, ret);
54     }
55     return ret;
56 }
57 
Deinit()58 int32_t ComponentManager::Deinit()
59 {
60     int32_t ret = CodecDeinit();
61     if (ret != HDF_SUCCESS) {
62         HDF_LOGE("%{public}s error, CodecDeinit failed errNo: %{public}x", __func__, ret);
63     }
64     return ret;
65 }
66 }  // namespace CodecAdapter
67 }  // namespace Codec
68 }  // namespace OHOS
69