• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2021 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 HISTREAMER_PIPELINE_FILTER_PLUGIN_UTILS_H
17 #define HISTREAMER_PIPELINE_FILTER_PLUGIN_UTILS_H
18 
19 #include <functional>
20 #include <memory>
21 
22 #include "pipeline/core/error_code.h"
23 #include "pipeline/core/compatible_check.h"
24 #include "plugin/common/plugin_types.h"
25 #include "plugin/common/plugin_tags.h"
26 #include "plugin/common/plugin_buffer.h"
27 #include "plugin/core/plugin_info.h"
28 #include "plugin/core/plugin_manager.h"
29 #include "plugin/core/plugin_meta.h"
30 #include "pipeline/core/type_define.h"
31 
32 namespace OHOS {
33 namespace Media {
34 namespace Pipeline {
35 #define RETURN_AGAIN_IF_NULL(plugin) \
36 do { \
37     if ((plugin) == nullptr) { \
38         return ErrorCode::ERROR_AGAIN; \
39     } \
40 } while (0)
41 
42 template<typename T>
43 bool AssignParameterIfMatch(Tag tag, T& ret, const Plugin::ValueType& val);
44 
45 /**
46  * translate plugin error into pipeline error code
47  * @param pluginError
48  * @return
49  */
50 ErrorCode TranslatePluginStatus(Plugin::Status pluginError);
51 
52 bool TranslateIntoParameter(const int &key, OHOS::Media::Plugin::Tag &tag);
53 
54 std::vector<std::pair<std::shared_ptr<Plugin::PluginInfo>, Plugin::Capability>>
55         FindAvailablePlugins(const Plugin::Capability& upStreamCaps, Plugin::PluginType pluginType);
56 
57 std::vector<std::shared_ptr<Plugin::PluginInfo>> FindAvailablePluginsByOutputMime(const std::string& outputMime,
58                                                                                   Plugin::PluginType pluginType);
59 uint8_t GetBytesPerSample(Plugin::AudioSampleFormat fmt);
60 
61 std::string Capability2String(const Capability& capability);
62 
63 std::string Meta2String(const Plugin::Meta& meta);
64 } // Pipeline
65 } // Media
66 } // OHOS
67 #endif // HISTREAMER_PIPELINE_FILTER_PLUGIN_UTILS_H
68