• 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_NATIVE_INCLUDE_PICTURE_HANDLE_CLIENT_H
17 #define INTERFACES_INNERKITS_NATIVE_INCLUDE_PICTURE_HANDLE_CLIENT_H
18 
19 #include <optional>
20 
21 #include "message_parcel.h"
22 #include "picture.h"
23 #include "surface_buffer.h"
24 
25 namespace OHOS {
26 namespace Media {
27 
28 static const int UINT32_LEN = sizeof(uint32_t);
29 
30 class PictureHandlerClient {
31 public:
32     static std::shared_ptr<Media::Picture> RequestPicture(const int32_t &fileId, int32_t &errCode);
33 
34 private:
35     static void FinishRequestPicture(const int32_t &fileId);
36     static std::optional<uint32_t> ReadMessageLength(const int32_t &fd);
37     static std::optional<std::pair<uint32_t, uint8_t*>> ReadMessage(uint8_t *addr, const uint32_t &msgLen);
38     static std::unique_ptr<Media::Picture> ParsePicture(MessageParcel &pictureParcel, uint8_t *addr,
39         const uint32_t &msgLen, int32_t &err);
40     static int32_t ReadPicture(const int32_t &fd, const int32_t &fileId, std::shared_ptr<Media::Picture> &picture,
41         int32_t &err);
42     static std::shared_ptr<PixelMap> ReadPixelMap(MessageParcel &data, int32_t &err);
43     static bool ReadAuxiliaryPicture(MessageParcel &data, std::unique_ptr<Media::Picture> &picture, int32_t &err);
44     static bool ReadAuxiliaryPictureInfo(MessageParcel &data, AuxiliaryPictureInfo &auxiliaryPictureInfo);
45     static bool ReadImageInfo(MessageParcel &data, ImageInfo &imageInfo);
46     static bool ReadYuvDataInfo(MessageParcel &data, YUVDataInfo &yuvInfo);
47     static bool ReadSurfaceBuffer(MessageParcel &data, std::unique_ptr<PixelMap> &pixelMap, int32_t &err);
48     static BufferHandle* CreateBufferHandle(MessageParcel &data, const uint32_t &reserveFds,
49         const uint32_t &reserveInts);
50     static bool ReadBufferHandle(MessageParcel &data, sptr<SurfaceBuffer> &surfaceBuffer, int32_t &err);
51     static bool ReadExifMetadata(MessageParcel &data, std::unique_ptr<Media::Picture> &picture);
52     static bool ReadMaintenanceData(MessageParcel &data, std::unique_ptr<Media::Picture> &picture, int32_t &err);
53     static int32_t RequestBufferHandlerFd(const int32_t &fd);
54 };
55 }
56 }
57 #endif