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 "foundation/error_code.h" 23 #include "utils/type_define.h" 24 #include "pipeline/core/compatible_check.h" 25 #include "plugin/common/plugin_types.h" 26 #include "plugin/common/plugin_tags.h" 27 #include "plugin/common/plugin_buffer.h" 28 #include "plugin/core/plugin_info.h" 29 #include "plugin/core/plugin_manager.h" 30 #include "plugin/core/plugin_meta.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 /** 43 * translate plugin error into pipeline error code 44 * @param pluginError 45 * @return 46 */ 47 ErrorCode TranslatePluginStatus(Plugin::Status pluginError); 48 49 bool TranslateIntoParameter(const int &key, OHOS::Media::Plugin::Tag &tag); 50 51 std::vector<std::pair<std::shared_ptr<Plugin::PluginInfo>, Plugin::Capability>> 52 FindAvailablePlugins(const Plugin::Capability& upStreamCaps, Plugin::PluginType pluginType); 53 54 std::vector<std::shared_ptr<Plugin::PluginInfo>> FindAvailablePluginsByOutputMime(const std::string& outputMime, 55 Plugin::PluginType pluginType); 56 uint8_t GetBytesPerSample(Plugin::AudioSampleFormat fmt); 57 58 std::string Capability2String(const Capability& capability); 59 60 std::string Meta2String(const Plugin::Meta& meta); 61 } // Pipeline 62 } // Media 63 } // OHOS 64 #endif // HISTREAMER_PIPELINE_FILTER_PLUGIN_UTILS_H 65