• 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 INTERFACES_INNERKITS_INCLUDE_PICTURE_H
17 #define INTERFACES_INNERKITS_INCLUDE_PICTURE_H
18 
19 #include "pixel_map.h"
20 #include "auxiliary_picture.h"
21 #include "gif_metadata.h"
22 #include "image_type.h"
23 #include <map>
24 
25 namespace OHOS {
26     class SurfaceBuffer;
27 }
28 
29 namespace OHOS {
30 namespace Media {
31 
32 class ExifMetadata;
33 class ImageMetadata;
34 
35 class Picture : public Parcelable {
36 public:
37     virtual ~Picture();
38 
39     NATIVEEXPORT static std::unique_ptr<Picture> Create(std::shared_ptr<PixelMap> &PixelMap);
40     NATIVEEXPORT static std::unique_ptr<Picture> Create(sptr<SurfaceBuffer> &surfaceBuffer);
41     NATIVEEXPORT static std::unique_ptr<Picture> CreatePictureByHdrAndSdrPixelMap(
42         std::shared_ptr<PixelMap> &hdrPixelMap, std::shared_ptr<PixelMap> &sdrPixelMap);
43     NATIVEEXPORT static std::unique_ptr<PixelMap> SurfaceBuffer2PixelMap(sptr<SurfaceBuffer> &surfaceBuffer);
44     NATIVEEXPORT std::shared_ptr<PixelMap> GetMainPixel();
45     NATIVEEXPORT void SetMainPixel(std::shared_ptr<PixelMap> PixelMap);
46     NATIVEEXPORT std::unique_ptr<PixelMap> GetHdrComposedPixelMap();
47     NATIVEEXPORT std::shared_ptr<PixelMap> GetGainmapPixelMap();
48     NATIVEEXPORT std::shared_ptr<AuxiliaryPicture> GetAuxiliaryPicture(AuxiliaryPictureType type);
49     NATIVEEXPORT void SetAuxiliaryPicture(std::shared_ptr<AuxiliaryPicture> &picture);
50     NATIVEEXPORT bool HasAuxiliaryPicture(AuxiliaryPictureType type);
51     NATIVEEXPORT void DropAuxiliaryPicture(AuxiliaryPictureType type);
52     NATIVEEXPORT virtual bool Marshalling(Parcel &data) const override;
53     NATIVEEXPORT static Picture *Unmarshalling(Parcel &data);
54     NATIVEEXPORT static Picture *Unmarshalling(Parcel &data, PICTURE_ERR &error);
55     NATIVEEXPORT int32_t CreateExifMetadata();
56     NATIVEEXPORT int32_t SetExifMetadata(sptr<SurfaceBuffer> &surfaceBuffer);
57     NATIVEEXPORT int32_t SetExifMetadata(std::shared_ptr<ExifMetadata> exifMetadata);
58     NATIVEEXPORT std::shared_ptr<ExifMetadata> GetExifMetadata();
59     NATIVEEXPORT bool SetMaintenanceData(sptr<SurfaceBuffer> &surfaceBuffer);
60     NATIVEEXPORT sptr<SurfaceBuffer> GetMaintenanceData() const;
61     NATIVEEXPORT bool MarshalMetadata(Parcel &data) const;
62     NATIVEEXPORT static bool UnmarshalMetadata(Parcel &parcel, Picture &picture, PICTURE_ERR &error);
63     NATIVEEXPORT static void DumpPictureIfDumpEnabled(Picture& picture, std::string dumpType);
64     NATIVEEXPORT std::shared_ptr<ImageMetadata> GetMetadata(MetadataType type);
65     NATIVEEXPORT uint32_t SetMetadata(MetadataType type, std::shared_ptr<ImageMetadata> metadata);
66     NATIVEEXPORT static bool IsValidPictureMetadataType(MetadataType metadataType);
67 
68 private:
69     std::shared_ptr<PixelMap> mainPixelMap_;
70     std::map<AuxiliaryPictureType, std::shared_ptr<AuxiliaryPicture>> auxiliaryPictures_;
71     sptr<SurfaceBuffer> maintenanceData_;
72     std::map<MetadataType, std::shared_ptr<ImageMetadata>> metadatas_;
73 };
74 }
75 }
76 
77 #endif //INTERFACES_INNERKITS_INCLUDE_PICTURE_H_