mirror of
https://github.com/openharmony/distributed_camera.git
synced 2026-07-18 16:04:29 -04:00
@@ -33,6 +33,7 @@ ohos_shared_library("distributed_camera_utils") {
|
||||
sources = [
|
||||
"src/utils/data_buffer.cpp",
|
||||
"src/utils/dcamera_hisysevent_adapter.cpp",
|
||||
"src/utils/dcamera_hitrace_adapter.cpp",
|
||||
"src/utils/dcamera_sa_process_state.cpp",
|
||||
"src/utils/dcamera_utils_tools.cpp",
|
||||
]
|
||||
@@ -51,6 +52,7 @@ ohos_shared_library("distributed_camera_utils") {
|
||||
external_deps = [
|
||||
"dsoftbus_standard:softbus_client",
|
||||
"hisysevent_native:libhisysevent",
|
||||
"hitrace_native:hitrace_meter",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
]
|
||||
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (c) 2022 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_DCAMERA_HITRACE_ADAPTER_H
|
||||
#define OHOS_DCAMERA_HITRACE_ADAPTER_H
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "hitrace_meter.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
constexpr uint64_t DCAMERA_HITRACE_LABEL = HITRACE_TAG_DISTRIBUTED_CAMERA;
|
||||
const std::string DCAMERA_OPEN_CHANNEL_START = "DCAMERA_OPEN_CHANNEL_START";
|
||||
const std::string DCAMERA_INPUT_OPEN_START = "DCAMERA_INPUT_OPEN_START";
|
||||
const std::string DCAMERA_CAPTURE_FIRST_FRAME = "DCAMERA_CAPTURE_GET_FIRST_FRAME";
|
||||
enum DcameraTaskId {
|
||||
DCAMERA_OPEN_CHANNEL_TASKID = 0,
|
||||
DCAMERA_INPUT_OPEN_TASKID = 1,
|
||||
DCAMERA_CAPTURE_FIRST_FRAM_TASKID = 2,
|
||||
};
|
||||
|
||||
void DcameraSyncTrace();
|
||||
void DcameraStartAsyncTrace(const std::string& str, int32_t taskId);
|
||||
void DcameraFinishAsyncTrace(const std::string& str, int32_t taskId);
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_DCAMERA_HITRACE_ADAPTER_H
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright (c) 2022 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 "dcamera_hitrace_adapter.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedHardware {
|
||||
void DcameraSyncTrace()
|
||||
{
|
||||
HITRACE_METER(DCAMERA_HITRACE_LABEL);
|
||||
}
|
||||
|
||||
void DcameraStartAsyncTrace(const std::string& str, int32_t taskId)
|
||||
{
|
||||
StartAsyncTrace(DCAMERA_HITRACE_LABEL, str, taskId, -1);
|
||||
}
|
||||
|
||||
void DcameraFinishAsyncTrace(const std::string& str, int32_t taskId)
|
||||
{
|
||||
FinishAsyncTrace(DCAMERA_HITRACE_LABEL, str, taskId);
|
||||
}
|
||||
} // namespace DistributedHardware
|
||||
} // namespace OHOS
|
||||
@@ -107,6 +107,7 @@ ohos_shared_library("distributed_camera_source") {
|
||||
"device_driver_framework:libhdf_utils",
|
||||
"device_driver_framework:libhdi",
|
||||
"eventhandler:libeventhandler",
|
||||
"hitrace_native:hitrace_meter",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"ipc:ipc_core",
|
||||
"safwk:system_ability_fwk",
|
||||
|
||||
+2
@@ -25,6 +25,7 @@
|
||||
#include "anonymous_string.h"
|
||||
#include "dcamera_hdf_operate.h"
|
||||
#include "dcamera_hisysevent_adapter.h"
|
||||
#include "dcamera_hitrace_adapter.h"
|
||||
#include "dcamera_service_state_listener.h"
|
||||
#include "dcamera_source_service_ipc.h"
|
||||
#include "distributed_camera_errno.h"
|
||||
@@ -194,6 +195,7 @@ int32_t DistributedCameraSourceService::DCameraNotify(const std::string& devId,
|
||||
|
||||
int32_t DistributedCameraSourceService::LoadDCameraHDF()
|
||||
{
|
||||
DcameraSyncTrace();
|
||||
DHLOGI("load hdf driver start");
|
||||
int32_t ret = DCameraHdfOperate::GetInstance().LoadDcameraHDFImpl();
|
||||
if (ret != DCAMERA_OK) {
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
#include "anonymous_string.h"
|
||||
#include "dcamera_hisysevent_adapter.h"
|
||||
#include "dcamera_hitrace_adapter.h"
|
||||
#include "distributed_camera_constants.h"
|
||||
#include "distributed_camera_errno.h"
|
||||
#include "distributed_hardware_log.h"
|
||||
@@ -214,6 +215,7 @@ void DCameraSourceDev::OnEvent(DCameraSourceEvent& event)
|
||||
|
||||
int32_t DCameraSourceDev::ExecuteRegister(std::shared_ptr<DCameraRegistParam>& param)
|
||||
{
|
||||
DcameraSyncTrace();
|
||||
DHLOGI("DCameraSourceDev Execute Register devId: %s dhId: %s",
|
||||
GetAnonyString(devId_).c_str(), GetAnonyString(dhId_).c_str());
|
||||
ReportRegisterCameraEvent(REGIST_CAMERA_EVENT, GetAnonyString(devId_), dhId_,
|
||||
@@ -259,6 +261,7 @@ int32_t DCameraSourceDev::ExecuteRegister(std::shared_ptr<DCameraRegistParam>& p
|
||||
|
||||
int32_t DCameraSourceDev::ExecuteUnRegister(std::shared_ptr<DCameraRegistParam>& param)
|
||||
{
|
||||
DcameraSyncTrace();
|
||||
DHLOGI("DCameraSourceDev Execute UnRegister devId: %s dhId: %s", GetAnonyString(devId_).c_str(),
|
||||
GetAnonyString(dhId_).c_str());
|
||||
ReportRegisterCameraEvent(UNREGIST_CAMERA_EVENT, GetAnonyString(devId_), dhId_,
|
||||
@@ -403,6 +406,7 @@ int32_t DCameraSourceDev::ExecuteReleaseAllStreams()
|
||||
|
||||
int32_t DCameraSourceDev::ExecuteStartCapture(std::vector<std::shared_ptr<DCCaptureInfo>>& captureInfos)
|
||||
{
|
||||
DcameraStartAsyncTrace(DCAMERA_CAPTURE_FIRST_FRAME, DCAMERA_CAPTURE_FIRST_FRAM_TASKID);
|
||||
DHLOGI("DCameraSourceDev Execute StartCapture devId %s dhId %s", GetAnonyString(devId_).c_str(),
|
||||
GetAnonyString(dhId_).c_str());
|
||||
int32_t ret = input_->StartCapture(captureInfos);
|
||||
|
||||
+3
@@ -20,6 +20,7 @@
|
||||
|
||||
#include "dcamera_capture_info_cmd.h"
|
||||
#include "dcamera_channel_source_impl.h"
|
||||
#include "dcamera_hitrace_adapter.h"
|
||||
#include "dcamera_metadata_setting_cmd.h"
|
||||
#include "dcamera_protocol.h"
|
||||
#include "dcamera_source_controller_channel_listener.h"
|
||||
@@ -264,6 +265,7 @@ int32_t DCameraSourceController::GetCameraInfo(std::shared_ptr<DCameraInfo>& cam
|
||||
|
||||
int32_t DCameraSourceController::OpenChannel(std::shared_ptr<DCameraOpenInfo>& openInfo)
|
||||
{
|
||||
DcameraStartAsyncTrace(DCAMERA_OPEN_CHANNEL_START, DCAMERA_OPEN_CHANNEL_TASKID);
|
||||
if (indexs_.size() > DCAMERA_MAX_NUM) {
|
||||
DHLOGE("DCameraSourceController OpenChannel not support operate %d camera", indexs_.size());
|
||||
return DCAMERA_BAD_OPERATE;
|
||||
@@ -381,6 +383,7 @@ void DCameraSourceController::OnSessionState(int32_t state)
|
||||
channelState_ = state;
|
||||
switch (state) {
|
||||
case DCAMERA_CHANNEL_STATE_CONNECTED: {
|
||||
DcameraFinishAsyncTrace(DCAMERA_OPEN_CHANNEL_START, DCAMERA_OPEN_CHANNEL_TASKID);
|
||||
stateMachine_->UpdateState(DCAMERA_STATE_OPENED);
|
||||
std::shared_ptr<DCameraEvent> camEvent = std::make_shared<DCameraEvent>();
|
||||
camEvent->eventType_ = DCAMERA_MESSAGE;
|
||||
|
||||
+3
@@ -16,6 +16,7 @@
|
||||
#include "dcamera_source_input.h"
|
||||
|
||||
#include "anonymous_string.h"
|
||||
#include "dcamera_hitrace_adapter.h"
|
||||
#include "distributed_camera_constants.h"
|
||||
#include "distributed_camera_errno.h"
|
||||
#include "distributed_hardware_log.h"
|
||||
@@ -179,6 +180,7 @@ int32_t DCameraSourceInput::StopCapture(std::vector<int>& streamIds, bool& isAll
|
||||
|
||||
int32_t DCameraSourceInput::OpenChannel(std::vector<DCameraIndex>& indexs)
|
||||
{
|
||||
DcameraStartAsyncTrace(DCAMERA_INPUT_OPEN_START, DCAMERA_INPUT_OPEN_TASKID);
|
||||
DHLOGI("DCameraSourceInput OpenChannel devId %s dhId %s continue state: %d, snapshot state: %d",
|
||||
GetAnonyString(devId_).c_str(), GetAnonyString(dhId_).c_str(), channelState_[CONTINUOUS_FRAME],
|
||||
channelState_[SNAPSHOT_FRAME]);
|
||||
@@ -324,6 +326,7 @@ void DCameraSourceInput::OnSessionState(DCStreamType streamType, int32_t state)
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
DcameraFinishAsyncTrace(DCAMERA_INPUT_OPEN_START, DCAMERA_INPUT_OPEN_TASKID);
|
||||
DHLOGI("DCameraSourceInput OnSessionState state %d", state);
|
||||
break;
|
||||
}
|
||||
|
||||
+2
@@ -19,6 +19,7 @@
|
||||
#include <securec.h>
|
||||
|
||||
#include "anonymous_string.h"
|
||||
#include "dcamera_hitrace_adapter.h"
|
||||
#include "distributed_camera_constants.h"
|
||||
#include "distributed_camera_errno.h"
|
||||
#include "distributed_hardware_log.h"
|
||||
@@ -175,6 +176,7 @@ void DCameraStreamDataProcessProducer::LooperSnapShot()
|
||||
GetAnonyString(devId_).c_str(), GetAnonyString(dhId_).c_str(), streamType_, streamId_, state_);
|
||||
continue;
|
||||
}
|
||||
DcameraFinishAsyncTrace(DCAMERA_CAPTURE_FIRST_FRAME, DCAMERA_CAPTURE_FIRST_FRAM_TASKID);
|
||||
int32_t ret = FeedStreamToDriver(dhBase, buffer);
|
||||
if (ret != DCAMERA_OK) {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(DCAMERA_PRODUCER_RETRY_SLEEP_MS));
|
||||
|
||||
@@ -84,6 +84,7 @@ ohos_shared_library("distributed_camera_data_process") {
|
||||
|
||||
external_deps = [
|
||||
"eventhandler:libeventhandler",
|
||||
"hitrace_native:hitrace_meter",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"multimedia_media_standard:media_client",
|
||||
]
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
|
||||
#include "dcamera_pipeline_sink.h"
|
||||
|
||||
#include "dcamera_hitrace_adapter.h"
|
||||
#include "distributed_hardware_log.h"
|
||||
|
||||
#include "encode_data_process.h"
|
||||
@@ -35,6 +36,7 @@ int32_t DCameraPipelineSink::CreateDataProcessPipeline(PipelineType piplineType,
|
||||
const VideoConfigParams& sourceConfig, const VideoConfigParams& targetConfig,
|
||||
const std::shared_ptr<DataProcessListener>& listener)
|
||||
{
|
||||
DcameraSyncTrace();
|
||||
DHLOGD("Create sink data process pipeline.");
|
||||
switch (piplineType) {
|
||||
case PipelineType::VIDEO:
|
||||
@@ -146,6 +148,7 @@ int32_t DCameraPipelineSink::ProcessData(std::vector<std::shared_ptr<DataBuffer>
|
||||
|
||||
void DCameraPipelineSink::DestroyDataProcessPipeline()
|
||||
{
|
||||
DcameraSyncTrace();
|
||||
DHLOGD("Destroy sink data process pipeline start.");
|
||||
isProcess_ = false;
|
||||
if (pipelineHead_ != nullptr) {
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
|
||||
#include "dcamera_pipeline_source.h"
|
||||
|
||||
#include "dcamera_hitrace_adapter.h"
|
||||
#include "distributed_hardware_log.h"
|
||||
|
||||
#include "color_format_process.h"
|
||||
@@ -37,6 +38,7 @@ int32_t DCameraPipelineSource::CreateDataProcessPipeline(PipelineType piplineTyp
|
||||
const VideoConfigParams& sourceConfig, const VideoConfigParams& targetConfig,
|
||||
const std::shared_ptr<DataProcessListener>& listener)
|
||||
{
|
||||
DcameraSyncTrace();
|
||||
DHLOGD("Create source data process pipeline.");
|
||||
switch (piplineType) {
|
||||
case PipelineType::VIDEO:
|
||||
@@ -168,6 +170,7 @@ int32_t DCameraPipelineSource::ProcessData(std::vector<std::shared_ptr<DataBuffe
|
||||
|
||||
void DCameraPipelineSource::DestroyDataProcessPipeline()
|
||||
{
|
||||
DcameraSyncTrace();
|
||||
DHLOGD("Destroy source data process pipeline start.");
|
||||
isProcess_ = false;
|
||||
if (pipelineHead_ != nullptr) {
|
||||
|
||||
Reference in New Issue
Block a user