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 IMAGE_AUTO_INITER 17 #define IMAGE_AUTO_INITER 18 #include "v2_0/icodec_image.h" 19 namespace OHOS { 20 namespace Codec { 21 namespace Image { 22 class ImageAutoIniter { 23 public: ImageAutoIniter(OHOS::sptr<OHOS::HDI::Codec::Image::V2_0::ICodecImage> imageClient,OHOS::HDI::Codec::Image::V2_0::CodecImageRole role)24 ImageAutoIniter(OHOS::sptr<OHOS::HDI::Codec::Image::V2_0::ICodecImage> imageClient, 25 OHOS::HDI::Codec::Image::V2_0::CodecImageRole role) : client_(imageClient), role_(role) 26 { 27 if (client_) { 28 client_->Init(role_); 29 } 30 } 31 ~ImageAutoIniter()32 ~ImageAutoIniter() 33 { 34 if (client_) { 35 client_->DeInit(role_); 36 client_ = nullptr; 37 } 38 } 39 40 private: 41 OHOS::sptr<OHOS::HDI::Codec::Image::V2_0::ICodecImage> client_; 42 OHOS::HDI::Codec::Image::V2_0::CodecImageRole role_; 43 }; 44 } // namespace Image 45 } // namespace Codec 46 } // namespace OHOS 47 48 #endif