From 8f446211f9bf4d71fe7c1b79ab0ac9b1b68821ee Mon Sep 17 00:00:00 2001 From: t00605578 Date: Wed, 16 Mar 2022 16:07:48 +0800 Subject: [PATCH] fix decodeCreation, FDleaks, and Codex Signed-off-by: t00605578 --- camera_hdf/hdi_impl/BUILD.gn | 2 +- .../dcamera_device/dmetadata_processor.cpp | 6 +- .../src/dstream_operator/dcamera_steam.cpp | 2 +- .../src/dstream_operator/dstream_operator.cpp | 2 +- camera_hdf/hdi_impl/test/BUILD.gn | 2 +- camera_hdf/hdi_impl/test/common.cpp | 21 ++- camera_hdf/interfaces/hdi_ipc/client/BUILD.gn | 2 +- .../operator/dstream_operator_proxy.cpp | 2 +- .../provider/dcamera_provider_proxy.cpp | 4 +- .../interfaces/hdi_ipc/config/host/BUILD.gn | 2 +- .../config/host/dcamera_host_config.cpp | 4 + .../hdi_ipc/config/provider/BUILD.gn | 2 +- .../interfaces/hdi_ipc/ipc_data_utils.h | 2 +- .../dstream_operator_callback_proxy.cpp | 4 +- .../dcamera_provider_callback_proxy.cpp | 2 +- .../server/provider/dcamera_provider_stub.cpp | 2 +- camera_hdf/interfaces/include/types.h | 2 +- common/BUILD.gn | 2 +- .../native_cpp/camera_sink/BUILD.gn | 2 +- .../native_cpp/camera_source/BUILD.gn | 2 +- sa_profile/4803.xml | 4 +- sa_profile/4804.xml | 4 +- .../cameraoperator/client/BUILD.gn | 2 +- .../include/callback/dcamera_input_callback.h | 2 +- .../callback/dcamera_manager_callback.h | 2 +- .../include/callback/dcamera_photo_callback.h | 2 +- .../callback/dcamera_preview_callback.h | 2 +- .../callback/dcamera_session_callback.h | 2 +- .../include/callback/dcamera_video_callback.h | 2 +- .../client/include/dcamera_client.h | 2 +- .../client/include/icamera_operator.h | 2 +- .../listener/dcamera_photo_surface_listener.h | 2 +- .../listener/dcamera_video_surface_listener.h | 2 +- .../src/callback/dcamera_input_callback.cpp | 2 +- .../src/callback/dcamera_manager_callback.cpp | 2 +- .../src/callback/dcamera_photo_callback.cpp | 2 +- .../src/callback/dcamera_preview_callback.cpp | 2 +- .../src/callback/dcamera_session_callback.cpp | 2 +- .../src/callback/dcamera_video_callback.cpp | 2 +- .../client/src/dcamera_client.cpp | 2 +- .../dcamera_photo_surface_listener.cpp | 2 +- .../dcamera_video_surface_listener.cpp | 2 +- .../cameraoperator/handler/BUILD.gn | 2 +- .../handler/include/dcamera_handler.h | 2 +- .../handler/src/dcamera_handler.cpp | 2 +- services/cameraservice/sinkservice/BUILD.gn | 2 +- .../mock_camera_channel.h | 2 +- .../mock_camera_operator.h | 2 +- .../mock_data_process_pipeline.h | 2 +- .../mock_dcamera_sink_controller.h | 2 +- .../mock_dcamera_sink_data_process.h | 2 +- .../mock_dcamera_sink_output.h | 2 +- services/cameraservice/sourceservice/BUILD.gn | 2 +- .../distributed_camera_source_stub.cpp | 2 +- .../dcamera_source_controller.cpp | 4 +- .../mock_dcamera_source_dev.h | 2 +- services/channel/BUILD.gn | 2 +- services/data_process/BUILD.gn | 3 +- .../multimedia_codec/decode_data_process.h | 21 +-- .../decode_surface_listener.h | 46 ++++++ .../multimedia_codec/encode_data_process.h | 2 + .../fpscontroller/fps_controller_process.cpp | 6 +- .../multimedia_codec/decode_data_process.cpp | 134 +++++++++++------- .../decode_surface_listener.cpp | 63 ++++++++ .../decode_video_callback.cpp | 2 +- .../multimedia_codec/encode_data_process.cpp | 74 +++++++--- .../encode_video_callback.cpp | 2 +- 67 files changed, 336 insertions(+), 166 deletions(-) create mode 100644 services/data_process/include/pipeline_node/multimedia_codec/decode_surface_listener.h create mode 100644 services/data_process/src/pipeline_node/multimedia_codec/decode_surface_listener.cpp diff --git a/camera_hdf/hdi_impl/BUILD.gn b/camera_hdf/hdi_impl/BUILD.gn index 0be31806..2307ca1c 100644 --- a/camera_hdf/hdi_impl/BUILD.gn +++ b/camera_hdf/hdi_impl/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (C) 2021 Huawei Device Co., Ltd. +# Copyright (c) 2021 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/camera_hdf/hdi_impl/src/dcamera_device/dmetadata_processor.cpp b/camera_hdf/hdi_impl/src/dcamera_device/dmetadata_processor.cpp index 44fa7a12..b7bc5e30 100644 --- a/camera_hdf/hdi_impl/src/dcamera_device/dmetadata_processor.cpp +++ b/camera_hdf/hdi_impl/src/dcamera_device/dmetadata_processor.cpp @@ -246,7 +246,7 @@ DCamRetCode DMetadataProcessor::AddAbilityEntry(uint32_t tag, const void *data, int ret = CameraStandard::FindCameraMetadataItem(dCameraAbility_->get(), tag, &item); if (ret) { if (!dCameraAbility_->addEntry(tag, data, size)) { - DHLOGE("Add tag %d failed.", tag); + DHLOGE("Add tag %u failed.", tag); return FAILED; } } @@ -264,12 +264,12 @@ DCamRetCode DMetadataProcessor::UpdateAbilityEntry(uint32_t tag, const void *dat int ret = CameraStandard::FindCameraMetadataItem(dCameraAbility_->get(), tag, &item); if (ret) { if (!dCameraAbility_->addEntry(tag, data, size)) { - DHLOGE("Add tag %d failed.", tag); + DHLOGE("Add tag %u failed.", tag); return FAILED; } } else { if (!dCameraAbility_->updateEntry(tag, data, size)) { - DHLOGE("Update tag %d failed.", tag); + DHLOGE("Update tag %u failed.", tag); return FAILED; } } diff --git a/camera_hdf/hdi_impl/src/dstream_operator/dcamera_steam.cpp b/camera_hdf/hdi_impl/src/dstream_operator/dcamera_steam.cpp index ee3cb82a..2cbc6f4a 100644 --- a/camera_hdf/hdi_impl/src/dstream_operator/dcamera_steam.cpp +++ b/camera_hdf/hdi_impl/src/dstream_operator/dcamera_steam.cpp @@ -187,7 +187,7 @@ DCamRetCode DCameraStream::GetNextRequest() OHOS::SurfaceError surfaceError = dcStreamProducer_->RequestBuffer(surfaceBuffer, fence, config); if (surfaceError == OHOS::SURFACE_ERROR_NO_BUFFER) { - DHLOGE("No availiable buffer to request in surface."); + DHLOGE("No available buffer to request in surface."); return DCamRetCode::EXCEED_MAX_NUMBER; } diff --git a/camera_hdf/hdi_impl/src/dstream_operator/dstream_operator.cpp b/camera_hdf/hdi_impl/src/dstream_operator/dstream_operator.cpp index 362fa246..0eec08ab 100644 --- a/camera_hdf/hdi_impl/src/dstream_operator/dstream_operator.cpp +++ b/camera_hdf/hdi_impl/src/dstream_operator/dstream_operator.cpp @@ -480,7 +480,7 @@ DCamRetCode DStreamOperator::ShutterBuffer(int streamId, const std::shared_ptr streamInfo = streamInfos.at(i); bool bRet = IpcDataUtils::EncodeStreamInfo(streamInfo, data); if (!bRet) { - DHLOGE("Write streamInfo failed. index = %d", i); + DHLOGE("Write streamInfo failed. index = %zu", i); return CamRetCode::INVALID_ARGUMENT; } } diff --git a/camera_hdf/interfaces/hdi_ipc/client/provider/dcamera_provider_proxy.cpp b/camera_hdf/interfaces/hdi_ipc/client/provider/dcamera_provider_proxy.cpp index 6b67de6a..470a10be 100644 --- a/camera_hdf/interfaces/hdi_ipc/client/provider/dcamera_provider_proxy.cpp +++ b/camera_hdf/interfaces/hdi_ipc/client/provider/dcamera_provider_proxy.cpp @@ -133,7 +133,7 @@ DCamRetCode DCameraProviderProxy::AcquireBuffer(const std::shared_ptr &d } int32_t retCode = reply.ReadInt32(); if (retCode != DCamRetCode::SUCCESS) { - DHLOGE("Acquire avaliable buffer from stub failed."); + DHLOGE("Acquire available buffer from stub failed."); return static_cast(retCode); } @@ -143,7 +143,7 @@ DCamRetCode DCameraProviderProxy::AcquireBuffer(const std::shared_ptr &d BufferHandle* retHandle = ReadBufferHandle(reply); if (retHandle == nullptr) { - DHLOGE("Read retrun buffer handle failed."); + DHLOGE("Read return buffer handle failed."); FreeBufferHandle(buffer->bufferHandle_); return DCamRetCode::INVALID_ARGUMENT; } diff --git a/camera_hdf/interfaces/hdi_ipc/config/host/BUILD.gn b/camera_hdf/interfaces/hdi_ipc/config/host/BUILD.gn index d3ec5b0d..7b744eb8 100644 --- a/camera_hdf/interfaces/hdi_ipc/config/host/BUILD.gn +++ b/camera_hdf/interfaces/hdi_ipc/config/host/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (C) 2021 Huawei Device Co., Ltd. +# Copyright (c) 2021 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/camera_hdf/interfaces/hdi_ipc/config/host/dcamera_host_config.cpp b/camera_hdf/interfaces/hdi_ipc/config/host/dcamera_host_config.cpp index da30b84d..fd07419d 100644 --- a/camera_hdf/interfaces/hdi_ipc/config/host/dcamera_host_config.cpp +++ b/camera_hdf/interfaces/hdi_ipc/config/host/dcamera_host_config.cpp @@ -28,6 +28,10 @@ static int32_t DCameraServiceDispatch(struct HdfDeviceIoClient *client, int cmdI struct HdfSBuf *data, struct HdfSBuf *reply) { HdfDCameraService *service = CONTAINER_OF(client->device->service, HdfDCameraService, ioservice); + if (service == nullptr) { + HDF_LOGE("HdfDCameraService CONTAINER_OF failed!"); + return HDF_FAILURE; + } return DCHostServiceOnRemoteRequest(service->instance, cmdId, data, reply); } diff --git a/camera_hdf/interfaces/hdi_ipc/config/provider/BUILD.gn b/camera_hdf/interfaces/hdi_ipc/config/provider/BUILD.gn index 053ddc2b..1d80115f 100644 --- a/camera_hdf/interfaces/hdi_ipc/config/provider/BUILD.gn +++ b/camera_hdf/interfaces/hdi_ipc/config/provider/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (C) 2021 Huawei Device Co., Ltd. +# Copyright (c) 2021 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/camera_hdf/interfaces/hdi_ipc/ipc_data_utils.h b/camera_hdf/interfaces/hdi_ipc/ipc_data_utils.h index e657d632..6eb671a0 100644 --- a/camera_hdf/interfaces/hdi_ipc/ipc_data_utils.h +++ b/camera_hdf/interfaces/hdi_ipc/ipc_data_utils.h @@ -43,7 +43,7 @@ public: bRet = (bRet && parcel.WriteInt32(static_cast(pInfo->width_))); bRet = (bRet && parcel.WriteInt32(static_cast(pInfo->height_))); bRet = (bRet && parcel.WriteInt32(static_cast(pInfo->format_))); - bRet = (bRet = (bRet && parcel.WriteInt32(pInfo->intent_))); + bRet = (bRet && parcel.WriteInt32(pInfo->intent_)); bRet = (bRet && parcel.WriteBool(pInfo->tunneledMode_)); bool bufferQueueFlag = (pInfo->bufferQueue_ != nullptr) ? true : false; bRet = (bRet && parcel.WriteBool(bufferQueueFlag)); diff --git a/camera_hdf/interfaces/hdi_ipc/server/operator/dstream_operator_callback_proxy.cpp b/camera_hdf/interfaces/hdi_ipc/server/operator/dstream_operator_callback_proxy.cpp index b971960a..dcba3ac2 100644 --- a/camera_hdf/interfaces/hdi_ipc/server/operator/dstream_operator_callback_proxy.cpp +++ b/camera_hdf/interfaces/hdi_ipc/server/operator/dstream_operator_callback_proxy.cpp @@ -77,7 +77,7 @@ void DStreamOperatorCallbackProxy::OnCaptureEnded(int32_t captureId, auto captureEndInfo = info.at(i); bool bRet = data.WriteBuffer((void *)captureEndInfo.get(), sizeof(CaptureEndedInfo)); if (!bRet) { - DHLOGE("Write info index = %d failed.", i); + DHLOGE("Write info index = %zu failed.", i); return; } } @@ -115,7 +115,7 @@ void DStreamOperatorCallbackProxy::OnCaptureError(int32_t captureId, auto captureErrorInfo = info.at(i); bool bRet = data.WriteBuffer((void *)captureErrorInfo.get(), sizeof(CaptureErrorInfo)); if (!bRet) { - DHLOGE("Write info index = %d failed.", i); + DHLOGE("Write info index = %zu failed.", i); return; } } diff --git a/camera_hdf/interfaces/hdi_ipc/server/provider/dcamera_provider_callback_proxy.cpp b/camera_hdf/interfaces/hdi_ipc/server/provider/dcamera_provider_callback_proxy.cpp index 8a9acc63..c3f57790 100644 --- a/camera_hdf/interfaces/hdi_ipc/server/provider/dcamera_provider_callback_proxy.cpp +++ b/camera_hdf/interfaces/hdi_ipc/server/provider/dcamera_provider_callback_proxy.cpp @@ -250,7 +250,7 @@ DCamRetCode DCameraProviderCallbackProxy::UpdateSettings(const std::shared_ptrindex_) || !reply.WriteInt32(dCamerabuffer->size_)) { diff --git a/camera_hdf/interfaces/include/types.h b/camera_hdf/interfaces/include/types.h index d49e2d95..e77adba9 100644 --- a/camera_hdf/interfaces/include/types.h +++ b/camera_hdf/interfaces/include/types.h @@ -267,7 +267,7 @@ using DCCaptureInfo = struct _DCCaptureInfo { /** * @brief Defines the inner buffer of the distributed camera, - * which is used to acquire buffer during procesing capture requests. + * which is used to acquire buffer during processing capture requests. */ using DCameraBuffer = struct _DCameraBuffer { /** diff --git a/common/BUILD.gn b/common/BUILD.gn index b8bb86a6..d3fa8481 100644 --- a/common/BUILD.gn +++ b/common/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (C) 2021 Huawei Device Co., Ltd. +# Copyright (c) 2021 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/interfaces/inner_kits/native_cpp/camera_sink/BUILD.gn b/interfaces/inner_kits/native_cpp/camera_sink/BUILD.gn index 8c8d618c..73b77ae4 100644 --- a/interfaces/inner_kits/native_cpp/camera_sink/BUILD.gn +++ b/interfaces/inner_kits/native_cpp/camera_sink/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (C) 2021 Huawei Device Co., Ltd. +# Copyright (c) 2021 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/interfaces/inner_kits/native_cpp/camera_source/BUILD.gn b/interfaces/inner_kits/native_cpp/camera_source/BUILD.gn index d7a463a3..43b7dfa4 100644 --- a/interfaces/inner_kits/native_cpp/camera_source/BUILD.gn +++ b/interfaces/inner_kits/native_cpp/camera_source/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (C) 2021 Huawei Device Co., Ltd. +# Copyright (c) 2021 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/sa_profile/4803.xml b/sa_profile/4803.xml index 32f4655e..d5e5bfaa 100644 --- a/sa_profile/4803.xml +++ b/sa_profile/4803.xml @@ -1,6 +1,6 @@ dhardware - + 4803 libdistributed_camera_source.z.so diff --git a/sa_profile/4804.xml b/sa_profile/4804.xml index d01ba659..f0e70574 100644 --- a/sa_profile/4804.xml +++ b/sa_profile/4804.xml @@ -1,6 +1,6 @@ dhardware - + 4804 libdistributed_camera_sink.z.so diff --git a/services/cameraservice/cameraoperator/client/BUILD.gn b/services/cameraservice/cameraoperator/client/BUILD.gn index c92d304e..1504df6d 100644 --- a/services/cameraservice/cameraoperator/client/BUILD.gn +++ b/services/cameraservice/cameraoperator/client/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (C) 2021 Huawei Device Co., Ltd. +# Copyright (c) 2021 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/services/cameraservice/cameraoperator/client/include/callback/dcamera_input_callback.h b/services/cameraservice/cameraoperator/client/include/callback/dcamera_input_callback.h index e29fcc70..52c11d3d 100644 --- a/services/cameraservice/cameraoperator/client/include/callback/dcamera_input_callback.h +++ b/services/cameraservice/cameraoperator/client/include/callback/dcamera_input_callback.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/services/cameraservice/cameraoperator/client/include/callback/dcamera_manager_callback.h b/services/cameraservice/cameraoperator/client/include/callback/dcamera_manager_callback.h index b6f35f3f..6d2aa46d 100644 --- a/services/cameraservice/cameraoperator/client/include/callback/dcamera_manager_callback.h +++ b/services/cameraservice/cameraoperator/client/include/callback/dcamera_manager_callback.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/services/cameraservice/cameraoperator/client/include/callback/dcamera_photo_callback.h b/services/cameraservice/cameraoperator/client/include/callback/dcamera_photo_callback.h index 5cc4804d..9e8bd211 100644 --- a/services/cameraservice/cameraoperator/client/include/callback/dcamera_photo_callback.h +++ b/services/cameraservice/cameraoperator/client/include/callback/dcamera_photo_callback.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/services/cameraservice/cameraoperator/client/include/callback/dcamera_preview_callback.h b/services/cameraservice/cameraoperator/client/include/callback/dcamera_preview_callback.h index c38caccf..a215c184 100644 --- a/services/cameraservice/cameraoperator/client/include/callback/dcamera_preview_callback.h +++ b/services/cameraservice/cameraoperator/client/include/callback/dcamera_preview_callback.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/services/cameraservice/cameraoperator/client/include/callback/dcamera_session_callback.h b/services/cameraservice/cameraoperator/client/include/callback/dcamera_session_callback.h index 343d1c2a..841a0424 100644 --- a/services/cameraservice/cameraoperator/client/include/callback/dcamera_session_callback.h +++ b/services/cameraservice/cameraoperator/client/include/callback/dcamera_session_callback.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/services/cameraservice/cameraoperator/client/include/callback/dcamera_video_callback.h b/services/cameraservice/cameraoperator/client/include/callback/dcamera_video_callback.h index 6f82f159..ff7cdec1 100644 --- a/services/cameraservice/cameraoperator/client/include/callback/dcamera_video_callback.h +++ b/services/cameraservice/cameraoperator/client/include/callback/dcamera_video_callback.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/services/cameraservice/cameraoperator/client/include/dcamera_client.h b/services/cameraservice/cameraoperator/client/include/dcamera_client.h index 73591141..f355d2f3 100644 --- a/services/cameraservice/cameraoperator/client/include/dcamera_client.h +++ b/services/cameraservice/cameraoperator/client/include/dcamera_client.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/services/cameraservice/cameraoperator/client/include/icamera_operator.h b/services/cameraservice/cameraoperator/client/include/icamera_operator.h index 6f787d36..e349339d 100644 --- a/services/cameraservice/cameraoperator/client/include/icamera_operator.h +++ b/services/cameraservice/cameraoperator/client/include/icamera_operator.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/services/cameraservice/cameraoperator/client/include/listener/dcamera_photo_surface_listener.h b/services/cameraservice/cameraoperator/client/include/listener/dcamera_photo_surface_listener.h index 54a9e50c..72f77a68 100644 --- a/services/cameraservice/cameraoperator/client/include/listener/dcamera_photo_surface_listener.h +++ b/services/cameraservice/cameraoperator/client/include/listener/dcamera_photo_surface_listener.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/services/cameraservice/cameraoperator/client/include/listener/dcamera_video_surface_listener.h b/services/cameraservice/cameraoperator/client/include/listener/dcamera_video_surface_listener.h index c1bae897..6e06a7e1 100644 --- a/services/cameraservice/cameraoperator/client/include/listener/dcamera_video_surface_listener.h +++ b/services/cameraservice/cameraoperator/client/include/listener/dcamera_video_surface_listener.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/services/cameraservice/cameraoperator/client/src/callback/dcamera_input_callback.cpp b/services/cameraservice/cameraoperator/client/src/callback/dcamera_input_callback.cpp index e915aac5..8d980fd5 100644 --- a/services/cameraservice/cameraoperator/client/src/callback/dcamera_input_callback.cpp +++ b/services/cameraservice/cameraoperator/client/src/callback/dcamera_input_callback.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/services/cameraservice/cameraoperator/client/src/callback/dcamera_manager_callback.cpp b/services/cameraservice/cameraoperator/client/src/callback/dcamera_manager_callback.cpp index 0f3865d7..f65adf08 100644 --- a/services/cameraservice/cameraoperator/client/src/callback/dcamera_manager_callback.cpp +++ b/services/cameraservice/cameraoperator/client/src/callback/dcamera_manager_callback.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/services/cameraservice/cameraoperator/client/src/callback/dcamera_photo_callback.cpp b/services/cameraservice/cameraoperator/client/src/callback/dcamera_photo_callback.cpp index 62f283ef..1ad5ca50 100644 --- a/services/cameraservice/cameraoperator/client/src/callback/dcamera_photo_callback.cpp +++ b/services/cameraservice/cameraoperator/client/src/callback/dcamera_photo_callback.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/services/cameraservice/cameraoperator/client/src/callback/dcamera_preview_callback.cpp b/services/cameraservice/cameraoperator/client/src/callback/dcamera_preview_callback.cpp index 1eb36092..06aeef65 100644 --- a/services/cameraservice/cameraoperator/client/src/callback/dcamera_preview_callback.cpp +++ b/services/cameraservice/cameraoperator/client/src/callback/dcamera_preview_callback.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/services/cameraservice/cameraoperator/client/src/callback/dcamera_session_callback.cpp b/services/cameraservice/cameraoperator/client/src/callback/dcamera_session_callback.cpp index d26fb922..a1b1aee6 100644 --- a/services/cameraservice/cameraoperator/client/src/callback/dcamera_session_callback.cpp +++ b/services/cameraservice/cameraoperator/client/src/callback/dcamera_session_callback.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/services/cameraservice/cameraoperator/client/src/callback/dcamera_video_callback.cpp b/services/cameraservice/cameraoperator/client/src/callback/dcamera_video_callback.cpp index 8adb9731..2e938fa9 100644 --- a/services/cameraservice/cameraoperator/client/src/callback/dcamera_video_callback.cpp +++ b/services/cameraservice/cameraoperator/client/src/callback/dcamera_video_callback.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/services/cameraservice/cameraoperator/client/src/dcamera_client.cpp b/services/cameraservice/cameraoperator/client/src/dcamera_client.cpp index e52b3966..462b99a7 100644 --- a/services/cameraservice/cameraoperator/client/src/dcamera_client.cpp +++ b/services/cameraservice/cameraoperator/client/src/dcamera_client.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/services/cameraservice/cameraoperator/client/src/listener/dcamera_photo_surface_listener.cpp b/services/cameraservice/cameraoperator/client/src/listener/dcamera_photo_surface_listener.cpp index 7a2ea6c4..29cbed9d 100644 --- a/services/cameraservice/cameraoperator/client/src/listener/dcamera_photo_surface_listener.cpp +++ b/services/cameraservice/cameraoperator/client/src/listener/dcamera_photo_surface_listener.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/services/cameraservice/cameraoperator/client/src/listener/dcamera_video_surface_listener.cpp b/services/cameraservice/cameraoperator/client/src/listener/dcamera_video_surface_listener.cpp index 8d7865e3..b2c2f811 100644 --- a/services/cameraservice/cameraoperator/client/src/listener/dcamera_video_surface_listener.cpp +++ b/services/cameraservice/cameraoperator/client/src/listener/dcamera_video_surface_listener.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/services/cameraservice/cameraoperator/handler/BUILD.gn b/services/cameraservice/cameraoperator/handler/BUILD.gn index 39c468a2..fa88481b 100644 --- a/services/cameraservice/cameraoperator/handler/BUILD.gn +++ b/services/cameraservice/cameraoperator/handler/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (C) 2021 Huawei Device Co., Ltd. +# Copyright (c) 2021 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/services/cameraservice/cameraoperator/handler/include/dcamera_handler.h b/services/cameraservice/cameraoperator/handler/include/dcamera_handler.h index 4167d4f3..d92c1e44 100644 --- a/services/cameraservice/cameraoperator/handler/include/dcamera_handler.h +++ b/services/cameraservice/cameraoperator/handler/include/dcamera_handler.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/services/cameraservice/cameraoperator/handler/src/dcamera_handler.cpp b/services/cameraservice/cameraoperator/handler/src/dcamera_handler.cpp index 116029db..c9c29b77 100644 --- a/services/cameraservice/cameraoperator/handler/src/dcamera_handler.cpp +++ b/services/cameraservice/cameraoperator/handler/src/dcamera_handler.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/services/cameraservice/sinkservice/BUILD.gn b/services/cameraservice/sinkservice/BUILD.gn index 8f442aed..58260e30 100644 --- a/services/cameraservice/sinkservice/BUILD.gn +++ b/services/cameraservice/sinkservice/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (C) 2021 Huawei Device Co., Ltd. +# Copyright (c) 2021 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/services/cameraservice/sinkservice/test/unittest/common/distributedcameramgr/mock_camera_channel.h b/services/cameraservice/sinkservice/test/unittest/common/distributedcameramgr/mock_camera_channel.h index 479caf75..8f722eea 100644 --- a/services/cameraservice/sinkservice/test/unittest/common/distributedcameramgr/mock_camera_channel.h +++ b/services/cameraservice/sinkservice/test/unittest/common/distributedcameramgr/mock_camera_channel.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/services/cameraservice/sinkservice/test/unittest/common/distributedcameramgr/mock_camera_operator.h b/services/cameraservice/sinkservice/test/unittest/common/distributedcameramgr/mock_camera_operator.h index 48deca9a..bd182c41 100644 --- a/services/cameraservice/sinkservice/test/unittest/common/distributedcameramgr/mock_camera_operator.h +++ b/services/cameraservice/sinkservice/test/unittest/common/distributedcameramgr/mock_camera_operator.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/services/cameraservice/sinkservice/test/unittest/common/distributedcameramgr/mock_data_process_pipeline.h b/services/cameraservice/sinkservice/test/unittest/common/distributedcameramgr/mock_data_process_pipeline.h index dca14bbf..87a4937a 100644 --- a/services/cameraservice/sinkservice/test/unittest/common/distributedcameramgr/mock_data_process_pipeline.h +++ b/services/cameraservice/sinkservice/test/unittest/common/distributedcameramgr/mock_data_process_pipeline.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/services/cameraservice/sinkservice/test/unittest/common/distributedcameramgr/mock_dcamera_sink_controller.h b/services/cameraservice/sinkservice/test/unittest/common/distributedcameramgr/mock_dcamera_sink_controller.h index abb5601d..92869e5b 100644 --- a/services/cameraservice/sinkservice/test/unittest/common/distributedcameramgr/mock_dcamera_sink_controller.h +++ b/services/cameraservice/sinkservice/test/unittest/common/distributedcameramgr/mock_dcamera_sink_controller.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/services/cameraservice/sinkservice/test/unittest/common/distributedcameramgr/mock_dcamera_sink_data_process.h b/services/cameraservice/sinkservice/test/unittest/common/distributedcameramgr/mock_dcamera_sink_data_process.h index 7096cd47..4f88a2f0 100644 --- a/services/cameraservice/sinkservice/test/unittest/common/distributedcameramgr/mock_dcamera_sink_data_process.h +++ b/services/cameraservice/sinkservice/test/unittest/common/distributedcameramgr/mock_dcamera_sink_data_process.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/services/cameraservice/sinkservice/test/unittest/common/distributedcameramgr/mock_dcamera_sink_output.h b/services/cameraservice/sinkservice/test/unittest/common/distributedcameramgr/mock_dcamera_sink_output.h index 56ca76b0..ecc5428b 100644 --- a/services/cameraservice/sinkservice/test/unittest/common/distributedcameramgr/mock_dcamera_sink_output.h +++ b/services/cameraservice/sinkservice/test/unittest/common/distributedcameramgr/mock_dcamera_sink_output.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/services/cameraservice/sourceservice/BUILD.gn b/services/cameraservice/sourceservice/BUILD.gn index 54b3d772..1851eead 100644 --- a/services/cameraservice/sourceservice/BUILD.gn +++ b/services/cameraservice/sourceservice/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (C) 2021 Huawei Device Co., Ltd. +# Copyright (c) 2021 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/services/cameraservice/sourceservice/src/distributedcamera/distributed_camera_source_stub.cpp b/services/cameraservice/sourceservice/src/distributedcamera/distributed_camera_source_stub.cpp index dd45a32a..54f0df86 100644 --- a/services/cameraservice/sourceservice/src/distributedcamera/distributed_camera_source_stub.cpp +++ b/services/cameraservice/sourceservice/src/distributedcamera/distributed_camera_source_stub.cpp @@ -36,7 +36,7 @@ DistributedCameraSourceStub::~DistributedCameraSourceStub() int32_t DistributedCameraSourceStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) { - DHLOGI("DistributedCameraSourceStub OnRemoteRequest code: %d", code); + DHLOGI("DistributedCameraSourceStub OnRemoteRequest code: %u", code); std::u16string desc = DistributedCameraSourceStub::GetDescriptor(); std::u16string remoteDesc = data.ReadInterfaceToken(); if (desc != remoteDesc) { diff --git a/services/cameraservice/sourceservice/src/distributedcameramgr/dcameracontrol/dcamera_source_controller.cpp b/services/cameraservice/sourceservice/src/distributedcameramgr/dcameracontrol/dcamera_source_controller.cpp index f993f583..3c73c545 100644 --- a/services/cameraservice/sourceservice/src/distributedcameramgr/dcameracontrol/dcamera_source_controller.cpp +++ b/services/cameraservice/sourceservice/src/distributedcameramgr/dcameracontrol/dcamera_source_controller.cpp @@ -71,7 +71,7 @@ int32_t DCameraSourceController::StartCapture(std::vector #include "surface.h" +#include "ibuffer_consumer_listener.h" #include "media_errors.h" #include "avcodec_common.h" #include "format.h" @@ -78,7 +79,9 @@ private: int32_t InitDecoder(); int32_t InitDecoderMetadataFormat(); int32_t SetDecoderOutputSurface(); - void ReleaseDecoder(); + int32_t StopVideoDecoder(); + void ReleaseVideoDecoder(); + void ReleaseDecoderSurface(); int32_t FeedDecoderInputBuffer(); int64_t GetDecoderTimeStamp(); int32_t GetAlignedHeight(); @@ -113,6 +116,7 @@ private: std::shared_ptr decodeVideoCallback_ = nullptr; sptr decodeConsumerSurface_ = nullptr; sptr decodeProducerSurface_ = nullptr; + sptr decodeSurfaceListener_ = nullptr; bool isDecoderProcess_ = false; int32_t waitDecoderOutputCount_ = 0; @@ -126,21 +130,6 @@ private: std::queue> inputBuffersQueue_; std::queue availableInputIndexsQueue_; }; - -class DecodeSurfaceListener : public IBufferConsumerListener { -public: - DecodeSurfaceListener(sptr surface, std::weak_ptr decodeVideoNode) - : surface_(surface), decodeVideoNode_(decodeVideoNode) {} - ~DecodeSurfaceListener() = default; - - void OnBufferAvailable() override; - void SetSurface(const sptr& surface); - void SetDecodeVideoNode(const std::weak_ptr& decodeVideoNode); - -private: - sptr surface_; - std::weak_ptr decodeVideoNode_; -}; } } #endif \ No newline at end of file diff --git a/services/data_process/include/pipeline_node/multimedia_codec/decode_surface_listener.h b/services/data_process/include/pipeline_node/multimedia_codec/decode_surface_listener.h new file mode 100644 index 00000000..223b936b --- /dev/null +++ b/services/data_process/include/pipeline_node/multimedia_codec/decode_surface_listener.h @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_DECODE_SURFACE_LISTENER_H +#define OHOS_DECODE_SURFACE_LISTENER_H + +#include "surface.h" +#include "ibuffer_consumer_listener.h" + +#include "decode_data_process.h" + +namespace OHOS { +namespace DistributedHardware { +class DecodeDataProcess; + +class DecodeSurfaceListener : public IBufferConsumerListener { +public: + DecodeSurfaceListener(sptr surface, std::weak_ptr decodeVideoNode) + : surface_(surface), decodeVideoNode_(decodeVideoNode) {} + ~DecodeSurfaceListener(); + + void OnBufferAvailable() override; + void SetSurface(const sptr& surface); + void SetDecodeVideoNode(const std::weak_ptr& decodeVideoNode); + sptr GetSurface() const; + std::shared_ptr GetDecodeVideoNode() const; + +private: + sptr surface_; + std::weak_ptr decodeVideoNode_; +}; +} +} +#endif \ No newline at end of file diff --git a/services/data_process/include/pipeline_node/multimedia_codec/encode_data_process.h b/services/data_process/include/pipeline_node/multimedia_codec/encode_data_process.h index ba265fa5..0d15682f 100644 --- a/services/data_process/include/pipeline_node/multimedia_codec/encode_data_process.h +++ b/services/data_process/include/pipeline_node/multimedia_codec/encode_data_process.h @@ -63,6 +63,8 @@ private: int32_t InitEncoder(); int32_t InitEncoderMetadataFormat(); int32_t InitEncoderBitrateFormat(); + int32_t StopVideoEncoder(); + void ReleaseVideoEncoder(); int32_t FeedEncoderInputBuffer(std::shared_ptr& inputBuffer); sptr GetEncoderInputSurfaceBuffer(); int64_t GetEncoderTimeStamp(); diff --git a/services/data_process/src/pipeline_node/fpscontroller/fps_controller_process.cpp b/services/data_process/src/pipeline_node/fpscontroller/fps_controller_process.cpp index 090aa045..0b52c49a 100644 --- a/services/data_process/src/pipeline_node/fpscontroller/fps_controller_process.cpp +++ b/services/data_process/src/pipeline_node/fpscontroller/fps_controller_process.cpp @@ -75,7 +75,7 @@ int32_t FpsControllerProcess::ProcessData(std::vectorFindInt64("timeUs", timeStampUs)) { - DHLOGE("Find decoder output timestamp fail."); + DHLOGE("Find decoder output timestamp failed."); return DCAMERA_BAD_TYPE; } @@ -270,7 +270,7 @@ bool FpsControllerProcess::ReduceFrameRateByUniformStrategy(int32_t incomingFrmR if (overshoot && DOUBLE_MULTIPLE * overshoot < incomingFrmRate) { /* * When the actual input frame rate is less than or equal to twice the target frame rate, - * one frame is droped every (incomingFrmRate / overshoot) frames. + * one frame is dropped every (incomingFrmRate / overshoot) frames. */ if (keepMoreThanDoubleCount_) { keepMoreThanDoubleCount_ = 0; @@ -314,7 +314,7 @@ int32_t FpsControllerProcess::FpsControllerDone(std::vectorProcessData(outputBuffers); if (err != DCAMERA_OK) { - DHLOGE("Someone node after the FpsController processes fail."); + DHLOGE("Someone node after the FpsController processes failed."); } return err; } diff --git a/services/data_process/src/pipeline_node/multimedia_codec/decode_data_process.cpp b/services/data_process/src/pipeline_node/multimedia_codec/decode_data_process.cpp index 488dec5b..8f604063 100644 --- a/services/data_process/src/pipeline_node/multimedia_codec/decode_data_process.cpp +++ b/services/data_process/src/pipeline_node/multimedia_codec/decode_data_process.cpp @@ -20,6 +20,7 @@ #include "convert_nv12_to_nv21.h" #include "dcamera_utils_tools.h" +#include "decode_surface_listener.h" #include "decode_video_callback.h" namespace OHOS { @@ -53,7 +54,7 @@ int32_t DecodeDataProcess::InitNode() InitCodecEvent(); int32_t err = InitDecoder(); if (err != DCAMERA_OK) { - DHLOGE("Init video decoder fail."); + DHLOGE("Init video decoder failed."); ReleaseProcessNode(); return err; } @@ -101,11 +102,11 @@ int32_t DecodeDataProcess::InitDecoder() DHLOGD("Init video decoder."); int32_t err = InitDecoderMetadataFormat(); if (err != DCAMERA_OK) { - DHLOGE("Init video decoder metadata format fail."); + DHLOGE("Init video decoder metadata format failed."); return err; } - videoDecoder_ = Media::VideoDecoderFactory::CreateByName("OMX_hisi_video_decoder_avc"); + videoDecoder_ = Media::VideoDecoderFactory::CreateByMime(processType_); if (videoDecoder_ == nullptr) { DHLOGE("Create video decoder failed."); return DCAMERA_INIT_ERR; @@ -123,7 +124,7 @@ int32_t DecodeDataProcess::InitDecoder() } retVal = SetDecoderOutputSurface(); if (retVal != DCAMERA_OK) { - DHLOGE("Set decoder output surface fail."); + DHLOGE("Set decoder output surface failed."); return retVal; } @@ -174,39 +175,94 @@ int32_t DecodeDataProcess::SetDecoderOutputSurface() decodeConsumerSurface_ = Surface::CreateSurfaceAsConsumer(); if (decodeConsumerSurface_ == nullptr) { - DHLOGE("Creat the decode consumer surface fail."); + DHLOGE("Create the decode consumer surface failed."); return DCAMERA_INIT_ERR; } decodeConsumerSurface_->SetDefaultWidthAndHeight((int32_t)sourceConfig_.GetWidth(), (int32_t)sourceConfig_.GetHeight()); - sptr decodeSurfaceListener_ = new DecodeSurfaceListener(decodeConsumerSurface_, - shared_from_this()); + decodeSurfaceListener_ = new DecodeSurfaceListener(decodeConsumerSurface_, shared_from_this()); if (decodeConsumerSurface_->RegisterConsumerListener(decodeSurfaceListener_) != SURFACE_ERROR_OK) { - DHLOGE("Register consumer listener fail."); + DHLOGE("Register consumer listener failed."); return DCAMERA_INIT_ERR; } sptr surfaceProducer = decodeConsumerSurface_->GetProducer(); if (surfaceProducer == nullptr) { - DHLOGE("Get the surface producer of the decode consumer surface fail."); + DHLOGE("Get the surface producer of the decode consumer surface failed."); return DCAMERA_INIT_ERR; } decodeProducerSurface_ = Surface::CreateSurfaceAsProducer(surfaceProducer); if (decodeProducerSurface_ == nullptr) { - DHLOGE("Creat the decode producer surface of the decode consumer surface fail."); + DHLOGE("Create the decode producer surface of the decode consumer surface failed."); return DCAMERA_INIT_ERR; } DHLOGD("Set the producer surface to video decoder output surface."); int32_t err = videoDecoder_->SetOutputSurface(decodeProducerSurface_); if (err != Media::MediaServiceErrCode::MSERR_OK) { - DHLOGE("Set decoder output surface fail."); + DHLOGE("Set decoder output surface failed."); return DCAMERA_INIT_ERR; } return DCAMERA_OK; } +int32_t DecodeDataProcess::StopVideoDecoder() +{ + if (videoDecoder_ == nullptr) { + DHLOGE("The video decoder does not exist before StopVideoDecoder."); + return DCAMERA_BAD_VALUE; + } + + int32_t ret = videoDecoder_->Flush(); + if (ret != Media::MediaServiceErrCode::MSERR_OK) { + DHLOGE("VideoDecoder flush failed. Error type: %d.", ret); + return DCAMERA_BAD_OPERATE; + } + ret = videoDecoder_->Stop(); + if (ret != Media::MediaServiceErrCode::MSERR_OK) { + DHLOGE("VideoDecoder stop failed. Error type: %d.", ret); + return DCAMERA_BAD_OPERATE; + } + return DCAMERA_OK; +} + +void DecodeDataProcess::ReleaseVideoDecoder() +{ + std::lock_guard lck(mtxDecoderState_); + DHLOGD("Start release videoDecoder."); + if (videoDecoder_ == nullptr) { + DHLOGE("The video decoder does not exist before ReleaseVideoDecoder."); + decodeVideoCallback_ = nullptr; + return; + } + int32_t ret = StopVideoDecoder(); + if (ret != DCAMERA_OK) { + DHLOGE("StopVideoDecoder failed."); + } + ret = videoDecoder_->Release(); + if (ret != Media::MediaServiceErrCode::MSERR_OK) { + DHLOGE("VideoDecoder release failed. Error type: %d.", ret); + } + videoDecoder_ = nullptr; + decodeVideoCallback_ = nullptr; +} + +void DecodeDataProcess::ReleaseDecoderSurface() +{ + if (decodeConsumerSurface_ == nullptr) { + decodeProducerSurface_ = nullptr; + DHLOGE("The decode consumer surface does not exist before UnregisterConsumerListener."); + return; + } + int32_t ret = decodeConsumerSurface_->UnregisterConsumerListener(); + if (ret != SURFACE_ERROR_OK) { + DHLOGE("Unregister consumer listener failed. Error type: %d.", ret); + } + decodeConsumerSurface_ = nullptr; + decodeProducerSurface_ = nullptr; +} + void DecodeDataProcess::ReleaseProcessNode() { DHLOGD("Start release [%d] node : DecodeNode.", nodeRank_); @@ -223,19 +279,8 @@ void DecodeDataProcess::ReleaseProcessNode() eventBusPipeline_ = nullptr; } - { - std::lock_guard lck(mtxDecoderState_); - if (videoDecoder_ != nullptr) { - DHLOGD("Start release videoDecoder."); - videoDecoder_->Flush(); - videoDecoder_->Stop(); - videoDecoder_->Release(); - decodeConsumerSurface_ = nullptr; - decodeProducerSurface_ = nullptr; - videoDecoder_ = nullptr; - decodeVideoCallback_ = nullptr; - } - } + ReleaseVideoDecoder(); + ReleaseDecoderSurface(); processType_ = ""; std::queue> emptyBuffersQueue; @@ -271,7 +316,7 @@ int32_t DecodeDataProcess::ProcessData(std::vector>& return DCAMERA_INDEX_OVERFLOW; } if (inputBuffers[0]->Size() > MAX_YUV420_BUFFER_SIZE) { - DHLOGE("DecodeNode input buffer size %d error.", inputBuffers[0]->Size()); + DHLOGE("DecodeNode input buffer size %zu error.", inputBuffers[0]->Size()); return DCAMERA_MEMORY_OPT_ERROR; } if (!isDecoderProcess_) { @@ -279,12 +324,12 @@ int32_t DecodeDataProcess::ProcessData(std::vector>& return DCAMERA_DISABLE_PROCESS; } inputBuffersQueue_.push(inputBuffers[0]); - DHLOGD("Push inputBuffer sucess. BufSize %d, QueueSize %d.", inputBuffers[0]->Size(), inputBuffersQueue_.size()); + DHLOGD("Push inputBuf sucess. BufSize %zu, QueueSize %zu.", inputBuffers[0]->Size(), inputBuffersQueue_.size()); int32_t err = FeedDecoderInputBuffer(); if (err != DCAMERA_OK) { int32_t sleepTimeUs = 5000; std::this_thread::sleep_for(std::chrono::microseconds(sleepTimeUs)); - DHLOGD("Feed decoder input buffer fail. Try FeedDecoderInputBuffer again."); + DHLOGD("Feed decoder input buffer failed. Try FeedDecoderInputBuffer again."); std::shared_ptr reFeedInputPacket = std::make_shared(); reFeedInputPacket->SetVideoCodecType(sourceConfig_.GetVideoCodecType()); DCameraCodecEvent dCamCodecEv(*this, reFeedInputPacket, VideoCodecAction::ACTION_ONCE_AGAIN); @@ -303,7 +348,7 @@ int32_t DecodeDataProcess::FeedDecoderInputBuffer() while ((!inputBuffersQueue_.empty()) && (isDecoderProcess_)) { std::shared_ptr buffer = inputBuffersQueue_.front(); if (buffer == nullptr || availableInputIndexsQueue_.empty()) { - DHLOGE("inputBuffersQueue size %d, availableInputIndexsQueue size %d.", + DHLOGE("inputBuffersQueue size %zu, availableInputIndexsQueue size %zu.", inputBuffersQueue_.size(), availableInputIndexsQueue_.size()); return DCAMERA_BAD_VALUE; } @@ -317,7 +362,7 @@ int32_t DecodeDataProcess::FeedDecoderInputBuffer() uint32_t index = availableInputIndexsQueue_.front(); std::shared_ptr sharedMemoryInput = videoDecoder_->GetInputBuffer(index); if (sharedMemoryInput == nullptr) { - DHLOGE("Failed to obtain the input shared memory corresponding to the [%d] index.", index); + DHLOGE("Failed to obtain the input shared memory corresponding to the [%u] index.", index); return DCAMERA_BAD_VALUE; } size_t inputMemoDataSize = static_cast(sharedMemoryInput->GetSize()); @@ -327,7 +372,7 @@ int32_t DecodeDataProcess::FeedDecoderInputBuffer() return DCAMERA_MEMORY_OPT_ERROR; } int64_t timeUs = GetDecoderTimeStamp(); - DHLOGD("Decoder input buffer size %d, timeStamp %lld.", buffer->Size(), (long long)timeUs); + DHLOGD("Decoder input buffer size %zu, timeStamp %lld.", buffer->Size(), (long long)timeUs); Media::AVCodecBufferInfo bufferInfo {timeUs, static_cast(buffer->Size()), 0}; int32_t ret = videoDecoder_->QueueInputBuffer(index, bufferInfo, Media::AVCODEC_BUFFER_FLAG_NONE); @@ -414,7 +459,7 @@ void DecodeDataProcess::CopyDecodedImage(const sptr& surBuf, int6 bytesPerPixel / y2UvRatio); size_t surfaceBufSize = static_cast(surBuf->GetSize()); if (validDecodedImageAlignedSize > surfaceBufSize || validDecodedImageAlignedSize < validDecodedImageSize) { - DHLOGE("Buffer size error, validDecodedImageSize %d, validDecodedImageAlignedSize %d, surBufSize %d.", + DHLOGE("Buffer size error, validDecodedImageSize %zu, validDecodedImageAlignedSize %zu, surBufSize %zu.", validDecodedImageSize, validDecodedImageAlignedSize, surBuf->GetSize()); return; } @@ -561,7 +606,7 @@ int32_t DecodeDataProcess::DecodeDone(std::vector> o DHLOGD("Send to the next node of the decoder for processing."); int32_t err = nextDataProcess_->ProcessData(outputBuffers); if (err != DCAMERA_OK) { - DHLOGE("Someone node after the decoder processes fail."); + DHLOGE("Someone node after the decoder processes failed."); } return err; } @@ -630,7 +675,7 @@ void DecodeDataProcess::OnInputBufferAvailable(uint32_t index) DHLOGE("Video decoder available indexs queue overflow."); return; } - DHLOGD("Video decoder available indexs queue push index [%d].", index); + DHLOGD("Video decoder available indexs queue push index [%u].", index); availableInputIndexsQueue_.push(index); } @@ -661,7 +706,7 @@ void DecodeDataProcess::OnOutputBufferAvailable(uint32_t index, const Media::AVC } int32_t errRelease = videoDecoder_->ReleaseOutputBuffer(index, true); if (errRelease != Media::MediaServiceErrCode::MSERR_OK) { - DHLOGE("The video decoder output decoded data to surface fail, index : [%d].", index); + DHLOGE("The video decoder output decoded data to surface failed, index : [%u].", index); } } } @@ -675,26 +720,5 @@ VideoConfigParams DecodeDataProcess::GetTargetConfig() const { return targetConfig_; } - -void DecodeSurfaceListener::OnBufferAvailable() -{ - DHLOGD("DecodeSurfaceListener : OnBufferAvailable."); - std::shared_ptr targetDecoderNode = decodeVideoNode_.lock(); - if (targetDecoderNode == nullptr) { - DHLOGE("decodeVideoNode_ is nullptr."); - return; - } - targetDecoderNode->GetDecoderOutputBuffer(surface_); -} - -void DecodeSurfaceListener::SetSurface(const sptr& surface) -{ - surface_ = surface; -} - -void DecodeSurfaceListener::SetDecodeVideoNode(const std::weak_ptr& decodeVideoNode) -{ - decodeVideoNode_ = decodeVideoNode; -} } } \ No newline at end of file diff --git a/services/data_process/src/pipeline_node/multimedia_codec/decode_surface_listener.cpp b/services/data_process/src/pipeline_node/multimedia_codec/decode_surface_listener.cpp new file mode 100644 index 00000000..2e2fae3a --- /dev/null +++ b/services/data_process/src/pipeline_node/multimedia_codec/decode_surface_listener.cpp @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "decode_surface_listener.h" + +#include "distributed_hardware_log.h" + +namespace OHOS { +namespace DistributedHardware { +DecodeSurfaceListener::~DecodeSurfaceListener() +{ + DHLOGD("DecodeSurfaceListener : ~DecodeSurfaceListener."); + surface_ = nullptr; +} + +void DecodeSurfaceListener::OnBufferAvailable() +{ + DHLOGD("DecodeSurfaceListener : OnBufferAvailable."); + std::shared_ptr targetDecoderNode = decodeVideoNode_.lock(); + if (targetDecoderNode == nullptr) { + DHLOGE("decodeVideoNode_ is nullptr."); + return; + } + targetDecoderNode->GetDecoderOutputBuffer(surface_); +} + +void DecodeSurfaceListener::SetSurface(const sptr& surface) +{ + surface_ = surface; +} + +void DecodeSurfaceListener::SetDecodeVideoNode(const std::weak_ptr& decodeVideoNode) +{ + decodeVideoNode_ = decodeVideoNode; +} + +sptr DecodeSurfaceListener::GetSurface() const +{ + return surface_; +} + +std::shared_ptr DecodeSurfaceListener::GetDecodeVideoNode() const +{ + std::shared_ptr targetDecoderNode = decodeVideoNode_.lock(); + if (targetDecoderNode == nullptr) { + DHLOGE("decodeVideoNode_ is nullptr."); + } + return targetDecoderNode; +} +} +} \ No newline at end of file diff --git a/services/data_process/src/pipeline_node/multimedia_codec/decode_video_callback.cpp b/services/data_process/src/pipeline_node/multimedia_codec/decode_video_callback.cpp index 401f3672..a4aa6883 100644 --- a/services/data_process/src/pipeline_node/multimedia_codec/decode_video_callback.cpp +++ b/services/data_process/src/pipeline_node/multimedia_codec/decode_video_callback.cpp @@ -21,7 +21,7 @@ namespace OHOS { namespace DistributedHardware { void DecodeVideoCallback::OnError(Media::AVCodecErrorType errorType, int32_t errorCode) { - DHLOGE("DecodeVideoCallback : OnError. Error type: %d . Error code: %d ", errorType, errorCode); + DHLOGE("DecodeVideoCallback : OnError. Error type: %d. Error code: %d ", errorType, errorCode); std::shared_ptr targetDecoderNode = decodeVideoNode_.lock(); if (targetDecoderNode == nullptr) { DHLOGE("decodeVideoNode_ is nullptr."); diff --git a/services/data_process/src/pipeline_node/multimedia_codec/encode_data_process.cpp b/services/data_process/src/pipeline_node/multimedia_codec/encode_data_process.cpp index f5d9c92a..b833daf4 100644 --- a/services/data_process/src/pipeline_node/multimedia_codec/encode_data_process.cpp +++ b/services/data_process/src/pipeline_node/multimedia_codec/encode_data_process.cpp @@ -71,7 +71,7 @@ int32_t EncodeDataProcess::InitNode() int32_t err = InitEncoder(); if (err != DCAMERA_OK) { - DHLOGE("Init video encoder fail."); + DHLOGE("Init video encoder failed."); ReleaseProcessNode(); return err; } @@ -97,12 +97,12 @@ int32_t EncodeDataProcess::InitEncoder() DHLOGD("Init video encoder."); int32_t err = InitEncoderMetadataFormat(); if (err != DCAMERA_OK) { - DHLOGE("Init video encoder metadata format fail."); + DHLOGE("Init video encoder metadata format failed."); return err; } err = InitEncoderBitrateFormat(); if (err != DCAMERA_OK) { - DHLOGE("Init video encoder bitrate format fail."); + DHLOGE("Init video encoder bitrate format failed."); return err; } @@ -214,6 +214,49 @@ int32_t EncodeDataProcess::InitEncoderBitrateFormat() return DCAMERA_OK; } +int32_t EncodeDataProcess::StopVideoEncoder() +{ + if (videoEncoder_ == nullptr) { + DHLOGE("The video encoder does not exist before StopVideoEncoder."); + return DCAMERA_BAD_VALUE; + } + int32_t ret = videoEncoder_->Flush(); + if (ret != Media::MediaServiceErrCode::MSERR_OK) { + DHLOGE("VideoEncoder flush failed. Error type: %d.", ret); + return DCAMERA_BAD_OPERATE; + } + ret = videoEncoder_->Stop(); + if (ret != Media::MediaServiceErrCode::MSERR_OK) { + DHLOGE("VideoEncoder stop failed. Error type: %d.", ret); + return DCAMERA_BAD_OPERATE; + } + return DCAMERA_OK; +} + +void EncodeDataProcess::ReleaseVideoEncoder() +{ + std::lock_guard lck(mtxEncoderState_); + DHLOGD("Start release videoEncoder."); + if (videoEncoder_ == nullptr) { + DHLOGE("The video encoder does not exist before ReleaseVideoEncoder."); + encodeProducerSurface_ = nullptr; + encodeVideoCallback_ = nullptr; + return; + } + + int32_t ret = StopVideoEncoder(); + if (ret != DCAMERA_OK) { + DHLOGE("StopVideoEncoder failed."); + } + ret = videoEncoder_->Release(); + if (ret != Media::MediaServiceErrCode::MSERR_OK) { + DHLOGE("VideoEncoder release failed. Error type: %d.", ret); + } + encodeProducerSurface_ = nullptr; + videoEncoder_ = nullptr; + encodeVideoCallback_ = nullptr; +} + void EncodeDataProcess::ReleaseProcessNode() { DHLOGD("Start release [%d] node : EncodeNode.", nodeRank_); @@ -222,18 +265,7 @@ void EncodeDataProcess::ReleaseProcessNode() nextDataProcess_->ReleaseProcessNode(); } - { - std::lock_guard lck(mtxEncoderState_); - if (videoEncoder_ != nullptr) { - DHLOGD("Start release videoEncoder."); - videoEncoder_->Flush(); - videoEncoder_->Stop(); - videoEncoder_->Release(); - encodeProducerSurface_ = nullptr; - videoEncoder_ = nullptr; - encodeVideoCallback_ = nullptr; - } - } + ReleaseVideoEncoder(); waitEncoderOutputCount_ = 0; lastFeedEncoderInputBufferTimeUs_ = 0; @@ -269,7 +301,7 @@ int32_t EncodeDataProcess::ProcessData(std::vector>& } int32_t err = FeedEncoderInputBuffer(inputBuffers[0]); if (err != DCAMERA_OK) { - DHLOGE("Feed encoder input Buffer fail."); + DHLOGE("Feed encoder input Buffer failed."); return err; } { @@ -375,7 +407,7 @@ int32_t EncodeDataProcess::GetEncoderOutputBuffer(uint32_t index, Media::AVCodec } std::shared_ptr sharedMemoryOutput = videoEncoder_->GetOutputBuffer(index); if (sharedMemoryOutput == nullptr) { - DHLOGE("Failed to get the output shared memory, index : %d", index); + DHLOGE("Failed to get the output shared memory, index : %u", index); return DCAMERA_BAD_OPERATE; } @@ -412,7 +444,7 @@ int32_t EncodeDataProcess::EncodeDone(std::vector> o DHLOGD("Send to the next node of the encoder for processing."); int32_t err = nextDataProcess_->ProcessData(outputBuffers); if (err != DCAMERA_OK) { - DHLOGE("Someone node after the encoder processes fail."); + DHLOGE("Someone node after the encoder processes failed."); } return err; } @@ -442,7 +474,7 @@ void EncodeDataProcess::OnError() void EncodeDataProcess::OnInputBufferAvailable(uint32_t index) { - DHLOGD("The available input buffer index : %d. No operation when using surface input.", index); + DHLOGD("The available input buffer index : %u. No operation when using surface input.", index); } void EncodeDataProcess::OnOutputFormatChanged(const Media::Format &format) @@ -465,7 +497,7 @@ void EncodeDataProcess::OnOutputBufferAvailable(uint32_t index, Media::AVCodecBu info.presentationTimeUs, info.size, info.offset, flag); int32_t err = GetEncoderOutputBuffer(index, info); if (err != DCAMERA_OK) { - DHLOGE("Get encode output Buffer fail."); + DHLOGE("Get encode output Buffer failed."); return; } { @@ -482,7 +514,7 @@ void EncodeDataProcess::OnOutputBufferAvailable(uint32_t index, Media::AVCodecBu } int32_t errRelease = videoEncoder_->ReleaseOutputBuffer(index); if (errRelease != Media::MediaServiceErrCode::MSERR_OK) { - DHLOGE("The video encoder release output buffer fail, index : [%d].", index); + DHLOGE("The video encoder release output buffer failed, index : [%u].", index); } } VideoConfigParams EncodeDataProcess::GetSourceConfig() const diff --git a/services/data_process/src/pipeline_node/multimedia_codec/encode_video_callback.cpp b/services/data_process/src/pipeline_node/multimedia_codec/encode_video_callback.cpp index 27b05a22..0c47eaa0 100644 --- a/services/data_process/src/pipeline_node/multimedia_codec/encode_video_callback.cpp +++ b/services/data_process/src/pipeline_node/multimedia_codec/encode_video_callback.cpp @@ -20,7 +20,7 @@ namespace OHOS { namespace DistributedHardware { void EncodeVideoCallback::OnError(Media::AVCodecErrorType errorType, int32_t errorCode) { - DHLOGD("EncodeVideoCallback : OnError. Error type: %d . Error code: %d ", errorType, errorCode); + DHLOGD("EncodeVideoCallback : OnError. Error type: %d. Error code: %d ", errorType, errorCode); std::shared_ptr targetEncoderNode = encodeVideoNode_.lock(); if (targetEncoderNode == nullptr) { DHLOGE("encodeVideoNode_ is nullptr."); -- Gitee