1 /* 2 * Copyright (c) 2023-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 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 OHOS_CAMERA_SERVER_PHOTO_PROXY_H 17 #define OHOS_CAMERA_SERVER_PHOTO_PROXY_H 18 19 #include "message_parcel.h" 20 #include "surface.h" 21 #include "photo_proxy.h" 22 #include <cstdint> 23 24 namespace OHOS { 25 namespace CameraStandard { 26 using namespace Media; 27 static const std::string prefix = "IMG_"; 28 static const std::string suffixJpeg = "jpg"; 29 static const std::string suffixHeif = "heic"; 30 static const std::string connector = "_"; 31 static const std::string burstTag = "BURST"; 32 static const std::string coverTag = "_COVER"; 33 static const char placeholder = '0'; 34 static const int yearWidth = 4; 35 static const int otherWidth = 2; 36 static const int burstWidth = 3; 37 static const int startYear = 1900; 38 39 static const std::map<int32_t, int32_t> modeMap = { 40 { 3, 23}, 41 { 4, 7}, 42 { 6, 33}, 43 { 7, 74}, 44 { 8, 47}, 45 { 9, 68}, 46 { 11, 2}, 47 { 12, 31}, 48 { 13, 33}, 49 { 14, 52} 50 }; 51 static const std::map<int32_t, PhotoFormat> formatMap = { 52 {0, PhotoFormat::RGBA}, 53 {1, PhotoFormat::JPG}, 54 {2, PhotoFormat::HEIF}, 55 {3, PhotoFormat::YUV} 56 }; 57 class CameraServerPhotoProxy : public PhotoProxy { 58 public: 59 CameraServerPhotoProxy(); 60 virtual ~CameraServerPhotoProxy(); 61 void ReadFromParcel(MessageParcel &parcel); 62 std::string GetTitle() override; 63 std::string GetExtension() override; 64 std::string GetPhotoId() override; 65 Media::DeferredProcType GetDeferredProcType() override; 66 void* GetFileDataAddr() override; 67 size_t GetFileSize() override; 68 int32_t GetWidth() override; 69 int32_t GetHeight() override; 70 PhotoFormat GetFormat() override; 71 PhotoQuality GetPhotoQuality() override; 72 void SetDisplayName(std::string displayName); 73 double GetLatitude() override; 74 double GetLongitude() override; 75 int32_t GetShootingMode() override; 76 void SetShootingMode(int32_t mode); 77 void Release() override; 78 std::string GetBurstKey() override; 79 bool IsCoverPhoto() override; 80 void SetBurstInfo(std::string burstKey, bool isCoverPhoto); 81 int32_t GetCaptureId(); 82 int32_t GetBurstSeqId(); 83 84 private: 85 BufferHandle* bufferHandle_; 86 int32_t format_; 87 int32_t photoWidth_; 88 int32_t photoHeight_; 89 void* fileDataAddr_; 90 size_t fileSize_; 91 bool isMmaped_; 92 std::mutex mutex_; 93 std::string photoId_; 94 int32_t deferredProcType_; 95 int32_t isDeferredPhoto_; 96 sptr<Surface> photoSurface_; 97 std::string displayName_; 98 bool isHighQuality_; 99 double latitude_; 100 double longitude_; 101 int32_t mode_; 102 int32_t captureId_; 103 int32_t burstSeqId_; 104 std::string burstKey_; 105 bool isCoverPhoto_; 106 int32_t imageFormat_; 107 int32_t CameraFreeBufferHandle(BufferHandle *handle); 108 }; 109 } // namespace CameraStandard 110 } // namespace OHOS 111 #endif // OHOS_CAMERA_SERVER_PHOTO_PROXY_H