1fa7767c5Sopenharmony_ci/* 2fa7767c5Sopenharmony_ci * Copyright (c) 2023-2023 Huawei Device Co., Ltd. 3fa7767c5Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4fa7767c5Sopenharmony_ci * you may not use this file except in compliance with the License. 5fa7767c5Sopenharmony_ci * You may obtain a copy of the License at 6fa7767c5Sopenharmony_ci * 7fa7767c5Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8fa7767c5Sopenharmony_ci * 9fa7767c5Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10fa7767c5Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11fa7767c5Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12fa7767c5Sopenharmony_ci * See the License for the specific language governing permissions and 13fa7767c5Sopenharmony_ci * limitations under the License. 14fa7767c5Sopenharmony_ci */ 15fa7767c5Sopenharmony_ci 16fa7767c5Sopenharmony_ci#ifndef HISTREAMER_PIPELINE_CORE_PIPELINE_H 17fa7767c5Sopenharmony_ci#define HISTREAMER_PIPELINE_CORE_PIPELINE_H 18fa7767c5Sopenharmony_ci 19fa7767c5Sopenharmony_ci#include <string> 20fa7767c5Sopenharmony_ci#include <vector> 21fa7767c5Sopenharmony_ci#include <memory> 22fa7767c5Sopenharmony_ci#include "common/status.h" 23fa7767c5Sopenharmony_ci#include "filter/filter.h" 24fa7767c5Sopenharmony_ci#include "osal/task/mutex.h" 25fa7767c5Sopenharmony_ci 26fa7767c5Sopenharmony_cinamespace OHOS { 27fa7767c5Sopenharmony_cinamespace Media { 28fa7767c5Sopenharmony_cinamespace Pipeline { 29fa7767c5Sopenharmony_ciclass FilterCallback; 30fa7767c5Sopenharmony_ci 31fa7767c5Sopenharmony_ciclass Pipeline : public EventReceiver { 32fa7767c5Sopenharmony_cipublic: 33fa7767c5Sopenharmony_ci ~Pipeline(); 34fa7767c5Sopenharmony_ci 35fa7767c5Sopenharmony_ci void Init(const std::shared_ptr<EventReceiver>& receiver, 36fa7767c5Sopenharmony_ci const std::shared_ptr<FilterCallback>& callback, const std::string& groupId); 37fa7767c5Sopenharmony_ci 38fa7767c5Sopenharmony_ci Status Prepare(); 39fa7767c5Sopenharmony_ci 40fa7767c5Sopenharmony_ci Status Start(); 41fa7767c5Sopenharmony_ci 42fa7767c5Sopenharmony_ci Status Pause(); 43fa7767c5Sopenharmony_ci 44fa7767c5Sopenharmony_ci Status Resume(); 45fa7767c5Sopenharmony_ci 46fa7767c5Sopenharmony_ci Status Stop(); 47fa7767c5Sopenharmony_ci 48fa7767c5Sopenharmony_ci Status Flush(); 49fa7767c5Sopenharmony_ci 50fa7767c5Sopenharmony_ci Status Release(); 51fa7767c5Sopenharmony_ci 52fa7767c5Sopenharmony_ci Status Preroll(bool render); 53fa7767c5Sopenharmony_ci 54fa7767c5Sopenharmony_ci Status SetPlayRange(int64_t start, int64_t end); 55fa7767c5Sopenharmony_ci 56fa7767c5Sopenharmony_ci Status AddHeadFilters(std::vector<std::shared_ptr<Filter>> filters); 57fa7767c5Sopenharmony_ci 58fa7767c5Sopenharmony_ci Status RemoveHeadFilter(const std::shared_ptr<Filter>& filter); 59fa7767c5Sopenharmony_ci 60fa7767c5Sopenharmony_ci Status LinkFilters(const std::shared_ptr<Filter>& preFilter, 61fa7767c5Sopenharmony_ci const std::vector<std::shared_ptr<Filter>>& filters, StreamType type); 62fa7767c5Sopenharmony_ci 63fa7767c5Sopenharmony_ci Status UpdateFilters(const std::shared_ptr<Filter>& preFilter, 64fa7767c5Sopenharmony_ci const std::vector<std::shared_ptr<Filter>>& filters, StreamType type); 65fa7767c5Sopenharmony_ci 66fa7767c5Sopenharmony_ci Status UnLinkFilters(const std::shared_ptr<Filter>& preFilter, 67fa7767c5Sopenharmony_ci const std::vector<std::shared_ptr<Filter>>& filters, StreamType type); 68fa7767c5Sopenharmony_ci 69fa7767c5Sopenharmony_ci void OnEvent(const Event& event) override; 70fa7767c5Sopenharmony_ci 71fa7767c5Sopenharmony_ci static int32_t GetNextPipelineId(); 72fa7767c5Sopenharmony_ciprivate: 73fa7767c5Sopenharmony_ci std::string groupId_; 74fa7767c5Sopenharmony_ci Mutex mutex_ {}; 75fa7767c5Sopenharmony_ci std::vector<std::shared_ptr<Filter>> filters_ {}; 76fa7767c5Sopenharmony_ci std::shared_ptr<EventReceiver> eventReceiver_ {nullptr}; 77fa7767c5Sopenharmony_ci std::shared_ptr<FilterCallback> filterCallback_ {nullptr}; 78fa7767c5Sopenharmony_ci}; 79fa7767c5Sopenharmony_ci} // namespace Pipeline 80fa7767c5Sopenharmony_ci} // namespace Media 81fa7767c5Sopenharmony_ci} // namespace OHOS 82fa7767c5Sopenharmony_ci#endif // HISTREAMER_PIPELINE_CORE_PIPELINE_H 83