• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 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 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 OHOS_HDI_CODEC_V2_1_CODECIMAGESERVICE_H
17 #define OHOS_HDI_CODEC_V2_1_CODECIMAGESERVICE_H
18 
19 #include <map>
20 #include <mutex>
21 #include "buffer_handle.h"
22 #include "codec_image_config.h"
23 #include "v2_1/icodec_image.h"
24 #include "codec_jpeg_service.h"
25 #include "codec_heif_encode_service.h"
26 #include "codec_heif_decode_service.h"
27 
28 constexpr uint32_t CODEC_IMAGE_MAX_BUFFER_SIZE = 50 * 1024 *1024;
29 namespace OHOS {
30 namespace HDI {
31 namespace Codec {
32 namespace Image {
33 namespace V2_1 {
34 class CodecImageService : public ICodecImage {
35 public:
36     explicit CodecImageService();
37 
38     virtual ~CodecImageService() = default;
39 
40     int32_t NotifyPowerOn(enum CodecImageRole role) override;
41 
42     int32_t GetImageCapability(std::vector<CodecImageCapability>& capList) override;
43 
44     int32_t Init(enum CodecImageRole role) override;
45 
46     int32_t DeInit(enum CodecImageRole role) override;
47 
48     int32_t DoJpegDecode(const CodecImageBuffer& inBuffer, const CodecImageBuffer& outBuffer,
49         const CodecJpegDecInfo& decInfo) override;
50 
51     int32_t AllocateInBuffer(CodecImageBuffer& inBuffer, uint32_t size, CodecImageRole role) override;
52 
53     int32_t FreeInBuffer(const CodecImageBuffer& buffer) override;
54 
55     int32_t DoHeifEncode(const std::vector<ImageItem>& inputImgs, const std::vector<MetaItem>& inputMetas,
56                          const std::vector<ItemRef>& refs, const SharedBuffer& output,
57                          uint32_t& filledLen) override;
58 
59     int32_t DoHeifDecode(const std::vector<sptr<Ashmem>>& inputs, const sptr<NativeBuffer>& output,
60                          const CodecHeifDecInfo& decInfo) override;
61 
62 private:
63     std::unique_ptr<CodecJpegService> jpegImpl_;
64     std::unique_ptr<CodecHeifEncodeService> heifEncodeImpl_;
65     std::unique_ptr<CodecHeifDecodeService> heifDecodeImpl_;
66 };
67 } // V2_1
68 } // Image
69 } // Codec
70 } // HDI
71 } // OHOS
72 
73 #endif // OHOS_HDI_CODEC_V2_1_CODECIMAGESERVICE_H
74