• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-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 #if !defined(OHOS_LITE) && defined(VIDEO_SUPPORT)
17 #ifndef HISTREAMER_PLUGIN_CORE_HDI_UTILS_H
18 #define HISTREAMER_PLUGIN_CORE_HDI_UTILS_H
19 
20 #include <iostream>
21 #include "hdi_adapter.h"
22 
23 namespace OHOS {
24 namespace Media {
25 namespace Plugin {
26 std::string OmxStateToString(OMX_STATETYPE state);
27 
28 std::string HdfStatus2String(int32_t status);
29 
30 std::string PortIndex2String(PortIndex portIndex);
31 
32 template<typename T, typename U>
33 bool TranslatesByMap(const T& t, U& u, const std::pair<T, U>* transMap, size_t mapSize);
34 
35 Status TranslateRets(const int32_t& ret);
36 
37 /**
38  * translate type T into type U
39  *
40  * @tparam T
41  * @tparam U
42  * @return success to translate
43  */
44 template<typename T, typename U,
45          typename std::enable_if<!std::is_same<typename std::decay<T>::type,
46          typename std::decay<U>::type>::value, bool>::type = true>
47 bool Translates(const T&, U&);
48 
49 uint64_t Translate2PluginFlagSet(uint32_t omxBufFlag);
50 
51 uint32_t Translate2omxFlagSet(uint64_t pluginFlags);
52 
53 VideoPixelFormat ConvertPixelFormatFromHdi(int32_t HdiPixelFormat);
54 
55 template <typename T>
InitOmxParam(T & param,CompVerInfo & verInfo)56 inline void InitOmxParam(T& param, CompVerInfo& verInfo)
57 {
58     memset_s(&param, sizeof(param), 0x0, sizeof(param));
59     param.nSize = sizeof(param);
60     param.nVersion.s.nVersionMajor = verInfo.compVersion.s.nVersionMajor;
61 }
62 
63 template <typename T>
InitHdiParam(T & param,CompVerInfo & verInfo)64 inline void InitHdiParam(T& param, CompVerInfo& verInfo)
65 {
66     memset_s(&param, sizeof(param), 0x0, sizeof(param));
67     param.size = sizeof(param);
68     param.version.s.nVersionMajor = verInfo.compVersion.s.nVersionMajor;
69 }
70 } // namespace Plugin
71 } // namespace Media
72 } // namespace OHOS
73 #endif // HISTREAMER_PLUGIN_CORE_HDI_UTILS_H
74 #endif