1 /* 2 * Copyright (C) 2022 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 IMAGE_CREATOR_PRIVATE_H 17 #define IMAGE_CREATOR_PRIVATE_H 18 19 #include <surface.h> 20 #include <list> 21 #include "iconsumer_surface.h" 22 #include "hilog/log.h" 23 24 namespace OHOS { 25 namespace Media { 26 class ImageCreatorContext { 27 public: ImageCreatorContext()28 ImageCreatorContext() { 29 }; ~ImageCreatorContext()30 ~ImageCreatorContext() { 31 }; 32 OHOS::sptr<OHOS::SurfaceBuffer> currentCreatorBuffer_; 33 static std::shared_ptr<ImageCreatorContext> CreateImageCreatorContext(); SetCreatorBufferConsumer(sptr<IConsumerSurface> & consumer)34 void SetCreatorBufferConsumer(sptr<IConsumerSurface> &consumer) 35 { 36 creatorConsumerSurface_ = consumer; 37 } GetCreatorBufferConsumer()38 sptr<IConsumerSurface> GetCreatorBufferConsumer() 39 { 40 return creatorConsumerSurface_; 41 } SetCreatorBufferProducer(sptr<Surface> & producer)42 void SetCreatorBufferProducer(sptr<Surface> &producer) 43 { 44 creatorProducerSurface_ = producer; 45 } GetCreatorBufferProducer()46 sptr<Surface> GetCreatorBufferProducer() 47 { 48 return creatorProducerSurface_; 49 } SetWidth(int32_t width)50 void SetWidth(int32_t width) 51 { 52 width_ = width; 53 } GetWidth()54 int32_t GetWidth() const 55 { 56 return width_; 57 } SetHeight(int32_t height)58 void SetHeight(int32_t height) 59 { 60 height_ = height; 61 } GetHeight()62 int32_t GetHeight() const 63 { 64 return height_; 65 } SetFormat(int32_t format)66 void SetFormat(int32_t format) 67 { 68 format_ = format; 69 } GetFormat()70 int32_t GetFormat() const 71 { 72 return format_; 73 } SetCapicity(int32_t capicity)74 void SetCapicity(int32_t capicity) 75 { 76 capicity_ = capicity; 77 } GetCapicity()78 int32_t GetCapicity() const 79 { 80 return capicity_; 81 } SetCreatorKey(std::string creatorKey)82 void SetCreatorKey(std::string creatorKey) 83 { 84 creatorKey_ = creatorKey; 85 } GetCreatorKey()86 std::string GetCreatorKey() const 87 { 88 return creatorKey_; 89 } GetCurrentCreatorBuffer()90 OHOS::sptr<OHOS::SurfaceBuffer> GetCurrentCreatorBuffer() const 91 { 92 return currentCreatorBuffer_; 93 } SetCurrentBuffer(OHOS::sptr<OHOS::SurfaceBuffer> currentCreatorBuffer)94 void SetCurrentBuffer(OHOS::sptr<OHOS::SurfaceBuffer> currentCreatorBuffer) 95 { 96 currentCreatorBuffer_ = currentCreatorBuffer; 97 } 98 private: 99 static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { 100 LOG_CORE, LOG_TAG_DOMAIN_ID_IMAGE, "ImageCreatorContext"}; 101 OHOS::sptr<IConsumerSurface> creatorConsumerSurface_; 102 OHOS::sptr<Surface> creatorProducerSurface_; 103 int32_t width_; 104 int32_t height_; 105 int32_t format_; 106 int32_t capicity_; 107 std::string creatorKey_; 108 }; 109 } // namespace Media 110 } // namespace OHOS 111 #endif // IMAGE_CREATOR_PRIVATE_H 112