1 /*
2  * Copyright (C) 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 ABS_IMAGE_ENCODER_H
17 #define ABS_IMAGE_ENCODER_H
18 
19 #include "pixel_map.h"
20 #include "image_plugin_type.h"
21 #include "output_data_stream.h"
22 #include "plugin_service.h"
23 #include "picture.h"
24 
25 namespace OHOS {
26 namespace ImagePlugin {
27 using namespace Media;
28 
29 struct PlEncodeOptions {
30     std::string format;
31     uint8_t quality = 100;
32     uint32_t numberHint = 1;
33     EncodeDynamicRange desiredDynamicRange = EncodeDynamicRange::AUTO;
34     uint16_t loop = 0;
35     std::vector<uint16_t> delayTimes;
36     std::vector<uint8_t> disposalTypes;
37     bool needsPackProperties = false;
38     bool isEditScene = true;
39 };
40 
41 class AbsImageEncoder {
42 public:
43     AbsImageEncoder() = default;
44     virtual ~AbsImageEncoder() = default;
45     virtual uint32_t StartEncode(OutputDataStream &outputStream, PlEncodeOptions &option) = 0;
46     virtual uint32_t AddImage(Media::PixelMap &pixelMap) = 0;
47     virtual uint32_t AddPicture(Media::Picture &picture) = 0;
48     virtual uint32_t FinalizeEncode() = 0;
49 
50     // define multiple subservices for this interface
51     static constexpr uint16_t SERVICE_DEFAULT = 0;
52 };
53 } // namespace ImagePlugin
54 } // namespace OHOS
55 
56 DECLARE_INTERFACE(OHOS::ImagePlugin::AbsImageEncoder, IMAGE_ENCODER_IID)
57 
58 #endif // ABS_IMAGE_ENCODER_H
59