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