1 /* 2 * Copyright (c) 2023-2023 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 <string> 20 #include <vector> 21 #include <memory> 22 #include "common/status.h" 23 #include "filter/filter.h" 24 #include "osal/task/mutex.h" 25 26 namespace OHOS { 27 namespace Media { 28 namespace Pipeline { 29 class FilterCallback; 30 31 class Pipeline : public EventReceiver { 32 public: 33 ~Pipeline(); 34 35 void Init(const std::shared_ptr<EventReceiver>& receiver, 36 const std::shared_ptr<FilterCallback>& callback, const std::string& groupId); 37 38 Status Prepare(); 39 40 Status Start(); 41 42 Status Pause(); 43 44 Status Resume(); 45 46 Status Stop(); 47 48 Status Flush(); 49 50 Status Release(); 51 52 Status Preroll(bool render); 53 54 Status SetPlayRange(int64_t start, int64_t end); 55 56 Status AddHeadFilters(std::vector<std::shared_ptr<Filter>> filters); 57 58 Status RemoveHeadFilter(const std::shared_ptr<Filter>& filter); 59 60 Status LinkFilters(const std::shared_ptr<Filter>& preFilter, 61 const std::vector<std::shared_ptr<Filter>>& filters, StreamType type, bool needTurbo = false, 62 bool needInit = true); 63 64 Status UpdateFilters(const std::shared_ptr<Filter>& preFilter, 65 const std::vector<std::shared_ptr<Filter>>& filters, StreamType type); 66 67 Status UnLinkFilters(const std::shared_ptr<Filter>& preFilter, 68 const std::vector<std::shared_ptr<Filter>>& filters, StreamType type); 69 70 void OnEvent(const Event& event) override; 71 72 static int32_t GetNextPipelineId(); 73 private: 74 std::string groupId_; 75 Mutex mutex_ {}; 76 std::vector<std::shared_ptr<Filter>> filters_ {}; 77 std::shared_ptr<EventReceiver> eventReceiver_ {nullptr}; 78 std::shared_ptr<FilterCallback> filterCallback_ {nullptr}; 79 }; 80 } // namespace Pipeline 81 } // namespace Media 82 } // namespace OHOS 83 #endif // HISTREAMER_PIPELINE_CORE_PIPELINE_H 84