1 /* 2 * Copyright (c) 2022-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 #include "decode_surface_listener.h" 17 18 #include "distributed_hardware_log.h" 19 20 namespace OHOS { 21 namespace DistributedHardware { ~DecodeSurfaceListener()22DecodeSurfaceListener::~DecodeSurfaceListener() 23 { 24 DHLOGD("DecodeSurfaceListener : ~DecodeSurfaceListener."); 25 surface_ = nullptr; 26 } 27 OnBufferAvailable()28void DecodeSurfaceListener::OnBufferAvailable() 29 { 30 DHLOGD("DecodeSurfaceListener : OnBufferAvailable."); 31 std::shared_ptr<DecodeDataProcess> targetDecoderNode = decodeVideoNode_.lock(); 32 if (targetDecoderNode == nullptr) { 33 DHLOGE("decodeVideoNode_ is nullptr."); 34 return; 35 } 36 targetDecoderNode->OnSurfaceOutputBufferAvailable(surface_); 37 } 38 SetSurface(const sptr<IConsumerSurface> & surface)39void DecodeSurfaceListener::SetSurface(const sptr<IConsumerSurface>& surface) 40 { 41 surface_ = surface; 42 } 43 SetDecodeVideoNode(const std::weak_ptr<DecodeDataProcess> & decodeVideoNode)44void DecodeSurfaceListener::SetDecodeVideoNode(const std::weak_ptr<DecodeDataProcess>& decodeVideoNode) 45 { 46 decodeVideoNode_ = decodeVideoNode; 47 } 48 GetSurface() const49sptr<IConsumerSurface> DecodeSurfaceListener::GetSurface() const 50 { 51 return surface_; 52 } 53 GetDecodeVideoNode() const54std::shared_ptr<DecodeDataProcess> DecodeSurfaceListener::GetDecodeVideoNode() const 55 { 56 std::shared_ptr<DecodeDataProcess> targetDecoderNode = decodeVideoNode_.lock(); 57 if (targetDecoderNode == nullptr) { 58 DHLOGE("decodeVideoNode_ is nullptr."); 59 } 60 return targetDecoderNode; 61 } 62 } // namespace DistributedHardware 63 } // namespace OHOS 64