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_PIPELINE_H 17 #define HISTREAMER_PIPELINE_CORE_PIPELINE_H 18 19 #include <initializer_list> 20 #include <memory> 21 22 #include "pipeline/core/filter.h" 23 24 namespace OHOS { 25 namespace Media { 26 namespace Pipeline { 27 class Pipeline : public EventReceiver { 28 public: 29 ~Pipeline() override = default; 30 virtual void Init(EventReceiver* receiver, FilterCallback* callback) = 0; 31 virtual ErrorCode Prepare() = 0; 32 virtual ErrorCode Start() = 0; 33 virtual ErrorCode Pause() = 0; 34 virtual ErrorCode Resume() = 0; 35 virtual ErrorCode Stop() = 0; 36 37 // 清除缓存 38 virtual void FlushStart() = 0; 39 virtual void FlushEnd() = 0; 40 41 /** 42 * 添加Filter到Pipeline 43 * 44 * 添加后的Filter,才会被初始化,才能使用。 45 * 46 * @param filters 要添加的filter 47 * @return 48 */ 49 virtual ErrorCode AddFilters(std::initializer_list<Filter*> filters) = 0; 50 51 virtual ErrorCode RemoveFilter(Filter* filter) = 0; 52 53 virtual ErrorCode RemoveFilterChain(Filter* firstFilter) = 0; 54 55 /** 56 * 连接Filter的默认端口 57 * 58 * 前一个Filter的默认输出端口,与后一个Filter的默认输入端口连接 59 * 60 * @param filters 要连接的filter 61 * @return 62 */ 63 virtual ErrorCode LinkFilters(std::initializer_list<Filter*> filters) = 0; 64 65 /** 66 * 连接两个端口 67 * 68 * 端口所属的Filter必须已经添加到Pipeline,否则报错 69 * 70 * @param port1 前一个节点的输出端口 71 * @return 72 */ 73 virtual ErrorCode LinkPorts(std::shared_ptr<OutPort> port1, std::shared_ptr<InPort> port2) = 0; 74 }; 75 } // namespace Pipeline 76 } // namespace Media 77 } // namespace OHOS 78 79 #endif // HISTREAMER_PIPELINE_CORE_PIPELINE_H