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 FRAMEWORKS_INNERKITSIMPL_RECEIVER_INCLUDE_IMAGE_RECEIVER_CONTEXT_H_ 17 #define FRAMEWORKS_INNERKITSIMPL_RECEIVER_INCLUDE_IMAGE_RECEIVER_CONTEXT_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 ImageReceiverContext { 27 public: ImageReceiverContext()28 ImageReceiverContext() { 29 } ~ImageReceiverContext()30 ~ImageReceiverContext() 31 { 32 currentBuffer_ = nullptr; 33 }; 34 OHOS::sptr<OHOS::SurfaceBuffer> currentBuffer_; 35 static std::shared_ptr<ImageReceiverContext> CreateImageReceiverContext(); SetReceiverBufferConsumer(sptr<IConsumerSurface> & consumer)36 void SetReceiverBufferConsumer(sptr<IConsumerSurface> &consumer) 37 { 38 receiverConsumerSurface_ = consumer; 39 } GetReceiverBufferConsumer()40 sptr<IConsumerSurface> GetReceiverBufferConsumer() 41 { 42 return receiverConsumerSurface_; 43 } SetReceiverBufferProducer(sptr<Surface> & producer)44 void SetReceiverBufferProducer(sptr<Surface> &producer) 45 { 46 receiverProducerSurface_ = producer; 47 } GetReceiverBufferProducer()48 sptr<Surface> GetReceiverBufferProducer() 49 { 50 return receiverProducerSurface_; 51 } SetWidth(int32_t width)52 void SetWidth(int32_t width) 53 { 54 width_ = width; 55 } GetWidth()56 int32_t GetWidth() const 57 { 58 return width_; 59 } SetHeight(int32_t height)60 void SetHeight(int32_t height) 61 { 62 height_ = height; 63 } GetHeight()64 int32_t GetHeight() const 65 { 66 return height_; 67 } SetFormat(int32_t format)68 void SetFormat(int32_t format) 69 { 70 format_ = format; 71 } GetFormat()72 int32_t GetFormat() const 73 { 74 return format_; 75 } SetCapicity(int32_t capicity)76 void SetCapicity(int32_t capicity) 77 { 78 capicity_ = capicity; 79 } GetCapicity()80 int32_t GetCapicity() const 81 { 82 return capicity_; 83 } SetReceiverKey(std::string receiverKey)84 void SetReceiverKey(std::string receiverKey) 85 { 86 receiverKey_ = receiverKey; 87 } GetReceiverKey()88 std::string GetReceiverKey() const 89 { 90 return receiverKey_; 91 } GetCurrentBuffer()92 OHOS::sptr<OHOS::SurfaceBuffer> GetCurrentBuffer() const 93 { 94 return currentBuffer_; 95 } SetCurrentBuffer(OHOS::sptr<OHOS::SurfaceBuffer> currentBuffer)96 void SetCurrentBuffer(OHOS::sptr<OHOS::SurfaceBuffer> currentBuffer) 97 { 98 currentBuffer_ = currentBuffer; 99 } 100 101 private: 102 static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { 103 LOG_CORE, LOG_TAG_DOMAIN_ID_IMAGE, "ImageReceiverContext"}; 104 OHOS::sptr<IConsumerSurface> receiverConsumerSurface_; 105 OHOS::sptr<Surface> receiverProducerSurface_; 106 int32_t width_; 107 int32_t height_; 108 int32_t format_; 109 int32_t capicity_; 110 std::string receiverKey_; 111 }; 112 } // namespace Media 113 } // namespace OHOS 114 115 #endif // FRAMEWORKS_INNERKITSIMPL_RECEIVER_INCLUDE_IMAGE_RECEIVER_CONTEXT_H_ 116