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_CORE_COMPATIBLE_CHECK_H 17 #define HISTREAMER_PIPELINE_CORE_COMPATIBLE_CHECK_H 18 19 #include "pipeline/core/type_define.h" 20 #include "plugin/common/plugin_caps.h" 21 #include "plugin/common/plugin_meta.h" 22 23 namespace OHOS { 24 namespace Media { 25 namespace Pipeline { 26 /** 27 * merge otherCap keys with originCap keys: 28 * 1. if key exists in only one Cap (e.g. only exists in originCap or otherCap), then put key into resCap directly 29 * 2. if key exists in both originCap and otherCap, then intersections will be calculated 30 * 2.1 if intersections of any key is empty, return false 31 * 2.2 otherwise, put intersections into resCap 32 * The mime of resCap is not set. 33 * 34 * @param originCap originCap 35 * @param otherCap otherCap 36 * @param resCap out parameter. The merge result is in it. 37 * @return success 38 */ 39 bool MergeCapabilityKeys(const Capability& originCap, const Capability& otherCap, Capability& resCap); 40 41 /** 42 * merge otherCap with originCap. The rule of merging keys is the same as MergeCapabilityKeys. Besides, it requires that 43 * mime in originCap should be subset of mime in otherCap. The mime of resCap is set as originCap.mime. 44 * 45 * @param originCap originCap 46 * @param otherCap otherCap 47 * @param resCap out parameter. The merge result is in it. 48 * @return success 49 */ 50 bool MergeCapability(const Capability& originCap, const Capability& otherCap, Capability& resCap); 51 52 53 /** 54 * change meta info capability 55 * 56 * @param meta target meta 57 * @return result capability 58 */ 59 std::shared_ptr<Capability> MetaToCapability(const Plugin::Meta& meta); 60 61 /** 62 * merge meta with capability. This function firstly change meta into capability metaCap. The mime of metaCap is the 63 * the same as cap. Then, merge metaCap and cap. 64 * After that, output the resMeta according merge result and origin meta, as the following rules: 65 * 1. if one meta key only exist in origin meta, put it into resMeta 66 * 2. if one meta key exist in both origin meta and capability merge results, then translate the one in capability merge 67 * results into fixed values 68 * 69 * @param meta origin meta 70 * @param cap origin cap 71 * @param resMeta result meta 72 * @return success to merge 73 */ 74 bool MergeMetaWithCapability(const Plugin::Meta& meta, const Capability& cap, Plugin::Meta& resMeta); 75 76 bool ApplyCapabilitySet(const Capability& originCap, const CapabilitySet& capabilitySet, Capability& resCap); 77 } 78 } 79 } 80 #endif // HISTREAMER_PIPELINE_CORE_COMPATIBLE_CHECK_H 81