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_CODEC_COMMON_H
17 #define IMAGE_CODEC_COMMON_H
18 
19 #include "surface_buffer.h" // foundation/graphic/graphic_surface/interfaces/inner_api/surface/surface_buffer.h
20 #include "surface_type.h" // foundation/graphic/graphic_surface/interfaces/inner_api/surface/surface_type.h
21 #include "format.h"
22 
23 namespace OHOS::ImagePlugin {
24 enum ImageCodecError : int32_t {
25     IC_ERR_OK,
26     IC_ERR_SERVICE_DIED,
27     IC_ERR_INVALID_VAL,
28     IC_ERR_INVALID_OPERATION,
29     IC_ERR_INVALID_STATE,
30     IC_ERR_NO_MEMORY,
31     IC_ERR_UNSUPPORT,
32     IC_ERR_UNKNOWN
33 };
34 
35 class ImageCodecCallback {
36 public:
37     virtual ~ImageCodecCallback() = default;
38     virtual void OnError(ImageCodecError err) = 0;
39     virtual void OnOutputFormatChanged(const Format &format) = 0;
40     virtual void OnInputBufferAvailable(uint32_t index, std::shared_ptr<ImageCodecBuffer> buffer) = 0;
41     virtual void OnOutputBufferAvailable(uint32_t index, std::shared_ptr<ImageCodecBuffer> buffer) = 0;
42 };
43 
44 class ImageCodecDescriptionKey {
45 public:
46     static constexpr char WIDTH[] = "width";
47     static constexpr char HEIGHT[] = "height";
48     static constexpr char VIDEO_DISPLAY_WIDTH[] = "video_display_width";
49     static constexpr char VIDEO_DISPLAY_HEIGHT[] = "video_display_height";
50     static constexpr char MAX_INPUT_SIZE[] = "max_input_size";
51     static constexpr char INPUT_BUFFER_COUNT[] = "input_buffer_count";
52     static constexpr char OUTPUT_BUFFER_COUNT[] = "output_buffer_count";
53     static constexpr char ENABLE_HEIF_GRID[] = "enable_heif_grid";
54     static constexpr char PIXEL_FORMAT[] = "pixel_format";
55     static constexpr char RANGE_FLAG[] = "range_flag";
56     static constexpr char COLOR_PRIMARIES[] = "color_primaries";
57     static constexpr char TRANSFER_CHARACTERISTICS[] = "transfer_characteristics";
58     static constexpr char MATRIX_COEFFICIENTS[] = "matrix_coefficients";
59     static constexpr char FRAME_RATE[] = "frame_rate";
60     static constexpr char VIDEO_FRAME_RATE_ADAPTIVE_MODE[] = "video_frame_rate_adaptive_mode";
61     static constexpr char PROCESS_NAME[] = "process_name";
62 };
63 } // namespace OHOS::ImagePlugin
64 #endif // IMAGE_CODEC_COMMON_H