• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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, const std::shared_ptr<FilterCallback>& callback);
36 
37     Status Prepare();
38 
39     Status Start();
40 
41     Status Pause();
42 
43     Status Resume();
44 
45     Status Stop();
46 
47     Status Flush();
48 
49     Status Release();
50 
51     Status AddHeadFilters(std::vector<std::shared_ptr<Filter>> filters);
52 
53     Status RemoveHeadFilter(const std::shared_ptr<Filter>& filter);
54 
55     Status LinkFilters(const std::shared_ptr<Filter>& preFilter,
56                        const std::vector<std::shared_ptr<Filter>>& filters, StreamType type);
57 
58     Status UpdateFilters(const std::shared_ptr<Filter>& preFilter,
59                          const std::vector<std::shared_ptr<Filter>>& filters, StreamType type);
60 
61     Status UnLinkFilters(const std::shared_ptr<Filter>& preFilter,
62                          const std::vector<std::shared_ptr<Filter>>& filters, StreamType type);
63 
64     void OnEvent(const Event& event) override;
65 private:
66     FilterState state_ {FilterState::CREATED};
67     Mutex mutex_ {};
68     std::vector<std::shared_ptr<Filter>> filters_ {};
69     std::shared_ptr<EventReceiver> eventReceiver_ {nullptr};
70     std::shared_ptr<FilterCallback> filterCallback_ {nullptr};
71 };
72 } // namespace Pipeline
73 } // namespace Media
74 } // namespace OHOS
75 #endif // HISTREAMER_PIPELINE_CORE_PIPELINE_H
76