mirror of
https://github.com/openharmony/drivers_peripheral.git
synced 2026-08-26 19:50:42 -04:00
Merge branch 'master' of https://gitee.com/long-youling/drivers_peripheral
This commit is contained in:
@@ -179,11 +179,11 @@ int32_t AudioCreateRenderVdi(struct IAudioAdapter *adapter, const struct AudioDe
|
||||
pthread_mutex_unlock(&g_adapterMutex);
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
*render = AudioCreateRenderByIdVdi(attrs, renderId, vdiRender, desc, adapterName);
|
||||
vdiRender->AddAudioEffect = NULL;
|
||||
vdiRender->RemoveAudioEffect = NULL;
|
||||
vdiRender->GetFrameBufferSize = NULL;
|
||||
vdiRender->IsSupportsPauseAndResume = NULL;
|
||||
*render = AudioCreateRenderByIdVdi(attrs, renderId, vdiRender, desc, adapterName);
|
||||
if (*render == NULL) {
|
||||
(void)vdiAdapter->DestroyRender(vdiAdapter, vdiRender);
|
||||
AUDIO_FUNC_LOGE("Create audio render failed");
|
||||
@@ -713,7 +713,7 @@ void AudioReleaseAdapterVdi(uint32_t descIndex)
|
||||
priv->isRegCb = false;
|
||||
priv->callback = NULL;
|
||||
|
||||
AUDIO_FUNC_LOGD(" audio vdiAdapter release adapter success");
|
||||
AUDIO_FUNC_LOGI(" audio vdiAdapter release adapter success");
|
||||
}
|
||||
|
||||
int32_t InitAdapterMutex(void)
|
||||
|
||||
@@ -893,4 +893,5 @@ void AudioDestroyCaptureByIdVdi(uint32_t captureId)
|
||||
|
||||
OsalMemFree(priv->captureInfos[captureId]);
|
||||
priv->captureInfos[captureId] = NULL;
|
||||
AUDIO_FUNC_LOGI("audio destroy capture success");
|
||||
}
|
||||
|
||||
@@ -356,7 +356,7 @@ static struct IAudioAdapter* VendorLoadAdapter(struct IAudioManagerVdi *vdiManag
|
||||
vdiManager->UnloadAdapter(vdiManager, vdiAdapter);
|
||||
return NULL;
|
||||
}
|
||||
AudioManagerReleaseVdiDesc(&vdiDesc);
|
||||
AudioManagerReleaseVdiDesc(vdiDesc);
|
||||
return adapter;
|
||||
}
|
||||
|
||||
@@ -398,7 +398,7 @@ int32_t AudioManagerVendorLoadAdapter(struct IAudioManager *manager, const struc
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
*adapter = VendorLoadAdapter(priv->vdiManager, descIndex, vdiDesc);
|
||||
*adapter = VendorLoadAdapter(priv->vdiManager, &vdiDesc, descIndex);
|
||||
if (*adapter == NULL) {
|
||||
pthread_mutex_unlock(&g_managerMutex);
|
||||
return HDF_FAILURE;
|
||||
@@ -414,7 +414,7 @@ static int32_t AudioManagerVendorUnloadAdapterLocked(struct IAudioManager *manag
|
||||
CHECK_NULL_PTR_RETURN_VALUE(adapterName, HDF_ERR_INVALID_PARAM);
|
||||
|
||||
struct AudioManagerPrivVdi *priv = (struct AudioManagerPrivVdi *)manager;
|
||||
if (priv == NULL || priv->vdiManager == NULL || priv->vdiManager->UnLoadAdapter == NULL) {
|
||||
if (priv == NULL || priv->vdiManager == NULL || priv->vdiManager->UnloadAdapter == NULL) {
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
@@ -438,7 +438,6 @@ static int32_t AudioManagerVendorUnloadAdapterLocked(struct IAudioManager *manag
|
||||
HdfAudioStartTrace("Hdi:AudioManagerVendorUnloadAdapter", 0);
|
||||
priv->vdiManager->UnloadAdapter(priv->vdiManager, vdiAdapter);
|
||||
HdfAudioFinishTrace();
|
||||
|
||||
AudioReleaseAdapterVdi(descIndex);
|
||||
AUDIO_FUNC_LOGD("audio vdiManager unload vdiAdapter success");
|
||||
return HDF_SUCCESS;
|
||||
@@ -484,6 +483,7 @@ int32_t ReleaseAudioManagerVendorObject(struct IAudioManager *manager)
|
||||
AudioManagerReleaseDescs(priv->descs, priv->descsCount);
|
||||
OsalMemFree((void *)priv);
|
||||
priv = NULL;
|
||||
AUDIO_FUNC_LOGI("audio release vendor lib success");
|
||||
pthread_mutex_unlock(&g_managerMutex);
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -1072,4 +1072,5 @@ void AudioDestroyRenderByIdVdi(uint32_t renderId)
|
||||
priv->renderInfos[renderId]->isRegCb = false;
|
||||
OsalMemFree(priv->renderInfos[renderId]);
|
||||
priv->renderInfos[renderId] = NULL;
|
||||
AUDIO_FUNC_LOGI("audio destroy render success");
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
#define HDF_LOG_TAG HDF_AUDIO_HAL_CAPTURE
|
||||
|
||||
typedef stuct CaptureData {
|
||||
typedef struct CaptureData {
|
||||
struct AlsaMixerCtlElement ctrlLeftVolume;
|
||||
struct AlsaMixerCtlElement ctrlRightVolume;
|
||||
long tempVolume;
|
||||
|
||||
@@ -13,13 +13,14 @@
|
||||
|
||||
import("//build/test.gni")
|
||||
import("//build/test.gni")
|
||||
import("../../../audio.gni")
|
||||
|
||||
group("audio_config_fuzzer") {
|
||||
testonly = true
|
||||
deps = []
|
||||
|
||||
deps += [
|
||||
"audiocardconfig_fuzzer:AudioCardConfigFuzzTest",
|
||||
"pathselectconfig_fuzzer:PathSelectConfigFuzzTest",
|
||||
]
|
||||
deps += [ "pathselectconfig_fuzzer:PathSelectConfigFuzzTest" ]
|
||||
if (drivers_peripheral_audio_feature_alsa_lib) {
|
||||
deps += [ "audiocardconfig_fuzzer:AudioCardConfigFuzzTest" ]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,8 +45,8 @@ ohos_fuzztest("AudioCardConfigFuzzTest") {
|
||||
external_deps += [ "c_utils:utils" ]
|
||||
}
|
||||
external_deps += [
|
||||
"alsa-lib:libasound",
|
||||
"bounds_checking_function:libsec_shared",
|
||||
"cJSON:cjson",
|
||||
]
|
||||
include_dirs += [ "//third_party/alsa-lib/include" ]
|
||||
}
|
||||
|
||||
@@ -1,439 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2024 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 "audio_type_vdi.h"
|
||||
#include "iaudio_callback_vdi.h"
|
||||
#include "iaudio_render_vdi.h"
|
||||
|
||||
static int32_t GetLatency(struct IAudioRenderVdi* render, uint32_t *ms)
|
||||
{
|
||||
if (render == NULL) {
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
if (ms == NULL) {
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
*ms = 1000;
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t RenderFrame(struct IAudioRenderVdi* render, const int8_t *frame, uint32_t frameLen, uint64_t *replyBytes)
|
||||
{
|
||||
if (render == NULL || frame == NULL || replyBytes == NULL) {
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
(void *)frame;
|
||||
*replyBytes = 48000 * 20 / 1000 * 32 / 8;
|
||||
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t GetPosition(struct IAudioRenderVdi* render, uint64_t *frames, struct AudioTimeStamp *time)
|
||||
{
|
||||
if (render == NULL || frame == NULL || time == NULL) {
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
(void *)frames;
|
||||
(void *)time;
|
||||
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t SetSpeed(struct IAudioRenderVdi* render, float speed)
|
||||
{
|
||||
if (render == NULL) {
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
(void)speed;
|
||||
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t GetSpeed(struct IAudioRenderVdi* render, float *speed)
|
||||
{
|
||||
if (render == NULL || speed == NULL) {
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
*speed == 1.0;
|
||||
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t RegCallback(struct IAudioRenderVdi* render, struct IAudioCallback *audioCallback, int8_t cookie)
|
||||
{
|
||||
if (render == NULL || speed == NULL) {
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
*speed == 1.0;
|
||||
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t SetChannelMode(struct IAudioRenderVdi* render, enum AudioChannelMode mode)
|
||||
{
|
||||
if (render == NULL || speed == NULL) {
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
(void)mode;
|
||||
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t GetChannelMode(struct IAudioRenderVdi* render, enum AudioChannelMode *mode)
|
||||
{
|
||||
if (render == NULL || speed == NULL) {
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
(void *)mode;
|
||||
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t DrainBuffer(struct IAudioRenderVdi* render, enum AudioDrainNotifyType *type)
|
||||
{
|
||||
if (render == NULL) {
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
(void *)type;
|
||||
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t IsSupportsDrain(struct IAudioRenderVdi* render, bool *support)
|
||||
{
|
||||
if (render == NULL) {
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
(void *)support;
|
||||
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t CheckSceneCapability(struct IAudioRenderVdi* render, const struct AudioSceneDescriptor *scene,
|
||||
bool *supported)
|
||||
{
|
||||
if (render == NULL || scene == NULL || support == NULL) {
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
(void *)supported;
|
||||
(void *)scene;
|
||||
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t SelectScene(struct IAudioRenderVdi* render, const struct AudioSceneDescriptor *scene)
|
||||
{
|
||||
if (render == NULL || scene == NULL) {
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
(void *)scene;
|
||||
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t SetMute(struct IAudioRenderVdi* render, bool mute)
|
||||
{
|
||||
if (render == NULL) {
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
(void)mute;
|
||||
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t GetMute(struct IAudioRenderVdi* render, bool *mute)
|
||||
{
|
||||
if (render == NULL || mute == NULL) {
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
(void *)mute;
|
||||
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static int32_t SetVolume(struct IAudioRenderVdi* render, float volume)
|
||||
{
|
||||
if (render == NULL) {
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
(void)volume;
|
||||
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t GetVolume(struct IAudioRenderVdi* render, float *volume)
|
||||
{
|
||||
if (render == NULL) {
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
(void *)volume;
|
||||
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t GetGainThreshold(struct IAudioRenderVdi* render, float *min, float *max)
|
||||
{
|
||||
if (render == NULL || min == NULL || max == NULL) {
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
(void *)min;
|
||||
(void *)max;
|
||||
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t GetGain(struct IAudioRenderVdi* render, float *gain)
|
||||
{
|
||||
if (render == NULL || gain == NULL) {
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
(void *)gain;
|
||||
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t SetGain(struct IAudioRenderVdi* render, float gain)
|
||||
{
|
||||
if (render == NULL) {
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
(void)gain;
|
||||
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t GetFrameSize(struct IAudioRenderVdi* render, uint64_t *size)
|
||||
{
|
||||
if (render == NULL || size == NULL) {
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
(void *)size;
|
||||
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t GetFrameCount(struct IAudioRenderVdi* render, uint64_t *count)
|
||||
{
|
||||
if (render == NULL || count == NULL) {
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
(void *)count;
|
||||
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t SetSampleAttributes(struct IAudioRenderVdi* render, const struct AudioSampleAttributes *attrs)
|
||||
{
|
||||
if (render == NULL || attrs == NULL) {
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
(void *)attrs;
|
||||
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t GetSampleAttributes(struct IAudioRenderVdi* render, struct AudioSampleAttributes *attrs)
|
||||
{
|
||||
if (render == NULL || attrs == NULL) {
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
(void *)attrs;
|
||||
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static int32_t GetCurrentChannelId(struct IAudioRenderVdi* render, uint32_t *channelId)
|
||||
{
|
||||
if (render == NULL || channelId == NULL) {
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
(void *)channelId;
|
||||
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t SetExtraParams(struct IAudioRenderVdi* render, const char *keyValueList)
|
||||
{
|
||||
if (render == NULL || keyValueList == NULL) {
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
(void *)keyValueList;
|
||||
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t GetExtraParams(struct IAudioRenderVdi* render, char *keyValueList, uint32_t keyValueListLen)
|
||||
{
|
||||
if (render == NULL || keyValueList == NULL) {
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
(void *)keyValueList;
|
||||
(void)keyValueListLen;
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t ReqMmapBuffer(struct IAudioRenderVdi* render, int32_t reqSize,
|
||||
struct AudioMmapBufferDescriptor *desc)
|
||||
{
|
||||
if (render == NULL || desc == NULL) {
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
(void *)desc;
|
||||
(void)reqSize;
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t GetMmapPosition(struct IAudioRenderVdi* render, uint64_t *frames, struct AudioTimeStamp *time)
|
||||
{
|
||||
if (render == NULL || frame == NULL) {
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
(void)effectid;
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t AddAudioEffect(struct IAudioRenderVdi* render, uint64_t effectid)
|
||||
{
|
||||
if (render == NULL) {
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
(void)effectid;
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t RemoveAudioEffect(struct IAudioRenderVdi* render, uint64_t effectid)
|
||||
{
|
||||
if (render == NULL) {
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
(void)effectid;
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t GetFrameBufferSize(struct IAudioRenderVdi* render, uint64_t *bufferSize)
|
||||
{
|
||||
if (render == NULL || bufferSize == NULL) {
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
(void *)bufferSize;
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t Start(struct IAudioRenderVdi* render)
|
||||
{
|
||||
if (render == NULL) {
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t Stop(struct IAudioRenderVdi* render)
|
||||
{
|
||||
if (render == NULL) {
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t Pause(struct IAudioRenderVdi* render)
|
||||
{
|
||||
if (render == NULL) {
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t Resume(struct IAudioRenderVdi* render)
|
||||
{
|
||||
if (render == NULL) {
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t Flush(struct IAudioRenderVdi* render)
|
||||
{
|
||||
if (render == NULL) {
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t TurnStandbyMode(struct IAudioRenderVdi* render)
|
||||
{
|
||||
if (render == NULL) {
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t AudioDevDump(struct IAudioRenderVdi* render, int32_t range, int32_t fd)
|
||||
{
|
||||
if (render == NULL) {
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
(void)range;
|
||||
(void)fd;
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t IsSupportsPauseAndResume(struct IAudioRenderVdi* render, bool *supportPause, bool *supportResume)
|
||||
{
|
||||
if (render == NULL || supportPause == NULL || supportResume == NULL) {
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
(void *)supportPause;
|
||||
(void *)supportResume;
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t SetbufferSize(struct IAudioRenderVdi* render, uint32_t size)
|
||||
{
|
||||
if (render == NULL) {
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
(void)size;
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
@@ -54,6 +54,11 @@ ohos_unittest("audio_ut_common_test") {
|
||||
if (drivers_peripheral_audio_feature_alsa_lib) {
|
||||
cflags_cc = [ "-DALSA_SUPPORT_FEATURE" ]
|
||||
}
|
||||
|
||||
defines = []
|
||||
if (drivers_peripheral_audio_feature_community) {
|
||||
defines += [ "AUDIO_FEATURE_COMMUNITY" ]
|
||||
}
|
||||
}
|
||||
|
||||
group("hdi_base_common") {
|
||||
|
||||
@@ -240,6 +240,52 @@ HWTEST_F(AudioUtCaptureTest, HdfAudioCaptureFrameExceptions001, TestSize.Level1)
|
||||
}
|
||||
}
|
||||
|
||||
/* capture frameEc cases */
|
||||
HWTEST_F(AudioUtCaptureTest, HdfAudioCaptureFrameEc001, TestSize.Level1)
|
||||
{
|
||||
uint32_t len = (uint64_t)GetCaptureBufferSize();
|
||||
struct AudioCaptureFrameInfo frameInfo = {};
|
||||
struct AudioFrameLen frameLen = {};
|
||||
frameLen.frameLen = len;
|
||||
frameLen.frameEcLen = len;
|
||||
ASSERT_NE(capture_->CaptureFrameEc, nullptr);
|
||||
|
||||
int32_t ret = capture_->Start(capture_);
|
||||
EXPECT_EQ(ret, HDF_SUCCESS);
|
||||
|
||||
ret = capture_->CaptureFrameEc(capture_, &frameLen, &frameInfo);
|
||||
#ifndef AUDIO_FEATURE_COMMUNITY
|
||||
EXPECT_EQ(ret, HDF_SUCCESS);
|
||||
#else
|
||||
EXPECT_EQ(ret, HDF_ERR_NOT_SUPPORT);
|
||||
#endif
|
||||
capture_->Stop(capture_);
|
||||
}
|
||||
|
||||
HWTEST_F(AudioUtCaptureTest, HdfAudioCaptureFrameEcExceptions001, TestSize.Level1)
|
||||
{
|
||||
uint32_t invalidLen = -1;
|
||||
struct AudioCaptureFrameInfo frameInfo = {};
|
||||
struct AudioFrameLen frameLen = {};
|
||||
frameLen.frameLen = invalidLen;
|
||||
frameLen.frameEcLen = invalidLen;
|
||||
ASSERT_NE(capture_->CaptureFrameEc, nullptr);
|
||||
|
||||
int32_t ret = capture_->Start(capture_);
|
||||
EXPECT_EQ(ret, HDF_SUCCESS);
|
||||
|
||||
EXPECT_NE(HDF_SUCCESS, capture_->CaptureFrameEc(nullptr, nullptr, nullptr));
|
||||
EXPECT_NE(HDF_SUCCESS, capture_->CaptureFrameEc(capture_, &frameLen, nullptr));
|
||||
EXPECT_NE(HDF_SUCCESS, capture_->CaptureFrameEc(capture_, &frameLen, &frameInfo));
|
||||
EXPECT_NE(HDF_SUCCESS, capture_->CaptureFrameEc(nullptr, nullptr, &frameInfo));
|
||||
EXPECT_NE(HDF_SUCCESS, capture_->CaptureFrameEc(capture_, &frameLen, nullptr));
|
||||
EXPECT_NE(HDF_SUCCESS, capture_->CaptureFrameEc(capture_, nullptr, nullptr));
|
||||
EXPECT_NE(HDF_SUCCESS, capture_->CaptureFrameEc(capture_, &frameLen, &frameInfo));
|
||||
EXPECT_NE(HDF_SUCCESS, capture_->CaptureFrameEc(capture_, nullptr, &frameInfo));
|
||||
|
||||
capture_->Stop(capture_);
|
||||
}
|
||||
|
||||
/* capture getposition cases */
|
||||
HWTEST_F(AudioUtCaptureTest, HdfAudioGetCapturePosition001, TestSize.Level1)
|
||||
{
|
||||
|
||||
+4
-20
@@ -11,24 +11,8 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
if (!defined(global_parts_info) ||
|
||||
defined(global_parts_info.customization_config_policy)) {
|
||||
has_battery_config_policy_part = true
|
||||
cflags_cc = [ "-DHAS_BATTERY_CONFIG_POLICY_PART" ]
|
||||
} else {
|
||||
has_battery_config_policy_part = false
|
||||
}
|
||||
|
||||
if (!defined(global_parts_info) ||
|
||||
defined(global_parts_info.commonlibrary_c_utils)) {
|
||||
has_battery_c_utils_part = true
|
||||
} else {
|
||||
has_battery_c_utils_part = false
|
||||
}
|
||||
|
||||
if (!defined(global_parts_info) ||
|
||||
defined(global_parts_info.hiviewdfx_hicollie)) {
|
||||
has_battery_xcollie_part = true
|
||||
} else {
|
||||
has_battery_xcollie_part = false
|
||||
declare_args() {
|
||||
drivers_peripheral_battery_feature_config_policy = true
|
||||
drivers_peripheral_battery_feature_c_utils = true
|
||||
drivers_peripheral_battery_feature_hicollie = false
|
||||
}
|
||||
|
||||
@@ -15,6 +15,11 @@
|
||||
"adapted_system_type": ["standard", "small"],
|
||||
"rom": "600KB",
|
||||
"ram": "7400KB",
|
||||
"features": [
|
||||
"drivers_peripheral_battery_feature_config_policy",
|
||||
"drivers_peripheral_battery_feature_c_utils",
|
||||
"drivers_peripheral_battery_feature_hicollie"
|
||||
],
|
||||
"deps": {
|
||||
"components": [
|
||||
"c_utils",
|
||||
|
||||
@@ -36,16 +36,15 @@ ohos_shared_library("libbattery_interface_service_2.0") {
|
||||
"ipc:ipc_single",
|
||||
"jsoncpp:jsoncpp",
|
||||
]
|
||||
if (has_battery_config_policy_part) {
|
||||
if (drivers_peripheral_battery_feature_config_policy) {
|
||||
external_deps += [ "config_policy:configpolicy_util" ]
|
||||
}
|
||||
if (has_battery_c_utils_part) {
|
||||
if (drivers_peripheral_battery_feature_c_utils) {
|
||||
external_deps += [ "c_utils:utils" ]
|
||||
}
|
||||
|
||||
# xcollie has a bug, disable it
|
||||
has_battery_xcollie_part = false
|
||||
if (has_battery_xcollie_part) {
|
||||
if (drivers_peripheral_battery_feature_hicollie) {
|
||||
external_deps += [ "hicollie:libhicollie" ]
|
||||
defines += [ "HICOLLIE_ENABLE" ]
|
||||
}
|
||||
@@ -84,7 +83,7 @@ ohos_shared_library("libbattery_driver") {
|
||||
"ipc:ipc_single",
|
||||
"jsoncpp:jsoncpp",
|
||||
]
|
||||
if (has_battery_c_utils_part) {
|
||||
if (drivers_peripheral_battery_feature_c_utils) {
|
||||
external_deps += [ "c_utils:utils" ]
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -32,7 +32,7 @@ ohos_fuzztest("BatteryHdiFuzzTest") {
|
||||
"hilog:libhilog",
|
||||
"ipc:ipc_single",
|
||||
]
|
||||
if (has_battery_c_utils_part) {
|
||||
if (drivers_peripheral_battery_feature_c_utils) {
|
||||
external_deps += [ "c_utils:utils" ]
|
||||
}
|
||||
|
||||
|
||||
+115
-19
@@ -18,6 +18,7 @@
|
||||
#include "securec.h"
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
#include <datetime_ex.h>
|
||||
#include <map>
|
||||
#include <random>
|
||||
#include <vector>
|
||||
@@ -46,15 +47,29 @@ public:
|
||||
sptr<IBatteryInterface> g_batteryInterface = IBatteryInterface::Get();
|
||||
} // namespace
|
||||
|
||||
void Register([[maybe_unused]] const uint8_t *data, [[maybe_unused]] size_t size)
|
||||
void Register(const uint8_t *data, size_t size)
|
||||
{
|
||||
uint8_t code;
|
||||
if (size < sizeof(code)) {
|
||||
return;
|
||||
}
|
||||
if (memcpy_s(&code, sizeof(code), data, sizeof(code)) != EOK) {
|
||||
return;
|
||||
}
|
||||
sptr<IBatteryCallback> callback = new BatteryCallback();
|
||||
g_batteryInterface->Register(callback);
|
||||
g_batteryInterface->Register(nullptr);
|
||||
}
|
||||
|
||||
void UnRegister([[maybe_unused]] const uint8_t *data, [[maybe_unused]] size_t size)
|
||||
void UnRegister(const uint8_t *data, size_t size)
|
||||
{
|
||||
uint8_t code;
|
||||
if (size < sizeof(code)) {
|
||||
return;
|
||||
}
|
||||
if (memcpy_s(&code, sizeof(code), data, sizeof(code)) != EOK) {
|
||||
return;
|
||||
}
|
||||
g_batteryInterface->UnRegister();
|
||||
}
|
||||
|
||||
@@ -64,80 +79,164 @@ void ChangePath(const uint8_t *data, size_t size)
|
||||
g_batteryInterface->ChangePath(result);
|
||||
}
|
||||
|
||||
void GetCapacity([[maybe_unused]] const uint8_t *data, [[maybe_unused]] size_t size)
|
||||
void GetCapacity(const uint8_t *data, size_t size)
|
||||
{
|
||||
int32_t out;
|
||||
if (size < sizeof(out)) {
|
||||
return;
|
||||
}
|
||||
if (memcpy_s(&out, sizeof(out), data, sizeof(out)) != EOK) {
|
||||
return;
|
||||
}
|
||||
g_batteryInterface->GetCapacity(out);
|
||||
}
|
||||
|
||||
void GetVoltage([[maybe_unused]] const uint8_t *data, [[maybe_unused]] size_t size)
|
||||
void GetVoltage(const uint8_t *data, size_t size)
|
||||
{
|
||||
int32_t out;
|
||||
if (size < sizeof(out)) {
|
||||
return;
|
||||
}
|
||||
if (memcpy_s(&out, sizeof(out), data, sizeof(out)) != EOK) {
|
||||
return;
|
||||
}
|
||||
g_batteryInterface->GetVoltage(out);
|
||||
}
|
||||
|
||||
void GetTemperature([[maybe_unused]] const uint8_t *data, [[maybe_unused]] size_t size)
|
||||
void GetTemperature(const uint8_t *data, size_t size)
|
||||
{
|
||||
int32_t out;
|
||||
if (size < sizeof(out)) {
|
||||
return;
|
||||
}
|
||||
if (memcpy_s(&out, sizeof(out), data, sizeof(out)) != EOK) {
|
||||
return;
|
||||
}
|
||||
g_batteryInterface->GetTemperature(out);
|
||||
}
|
||||
|
||||
void GetHealthState([[maybe_unused]] const uint8_t *data, [[maybe_unused]] size_t size)
|
||||
void GetHealthState(const uint8_t *data, size_t size)
|
||||
{
|
||||
uint8_t code;
|
||||
if (size < sizeof(code)) {
|
||||
return;
|
||||
}
|
||||
if (memcpy_s(&code, sizeof(code), data, sizeof(code)) != EOK) {
|
||||
return;
|
||||
}
|
||||
BatteryHealthState state;
|
||||
g_batteryInterface->GetHealthState(state);
|
||||
}
|
||||
|
||||
void GetPluggedType([[maybe_unused]] const uint8_t *data, [[maybe_unused]] size_t size)
|
||||
void GetPluggedType(const uint8_t *data, size_t size)
|
||||
{
|
||||
uint8_t code;
|
||||
if (size < sizeof(code)) {
|
||||
return;
|
||||
}
|
||||
if (memcpy_s(&code, sizeof(code), data, sizeof(code)) != EOK) {
|
||||
return;
|
||||
}
|
||||
BatteryPluggedType type;
|
||||
g_batteryInterface->GetPluggedType(type);
|
||||
}
|
||||
|
||||
void GetChargeState([[maybe_unused]] const uint8_t *data, [[maybe_unused]] size_t size)
|
||||
void GetChargeState(const uint8_t *data, size_t size)
|
||||
{
|
||||
uint8_t code;
|
||||
if (size < sizeof(code)) {
|
||||
return;
|
||||
}
|
||||
if (memcpy_s(&code, sizeof(code), data, sizeof(code)) != EOK) {
|
||||
return;
|
||||
}
|
||||
BatteryChargeState state;
|
||||
g_batteryInterface->GetChargeState(state);
|
||||
}
|
||||
|
||||
void GetPresent([[maybe_unused]] const uint8_t *data, [[maybe_unused]] size_t size)
|
||||
void GetPresent(const uint8_t *data, size_t size)
|
||||
{
|
||||
uint8_t code;
|
||||
if (size < sizeof(code)) {
|
||||
return;
|
||||
}
|
||||
if (memcpy_s(&code, sizeof(code), data, sizeof(code)) != EOK) {
|
||||
return;
|
||||
}
|
||||
bool present;
|
||||
g_batteryInterface->GetPresent(present);
|
||||
}
|
||||
|
||||
void GetTechnology([[maybe_unused]] const uint8_t *data, [[maybe_unused]] size_t size)
|
||||
void GetTechnology(const uint8_t *data, size_t size)
|
||||
{
|
||||
uint8_t code;
|
||||
if (size < sizeof(code)) {
|
||||
return;
|
||||
}
|
||||
if (memcpy_s(&code, sizeof(code), data, sizeof(code)) != EOK) {
|
||||
return;
|
||||
}
|
||||
std::string str;
|
||||
g_batteryInterface->GetTechnology(str);
|
||||
}
|
||||
|
||||
void GetTotalEnergy([[maybe_unused]] const uint8_t *data, [[maybe_unused]] size_t size)
|
||||
void GetTotalEnergy(const uint8_t *data, size_t size)
|
||||
{
|
||||
int32_t out;
|
||||
if (size < sizeof(out)) {
|
||||
return;
|
||||
}
|
||||
if (memcpy_s(&out, sizeof(out), data, sizeof(out)) != EOK) {
|
||||
return;
|
||||
}
|
||||
g_batteryInterface->GetTotalEnergy(out);
|
||||
}
|
||||
|
||||
void GetCurrentAverage([[maybe_unused]] const uint8_t *data, [[maybe_unused]] size_t size)
|
||||
void GetCurrentAverage(const uint8_t *data, size_t size)
|
||||
{
|
||||
int32_t out;
|
||||
if (size < sizeof(out)) {
|
||||
return;
|
||||
}
|
||||
if (memcpy_s(&out, sizeof(out), data, sizeof(out)) != EOK) {
|
||||
return;
|
||||
}
|
||||
g_batteryInterface->GetCurrentAverage(out);
|
||||
}
|
||||
|
||||
void GetCurrentNow([[maybe_unused]] const uint8_t *data, [[maybe_unused]] size_t size)
|
||||
void GetCurrentNow(const uint8_t *data, size_t size)
|
||||
{
|
||||
int32_t out;
|
||||
if (size < sizeof(out)) {
|
||||
return;
|
||||
}
|
||||
if (memcpy_s(&out, sizeof(out), data, sizeof(out)) != EOK) {
|
||||
return;
|
||||
}
|
||||
g_batteryInterface->GetCurrentNow(out);
|
||||
}
|
||||
|
||||
void GetRemainEnergy([[maybe_unused]] const uint8_t *data, [[maybe_unused]] size_t size)
|
||||
void GetRemainEnergy(const uint8_t *data, size_t size)
|
||||
{
|
||||
int32_t out;
|
||||
if (size < sizeof(out)) {
|
||||
return;
|
||||
}
|
||||
if (memcpy_s(&out, sizeof(out), data, sizeof(out)) != EOK) {
|
||||
return;
|
||||
}
|
||||
g_batteryInterface->GetRemainEnergy(out);
|
||||
}
|
||||
|
||||
void GetBatteryInfo([[maybe_unused]] const uint8_t *data, [[maybe_unused]] size_t size)
|
||||
void GetBatteryInfo(const uint8_t *data, size_t size)
|
||||
{
|
||||
uint8_t code;
|
||||
if (size < sizeof(code)) {
|
||||
return;
|
||||
}
|
||||
if (memcpy_s(&code, sizeof(code), data, sizeof(code)) != EOK) {
|
||||
return;
|
||||
}
|
||||
BatteryInfo info;
|
||||
g_batteryInterface->GetBatteryInfo(info);
|
||||
}
|
||||
@@ -187,10 +286,7 @@ static std::vector<std::function<void(const uint8_t *, size_t)>> fuzzFunc = {
|
||||
|
||||
void BatteryHdiFuzzTest(const uint8_t *data, size_t size)
|
||||
{
|
||||
std::random_device rd;
|
||||
std::default_random_engine engine(rd());
|
||||
std::uniform_int_distribution<int32_t> randomNum(0, fuzzFunc.size() - 1);
|
||||
int32_t number = randomNum(engine);
|
||||
int32_t number = GetTickCount() % fuzzFunc.size();
|
||||
fuzzFunc[number](data, size);
|
||||
}
|
||||
} // namespace V2_0
|
||||
|
||||
@@ -41,7 +41,7 @@ ohos_fuzztest("BatteryHdiStubFuzzTest") {
|
||||
"hilog:libhilog",
|
||||
"ipc:ipc_single",
|
||||
]
|
||||
if (has_battery_c_utils_part) {
|
||||
if (drivers_peripheral_battery_feature_c_utils) {
|
||||
external_deps += [ "c_utils:utils" ]
|
||||
}
|
||||
|
||||
|
||||
@@ -46,13 +46,15 @@ ohos_systemtest("test_battery_sys_test") {
|
||||
deps = []
|
||||
|
||||
external_deps = [
|
||||
"config_policy:configpolicy_util",
|
||||
"googletest:gtest_main",
|
||||
"hdf_core:libpub_utils",
|
||||
"hilog:libhilog",
|
||||
"jsoncpp:jsoncpp",
|
||||
]
|
||||
if (has_battery_c_utils_part) {
|
||||
if (drivers_peripheral_battery_feature_config_policy) {
|
||||
external_deps += [ "config_policy:configpolicy_util" ]
|
||||
}
|
||||
if (drivers_peripheral_battery_feature_c_utils) {
|
||||
external_deps += [ "c_utils:utils" ]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +45,6 @@ ohos_unittest("test_hdisrv") {
|
||||
|
||||
external_deps = [
|
||||
"cJSON:cjson",
|
||||
"config_policy:configpolicy_util",
|
||||
"drivers_interface_battery:libbattery_stub_2.0",
|
||||
"googletest:gmock_main",
|
||||
"googletest:gtest_main",
|
||||
@@ -56,7 +55,10 @@ ohos_unittest("test_hdisrv") {
|
||||
"ipc:ipc_single",
|
||||
"jsoncpp:jsoncpp",
|
||||
]
|
||||
if (has_battery_c_utils_part) {
|
||||
if (drivers_peripheral_battery_feature_config_policy) {
|
||||
external_deps += [ "config_policy:configpolicy_util" ]
|
||||
}
|
||||
if (drivers_peripheral_battery_feature_c_utils) {
|
||||
external_deps += [ "c_utils:utils" ]
|
||||
}
|
||||
}
|
||||
@@ -74,7 +76,7 @@ ohos_unittest("hdi_unittest_battery") {
|
||||
"hilog:libhilog",
|
||||
"ipc:ipc_single",
|
||||
]
|
||||
if (has_battery_c_utils_part) {
|
||||
if (drivers_peripheral_battery_feature_c_utils) {
|
||||
external_deps += [ "c_utils:utils" ]
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -70,6 +70,7 @@ ohos_shared_library("audio_bluetooth_hdi_proxy_server") {
|
||||
"src/audio_proxy_common.cpp",
|
||||
"src/audio_proxy_manager.cpp",
|
||||
"src/audio_proxy_render.cpp",
|
||||
"src/audio_proxy_capture.cpp",
|
||||
]
|
||||
|
||||
deps = []
|
||||
@@ -88,6 +89,7 @@ ohos_shared_library("audio_bluetooth_hdi_proxy_server") {
|
||||
external_deps += [ "c_utils:utils" ]
|
||||
|
||||
public_configs = [ ":hdi_service_proxy_config" ]
|
||||
|
||||
innerapi_tags = [ "passthrough" ]
|
||||
install_images = [ chipset_base_dir ]
|
||||
subsystem_name = "hdf"
|
||||
|
||||
@@ -42,5 +42,6 @@ int32_t AudioProxyCommonGetRenderCtrlParam(int cmId, AudioHandle handle, float *
|
||||
int32_t AudioProxyGetMmapPositionRead(struct HdfSBuf *reply, uint64_t *frames, struct AudioTimeStamp *time);
|
||||
int32_t AudioProxyReqMmapBufferWrite(struct HdfSBuf *data, int32_t reqSize,
|
||||
const struct AudioMmapBufferDescriptor *desc);
|
||||
int32_t AudioProxyPreprocessCapture(struct AudioHwCapture *capture, struct HdfSBuf **data, struct HdfSBuf **reply);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -71,5 +71,17 @@ int32_t AudioProxyRenderTurnStandbyMode(AudioHandle render);
|
||||
int32_t AudioProxyRenderAudioDevDump(AudioHandle render, int32_t range, int32_t fd);
|
||||
int32_t AudioProxyRenderRegCallback(struct AudioRender *render, RenderCallback callback, void *cookie);
|
||||
int32_t AudioProxyRenderDrainBuffer(struct AudioRender *render, AudioDrainNotifyType *type);
|
||||
int32_t AudioProxyAdapterCreateCapture(struct AudioAdapter *adapter, const struct AudioDeviceDescriptor *desc,
|
||||
const struct AudioSampleAttributes *attrs, struct AudioCapture **capture);
|
||||
int32_t AudioProxyAdapterDestroyCapture(struct AudioAdapter *adapter, struct AudioCapture *capture);
|
||||
int32_t AudioProxyCaptureCaptureFrame(struct AudioCapture *capture, void *frame,
|
||||
uint64_t requestBytes, uint64_t *replyBytes);
|
||||
int32_t AudioProxyCaptureStart(AudioHandle handle);
|
||||
int32_t AudioProxyCaptureStop(AudioHandle handle);
|
||||
int32_t AudioProxyCapturePause(AudioHandle handle);
|
||||
int32_t AudioProxyCaptureResume(AudioHandle handle);
|
||||
int32_t AudioProxyCaptureFlush(AudioHandle handle);
|
||||
int32_t AudioProxyCaptureSetMute(const AudioHandle handle, bool mute);
|
||||
int32_t AudioProxyCaptureGetMute(const AudioHandle handle, bool *mute);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -145,6 +145,22 @@ int32_t GetAudioProxyRenderFunc(struct AudioHwRender *hwRender)
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t GetAudioProxyCaptureFunc(struct AudioHwCapture *hwCapture)
|
||||
{
|
||||
if (hwCapture == nullptr) {
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
hwCapture->common.control.Start = AudioProxyCaptureStart;
|
||||
hwCapture->common.control.Stop = AudioProxyCaptureStop;
|
||||
hwCapture->common.control.Pause = AudioProxyCapturePause;
|
||||
hwCapture->common.control.Resume = AudioProxyCaptureResume;
|
||||
hwCapture->common.control.Flush = AudioProxyCaptureFlush;
|
||||
hwCapture->common.volume.SetMute = AudioProxyCaptureSetMute;
|
||||
hwCapture->common.volume.GetMute = AudioProxyCaptureGetMute;
|
||||
hwCapture->common.CaptureFrame = AudioProxyCaptureCaptureFrame;
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t InitHwRenderParam(struct AudioHwRender *hwRender, const struct AudioDeviceDescriptor *desc,
|
||||
const struct AudioSampleAttributes *attrs)
|
||||
{
|
||||
@@ -157,6 +173,18 @@ int32_t InitHwRenderParam(struct AudioHwRender *hwRender, const struct AudioDevi
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t InitHwCaptureParam(struct AudioHwCapture *hwCapture, const struct AudioDeviceDescriptor *desc,
|
||||
const struct AudioSampleAttributes *attrs)
|
||||
{
|
||||
if (hwCapture == nullptr || desc == nullptr || attrs == nullptr) {
|
||||
HDF_LOGE("InitHwCaptureParam param Is NULL");
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
hwCapture->captureParam.captureMode.hwInfo.deviceDescript = *desc;
|
||||
hwCapture->captureParam.frameCaptureMode.attrs = *attrs;
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
AudioFormat g_formatIdZero = AUDIO_FORMAT_TYPE_PCM_16_BIT;
|
||||
int32_t InitForGetPortCapability(struct AudioPort portIndex, struct AudioPortCapability *capabilityIndex)
|
||||
{
|
||||
@@ -301,6 +329,24 @@ int32_t AudioProxyAdapterCreateRenderSplit(const struct AudioHwAdapter *hwAdapte
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t AudioProxyAdapterCreateCaptureSplit(const struct AudioHwAdapter *hwAdapter, struct AudioHwCapture *hwCapture)
|
||||
{
|
||||
if (hwAdapter == nullptr || hwCapture == nullptr) {
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
if (hwAdapter->adapterDescriptor.adapterName == nullptr) {
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
uint32_t adapterNameLen = strlen(hwAdapter->adapterDescriptor.adapterName);
|
||||
/* Get Adapter name */
|
||||
int32_t ret = strncpy_s(hwCapture->captureParam.captureMode.hwInfo.adapterName, NAME_LEN - 1,
|
||||
hwAdapter->adapterDescriptor.adapterName, adapterNameLen);
|
||||
if (ret != EOK) {
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t AudioProxyAdapterCreateRender(struct AudioAdapter *adapter, const struct AudioDeviceDescriptor *desc,
|
||||
const struct AudioSampleAttributes *attrs, struct AudioRender **render)
|
||||
{
|
||||
@@ -357,6 +403,70 @@ int32_t AudioProxyAdapterCreateRender(struct AudioAdapter *adapter, const struct
|
||||
return AUDIO_HAL_SUCCESS;
|
||||
}
|
||||
|
||||
bool InitializeHwCapture(struct AudioHwCapture *hwCapture, struct AudioHwAdapter *hwAdapter,
|
||||
const struct AudioDeviceDescriptor *desc, const struct AudioSampleAttributes *attrs)
|
||||
{
|
||||
hwCapture->proxyRemoteHandle = hwAdapter->proxyRemoteHandle;
|
||||
if (GetAudioProxyCaptureFunc(hwCapture) < 0) {
|
||||
return false;
|
||||
}
|
||||
if (InitHwCaptureParam(hwCapture, desc, attrs) < 0) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
int32_t AudioProxyAdapterCreateCapture(struct AudioAdapter *adapter, const struct AudioDeviceDescriptor *desc,
|
||||
const struct AudioSampleAttributes *attrs, struct AudioCapture **capture)
|
||||
{
|
||||
HDF_LOGI("%{public}s", __func__);
|
||||
struct HdfSBuf *data = nullptr;
|
||||
struct HdfSBuf *reply = nullptr;
|
||||
struct AudioHwAdapter *hwAdapter = reinterpret_cast<struct AudioHwAdapter *>(adapter);
|
||||
if (hwAdapter == nullptr || hwAdapter->proxyRemoteHandle == nullptr || desc == nullptr ||
|
||||
attrs == nullptr || capture == nullptr) {
|
||||
return AUDIO_HAL_ERR_INVALID_PARAM;
|
||||
}
|
||||
struct AudioHwCapture *hwCapture = reinterpret_cast<struct AudioHwCapture *>(calloc(1, sizeof(*hwCapture)));
|
||||
if (hwCapture == nullptr) {
|
||||
HDF_LOGE("hwCapture is NULL!");
|
||||
return AUDIO_HAL_ERR_MALLOC_FAIL;
|
||||
}
|
||||
if (!InitializeHwCapture(hwCapture, hwAdapter, desc, attrs)) {
|
||||
AudioMemFree(reinterpret_cast<void **>(&hwCapture));
|
||||
return AUDIO_HAL_ERR_INTERNAL;
|
||||
}
|
||||
if (AudioProxyPreprocessSBuf(&data, &reply) < 0) {
|
||||
AudioMemFree(reinterpret_cast<void **>(&hwCapture));
|
||||
return AUDIO_HAL_ERR_INTERNAL;
|
||||
}
|
||||
if (!HdfRemoteServiceWriteInterfaceToken(hwAdapter->proxyRemoteHandle, data)) {
|
||||
AudioProxyBufReplyRecycle(data, reply);
|
||||
AudioMemFree(reinterpret_cast<void **>(&hwCapture));
|
||||
return AUDIO_HAL_ERR_INTERNAL;
|
||||
}
|
||||
if (AudioProxyCommonInitCreateData(data, hwAdapter, desc, attrs) < 0) {
|
||||
HDF_LOGE("Failed to obtain reply");
|
||||
AudioProxyBufReplyRecycle(data, reply);
|
||||
AudioMemFree(reinterpret_cast<void **>(&hwCapture));
|
||||
return AUDIO_HAL_ERR_INTERNAL;
|
||||
}
|
||||
int32_t ret = AudioProxyDispatchCall(hwCapture->proxyRemoteHandle, AUDIO_HDI_CAPTURE_CREATE_CAPTURE, data, reply);
|
||||
if (ret < 0) {
|
||||
HDF_LOGE("Send Server fail!");
|
||||
AudioProxyBufReplyRecycle(data, reply);
|
||||
AudioMemFree(reinterpret_cast<void **>(&hwCapture));
|
||||
return ret;
|
||||
}
|
||||
AudioProxyBufReplyRecycle(data, reply);
|
||||
if (AudioProxyAdapterCreateCaptureSplit(hwAdapter, hwCapture) < 0) {
|
||||
AudioMemFree(reinterpret_cast<void **>(&hwCapture));
|
||||
return AUDIO_HAL_ERR_INTERNAL;
|
||||
}
|
||||
*capture = &hwCapture->common;
|
||||
return AUDIO_HAL_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t AudioProxyAdapterDestroyRender(struct AudioAdapter *adapter, struct AudioRender *render)
|
||||
{
|
||||
struct HdfSBuf *data = NULL;
|
||||
@@ -385,6 +495,33 @@ int32_t AudioProxyAdapterDestroyRender(struct AudioAdapter *adapter, struct Audi
|
||||
return AUDIO_HAL_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t AudioProxyAdapterDestroyCapture(struct AudioAdapter *adapter, struct AudioCapture *capture)
|
||||
{
|
||||
struct HdfSBuf *data = nullptr;
|
||||
struct HdfSBuf *reply = nullptr;
|
||||
if (adapter == nullptr || capture == nullptr) {
|
||||
return AUDIO_HAL_ERR_INVALID_PARAM;
|
||||
}
|
||||
struct AudioHwCapture *hwCapture = reinterpret_cast<struct AudioHwCapture *>(capture);
|
||||
if (hwCapture == nullptr || hwCapture->proxyRemoteHandle == nullptr) {
|
||||
return AUDIO_HAL_ERR_INVALID_PARAM;
|
||||
}
|
||||
if (AudioProxyPreprocessCapture(reinterpret_cast<AudioHwCapture *>(capture), &data, &reply) < 0) {
|
||||
return AUDIO_HAL_ERR_INTERNAL;
|
||||
}
|
||||
int32_t ret = AudioProxyDispatchCall(hwCapture->proxyRemoteHandle, AUDIO_HDI_CAPTURE_DESTROY, data, reply);
|
||||
if (ret < 0) {
|
||||
if (ret != HDF_ERR_INVALID_OBJECT) {
|
||||
HDF_LOGE("AudioDestroyCapture FAIL");
|
||||
}
|
||||
AudioProxyBufReplyRecycle(data, reply);
|
||||
return ret;
|
||||
}
|
||||
AudioMemFree(reinterpret_cast<void **>(&capture));
|
||||
AudioProxyBufReplyRecycle(data, reply);
|
||||
return AUDIO_HAL_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t AudioProxyAdapterWritePortCapability(const struct AudioHwAdapter *hwAdapter,
|
||||
const struct AudioPort *port, struct HdfSBuf *data)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,177 @@
|
||||
/*
|
||||
* Copyright (c) 2024 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 <cinttypes>
|
||||
#include <hdf_log.h>
|
||||
#include "audio_proxy_common.h"
|
||||
|
||||
namespace OHOS::HDI::Audio_Bluetooth {
|
||||
int32_t AudioProxyCaptureCtrl(int cmId, AudioHandle handle)
|
||||
{
|
||||
struct HdfSBuf *data = nullptr;
|
||||
struct HdfSBuf *reply = nullptr;
|
||||
struct AudioHwCapture *hwCapture = reinterpret_cast<struct AudioHwCapture *>(handle);
|
||||
if (hwCapture == nullptr || hwCapture->proxyRemoteHandle == nullptr) {
|
||||
HDF_LOGE("The hwCapture parameter is null");
|
||||
return AUDIO_HAL_ERR_INVALID_PARAM;
|
||||
}
|
||||
if (AudioProxyPreprocessCapture(hwCapture, &data, &reply) < 0) {
|
||||
return AUDIO_HAL_ERR_INTERNAL;
|
||||
}
|
||||
int32_t ret = AudioProxyDispatchCall(hwCapture->proxyRemoteHandle, cmId, data, reply);
|
||||
AudioProxyBufReplyRecycle(data, reply);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t AudioProxyCaptureStart(AudioHandle handle)
|
||||
{
|
||||
HDF_LOGI("%{public}s", __func__);
|
||||
return AudioProxyCaptureCtrl(AUDIO_HDI_CAPTURE_START, handle);
|
||||
}
|
||||
|
||||
int32_t AudioProxyCaptureStop(AudioHandle handle)
|
||||
{
|
||||
HDF_LOGI("%{public}s", __func__);
|
||||
return AudioProxyCaptureCtrl(AUDIO_HDI_CAPTURE_STOP, handle);
|
||||
}
|
||||
|
||||
int32_t AudioProxyCapturePause(AudioHandle handle)
|
||||
{
|
||||
HDF_LOGI("%{public}s", __func__);
|
||||
return AudioProxyCaptureCtrl(AUDIO_HDI_CAPTURE_PAUSE, handle);
|
||||
}
|
||||
|
||||
int32_t AudioProxyCaptureResume(AudioHandle handle)
|
||||
{
|
||||
HDF_LOGI("%{public}s", __func__);
|
||||
return AudioProxyCaptureCtrl(AUDIO_HDI_CAPTURE_RESUME, handle);
|
||||
}
|
||||
|
||||
int32_t AudioProxyCaptureFlush(AudioHandle handle)
|
||||
{
|
||||
struct AudioHwCapture *hwCapture = reinterpret_cast<struct AudioHwCapture *>(handle);
|
||||
if (hwCapture == nullptr) {
|
||||
return AUDIO_HAL_ERR_INVALID_PARAM;
|
||||
}
|
||||
return AUDIO_HAL_ERR_NOT_SUPPORT;
|
||||
}
|
||||
|
||||
int32_t AudioProxyCaptureSetMute(const AudioHandle handle, bool mute)
|
||||
{
|
||||
(void)mute;
|
||||
struct HdfSBuf *data = nullptr;
|
||||
struct HdfSBuf *reply = nullptr;
|
||||
struct AudioHwCapture *hwCapture = reinterpret_cast<struct AudioHwCapture *>(handle);
|
||||
if (hwCapture == NULL || hwCapture->proxyRemoteHandle == NULL) {
|
||||
HDF_LOGE("The pointer is null");
|
||||
return AUDIO_HAL_ERR_INVALID_PARAM;
|
||||
}
|
||||
if (AudioProxyPreprocessCapture(hwCapture, &data, &reply) < 0) {
|
||||
return AUDIO_HAL_ERR_INTERNAL;
|
||||
}
|
||||
uint32_t tempMute = (uint32_t)mute;
|
||||
if (!HdfSbufWriteUint32(data, tempMute)) {
|
||||
AudioProxyBufReplyRecycle(data, reply);
|
||||
return AUDIO_HAL_ERR_INTERNAL;
|
||||
}
|
||||
int32_t ret = AudioProxyDispatchCall(hwCapture->proxyRemoteHandle, AUDIO_HDI_CAPTURE_SET_MUTE, data, reply);
|
||||
AudioProxyBufReplyRecycle(data, reply);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t AudioProxyCaptureGetMute(const AudioHandle handle, bool *mute)
|
||||
{
|
||||
if (mute == nullptr) {
|
||||
return AUDIO_HAL_ERR_INVALID_PARAM;
|
||||
}
|
||||
struct HdfSBuf *data = nullptr;
|
||||
struct HdfSBuf *reply = nullptr;
|
||||
struct AudioHwCapture *hwCapture = reinterpret_cast<struct AudioHwCapture *>(handle);
|
||||
if (hwCapture == nullptr || hwCapture->proxyRemoteHandle == nullptr) {
|
||||
HDF_LOGE("The parameter is null");
|
||||
return AUDIO_HAL_ERR_INVALID_PARAM;
|
||||
}
|
||||
if (AudioProxyPreprocessCapture(hwCapture, &data, &reply) < 0) {
|
||||
return AUDIO_HAL_ERR_INTERNAL;
|
||||
}
|
||||
int32_t ret = AudioProxyDispatchCall(hwCapture->proxyRemoteHandle, AUDIO_HDI_CAPTURE_GET_MUTE, data, reply);
|
||||
uint32_t tempMute = 0;
|
||||
if (!HdfSbufReadUint32(reply, &tempMute)) {
|
||||
AudioProxyBufReplyRecycle(data, reply);
|
||||
return AUDIO_HAL_ERR_INTERNAL;
|
||||
}
|
||||
*mute = (bool)tempMute;
|
||||
AudioProxyBufReplyRecycle(data, reply);
|
||||
LOG_PARA_INFO("GetMute SUCCESS!");
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool ReadReplyBuffer(struct HdfSBuf *reply, uint64_t replyBytes, void *frame, uint64_t requestBytes)
|
||||
{
|
||||
const void *rBuf = nullptr;
|
||||
uint32_t rLen;
|
||||
if (HdfSbufReadBuffer(reply, &rBuf, &rLen) && rLen == replyBytes) {
|
||||
if (memcpy_s(frame, requestBytes, rBuf, rLen) != EOK) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int32_t AudioProxyCaptureCaptureFrame(struct AudioCapture *capture, void *frame,
|
||||
uint64_t requestBytes, uint64_t *replyBytes)
|
||||
{
|
||||
HDF_LOGD("%{public}s", __func__);
|
||||
if (frame == nullptr || replyBytes == nullptr) {
|
||||
HDF_LOGE("Capture Frame Paras is NULL!");
|
||||
return AUDIO_HAL_ERR_INVALID_PARAM;
|
||||
}
|
||||
struct HdfSBuf *data = nullptr;
|
||||
struct HdfSBuf *reply = nullptr;
|
||||
struct AudioHwCapture *hwCapture = reinterpret_cast<struct AudioHwCapture *>(capture);
|
||||
if (hwCapture == nullptr || hwCapture->proxyRemoteHandle == nullptr) {
|
||||
HDF_LOGE("The hwCapture parameter is null");
|
||||
return AUDIO_HAL_ERR_INVALID_PARAM;
|
||||
}
|
||||
if (AudioProxyPreprocessCapture(hwCapture, &data, &reply) < 0) {
|
||||
HDF_LOGE("AudioProxyPreprocessCapture FAIL");
|
||||
return AUDIO_HAL_ERR_INTERNAL;
|
||||
}
|
||||
if (!HdfSbufWriteUint64(data, requestBytes)) {
|
||||
AudioProxyBufReplyRecycle(data, reply);
|
||||
HDF_LOGE("HdfSbufWriteUint64 FAIL");
|
||||
return AUDIO_HAL_ERR_INTERNAL;
|
||||
}
|
||||
int32_t ret = AudioProxyDispatchCall(hwCapture->proxyRemoteHandle, AUDIO_HDI_CAPTURE_CAPTURE_FRAME, data, reply);
|
||||
if (ret < 0) {
|
||||
if (ret != AUDIO_HAL_ERR_INVALID_OBJECT) {
|
||||
HDF_LOGE("AudioCaptureCaptureFrame FAIL");
|
||||
}
|
||||
AudioProxyBufReplyRecycle(data, reply);
|
||||
return ret;
|
||||
}
|
||||
if (!HdfSbufReadUint64(reply, replyBytes)) {
|
||||
AudioProxyBufReplyRecycle(data, reply);
|
||||
HDF_LOGE("HdfSbufReadUint64 FAIL");
|
||||
return AUDIO_HAL_ERR_INTERNAL;
|
||||
}
|
||||
if (!ReadReplyBuffer(reply, *replyBytes, frame, requestBytes)) {
|
||||
AudioProxyBufReplyRecycle(data, reply);
|
||||
HDF_LOGE("memcpy rBuf failed");
|
||||
return AUDIO_HAL_ERR_INTERNAL;
|
||||
}
|
||||
AudioProxyBufReplyRecycle(data, reply);
|
||||
return AUDIO_HAL_SUCCESS;
|
||||
}
|
||||
}
|
||||
@@ -101,6 +101,36 @@ int32_t AudioProxyPreprocessRender(struct AudioHwRender *render, struct HdfSBuf
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t AudioProxyPreprocessCapture(struct AudioHwCapture *capture, struct HdfSBuf **data, struct HdfSBuf **reply)
|
||||
{
|
||||
struct AudioHwCapture *hwCapture = capture;
|
||||
if (hwCapture == nullptr || data == nullptr || reply == nullptr) {
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
uint32_t capturePid = (uint32_t)getpid();
|
||||
const char *adapterName = hwCapture->captureParam.captureMode.hwInfo.adapterName;
|
||||
if (adapterName == nullptr) {
|
||||
HDF_LOGE("adapterName is NULL");
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
if (AudioProxyPreprocessSBuf(data, reply) < 0) {
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
if (!HdfRemoteServiceWriteInterfaceToken(capture->proxyRemoteHandle, *data)) {
|
||||
AudioProxyBufReplyRecycle(*data, *reply);
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
if (!HdfSbufWriteString(*data, adapterName)) {
|
||||
AudioProxyBufReplyRecycle(*data, *reply);
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
if (!HdfSbufWriteUint32(*data, capturePid)) {
|
||||
AudioProxyBufReplyRecycle(*data, *reply);
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t AudioProxyWriteSampleAttributes(struct HdfSBuf *data, const struct AudioSampleAttributes *attrs)
|
||||
{
|
||||
if (data == NULL || attrs == NULL) {
|
||||
|
||||
@@ -103,6 +103,8 @@ int32_t AudioProxyManagerLoadAdapter(struct AudioProxyManager *manager, const st
|
||||
hwAdapter->common.InitAllPorts = AudioProxyAdapterInitAllPorts;
|
||||
hwAdapter->common.CreateRender = AudioProxyAdapterCreateRender;
|
||||
hwAdapter->common.DestroyRender = AudioProxyAdapterDestroyRender;
|
||||
hwAdapter->common.CreateCapture = AudioProxyAdapterCreateCapture;
|
||||
hwAdapter->common.DestroyCapture = AudioProxyAdapterDestroyCapture;
|
||||
hwAdapter->common.GetPortCapability = AudioProxyAdapterGetPortCapability;
|
||||
hwAdapter->common.SetPassthroughMode = AudioProxyAdapterSetPassthroughMode;
|
||||
hwAdapter->common.GetPassthroughMode = AudioProxyAdapterGetPassthroughMode;
|
||||
|
||||
@@ -51,6 +51,7 @@ ohos_shared_library("audio_bluetooth_hdi_adapter_server") {
|
||||
"src/hdf_audio_server.cpp",
|
||||
"src/hdf_audio_server_common.cpp",
|
||||
"src/hdf_audio_server_render.cpp",
|
||||
"src/hdf_audio_server_capture.cpp",
|
||||
]
|
||||
|
||||
deps = [ "//drivers/peripheral/bluetooth/audio/hal/hdi_passthrough:hdi_audio_bluetooth" ]
|
||||
|
||||
@@ -64,7 +64,18 @@ enum AudioHdiServerCmdId {
|
||||
AUDIO_HDI_RENDER_TURN_STAND_BY_MODE,
|
||||
AUDIO_HDI_RENDER_DEV_DUMP,
|
||||
AUDIO_HDI_RENDER_REG_CALLBACK,
|
||||
AUDIO_HDI_RENDER_DRAIN_BUFFER
|
||||
AUDIO_HDI_RENDER_DRAIN_BUFFER,
|
||||
/***********capture***************/
|
||||
AUDIO_HDI_CAPTURE_CREATE_CAPTURE,
|
||||
AUDIO_HDI_CAPTURE_DESTROY,
|
||||
AUDIO_HDI_CAPTURE_START,
|
||||
AUDIO_HDI_CAPTURE_STOP,
|
||||
AUDIO_HDI_CAPTURE_PAUSE,
|
||||
AUDIO_HDI_CAPTURE_RESUME,
|
||||
AUDIO_HDI_CAPTURE_FLUSH,
|
||||
AUDIO_HDI_CAPTURE_CAPTURE_FRAME,
|
||||
AUDIO_HDI_CAPTURE_GET_MUTE,
|
||||
AUDIO_HDI_CAPTURE_SET_MUTE
|
||||
};
|
||||
|
||||
typedef int32_t (*AudioAllfunc)(const struct HdfDeviceIoClient *client, struct HdfSBuf *data, struct HdfSBuf *reply);
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (c) 2024 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 HDF_AUDIO_SERVER_CAPTURE_H
|
||||
#define HDF_AUDIO_SERVER_CAPTURE_H
|
||||
|
||||
#include "hdf_device_desc.h"
|
||||
namespace OHOS::HDI::Audio_Bluetooth {
|
||||
int32_t HdiServiceCreateCapture(const struct HdfDeviceIoClient *client,
|
||||
struct HdfSBuf *data, struct HdfSBuf *reply);
|
||||
int32_t HdiServiceCaptureDestory(const struct HdfDeviceIoClient *client,
|
||||
struct HdfSBuf *data, struct HdfSBuf *reply);
|
||||
int32_t HdiServiceCaptureStart(const struct HdfDeviceIoClient *client,
|
||||
struct HdfSBuf *data, struct HdfSBuf *reply);
|
||||
int32_t HdiServiceCaptureStop(const struct HdfDeviceIoClient *client,
|
||||
struct HdfSBuf *data, struct HdfSBuf *reply);
|
||||
int32_t HdiServiceCapturePause(const struct HdfDeviceIoClient *client,
|
||||
struct HdfSBuf *data, struct HdfSBuf *reply);
|
||||
int32_t HdiServiceCaptureResume(const struct HdfDeviceIoClient *client,
|
||||
struct HdfSBuf *data, struct HdfSBuf *reply);
|
||||
int32_t HdiServiceCaptureFlush(const struct HdfDeviceIoClient *client,
|
||||
struct HdfSBuf *data, struct HdfSBuf *reply);
|
||||
int32_t HdiServiceCaptureGetMute(const struct HdfDeviceIoClient *client,
|
||||
struct HdfSBuf *data, struct HdfSBuf *reply);
|
||||
int32_t HdiServiceCaptureSetMute(const struct HdfDeviceIoClient *client,
|
||||
struct HdfSBuf *data, struct HdfSBuf *reply);
|
||||
int32_t HdiServiceCaptureCaptureFrame(const struct HdfDeviceIoClient *client,
|
||||
struct HdfSBuf *data, struct HdfSBuf *reply);
|
||||
}
|
||||
#endif
|
||||
@@ -34,6 +34,12 @@ struct AudioInfoInAdapter {
|
||||
bool renderBusy;
|
||||
bool renderDestory;
|
||||
uint32_t renderPid;
|
||||
int captureStatus;
|
||||
int capturePriority;
|
||||
struct AudioCapture *capture;
|
||||
bool captureBusy;
|
||||
bool captureDestroy;
|
||||
uint32_t capturePid;
|
||||
};
|
||||
|
||||
int32_t AudioAdapterListGetAdapter(const char *adapterName, struct AudioAdapter **adapter);
|
||||
@@ -67,5 +73,17 @@ int32_t AdaptersServerManageInit(const struct AudioAdapterDescriptor *descs, int
|
||||
int32_t HdiServicePositionWrite(struct HdfSBuf *reply,
|
||||
uint64_t frames, struct AudioTimeStamp time);
|
||||
int32_t HdiServiceReqMmapBuffer(struct AudioMmapBufferDescriptor *desc, struct HdfSBuf *data);
|
||||
int32_t AudioAdapterListGetCapture(const char *adapterName, struct AudioCapture **capture,
|
||||
uint32_t pid);
|
||||
int32_t AudioAdapterListGetAdapterCapture(const char *adapterName, struct AudioAdapter **adapter,
|
||||
struct AudioCapture **capture);
|
||||
int32_t AudioDestroyCaptureInfoInAdapter(const char *adapterName);
|
||||
int32_t AudioAddCaptureInfoInAdapter(const char *adapterName, struct AudioCapture *capture,
|
||||
const struct AudioAdapter *adapter, const int32_t priority, uint32_t capturePid);
|
||||
int32_t AudioAdapterListCheckAndGetCapture(struct AudioCapture **capture, struct HdfSBuf *data);
|
||||
int32_t AudioCreateCaptureCheck(const char *adapterName, const int32_t priority);
|
||||
int32_t AudioAdapterFrameGetCapture(const char *adapterName, struct AudioCapture **capture, uint32_t pid,
|
||||
uint32_t *index);
|
||||
void AudioSetCaptureBusy(uint32_t index, bool captureStatus);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "hdf_audio_server_common.h"
|
||||
#include "hdf_audio_server_render.h"
|
||||
#include "hdf_audio_server.h"
|
||||
#include "hdf_audio_server_capture.h"
|
||||
namespace OHOS::HDI::Audio_Bluetooth {
|
||||
#define HDF_LOG_TAG hdf_audio_bluetooth_server
|
||||
|
||||
@@ -403,6 +404,16 @@ struct HdiServiceDispatchCmdHandleList g_hdiServiceDispatchCmdHandleList[] = {
|
||||
{AUDIO_HDI_RENDER_DEV_DUMP, HdiServiceRenderDevDump},
|
||||
{AUDIO_HDI_RENDER_REG_CALLBACK, HdiServiceRenderRegCallback},
|
||||
{AUDIO_HDI_RENDER_DRAIN_BUFFER, HdiServiceRenderDrainBuffer},
|
||||
{AUDIO_HDI_CAPTURE_CREATE_CAPTURE, HdiServiceCreateCapture},
|
||||
{AUDIO_HDI_CAPTURE_DESTROY, HdiServiceCaptureDestory},
|
||||
{AUDIO_HDI_CAPTURE_START, HdiServiceCaptureStart},
|
||||
{AUDIO_HDI_CAPTURE_STOP, HdiServiceCaptureStop},
|
||||
{AUDIO_HDI_CAPTURE_PAUSE, HdiServiceCapturePause},
|
||||
{AUDIO_HDI_CAPTURE_RESUME, HdiServiceCaptureResume},
|
||||
{AUDIO_HDI_CAPTURE_FLUSH, HdiServiceCaptureFlush},
|
||||
{AUDIO_HDI_CAPTURE_GET_MUTE, HdiServiceCaptureGetMute},
|
||||
{AUDIO_HDI_CAPTURE_SET_MUTE, HdiServiceCaptureSetMute},
|
||||
{AUDIO_HDI_CAPTURE_CAPTURE_FRAME, HdiServiceCaptureCaptureFrame},
|
||||
};
|
||||
|
||||
static int32_t HdiServiceDispatch(struct HdfDeviceIoClient *client, int cmdId, struct HdfSBuf *data,
|
||||
@@ -417,10 +428,10 @@ static int32_t HdiServiceDispatch(struct HdfDeviceIoClient *client, int cmdId, s
|
||||
if (!HdfDeviceObjectCheckInterfaceDesc(client->device, data)) {
|
||||
return AUDIO_HAL_ERR_INVALID_PARAM;
|
||||
}
|
||||
if (cmdId > AUDIO_HDI_RENDER_DRAIN_BUFFER || cmdId < 0) {
|
||||
if (cmdId > AUDIO_HDI_CAPTURE_SET_MUTE || cmdId < 0) {
|
||||
HDF_LOGE("ControlDispatch: invalid cmdId = %{public}d", cmdId);
|
||||
return AUDIO_HAL_ERR_INTERNAL;
|
||||
} else if (cmdId <= AUDIO_HDI_RENDER_DRAIN_BUFFER) {
|
||||
} else if (cmdId <= AUDIO_HDI_CAPTURE_SET_MUTE) {
|
||||
for (i = 0; i < sizeof(g_hdiServiceDispatchCmdHandleList) /
|
||||
sizeof(g_hdiServiceDispatchCmdHandleList[0]); ++i) {
|
||||
if ((cmdId == (int)(g_hdiServiceDispatchCmdHandleList[i].cmd)) &&
|
||||
|
||||
@@ -0,0 +1,364 @@
|
||||
/*
|
||||
* Copyright (c) 2024 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 "hdf_audio_server_capture.h"
|
||||
#include "hdf_audio_server_common.h"
|
||||
#include "osal_mem.h"
|
||||
|
||||
#ifdef LOG_DOMAIN
|
||||
#undef LOG_DOMAIN
|
||||
#endif
|
||||
|
||||
#define LOG_DOMAIN 0xD000105
|
||||
|
||||
namespace OHOS::HDI::Audio_Bluetooth {
|
||||
int32_t GetInitCaptureParaAttrs(struct HdfSBuf *data, struct AudioSampleAttributes *attrs)
|
||||
{
|
||||
if (data == nullptr || attrs == nullptr) {
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
uint32_t tempCapturePara = 0;
|
||||
if (!HdfSbufReadUint32(data, &tempCapturePara)) {
|
||||
HDF_LOGE("%{public}s: read tempCapturePara fail", __func__);
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
attrs->type = (AudioCategory)tempCapturePara;
|
||||
if (!HdfSbufReadUint32(data, &attrs->period)) {
|
||||
HDF_LOGE("%{public}s: read period fail", __func__);
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
if (!HdfSbufReadUint32(data, &attrs->frameSize)) {
|
||||
HDF_LOGE("%{public}s: read frameSize fail", __func__);
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
if (!HdfSbufReadUint32(data, &attrs->startThreshold)) {
|
||||
HDF_LOGE("%{public}s: read startThreshold fail", __func__);
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
if (!HdfSbufReadUint32(data, &attrs->stopThreshold)) {
|
||||
HDF_LOGE("%{public}s: read stopThreshold fail", __func__);
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
if (!HdfSbufReadUint32(data, &attrs->silenceThreshold)) {
|
||||
HDF_LOGE("%{public}s: read silenceThreshold fail", __func__);
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
if (!HdfSbufReadUint32(data, &tempCapturePara)) {
|
||||
HDF_LOGE("%{public}s: read bool isBigEndian fail", __func__);
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
attrs->isBigEndian = (bool)tempCapturePara;
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t GetInitCapturePara(struct HdfSBuf *data, struct AudioDeviceDescriptor *devDesc,
|
||||
struct AudioSampleAttributes *attrs)
|
||||
{
|
||||
if (data == nullptr || devDesc == nullptr || attrs == nullptr) {
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
uint32_t tempCapturePara = 0;
|
||||
if (!HdfSbufReadUint32(data, &tempCapturePara)) {
|
||||
HDF_LOGE("%{public}s: read attrs format fail", __func__);
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
attrs->format = (AudioFormat)tempCapturePara;
|
||||
if (!HdfSbufReadUint32(data, &attrs->channelCount)) {
|
||||
HDF_LOGE("%{public}s: read channelCount fail", __func__);
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
if (!HdfSbufReadUint32(data, &attrs->sampleRate)) {
|
||||
HDF_LOGE("%{public}s: read sampleRate fail", __func__);
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
if (!HdfSbufReadUint32(data, &tempCapturePara)) {
|
||||
HDF_LOGE("%{public}s: read attrs interleaved fail", __func__);
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
attrs->interleaved = (bool)tempCapturePara;
|
||||
if (GetInitCaptureParaAttrs(data, attrs) < 0) {
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
if (!HdfSbufReadUint32(data, &tempCapturePara)) {
|
||||
HDF_LOGE("%{public}s: read attrs isSignedData fail", __func__);
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
attrs->isSignedData = (bool)tempCapturePara;
|
||||
if (!HdfSbufReadUint32(data, &devDesc->portId)) {
|
||||
HDF_LOGE("%{public}s: read portId fail", __func__);
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
if (!HdfSbufReadUint32(data, &tempCapturePara)) {
|
||||
HDF_LOGE("%{public}s: read tempRenderPara fail", __func__);
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
devDesc->pins = (AudioPortPin)tempCapturePara;
|
||||
devDesc->desc = nullptr;
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t HdiServiceCreateCapture(const struct HdfDeviceIoClient *client,
|
||||
struct HdfSBuf *data, struct HdfSBuf *reply)
|
||||
{
|
||||
if (client == nullptr || data == nullptr || reply == nullptr) {
|
||||
return AUDIO_HAL_ERR_INVALID_PARAM;
|
||||
}
|
||||
struct AudioAdapter *adapter = nullptr;
|
||||
struct AudioDeviceDescriptor devDesc;
|
||||
struct AudioSampleAttributes attrs;
|
||||
struct AudioCapture *capture = nullptr;
|
||||
const char *adapterName = nullptr;
|
||||
uint32_t capturePid = 0;
|
||||
if ((adapterName = HdfSbufReadString(data)) == nullptr) {
|
||||
HDF_LOGE("%{public}s: adapterNameCase Is NULL", __func__);
|
||||
return AUDIO_HAL_ERR_INVALID_PARAM;
|
||||
}
|
||||
if (!HdfSbufReadUint32(data, &capturePid)) {
|
||||
return AUDIO_HAL_ERR_INTERNAL;
|
||||
}
|
||||
HDF_LOGE("HdiServiceCreatRender: capturePid = %{public}u", capturePid);
|
||||
int32_t ret = GetInitCapturePara(data, &devDesc, &attrs);
|
||||
if (ret < 0) {
|
||||
HDF_LOGE("%{public}s: GetInitCapturePara fail", __func__);
|
||||
return AUDIO_HAL_ERR_INTERNAL;
|
||||
}
|
||||
if (AudioAdapterListGetAdapter(adapterName, &adapter)) {
|
||||
HDF_LOGE("%{public}s: fail", __func__);
|
||||
return AUDIO_HAL_ERR_INTERNAL;
|
||||
}
|
||||
if (adapter == nullptr) {
|
||||
HDF_LOGE("%{public}s: adapter is NULL!", __func__);
|
||||
return AUDIO_HAL_ERR_INVALID_PARAM;
|
||||
}
|
||||
const int32_t priority = attrs.type;
|
||||
ret = AudioCreateCaptureCheck(adapterName, priority);
|
||||
if (ret < 0) {
|
||||
HDF_LOGE("%{public}s: AudioCreateCaptureCheck: Capture is working can not replace!", __func__);
|
||||
return ret;
|
||||
}
|
||||
ret = adapter->CreateCapture(adapter, &devDesc, &attrs, &capture);
|
||||
if (capture == nullptr || ret < 0) {
|
||||
HDF_LOGE("%{public}s: Failed to CreateCapture", __func__);
|
||||
return AUDIO_HAL_ERR_INTERNAL;
|
||||
}
|
||||
if (AudioAddCaptureInfoInAdapter(adapterName, capture, adapter, priority, capturePid)) {
|
||||
HDF_LOGE("%{public}s: AudioAddCaptureInfoInAdapter", __func__);
|
||||
adapter->DestroyCapture(adapter, capture);
|
||||
return AUDIO_HAL_ERR_INTERNAL;
|
||||
}
|
||||
return AUDIO_HAL_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t HdiServiceCaptureDestory(const struct HdfDeviceIoClient *client,
|
||||
struct HdfSBuf *data, struct HdfSBuf *reply)
|
||||
{
|
||||
if (client == nullptr || data == nullptr || reply == nullptr) {
|
||||
return AUDIO_HAL_ERR_INVALID_PARAM;
|
||||
}
|
||||
struct AudioAdapter *adapter = nullptr;
|
||||
struct AudioCapture *capture = nullptr;
|
||||
const char *adapterName = nullptr;
|
||||
uint32_t pid = 0;
|
||||
if (HdiServiceRenderCaptureReadData(data, &adapterName, &pid) < 0) {
|
||||
return AUDIO_HAL_ERR_INTERNAL;
|
||||
}
|
||||
int32_t ret = AudioAdapterListGetCapture(adapterName, &capture, pid);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
ret = AudioAdapterListGetAdapterCapture(adapterName, &adapter, &capture);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
if (adapter == nullptr || capture == nullptr) {
|
||||
return AUDIO_HAL_ERR_INVALID_PARAM;
|
||||
}
|
||||
HDF_LOGI("%{public}s: DestroyCapture.", __func__);
|
||||
ret = adapter->DestroyCapture(adapter, capture);
|
||||
if (ret < 0) {
|
||||
HDF_LOGE("%{public}s: DestroyCapture failed!", __func__);
|
||||
return ret;
|
||||
}
|
||||
if (AudioDestroyCaptureInfoInAdapter(adapterName)) {
|
||||
return AUDIO_HAL_ERR_INTERNAL;
|
||||
}
|
||||
return AUDIO_HAL_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t HdiServiceCaptureStart(const struct HdfDeviceIoClient *client, struct HdfSBuf *data, struct HdfSBuf *reply)
|
||||
{
|
||||
if (client == nullptr || data == nullptr || reply == nullptr) {
|
||||
return AUDIO_HAL_ERR_INVALID_PARAM;
|
||||
}
|
||||
struct AudioCapture *capture = nullptr;
|
||||
int ret = AudioAdapterListCheckAndGetCapture(&capture, data);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
return capture->control.Start((AudioHandle)capture);
|
||||
}
|
||||
|
||||
int32_t HdiServiceCaptureStop(const struct HdfDeviceIoClient *client, struct HdfSBuf *data, struct HdfSBuf *reply)
|
||||
{
|
||||
if (client == nullptr || data == nullptr || reply == nullptr) {
|
||||
return AUDIO_HAL_ERR_INVALID_PARAM;
|
||||
}
|
||||
struct AudioCapture *capture = nullptr;
|
||||
int ret = AudioAdapterListCheckAndGetCapture(&capture, data);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
return capture->control.Stop((AudioHandle)capture);
|
||||
}
|
||||
|
||||
int32_t HdiServiceCapturePause(const struct HdfDeviceIoClient *client,
|
||||
struct HdfSBuf *data, struct HdfSBuf *reply)
|
||||
{
|
||||
if (client == nullptr || data == nullptr || reply == nullptr) {
|
||||
return AUDIO_HAL_ERR_INVALID_PARAM;
|
||||
}
|
||||
HDF_LOGE("%{public}s: enter", __func__);
|
||||
struct AudioCapture *capture = nullptr;
|
||||
int ret = AudioAdapterListCheckAndGetCapture(&capture, data);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
return capture->control.Pause((AudioHandle)capture);
|
||||
}
|
||||
|
||||
int32_t HdiServiceCaptureResume(const struct HdfDeviceIoClient *client, struct HdfSBuf *data, struct HdfSBuf *reply)
|
||||
{
|
||||
if (client == nullptr || data == nullptr || reply == nullptr) {
|
||||
return AUDIO_HAL_ERR_INVALID_PARAM;
|
||||
}
|
||||
struct AudioCapture *capture = nullptr;
|
||||
int ret = AudioAdapterListCheckAndGetCapture(&capture, data);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
return capture->control.Resume((AudioHandle)capture);
|
||||
}
|
||||
|
||||
int32_t HdiServiceCaptureFlush(const struct HdfDeviceIoClient *client, struct HdfSBuf *data, struct HdfSBuf *reply)
|
||||
{
|
||||
if (client == nullptr || data == nullptr || reply == nullptr) {
|
||||
HDF_LOGI("%{public}s: The parameter is empty", __func__);
|
||||
return AUDIO_HAL_ERR_INVALID_PARAM;
|
||||
}
|
||||
struct AudioCapture *capture = nullptr;
|
||||
int ret = AudioAdapterListCheckAndGetCapture(&capture, data);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
return capture->control.Flush((AudioHandle)capture);
|
||||
}
|
||||
|
||||
int32_t HdiServiceCaptureGetMute(const struct HdfDeviceIoClient *client,
|
||||
struct HdfSBuf *data, struct HdfSBuf *reply)
|
||||
{
|
||||
if (client == nullptr || data == nullptr || reply == nullptr) {
|
||||
HDF_LOGI("%{public}s: parameter is empty", __func__);
|
||||
return AUDIO_HAL_ERR_INVALID_PARAM;
|
||||
}
|
||||
bool mute = false;
|
||||
struct AudioCapture *capture = nullptr;
|
||||
int ret = AudioAdapterListCheckAndGetCapture(&capture, data);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
ret = capture->volume.GetMute((AudioHandle)capture, &mute);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
uint32_t tempMute = (uint32_t)mute;
|
||||
if (!HdfSbufWriteUint32(reply, tempMute)) {
|
||||
return AUDIO_HAL_ERR_INTERNAL;
|
||||
}
|
||||
return AUDIO_HAL_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t HdiServiceCaptureSetMute(const struct HdfDeviceIoClient *client,
|
||||
struct HdfSBuf *data, struct HdfSBuf *reply)
|
||||
{
|
||||
if (client == nullptr || data == nullptr || reply == nullptr) {
|
||||
return AUDIO_HAL_ERR_INVALID_PARAM;
|
||||
}
|
||||
bool mute = false;
|
||||
struct AudioCapture *capture = nullptr;
|
||||
int ret = AudioAdapterListCheckAndGetCapture(&capture, data);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
uint32_t tempMute = 0;
|
||||
if (!HdfSbufReadUint32(data, &tempMute)) {
|
||||
return AUDIO_HAL_ERR_INTERNAL;
|
||||
}
|
||||
mute = (bool)tempMute;
|
||||
return capture->volume.SetMute((AudioHandle)capture, mute);
|
||||
}
|
||||
|
||||
int32_t HdiServiceCaptureCaptureFrame(const struct HdfDeviceIoClient *client,
|
||||
struct HdfSBuf *data, struct HdfSBuf *reply)
|
||||
{
|
||||
if (client == nullptr || data == nullptr || reply == nullptr) {
|
||||
return AUDIO_HAL_ERR_INVALID_PARAM;
|
||||
}
|
||||
char *frame = nullptr;
|
||||
uint64_t requestBytes;
|
||||
uint64_t replyBytes;
|
||||
struct AudioCapture *capture = nullptr;
|
||||
const char *adapterName = nullptr;
|
||||
uint32_t pid;
|
||||
uint32_t index = 0;
|
||||
if (HdiServiceRenderCaptureReadData(data, &adapterName, &pid) < 0) {
|
||||
HDF_LOGE("%{public}s: HdiServiceRenderCaptureReadData fail!", __func__);
|
||||
return AUDIO_HAL_ERR_INTERNAL;
|
||||
}
|
||||
int32_t ret = AudioAdapterFrameGetCapture(adapterName, &capture, pid, &index);
|
||||
if (ret < 0) {
|
||||
HDF_LOGE("%{public}s: AudioAdapterFrameGetCapture fail", __func__);
|
||||
return ret;
|
||||
}
|
||||
if (!HdfSbufReadUint64(data, &requestBytes)) {
|
||||
return AUDIO_HAL_ERR_INTERNAL;
|
||||
}
|
||||
frame = (char *)OsalMemCalloc(FRAME_DATA);
|
||||
if (frame == nullptr) {
|
||||
return AUDIO_HAL_ERR_MALLOC_FAIL;
|
||||
}
|
||||
AudioSetCaptureBusy(index, true);
|
||||
if (capture == nullptr || capture->CaptureFrame == nullptr) {
|
||||
HDF_LOGE("capture or capureFrame in NULL");
|
||||
AudioMemFree(reinterpret_cast<void **>(&frame));
|
||||
return AUDIO_HAL_ERR_INTERNAL;
|
||||
}
|
||||
ret = capture->CaptureFrame(capture, (void *)frame, requestBytes, &replyBytes);
|
||||
AudioSetCaptureBusy(index, false);
|
||||
if (ret < 0) {
|
||||
AudioMemFree(reinterpret_cast<void **>(&frame));
|
||||
return ret;
|
||||
}
|
||||
if (!HdfSbufWriteUint64(reply, replyBytes)) {
|
||||
AudioMemFree(reinterpret_cast<void **>(&frame));
|
||||
return AUDIO_HAL_ERR_INTERNAL;
|
||||
}
|
||||
if (!HdfSbufWriteBuffer(reply, (const void *)frame, replyBytes)) {
|
||||
AudioMemFree(reinterpret_cast<void **>(&frame));
|
||||
return AUDIO_HAL_ERR_INTERNAL;
|
||||
}
|
||||
AudioMemFree(reinterpret_cast<void **>(&frame));
|
||||
return AUDIO_HAL_SUCCESS;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -303,6 +303,37 @@ int32_t AudioDestroyFormerRender(struct AudioInfoInAdapter *renderManage)
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t AudioDestroyFormerCapture(struct AudioInfoInAdapter *captureManage)
|
||||
{
|
||||
LOG_FUN_INFO();
|
||||
if (captureManage == nullptr || captureManage->adapter == nullptr || captureManage->capture == nullptr) {
|
||||
HDF_LOGE("%{public}s: input para is NULL. ", __func__);
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
int count = 0;
|
||||
captureManage->captureDestroy = true;
|
||||
while (captureManage->captureBusy) {
|
||||
if (count > 1000) { // Less than 1000
|
||||
HDF_LOGE("%{public}s: , count = %{public}d", __func__, count);
|
||||
captureManage->captureDestroy = false;
|
||||
return AUDIO_HAL_ERR_AO_BUSY; // render is busy now
|
||||
}
|
||||
usleep(500); // sleep 500us
|
||||
count++;
|
||||
}
|
||||
captureManage->capturePid = 0;
|
||||
if (captureManage->adapter->DestroyCapture(captureManage->adapter, captureManage->capture)) {
|
||||
captureManage->captureDestroy = false;
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
captureManage->capture = nullptr;
|
||||
captureManage->captureStatus = 0;
|
||||
captureManage->captureBusy = false;
|
||||
captureManage->captureDestroy = false;
|
||||
captureManage->capturePriority = -1;
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t AudioJudgeRenderPriority(const int32_t priority, int which)
|
||||
{
|
||||
int32_t num;
|
||||
@@ -327,6 +358,30 @@ int32_t AudioJudgeRenderPriority(const int32_t priority, int which)
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
int32_t AudioJudgeCapturePriority(const int32_t priority, int which)
|
||||
{
|
||||
int32_t num = (g_serverAdapterNum > MAX_AUDIO_ADAPTER_NUM_SERVER)
|
||||
? MAX_AUDIO_ADAPTER_NUM_SERVER
|
||||
: g_serverAdapterNum;
|
||||
if (which < 0 || which >= num) {
|
||||
HDF_LOGE("%{public}s: invalid value! ", __func__);
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
if (g_renderAndCaptureManage == NULL) {
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
if (g_renderAndCaptureManage[which].capturePriority <= priority) {
|
||||
if (AudioDestroyFormerCapture(&g_renderAndCaptureManage[which])) {
|
||||
HDF_LOGE("%{public}s: AudioDestroyFormerCapture: Fail. ", __func__);
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
return HDF_SUCCESS;
|
||||
} else {
|
||||
return AUDIO_HAL_ERR_AO_BUSY; // render is busy now
|
||||
}
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
int32_t AudioCreatRenderCheck(const char *adapterName, const int32_t priority)
|
||||
{
|
||||
int32_t i;
|
||||
@@ -336,8 +391,9 @@ int32_t AudioCreatRenderCheck(const char *adapterName, const int32_t priority)
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
int32_t num = (g_serverAdapterNum > MAX_AUDIO_ADAPTER_NUM_SERVER) ?
|
||||
MAX_AUDIO_ADAPTER_NUM_SERVER : g_serverAdapterNum;
|
||||
int32_t num = (g_serverAdapterNum > MAX_AUDIO_ADAPTER_NUM_SERVER)
|
||||
? MAX_AUDIO_ADAPTER_NUM_SERVER
|
||||
: g_serverAdapterNum;
|
||||
for (i = 0; i < num; i++) {
|
||||
if (g_renderAndCaptureManage[i].adapterName == NULL) {
|
||||
return HDF_FAILURE;
|
||||
@@ -354,6 +410,32 @@ int32_t AudioCreatRenderCheck(const char *adapterName, const int32_t priority)
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
int32_t AudioCreateCaptureCheck(const char *adapterName, const int32_t priority)
|
||||
{
|
||||
int32_t i;
|
||||
LOG_FUN_INFO();
|
||||
if (adapterName == NULL || g_renderAndCaptureManage == NULL) {
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
int32_t num = (g_serverAdapterNum > MAX_AUDIO_ADAPTER_NUM_SERVER)
|
||||
? MAX_AUDIO_ADAPTER_NUM_SERVER
|
||||
: g_serverAdapterNum;
|
||||
for (i = 0; i < num; i++) {
|
||||
if (g_renderAndCaptureManage[i].adapterName == NULL) {
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
if (!strcmp(g_renderAndCaptureManage[i].adapterName, adapterName)) {
|
||||
if (!(g_renderAndCaptureManage[i].captureStatus)) {
|
||||
return HDF_SUCCESS;
|
||||
} else {
|
||||
return AudioJudgeCapturePriority(priority, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
HDF_LOGE("%{public}s: Can not find Adapter! ", __func__);
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
int32_t AudioAddRenderInfoInAdapter(const char *adapterName,
|
||||
struct AudioRender *render,
|
||||
const struct AudioAdapter *adapter,
|
||||
@@ -386,6 +468,35 @@ int32_t AudioAddRenderInfoInAdapter(const char *adapterName,
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
int32_t AudioAddCaptureInfoInAdapter(const char *adapterName, struct AudioCapture *capture,
|
||||
const struct AudioAdapter *adapter, const int32_t priority, uint32_t capturePid)
|
||||
{
|
||||
int32_t i;
|
||||
int32_t num;
|
||||
if (adapterName == nullptr || adapter == nullptr || capture == nullptr) {
|
||||
HDF_LOGE("%{public}s: input para is NULL. ", __func__);
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
if (g_renderAndCaptureManage == nullptr) {
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
num = (g_serverAdapterNum > MAX_AUDIO_ADAPTER_NUM_SERVER) ? MAX_AUDIO_ADAPTER_NUM_SERVER : g_serverAdapterNum;
|
||||
for (i = 0; i < num; i++) {
|
||||
if (g_renderAndCaptureManage[i].adapterName == nullptr) {
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
if (!strcmp(g_renderAndCaptureManage[i].adapterName, adapterName)) {
|
||||
g_renderAndCaptureManage[i].captureStatus = 1;
|
||||
g_renderAndCaptureManage[i].capturePriority = priority;
|
||||
g_renderAndCaptureManage[i].capture = capture;
|
||||
g_renderAndCaptureManage[i].capturePid = capturePid;
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
}
|
||||
HDF_LOGE("%{public}s: Can not find Adapter! ", __func__);
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
void AudioSetRenderStatus(const char *adapterName, bool renderStatus)
|
||||
{
|
||||
int32_t i, num;
|
||||
@@ -470,6 +581,35 @@ int32_t AudioDestroyRenderInfoInAdapter(const char *adapterName)
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
int32_t AudioDestroyCaptureInfoInAdapter(const char *adapterName)
|
||||
{
|
||||
int32_t i;
|
||||
int32_t num;
|
||||
LOG_FUN_INFO();
|
||||
if (adapterName == nullptr) {
|
||||
HDF_LOGE("%{public}s: adapterName is null ", __func__);
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
num = (g_serverAdapterNum > MAX_AUDIO_ADAPTER_NUM_SERVER) ? MAX_AUDIO_ADAPTER_NUM_SERVER : g_serverAdapterNum;
|
||||
if (g_renderAndCaptureManage == nullptr) {
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
for (i = 0; i < num; i++) {
|
||||
if (g_renderAndCaptureManage[i].adapterName == nullptr) {
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
if (!strcmp(g_renderAndCaptureManage[i].adapterName, adapterName)) {
|
||||
g_renderAndCaptureManage[i].captureStatus = 0;
|
||||
g_renderAndCaptureManage[i].capturePriority = -1;
|
||||
g_renderAndCaptureManage[i].capture = nullptr;
|
||||
g_renderAndCaptureManage[i].capturePid = 0;
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
}
|
||||
HDF_LOGE("%{public}s: Can not find Adapter! ", __func__);
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
int32_t AudioAdapterListGetPid(const char *adapterName, uint32_t *pid)
|
||||
{
|
||||
LOG_FUN_INFO();
|
||||
@@ -524,6 +664,34 @@ int32_t AudioAdapterListGetAdapterRender(const char *adapterName,
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
int32_t AudioAdapterListGetAdapterCapture(const char *adapterName,
|
||||
struct AudioAdapter **adapter, struct AudioCapture **capture)
|
||||
{
|
||||
int32_t i;
|
||||
int32_t num;
|
||||
LOG_FUN_INFO();
|
||||
if (g_renderAndCaptureManage == nullptr) {
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
if (adapterName == nullptr || adapter == nullptr || capture == nullptr) {
|
||||
HDF_LOGE("%{public}s: The pointer is null ", __func__);
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
num = (g_serverAdapterNum > MAX_AUDIO_ADAPTER_NUM_SERVER) ? MAX_AUDIO_ADAPTER_NUM_SERVER : g_serverAdapterNum;
|
||||
for (i = 0; i < num; i++) {
|
||||
if (g_renderAndCaptureManage[i].adapterName == nullptr) {
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
if (!strcmp(g_renderAndCaptureManage[i].adapterName, adapterName)) {
|
||||
*adapter = g_renderAndCaptureManage[i].adapter;
|
||||
*capture = g_renderAndCaptureManage[i].capture;
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
}
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
int32_t AudioAdapterListGetRender(const char *adapterName, struct AudioRender **render, uint32_t pid)
|
||||
{
|
||||
int32_t num;
|
||||
@@ -554,6 +722,72 @@ int32_t AudioAdapterListGetRender(const char *adapterName, struct AudioRender **
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
int32_t AudioAdapterListGetCapture(const char *adapterName, struct AudioCapture **capture, uint32_t pid)
|
||||
{
|
||||
int32_t num;
|
||||
HDF_LOGD("%{public}s: enter ", __func__);
|
||||
if (g_renderAndCaptureManage == nullptr) {
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
if (adapterName == nullptr || capture == nullptr) {
|
||||
HDF_LOGE("%{public}s: pointer is null ", __func__);
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
num = (g_serverAdapterNum > MAX_AUDIO_ADAPTER_NUM_SERVER) ? MAX_AUDIO_ADAPTER_NUM_SERVER : g_serverAdapterNum;
|
||||
for (int32_t i = 0; i < num; i++) {
|
||||
if (g_renderAndCaptureManage[i].adapterName == nullptr) {
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
if (!strcmp(g_renderAndCaptureManage[i].adapterName, adapterName)) {
|
||||
if (g_renderAndCaptureManage[i].capturePid != pid) {
|
||||
HDF_LOGE("%{public}s: renderPid != pid renderPid = %{public}u, pid = %{public}u",
|
||||
__func__, g_renderAndCaptureManage[i].capturePid, pid);
|
||||
return AUDIO_HAL_ERR_INVALID_OBJECT;
|
||||
}
|
||||
*capture = g_renderAndCaptureManage[i].capture;
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
}
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
int32_t AudioAdapterFrameGetCapture(const char *adapterName, struct AudioCapture **capture, uint32_t pid,
|
||||
uint32_t *index)
|
||||
{
|
||||
if (adapterName == nullptr || capture == nullptr || index == nullptr) {
|
||||
HDF_LOGE("adapterName or capture or index is null");
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
int32_t num = (g_serverAdapterNum > MAX_AUDIO_ADAPTER_NUM_SERVER)
|
||||
? MAX_AUDIO_ADAPTER_NUM_SERVER
|
||||
: g_serverAdapterNum;
|
||||
*index = MAX_AUDIO_ADAPTER_NUM_SERVER;
|
||||
for (int32_t i = 0; i < num; i++) {
|
||||
if (g_renderAndCaptureManage[i].adapterName == nullptr) {
|
||||
HDF_LOGE("g_renderAndCaptureManage[%{public}d] adapterName is null!", i);
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
if (strcmp(g_renderAndCaptureManage[i].adapterName, adapterName) == 0) {
|
||||
if (g_renderAndCaptureManage[i].capturePid != pid) {
|
||||
HDF_LOGE("%{public}s: capturePid != pid capturePid = %{public}u, pid = %{public}u",
|
||||
__func__, g_renderAndCaptureManage[i].capturePid, pid);
|
||||
return AUDIO_HAL_ERR_INVALID_OBJECT;
|
||||
}
|
||||
if (!g_renderAndCaptureManage[i].captureDestroy) {
|
||||
*capture = g_renderAndCaptureManage[i].capture;
|
||||
*index = i;
|
||||
return HDF_SUCCESS;
|
||||
} else {
|
||||
g_renderAndCaptureManage[i].captureBusy = false;
|
||||
HDF_LOGE("g_renderAndCaptureManage[%{public}d] captureBusy is false!", i);
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
HDF_LOGE("AudioAdapterFrameGetCapture failed!");
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
int32_t AudioAdapterListCheckAndGetRender(struct AudioRender **render, struct HdfSBuf *data)
|
||||
{
|
||||
if (render == NULL || data == NULL) {
|
||||
@@ -577,6 +811,29 @@ int32_t AudioAdapterListCheckAndGetRender(struct AudioRender **render, struct Hd
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t AudioAdapterListCheckAndGetCapture(struct AudioCapture **capture, struct HdfSBuf *data)
|
||||
{
|
||||
if (capture == nullptr || data == nullptr) {
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
struct AudioCapture *captureTemp = nullptr;
|
||||
const char *adapterName = nullptr;
|
||||
uint32_t pid = 0;
|
||||
if (HdiServiceRenderCaptureReadData(data, &adapterName, &pid) < 0) {
|
||||
HDF_LOGE("%{public}s: HdiServiceRenderStart: HdiServiceRenderCaptureReadData fail ", __func__);
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
int ret = AudioAdapterListGetCapture(adapterName, &captureTemp, pid);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
if (captureTemp == NULL) {
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
*capture = captureTemp;
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t AudioAdapterCheckListExist(const char *adapterName)
|
||||
{
|
||||
int32_t i, num;
|
||||
@@ -717,4 +974,11 @@ int32_t HdiServiceReqMmapBuffer(struct AudioMmapBufferDescriptor *desc, struct H
|
||||
}
|
||||
return AUDIO_HAL_SUCCESS;
|
||||
}
|
||||
|
||||
void AudioSetCaptureBusy(uint32_t index, bool captureStatus)
|
||||
{
|
||||
if (index == MAX_AUDIO_ADAPTER_NUM_SERVER) {
|
||||
g_renderAndCaptureManage[index].captureBusy = captureStatus;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"adapterNum": 5,
|
||||
"adapterNum": 6,
|
||||
"adapters": [{
|
||||
"name": "internal",
|
||||
"portnum": 2,
|
||||
@@ -59,5 +59,14 @@
|
||||
"id": 0,
|
||||
"name": "AOP"
|
||||
}]
|
||||
},
|
||||
{
|
||||
"name": "bt_hdap",
|
||||
"portnum": 1,
|
||||
"port": [{
|
||||
"dir": "PORT_IN",
|
||||
"id": 0,
|
||||
"name": "AIP"
|
||||
}]
|
||||
}]
|
||||
}
|
||||
|
||||
@@ -60,6 +60,7 @@ ohos_shared_library("hdi_audio_bluetooth") {
|
||||
"src/bluetooth_a2dp_audio_src_observer_stub.cpp",
|
||||
"src/bluetooth_a2dp_src_observer.cpp",
|
||||
"src/fast_audio_render.cpp",
|
||||
"src/audio_capture.cpp",
|
||||
]
|
||||
|
||||
include_dirs = [
|
||||
|
||||
@@ -54,6 +54,12 @@ int FastStopPlaying();
|
||||
int FastReqMmapBuffer(int32_t ashmemLength);
|
||||
void FastReadMmapPosition(int64_t &sec, int64_t &nSec, uint64_t &frames);
|
||||
int FastGetLatency(uint32_t &latency);
|
||||
bool SetUpCapture();
|
||||
void TearDownCapture();
|
||||
int StartCapture();
|
||||
int SuspendCapture();
|
||||
int StopCapture();
|
||||
int ReadFrame(uint8_t *data, uint64_t size);
|
||||
#endif
|
||||
|
||||
int WriteFrame(const uint8_t *data, uint32_t size, const HDI::Audio_Bluetooth::AudioSampleAttributes *attrs);
|
||||
|
||||
@@ -187,6 +187,7 @@ struct AudioHwAdapter {
|
||||
struct AudioPortAndCapability *portCapabilitys;
|
||||
struct HdfRemoteService *proxyRemoteHandle; // proxyRemoteHandle
|
||||
int32_t adapterMgrRenderFlag;
|
||||
int32_t adapterMgrCaptureFlag;
|
||||
};
|
||||
|
||||
struct AudioFrameRenderMode {
|
||||
@@ -209,6 +210,15 @@ struct AudioFrameRenderMode {
|
||||
struct AudioMmapBufferDescriptor mmapBufDesc;
|
||||
};
|
||||
|
||||
struct AudioFrameCaptureMode {
|
||||
uint64_t frames;
|
||||
struct AudioTimeStamp time;
|
||||
struct AudioSampleAttributes attrs;
|
||||
uint32_t byteRate;
|
||||
uint32_t periodSize;
|
||||
uint32_t periodCount;
|
||||
};
|
||||
|
||||
struct AudioGain {
|
||||
float gain;
|
||||
float gainMin;
|
||||
@@ -284,6 +294,16 @@ struct AudioHwRenderParam {
|
||||
struct AudioFrameRenderMode frameRenderMode;
|
||||
};
|
||||
|
||||
struct AudioHwCaptureMode {
|
||||
struct AudioCtlParam ctlParam;
|
||||
struct HwInfo hwInfo;
|
||||
};
|
||||
|
||||
struct AudioHwCaptureParam {
|
||||
struct AudioHwCaptureMode captureMode;
|
||||
struct AudioFrameCaptureMode frameCaptureMode;
|
||||
};
|
||||
|
||||
struct ErrorDump {
|
||||
int32_t errorCode;
|
||||
int32_t count;
|
||||
@@ -305,6 +325,13 @@ struct AudioHwRender {
|
||||
struct ErrorLog errorLog;
|
||||
};
|
||||
|
||||
struct AudioHwCapture {
|
||||
struct AudioCapture common;
|
||||
struct AudioHwCaptureParam captureParam;
|
||||
struct HdfRemoteService *proxyRemoteHandle; // proxyRemoteHandle
|
||||
struct ErrorLog errorLog;
|
||||
};
|
||||
|
||||
struct ParamValMap {
|
||||
char key[EXTPARAM_LEN];
|
||||
char value[EXTPARAM_LEN];
|
||||
@@ -395,6 +422,22 @@ int32_t AudioRenderTurnStandbyMode(AudioHandle handle);
|
||||
int32_t AudioRenderAudioDevDump(AudioHandle handle, int32_t range, int32_t fd);
|
||||
int32_t AudioRenderRegCallback(struct AudioRender *render, RenderCallback callback, void* cookie);
|
||||
int32_t AudioRenderDrainBuffer(struct AudioRender *render, AudioDrainNotifyType *type);
|
||||
int32_t InitHwCaptureParam(struct AudioHwCapture *hwCapture, const struct AudioDeviceDescriptor *desc,
|
||||
const struct AudioSampleAttributes *attrs);
|
||||
int32_t GetAudioCaptureFunc(struct AudioHwCapture *hwCapture, const char *adapterName);
|
||||
int32_t AudioAdapterCreateCapture(struct AudioAdapter *adapter, const struct AudioDeviceDescriptor *desc,
|
||||
const struct AudioSampleAttributes *attrs, struct AudioCapture **capture);
|
||||
int32_t AudioAdapterDestroyCapture(struct AudioAdapter *adapter, struct AudioCapture *capture);
|
||||
int32_t AudioCaptureStart(AudioHandle handle);
|
||||
int32_t AudioCaptureStop(AudioHandle handle);
|
||||
int32_t AudioCapturePause(AudioHandle handle);
|
||||
int32_t AudioCaptureResume(AudioHandle handle);
|
||||
int32_t AudioCaptureFlush(AudioHandle handle);
|
||||
int32_t AudioCaptureSetMute(AudioHandle handle, bool mute);
|
||||
int32_t AudioCaptureGetMute(AudioHandle handle, bool *mute);
|
||||
int32_t AudioCaptureCaptureFrame(struct AudioCapture *capture, void *frame, uint64_t requestBytes,
|
||||
uint64_t *replyBytes);
|
||||
void AudioReleaseCaptureHandle(struct AudioHwCapture *hwCapture);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -40,6 +40,8 @@ typedef size_t (*WriteFrameFunc)(const void* data, size_t size);
|
||||
typedef int32_t (*ReqMmapBufferFunc)(int32_t ashmemLength);
|
||||
typedef void (*ReadMmapPositionFunc)(int64_t &sec, int64_t &nSec, uint64_t &frames);
|
||||
typedef bool (*GetLatencyFunc)(uint32_t &latency);
|
||||
typedef size_t (*ReadFrameFunc)(void *data, size_t size);
|
||||
typedef bool (*StartCaptureFunc)();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,6 +104,18 @@ static void GetNormalRenderFuncs(struct AudioHwRender *hwRender)
|
||||
hwRender->common.DrainBuffer = AudioRenderDrainBuffer;
|
||||
}
|
||||
|
||||
static void GetCaptureFuncs(struct AudioHwCapture *hwCapture)
|
||||
{
|
||||
hwCapture->common.control.Start = AudioCaptureStart;
|
||||
hwCapture->common.control.Stop = AudioCaptureStop;
|
||||
hwCapture->common.control.Pause = AudioCapturePause;
|
||||
hwCapture->common.control.Resume = AudioCaptureResume;
|
||||
hwCapture->common.control.Flush = AudioCaptureFlush;
|
||||
hwCapture->common.volume.SetMute = AudioCaptureSetMute;
|
||||
hwCapture->common.volume.GetMute = AudioCaptureGetMute;
|
||||
hwCapture->common.CaptureFrame = AudioCaptureCaptureFrame;
|
||||
}
|
||||
|
||||
int32_t GetAudioRenderFunc(struct AudioHwRender *hwRender, const char *adapterName)
|
||||
{
|
||||
if (hwRender == nullptr || adapterName == nullptr) {
|
||||
@@ -117,6 +129,15 @@ int32_t GetAudioRenderFunc(struct AudioHwRender *hwRender, const char *adapterNa
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t GetAudioCaptureFunc(struct AudioHwCapture *hwCapture, const char *adapterName)
|
||||
{
|
||||
if (hwCapture == nullptr || adapterName == nullptr) {
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
GetCaptureFuncs(hwCapture);
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t CheckParaDesc(const struct AudioDeviceDescriptor *desc, const char *type)
|
||||
{
|
||||
if (desc == NULL || type == NULL) {
|
||||
@@ -232,6 +253,52 @@ int32_t InitHwRenderParam(struct AudioHwRender *hwRender, const struct AudioDevi
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t InitHwCaptureParam(struct AudioHwCapture *hwCapture, const struct AudioDeviceDescriptor *desc,
|
||||
const struct AudioSampleAttributes *attrs)
|
||||
{
|
||||
if (hwCapture == nullptr || desc == nullptr || attrs == nullptr) {
|
||||
HDF_LOGE("InitHwCaptureParam param Is NULL");
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
int32_t ret = CheckParaDesc(desc, TYPE_CAPTURE);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("CheckParaDesc Fail");
|
||||
return ret;
|
||||
}
|
||||
ret = CheckParaAttr(attrs);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("CheckParaAttr Fail");
|
||||
return ret;
|
||||
}
|
||||
int32_t formatValue = -1;
|
||||
ret = AttrFormatToBit(attrs, &formatValue);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGE("AttrFormatToBit Fail");
|
||||
return ret;
|
||||
}
|
||||
if (attrs->channelCount == 0) {
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
hwCapture->captureParam.captureMode.hwInfo.deviceDescript = *desc;
|
||||
hwCapture->captureParam.frameCaptureMode.attrs = *attrs;
|
||||
hwCapture->captureParam.captureMode.ctlParam.audioGain.gainMax = GAIN_MAX; // init gainMax
|
||||
hwCapture->captureParam.captureMode.ctlParam.audioGain.gainMin = 0;
|
||||
hwCapture->captureParam.frameCaptureMode.frames = 0;
|
||||
hwCapture->captureParam.frameCaptureMode.time.tvNSec = 0;
|
||||
hwCapture->captureParam.frameCaptureMode.time.tvSec = 0;
|
||||
hwCapture->captureParam.frameCaptureMode.byteRate = DEFAULT_RENDER_SAMPLING_RATE;
|
||||
hwCapture->captureParam.frameCaptureMode.periodSize = DEEP_BUFFER_RENDER_PERIOD_SIZE;
|
||||
hwCapture->captureParam.frameCaptureMode.periodCount = DEEP_BUFFER_RENDER_PERIOD_COUNT;
|
||||
hwCapture->captureParam.frameCaptureMode.attrs.period = attrs->period;
|
||||
hwCapture->captureParam.frameCaptureMode.attrs.frameSize = attrs->frameSize;
|
||||
hwCapture->captureParam.frameCaptureMode.attrs.startThreshold = attrs->startThreshold;
|
||||
hwCapture->captureParam.frameCaptureMode.attrs.stopThreshold = attrs->stopThreshold;
|
||||
hwCapture->captureParam.frameCaptureMode.attrs.silenceThreshold = attrs->silenceThreshold;
|
||||
hwCapture->captureParam.frameCaptureMode.attrs.isBigEndian = attrs->isBigEndian;
|
||||
hwCapture->captureParam.frameCaptureMode.attrs.isSignedData = attrs->isSignedData;
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
AudioFormat g_formatIdZero = AUDIO_FORMAT_TYPE_PCM_16_BIT;
|
||||
int32_t InitForGetPortCapability(struct AudioPort portIndex, struct AudioPortCapability *capabilityIndex)
|
||||
{
|
||||
@@ -346,6 +413,11 @@ void AudioReleaseRenderHandle(struct AudioHwRender *hwRender)
|
||||
return;
|
||||
}
|
||||
|
||||
void AudioReleaseCaptureHandle(struct AudioHwCapture *hwCapture)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int32_t AudioAdapterCreateRenderPre(struct AudioHwRender *hwRender, const struct AudioDeviceDescriptor *desc,
|
||||
const struct AudioSampleAttributes *attrs, const struct AudioHwAdapter *hwAdapter)
|
||||
{
|
||||
@@ -383,6 +455,38 @@ int32_t AudioAdapterCreateRenderPre(struct AudioHwRender *hwRender, const struct
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t AudioAdapterCreateCapturePre(struct AudioHwCapture *hwCapture, const struct AudioDeviceDescriptor *desc,
|
||||
const struct AudioSampleAttributes *attrs, const struct AudioHwAdapter *hwAdapter)
|
||||
{
|
||||
HDF_LOGD("%s", __func__);
|
||||
if (hwAdapter == nullptr || hwCapture == nullptr || desc == nullptr || attrs == nullptr) {
|
||||
HDF_LOGE("Pointer is null!");
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
if (InitHwCaptureParam(hwCapture, desc, attrs) < 0) {
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
if (GetAudioCaptureFunc(hwCapture, hwAdapter->adapterDescriptor.adapterName) < 0) {
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
if (hwAdapter->adapterDescriptor.adapterName == nullptr) {
|
||||
HDF_LOGE("pointer is null!");
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
uint32_t adapterNameLen = strlen(hwAdapter->adapterDescriptor.adapterName);
|
||||
if (adapterNameLen == 0) {
|
||||
HDF_LOGE("adapterNameLen is null!");
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
int32_t ret = strncpy_s(hwCapture->captureParam.captureMode.hwInfo.adapterName, NAME_LEN - 1,
|
||||
hwAdapter->adapterDescriptor.adapterName, adapterNameLen);
|
||||
if (ret != EOK) {
|
||||
HDF_LOGE("copy fail");
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t AudioAdapterCreateRender(struct AudioAdapter *adapter, const struct AudioDeviceDescriptor *desc,
|
||||
const struct AudioSampleAttributes *attrs, struct AudioRender **render)
|
||||
{
|
||||
@@ -410,6 +514,33 @@ int32_t AudioAdapterCreateRender(struct AudioAdapter *adapter, const struct Audi
|
||||
return AUDIO_HAL_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t AudioAdapterCreateCapture(struct AudioAdapter *adapter, const struct AudioDeviceDescriptor *desc,
|
||||
const struct AudioSampleAttributes *attrs, struct AudioCapture **capture)
|
||||
{
|
||||
struct AudioHwAdapter *hwAdapter = reinterpret_cast<struct AudioHwAdapter *>(adapter);
|
||||
if (hwAdapter == nullptr || desc == nullptr || attrs == nullptr || capture == nullptr) {
|
||||
return AUDIO_HAL_ERR_INVALID_PARAM;
|
||||
}
|
||||
if (hwAdapter->adapterMgrCaptureFlag > 0) {
|
||||
HDF_LOGE("Create capture repeatedly!");
|
||||
return AUDIO_HAL_ERR_INTERNAL;
|
||||
}
|
||||
struct AudioHwCapture *hwCapture = reinterpret_cast<struct AudioHwCapture *>(calloc(1, sizeof(*hwCapture)));
|
||||
if (hwCapture == nullptr) {
|
||||
HDF_LOGE("hwCapture is NULL!");
|
||||
return AUDIO_HAL_ERR_MALLOC_FAIL;
|
||||
}
|
||||
int32_t ret = AudioAdapterCreateCapturePre(hwCapture, desc, attrs, hwAdapter);
|
||||
if (ret != 0) {
|
||||
HDF_LOGE("AudioAdapterCreateCapturePre fail");
|
||||
AudioMemFree(reinterpret_cast<void **>(&hwCapture));
|
||||
return AUDIO_HAL_ERR_INTERNAL;
|
||||
}
|
||||
hwAdapter->adapterMgrCaptureFlag++;
|
||||
*capture = &hwCapture->common;
|
||||
return AUDIO_HAL_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t AudioAdapterDestroyRender(struct AudioAdapter *adapter, struct AudioRender *render)
|
||||
{
|
||||
HDF_LOGI("enter");
|
||||
@@ -438,6 +569,26 @@ int32_t AudioAdapterDestroyRender(struct AudioAdapter *adapter, struct AudioRend
|
||||
return AUDIO_HAL_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t AudioAdapterDestroyCapture(struct AudioAdapter *adapter, struct AudioCapture *capture)
|
||||
{
|
||||
HDF_LOGI("enter");
|
||||
struct AudioHwAdapter *hwAdapter = reinterpret_cast<struct AudioHwAdapter *>(adapter);
|
||||
if (hwAdapter == nullptr || capture == nullptr) {
|
||||
return AUDIO_HAL_ERR_INVALID_PARAM;
|
||||
}
|
||||
if (hwAdapter->adapterMgrRenderFlag > 0) {
|
||||
hwAdapter->adapterMgrRenderFlag--;
|
||||
}
|
||||
struct AudioHwCapture *hwCapture = reinterpret_cast<struct AudioHwCapture *>(capture);
|
||||
if (hwCapture == nullptr) {
|
||||
return AUDIO_HAL_ERR_INTERNAL;
|
||||
}
|
||||
AudioReleaseCaptureHandle(hwCapture);
|
||||
AudioMemFree(reinterpret_cast<void **>(&capture));
|
||||
HDF_LOGI("AudioAdapterDestroyCapture cleaned.");
|
||||
return AUDIO_HAL_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t AudioAdapterGetPortCapability(struct AudioAdapter *adapter, const struct AudioPort *port,
|
||||
struct AudioPortCapability *capability)
|
||||
{
|
||||
|
||||
@@ -56,6 +56,14 @@ StopPlayingFunc fastStopPlayingFunc;
|
||||
ReqMmapBufferFunc fastReqMmapBufferFunc;
|
||||
ReadMmapPositionFunc fastReadMmapPositionFunc;
|
||||
GetLatencyFunc fastGetLatencyFunc;
|
||||
|
||||
SetUpFunc setUpCaptureFunc;
|
||||
TearDownFunc tearDownCaptureFunc;
|
||||
GetStateFunc getCaptureStateFunc;
|
||||
StartCaptureFunc startCaptureFunc;
|
||||
SuspendPlayingFunc suspendCaptureFunc;
|
||||
StopPlayingFunc stopCaptureFunc;
|
||||
ReadFrameFunc readFrameFunc;
|
||||
#endif
|
||||
|
||||
sptr<IBluetoothA2dpSrc> g_proxy_ = nullptr;
|
||||
@@ -230,6 +238,14 @@ static bool InitAudioDeviceSoHandle(const char *path)
|
||||
GET_SYM_ERRPR_RET(
|
||||
g_ptrAudioDeviceHandle, ReadMmapPositionFunc, fastReadMmapPositionFunc, "FastReadMmapPosition");
|
||||
GET_SYM_ERRPR_RET(g_ptrAudioDeviceHandle, GetLatencyFunc, fastGetLatencyFunc, "FastGetLatency");
|
||||
|
||||
GET_SYM_ERRPR_RET(g_ptrAudioDeviceHandle, SetUpFunc, setUpCaptureFunc, "SetUpCapture");
|
||||
GET_SYM_ERRPR_RET(g_ptrAudioDeviceHandle, TearDownFunc, tearDownCaptureFunc, "TearDownCapture");
|
||||
GET_SYM_ERRPR_RET(g_ptrAudioDeviceHandle, GetStateFunc, getCaptureStateFunc, "GetCaptureState");
|
||||
GET_SYM_ERRPR_RET(g_ptrAudioDeviceHandle, StartCaptureFunc, startCaptureFunc, "StartCapture");
|
||||
GET_SYM_ERRPR_RET(g_ptrAudioDeviceHandle, SuspendPlayingFunc, suspendCaptureFunc, "SuspendCapture");
|
||||
GET_SYM_ERRPR_RET(g_ptrAudioDeviceHandle, StopPlayingFunc, stopCaptureFunc, "StopCapture");
|
||||
GET_SYM_ERRPR_RET(g_ptrAudioDeviceHandle, ReadFrameFunc, readFrameFunc, "ReadFrame");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -247,11 +263,28 @@ bool SetUp()
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool SetUpCapture()
|
||||
{
|
||||
bool ret = InitAudioDeviceSoHandle(g_bluetoothAudioDeviceSoPath);
|
||||
if (ret) {
|
||||
ret = setUpCaptureFunc();
|
||||
}
|
||||
if (!ret) {
|
||||
HDF_LOGE("%{public}s failed!", __func__);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void TearDown()
|
||||
{
|
||||
tearDownFunc();
|
||||
}
|
||||
|
||||
void TearDownCapture()
|
||||
{
|
||||
tearDownCaptureFunc();
|
||||
}
|
||||
|
||||
bool FastSetUp()
|
||||
{
|
||||
bool ret = InitAudioDeviceSoHandle(g_bluetoothAudioDeviceSoPath);
|
||||
@@ -318,6 +351,48 @@ int FastGetLatency(uint32_t &latency)
|
||||
{
|
||||
return (fastGetLatencyFunc(latency) ? HDF_SUCCESS : HDF_FAILURE);
|
||||
}
|
||||
|
||||
int StartCapture()
|
||||
{
|
||||
BTAudioStreamState state = getCaptureStateFunc();
|
||||
if (state != BTAudioStreamState::STARTED) {
|
||||
HDF_LOGE("%{public}s: state=%{public}hhu", __func__, state);
|
||||
if (!startCaptureFunc()) {
|
||||
HDF_LOGE("%{public}s: fail to startPlaying", __func__);
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
}
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
int SuspendCapture()
|
||||
{
|
||||
int ret = 0;
|
||||
BTAudioStreamState state = getCaptureStateFunc();
|
||||
if (state == BTAudioStreamState::STARTED) {
|
||||
ret = suspendCaptureFunc() ? HDF_SUCCESS : HDF_FAILURE;
|
||||
} else {
|
||||
HDF_LOGE("%{public}s: state=%{public}hhu is bad state", __func__, state);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int StopCapture()
|
||||
{
|
||||
BTAudioStreamState state = getCaptureStateFunc();
|
||||
HDF_LOGE("%{public}s: state=%{public}hhu", __func__, state);
|
||||
if (state != BTAudioStreamState::INVALID) {
|
||||
stopCaptureFunc();
|
||||
}
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
int ReadFrame(uint8_t *data, uint64_t size)
|
||||
{
|
||||
HDF_LOGD("%{public}s", __func__);
|
||||
return readFrameFunc(data, size);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
int WriteFrame(const uint8_t *data, uint32_t size, const HDI::Audio_Bluetooth::AudioSampleAttributes *attrs)
|
||||
|
||||
@@ -0,0 +1,125 @@
|
||||
/*
|
||||
* 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 <hdf_log.h>
|
||||
#include "audio_internal.h"
|
||||
#include "audio_adapter_info_common.h"
|
||||
#include "audio_bluetooth_manager.h"
|
||||
#include "audio_capture.h"
|
||||
namespace OHOS::HDI::Audio_Bluetooth {
|
||||
int32_t AudioCaptureStart(AudioHandle handle)
|
||||
{
|
||||
HDF_LOGI("%{public}s enter", __func__);
|
||||
#ifdef A2DP_HDI_SERVICE
|
||||
auto *hwCapture = reinterpret_cast<struct AudioHwCapture *>(handle);
|
||||
if (hwCapture == nullptr) {
|
||||
return AUDIO_HAL_ERR_INVALID_PARAM;
|
||||
}
|
||||
return OHOS::Bluetooth::StartCapture();
|
||||
#endif
|
||||
return AUDIO_HAL_ERR_NOT_SUPPORT;
|
||||
}
|
||||
|
||||
int32_t AudioCaptureStop(AudioHandle handle)
|
||||
{
|
||||
HDF_LOGI("%{public}s enter", __func__);
|
||||
#ifdef A2DP_HDI_SERVICE
|
||||
auto *hwCapture = reinterpret_cast<struct AudioHwCapture *>(handle);
|
||||
if (hwCapture == nullptr) {
|
||||
return AUDIO_HAL_ERR_INVALID_PARAM;
|
||||
}
|
||||
OHOS::Bluetooth::StopCapture();
|
||||
hwCapture->captureParam.captureMode.ctlParam.pause = false;
|
||||
return AUDIO_HAL_SUCCESS;
|
||||
#endif
|
||||
return AUDIO_HAL_ERR_NOT_SUPPORT;
|
||||
}
|
||||
|
||||
int32_t AudioCapturePause(AudioHandle handle)
|
||||
{
|
||||
HDF_LOGI("%{public}s enter", __func__);
|
||||
#ifdef A2DP_HDI_SERVICE
|
||||
auto *hwCapture = reinterpret_cast<struct AudioHwCapture *>(handle);
|
||||
if (hwCapture == nullptr) {
|
||||
return AUDIO_HAL_ERR_INVALID_PARAM;
|
||||
}
|
||||
if (hwCapture->captureParam.captureMode.ctlParam.pause) {
|
||||
HDF_LOGE("Audio is already pause");
|
||||
return AUDIO_HAL_ERR_NOT_SUPPORT;
|
||||
}
|
||||
OHOS::Bluetooth::StopCapture();
|
||||
hwCapture->captureParam.captureMode.ctlParam.pause = true;
|
||||
return AUDIO_HAL_SUCCESS;
|
||||
#endif
|
||||
return AUDIO_HAL_ERR_NOT_SUPPORT;
|
||||
}
|
||||
|
||||
int32_t AudioCaptureResume(AudioHandle handle)
|
||||
{
|
||||
HDF_LOGI("%{public}s enter", __func__);
|
||||
#ifdef A2DP_HDI_SERVICE
|
||||
auto *hwCapture = reinterpret_cast<struct AudioHwCapture *>(handle);
|
||||
if (hwCapture == nullptr) {
|
||||
return AUDIO_HAL_ERR_INVALID_PARAM;
|
||||
}
|
||||
if (!hwCapture->captureParam.captureMode.ctlParam.pause) {
|
||||
HDF_LOGE("Audio is already Resume");
|
||||
return AUDIO_HAL_ERR_NOT_SUPPORT;
|
||||
}
|
||||
OHOS::Bluetooth::StartCapture();
|
||||
hwCapture->captureParam.captureMode.ctlParam.pause = false;
|
||||
return AUDIO_HAL_SUCCESS;
|
||||
#endif
|
||||
return AUDIO_HAL_ERR_NOT_SUPPORT;
|
||||
}
|
||||
|
||||
int32_t AudioCaptureFlush(AudioHandle handle)
|
||||
{
|
||||
HDF_LOGI("%{public}s enter", __func__);
|
||||
auto *hwCapture = reinterpret_cast<struct AudioHwCapture *>(handle);
|
||||
if (hwCapture == nullptr) {
|
||||
return AUDIO_HAL_ERR_INVALID_PARAM;
|
||||
}
|
||||
return AUDIO_HAL_ERR_NOT_SUPPORT;
|
||||
}
|
||||
|
||||
int32_t AudioCaptureSetMute(AudioHandle handle, bool mute)
|
||||
{
|
||||
(void)mute;
|
||||
return AUDIO_HAL_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t AudioCaptureGetMute(AudioHandle handle, bool *mute)
|
||||
{
|
||||
(void)mute;
|
||||
return AUDIO_HAL_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t AudioCaptureCaptureFrame(struct AudioCapture *capture, void *frame, uint64_t requestBytes, uint64_t *replyBytes)
|
||||
{
|
||||
HDF_LOGD("%{public}s enter", __func__);
|
||||
#ifdef A2DP_HDI_SERVICE
|
||||
auto *hwCapture = reinterpret_cast<struct AudioHwCapture *>(capture);
|
||||
if (hwCapture == nullptr || frame == nullptr || replyBytes == nullptr) {
|
||||
HDF_LOGE("Capture Frame Paras is NULL");
|
||||
return AUDIO_HAL_ERR_INVALID_PARAM;
|
||||
}
|
||||
auto *data = reinterpret_cast<uint8_t *>(frame);
|
||||
int32_t ret = OHOS::Bluetooth::ReadFrame(data, requestBytes);
|
||||
*replyBytes = ret;
|
||||
return ret;
|
||||
#endif
|
||||
return AUDIO_HAL_ERR_NOT_SUPPORT;
|
||||
}
|
||||
}
|
||||
@@ -35,6 +35,28 @@ int32_t AudioManagerGetAllAdapters(struct AudioManager *manager,
|
||||
return AUDIO_HAL_SUCCESS;
|
||||
}
|
||||
|
||||
bool SetupBluetoothInterface(struct AudioHwAdapter *hwAdapter, const struct AudioAdapterDescriptor *desc)
|
||||
{
|
||||
#ifndef A2DP_HDI_SERVICE
|
||||
OHOS::Bluetooth::GetProxy();
|
||||
OHOS::Bluetooth::RegisterObserver();
|
||||
return true;
|
||||
#else
|
||||
bool ret = false;
|
||||
if (strcmp(desc->adapterName, "bt_a2dp_fast") == 0) {
|
||||
HDF_LOGI("%{public}s, fast set up", __func__);
|
||||
ret = OHOS::Bluetooth::FastSetUp();
|
||||
} else if (strcmp(desc->adapterName, "bt_hdap") == 0) {
|
||||
HDF_LOGI("%{public}s, hdap set up", __func__);
|
||||
ret = OHOS::Bluetooth::SetUpCapture();
|
||||
} else {
|
||||
HDF_LOGI("%{public}s, normal set up", __func__);
|
||||
ret = OHOS::Bluetooth::SetUp();
|
||||
}
|
||||
return ret;
|
||||
#endif
|
||||
}
|
||||
|
||||
int32_t AudioManagerLoadAdapter(struct AudioManager *manager, const struct AudioAdapterDescriptor *desc,
|
||||
struct AudioAdapter **adapter)
|
||||
{
|
||||
@@ -55,6 +77,8 @@ int32_t AudioManagerLoadAdapter(struct AudioManager *manager, const struct Audio
|
||||
hwAdapter->common.InitAllPorts = AudioAdapterInitAllPorts;
|
||||
hwAdapter->common.CreateRender = AudioAdapterCreateRender;
|
||||
hwAdapter->common.DestroyRender = AudioAdapterDestroyRender;
|
||||
hwAdapter->common.CreateCapture = AudioAdapterCreateCapture;
|
||||
hwAdapter->common.DestroyCapture = AudioAdapterDestroyCapture;
|
||||
hwAdapter->common.GetPortCapability = AudioAdapterGetPortCapability;
|
||||
hwAdapter->common.SetPassthroughMode = AudioAdapterSetPassthroughMode;
|
||||
hwAdapter->common.GetPassthroughMode = AudioAdapterGetPassthroughMode;
|
||||
@@ -63,25 +87,11 @@ int32_t AudioManagerLoadAdapter(struct AudioManager *manager, const struct Audio
|
||||
*adapter = &hwAdapter->common;
|
||||
hwAdapter->adapterDescriptor = *desc;
|
||||
hwAdapter->adapterMgrRenderFlag = 0; // The adapterMgrRenderFlag init is zero
|
||||
|
||||
hwAdapter->adapterMgrCaptureFlag = 0;
|
||||
HDF_LOGI("%s call bluetooth RegisterObserver interface", __func__);
|
||||
#ifndef A2DP_HDI_SERVICE
|
||||
OHOS::Bluetooth::GetProxy();
|
||||
OHOS::Bluetooth::RegisterObserver();
|
||||
#else
|
||||
bool ret = false;
|
||||
if (strcmp(desc->adapterName, "bt_a2dp_fast") == 0) {
|
||||
HDF_LOGI("%{public}s, fast set up", __func__);
|
||||
ret = OHOS::Bluetooth::FastSetUp();
|
||||
} else {
|
||||
HDF_LOGI("%{public}s, normal set up", __func__);
|
||||
ret = OHOS::Bluetooth::SetUp();
|
||||
}
|
||||
if (!ret) {
|
||||
if (!SetupBluetoothInterface(hwAdapter, desc)) {
|
||||
return AUDIO_HAL_ERR_INTERNAL;
|
||||
}
|
||||
#endif
|
||||
|
||||
return AUDIO_HAL_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -93,6 +103,7 @@ void AudioManagerUnloadAdapter(struct AudioManager *manager, struct AudioAdapter
|
||||
}
|
||||
#ifdef A2DP_HDI_SERVICE
|
||||
bool isFastAdapter = (strcmp(hwAdapter->adapterDescriptor.adapterName, "bt_a2dp_fast") == 0);
|
||||
bool isHdapAdapter = (strcmp(hwAdapter->adapterDescriptor.adapterName, "bt_hdap") == 0);
|
||||
#endif
|
||||
if (hwAdapter->portCapabilitys != NULL) {
|
||||
int32_t portNum = hwAdapter->adapterDescriptor.portNum;
|
||||
@@ -113,6 +124,8 @@ void AudioManagerUnloadAdapter(struct AudioManager *manager, struct AudioAdapter
|
||||
#else
|
||||
if (isFastAdapter) {
|
||||
OHOS::Bluetooth::FastTearDown();
|
||||
} else if (isHdapAdapter) {
|
||||
OHOS::Bluetooth::TearDownCapture();
|
||||
} else {
|
||||
OHOS::Bluetooth::TearDown();
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
|
||||
#include "audio_types.h"
|
||||
#include "audio_render.h"
|
||||
#include "audio_capture.h"
|
||||
namespace OHOS::HDI::Audio_Bluetooth {
|
||||
/**
|
||||
* @brief Provides audio adapter capabilities, including initializing ports, creating rendering and capturing tasks,
|
||||
@@ -76,6 +77,21 @@ struct AudioAdapter {
|
||||
int32_t (*CreateRender)(struct AudioAdapter *adapter, const struct AudioDeviceDescriptor *desc,
|
||||
const struct AudioSampleAttributes *attrs, struct AudioRender **render);
|
||||
|
||||
/**
|
||||
* @brief Creates an <b>AudioCapture</b> object.
|
||||
*
|
||||
* @param adapter Indicates the pointer to the audio adapter to operate.
|
||||
* @param desc Indicates the pointer to the descriptor of the audio adapter to start.
|
||||
* @param attrs Indicates the pointer to the audio sampling attributes to open.
|
||||
* @param capture Indicates the double pointer to the <b>AudioCapture</b> object.
|
||||
* @return Returns <b>0</b> if the <b>AudioCapture</b> object is created successfully;
|
||||
* returns a negative value otherwise.
|
||||
* @see GetPortCapability
|
||||
* @see DestroyCapture
|
||||
*/
|
||||
int32_t (*CreateCapture)(struct AudioAdapter *adapter, const struct AudioDeviceDescriptor *desc,
|
||||
const struct AudioSampleAttributes *attrs, struct AudioCapture **capture);
|
||||
|
||||
/**
|
||||
* @brief Destroys an <b>AudioRender</b> object.
|
||||
*
|
||||
@@ -88,6 +104,18 @@ struct AudioAdapter {
|
||||
*/
|
||||
int32_t (*DestroyRender)(struct AudioAdapter *adapter, struct AudioRender *render);
|
||||
|
||||
/**
|
||||
* @brief Destroys an <b>AudioCapture</b> object.
|
||||
*
|
||||
* @attention Do not destroy the object during audio capturing.
|
||||
*
|
||||
* @param adapter Indicates the pointer to the audio adapter to operate.
|
||||
* @param capture Indicates the pointer to the <b>AudioCapture</b> object to operate.
|
||||
* @return Returns <b>0</b> if the <b>AudioCapture</b> object is destroyed; returns a negative value otherwise.
|
||||
* @see CreateCapture
|
||||
*/
|
||||
int32_t (*DestroyCapture)(struct AudioAdapter *adapter, struct AudioCapture *capture);
|
||||
|
||||
/**
|
||||
* @brief Obtains the capability set of the port driver for the audio adapter.
|
||||
*
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright (c) 2024 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup Audio
|
||||
* @{
|
||||
*
|
||||
* @brief Defines audio-related APIs, including custom data types and functions for loading drivers,
|
||||
* accessing a driver adapter, and rendering and capturing audios.
|
||||
*
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file audio_capture.h
|
||||
*
|
||||
* @brief Declares APIs for audio capturing.
|
||||
*
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
#ifndef AUDIO_CAPTURE_H
|
||||
#define AUDIO_CAPTURE_H
|
||||
|
||||
#include "audio_control.h"
|
||||
#include "audio_volume.h"
|
||||
namespace OHOS::HDI::Audio_Bluetooth {
|
||||
/**
|
||||
* @brief Provides capabilities for audio capturing, including controlling the capturing, setting audio attributes,
|
||||
* scenes, and volume, obtaining hardware latency, and capturing audio frames.
|
||||
*
|
||||
* @see AudioControl
|
||||
* @see AudioAttribute
|
||||
* @since 1.0
|
||||
* @version 1.0
|
||||
*/
|
||||
struct AudioCapture {
|
||||
/**
|
||||
* @brief Defines the audio control. For details, see {@link AudioControl}.
|
||||
*/
|
||||
struct AudioControl control;
|
||||
/**
|
||||
* @brief Defines audio volume. For details, see {@link AudioVolume}.
|
||||
*/
|
||||
struct AudioVolume volume;
|
||||
|
||||
/**
|
||||
* @brief Reads a frame of intput data (uplink data) into the audio driver for capturing.
|
||||
*
|
||||
* @param capture Indicates the pointer to the <b>AudioCapture</b> object to operate.
|
||||
* @param frame Indicates the pointer to the frame to read.
|
||||
* @param requestBytes Indicates the size of the frame, in bytes.
|
||||
* @param replyBytes Indicates the pointer to the actual length (in bytes) of the audio data to read.
|
||||
* @return Returns <b>0</b> if the data is read successfully; returns a negative value otherwise.
|
||||
*/
|
||||
int32_t (*CaptureFrame)(struct AudioCapture *capture, void *frame, uint64_t requestBytes, uint64_t *replyBytes);
|
||||
};
|
||||
}
|
||||
#endif
|
||||
@@ -41,6 +41,7 @@
|
||||
"header_files": [
|
||||
"interfaces/include/audio_adapter.h",
|
||||
"interfaces/include/audio_attribute.h",
|
||||
"interfaces/include/audio_capture.h",
|
||||
"interfaces/include/audio_control.h",
|
||||
"interfaces/include/audio_manager.h",
|
||||
"interfaces/include/audio_render.h",
|
||||
|
||||
@@ -72,6 +72,9 @@ int32_t HciInterfaceImpl::Init(const sptr<IHciCallback>& callbackObj)
|
||||
.onEventReceive =
|
||||
[callbackObj](
|
||||
const std::vector<uint8_t> &packet) { callbackObj->OnReceivedHciPacket(BtType::HCI_EVENT, packet); },
|
||||
.onIsoReceive =
|
||||
[callbackObj](
|
||||
const std::vector<uint8_t> &packet) { callbackObj->OnReceivedHciPacket(BtType::ISO_DATA, packet); },
|
||||
};
|
||||
|
||||
bool result = VendorInterface::GetInstance()->Initialize(
|
||||
|
||||
@@ -19,6 +19,9 @@
|
||||
#include <cstring>
|
||||
|
||||
#include <hdf_log.h>
|
||||
#include <sys/types.h>
|
||||
#include <syscall.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#ifdef LOG_DOMAIN
|
||||
#undef LOG_DOMAIN
|
||||
@@ -29,13 +32,34 @@ namespace OHOS {
|
||||
namespace HDI {
|
||||
namespace Bluetooth {
|
||||
namespace Hci {
|
||||
const int32_t RT_PRIORITY = 1;
|
||||
|
||||
H4Protocol::H4Protocol(
|
||||
int fd, HciDataCallback onAclReceive, HciDataCallback onScoReceive, HciDataCallback onEventReceive)
|
||||
: hciFd_(fd), onAclReceive_(onAclReceive), onScoReceive_(onScoReceive), onEventReceive_(onEventReceive)
|
||||
int fd, HciDataCallback onAclReceive, HciDataCallback onScoReceive, HciDataCallback onEventReceive,
|
||||
HciDataCallback onIsoReceive) : hciFd_(fd), onAclReceive_(onAclReceive), onScoReceive_(onScoReceive),
|
||||
onEventReceive_(onEventReceive), onIsoReceive_(onIsoReceive)
|
||||
{}
|
||||
|
||||
void H4Protocol::SetRTSchedule()
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(tidMutex_);
|
||||
pid_t tid = gettid();
|
||||
auto it = tidMap_.find(tid);
|
||||
if (it == tidMap_.end()) {
|
||||
struct sched_param rtParams = {.sched_priority = RT_PRIORITY};
|
||||
int rc = sched_setscheduler(tid, SCHED_FIFO, &rtParams);
|
||||
if (rc != 0) {
|
||||
HDF_LOGE("set tid rt fail.");
|
||||
tidMap_[tid] = false;
|
||||
} else {
|
||||
tidMap_[tid] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ssize_t H4Protocol::SendPacket(HciPacketType packetType, const std::vector<uint8_t> &packetData)
|
||||
{
|
||||
SetRTSchedule();
|
||||
uint8_t type = packetType;
|
||||
ssize_t writtenNumber = 0;
|
||||
|
||||
@@ -117,6 +141,7 @@ H4Protocol::~H4Protocol() {}
|
||||
|
||||
void H4Protocol::PacketCallback()
|
||||
{
|
||||
SetRTSchedule();
|
||||
switch (packetType_) {
|
||||
case HCI_PACKET_TYPE_ACL_DATA:
|
||||
if (onAclReceive_) {
|
||||
@@ -133,8 +158,13 @@ void H4Protocol::PacketCallback()
|
||||
onEventReceive_(hciPacket_);
|
||||
}
|
||||
break;
|
||||
case HCI_PACKET_TYPE_ISO_DATA:
|
||||
if (onIsoReceive_) {
|
||||
onIsoReceive_(hciPacket_);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
HDF_LOGE("PacketCallback type[%d] error.", packetType_);
|
||||
HDF_LOGE("PacketCallback type[%{public}d] error.", packetType_);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
#define OHOS_HDI_BLUETOOTH_HCI_H4_PROTOCOL_H
|
||||
|
||||
#include "hci_protocol.h"
|
||||
#include <map>
|
||||
#include <mutex>
|
||||
|
||||
namespace OHOS {
|
||||
namespace HDI {
|
||||
@@ -24,7 +26,8 @@ namespace Bluetooth {
|
||||
namespace Hci {
|
||||
class H4Protocol : public HciProtocol {
|
||||
public:
|
||||
H4Protocol(int fd, HciDataCallback onAclReceive, HciDataCallback onScoReceive, HciDataCallback onEventReceive);
|
||||
H4Protocol(int fd, HciDataCallback onAclReceive, HciDataCallback onScoReceive, HciDataCallback onEventReceive,
|
||||
HciDataCallback onIsoReceive);
|
||||
|
||||
ssize_t SendPacket(HciPacketType packetType, const std::vector<uint8_t> &packetData) override;
|
||||
void ReadData(int fd);
|
||||
@@ -32,12 +35,16 @@ public:
|
||||
|
||||
private:
|
||||
void PacketCallback();
|
||||
void SetRTSchedule();
|
||||
|
||||
private:
|
||||
int hciFd_ = 0;
|
||||
HciDataCallback onAclReceive_;
|
||||
HciDataCallback onScoReceive_;
|
||||
HciDataCallback onEventReceive_;
|
||||
HciDataCallback onIsoReceive_;
|
||||
std::mutex tidMutex_;
|
||||
std::map<pid_t, bool> tidMap_;
|
||||
|
||||
uint8_t packetType_ = 0;
|
||||
std::vector<uint8_t> hciPacket_;
|
||||
|
||||
@@ -26,6 +26,7 @@ enum HciPacketType : uint8_t {
|
||||
HCI_PACKET_TYPE_ACL_DATA = 2,
|
||||
HCI_PACKET_TYPE_SCO_DATA = 3,
|
||||
HCI_PACKET_TYPE_EVENT = 4,
|
||||
HCI_PACKET_TYPE_ISO_DATA = 5,
|
||||
HCI_PACKET_TYPE_MAX,
|
||||
};
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ const PacketHeader HciProtocol::header_[HCI_PACKET_TYPE_MAX] = {
|
||||
{.headerSize = 4, .dataLengthOffset = 2, .dataLengthSize = 2}, /* HCI_PACKET_TYPE_ACL_DATA */
|
||||
{.headerSize = 3, .dataLengthOffset = 2, .dataLengthSize = 1}, /* HCI_PACKET_TYPE_SCO_DATA */
|
||||
{.headerSize = 2, .dataLengthOffset = 1, .dataLengthSize = 1}, /* HCI_PACKET_TYPE_EVENT */
|
||||
{.headerSize = 4, .dataLengthOffset = 2, .dataLengthSize = 2}, /* HCI_PACKET_TYPE_ISO_DATA */
|
||||
};
|
||||
|
||||
const PacketHeader &HciProtocol::GetPacketHeaderInfo(HciPacketType packetType)
|
||||
|
||||
@@ -69,7 +69,8 @@ bool VendorInterface::WatchHciChannel(const ReceiveCallback &receiveCallback)
|
||||
auto h4 = std::make_shared<Hci::H4Protocol>(channel[0],
|
||||
receiveCallback.onAclReceive,
|
||||
receiveCallback.onScoReceive,
|
||||
std::bind(&VendorInterface::OnEventReceived, this, std::placeholders::_1));
|
||||
std::bind(&VendorInterface::OnEventReceived, this, std::placeholders::_1),
|
||||
receiveCallback.onIsoReceive);
|
||||
watcher_.AddFdToWatcher(channel[0], std::bind(&Hci::H4Protocol::ReadData, h4, std::placeholders::_1));
|
||||
hci_ = h4;
|
||||
} else {
|
||||
|
||||
@@ -39,6 +39,7 @@ public:
|
||||
ReceiveDataCallback onAclReceive;
|
||||
ReceiveDataCallback onScoReceive;
|
||||
ReceiveDataCallback onEventReceive;
|
||||
ReceiveDataCallback onIsoReceive;
|
||||
};
|
||||
|
||||
bool Initialize(InitializeCompleteCallback initializeCompleteCallback, const ReceiveCallback &receiveCallback);
|
||||
|
||||
+2
-1
@@ -34,7 +34,8 @@
|
||||
"libexif",
|
||||
"libjpeg-turbo",
|
||||
"ffmpeg",
|
||||
"googletest"
|
||||
"googletest",
|
||||
"hicollie"
|
||||
],
|
||||
"third_party": []
|
||||
},
|
||||
|
||||
@@ -43,6 +43,7 @@ if (defined(ohos_lite)) {
|
||||
"$camera_path/../../interfaces/include",
|
||||
"$camera_path/../../interfaces/hdi_passthrough",
|
||||
"$camera_path/include",
|
||||
"$camera_path/utils/hicollie",
|
||||
"$camera_path/utils/watchdog",
|
||||
"$camera_path/../interfaces",
|
||||
"./include",
|
||||
@@ -101,6 +102,7 @@ if (defined(ohos_lite)) {
|
||||
"$camera_path/../../interfaces/hdi_ipc/callback/device/include",
|
||||
"$camera_path/../../interfaces/hdi_ipc/callback/operator/include",
|
||||
"$camera_path/include",
|
||||
"$camera_path/utils/hicollie",
|
||||
"$camera_path/utils/watchdog",
|
||||
"$camera_path/../interfaces",
|
||||
"./include",
|
||||
@@ -131,8 +133,8 @@ if (defined(ohos_lite)) {
|
||||
"hdf_core:libhdf_ipc_adapter",
|
||||
"hdf_core:libhdf_utils",
|
||||
"hdf_core:libhdi",
|
||||
"hicollie:libhicollie",
|
||||
"hilog:libhilog",
|
||||
"ipc:ipc_single",
|
||||
]
|
||||
} else {
|
||||
external_deps = [ "hilog:libhilog" ]
|
||||
@@ -176,8 +178,8 @@ if (defined(ohos_lite)) {
|
||||
"hdf_core:libhdf_ipc_adapter",
|
||||
"hdf_core:libhdf_utils",
|
||||
"hdf_core:libhdi",
|
||||
"hicollie:libhicollie",
|
||||
"hilog:libhilog",
|
||||
"ipc:ipc_single",
|
||||
]
|
||||
} else {
|
||||
external_deps = [ "hilog:libhilog" ]
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "v1_0/icamera_device_callback.h"
|
||||
#include "v1_0/icamera_device_vdi.h"
|
||||
#include "v1_0/icamera_device_vdi_callback.h"
|
||||
#include "camera_hal_hicollie.h"
|
||||
|
||||
namespace OHOS::Camera {
|
||||
using namespace OHOS::HDI::Camera::V1_0;
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "v1_0/icamera_device.h"
|
||||
#include "v1_0/icamera_host.h"
|
||||
#include "v1_0/icamera_host_vdi.h"
|
||||
#include "camera_hal_hicollie.h"
|
||||
|
||||
namespace OHOS::Camera {
|
||||
#ifdef CHIP_PROD_CAMERA_HOST_CONFIG
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "v1_0/ioffline_stream_operator.h"
|
||||
#include "v1_0/types.h"
|
||||
#include "v1_0/istream_operator_vdi.h"
|
||||
#include "camera_hal_hicollie.h"
|
||||
|
||||
namespace OHOS::Camera {
|
||||
using namespace OHOS::HDI::Camera::V1_0;
|
||||
|
||||
@@ -27,6 +27,7 @@ CameraDeviceService::CameraDeviceService(OHOS::sptr<ICameraDeviceVdi> cameraDevi
|
||||
int32_t CameraDeviceService::GetStreamOperator(const sptr<IStreamOperatorCallback> &callbackObj,
|
||||
sptr<IStreamOperator> &streamOperator)
|
||||
{
|
||||
CameraHalHicollie cameraHalHicollie("CameraHost:GetStreamOperator");
|
||||
OHOS::sptr<IStreamOperatorVdi> streamOperatorVdi = nullptr;
|
||||
CHECK_IF_PTR_NULL_RETURN_VALUE(cameraDeviceServiceVdi_, OHOS::HDI::Camera::V1_0::INVALID_ARGUMENT);
|
||||
OHOS::sptr<IStreamOperatorVdiCallback> vdiCallbackObj = new StreamOperatorServiceCallback(callbackObj);
|
||||
@@ -54,36 +55,42 @@ int32_t CameraDeviceService::GetStreamOperator(const sptr<IStreamOperatorCallbac
|
||||
|
||||
int32_t CameraDeviceService::UpdateSettings(const std::vector<uint8_t> &settings)
|
||||
{
|
||||
CameraHalHicollie cameraHalHicollie("CameraHost:UpdateSettings");
|
||||
CHECK_IF_PTR_NULL_RETURN_VALUE(cameraDeviceServiceVdi_, OHOS::HDI::Camera::V1_0::INVALID_ARGUMENT);
|
||||
return cameraDeviceServiceVdi_->UpdateSettings(settings);
|
||||
}
|
||||
|
||||
int32_t CameraDeviceService::SetResultMode(ResultCallbackMode mode)
|
||||
{
|
||||
CameraHalHicollie cameraHalHicollie("CameraHost:SetResultMode");
|
||||
CHECK_IF_PTR_NULL_RETURN_VALUE(cameraDeviceServiceVdi_, OHOS::HDI::Camera::V1_0::INVALID_ARGUMENT);
|
||||
return cameraDeviceServiceVdi_->SetResultMode(static_cast<VdiResultCallbackMode>(mode));
|
||||
}
|
||||
|
||||
int32_t CameraDeviceService::GetEnabledResults(std::vector<int32_t> &results)
|
||||
{
|
||||
CameraHalHicollie cameraHalHicollie("CameraHost:GetEnabledResults");
|
||||
CHECK_IF_PTR_NULL_RETURN_VALUE(cameraDeviceServiceVdi_, OHOS::HDI::Camera::V1_0::INVALID_ARGUMENT);
|
||||
return cameraDeviceServiceVdi_->GetEnabledResults(results);
|
||||
}
|
||||
|
||||
int32_t CameraDeviceService::EnableResult(const std::vector<int32_t> &results)
|
||||
{
|
||||
CameraHalHicollie cameraHalHicollie("CameraHost:EnableResult");
|
||||
CHECK_IF_PTR_NULL_RETURN_VALUE(cameraDeviceServiceVdi_, OHOS::HDI::Camera::V1_0::INVALID_ARGUMENT);
|
||||
return cameraDeviceServiceVdi_->EnableResult(results);
|
||||
}
|
||||
|
||||
int32_t CameraDeviceService::DisableResult(const std::vector<int32_t> &results)
|
||||
{
|
||||
CameraHalHicollie cameraHalHicollie("CameraHost:DisableResult");
|
||||
CHECK_IF_PTR_NULL_RETURN_VALUE(cameraDeviceServiceVdi_, OHOS::HDI::Camera::V1_0::INVALID_ARGUMENT);
|
||||
return cameraDeviceServiceVdi_->DisableResult(results);
|
||||
}
|
||||
|
||||
int32_t CameraDeviceService::Close()
|
||||
{
|
||||
CameraHalHicollie cameraHalHicollie("CameraHost:Close");
|
||||
CHECK_IF_PTR_NULL_RETURN_VALUE(cameraDeviceServiceVdi_, OHOS::HDI::Camera::V1_0::INVALID_ARGUMENT);
|
||||
return cameraDeviceServiceVdi_->Close();
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ extern "C" ICameraHost *CameraHostServiceGetInstance(void)
|
||||
|
||||
int32_t CameraHostService::GetVdiLibList(std::vector<std::string> &vdiLibList)
|
||||
{
|
||||
CameraHalHicollie cameraHalHicollie("CameraHost:GetVdiLibList");
|
||||
std::vector<std::string>().swap(vdiLibList);
|
||||
ReleaseHcsTree();
|
||||
const struct DeviceResourceIface *pDevResIns = DeviceResourceGetIfaceInstance(HDF_CONFIG_SOURCE);
|
||||
@@ -77,6 +78,7 @@ int32_t CameraHostService::GetVdiLibList(std::vector<std::string> &vdiLibList)
|
||||
|
||||
void CameraHostService::HdfCloseVdiLoaderList(std::vector<struct HdfVdiObject *> &cameraHostVdiLoaderList)
|
||||
{
|
||||
CameraHalHicollie cameraHalHicollie("CameraHost:HdfCloseVdiLoaderList");
|
||||
for (auto cameraHostVdiLoader : cameraHostVdiLoaderList) {
|
||||
if (cameraHostVdiLoader != nullptr) {
|
||||
HdfCloseVdi(cameraHostVdiLoader);
|
||||
@@ -168,6 +170,7 @@ int32_t CameraHostService::SetCallback(const OHOS::sptr<ICameraHostCallback> &ca
|
||||
|
||||
int32_t CameraHostService::GetCameraIds(std::vector<std::string> &cameraIds)
|
||||
{
|
||||
CameraHalHicollie cameraHalHicollie("CameraHost:GetCameraIds");
|
||||
std::vector<std::string>().swap(cameraIds);
|
||||
if (cameraIdInfoList_.size() == 0) {
|
||||
int32_t ret = UpdateCameraIdMapList();
|
||||
|
||||
@@ -36,6 +36,7 @@ StreamOperatorService::~StreamOperatorService()
|
||||
int32_t StreamOperatorService::IsStreamsSupported(OperationMode mode, const std::vector<uint8_t> &modeSetting,
|
||||
const std::vector<StreamInfo> &infos, StreamSupportType &type)
|
||||
{
|
||||
CameraHalHicollie cameraHalHicollie("CameraHost:IsStreamsSupported");
|
||||
CHECK_IF_PTR_NULL_RETURN_VALUE(streamOperatorVdi_, OHOS::HDI::Camera::V1_0::INVALID_ARGUMENT);
|
||||
std::vector<VdiStreamInfo> vdiInfos;
|
||||
for (auto info : infos) {
|
||||
@@ -52,6 +53,7 @@ int32_t StreamOperatorService::IsStreamsSupported(OperationMode mode, const std:
|
||||
|
||||
int32_t StreamOperatorService::CreateStreams(const std::vector<StreamInfo> &streamInfos)
|
||||
{
|
||||
CameraHalHicollie cameraHalHicollie("CameraHost:CreateStreams");
|
||||
CHECK_IF_PTR_NULL_RETURN_VALUE(streamOperatorVdi_, OHOS::HDI::Camera::V1_0::INVALID_ARGUMENT);
|
||||
std::vector<VdiStreamInfo> vdiStreamInfos;
|
||||
for (auto info : streamInfos) {
|
||||
@@ -64,18 +66,21 @@ int32_t StreamOperatorService::CreateStreams(const std::vector<StreamInfo> &stre
|
||||
|
||||
int32_t StreamOperatorService::ReleaseStreams(const std::vector<int32_t> &streamIds)
|
||||
{
|
||||
CameraHalHicollie cameraHalHicollie("CameraHost:ReleaseStreams");
|
||||
CHECK_IF_PTR_NULL_RETURN_VALUE(streamOperatorVdi_, OHOS::HDI::Camera::V1_0::INVALID_ARGUMENT);
|
||||
return streamOperatorVdi_->ReleaseStreams(streamIds);
|
||||
}
|
||||
|
||||
int32_t StreamOperatorService::CommitStreams(OperationMode mode, const std::vector<uint8_t> &modeSetting)
|
||||
{
|
||||
CameraHalHicollie cameraHalHicollie("CameraHost:CommitStreams");
|
||||
CHECK_IF_PTR_NULL_RETURN_VALUE(streamOperatorVdi_, OHOS::HDI::Camera::V1_0::INVALID_ARGUMENT);
|
||||
return streamOperatorVdi_->CommitStreams(static_cast<VdiOperationMode>(mode), modeSetting);
|
||||
}
|
||||
|
||||
int32_t StreamOperatorService::GetStreamAttributes(std::vector<StreamAttribute> &attributes)
|
||||
{
|
||||
CameraHalHicollie cameraHalHicollie("CameraHost:GetStreamAttributes");
|
||||
CHECK_IF_PTR_NULL_RETURN_VALUE(streamOperatorVdi_, OHOS::HDI::Camera::V1_0::INVALID_ARGUMENT);
|
||||
std::vector<VdiStreamAttribute> vdiAttributes;
|
||||
for (auto attribute : attributes) {
|
||||
@@ -96,18 +101,21 @@ int32_t StreamOperatorService::GetStreamAttributes(std::vector<StreamAttribute>
|
||||
int32_t StreamOperatorService::AttachBufferQueue(int32_t streamId,
|
||||
const sptr<BufferProducerSequenceable> &bufferProducer)
|
||||
{
|
||||
CameraHalHicollie cameraHalHicollie("CameraHost:AttachBufferQueue");
|
||||
CHECK_IF_PTR_NULL_RETURN_VALUE(streamOperatorVdi_, OHOS::HDI::Camera::V1_0::INVALID_ARGUMENT);
|
||||
return streamOperatorVdi_->AttachBufferQueue(streamId, bufferProducer);
|
||||
}
|
||||
|
||||
int32_t StreamOperatorService::DetachBufferQueue(int32_t streamId)
|
||||
{
|
||||
CameraHalHicollie cameraHalHicollie("CameraHost:DetachBufferQueue");
|
||||
CHECK_IF_PTR_NULL_RETURN_VALUE(streamOperatorVdi_, OHOS::HDI::Camera::V1_0::INVALID_ARGUMENT);
|
||||
return streamOperatorVdi_->DetachBufferQueue(streamId);
|
||||
}
|
||||
|
||||
int32_t StreamOperatorService::Capture(int32_t captureId, const CaptureInfo &info, bool isStreaming)
|
||||
{
|
||||
CameraHalHicollie cameraHalHicollie("CameraHost:Capture");
|
||||
CAMERAHALPERFSYSEVENT(TIME_FOR_CAPTURE);
|
||||
CHECK_IF_PTR_NULL_RETURN_VALUE(streamOperatorVdi_, OHOS::HDI::Camera::V1_0::INVALID_ARGUMENT);
|
||||
VdiCaptureInfo vdiInfo;
|
||||
@@ -117,6 +125,7 @@ int32_t StreamOperatorService::Capture(int32_t captureId, const CaptureInfo &inf
|
||||
|
||||
int32_t StreamOperatorService::CancelCapture(int32_t captureId)
|
||||
{
|
||||
CameraHalHicollie cameraHalHicollie("CameraHost:CancelCapture");
|
||||
CHECK_IF_PTR_NULL_RETURN_VALUE(streamOperatorVdi_, OHOS::HDI::Camera::V1_0::INVALID_ARGUMENT);
|
||||
return streamOperatorVdi_->CancelCapture(captureId);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ import("//build/test.gni")
|
||||
import("../../../camera.gni")
|
||||
|
||||
# NOSORT
|
||||
import("$hdf_core_path/adapter/uhdf2/uhdf.gni")
|
||||
module_output_path = "drivers_peripheral_camera/camera"
|
||||
|
||||
config("hdf_camera_benchmark_test_config") {
|
||||
@@ -42,19 +41,11 @@ ohos_benchmarktest("hdf_camera_benchmark_test") {
|
||||
include_dirs = [
|
||||
"./include/",
|
||||
"$camera_common_path/v1_0/include/",
|
||||
"//third_party/googletest/googletest/include",
|
||||
"$camera_path/../../../display/interfaces/include",
|
||||
"$camera_path/../../../display/hdi_service/gralloc/include",
|
||||
"$camera_path/../../interfaces/include",
|
||||
"$camera_path/include",
|
||||
]
|
||||
|
||||
deps = [
|
||||
"//third_party/benchmark",
|
||||
"//third_party/googletest:gmock_main",
|
||||
"//third_party/googletest:gtest",
|
||||
"//third_party/googletest:gtest_main",
|
||||
]
|
||||
deps = []
|
||||
|
||||
if (is_standard_system) {
|
||||
external_deps = [
|
||||
@@ -68,8 +59,12 @@ ohos_benchmarktest("hdf_camera_benchmark_test") {
|
||||
external_deps = [ "hilog:libhilog" ]
|
||||
}
|
||||
external_deps += [
|
||||
"benchmark:benchmark",
|
||||
"drivers_interface_camera:libbuffer_producer_sequenceable_1.0",
|
||||
"drivers_interface_camera:metadata",
|
||||
"googletest:gmock_main",
|
||||
"googletest:gtest",
|
||||
"googletest:gtest_main",
|
||||
"graphic_surface:surface",
|
||||
"samgr:samgr_proxy",
|
||||
]
|
||||
|
||||
@@ -34,22 +34,6 @@ void CameraBenchmarkSecureStreamTest::TearDown(const ::benchmark::State &state)
|
||||
cameraTest->Close();
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: OpenSecureCamera
|
||||
* @tc.desc: benchmark
|
||||
* @tc.level: Level0
|
||||
* @tc.size: MediumTest
|
||||
* @tc.type: Function
|
||||
*/
|
||||
BENCHMARK_F(CameraBenchmarkSecureStreamTest, OpenSecureCamera_benchmark_001)(
|
||||
benchmark::State &st)
|
||||
{
|
||||
for (auto _ : st) {
|
||||
}
|
||||
}
|
||||
BENCHMARK_REGISTER_F(CameraBenchmarkSecureStreamTest, OpenSecureCamera_benchmark_001)->\
|
||||
Iterations(ITERATION_FREQUENCY)->Repetitions(REPETITION_FREQUENCY)->ReportAggregatesOnly();
|
||||
|
||||
/**
|
||||
* @tc.name: GetSecureCameraSeq
|
||||
* @tc.desc: benchmark
|
||||
|
||||
@@ -48,8 +48,8 @@ public:
|
||||
OHOS::sptr<OHOS::HDI::Camera::V1_3::IStreamOperator> streamOperator_V1_3 = nullptr;
|
||||
std::shared_ptr<OHOS::HDI::Camera::V1_1::StreamInfo_V1_1> streamInfoMeta = nullptr;
|
||||
int streamIdMeta = 106;
|
||||
int metaWidth = 1280;
|
||||
int metaHeight = 960;
|
||||
int metaWidth = 1920;
|
||||
int metaHeight = 1080;
|
||||
int captureIdMeta = 2060;
|
||||
uint32_t itemCapacity = 100;
|
||||
uint32_t dataCapacity = 2000;
|
||||
|
||||
@@ -87,7 +87,6 @@ if (defined(ohos_lite)) {
|
||||
}
|
||||
} else {
|
||||
import("//build/ohos.gni")
|
||||
import("../../../../hdf_core/adapter/uhdf2/uhdf.gni")
|
||||
|
||||
config("ohos_camera_demo_config") {
|
||||
visibility = [ ":*" ]
|
||||
|
||||
@@ -45,5 +45,6 @@ HWTEST_F(CameraExampleVendorTagsTest, Camera_Example_Vendor_Tags_001, TestSize.L
|
||||
auto cameraVendorTagExample = std::make_shared<OHOS::Camera::CameraVendorTagExample>();
|
||||
std::vector<vendorTag_t> tagVec {};
|
||||
cameraVendorTagExample->GetAllVendorTags(tagVec);
|
||||
cameraVendorTagExample->GetVendorTagCount();
|
||||
int ret = (int)cameraVendorTagExample->GetVendorTagCount();
|
||||
EXPECT_EQ(true, ret != -1);
|
||||
}
|
||||
@@ -114,19 +114,6 @@ HWTEST_F(CameraMetadataInfoTest, Camera_Metedate_Info_004, TestSize.Level1)
|
||||
EXPECT_NE(header2, nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: Camera_Metedate_Info_005
|
||||
* @tc.desc: dst = nullptr
|
||||
* @tc.size: MediumTest
|
||||
* @tc.type: Function
|
||||
*/
|
||||
HWTEST_F(CameraMetadataInfoTest, Camera_Metedate_Info_005, TestSize.Level1)
|
||||
{
|
||||
printf("CameraMetadataInfoTest Camera_Metedate_Info_005 start...\n");
|
||||
FreeCameraMetadataBuffer(nullptr);
|
||||
ASSERT_EQ(1, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: Camera_Metedate_Info_006
|
||||
* @tc.desc: dst = nullptr, item = 131071
|
||||
|
||||
@@ -72,7 +72,7 @@ HWTEST_F(CameraHdiSequenceableTest, MapDataSequencebleTest_01, TestSize.Level1)
|
||||
EXPECT_EQ(ret, 0);
|
||||
ret = mapDataSequenceable->Get("doubleTemp", doubleTemp1);
|
||||
EXPECT_EQ(ret, 0);
|
||||
EXPECT_EQ(doubleTemp0, doubleTemp0);
|
||||
EXPECT_EQ(doubleTemp1, doubleTemp0);
|
||||
|
||||
string stringTemp0 = "s1234.5678";
|
||||
string stringTemp1 = "0";
|
||||
@@ -80,7 +80,7 @@ HWTEST_F(CameraHdiSequenceableTest, MapDataSequencebleTest_01, TestSize.Level1)
|
||||
EXPECT_EQ(ret, 0);
|
||||
ret = mapDataSequenceable->Get("stringTemp", stringTemp1);
|
||||
EXPECT_EQ(ret, 0);
|
||||
EXPECT_EQ(stringTemp0, stringTemp0);
|
||||
EXPECT_EQ(stringTemp1, stringTemp0);
|
||||
|
||||
// Marshalling and Unmarshalling Test
|
||||
Parcel parcel;
|
||||
|
||||
@@ -124,7 +124,11 @@ if (defined(ohos_lite)) {
|
||||
]
|
||||
|
||||
deps = []
|
||||
defines = [ "CAMERA_UT_TEST" ]
|
||||
if (defined(defines)) {
|
||||
defines += [ "CAMERA_UT_TEST" ]
|
||||
} else {
|
||||
defines = [ "CAMERA_UT_TEST" ]
|
||||
}
|
||||
|
||||
if (is_standard_system) {
|
||||
external_deps = [
|
||||
|
||||
@@ -24,6 +24,7 @@ void CameraHdiUtTestSecureStreamV1_3::SetUpTestCase(void) {}
|
||||
void CameraHdiUtTestSecureStreamV1_3::TearDownTestCase(void) {}
|
||||
void CameraHdiUtTestSecureStreamV1_3::SetUp(void)
|
||||
{
|
||||
sleep(1);
|
||||
cameraTest = std::make_shared<OHOS::Camera::HdiCommonV1_3>();
|
||||
cameraTest->Init(); // assert inside
|
||||
cameraTest->OpenSecureCamera(DEVICE_1); // assert inside
|
||||
|
||||
@@ -1931,8 +1931,6 @@ HWTEST_F(CameraHdiUtTestV1_3, Camera_Device_Hdi_V1_3_047, TestSize.Level1)
|
||||
// Preview streamInfo
|
||||
cameraTest->streamInfoV1_1 = std::make_shared<OHOS::HDI::Camera::V1_1::StreamInfo_V1_1>();
|
||||
cameraTest->DefaultInfosPreview(cameraTest->streamInfoV1_1);
|
||||
cameraTest->streamInfoV1_1->v1_0.width_ = 1280;
|
||||
cameraTest->streamInfoV1_1->v1_0.height_ = 960;
|
||||
cameraTest->streamInfosV1_1.push_back(*cameraTest->streamInfoV1_1);
|
||||
cameraTest->streamInfoVideo = std::make_shared<OHOS::HDI::Camera::V1_1::StreamInfo_V1_1>();
|
||||
cameraTest->DefaultInfosVideo(cameraTest->streamInfoVideo);
|
||||
|
||||
@@ -692,7 +692,7 @@ TEST_F(UtestUSBCameraTest, camera_usb_0023)
|
||||
StreamInfo streamInfoCapture = {};
|
||||
streamInfoCapture.streamId_ = cameraBase_->STREAM_ID_CAPTURE;
|
||||
streamInfoCapture.width_ = 1280; // 1280:picture width
|
||||
streamInfoCapture.height_ = 960; // 960:picture height
|
||||
streamInfoCapture.height_ = 720; // 720:picture height
|
||||
streamInfoCapture.format_ = PIXEL_FMT_RGBA_8888;
|
||||
streamInfoCapture.dataspace_ = 8; // 8:picture dataspace
|
||||
streamInfoCapture.intent_ = STILL_CAPTURE;
|
||||
@@ -847,7 +847,7 @@ TEST_F(UtestUSBCameraTest, camera_usb_0027)
|
||||
StreamInfo streamInfoVideo = {};
|
||||
streamInfoVideo.streamId_ = cameraBase_->STREAM_ID_VIDEO;
|
||||
streamInfoVideo.width_ = 1280; // 1280:picture width
|
||||
streamInfoVideo.height_ = 960; // 960:picture height
|
||||
streamInfoVideo.height_ = 720; // 720:picture height
|
||||
streamInfoVideo.format_ = PIXEL_FMT_RGBA_8888;
|
||||
streamInfoVideo.dataspace_ = 8; // 8:picture dataspace
|
||||
streamInfoVideo.intent_ = VIDEO;
|
||||
@@ -1900,4 +1900,61 @@ TEST_F(UtestUSBCameraTest, camera_usb_0055)
|
||||
sleep(1);
|
||||
cameraBase_->rc = (CamRetCode)cameraBase_->streamOperator->ReleaseStreams({streamIdVideo});
|
||||
EXPECT_EQ(true, cameraBase_->rc == HDI::Camera::V1_0::NO_ERROR);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: USB Camera
|
||||
* @tc.desc: Commit 2 streams together, width = 1280, height = 960, expected success.
|
||||
* @tc.level: Level0
|
||||
* @tc.size: MediumTest
|
||||
* @tc.type: Function
|
||||
*/
|
||||
TEST_F(UtestUSBCameraTest, camera_usb_0056)
|
||||
{
|
||||
cameraBase_->OpenUsbCamera();
|
||||
if (!g_usbCameraExit) {
|
||||
GTEST_SKIP() << "No usb camera plugged in" << std::endl;
|
||||
}
|
||||
cameraBase_->AchieveStreamOperator();
|
||||
if (cameraBase_->streamCustomerPreview_ == nullptr) {
|
||||
cameraBase_->streamCustomerPreview_ = std::make_shared<StreamCustomer>();
|
||||
}
|
||||
std::vector<StreamInfo> streamInfos;
|
||||
StreamInfo streamInfo = {};
|
||||
streamInfo.streamId_ = cameraBase_->STREAM_ID_PREVIEW;
|
||||
streamInfo.width_ = 1280; // 1280:picture width
|
||||
streamInfo.height_ = 960; // 960:picture height
|
||||
streamInfo.format_ = PIXEL_FMT_RGBA_8888;
|
||||
streamInfo.dataspace_ = 8; // 8:picture dataspace
|
||||
streamInfo.intent_ = PREVIEW;
|
||||
streamInfo.tunneledMode_ = 5; // 5:tunnel mode
|
||||
streamInfo.bufferQueue_ = new BufferProducerSequenceable(cameraBase_->streamCustomerPreview_->CreateProducer());
|
||||
ASSERT_NE(streamInfo.bufferQueue_, nullptr);
|
||||
streamInfo.bufferQueue_->producer_->SetQueueSize(8); // 8:set bufferQueue size
|
||||
streamInfos.push_back(streamInfo);
|
||||
if (cameraBase_->streamCustomerVideo_ == nullptr) {
|
||||
cameraBase_->streamCustomerVideo_ = std::make_shared<StreamCustomer>();
|
||||
}
|
||||
StreamInfo streamInfoVideo = {};
|
||||
streamInfoVideo.streamId_ = cameraBase_->STREAM_ID_VIDEO;
|
||||
streamInfoVideo.width_ = 1280; // 1280:picture width
|
||||
streamInfoVideo.height_ = 960; // 960:picture height
|
||||
streamInfoVideo.format_ = PIXEL_FMT_RGBA_8888;
|
||||
streamInfoVideo.dataspace_ = 8; // 8:picture dataspace
|
||||
streamInfoVideo.intent_ = VIDEO;
|
||||
streamInfoVideo.encodeType_ = ENCODE_TYPE_H264;
|
||||
streamInfoVideo.tunneledMode_ = 5; // 5:tunnel mode
|
||||
streamInfoVideo.bufferQueue_ = new BufferProducerSequenceable(cameraBase_->streamCustomerVideo_->CreateProducer());
|
||||
ASSERT_NE(streamInfoVideo.bufferQueue_, nullptr);
|
||||
streamInfoVideo.bufferQueue_->producer_->SetQueueSize(8); // 8:set bufferQueue size
|
||||
streamInfos.push_back(streamInfoVideo);
|
||||
cameraBase_->rc = (CamRetCode)cameraBase_->streamOperator->CreateStreams(streamInfos);
|
||||
ASSERT_EQ(true, cameraBase_->rc == HDI::Camera::V1_0::NO_ERROR);
|
||||
cameraBase_->rc = (CamRetCode)cameraBase_->streamOperator->CommitStreams(NORMAL, cameraBase_->ability_);
|
||||
ASSERT_EQ(true, cameraBase_->rc == HDI::Camera::V1_0::NO_ERROR);
|
||||
cameraBase_->StartCapture(cameraBase_->STREAM_ID_PREVIEW, cameraBase_->CAPTURE_ID_PREVIEW, false, true);
|
||||
cameraBase_->StartCapture(cameraBase_->STREAM_ID_VIDEO, cameraBase_->CAPTURE_ID_VIDEO, false, true);
|
||||
cameraBase_->captureIds = {cameraBase_->CAPTURE_ID_PREVIEW, cameraBase_->CAPTURE_ID_VIDEO};
|
||||
cameraBase_->streamIds = {cameraBase_->STREAM_ID_PREVIEW, cameraBase_->STREAM_ID_VIDEO};
|
||||
cameraBase_->StopStream(cameraBase_->captureIds, cameraBase_->streamIds);
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file expected 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 "camera_hal_hisysevent_test.h"
|
||||
|
||||
using namespace OHOS;
|
||||
using namespace std;
|
||||
using namespace testing::ext;
|
||||
using namespace OHOS::Camera;
|
||||
|
||||
void CameraHalHisyseventTest::SetUpTestCase(void) {}
|
||||
void CameraHalHisyseventTest::TearDownTestCase(void) {}
|
||||
void CameraHalHisyseventTest::SetUp(void)
|
||||
{
|
||||
cameraBase_ = std::make_shared<TestCameraBase>();
|
||||
cameraBase_->Init();
|
||||
}
|
||||
|
||||
void CameraHalHisyseventTest::TearDown(void)
|
||||
{
|
||||
cameraBase_->Close();
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: updateSetting AE
|
||||
* @tc.desc: preview, updateSetting OHOS_CONTROL_AE_EXPOSURE_COMPENSATION, success
|
||||
* @tc.size: MediumTest
|
||||
* @tc.type: Function
|
||||
*/
|
||||
HWTEST_F(CameraHalHisyseventTest, Camera_Hal_Hisysevent_001, TestSize.Level1)
|
||||
{
|
||||
cameraBase_->AchieveStreamOperator();
|
||||
cameraBase_->DefaultInfosPreview();
|
||||
cameraBase_->streamInfoPre.format_ = 9990;
|
||||
cameraBase_->DefaultInfosCapture();
|
||||
cameraBase_->streamInfoCapture.format_ = 9990;
|
||||
cameraBase_->rc = (CamRetCode)cameraBase_->streamOperator->CreateStreams(cameraBase_->streamInfos);
|
||||
EXPECT_EQ(false, cameraBase_->rc != HDI::Camera::V1_0::NO_ERROR);
|
||||
cameraBase_->rc = (CamRetCode)cameraBase_->streamOperator->CommitStreams(NORMAL, cameraBase_->ability_);
|
||||
EXPECT_EQ(false, cameraBase_->rc != HDI::Camera::V1_0::NO_ERROR);
|
||||
cameraBase_->StartCapture(cameraBase_->STREAM_ID_PREVIEW, cameraBase_->CAPTURE_ID_PREVIEW, false, true);
|
||||
sleep(1);
|
||||
cameraBase_->captureIds = {cameraBase_->CAPTURE_ID_PREVIEW};
|
||||
cameraBase_->streamIds = {cameraBase_->STREAM_ID_PREVIEW};
|
||||
cameraBase_->StopStream(cameraBase_->captureIds, cameraBase_->streamIds);
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file expected 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 CAMERA_HAL_HISYSEVENT_UTTEST_H
|
||||
#define CAMERA_HAL_HISYSEVENT_UTTEST_H
|
||||
|
||||
#include "test_camera_base.h"
|
||||
|
||||
class CameraHalHisyseventTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase(void);
|
||||
static void TearDownTestCase(void);
|
||||
void SetUp(void);
|
||||
void TearDown(void);
|
||||
std::shared_ptr<TestCameraBase> cameraBase_ = nullptr;
|
||||
};
|
||||
#endif
|
||||
@@ -501,6 +501,46 @@ void TestCameraBase::OpenCamera()
|
||||
}
|
||||
}
|
||||
|
||||
void TestCameraBase::DefaultInfosPreview()
|
||||
{
|
||||
if (streamCustomerPreview_ == nullptr) {
|
||||
streamCustomerPreview_ = std::make_shared<StreamCustomer>();
|
||||
}
|
||||
streamInfoPre.streamId_ = STREAM_ID_PREVIEW;
|
||||
streamInfoPre.width_ = PREVIEW_WIDTH; // 640:picture width
|
||||
streamInfoPre.height_ = PREVIEW_HEIGHT; // 480:picture height
|
||||
streamInfoPre.format_ = PIXEL_FMT_RGBA_8888;
|
||||
streamInfoPre.dataspace_ = 8; // 8:picture dataspace
|
||||
streamInfoPre.intent_ = PREVIEW;
|
||||
streamInfoPre.tunneledMode_ = 5; // 5:tunnel mode
|
||||
streamInfoPre.bufferQueue_ = new BufferProducerSequenceable(streamCustomerPreview_->CreateProducer());
|
||||
ASSERT_NE(streamInfoPre.bufferQueue_, nullptr);
|
||||
streamInfoPre.bufferQueue_->producer_->SetQueueSize(8); // 8:set bufferQueue size
|
||||
std::cout << "preview success1." << std::endl;
|
||||
std::vector<StreamInfo>().swap(streamInfos);
|
||||
streamInfos.push_back(streamInfoPre);
|
||||
}
|
||||
|
||||
void TestCameraBase::DefaultInfosCapture()
|
||||
{
|
||||
if (streamCustomerCapture_ == nullptr) {
|
||||
streamCustomerCapture_ = std::make_shared<StreamCustomer>();
|
||||
}
|
||||
streamInfoCapture.streamId_ = STREAM_ID_CAPTURE;
|
||||
streamInfoCapture.width_ = CAPTURE_WIDTH; // 1280:picture width
|
||||
streamInfoCapture.height_ = CAPTURE_HEIGHT; // 960:picture height
|
||||
streamInfoCapture.format_ = PIXEL_FMT_RGBA_8888;
|
||||
streamInfoCapture.dataspace_ = 8; // 8:picture dataspace
|
||||
streamInfoCapture.intent_ = STILL_CAPTURE;
|
||||
streamInfoCapture.encodeType_ = ENCODE_TYPE_JPEG;
|
||||
streamInfoCapture.tunneledMode_ = 5; // 5:tunnel mode
|
||||
streamInfoCapture.bufferQueue_ = new BufferProducerSequenceable(streamCustomerCapture_->CreateProducer());
|
||||
ASSERT_NE(streamInfoCapture.bufferQueue_, nullptr);
|
||||
streamInfoCapture.bufferQueue_->producer_->SetQueueSize(8); // 8:set bufferQueue size
|
||||
std::cout << "capture success1." << std::endl;
|
||||
streamInfos.push_back(streamInfoCapture);
|
||||
}
|
||||
|
||||
float TestCameraBase::CalTime(struct timeval start, struct timeval end)
|
||||
{
|
||||
float timeUse = 0;
|
||||
|
||||
@@ -160,6 +160,8 @@ public:
|
||||
CamRetCode SelectOpenCamera(std::string cameraId);
|
||||
void Close();
|
||||
void OpenCamera();
|
||||
void DefaultInfosPreview();
|
||||
void DefaultInfosCapture();
|
||||
void AchieveStreamOperator();
|
||||
void StartStream(std::vector<StreamIntent> intents);
|
||||
void StopStream(std::vector<int>& captureIds, std::vector<int>& streamIds);
|
||||
|
||||
@@ -371,9 +371,15 @@ void SourceNode::PortHandler::DistributeBuffers()
|
||||
}
|
||||
|
||||
if (!dbtRun || respondBufferList.empty()) {
|
||||
loopErrorCount_++;
|
||||
if (loopErrorCount_ == LOOP_MAX_COUNT) {
|
||||
CAMERA_LOGE("DistributeBuffers timeout 5s update dbtRun = false");
|
||||
dbtRun = false;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
loopErrorCount_ = 0;
|
||||
buffer = respondBufferList.front();
|
||||
respondBufferList.pop_front();
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include <vector>
|
||||
|
||||
namespace OHOS::Camera {
|
||||
constexpr uint32_t LOOP_MAX_COUNT = 10;
|
||||
class SourceNode : virtual public NodeBase {
|
||||
public:
|
||||
SourceNode(const std::string& name, const std::string& type, const std::string &cameraId);
|
||||
@@ -77,6 +78,7 @@ protected:
|
||||
bool isResize_ = false;
|
||||
int32_t maxWide_ = 0;
|
||||
int32_t maxHigh_ = 0;
|
||||
uint32_t loopErrorCount_ = 0;
|
||||
};
|
||||
|
||||
std::mutex hndl_ = {};
|
||||
|
||||
@@ -56,11 +56,13 @@ if (defined(ohos_lite)) {
|
||||
sources = [
|
||||
"event/camera_hal_hisysevent.cpp",
|
||||
"exif/exif_utils.cpp",
|
||||
"hicollie/camera_hal_hicollie.cpp",
|
||||
"watchdog/watchdog.cpp",
|
||||
]
|
||||
include_dirs = [
|
||||
"$camera_path/include",
|
||||
"$camera_path/utils/event",
|
||||
"$camera_path/utils/hicollie",
|
||||
]
|
||||
libs = []
|
||||
defines = []
|
||||
@@ -69,6 +71,7 @@ if (defined(ohos_lite)) {
|
||||
"c_utils:utils",
|
||||
"drivers_interface_camera:metadata",
|
||||
"hdf_core:libhdf_utils",
|
||||
"hicollie:libhicollie",
|
||||
"hilog:libhilog",
|
||||
"hisysevent:libhisysevent",
|
||||
"libexif:libexif",
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (c) 2024 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 "camera_hal_hicollie.h"
|
||||
|
||||
namespace OHOS::Camera {
|
||||
|
||||
CameraHalHicollie::CameraHalHicollie(
|
||||
const std::string &name, uint32_t timeout, std::function<void (void *)> func, void *arg, uint32_t flag)
|
||||
{
|
||||
id_ = HiviewDFX::XCollie::GetInstance().SetTimer(name, timeout, func, arg, flag);
|
||||
if (id_ < NUMBER_ZERO) {
|
||||
CAMERA_LOGE("CameraHalHicollie SetTimer name:%{public}s id:%{public}d failed", name.c_str(), id_);
|
||||
}
|
||||
CAMERA_LOGD("CameraHalHicollie SetTimer name:%{public}s id:%{public}d", name.c_str(), id_);
|
||||
}
|
||||
|
||||
CameraHalHicollie::~CameraHalHicollie()
|
||||
{
|
||||
if (id_ >= NUMBER_ZERO) {
|
||||
HiviewDFX::XCollie::GetInstance().CancelTimer(id_);
|
||||
CAMERA_LOGD("CameraHalHicollie CancelTimer id:%{public}d", id_);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (c) 2024 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 CAMERA_HAL_HICOLLIE_H
|
||||
#define CAMERA_HAL_HICOLLIE_H
|
||||
|
||||
#include <string>
|
||||
#include "camera.h"
|
||||
#include "xcollie/xcollie.h"
|
||||
#include "xcollie/xcollie_define.h"
|
||||
|
||||
namespace OHOS::Camera {
|
||||
|
||||
constexpr uint32_t TIMEOUT_SECOND = 10;
|
||||
constexpr uint32_t NUMBER_ZERO = 0;
|
||||
|
||||
class CameraHalHicollie {
|
||||
public:
|
||||
explicit CameraHalHicollie(const std::string &name, uint32_t timeout = TIMEOUT_SECOND,
|
||||
std::function<void (void *)> func = nullptr, void *arg = nullptr,
|
||||
uint32_t flag = (HiviewDFX::XCOLLIE_FLAG_LOG | HiviewDFX::XCOLLIE_FLAG_RECOVERY));
|
||||
~CameraHalHicollie();
|
||||
|
||||
private:
|
||||
int id_ = -1;
|
||||
};
|
||||
|
||||
} // namespace OHOS::Camera
|
||||
#endif
|
||||
@@ -496,8 +496,7 @@ int32_t StreamOperatorVdiImpl::Capture(int32_t captureId, const VdiCaptureInfo &
|
||||
request->SetFirstRequest(!isStreaming);
|
||||
for (auto id : info.streamIds_) {
|
||||
std::lock_guard<std::mutex> l(streamLock_);
|
||||
RetCode rc = streamMap_[id]->AddRequest(request);
|
||||
if (rc != RC_OK) {
|
||||
if (streamMap_[id] == nullptr || streamMap_[id]->AddRequest(request)) {
|
||||
return DEVICE_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,4 +17,5 @@ declare_args() {
|
||||
drivers_peripheral_codec_feature_set_omx_role = false
|
||||
drivers_peripheral_codec_feature_support_dma_buffer = false
|
||||
drivers_peripheral_codec_feature_support_high_work_frequency = false
|
||||
drivers_peripheral_codec_feature_support_hdi_v1 = false
|
||||
}
|
||||
|
||||
@@ -67,6 +67,7 @@ namespace {
|
||||
constexpr char CODEC_CONFIG_KEY_IS_SUPPORT_LTR[] = "isSupportLTR";
|
||||
constexpr char CODEC_CONFIG_KEY_MAX_LTR_FRAME_NUM[] = "maxLTRFrameNum";
|
||||
constexpr char CODEC_CONFIG_KEY_IS_SUPPORT_WATERMARK[] = "isSupportWaterMark";
|
||||
constexpr char CODEC_CONFIG_KEY_IS_SUPPORT_QP_MAP[] = "isSupportQPMap";
|
||||
|
||||
constexpr char CODEC_CONFIG_KEY_SAMPLE_FORMATS[] = "sampleFormats";
|
||||
constexpr char CODEC_CONFIG_KEY_SAMPLE_RATE[] = "sampleRate";
|
||||
@@ -372,6 +373,7 @@ int32_t CodecComponentConfig::GetVideoPortCapability(const struct DeviceResource
|
||||
}
|
||||
}
|
||||
cap.port.video.isSupportWaterMark = iface.GetBool(&childNode, CODEC_CONFIG_KEY_IS_SUPPORT_WATERMARK);
|
||||
cap.port.video.isSupportQPMap = iface.GetBool(&childNode, CODEC_CONFIG_KEY_IS_SUPPORT_QP_MAP);
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -163,6 +163,15 @@ int32_t CodecComponentService::GetParameter(uint32_t index, const std::vector<in
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_HDF, "HDFCodecGetParameter");
|
||||
CODEC_LOGD("index [%{public}x]", index);
|
||||
if (inParamStruct.empty() || (inParamStruct.size() < sizeof(uint32_t))) {
|
||||
CODEC_LOGE("GetParamStruct is Invalid");
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
uint32_t currentSize = *(reinterpret_cast<const uint32_t*>(inParamStruct.data()));
|
||||
if (inParamStruct.size() != currentSize) {
|
||||
CODEC_LOGE("Invalid GetParams");
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
outParamStruct = inParamStruct;
|
||||
return node_->GetParameter(static_cast<enum OMX_INDEXTYPE>(index), outParamStruct.data());
|
||||
}
|
||||
@@ -171,6 +180,15 @@ int32_t CodecComponentService::SetParameter(uint32_t index, const std::vector<in
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_HDF, "HDFCodecSetParameter");
|
||||
CODEC_LOGD("index [%{public}x]", index);
|
||||
if (paramStruct.empty() || (paramStruct.size() < sizeof(uint32_t))) {
|
||||
CODEC_LOGE("SetParamStruct is Invalid");
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
uint32_t currentSize = *(reinterpret_cast<const uint32_t*>(paramStruct.data()));
|
||||
if (paramStruct.size() != currentSize) {
|
||||
CODEC_LOGE("Invalid SetParams");
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
return node_->SetParameter(static_cast<enum OMX_INDEXTYPE>(index), paramStruct.data());
|
||||
}
|
||||
|
||||
@@ -179,6 +197,15 @@ int32_t CodecComponentService::GetConfig(uint32_t index, const std::vector<int8_
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_HDF, "HDFCodecGetConfig");
|
||||
CODEC_LOGD("index [%{public}x]", index);
|
||||
if (inCfgStruct.empty() || (inCfgStruct.size() < sizeof(uint32_t))) {
|
||||
CODEC_LOGE("GetCfgStruct is Invalid");
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
uint32_t currentSize = *(reinterpret_cast<const uint32_t*>(inCfgStruct.data()));
|
||||
if (inCfgStruct.size() != currentSize) {
|
||||
CODEC_LOGE("Invalid GetConfig");
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
outCfgStruct = inCfgStruct;
|
||||
return node_->GetConfig(static_cast<enum OMX_INDEXTYPE>(index), outCfgStruct.data());
|
||||
}
|
||||
@@ -187,6 +214,15 @@ int32_t CodecComponentService::SetConfig(uint32_t index, const std::vector<int8_
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_HDF, "HDFCodecSetConfig");
|
||||
CODEC_LOGD("index [%{public}x]", index);
|
||||
if (cfgStruct.empty() || ((cfgStruct.size() < sizeof(uint32_t)))) {
|
||||
CODEC_LOGE("SetCfgStruct is Invalid");
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
uint32_t currentSize = *(reinterpret_cast<const uint32_t*>(cfgStruct.data()));
|
||||
if (cfgStruct.size() != currentSize) {
|
||||
CODEC_LOGE("Invalid SetConfig");
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
return node_->SetConfig(static_cast<enum OMX_INDEXTYPE>(index), cfgStruct.data());
|
||||
}
|
||||
|
||||
|
||||
@@ -73,6 +73,7 @@ int32_t CodecDynaBuffer::EmptyOmxBuffer(struct OmxCodecBuffer &codecBuffer, OMX_
|
||||
CODEC_LOGE("CheckInvalid return false");
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
if (codecBuffer.bufferhandle != nullptr) {
|
||||
BufferHandle* handle = codecBuffer.bufferhandle->GetBufferHandle();
|
||||
if (handle != nullptr) {
|
||||
@@ -81,6 +82,7 @@ int32_t CodecDynaBuffer::EmptyOmxBuffer(struct OmxCodecBuffer &codecBuffer, OMX_
|
||||
codecBuffer.filledLen = sizeof(DynamicBuffer);
|
||||
}
|
||||
}
|
||||
codecBuffer_.alongParam = std::move(codecBuffer.alongParam);
|
||||
|
||||
int fence = codecBuffer.fenceFd;
|
||||
if (fence >= 0) {
|
||||
|
||||
@@ -553,9 +553,10 @@ int32_t ComponentNode::EmptyThisBuffer(OmxCodecBuffer &buffer)
|
||||
}
|
||||
bufferHdrType->pAppPrivate = nullptr;
|
||||
OMXBufferAppPrivateData privateData{};
|
||||
if (buffer.bufferType == CODEC_BUFFER_TYPE_DYNAMIC_HANDLE && (!buffer.alongParam.empty())) {
|
||||
privateData.sizeOfParam = static_cast<uint32_t>(buffer.alongParam.size());
|
||||
privateData.param = static_cast<void *>(buffer.alongParam.data());
|
||||
OmxCodecBuffer& omxCodecBuffer = codecBuffer->GetCodecBuffer();
|
||||
if (buffer.bufferType == CODEC_BUFFER_TYPE_DYNAMIC_HANDLE && (!omxCodecBuffer.alongParam.empty())) {
|
||||
privateData.sizeOfParam = static_cast<uint32_t>(omxCodecBuffer.alongParam.size());
|
||||
privateData.param = static_cast<void *>(omxCodecBuffer.alongParam.data());
|
||||
bufferHdrType->pAppPrivate = static_cast<void *>(&privateData);
|
||||
}
|
||||
|
||||
|
||||
@@ -117,7 +117,11 @@ int32_t OmxAdapterGetParameter(struct CodecComponentNode *codecNode, OMX_INDEXTY
|
||||
CODEC_LOGE("codecNode, node or param is null");
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
|
||||
uint32_t currentSize = *(reinterpret_cast<uint32_t*>(param));
|
||||
if (currentSize < sizeof(uint32_t) || currentSize != paramLen) {
|
||||
CODEC_LOGE("Invalid OmxGetParams");
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
return codecNode->node->GetParameter(paramIndex, param, paramLen);
|
||||
}
|
||||
|
||||
@@ -128,6 +132,11 @@ int32_t OmxAdapterSetParameter(struct CodecComponentNode *codecNode, OMX_INDEXTY
|
||||
CODEC_LOGE("codecNode, node or param is null");
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
uint32_t currentSize = *(reinterpret_cast<uint32_t*>(param));
|
||||
if (currentSize < sizeof(uint32_t) || currentSize != paramLen) {
|
||||
CODEC_LOGE("Invalid OmxSetParams");
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
return codecNode->node->SetParameter(index, param, paramLen);
|
||||
}
|
||||
|
||||
@@ -138,6 +147,11 @@ int32_t OmxAdapterGetConfig(struct CodecComponentNode *codecNode, OMX_INDEXTYPE
|
||||
CODEC_LOGE("codecNode, node or config is null");
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
uint32_t currentSize = *(reinterpret_cast<uint32_t*>(config));
|
||||
if (currentSize < sizeof(uint32_t) || currentSize != configLen) {
|
||||
CODEC_LOGE("Invalid OmxGetconfig");
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
return codecNode->node->GetConfig(index, config, configLen);
|
||||
}
|
||||
|
||||
@@ -148,6 +162,11 @@ int32_t OmxAdapterSetConfig(struct CodecComponentNode *codecNode, OMX_INDEXTYPE
|
||||
CODEC_LOGE("codecNode, node or config is null");
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
uint32_t currentSize = *(reinterpret_cast<uint32_t*>(config));
|
||||
if (currentSize < sizeof(uint32_t) || currentSize != configLen) {
|
||||
CODEC_LOGE("Invalid OmxGetconfig");
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
return codecNode->node->SetConfig(index, config, configLen);
|
||||
}
|
||||
|
||||
|
||||
@@ -88,11 +88,16 @@ static int32_t GetComponentNum()
|
||||
static int32_t GetComponentCapabilityList(CodecCompCapability *capList, int32_t count)
|
||||
{
|
||||
struct HdfSBuf *data = HdfSbufTypedObtain(SBUF_IPC);
|
||||
int32_t num = GetComponentNum();
|
||||
if (data == NULL || count <= 0 || count > num) {
|
||||
if (data == NULL) {
|
||||
CODEC_LOGE("Failed to obtain");
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
int32_t num = GetComponentNum();
|
||||
if (count <= 0 || count > num) {
|
||||
CODEC_LOGE("Failed to get component");
|
||||
HdfSbufRecycle(data);
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
struct HdfSBuf *reply = HdfSbufTypedObtain(SBUF_IPC);
|
||||
if (reply == NULL) {
|
||||
CODEC_LOGE("Failed to obtain reply");
|
||||
|
||||
@@ -34,7 +34,12 @@ ohos_shared_library("libcodec_image_service_2.0") {
|
||||
external_deps = [
|
||||
"c_utils:utils",
|
||||
"drivers_interface_codec:libimage_proxy_2.0",
|
||||
"drivers_interface_display:libdisplay_buffer_stub_1.0",
|
||||
"drivers_interface_display:libdisplay_buffer_stub_1.1",
|
||||
"drivers_interface_display:libdisplay_composer_stub_1.0",
|
||||
"graphic_surface:buffer_handle",
|
||||
"hdf_core:libhdf_host",
|
||||
"hdf_core:libhdf_ipc_adapter",
|
||||
"hdf_core:libhdf_utils",
|
||||
"hdf_core:libhdi",
|
||||
"hilog:libhilog",
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#ifndef OHOS_HDI_CODEC_V2_0_CODECHEIFENCODESERVICE_H
|
||||
#define OHOS_HDI_CODEC_V2_0_CODECHEIFENCODESERVICE_H
|
||||
|
||||
#include <mutex>
|
||||
#include "codec_heif_vdi.h"
|
||||
#include "v2_0/icodec_image.h"
|
||||
|
||||
@@ -26,15 +27,18 @@ namespace Image {
|
||||
namespace V2_0 {
|
||||
class CodecHeifEncodeService {
|
||||
public:
|
||||
CodecHeifEncodeService() = default;
|
||||
~CodecHeifEncodeService() = default;
|
||||
CodecHeifEncodeService();
|
||||
virtual ~CodecHeifEncodeService();
|
||||
int32_t DoHeifEncode(const std::vector<ImageItem>& inputImgs, const std::vector<MetaItem>& inputMetas,
|
||||
const std::vector<ItemRef>& refs, const SharedBuffer& output, uint32_t& filledLen);
|
||||
private:
|
||||
bool LoadVendorLib();
|
||||
bool ReWrapNativeBufferInImageItem(const std::vector<ImageItem>& inputImgs);
|
||||
private:
|
||||
std::mutex mutex_;
|
||||
std::shared_ptr<void> libHeif_ = nullptr;
|
||||
ICodecHeifHwi* heifHwi_ = nullptr;
|
||||
bool isIPCMode_;
|
||||
};
|
||||
} // V2_0
|
||||
} // Image
|
||||
|
||||
@@ -15,8 +15,13 @@
|
||||
#include "codec_heif_encode_service.h"
|
||||
#include "codec_log_wrapper.h"
|
||||
#include "hdf_base.h"
|
||||
#include "hdf_remote_service.h"
|
||||
#include "v1_0/display_composer_type.h"
|
||||
#include "v1_0/imapper.h"
|
||||
#include "v1_1/imetadata.h"
|
||||
#include <dlfcn.h>
|
||||
#include <unistd.h>
|
||||
#include <mutex>
|
||||
|
||||
namespace OHOS {
|
||||
namespace HDI {
|
||||
@@ -25,8 +30,92 @@ namespace Image {
|
||||
namespace V2_0 {
|
||||
using GetCodecHeifHwi = ICodecHeifHwi*(*)();
|
||||
|
||||
std::mutex g_mapperMtx;
|
||||
std::mutex g_metaMtx;
|
||||
sptr<OHOS::HDI::Display::Buffer::V1_0::IMapper> g_mapperService;
|
||||
sptr<OHOS::HDI::Display::Buffer::V1_1::IMetadata> g_metaService;
|
||||
|
||||
sptr<OHOS::HDI::Display::Buffer::V1_0::IMapper> GetMapperService()
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(g_mapperMtx);
|
||||
if (g_mapperService) {
|
||||
return g_mapperService;
|
||||
}
|
||||
g_mapperService = OHOS::HDI::Display::Buffer::V1_0::IMapper::Get(true);
|
||||
if (g_mapperService) {
|
||||
CODEC_LOGI("get IMapper succ");
|
||||
return g_mapperService;
|
||||
}
|
||||
CODEC_LOGE("get IMapper failed");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
sptr<OHOS::HDI::Display::Buffer::V1_1::IMetadata> GetMetaService()
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(g_metaMtx);
|
||||
if (g_metaService) {
|
||||
return g_metaService;
|
||||
}
|
||||
g_metaService = OHOS::HDI::Display::Buffer::V1_1::IMetadata::Get(true);
|
||||
if (g_metaService) {
|
||||
CODEC_LOGI("get IMetadata succ");
|
||||
return g_metaService;
|
||||
}
|
||||
CODEC_LOGE("get IMetadata failed");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void BufferDestructor(BufferHandle* handle)
|
||||
{
|
||||
if (handle == nullptr) {
|
||||
return;
|
||||
}
|
||||
sptr<OHOS::HDI::Display::Buffer::V1_0::IMapper> mapper = GetMapperService();
|
||||
if (mapper == nullptr) {
|
||||
return;
|
||||
}
|
||||
sptr<NativeBuffer> buffer = new NativeBuffer();
|
||||
buffer->SetBufferHandle(handle, true);
|
||||
mapper->FreeMem(buffer);
|
||||
}
|
||||
|
||||
bool ReWrapNativeBuffer(sptr<NativeBuffer>& buffer)
|
||||
{
|
||||
if (buffer == nullptr) {
|
||||
return true;
|
||||
}
|
||||
BufferHandle* handle = buffer->Move();
|
||||
if (handle == nullptr) {
|
||||
return true;
|
||||
}
|
||||
buffer->SetBufferHandle(handle, true, BufferDestructor);
|
||||
sptr<OHOS::HDI::Display::Buffer::V1_1::IMetadata> meta = GetMetaService();
|
||||
if (meta == nullptr) {
|
||||
return false;
|
||||
}
|
||||
int32_t ret = meta->RegisterBuffer(buffer);
|
||||
if (ret != Display::Composer::V1_0::DISPLAY_SUCCESS &&
|
||||
ret != Display::Composer::V1_0::DISPLAY_NOT_SUPPORT) {
|
||||
CODEC_LOGE("RegisterBuffer failed, ret = %{public}d", ret);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
CodecHeifEncodeService::CodecHeifEncodeService()
|
||||
{
|
||||
isIPCMode_ = (HdfRemoteGetCallingPid() == getpid() ? false : true);
|
||||
}
|
||||
|
||||
CodecHeifEncodeService::~CodecHeifEncodeService()
|
||||
{
|
||||
heifHwi_ = nullptr;
|
||||
libHeif_ = nullptr;
|
||||
}
|
||||
|
||||
bool CodecHeifEncodeService::LoadVendorLib()
|
||||
{
|
||||
std::lock_guard<std::mutex> lk(mutex_);
|
||||
if (heifHwi_) {
|
||||
return true;
|
||||
}
|
||||
@@ -51,6 +140,21 @@ bool CodecHeifEncodeService::LoadVendorLib()
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CodecHeifEncodeService::ReWrapNativeBufferInImageItem(const std::vector<ImageItem>& inputImgs)
|
||||
{
|
||||
if (!isIPCMode_) {
|
||||
return true;
|
||||
}
|
||||
|
||||
for (const auto &image : inputImgs) {
|
||||
if (!ReWrapNativeBuffer(const_cast<ImageItem &>(image).pixelBuffer)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int32_t CodecHeifEncodeService::DoHeifEncode(const std::vector<ImageItem>& inputImgs,
|
||||
const std::vector<MetaItem>& inputMetas,
|
||||
const std::vector<ItemRef>& refs,
|
||||
@@ -59,6 +163,11 @@ int32_t CodecHeifEncodeService::DoHeifEncode(const std::vector<ImageItem>& input
|
||||
if (!LoadVendorLib()) {
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
if (!ReWrapNativeBufferInImageItem(inputImgs)) {
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
SharedBuffer outputToReturn = output;
|
||||
int32_t ret = (heifHwi_->DoHeifEncode)(inputImgs, inputMetas, refs, outputToReturn);
|
||||
filledLen = outputToReturn.filledLen;
|
||||
|
||||
@@ -42,7 +42,7 @@ enum CodecAVCProfileExt {
|
||||
enum CodecVideoExType {
|
||||
CODEC_OMX_VIDEO_CodingVP9 = 10, /** VP9 Index in Codec HDI */
|
||||
CODEC_OMX_VIDEO_CodingHEVC = 11, /** HEVC Index in Codec HDI */
|
||||
CODEC_OMX_VIDEO_CodingVVC = 12, /** VVC Index in Codec HDI */
|
||||
CODEC_OMX_VIDEO_CodingVVC = 0x7F000007, /** VVC Index in Codec HDI */
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -93,6 +93,68 @@ enum CodecHevcLevel {
|
||||
CODEC_HEVC_HIGH_TIER_MAX = 0x7FFFFFFF
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Enumerates the extended VVC profile.
|
||||
*/
|
||||
enum CodecVvcProfile {
|
||||
CODEC_VVC_PROFILE_INVALID = 0x0,
|
||||
CODEC_VVC_PROFILE_MAIN10 = 0x1,
|
||||
CODEC_VVC_PROFILE_MAIN10_STILL = 0x2,
|
||||
CODEC_VVC_PROFILE_MAIN10_444 = 0x3,
|
||||
CODEC_VVC_PROFILE_MAIN10_444_STILL = 0x4,
|
||||
CODEC_VVC_PROFILE_MULTI_MAIN10 = 0x5,
|
||||
CODEC_VVC_PROFILE_MULTI_MAIN10_444 = 0x6,
|
||||
// Operation range extensions profiles
|
||||
CODEC_VVC_PROFILE_MAIN12 = 0x7,
|
||||
CODEC_VVC_PROFILE_MAIN12_INTRA = 0x8,
|
||||
CODEC_VVC_PROFILE_MAIN12_STILL = 0x9,
|
||||
CODEC_VVC_PROFILE_MAIN12_444 = 0xA,
|
||||
CODEC_VVC_PROFILE_MAIN12_444_INTRA = 0xB,
|
||||
CODEC_VVC_PROFILE_MAIN12_444_STILL = 0xC,
|
||||
CODEC_VVC_PROFILE_MAIN16_444 = 0xD,
|
||||
CODEC_VVC_PROFILE_MAIN16_444_INTRA = 0xE,
|
||||
CODEC_VVC_PROFILE_MAIN16_444_STILL = 0xF,
|
||||
CODEC_VVC_PROFILE_MAX = 0x7FFFFFFF
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Enumerates the extended VVC level.
|
||||
*/
|
||||
enum CodecVvcLevel {
|
||||
CODEC_VVC_LEVEL_INVALID = 0x0,
|
||||
CODEC_VVC_MAIN_TIER_LEVEL1 = 0x1,
|
||||
CODEC_VVC_HIGH_TIER_LEVEL1 = 0x2,
|
||||
CODEC_VVC_MAIN_TIER_LEVEL2 = 0x4,
|
||||
CODEC_VVC_HIGH_TIER_LEVEL2 = 0x8,
|
||||
CODEC_VVC_MAIN_TIER_LEVEL21 = 0x10,
|
||||
CODEC_VVC_HIGH_TIER_LEVEL21 = 0x20,
|
||||
CODEC_VVC_MAIN_TIER_LEVEL3 = 0x40,
|
||||
CODEC_VVC_HIGH_TIER_LEVEL3 = 0x80,
|
||||
CODEC_VVC_MAIN_TIER_LEVEL31 = 0x100,
|
||||
CODEC_VVC_HIGH_TIER_LEVEL31 = 0x200,
|
||||
CODEC_VVC_MAIN_TIER_LEVEL4 = 0x400,
|
||||
CODEC_VVC_HIGH_TIER_LEVEL4 = 0x800,
|
||||
CODEC_VVC_MAIN_TIER_LEVEL41 = 0x1000,
|
||||
CODEC_VVC_HIGH_TIER_LEVEL41 = 0x2000,
|
||||
CODEC_VVC_MAIN_TIER_LEVEL5 = 0x4000,
|
||||
CODEC_VVC_HIGH_TIER_LEVEL5 = 0x8000,
|
||||
CODEC_VVC_MAIN_TIER_LEVEL51 = 0x10000,
|
||||
CODEC_VVC_HIGH_TIER_LEVEL51 = 0x20000,
|
||||
CODEC_VVC_MAIN_TIER_LEVEL52 = 0x40000,
|
||||
CODEC_VVC_HIGH_TIER_LEVEL52 = 0x80000,
|
||||
CODEC_VVC_MAIN_TIER_LEVEL6 = 0x100000,
|
||||
CODEC_VVC_HIGH_TIER_LEVEL6 = 0x200000,
|
||||
CODEC_VVC_MAIN_TIER_LEVEL61 = 0x400000,
|
||||
CODEC_VVC_HIGH_TIER_LEVEL61 = 0x800000,
|
||||
CODEC_VVC_MAIN_TIER_LEVEL62 = 0x1000000,
|
||||
CODEC_VVC_HIGH_TIER_LEVEL62 = 0x2000000,
|
||||
CODEC_VVC_MAIN_TIER_LEVEL63 = 0x4000000,
|
||||
CODEC_VVC_HIGH_TIER_LEVEL63 = 0x8000000,
|
||||
CODEC_VVC_MAIN_TIER_LEVEL155 = 0x10000000,
|
||||
CODEC_VVC_HIGH_TIER_LEVEL155 = 0x20000000,
|
||||
CODEC_VVC_HIGH_TIER_MAX = 0x7FFFFFFF
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Enumerates the extended codec color format.
|
||||
*/
|
||||
@@ -255,8 +317,6 @@ enum OmxIndexCodecExType {
|
||||
OMX_IndexParamEncOutMse,
|
||||
/** CodecEncOutLTRParam */
|
||||
OMX_IndexParamEncOutLTR,
|
||||
/** CodecTemperalLayerParam */
|
||||
OMX_IndexParamTemperalLayer,
|
||||
/** OMX_CONFIG_BOOLEANTYPE */
|
||||
OMX_IndexParamEncParamsFeedback,
|
||||
/** OMX_S32 */
|
||||
@@ -265,6 +325,8 @@ enum OmxIndexCodecExType {
|
||||
OMX_IndexParamQPStsart,
|
||||
/** OMX_BOOL */
|
||||
OMX_IndexParamSkipFrame,
|
||||
/** CodecTemperalLayerParam */
|
||||
OMX_IndexParamTemperalLayer,
|
||||
/** OMX_S32 */
|
||||
OMX_IndexParamEncOutRealBitrate,
|
||||
/** CodecEncOutMadParam */
|
||||
@@ -277,6 +339,10 @@ enum OmxIndexCodecExType {
|
||||
OMX_IndexParamSupportPackInput,
|
||||
/** OMX_CONFIG_BOOLEANTYPE */
|
||||
OMX_IndexParamIsMvUpload,
|
||||
/** OMX_CONFIG_BOOLEANTYPE */
|
||||
OMX_IndexParamEnableQPMap,
|
||||
/** CodecBlockQpParam */
|
||||
OMX_IndexParamBlockQP,
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -407,6 +473,15 @@ struct CodecEncOutMadParam {
|
||||
int32_t sumMadi;
|
||||
};
|
||||
|
||||
struct CodecBlockQpParam {
|
||||
uint32_t size; /** Size of the structure */
|
||||
union OMX_VERSIONTYPE version; /** Component version */
|
||||
void *blockQpAddr; /** qp map data address */
|
||||
uint32_t blockQpSize; /** qp map data size */
|
||||
uint32_t qpMapReserveInts; /**< Number of the qpMap reserved integers */
|
||||
uint8_t qpMapReserve[0]; /** reserve for qpmap data */
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ public:
|
||||
private:
|
||||
int32_t LoadVdi();
|
||||
void FreeMemVdi(BufferHandle* handle);
|
||||
void WriteAllocPidToDma(int32_t fd);
|
||||
void WriteAllocPidToDma(int32_t fd, pid_t remotePid);
|
||||
std::mutex mutex_;
|
||||
void *libHandle_;
|
||||
IDisplayBufferVdi *vdiImpl_;
|
||||
|
||||
@@ -119,17 +119,36 @@ public:
|
||||
*/
|
||||
virtual int32_t IsSupportedAlloc(
|
||||
const std::vector<VerifyAllocInfo>& infos, std::vector<bool>& supporteds) const = 0;
|
||||
virtual int32_t RegisterBuffer(const BufferHandle& handle) = 0;
|
||||
|
||||
virtual int32_t SetMetadata(const BufferHandle& handle, uint32_t key, const std::vector<uint8_t>& value) = 0;
|
||||
virtual int32_t RegisterBuffer(const BufferHandle& handle)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual int32_t GetMetadata(const BufferHandle& handle, uint32_t key, std::vector<uint8_t>& value) = 0;
|
||||
virtual int32_t SetMetadata(const BufferHandle& handle, uint32_t key, const std::vector<uint8_t>& value)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual int32_t ListMetadataKeys(const BufferHandle& handle, std::vector<uint32_t>& keys) = 0;
|
||||
virtual int32_t GetMetadata(const BufferHandle& handle, uint32_t key, std::vector<uint8_t>& value)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual int32_t EraseMetadataKey(const BufferHandle& handle, uint32_t key) = 0;
|
||||
virtual int32_t ListMetadataKeys(const BufferHandle& handle, std::vector<uint32_t>& keys)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual int32_t GetImageLayout(const BufferHandle& handle, V1_2::ImageLayout& layout) const = 0;
|
||||
virtual int32_t EraseMetadataKey(const BufferHandle& handle, uint32_t key)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual int32_t GetImageLayout(const BufferHandle& handle, V1_2::ImageLayout& layout) const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
using CreateDisplayBufferVdiFunc = IDisplayBufferVdi* (*)();
|
||||
|
||||
@@ -114,9 +114,8 @@ int32_t AllocatorService::LoadVdi()
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
void AllocatorService::WriteAllocPidToDma(int32_t fd)
|
||||
void AllocatorService::WriteAllocPidToDma(int32_t fd, pid_t remotePid)
|
||||
{
|
||||
pid_t remotePid = HdfRemoteGetCallingPid();
|
||||
char pidStr[BUFF_SIZE] = { 0 };
|
||||
if (sprintf_s(pidStr, BUFF_SIZE, "%d", remotePid) >= 0) {
|
||||
ioctl(fd, DMA_BUF_SET_NAME_A, pidStr);
|
||||
@@ -134,12 +133,13 @@ void AllocatorService::FreeMemVdi(BufferHandle* handle)
|
||||
|
||||
int32_t AllocatorService::AllocMem(const AllocInfo& info, sptr<NativeBuffer>& handle)
|
||||
{
|
||||
HdfTrace trace(__func__, "HDI:DISP:");
|
||||
pid_t remotePid = HdfRemoteGetCallingPid();
|
||||
HITRACE_METER_FMT(HITRACE_TAG_HDF, "%s: remotePid %d", __func__, remotePid);
|
||||
|
||||
BufferHandle* buffer = nullptr;
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiImpl_, HDF_FAILURE);
|
||||
{
|
||||
DisplayBufferDfx dfxIns("HDI:Display:AllocatorService:AllocMem");
|
||||
DisplayBufferDfx dfxIns("HDI:Display:AllocatorService:remotePid:" + std::to_string(remotePid));
|
||||
dfxIns.SetTimer();
|
||||
dfxIns.StartTimeStamp();
|
||||
HdfTrace traceOne("AllocMem-VDI", "HDI:VDI:");
|
||||
@@ -151,7 +151,7 @@ int32_t AllocatorService::AllocMem(const AllocInfo& info, sptr<NativeBuffer>& ha
|
||||
}
|
||||
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(buffer, HDF_DEV_ERR_NO_MEMORY);
|
||||
WriteAllocPidToDma(buffer->fd);
|
||||
WriteAllocPidToDma(buffer->fd, remotePid);
|
||||
|
||||
handle = new NativeBuffer();
|
||||
if (handle == nullptr) {
|
||||
|
||||
@@ -16,13 +16,13 @@
|
||||
#ifndef OHOS_HDI_DISPLAY_COMPOSER_SERVICE_H
|
||||
#define OHOS_HDI_DISPLAY_COMPOSER_SERVICE_H
|
||||
|
||||
#include "idisplay_composer_vdi_v1_1.h"
|
||||
#include "cache_manager/device_cache_manager.h"
|
||||
#include "v1_1/display_command/display_cmd_responser.h"
|
||||
#include "v1_1/idisplay_composer.h"
|
||||
#include "v1_2/display_command/display_cmd_responser.h"
|
||||
#include "v1_2/idisplay_composer.h"
|
||||
#include "v1_2/display_composer_type.h"
|
||||
#include "common/include/display_vdi_adapter_interface.h"
|
||||
#include <mutex>
|
||||
|
||||
namespace OHOS {
|
||||
@@ -80,12 +80,19 @@ public:
|
||||
int32_t RegDisplayVBlankIdleCallback (const sptr<IVBlankIdleCallback>& cb) override;
|
||||
int32_t ClearClientBuffer(uint32_t devId) override;
|
||||
int32_t ClearLayerBuffer(uint32_t devId, uint32_t layerId) override;
|
||||
int32_t SetDisplayActiveRegion(uint32_t devId, const IRect& rect) override;
|
||||
int32_t FastPresent(uint32_t devId, const PresentParam& param,
|
||||
const std::vector<sptr<NativeBuffer>>& inHandles) override;
|
||||
|
||||
private:
|
||||
void HidumperInit();
|
||||
int32_t LoadVdiSo();
|
||||
int32_t LoadVdiV1_0();
|
||||
int32_t LoadVdiV1_1();
|
||||
int32_t LoadVdiAdapter();
|
||||
void LoadVdiFuncPart1();
|
||||
void LoadVdiFuncPart2();
|
||||
void LoadVdiFuncPart3();
|
||||
void ExitService();
|
||||
int32_t CreateResponser();
|
||||
static void OnHotPlug(uint32_t outputId, bool connected, void* data);
|
||||
static void OnVBlank(unsigned int sequence, uint64_t ns, void* data);
|
||||
static void OnMode(uint32_t modeId, uint64_t vBlankPeriod, void* data);
|
||||
@@ -95,6 +102,7 @@ private:
|
||||
private:
|
||||
/* Common */
|
||||
void* libHandle_;
|
||||
DisplayComposerVdiAdapter* vdiAdapter_;
|
||||
std::mutex mutex_;
|
||||
std::shared_ptr<DeviceCacheManager> cacheMgr_;
|
||||
uint32_t currentBacklightLevel_;
|
||||
@@ -102,16 +110,7 @@ private:
|
||||
sptr<IVBlankCallback> vBlankCb_;
|
||||
sptr<IModeCallback> modeCb_;
|
||||
sptr<ISeamlessChangeCallback> seamlessChangeCb_;
|
||||
|
||||
/* V1_0, which is the version of vdi */
|
||||
IDisplayComposerVdi* vdiImpl_;
|
||||
DestroyComposerVdiFunc destroyVdiFunc_;
|
||||
std::unique_ptr<V1_2::HdiDisplayCmdResponser> cmdResponser_;
|
||||
|
||||
/* V1_1, which is the version of vdi */
|
||||
IDisplayComposerVdiV1_1* vdiImplV1_1_;
|
||||
DestroyComposerVdiFuncV1_1 destroyVdiFuncV1_1_;
|
||||
std::unique_ptr<V1_2::HdiDisplayCmdResponser_1_1> cmdResponserV1_1_;
|
||||
sptr<IRefreshCallback> refreshCb_;
|
||||
sptr<IVBlankIdleCallback> VBlankIdleCb_;
|
||||
};
|
||||
|
||||
@@ -47,6 +47,9 @@ class IDisplayComposerVdiV1_1 : public IDisplayComposerVdi {
|
||||
virtual int32_t SetHardwareCursorPosition(uint32_t devId, int32_t x, int32_t y) = 0;
|
||||
virtual int32_t EnableHardwareCursorStats(uint32_t devId, bool enable) = 0;
|
||||
virtual int32_t GetHardwareCursorStats(uint32_t devId, uint32_t& frameCount, uint32_t& vsyncCount) = 0;
|
||||
virtual int32_t SetDisplayActiveRegion(uint32_t devId, const IRect& rect) = 0;
|
||||
virtual int32_t FastPresent(uint32_t devId, const PresentParam& param,
|
||||
const std::vector<BufferHandle*>& inHandles) = 0;
|
||||
};
|
||||
|
||||
using CreateComposerVdiFuncV1_1 = IDisplayComposerVdiV1_1* (*)();
|
||||
|
||||
@@ -44,36 +44,32 @@ extern "C" V1_2::IDisplayComposer* DisplayComposerImplGetInstance(void)
|
||||
|
||||
DisplayComposerService::DisplayComposerService()
|
||||
: libHandle_(nullptr),
|
||||
vdiAdapter_(new(std::nothrow) DisplayComposerVdiAdapter),
|
||||
cacheMgr_(nullptr),
|
||||
currentBacklightLevel_(0),
|
||||
hotPlugCb_(nullptr),
|
||||
vBlankCb_(nullptr),
|
||||
modeCb_(nullptr),
|
||||
seamlessChangeCb_(nullptr),
|
||||
vdiImpl_(nullptr),
|
||||
destroyVdiFunc_(nullptr),
|
||||
cmdResponser_(nullptr),
|
||||
vdiImplV1_1_(nullptr),
|
||||
destroyVdiFuncV1_1_(nullptr),
|
||||
cmdResponserV1_1_(nullptr),
|
||||
refreshCb_(nullptr),
|
||||
VBlankIdleCb_(nullptr)
|
||||
{
|
||||
int32_t ret = LoadVdiSo();
|
||||
if (ret != HDF_SUCCESS) {
|
||||
DISPLAY_LOGE("Load composer VDI failed, lib: %{public}s", DISPLAY_COMPOSER_VDI_LIBRARY);
|
||||
DISPLAY_LOGE("LoadVdiSo failed");
|
||||
return;
|
||||
}
|
||||
|
||||
ret = LoadVdiV1_1();
|
||||
if (ret != HDF_SUCCESS) {
|
||||
ret = LoadVdiV1_0();
|
||||
if (LoadVdiAdapter() != HDF_SUCCESS) {
|
||||
ExitService();
|
||||
DISPLAY_LOGE("Create DisplayComposerService failed");
|
||||
return;
|
||||
}
|
||||
|
||||
if (ret != HDF_SUCCESS) {
|
||||
dlclose(libHandle_);
|
||||
libHandle_ = nullptr;
|
||||
DISPLAY_LOGE("Load composer VDI function failed");
|
||||
if (CreateResponser() != HDF_SUCCESS) {
|
||||
ExitService();
|
||||
DISPLAY_LOGE("CreateResponser failed");
|
||||
return;
|
||||
}
|
||||
|
||||
HidumperInit();
|
||||
@@ -82,19 +78,14 @@ DisplayComposerService::DisplayComposerService()
|
||||
DisplayComposerService::~DisplayComposerService()
|
||||
{
|
||||
std::lock_guard<std::mutex> lck(mutex_);
|
||||
cmdResponser_ = nullptr;
|
||||
cmdResponserV1_1_ = nullptr;
|
||||
ExitService();
|
||||
}
|
||||
|
||||
if ((destroyVdiFunc_ != nullptr) && (vdiImpl_ != nullptr)) {
|
||||
destroyVdiFunc_(vdiImpl_);
|
||||
vdiImpl_ = nullptr;
|
||||
destroyVdiFunc_ = nullptr;
|
||||
}
|
||||
|
||||
if ((destroyVdiFuncV1_1_ != nullptr) && (vdiImplV1_1_ != nullptr)) {
|
||||
destroyVdiFuncV1_1_(vdiImplV1_1_);
|
||||
vdiImplV1_1_ = nullptr;
|
||||
destroyVdiFuncV1_1_ = nullptr;
|
||||
void DisplayComposerService::ExitService()
|
||||
{
|
||||
if (vdiAdapter_ != nullptr) {
|
||||
delete vdiAdapter_;
|
||||
vdiAdapter_ = nullptr;
|
||||
}
|
||||
|
||||
if (libHandle_ != nullptr) {
|
||||
@@ -103,6 +94,162 @@ DisplayComposerService::~DisplayComposerService()
|
||||
}
|
||||
}
|
||||
|
||||
int32_t DisplayComposerService::LoadVdiAdapter()
|
||||
{
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_, HDF_FAILURE);
|
||||
|
||||
LoadVdiFuncPart1();
|
||||
LoadVdiFuncPart2();
|
||||
LoadVdiFuncPart3();
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_->RegHotPlugCallback, HDF_FAILURE);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_->GetDisplayCapability, HDF_FAILURE);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_->GetDisplaySupportedModes, HDF_FAILURE);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_->GetDisplayMode, HDF_FAILURE);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_->SetDisplayMode, HDF_FAILURE);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_->GetDisplayPowerStatus, HDF_FAILURE);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_->SetDisplayPowerStatus, HDF_FAILURE);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_->GetDisplayBacklight, HDF_FAILURE);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_->SetDisplayBacklight, HDF_FAILURE);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_->GetDisplayProperty, HDF_FAILURE);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_->GetDisplayCompChange, HDF_FAILURE);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_->SetDisplayClientCrop, HDF_FAILURE);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_->SetDisplayClientBuffer, HDF_FAILURE);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_->SetDisplayClientDamage, HDF_FAILURE);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_->SetDisplayVsyncEnabled, HDF_FAILURE);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_->RegDisplayVBlankCallback, HDF_FAILURE);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_->GetDisplayReleaseFence, HDF_FAILURE);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_->CreateVirtualDisplay, HDF_FAILURE);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_->DestroyVirtualDisplay, HDF_FAILURE);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_->SetVirtualDisplayBuffer, HDF_FAILURE);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_->SetDisplayProperty, HDF_FAILURE);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_->Commit, HDF_FAILURE);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_->CreateLayer, HDF_FAILURE);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_->DestroyLayer, HDF_FAILURE);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_->PrepareDisplayLayers, HDF_FAILURE);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_->SetLayerAlpha, HDF_FAILURE);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_->SetLayerRegion, HDF_FAILURE);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_->SetLayerCrop, HDF_FAILURE);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_->SetLayerZorder, HDF_FAILURE);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_->SetLayerPreMulti, HDF_FAILURE);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_->SetLayerTransformMode, HDF_FAILURE);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_->SetLayerDirtyRegion, HDF_FAILURE);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_->SetLayerVisibleRegion, HDF_FAILURE);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_->SetLayerBuffer, HDF_FAILURE);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_->SetLayerCompositionType, HDF_FAILURE);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_->SetLayerBlendType, HDF_FAILURE);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_->SetLayerMaskInfo, HDF_FAILURE);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_->SetLayerColor, HDF_FAILURE);
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
void DisplayComposerService::LoadVdiFuncPart1()
|
||||
{
|
||||
vdiAdapter_->RegHotPlugCallback =
|
||||
reinterpret_cast<RegHotPlugCallbackFunc>(dlsym(libHandle_, "RegHotPlugCallback"));
|
||||
vdiAdapter_->GetDisplayCapability =
|
||||
reinterpret_cast<GetDisplayCapabilityFunc>(dlsym(libHandle_, "GetDisplayCapability"));
|
||||
vdiAdapter_->GetDisplaySupportedModes =
|
||||
reinterpret_cast<GetDisplaySupportedModesFunc>(dlsym(libHandle_, "GetDisplaySupportedModes"));
|
||||
vdiAdapter_->GetDisplayMode = reinterpret_cast<GetDisplayModeFunc>(dlsym(libHandle_, "GetDisplayMode"));
|
||||
vdiAdapter_->SetDisplayMode = reinterpret_cast<SetDisplayModeFunc>(dlsym(libHandle_, "SetDisplayMode"));
|
||||
vdiAdapter_->GetDisplayPowerStatus =
|
||||
reinterpret_cast<GetDisplayPowerStatusFunc>(dlsym(libHandle_, "GetDisplayPowerStatus"));
|
||||
vdiAdapter_->SetDisplayPowerStatus =
|
||||
reinterpret_cast<SetDisplayPowerStatusFunc>(dlsym(libHandle_, "SetDisplayPowerStatus"));
|
||||
vdiAdapter_->GetDisplayBacklight =
|
||||
reinterpret_cast<GetDisplayBacklightFunc>(dlsym(libHandle_, "GetDisplayBacklight"));
|
||||
vdiAdapter_->SetDisplayBacklight =
|
||||
reinterpret_cast<SetDisplayBacklightFunc>(dlsym(libHandle_, "SetDisplayBacklight"));
|
||||
vdiAdapter_->GetDisplayProperty =
|
||||
reinterpret_cast<GetDisplayPropertyFunc>(dlsym(libHandle_, "GetDisplayProperty"));
|
||||
vdiAdapter_->GetDisplayCompChange =
|
||||
reinterpret_cast<GetDisplayCompChangeFunc>(dlsym(libHandle_, "GetDisplayCompChange"));
|
||||
vdiAdapter_->SetDisplayClientCrop =
|
||||
reinterpret_cast<SetDisplayClientCropFunc>(dlsym(libHandle_, "SetDisplayClientCrop"));
|
||||
vdiAdapter_->SetDisplayClientBuffer =
|
||||
reinterpret_cast<SetDisplayClientBufferFunc>(dlsym(libHandle_, "SetDisplayClientBuffer"));
|
||||
vdiAdapter_->SetDisplayClientDamage =
|
||||
reinterpret_cast<SetDisplayClientDamageFunc>(dlsym(libHandle_, "SetDisplayClientDamage"));
|
||||
vdiAdapter_->SetDisplayVsyncEnabled =
|
||||
reinterpret_cast<SetDisplayVsyncEnabledFunc>(dlsym(libHandle_, "SetDisplayVsyncEnabled"));
|
||||
vdiAdapter_->RegDisplayVBlankCallback =
|
||||
reinterpret_cast<RegDisplayVBlankCallbackFunc>(dlsym(libHandle_, "RegDisplayVBlankCallback"));
|
||||
vdiAdapter_->GetDisplayReleaseFence =
|
||||
reinterpret_cast<GetDisplayReleaseFenceFunc>(dlsym(libHandle_, "GetDisplayReleaseFence"));
|
||||
vdiAdapter_->CreateVirtualDisplay =
|
||||
reinterpret_cast<CreateVirtualDisplayFunc>(dlsym(libHandle_, "CreateVirtualDisplay"));
|
||||
vdiAdapter_->DestroyVirtualDisplay =
|
||||
reinterpret_cast<DestroyVirtualDisplayFunc>(dlsym(libHandle_, "DestroyVirtualDisplay"));
|
||||
vdiAdapter_->SetVirtualDisplayBuffer =
|
||||
reinterpret_cast<SetVirtualDisplayBufferFunc>(dlsym(libHandle_, "SetVirtualDisplayBuffer"));
|
||||
vdiAdapter_->SetDisplayProperty =
|
||||
reinterpret_cast<SetDisplayPropertyFunc>(dlsym(libHandle_, "SetDisplayProperty"));
|
||||
vdiAdapter_->Commit = reinterpret_cast<CommitFunc>(dlsym(libHandle_, "Commit"));
|
||||
vdiAdapter_->CreateLayer = reinterpret_cast<CreateLayerFunc>(dlsym(libHandle_, "CreateLayer"));
|
||||
vdiAdapter_->DestroyLayer = reinterpret_cast<DestroyLayerFunc>(dlsym(libHandle_, "DestroyLayer"));
|
||||
vdiAdapter_->PrepareDisplayLayers =
|
||||
reinterpret_cast<PrepareDisplayLayersFunc>(dlsym(libHandle_, "PrepareDisplayLayers"));
|
||||
vdiAdapter_->SetLayerAlpha = reinterpret_cast<SetLayerAlphaFunc>(dlsym(libHandle_, "SetLayerAlpha"));
|
||||
vdiAdapter_->SetLayerRegion = reinterpret_cast<SetLayerRegionFunc>(dlsym(libHandle_, "SetLayerRegion"));
|
||||
}
|
||||
|
||||
void DisplayComposerService::LoadVdiFuncPart2()
|
||||
{
|
||||
vdiAdapter_->SetLayerCrop = reinterpret_cast<SetLayerCropFunc>(dlsym(libHandle_, "SetLayerCrop"));
|
||||
vdiAdapter_->SetLayerZorder = reinterpret_cast<SetLayerZorderFunc>(dlsym(libHandle_, "SetLayerZorder"));
|
||||
vdiAdapter_->SetLayerPreMulti = reinterpret_cast<SetLayerPreMultiFunc>(dlsym(libHandle_, "SetLayerPreMulti"));
|
||||
vdiAdapter_->SetLayerTransformMode =
|
||||
reinterpret_cast<SetLayerTransformModeFunc>(dlsym(libHandle_, "SetLayerTransformMode"));
|
||||
vdiAdapter_->SetLayerDirtyRegion =
|
||||
reinterpret_cast<SetLayerDirtyRegionFunc>(dlsym(libHandle_, "SetLayerDirtyRegion"));
|
||||
vdiAdapter_->SetLayerVisibleRegion =
|
||||
reinterpret_cast<SetLayerVisibleRegionFunc>(dlsym(libHandle_, "SetLayerVisibleRegion"));
|
||||
vdiAdapter_->SetLayerBuffer = reinterpret_cast<SetLayerBufferFunc>(dlsym(libHandle_, "SetLayerBuffer"));
|
||||
vdiAdapter_->SetLayerCompositionType =
|
||||
reinterpret_cast<SetLayerCompositionTypeFunc>(dlsym(libHandle_, "SetLayerCompositionType"));
|
||||
vdiAdapter_->SetLayerBlendType =
|
||||
reinterpret_cast<SetLayerBlendTypeFunc>(dlsym(libHandle_, "SetLayerBlendType"));
|
||||
vdiAdapter_->SetLayerMaskInfo = reinterpret_cast<SetLayerMaskInfoFunc>(dlsym(libHandle_, "SetLayerMaskInfo"));
|
||||
vdiAdapter_->SetLayerColor = reinterpret_cast<SetLayerColorFunc>(dlsym(libHandle_, "SetLayerColor"));
|
||||
vdiAdapter_->RegSeamlessChangeCallback =
|
||||
reinterpret_cast<RegSeamlessChangeCallbackFunc>(dlsym(libHandle_, "RegSeamlessChangeCallback"));
|
||||
vdiAdapter_->GetDisplaySupportedModesExt =
|
||||
reinterpret_cast<GetDisplaySupportedModesExtFunc>(dlsym(libHandle_, "GetDisplaySupportedModesExt"));
|
||||
vdiAdapter_->SetDisplayModeAsync =
|
||||
reinterpret_cast<SetDisplayModeAsyncFunc>(dlsym(libHandle_, "SetDisplayModeAsync"));
|
||||
vdiAdapter_->GetDisplayVBlankPeriod =
|
||||
reinterpret_cast<GetDisplayVBlankPeriodFunc>(dlsym(libHandle_, "GetDisplayVBlankPeriod"));
|
||||
vdiAdapter_->SetLayerPerFrameParameter =
|
||||
reinterpret_cast<SetLayerPerFrameParameterFunc>(dlsym(libHandle_, "SetLayerPerFrameParameter"));
|
||||
vdiAdapter_->GetSupportedLayerPerFrameParameterKey = reinterpret_cast<GetSupportedLayerPerFrameParameterKeyFunc>(
|
||||
dlsym(libHandle_, "GetSupportedLayerPerFrameParameterKey"));
|
||||
vdiAdapter_->SetDisplayOverlayResolution =
|
||||
reinterpret_cast<SetDisplayOverlayResolutionFunc>(dlsym(libHandle_, "SetDisplayOverlayResolution"));
|
||||
vdiAdapter_->RegRefreshCallback =
|
||||
reinterpret_cast<RegRefreshCallbackFunc>(dlsym(libHandle_, "RegRefreshCallback"));
|
||||
vdiAdapter_->GetDisplaySupportedColorGamuts =
|
||||
reinterpret_cast<GetDisplaySupportedColorGamutsFunc>(dlsym(libHandle_, "GetDisplaySupportedColorGamuts"));
|
||||
vdiAdapter_->GetHDRCapabilityInfos =
|
||||
reinterpret_cast<GetHDRCapabilityInfosFunc>(dlsym(libHandle_, "GetHDRCapabilityInfos"));
|
||||
vdiAdapter_->RegDisplayVBlankIdleCallback =
|
||||
reinterpret_cast<RegDisplayVBlankIdleCallbackFunc>(dlsym(libHandle_, "RegDisplayVBlankIdleCallback"));
|
||||
vdiAdapter_->SetDisplayConstraint =
|
||||
reinterpret_cast<SetDisplayConstraintFunc>(dlsym(libHandle_, "SetDisplayConstraint"));
|
||||
vdiAdapter_->SetHardwareCursorPosition =
|
||||
reinterpret_cast<SetHardwareCursorPositionFunc>(dlsym(libHandle_, "SetHardwareCursorPosition"));
|
||||
vdiAdapter_->EnableHardwareCursorStats =
|
||||
reinterpret_cast<EnableHardwareCursorStatsFunc>(dlsym(libHandle_, "EnableHardwareCursorStats"));
|
||||
vdiAdapter_->GetHardwareCursorStats =
|
||||
reinterpret_cast<GetHardwareCursorStatsFunc>(dlsym(libHandle_, "GetHardwareCursorStats"));
|
||||
vdiAdapter_->FastPresent = reinterpret_cast<FastPresentFunc>(dlsym(libHandle_, "FastPresent"));
|
||||
}
|
||||
|
||||
void DisplayComposerService::LoadVdiFuncPart3()
|
||||
{
|
||||
vdiAdapter_->SetDisplayActiveRegion =
|
||||
reinterpret_cast<SetDisplayActiveRegionFunc>(dlsym(libHandle_, "SetDisplayActiveRegion"));
|
||||
}
|
||||
|
||||
void DisplayComposerService::HidumperInit()
|
||||
{
|
||||
#ifdef DISPLAY_COMPOSER_SERVICE_HIDUMPER
|
||||
@@ -137,69 +284,18 @@ int32_t DisplayComposerService::LoadVdiSo()
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t DisplayComposerService::LoadVdiV1_0()
|
||||
int32_t DisplayComposerService::DisplayComposerService::CreateResponser()
|
||||
{
|
||||
CreateComposerVdiFunc createVdiFunc = nullptr;
|
||||
const char* errStr = nullptr;
|
||||
|
||||
createVdiFunc = reinterpret_cast<CreateComposerVdiFunc>(dlsym(libHandle_, "CreateComposerVdi"));
|
||||
if (createVdiFunc == nullptr) {
|
||||
errStr = dlerror();
|
||||
if (errStr != nullptr) {
|
||||
DISPLAY_LOGE("CreateVdiFuncV1_0 dlsym error: %{public}s", errStr);
|
||||
}
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
destroyVdiFunc_ = reinterpret_cast<DestroyComposerVdiFunc>(dlsym(libHandle_, "DestroyComposerVdi"));
|
||||
if (destroyVdiFunc_ == nullptr) {
|
||||
errStr = dlerror();
|
||||
if (errStr != nullptr) {
|
||||
DISPLAY_LOGE("DestroyVdiFuncV1_0 dlsym error: %{public}s", errStr);
|
||||
}
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
vdiImpl_ = createVdiFunc();
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiImpl_, HDF_FAILURE);
|
||||
cacheMgr_ = DeviceCacheManager::GetInstance();
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(cacheMgr_, HDF_FAILURE);
|
||||
cmdResponser_ = V1_2::HdiDisplayCmdResponser::Create(vdiImpl_, cacheMgr_);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_, HDF_FAILURE);
|
||||
if (vdiAdapter_->RegDisplayVBlankIdleCallback != nullptr) {
|
||||
DISPLAY_LOGI("%{public}s Enable Map", __func__);
|
||||
cacheMgr_->SetNeedMap(true);
|
||||
}
|
||||
cmdResponser_ = V1_2::HdiDisplayCmdResponser::Create(vdiAdapter_, cacheMgr_);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(cmdResponser_, HDF_FAILURE);
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t DisplayComposerService::LoadVdiV1_1()
|
||||
{
|
||||
CreateComposerVdiFuncV1_1 createVdiFunc = nullptr;
|
||||
const char* errStr = nullptr;
|
||||
|
||||
createVdiFunc = reinterpret_cast<CreateComposerVdiFuncV1_1>(dlsym(libHandle_, "CreateComposerVdiV1_1"));
|
||||
if (createVdiFunc == nullptr) {
|
||||
errStr = dlerror();
|
||||
if (errStr != nullptr) {
|
||||
DISPLAY_LOGE("CreateVdiFuncV1_1 dlsym error: %{public}s", errStr);
|
||||
}
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
destroyVdiFuncV1_1_ = reinterpret_cast<DestroyComposerVdiFuncV1_1>(dlsym(libHandle_, "DestroyComposerVdiV1_1"));
|
||||
if (destroyVdiFuncV1_1_ == nullptr) {
|
||||
errStr = dlerror();
|
||||
if (errStr != nullptr) {
|
||||
DISPLAY_LOGE("DestroyVdiFuncV1_1 dlsym error: %{public}s", errStr);
|
||||
}
|
||||
return HDF_FAILURE;
|
||||
}
|
||||
|
||||
vdiImplV1_1_ = createVdiFunc();
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiImplV1_1_, HDF_FAILURE);
|
||||
vdiImpl_ = dynamic_cast<IDisplayComposerVdi*>(vdiImplV1_1_);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiImpl_, HDF_FAILURE);
|
||||
cacheMgr_ = DeviceCacheManager::GetInstance();
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(cacheMgr_, HDF_FAILURE);
|
||||
cmdResponserV1_1_ = V1_2::HdiDisplayCmdResponser_1_1::CreateV1_1(vdiImplV1_1_, cacheMgr_);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(cmdResponserV1_1_, HDF_FAILURE);
|
||||
DISPLAY_LOGI("%{public}s out", __func__);
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -256,16 +352,16 @@ int32_t DisplayComposerService::RegHotPlugCallback(const sptr<IHotPlugCallback>&
|
||||
{
|
||||
DISPLAY_TRACE;
|
||||
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiImpl_, HDF_FAILURE);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_, HDF_FAILURE);
|
||||
hotPlugCb_ = cb;
|
||||
int32_t ret = vdiImpl_->RegHotPlugCallback(OnHotPlug, this);
|
||||
int32_t ret = vdiAdapter_->RegHotPlugCallback(OnHotPlug, this);
|
||||
DISPLAY_CHK_RETURN(ret != HDF_SUCCESS, HDF_FAILURE, DISPLAY_LOGE(" fail"));
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t DisplayComposerService::SetClientBufferCacheCount(uint32_t devId, uint32_t count)
|
||||
{
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiImpl_, HDF_FAILURE);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_, HDF_FAILURE);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(cacheMgr_, HDF_FAILURE);
|
||||
std::lock_guard<std::mutex> lock(cacheMgr_->GetCacheMgrMutex());
|
||||
DeviceCache* devCache = cacheMgr_->DeviceCacheInstance(devId);
|
||||
@@ -279,8 +375,8 @@ int32_t DisplayComposerService::GetDisplayCapability(uint32_t devId, DisplayCapa
|
||||
{
|
||||
DISPLAY_TRACE;
|
||||
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiImpl_, HDF_FAILURE);
|
||||
int32_t ret = vdiImpl_->GetDisplayCapability(devId, info);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_, HDF_FAILURE);
|
||||
int32_t ret = vdiAdapter_->GetDisplayCapability(devId, info);
|
||||
DISPLAY_CHK_RETURN(ret != HDF_SUCCESS, HDF_FAILURE, DISPLAY_LOGE(" fail"));
|
||||
return HDF_SUCCESS;
|
||||
}
|
||||
@@ -289,8 +385,8 @@ int32_t DisplayComposerService::GetDisplaySupportedModes(uint32_t devId, std::ve
|
||||
{
|
||||
DISPLAY_TRACE;
|
||||
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiImpl_, HDF_FAILURE);
|
||||
int32_t ret = vdiImpl_->GetDisplaySupportedModes(devId, modes);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_, HDF_FAILURE);
|
||||
int32_t ret = vdiAdapter_->GetDisplaySupportedModes(devId, modes);
|
||||
DISPLAY_CHK_RETURN(ret != HDF_SUCCESS, HDF_FAILURE, DISPLAY_LOGE(" fail"));
|
||||
return ret;
|
||||
}
|
||||
@@ -299,8 +395,8 @@ int32_t DisplayComposerService::GetDisplayMode(uint32_t devId, uint32_t& modeId)
|
||||
{
|
||||
DISPLAY_TRACE;
|
||||
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiImpl_, HDF_FAILURE);
|
||||
int32_t ret = vdiImpl_->GetDisplayMode(devId, modeId);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_, HDF_FAILURE);
|
||||
int32_t ret = vdiAdapter_->GetDisplayMode(devId, modeId);
|
||||
DISPLAY_CHK_RETURN(ret != HDF_SUCCESS, HDF_FAILURE, DISPLAY_LOGE(" fail"));
|
||||
return ret;
|
||||
}
|
||||
@@ -309,8 +405,8 @@ int32_t DisplayComposerService::SetDisplayMode(uint32_t devId, uint32_t modeId)
|
||||
{
|
||||
DISPLAY_TRACE;
|
||||
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiImpl_, HDF_FAILURE);
|
||||
int32_t ret = vdiImpl_->SetDisplayMode(devId, modeId);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_, HDF_FAILURE);
|
||||
int32_t ret = vdiAdapter_->SetDisplayMode(devId, modeId);
|
||||
DISPLAY_CHK_RETURN(ret != HDF_SUCCESS, HDF_FAILURE, DISPLAY_LOGE(" fail"));
|
||||
return ret;
|
||||
}
|
||||
@@ -319,8 +415,8 @@ int32_t DisplayComposerService::GetDisplayPowerStatus(uint32_t devId, V1_0::Disp
|
||||
{
|
||||
DISPLAY_TRACE;
|
||||
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiImpl_, HDF_FAILURE);
|
||||
int32_t ret = vdiImpl_->GetDisplayPowerStatus(devId, status);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_, HDF_FAILURE);
|
||||
int32_t ret = vdiAdapter_->GetDisplayPowerStatus(devId, status);
|
||||
DISPLAY_CHK_RETURN(ret != HDF_SUCCESS, HDF_FAILURE, DISPLAY_LOGE(" fail"));
|
||||
return ret;
|
||||
}
|
||||
@@ -329,8 +425,8 @@ int32_t DisplayComposerService::SetDisplayPowerStatus(uint32_t devId, V1_0::Disp
|
||||
{
|
||||
DISPLAY_TRACE;
|
||||
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiImpl_, HDF_FAILURE);
|
||||
int32_t ret = vdiImpl_->SetDisplayPowerStatus(devId, status);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_, HDF_FAILURE);
|
||||
int32_t ret = vdiAdapter_->SetDisplayPowerStatus(devId, status);
|
||||
DISPLAY_LOGI("devid: %{public}u, status: %{public}u, vdi return %{public}d", devId, status, ret);
|
||||
DISPLAY_CHK_RETURN(ret != HDF_SUCCESS, HDF_FAILURE, DISPLAY_LOGE(" fail"));
|
||||
return ret;
|
||||
@@ -340,8 +436,8 @@ int32_t DisplayComposerService::GetDisplayBacklight(uint32_t devId, uint32_t& le
|
||||
{
|
||||
DISPLAY_TRACE;
|
||||
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiImpl_, HDF_FAILURE);
|
||||
int32_t ret = vdiImpl_->GetDisplayBacklight(devId, level);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_, HDF_FAILURE);
|
||||
int32_t ret = vdiAdapter_->GetDisplayBacklight(devId, level);
|
||||
DISPLAY_CHK_RETURN(ret == DISPLAY_NOT_SUPPORT, HDF_SUCCESS, level = currentBacklightLevel_);
|
||||
return ret;
|
||||
}
|
||||
@@ -350,8 +446,8 @@ int32_t DisplayComposerService::SetDisplayBacklight(uint32_t devId, uint32_t lev
|
||||
{
|
||||
DISPLAY_TRACE;
|
||||
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiImpl_, HDF_FAILURE);
|
||||
int32_t ret = vdiImpl_->SetDisplayBacklight(devId, level);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_, HDF_FAILURE);
|
||||
int32_t ret = vdiAdapter_->SetDisplayBacklight(devId, level);
|
||||
DISPLAY_LOGD("devid: %{public}u, level: %{public}u, vdi return %{public}d", devId, level, ret);
|
||||
DISPLAY_CHK_RETURN(ret != HDF_SUCCESS, HDF_FAILURE, DISPLAY_LOGE(" fail"));
|
||||
currentBacklightLevel_ = level;
|
||||
@@ -362,8 +458,8 @@ int32_t DisplayComposerService::GetDisplayProperty(uint32_t devId, uint32_t id,
|
||||
{
|
||||
DISPLAY_TRACE;
|
||||
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiImpl_, HDF_FAILURE);
|
||||
int32_t ret = vdiImpl_->GetDisplayProperty(devId, id, value);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_, HDF_FAILURE);
|
||||
int32_t ret = vdiAdapter_->GetDisplayProperty(devId, id, value);
|
||||
DISPLAY_CHK_RETURN(ret == DISPLAY_NOT_SUPPORT, HDF_ERR_NOT_SUPPORT);
|
||||
DISPLAY_CHK_RETURN(ret != HDF_SUCCESS && ret != HDF_ERR_NOT_SUPPORT, HDF_FAILURE, DISPLAY_LOGE(" fail"));
|
||||
return ret;
|
||||
@@ -372,9 +468,9 @@ int32_t DisplayComposerService::GetDisplayProperty(uint32_t devId, uint32_t id,
|
||||
int32_t DisplayComposerService::SetHardwareCursorPosition(uint32_t devId, int32_t x, int32_t y)
|
||||
{
|
||||
DISPLAY_TRACE;
|
||||
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiImplV1_1_, HDF_ERR_NOT_SUPPORT);
|
||||
int32_t ret = vdiImplV1_1_->SetHardwareCursorPosition(devId, x, y);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_, HDF_FAILURE);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_->SetHardwareCursorPosition, HDF_ERR_NOT_SUPPORT);
|
||||
int32_t ret = vdiAdapter_->SetHardwareCursorPosition(devId, x, y);
|
||||
DISPLAY_CHK_RETURN(ret != HDF_SUCCESS && ret != HDF_ERR_NOT_SUPPORT, HDF_FAILURE, DISPLAY_LOGE(" fail"));
|
||||
return ret;
|
||||
}
|
||||
@@ -382,9 +478,9 @@ int32_t DisplayComposerService::SetHardwareCursorPosition(uint32_t devId, int32_
|
||||
int32_t DisplayComposerService::EnableHardwareCursorStats(uint32_t devId, bool enable)
|
||||
{
|
||||
DISPLAY_TRACE;
|
||||
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiImplV1_1_, HDF_ERR_NOT_SUPPORT);
|
||||
int32_t ret = vdiImplV1_1_->EnableHardwareCursorStats(devId, enable);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_, HDF_FAILURE);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_->EnableHardwareCursorStats, HDF_ERR_NOT_SUPPORT);
|
||||
int32_t ret = vdiAdapter_->EnableHardwareCursorStats(devId, enable);
|
||||
DISPLAY_CHK_RETURN(ret != HDF_SUCCESS && ret != HDF_ERR_NOT_SUPPORT, HDF_FAILURE, DISPLAY_LOGE(" fail"));
|
||||
return ret;
|
||||
}
|
||||
@@ -392,9 +488,9 @@ int32_t DisplayComposerService::EnableHardwareCursorStats(uint32_t devId, bool e
|
||||
int32_t DisplayComposerService::GetHardwareCursorStats(uint32_t devId, uint32_t& frameCount, uint32_t& vsyncCount)
|
||||
{
|
||||
DISPLAY_TRACE;
|
||||
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiImplV1_1_, HDF_ERR_NOT_SUPPORT);
|
||||
int32_t ret = vdiImplV1_1_->GetHardwareCursorStats(devId, frameCount, vsyncCount);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_, HDF_FAILURE);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_->GetHardwareCursorStats, HDF_ERR_NOT_SUPPORT);
|
||||
int32_t ret = vdiAdapter_->GetHardwareCursorStats(devId, frameCount, vsyncCount);
|
||||
DISPLAY_CHK_RETURN(ret != HDF_SUCCESS && ret != HDF_ERR_NOT_SUPPORT, HDF_FAILURE, DISPLAY_LOGE(" fail"));
|
||||
return ret;
|
||||
}
|
||||
@@ -403,8 +499,8 @@ int32_t DisplayComposerService::SetDisplayClientCrop(uint32_t devId, const IRect
|
||||
{
|
||||
DISPLAY_TRACE;
|
||||
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiImpl_, HDF_FAILURE);
|
||||
int32_t ret = vdiImpl_->SetDisplayClientCrop(devId, rect);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_, HDF_FAILURE);
|
||||
int32_t ret = vdiAdapter_->SetDisplayClientCrop(devId, rect);
|
||||
DISPLAY_CHK_RETURN(ret != HDF_SUCCESS, HDF_FAILURE, DISPLAY_LOGE(" fail"));
|
||||
return ret;
|
||||
}
|
||||
@@ -413,8 +509,8 @@ int32_t DisplayComposerService::SetDisplayVsyncEnabled(uint32_t devId, bool enab
|
||||
{
|
||||
DISPLAY_TRACE;
|
||||
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiImpl_, HDF_FAILURE);
|
||||
int32_t ret = vdiImpl_->SetDisplayVsyncEnabled(devId, enabled);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_, HDF_FAILURE);
|
||||
int32_t ret = vdiAdapter_->SetDisplayVsyncEnabled(devId, enabled);
|
||||
DISPLAY_CHK_RETURN(ret != HDF_SUCCESS, HDF_FAILURE, DISPLAY_LOGE(" fail"));
|
||||
return ret;
|
||||
}
|
||||
@@ -423,8 +519,8 @@ int32_t DisplayComposerService::RegDisplayVBlankCallback(uint32_t devId, const s
|
||||
{
|
||||
DISPLAY_TRACE;
|
||||
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiImpl_, HDF_FAILURE);
|
||||
int32_t ret = vdiImpl_->RegDisplayVBlankCallback(devId, OnVBlank, cb.GetRefPtr());
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_, HDF_FAILURE);
|
||||
int32_t ret = vdiAdapter_->RegDisplayVBlankCallback(devId, OnVBlank, cb.GetRefPtr());
|
||||
DISPLAY_CHK_RETURN(ret != HDF_SUCCESS, HDF_FAILURE, DISPLAY_LOGE(" fail"));
|
||||
vBlankCb_ = cb;
|
||||
return ret;
|
||||
@@ -436,8 +532,8 @@ int32_t DisplayComposerService::GetDisplayReleaseFence(
|
||||
DISPLAY_TRACE;
|
||||
|
||||
std::vector<int32_t> outFences;
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiImpl_, HDF_FAILURE);
|
||||
int32_t ret = vdiImpl_->GetDisplayReleaseFence(devId, layers, outFences);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_, HDF_FAILURE);
|
||||
int32_t ret = vdiAdapter_->GetDisplayReleaseFence(devId, layers, outFences);
|
||||
for (uint i = 0; i < outFences.size(); i++) {
|
||||
int32_t dupFd = outFences[i];
|
||||
sptr<HdifdParcelable> hdifd(new HdifdParcelable());
|
||||
@@ -452,8 +548,8 @@ int32_t DisplayComposerService::CreateVirtualDisplay(uint32_t width, uint32_t he
|
||||
{
|
||||
DISPLAY_TRACE;
|
||||
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiImpl_, HDF_FAILURE);
|
||||
int32_t ret = vdiImpl_->CreateVirtualDisplay(width, height, format, devId);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_, HDF_FAILURE);
|
||||
int32_t ret = vdiAdapter_->CreateVirtualDisplay(width, height, format, devId);
|
||||
DISPLAY_CHK_RETURN(ret != HDF_SUCCESS, HDF_FAILURE, DISPLAY_LOGE(" fail"));
|
||||
return ret;
|
||||
}
|
||||
@@ -462,8 +558,8 @@ int32_t DisplayComposerService::DestroyVirtualDisplay(uint32_t devId)
|
||||
{
|
||||
DISPLAY_TRACE;
|
||||
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiImpl_, HDF_FAILURE);
|
||||
int32_t ret = vdiImpl_->DestroyVirtualDisplay(devId);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_, HDF_FAILURE);
|
||||
int32_t ret = vdiAdapter_->DestroyVirtualDisplay(devId);
|
||||
DISPLAY_CHK_RETURN(ret != HDF_SUCCESS, HDF_FAILURE, DISPLAY_LOGE(" fail"));
|
||||
return ret;
|
||||
}
|
||||
@@ -477,9 +573,9 @@ int32_t DisplayComposerService::SetVirtualDisplayBuffer(
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(fence, HDF_FAILURE);
|
||||
BufferHandle* handle = buffer->GetBufferHandle();
|
||||
int32_t inFence = fence->GetFd();
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiImpl_, HDF_FAILURE);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_, HDF_FAILURE);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(handle, HDF_FAILURE);
|
||||
int32_t ret = vdiImpl_->SetVirtualDisplayBuffer(devId, *handle, inFence);
|
||||
int32_t ret = vdiAdapter_->SetVirtualDisplayBuffer(devId, *handle, inFence);
|
||||
DISPLAY_CHK_RETURN(ret != HDF_SUCCESS, HDF_FAILURE, DISPLAY_LOGE(" fail"));
|
||||
return ret;
|
||||
}
|
||||
@@ -488,8 +584,8 @@ int32_t DisplayComposerService::SetDisplayProperty(uint32_t devId, uint32_t id,
|
||||
{
|
||||
DISPLAY_TRACE;
|
||||
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiImpl_, HDF_FAILURE);
|
||||
int32_t ret = vdiImpl_->SetDisplayProperty(devId, id, value);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_, HDF_FAILURE);
|
||||
int32_t ret = vdiAdapter_->SetDisplayProperty(devId, id, value);
|
||||
DISPLAY_CHK_RETURN(ret != HDF_SUCCESS, HDF_FAILURE, DISPLAY_LOGE(" fail"));
|
||||
return ret;
|
||||
}
|
||||
@@ -499,8 +595,8 @@ int32_t DisplayComposerService::CreateLayer(uint32_t devId, const LayerInfo& lay
|
||||
{
|
||||
DISPLAY_TRACE;
|
||||
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiImpl_, HDF_FAILURE);
|
||||
int32_t ret = vdiImpl_->CreateLayer(devId, layerInfo, layerId);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_, HDF_FAILURE);
|
||||
int32_t ret = vdiAdapter_->CreateLayer(devId, layerInfo, layerId);
|
||||
DISPLAY_CHK_RETURN(ret != HDF_SUCCESS, HDF_FAILURE, DISPLAY_LOGE(" fail"));
|
||||
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(cacheMgr_, HDF_FAILURE);
|
||||
@@ -514,8 +610,8 @@ int32_t DisplayComposerService::CreateLayer(uint32_t devId, const LayerInfo& lay
|
||||
int32_t DisplayComposerService::DestroyLayer(uint32_t devId, uint32_t layerId)
|
||||
{
|
||||
DISPLAY_TRACE;
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiImpl_, HDF_FAILURE);
|
||||
int32_t ret = vdiImpl_->DestroyLayer(devId, layerId);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_, HDF_FAILURE);
|
||||
int32_t ret = vdiAdapter_->DestroyLayer(devId, layerId);
|
||||
DISPLAY_CHK_RETURN(ret != HDF_SUCCESS, HDF_FAILURE, DISPLAY_LOGE(" fail"));
|
||||
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(cacheMgr_, HDF_FAILURE);
|
||||
@@ -529,8 +625,9 @@ int32_t DisplayComposerService::DestroyLayer(uint32_t devId, uint32_t layerId)
|
||||
int32_t DisplayComposerService::RegSeamlessChangeCallback(const sptr<ISeamlessChangeCallback>& cb)
|
||||
{
|
||||
DISPLAY_TRACE;
|
||||
DISPLAY_CHK_RETURN(vdiImplV1_1_ == nullptr, HDF_ERR_NOT_SUPPORT);
|
||||
int32_t ret = vdiImplV1_1_->RegSeamlessChangeCallback(OnSeamlessChange, this);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_, HDF_FAILURE);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_->RegSeamlessChangeCallback, HDF_ERR_NOT_SUPPORT);
|
||||
int32_t ret = vdiAdapter_->RegSeamlessChangeCallback(OnSeamlessChange, this);
|
||||
DISPLAY_CHK_RETURN(ret == DISPLAY_NOT_SUPPORT, HDF_ERR_NOT_SUPPORT);
|
||||
DISPLAY_CHK_RETURN(ret != HDF_SUCCESS && ret != HDF_ERR_NOT_SUPPORT, HDF_FAILURE, DISPLAY_LOGE(" fail"));
|
||||
if (ret == HDF_SUCCESS) {
|
||||
@@ -542,8 +639,9 @@ int32_t DisplayComposerService::RegSeamlessChangeCallback(const sptr<ISeamlessCh
|
||||
int32_t DisplayComposerService::GetDisplaySupportedModesExt(uint32_t devId, std::vector<DisplayModeInfoExt>& modes)
|
||||
{
|
||||
DISPLAY_TRACE;
|
||||
DISPLAY_CHK_RETURN(vdiImplV1_1_ == nullptr, HDF_ERR_NOT_SUPPORT);
|
||||
int32_t ret = vdiImplV1_1_->GetDisplaySupportedModesExt(devId, modes);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_, HDF_FAILURE);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_->GetDisplaySupportedModesExt, HDF_ERR_NOT_SUPPORT);
|
||||
int32_t ret = vdiAdapter_->GetDisplaySupportedModesExt(devId, modes);
|
||||
DISPLAY_CHK_RETURN(ret == DISPLAY_NOT_SUPPORT, HDF_ERR_NOT_SUPPORT);
|
||||
DISPLAY_CHK_RETURN(ret != HDF_SUCCESS && ret != HDF_ERR_NOT_SUPPORT, HDF_FAILURE, DISPLAY_LOGE(" fail"));
|
||||
return ret;
|
||||
@@ -567,8 +665,9 @@ void DisplayComposerService::OnMode(uint32_t modeId, uint64_t vBlankPeriod, void
|
||||
int32_t DisplayComposerService::SetDisplayModeAsync(uint32_t devId, uint32_t modeId, const sptr<IModeCallback>& cb)
|
||||
{
|
||||
DISPLAY_TRACE;
|
||||
DISPLAY_CHK_RETURN(vdiImplV1_1_ == nullptr, HDF_ERR_NOT_SUPPORT);
|
||||
int32_t ret = vdiImplV1_1_->SetDisplayModeAsync(devId, modeId, OnMode, this);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_, HDF_FAILURE);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_->SetDisplayModeAsync, HDF_ERR_NOT_SUPPORT);
|
||||
int32_t ret = vdiAdapter_->SetDisplayModeAsync(devId, modeId, OnMode, this);
|
||||
DISPLAY_CHK_RETURN(ret == DISPLAY_NOT_SUPPORT, HDF_ERR_NOT_SUPPORT);
|
||||
DISPLAY_CHK_RETURN(ret != HDF_SUCCESS && ret != HDF_ERR_NOT_SUPPORT, HDF_FAILURE, DISPLAY_LOGE(" fail"));
|
||||
if (ret == HDF_SUCCESS) {
|
||||
@@ -580,8 +679,9 @@ int32_t DisplayComposerService::SetDisplayModeAsync(uint32_t devId, uint32_t mod
|
||||
int32_t DisplayComposerService::GetDisplayVBlankPeriod(uint32_t devId, uint64_t& period)
|
||||
{
|
||||
DISPLAY_TRACE;
|
||||
DISPLAY_CHK_RETURN(vdiImplV1_1_ == nullptr, HDF_ERR_NOT_SUPPORT);
|
||||
int32_t ret = vdiImplV1_1_->GetDisplayVBlankPeriod(devId, period);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_, HDF_FAILURE);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_->GetDisplayVBlankPeriod, HDF_ERR_NOT_SUPPORT);
|
||||
int32_t ret = vdiAdapter_->GetDisplayVBlankPeriod(devId, period);
|
||||
DISPLAY_CHK_RETURN(ret == DISPLAY_NOT_SUPPORT, HDF_ERR_NOT_SUPPORT);
|
||||
DISPLAY_CHK_RETURN(ret != HDF_SUCCESS && ret != HDF_ERR_NOT_SUPPORT, HDF_FAILURE, DISPLAY_LOGE(" fail"));
|
||||
return ret;
|
||||
@@ -607,12 +707,11 @@ int32_t DisplayComposerService::InitCmdRequest(const std::shared_ptr<SharedMemQu
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(request, HDF_FAILURE);
|
||||
int32_t ret = HDF_FAILURE;
|
||||
|
||||
if (cmdResponserV1_1_ != nullptr) {
|
||||
ret = cmdResponserV1_1_->InitCmdRequest(request);
|
||||
} else if (cmdResponser_ != nullptr) {
|
||||
if (cmdResponser_ != nullptr) {
|
||||
ret = cmdResponser_->InitCmdRequest(request);
|
||||
}
|
||||
DISPLAY_CHK_RETURN(ret != HDF_SUCCESS, HDF_FAILURE, DISPLAY_LOGE(" fail"));
|
||||
DISPLAY_LOGI("%{public}s out", __func__);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -621,9 +720,7 @@ int32_t DisplayComposerService::CmdRequest(
|
||||
{
|
||||
int32_t ret = HDF_FAILURE;
|
||||
|
||||
if (cmdResponserV1_1_ != nullptr) {
|
||||
ret = cmdResponserV1_1_->CmdRequest(inEleCnt, inFds, outEleCnt, outFds);
|
||||
} else if (cmdResponser_ != nullptr) {
|
||||
if (cmdResponser_ != nullptr) {
|
||||
ret = cmdResponser_->CmdRequest(inEleCnt, inFds, outEleCnt, outFds);
|
||||
}
|
||||
DISPLAY_CHK_RETURN(ret != HDF_SUCCESS, HDF_FAILURE, DISPLAY_LOGE(" fail"));
|
||||
@@ -634,9 +731,7 @@ int32_t DisplayComposerService::GetCmdReply(std::shared_ptr<SharedMemQueue<int32
|
||||
{
|
||||
int32_t ret = HDF_FAILURE;
|
||||
|
||||
if (cmdResponserV1_1_ != nullptr) {
|
||||
ret = cmdResponserV1_1_->GetCmdReply(reply);
|
||||
} else if (cmdResponser_ != nullptr) {
|
||||
if (cmdResponser_ != nullptr) {
|
||||
ret = cmdResponser_->GetCmdReply(reply);
|
||||
}
|
||||
DISPLAY_CHK_RETURN(ret != HDF_SUCCESS, HDF_FAILURE, DISPLAY_LOGE(" fail"));
|
||||
@@ -647,8 +742,9 @@ int32_t DisplayComposerService::SetLayerPerFrameParameter(uint32_t devId, uint32
|
||||
const std::vector<int8_t>& value)
|
||||
{
|
||||
DISPLAY_TRACE;
|
||||
DISPLAY_CHK_RETURN(vdiImplV1_1_ == nullptr, HDF_ERR_NOT_SUPPORT);
|
||||
int32_t ret = vdiImplV1_1_->SetLayerPerFrameParameter(devId, layerId, key, value);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_, HDF_FAILURE);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_->SetLayerPerFrameParameter, HDF_ERR_NOT_SUPPORT);
|
||||
int32_t ret = vdiAdapter_->SetLayerPerFrameParameter(devId, layerId, key, value);
|
||||
DISPLAY_CHK_RETURN(ret == DISPLAY_NOT_SUPPORT, HDF_ERR_NOT_SUPPORT);
|
||||
DISPLAY_CHK_RETURN(ret != HDF_SUCCESS && ret != HDF_ERR_NOT_SUPPORT, HDF_FAILURE, DISPLAY_LOGE(" fail"));
|
||||
return ret;
|
||||
@@ -657,8 +753,9 @@ int32_t DisplayComposerService::SetLayerPerFrameParameter(uint32_t devId, uint32
|
||||
int32_t DisplayComposerService::GetSupportedLayerPerFrameParameterKey(std::vector<std::string>& keys)
|
||||
{
|
||||
DISPLAY_TRACE;
|
||||
DISPLAY_CHK_RETURN(vdiImplV1_1_ == nullptr, HDF_ERR_NOT_SUPPORT);
|
||||
int32_t ret = vdiImplV1_1_->GetSupportedLayerPerFrameParameterKey(keys);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_, HDF_FAILURE);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_->GetSupportedLayerPerFrameParameterKey, HDF_ERR_NOT_SUPPORT);
|
||||
int32_t ret = vdiAdapter_->GetSupportedLayerPerFrameParameterKey(keys);
|
||||
DISPLAY_CHK_RETURN(ret == DISPLAY_NOT_SUPPORT, HDF_ERR_NOT_SUPPORT);
|
||||
DISPLAY_CHK_RETURN(ret != HDF_SUCCESS && ret != HDF_ERR_NOT_SUPPORT, HDF_FAILURE, DISPLAY_LOGE(" fail"));
|
||||
return ret;
|
||||
@@ -667,8 +764,9 @@ int32_t DisplayComposerService::GetSupportedLayerPerFrameParameterKey(std::vecto
|
||||
int32_t DisplayComposerService::SetDisplayOverlayResolution(uint32_t devId, uint32_t width, uint32_t height)
|
||||
{
|
||||
DISPLAY_TRACE;
|
||||
DISPLAY_CHK_RETURN(vdiImplV1_1_ == nullptr, HDF_ERR_NOT_SUPPORT);
|
||||
int32_t ret = vdiImplV1_1_->SetDisplayOverlayResolution(devId, width, height);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_, HDF_FAILURE);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_->SetDisplayOverlayResolution, HDF_ERR_NOT_SUPPORT);
|
||||
int32_t ret = vdiAdapter_->SetDisplayOverlayResolution(devId, width, height);
|
||||
DISPLAY_CHK_RETURN(ret == DISPLAY_NOT_SUPPORT, HDF_ERR_NOT_SUPPORT);
|
||||
DISPLAY_CHK_RETURN(ret != HDF_SUCCESS && ret != HDF_ERR_NOT_SUPPORT, HDF_FAILURE, DISPLAY_LOGE(" fail"));
|
||||
return ret;
|
||||
@@ -692,8 +790,9 @@ void DisplayComposerService::OnRefresh(uint32_t devId, void *data)
|
||||
int32_t DisplayComposerService::RegRefreshCallback(const sptr<IRefreshCallback>& cb)
|
||||
{
|
||||
DISPLAY_TRACE;
|
||||
DISPLAY_CHK_RETURN(vdiImplV1_1_ == nullptr, HDF_ERR_NOT_SUPPORT);
|
||||
int32_t ret = vdiImplV1_1_->RegRefreshCallback(OnRefresh, this);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_, HDF_FAILURE);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_->RegRefreshCallback, HDF_ERR_NOT_SUPPORT);
|
||||
int32_t ret = vdiAdapter_->RegRefreshCallback(OnRefresh, this);
|
||||
DISPLAY_CHK_RETURN(ret == DISPLAY_NOT_SUPPORT, HDF_ERR_NOT_SUPPORT);
|
||||
DISPLAY_CHK_RETURN(ret != HDF_SUCCESS && ret != HDF_ERR_NOT_SUPPORT, HDF_FAILURE, DISPLAY_LOGE(" fail"));
|
||||
if (ret == HDF_SUCCESS) {
|
||||
@@ -705,8 +804,9 @@ int32_t DisplayComposerService::RegRefreshCallback(const sptr<IRefreshCallback>&
|
||||
int32_t DisplayComposerService::GetDisplaySupportedColorGamuts(uint32_t devId, std::vector<ColorGamut>& gamuts)
|
||||
{
|
||||
DISPLAY_TRACE;
|
||||
DISPLAY_CHK_RETURN(vdiImplV1_1_ == nullptr, HDF_ERR_NOT_SUPPORT);
|
||||
int32_t ret = vdiImplV1_1_->GetDisplaySupportedColorGamuts(devId, gamuts);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_, HDF_FAILURE);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_->GetDisplaySupportedColorGamuts, HDF_ERR_NOT_SUPPORT);
|
||||
int32_t ret = vdiAdapter_->GetDisplaySupportedColorGamuts(devId, gamuts);
|
||||
DISPLAY_CHK_RETURN(ret == DISPLAY_NOT_SUPPORT, HDF_ERR_NOT_SUPPORT);
|
||||
DISPLAY_CHK_RETURN(ret != HDF_SUCCESS && ret != HDF_ERR_NOT_SUPPORT, HDF_FAILURE, DISPLAY_LOGE(" fail"));
|
||||
return ret;
|
||||
@@ -715,8 +815,9 @@ int32_t DisplayComposerService::GetDisplaySupportedColorGamuts(uint32_t devId, s
|
||||
int32_t DisplayComposerService::GetHDRCapabilityInfos(uint32_t devId, HDRCapability& info)
|
||||
{
|
||||
DISPLAY_TRACE;
|
||||
DISPLAY_CHK_RETURN(vdiImplV1_1_ == nullptr, HDF_ERR_NOT_SUPPORT);
|
||||
int32_t ret = vdiImplV1_1_->GetHDRCapabilityInfos(devId, info);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_, HDF_FAILURE);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_->GetHDRCapabilityInfos, HDF_ERR_NOT_SUPPORT);
|
||||
int32_t ret = vdiAdapter_->GetHDRCapabilityInfos(devId, info);
|
||||
DISPLAY_CHK_RETURN(ret == DISPLAY_NOT_SUPPORT, HDF_ERR_NOT_SUPPORT);
|
||||
DISPLAY_CHK_RETURN(ret != HDF_SUCCESS && ret != HDF_ERR_NOT_SUPPORT, HDF_FAILURE, DISPLAY_LOGE(" fail"));
|
||||
return ret;
|
||||
@@ -741,9 +842,10 @@ void DisplayComposerService::OnVBlankIdleCallback(uint32_t devId, uint64_t ns, v
|
||||
int32_t DisplayComposerService::RegDisplayVBlankIdleCallback(const sptr<IVBlankIdleCallback>& cb)
|
||||
{
|
||||
DISPLAY_TRACE;
|
||||
DISPLAY_CHK_RETURN(vdiImplV1_1_ == nullptr, HDF_ERR_NOT_SUPPORT);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_, HDF_FAILURE);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_->RegDisplayVBlankIdleCallback, HDF_ERR_NOT_SUPPORT);
|
||||
VBlankIdleCb_ = cb;
|
||||
int32_t ret = vdiImplV1_1_->RegDisplayVBlankIdleCallback(OnVBlankIdleCallback, this);
|
||||
int32_t ret = vdiAdapter_->RegDisplayVBlankIdleCallback(OnVBlankIdleCallback, this);
|
||||
DISPLAY_CHK_RETURN(ret != HDF_SUCCESS && ret != HDF_ERR_NOT_SUPPORT, HDF_FAILURE, DISPLAY_LOGE(" fail"));
|
||||
return ret;
|
||||
}
|
||||
@@ -770,6 +872,41 @@ int32_t DisplayComposerService::ClearLayerBuffer(uint32_t devId, uint32_t layerI
|
||||
return devCache->ClearLayerBuffer(layerId);
|
||||
}
|
||||
|
||||
int32_t DisplayComposerService::SetDisplayActiveRegion(uint32_t devId, const IRect& rect)
|
||||
{
|
||||
HDF_LOGI("%{public}s: devId %{public}u, rect {%{public}u, %{public}u, %{public}u, %{public}u}",
|
||||
__func__, devId, rect.x, rect.y, rect.w, rect.h);
|
||||
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_, HDF_FAILURE);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_->SetDisplayActiveRegion, HDF_ERR_NOT_SUPPORT);
|
||||
|
||||
StartTrace(HITRACE_TAG_HDF, "vdiAdapter_->SetDisplayActiveRegion");
|
||||
int32_t ret = vdiAdapter_->SetDisplayActiveRegion(devId, rect);
|
||||
FinishTrace(HITRACE_TAG_HDF);
|
||||
|
||||
if (ret != HDF_SUCCESS) {
|
||||
HDF_LOGI("%{public}s: fail, ret %{public}d", __func__, ret);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t DisplayComposerService::FastPresent(uint32_t devId, const PresentParam& param,
|
||||
const std::vector<sptr<NativeBuffer>>& inHandles)
|
||||
{
|
||||
DISPLAY_TRACE;
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_, HDF_FAILURE);
|
||||
CHECK_NULLPOINTER_RETURN_VALUE(vdiAdapter_->FastPresent, HDF_ERR_NOT_SUPPORT);
|
||||
|
||||
std::vector<BufferHandle*> handles;
|
||||
for (uint32_t i = 0; i < param.sliceNum; i++) {
|
||||
handles.emplace_back(inHandles[i]->GetBufferHandle());
|
||||
}
|
||||
|
||||
int32_t ret = vdiAdapter_->FastPresent(devId, param, handles);
|
||||
DISPLAY_CHK_RETURN(ret != HDF_SUCCESS && ret != HDF_ERR_NOT_SUPPORT, HDF_FAILURE, DISPLAY_LOGE(" fail"));
|
||||
return ret;
|
||||
}
|
||||
} // namespace Composer
|
||||
} // namespace Display
|
||||
} // namespace HDI
|
||||
|
||||
@@ -1058,3 +1058,28 @@ HWTEST_F(DeviceTest, test_GetHDRCapabilityInfos, TestSize.Level1)
|
||||
}
|
||||
EXPECT_EQ(DISPLAY_SUCCESS, ret);
|
||||
}
|
||||
|
||||
HWTEST_F(DeviceTest, test_SetDisplayActiveRegion, TestSize.Level1)
|
||||
{
|
||||
IRect rect = {0, 0, 1920, 540};
|
||||
auto ret = g_composerDevice->SetDisplayActiveRegion(g_displayIds[0], rect);
|
||||
HDF_LOGI("SetDisplayActiveRegion ret = %{public}d", ret);
|
||||
|
||||
if (ret == DISPLAY_NOT_SUPPORT) {
|
||||
DISPLAY_TEST_LOGD("SetDisplayActiveRegion not support");
|
||||
return;
|
||||
}
|
||||
EXPECT_EQ(DISPLAY_SUCCESS, ret);
|
||||
}
|
||||
|
||||
HWTEST_F(DeviceTest, test_FastPresent, TestSize.Level1)
|
||||
{
|
||||
PresentParam param = { 0, 1280, 1, 0x5000280, 0 };
|
||||
std::vector<BufferHandle *> inHandles;
|
||||
auto ret = g_composerDevice->FastPresent(g_displayIds[0], param, inHandles);
|
||||
if (ret == DISPLAY_NOT_SUPPORT) {
|
||||
DISPLAY_TEST_LOGD("FastPresent not support");
|
||||
return;
|
||||
}
|
||||
EXPECT_EQ(DISPLAY_FAILURE, ret);
|
||||
}
|
||||
@@ -68,11 +68,9 @@ int32_t AllocatorServiceStub::OnRemoteRequest(
|
||||
{
|
||||
if (cmdId == CMD_ALLOCATOR_ALLOCMEM) {
|
||||
return AllocaltorStubAllocMem(data, reply, option);
|
||||
} else {
|
||||
HDF_LOGE("%{public}s: not support cmd", __func__);
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
return HDF_SUCCESS;
|
||||
HDF_LOGE("%{public}s: not support cmd", __func__);
|
||||
return HDF_ERR_INVALID_PARAM;
|
||||
}
|
||||
} // namespace V1_0
|
||||
} // namespace Display
|
||||
|
||||
@@ -148,7 +148,7 @@ private:
|
||||
bool GetSpkStatus(const uint32_t streamId);
|
||||
|
||||
private:
|
||||
static constexpr uint8_t WAIT_SECONDS = 20;
|
||||
static constexpr uint32_t WAIT_MILLISECONDS = 8000;
|
||||
static constexpr int32_t TYPE_CONDITION = 11;
|
||||
static constexpr int32_t MAX_EVENT_DIGITS = 3;
|
||||
AudioAdapterDescriptor adpDescriptor_;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user