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 INTERFACE_INNERKITS_INCLUDE_AUXILIARY_PICTURE_H
17 #define INTERFACE_INNERKITS_INCLUDE_AUXILIARY_PICTURE_H
18 
19 #include <map>
20 #include "metadata.h"
21 #include "pixel_map.h"
22 #include "image_type.h"
23 
24 namespace OHOS {
25     class SurfaceBuffer;
26 }
27 
28 namespace OHOS {
29 namespace Media {
30 class ImageMetadata;
31 
32 class AuxiliaryPicture : public Parcelable {
33 public:
34     virtual ~AuxiliaryPicture();
35 
36     NATIVEEXPORT static std::unique_ptr<AuxiliaryPicture> Create(std::shared_ptr<PixelMap> &content,
37                                                                  AuxiliaryPictureType type, Size size = {0, 0});
38     NATIVEEXPORT static std::unique_ptr<AuxiliaryPicture> Create(sptr<SurfaceBuffer> &surfaceBuffer,
39                                                                  AuxiliaryPictureType type, Size size = {0, 0});
40     NATIVEEXPORT AuxiliaryPictureType GetType();
41     NATIVEEXPORT void SetType(AuxiliaryPictureType type);
42     NATIVEEXPORT virtual Size GetSize();
43     NATIVEEXPORT void SetSize(Size size);
44     NATIVEEXPORT std::shared_ptr<PixelMap> GetContentPixel();
45     NATIVEEXPORT void SetContentPixel(std::shared_ptr<PixelMap> content);
46     NATIVEEXPORT uint32_t ReadPixels(const uint64_t &bufferSize, uint8_t *dst);
47     NATIVEEXPORT uint32_t WritePixels(const uint8_t *source, const uint64_t &bufferSize);
48     NATIVEEXPORT AuxiliaryPictureInfo GetAuxiliaryPictureInfo();
49     NATIVEEXPORT uint32_t SetAuxiliaryPictureInfo(const AuxiliaryPictureInfo &auxiliaryPictureInfo);
50     NATIVEEXPORT std::shared_ptr<ImageMetadata> GetMetadata(MetadataType type);
51     NATIVEEXPORT void SetMetadata(MetadataType type, std::shared_ptr<ImageMetadata> metadata);
52     NATIVEEXPORT bool HasMetadata(MetadataType type);
53     NATIVEEXPORT virtual bool Marshalling(Parcel &data) const override;
54     NATIVEEXPORT static AuxiliaryPicture *Unmarshalling(Parcel &data);
55     NATIVEEXPORT static AuxiliaryPicture *Unmarshalling(Parcel &parcel, PICTURE_ERR &error);
56 
57 protected:
58     std::shared_ptr<PixelMap> content_;
59     AuxiliaryPictureInfo auxiliaryPictureInfo_;
60     std::map<MetadataType, std::shared_ptr<ImageMetadata>> metadatas_;
61     bool WriteAuxPictureInfoToParcel(Parcel &data) const;
62 };
63 }
64 }
65 
66 
67 #endif // INTERFACE_INNERKITS_INCLUDE_AUXILIARY_PICTURE_H