• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2024 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 IMAGE_EFFECT_EFFECT_H
17 #define IMAGE_EFFECT_EFFECT_H
18 
19 #include "efilter.h"
20 
21 namespace OHOS {
22 namespace Media {
23 namespace Effect {
24 class Effect {
25 public:
26     Effect() = default;
27 
28     virtual ~Effect() = default;
29 
30     /**
31      * Adds an EFilter to the collection.
32      *
33      * @param efilter The EFilter to be added, provided as a shared pointer.
34      * This function does not return any value.
35      */
36     virtual void AddEFilter(const std::shared_ptr<EFilter> &efilter);
37 
38     /**
39      * Virtual function to insert an EFilter at a specified index.
40      * @param efilter A shared pointer to the EFilter object to be inserted.
41      * @param index The position at which the EFilter should be inserted.
42      * @return ErrorCode indicating the result of the operation.
43      */
44     virtual ErrorCode InsertEFilter(const std::shared_ptr<EFilter> &efilter, uint32_t index);
45 
46     /**
47      * Removes the specified EFilter from the collection.
48      *
49      * @param efilter The EFilter to be removed.
50      */
51     virtual void RemoveEFilter(const std::shared_ptr<EFilter> &efilter);
52 
53     /**
54      * Removes an EFilter at a specified index.
55      *
56      * @param index The position of the EFilter to be removed.
57      * @return ErrorCode indicating the result of the operation.
58      */
59     virtual ErrorCode RemoveEFilter(uint32_t index);
60 
61     /**
62      * Replaces an EFilter at a specified index with a new EFilter.
63      *
64      * @param efilter A shared pointer to the new EFilter object.
65      * @param index The position at which the new EFilter should replace the old one.
66      * @return ErrorCode indicating the result of the operation.
67      */
68     virtual ErrorCode ReplaceEFilter(const std::shared_ptr<EFilter> &efilter, uint32_t index);
69 
70     /**
71      * Virtual function to start the effect processing.
72      * Must be implemented by derived classes.
73      *
74      * @return ErrorCode indicating the result of the operation.
75      */
76     virtual ErrorCode Start() = 0;
77 
78     /**
79      * Virtual function to save the effect configuration.
80      * Must be implemented by derived classes.
81      *
82      * @param res A reference to a shared pointer for storing the result in JSON format.
83      * @return ErrorCode indicating the result of the operation.
84      */
85     virtual ErrorCode Save(EffectJsonPtr &res) = 0;
86 
87     /**
88      * Retrieves the collection of EFilters.
89      *
90      * @return A reference to a vector containing shared pointers to EFilter objects.
91      */
GetEFilters()92     std::vector<std::shared_ptr<EFilter>> &GetEFilters()
93     {
94         return efilters_;
95     }
96 protected:
97     // Collection of EFilters
98     std::vector<std::shared_ptr<EFilter>> efilters_;
99 };
100 } // namespace Effect
101 } // namespace Media
102 } // namespace OHOS
103 #endif // IMAGE_EFFECT_EFFECT_H
104