!529 【Distributedhardware】【Master】音频低时延更新!

Merge pull request !529 from liangxiafei/master
This commit is contained in:
openharmony_ci 2024-01-03 07:20:25 +00:00 committed by Gitee
commit 07511cf0cd
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
6 changed files with 2070 additions and 0 deletions

View File

@ -17,6 +17,7 @@ group("distributedhardware") {
testonly = true
if (is_standard_system) {
deps = [
"distributedaudiodelaytest:SubDctsdisAudioDelayTest",
"distributedaudiotest:SubDctsdisAudioTest",
"distributedcameratest:SubDctsdisCameraTest",
"distributeddevicejstest:SubDctsdisDeviceJsTest",

View File

@ -0,0 +1,54 @@
# 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.
base_root = "../../../../../"
import("//test/xts/tools/build/suite.gni")
module_output_path = "dcts/distributedhardware"
ohos_moduletest_suite("SubDctsdisAudioDelayTest") {
module_out_path = module_output_path
include_dirs = [
"$base_root/foundation/distributedhardware/distributed_hardware_fwk/common/log/include",
"$base_root/foundation/distributedhardware/distributed_hardware_fwk/utils/include/log",
"$base_root/foundation/multimedia/audio_framework/frameworks/native/audioutils/include",
"$base_root/foundation/multimedia/audio_framework/interfaces/inner_api/native/audiocommon/include",
"$base_root/foundation/multimedia/audio_framework/services/audio_service/client/include",
]
sources = [
"daudio_automat_delay_test.cpp",
"distributedaudiodelaytest.cpp",
]
deps = [
"$base_root/foundation/multimedia/audio_framework/frameworks/native/audioutils:audio_utils",
"$base_root/foundation/multimedia/audio_framework/services/audio_service:audio_client",
]
external_deps = [
"c_utils:utils",
"hilog:libhilog",
"init:libbegetutil",
]
defines = [
"HI_LOG_ENABLE",
"DH_LOG_TAG=\"SubDctsdisAudioDelayTest\"",
"LOG_DOMAIN=0xD004100",
]
install_enable = true
part_name = "audio_framework"
subsystem_name = "multimedia"
}

View File

@ -0,0 +1,22 @@
{
"description": "Config for disCamera test cases",
"driver": {
"module-name": "SubDctsdisAudioDelayTest",
"native-test-timeout": "120000",
"native-test-device-path": "/data/local/tmp",
"runtime-hint": "1s",
"type": "CppTest"
},
"kits": [
{
"post-push" : [
"chmod -R 777 /data/local/tmp/*"
],
"push": [
"SubDctsdisAudioDelayTest->/data/local/tmp/SubDctsdisAudioDelayTest"
],
"type": "PushKit"
}
]
}

View File

@ -0,0 +1,426 @@
/*
* 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 <gtest/gtest.h>
#include "./distributedaudiodelaytest.h"
using namespace testing::ext;
using namespace OHOS::AudioStandard;
int32_t g_audioOk = 0;
int32_t g_audioDelay = 5;
class DAudioAutoDelaymatTest : public testing::Test {
public:
static void SetUpTestCase(void);
static void TearDownTestCase(void);
void SetUp();
void TearDown();
DAudioAutoDelaymatTest();
};
void DAudioAutoDelaymatTest::SetUpTestCase(void)
{
MakeShare();
}
void DAudioAutoDelaymatTest::TearDownTestCase(void) {}
void DAudioAutoDelaymatTest::SetUp(void) {}
void DAudioAutoDelaymatTest::TearDown(void) {}
DAudioAutoDelaymatTest::DAudioAutoDelaymatTest(void) {}
/**
* @tc.name RemoteSpkInitProcessTest()
* @tc.number SUB_DH_DAudio_Delay_Dcts_0100
* @tc.desc Call Remote Spk Init Process Test
* @tc.size MediumTest
* @tc.type Function
* @tc.level Level 1
*/
HWTEST_F(DAudioAutoDelaymatTest, SUB_DH_DAudio_Delay_Dcts_0100, TestSize.Level1)
{
std::string ret = RemoteSpkInitProcessTest();
EXPECT_EQ("Spk init SUCCESS", ret) << "Remote Spk init SUCCESS";
sleep(g_audioDelay);
}
/**
* @tc.name StartSpkProcessTest()
* @tc.number SUB_DH_DAudio_Delay_Dcts_0200
* @tc.desc Remote Call Start Spk Process
* @tc.size MediumTest
* @tc.type Function
* @tc.level Level 1
*/
HWTEST_F(DAudioAutoDelaymatTest, SUB_DH_DAudio_Delay_Dcts_0200, TestSize.Level1)
{
std::string ret = StartSpkProcessTest();
EXPECT_EQ("Spk start SUCCESS", ret) << "Local Spk start failed";
sleep(g_audioDelay);
}
/**
* @tc.name PauseSpkProcessTest()
* @tc.number SUB_DH_DAudio_Delay_Dcts_0300
* @tc.desc Remote Call Pause Spk Process
* @tc.size MediumTest
* @tc.type Function
* @tc.level Level 1
*/
HWTEST_F(DAudioAutoDelaymatTest, SUB_DH_DAudio_Delay_Dcts_0300, TestSize.Level1)
{
std::string ret = PauseSpkProcessTest();
EXPECT_EQ("Spk pause SUCCESS", ret) << "Local Spk pause failed";
sleep(g_audioDelay);
}
/**
* @tc.name ResumeSpkProcessTest()
* @tc.number SUB_DH_DAudio_Delay_Dcts_0400
* @tc.desc Remote Call Resume Spk Process
* @tc.size MediumTest
* @tc.type Function
* @tc.level Level 1
*/
HWTEST_F(DAudioAutoDelaymatTest, SUB_DH_DAudio_Delay_Dcts_0400, TestSize.Level1)
{
std::string ret = ResumeSpkProcessTest();
EXPECT_EQ("Spk resume SUCCESS", ret) << "Local Spk resume failed";
sleep(g_audioDelay);
}
/**
* @tc.name StopSpkProcessTest()
* @tc.number SUB_DH_DAudio_Delay_Dcts_0500
* @tc.desc Remote Call Stop Spk Process
* @tc.size MediumTest
* @tc.type Function
* @tc.level Level 1
*/
HWTEST_F(DAudioAutoDelaymatTest, SUB_DH_DAudio_Delay_Dcts_0500, TestSize.Level1)
{
std::string ret = StopSpkProcessTest();
EXPECT_EQ("Spk stop SUCCESS", ret) << "Local Spk stop failed";
sleep(g_audioDelay);
}
/**
* @tc.name ReleaseSpkProcessTest()
* @tc.number SUB_DH_DAudio_Delay_Dcts_0600
* @tc.desc Remote Call Release Spk Process
* @tc.size MediumTest
* @tc.type Function
* @tc.level Level 1
*/
HWTEST_F(DAudioAutoDelaymatTest, SUB_DH_DAudio_Delay_Dcts_0600, TestSize.Level1)
{
std::string ret = ReleaseSpkProcessTest();
EXPECT_EQ("Spk release SUCCESS", ret) << "Local Spk release failed";
sleep(g_audioDelay);
}
/**
* @tc.name RemoteMicInitProcessTest()
* @tc.number SUB_DH_DAudio_Delay_Dcts_700
* @tc.desc Remote Mic Init Process
* @tc.size MediumTest
* @tc.type Function
* @tc.level Level 1
*/
HWTEST_F(DAudioAutoDelaymatTest, SUB_DH_DAudio_Delay_Dcts_700, TestSize.Level1)
{
std::string ret = RemoteMicInitProcessTest();
EXPECT_EQ("Mic init SUCCESS", ret) << "Local Mic init failed";
sleep(g_audioDelay);
}
/**
* @tc.name StartMicProcessTest()
* @tc.number SUB_DH_DAudio_Delay_Dcts_800
* @tc.desc Remote Call Start Mic Process
* @tc.size MediumTest
* @tc.type Function
* @tc.level Level 1
*/
HWTEST_F(DAudioAutoDelaymatTest, SUB_DH_DAudio_Delay_Dcts_800, TestSize.Level1)
{
std::string ret = StartMicProcessTest();
EXPECT_EQ("Mic start SUCCESS", ret) << "Local Mic start failed";
sleep(g_audioDelay);
}
/**
* @tc.name PauseMicProcessTest()
* @tc.number SUB_DH_DAudio_Delay_Dcts_900
* @tc.desc Remote Call Pause Mic Process
* @tc.size MediumTest
* @tc.type Function
* @tc.level Level 1
*/
HWTEST_F(DAudioAutoDelaymatTest, SUB_DH_DAudio_Delay_Dcts_900, TestSize.Level1)
{
std::string ret = PauseMicProcessTest();
EXPECT_EQ("Mic pause SUCCESS", ret) << "Local Mic pause failed";
sleep(g_audioDelay);
}
/**
* @tc.name ResumeMicProcessTest()
* @tc.number SUB_DH_DAudio_Delay_Dcts_1000
* @tc.desc Remote Call Resume Mic Process
* @tc.size MediumTest
* @tc.type Function
* @tc.level Level 1
*/
HWTEST_F(DAudioAutoDelaymatTest, SUB_DH_DAudio_Delay_Dcts_1000, TestSize.Level1)
{
std::string ret = ResumeMicProcessTest();
EXPECT_EQ("Mic resume SUCCESS", ret) << "Local Mic resume failed";
sleep(g_audioDelay);
}
/**
* @tc.name StopMicProcessTest()
* @tc.number SUB_DH_DAudio_Delay_Dcts_1100
* @tc.desc Remote Call Stop Mic Process
* @tc.size MediumTest
* @tc.type Function
* @tc.level Level 1
*/
HWTEST_F(DAudioAutoDelaymatTest, SUB_DH_DAudio_Delay_Dcts_1100, TestSize.Level1)
{
std::string ret = StopMicProcessTest();
EXPECT_EQ("Mic stop SUCCESS", ret) << "Local Mic stop failed";
sleep(g_audioDelay);
}
/**
* @tc.name ReleaseMicProcessTest()
* @tc.number SUB_DH_DAudio_Delay_Dcts_1200
* @tc.desc Remote Call Release Mic Process
* @tc.size MediumTest
* @tc.type Function
* @tc.level Level 1
*/
HWTEST_F(DAudioAutoDelaymatTest, SUB_DH_DAudio_Delay_Dcts_1200, TestSize.Level1)
{
std::string ret = ReleaseMicProcessTest();
EXPECT_EQ("Mic release SUCCESS", ret) << "Local Mic release failed";
sleep(g_audioDelay);
}
/**
* @tc.name RemoteLoopTest()
* @tc.number SUB_DH_DAudio_Delay_Dcts_1300
* @tc.desc Call Remote Loop Latency Test
* @tc.size MediumTest
* @tc.type Function
* @tc.level Level 1
*/
HWTEST_F(DAudioAutoDelaymatTest, SUB_DH_DAudio_Delay_Dcts_1300, TestSize.Level1)
{
std::string ret = RemoteLoopTest();
EXPECT_EQ("Loop latency test success", ret) << "Local Loop latency test failed";
sleep(g_audioDelay);
}
/**
* @tc.name LocalSpkInitProcessTestk()
* @tc.number SUB_DH_DAudio_Delay_Dcts_1400
* @tc.desc Call Local Spk Init Process
* @tc.size MediumTest
* @tc.type Function
* @tc.level Level 1
*/
HWTEST_F(DAudioAutoDelaymatTest, SUB_DH_DAudio_Delay_Dcts_1400, TestSize.Level1)
{
std::string ret = LocalSpkInitProcessTestk();
EXPECT_EQ("Spk init SUCCESS", ret) << "Remote Spk init SUCCESS";
sleep(g_audioDelay);
}
/**
* @tc.name StartSpkProcessTest()
* @tc.number SUB_DH_DAudio_Delay_Dcts_1500
* @tc.desc Local Call Start Spk Process
* @tc.size MediumTest
* @tc.type Function
* @tc.level Level 1
*/
HWTEST_F(DAudioAutoDelaymatTest, SUB_DH_DAudio_Delay_Dcts_1500, TestSize.Level1)
{
std::string ret = StartSpkProcessTest();
EXPECT_EQ("Spk start SUCCESS", ret) << "remote Spk start failed";
sleep(g_audioDelay);
}
/**
* @tc.name PauseSpkProcessTest()
* @tc.number SUB_DH_DAudio_Delay_Dcts_1600
* @tc.desc Local Call Pause Spk Process
* @tc.size MediumTest
* @tc.type Function
* @tc.level Level 1
*/
HWTEST_F(DAudioAutoDelaymatTest, SUB_DH_DAudio_Delay_Dcts_1600, TestSize.Level1)
{
std::string ret = PauseSpkProcessTest();
EXPECT_EQ("Spk pause SUCCESS", ret) << "remote Spk pause failed";
sleep(g_audioDelay);
}
/**
* @tc.name ResumeSpkProcessTest()
* @tc.number SUB_DH_DAudio_Delay_Dcts_1700
* @tc.desc Local Call Resume Spk Process
* @tc.size MediumTest
* @tc.type Function
* @tc.level Level 1
*/
HWTEST_F(DAudioAutoDelaymatTest, SUB_DH_DAudio_Delay_Dcts_1700, TestSize.Level1)
{
std::string ret = ResumeSpkProcessTest();
EXPECT_EQ("Spk resume SUCCESS", ret) << "remote Spk resume failed";
sleep(g_audioDelay);
}
/**
* @tc.name StopSpkProcessTest()
* @tc.number SUB_DH_DAudio_Delay_Dcts_1800
* @tc.desc Local Call Stop Spk Process
* @tc.size MediumTest
* @tc.type Function
* @tc.level Level 1
*/
HWTEST_F(DAudioAutoDelaymatTest, SUB_DH_DAudio_Delay_Dcts_1800, TestSize.Level1)
{
std::string ret = StopSpkProcessTest();
EXPECT_EQ("Spk stop SUCCESS", ret) << "remote Spk stop failed";
sleep(g_audioDelay);
}
/**
* @tc.name ReleaseSpkProcessTest()
* @tc.number SUB_DH_DAudio_Delay_Dcts_1900
* @tc.desc Local Call Release Spk Process
* @tc.size MediumTest
* @tc.type Function
* @tc.level Level 1
*/
HWTEST_F(DAudioAutoDelaymatTest, SUB_DH_DAudio_Delay_Dcts_1900, TestSize.Level1)
{
std::string ret = ReleaseSpkProcessTest();
EXPECT_EQ("Spk release SUCCESS", ret) << "remote Spk release failed";
sleep(g_audioDelay);
}
/**
* @tc.name LocalMicInitProcessTest()
* @tc.number SUB_DH_DAudio_Delay_Dcts_2000
* @tc.desc Local Mic Init Process
* @tc.size MediumTest
* @tc.type Function
* @tc.level Level 1
*/
HWTEST_F(DAudioAutoDelaymatTest, SUB_DH_DAudio_Delay_Dcts_2000, TestSize.Level1)
{
std::string ret = LocalMicInitProcessTest();
EXPECT_EQ("Mic init SUCCESS", ret) << "remote Mic init failed";
sleep(g_audioDelay);
}
/**
* @tc.name StartMicProcessTest()
* @tc.number SUB_DH_DAudio_Delay_Dcts_2100
* @tc.desc Local Call Start Mic Process
* @tc.size MediumTest
* @tc.type Function
* @tc.level Level 1
*/
HWTEST_F(DAudioAutoDelaymatTest, SUB_DH_DAudio_Delay_Dcts_2100, TestSize.Level1)
{
std::string ret = StartMicProcessTest();
EXPECT_EQ("Mic start SUCCESS", ret) << "remote start failed";
sleep(g_audioDelay);
}
/**
* @tc.name PauseMicProcessTest()
* @tc.number SUB_DH_DAudio_Delay_Dcts_2200
* @tc.desc Local Call Pause Mic Process
* @tc.size MediumTest
* @tc.type Function
* @tc.level Level 1
*/
HWTEST_F(DAudioAutoDelaymatTest, SUB_DH_DAudio_Delay_Dcts_2200, TestSize.Level1)
{
std::string ret = PauseMicProcessTest();
EXPECT_EQ("Mic pause SUCCESS", ret) << "remote Mic pause failed";
sleep(g_audioDelay);
}
/**
* @tc.name ResumeMicProcessTest()
* @tc.number SUB_DH_DAudio_Delay_Dcts_2300
* @tc.desc Local Call Resume Mic Process
* @tc.size MediumTest
* @tc.type Function
* @tc.level Level 1
*/
HWTEST_F(DAudioAutoDelaymatTest, SUB_DH_DAudio_Delay_Dcts_2300, TestSize.Level1)
{
std::string ret = ResumeMicProcessTest();
EXPECT_EQ("Mic resume SUCCESS", ret) << "remote Mic resume failed";
sleep(g_audioDelay);
}
/**
* @tc.name StopMicProcessTest()
* @tc.number SUB_DH_DAudio_Delay_Dcts_2400
* @tc.desc Local Call Stop Mic Process
* @tc.size MediumTest
* @tc.type Function
* @tc.level Level 1
*/
HWTEST_F(DAudioAutoDelaymatTest, SUB_DH_DAudio_Delay_Dcts_2400, TestSize.Level1)
{
std::string ret = StopMicProcessTest();
EXPECT_EQ("Mic stop SUCCESS", ret) << "remote Mic stop failed";
sleep(g_audioDelay);
}
/**
* @tc.name ReleaseMicProcessTest()
* @tc.number SUB_DH_DAudio_Delay_Dcts_2500
* @tc.desc Local Call Release Mic Process
* @tc.size MediumTest
* @tc.type Function
* @tc.level Level 1
*/
HWTEST_F(DAudioAutoDelaymatTest, SUB_DH_DAudio_Delay_Dcts_2500, TestSize.Level1)
{
std::string ret = ReleaseMicProcessTest();
EXPECT_EQ("Mic release SUCCESS", ret) << "remote Mic release failed";
sleep(g_audioDelay);
}
/**
* @tc.name LocalLoopTest()
* @tc.number SUB_DH_DAudio_Delay_Dcts_2600
* @tc.desc Call Local Loop Latency Test
* @tc.size MediumTest
* @tc.type Function
* @tc.level Level 1
*/
HWTEST_F(DAudioAutoDelaymatTest, SUB_DH_DAudio_Delay_Dcts_2600, TestSize.Level1)
{
std::string ret = LocalLoopTest();
EXPECT_EQ("Loop latency test success", ret) << "remote Loop latency test failed";
sleep(g_audioDelay);
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,75 @@
#ifndef DISTRIBUTED_AUDIO_DELAY_TEST_H
#define DISTRIBUTED_AUDIO_DELAY_TEST_H
/*
* 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 <condition_variable>
#include <cstdint>
#include <ctime>
#include <ostream>
#include <sstream>
#include <iostream>
#include <thread>
#include <mutex>
#include <map>
#include <securec.h>
#include <sys/time.h>
#include "audio_log.h"
#include "audio_errors.h"
#include "audio_utils.h"
#include "audio_process_in_client.h"
#include "audio_system_manager.h"
#include "parameter.h"
namespace OHOS {
namespace AudioStandard {
struct WAV_HEADER {
/* RIFF Chunk Descriptor */
uint8_t riff[4] = {'R', 'I', 'F', 'F'}; // RIFF Header Magic header
uint32_t chunkSize = 0; // RIFF Chunk Size
uint8_t wave[4] = {'W', 'A', 'V', 'E'}; // WAVE Header
/* "fmt" sub-chunk */
uint8_t fmt[4] = {'f', 'm', 't', ' '}; // FMT header
uint32_t subchunk1Size = 16; // Size of the fmt chunk
uint16_t audioFormat = 1; // Audio format 1=PCM
uint16_t numOfChan = 2; // Number of channels 1=Mono 2=Stereo
uint32_t samplesPerSec = 44100; // Sampling Frequency in Hz
uint32_t bytesPerSec = 176400; // bytes per second
uint16_t blockAlign = 2; // 2=16-bit mono, 4=16-bit stereo
uint16_t bitsPerSample = 16; // Number of bits per sample
/* "data" sub-chunk */
uint8_t subchunk2ID[4] = {'d', 'a', 't', 'a'}; // "data" string
uint32_t subchunk2Size = 0; // Sampled data length
};
using WavHdr = struct WAV_HEADER;
void MakeShare();
std::string LocalSpkInitProcessTestk();
std::string RemoteSpkInitProcessTest();
std::string StartSpkProcessTest();
std::string PauseSpkProcessTest();
std::string ResumeSpkProcessTest();
std::string StopSpkProcessTest();
std::string ReleaseSpkProcessTest();
std::string LocalMicInitProcessTest();
std::string RemoteMicInitProcessTest();
std::string StartMicProcessTest();
std::string PauseMicProcessTest();
std::string ResumeMicProcessTest();
std::string StopMicProcessTest();
std::string ReleaseMicProcessTest();
std::string LocalLoopTest();
std::string RemoteLoopTest();
}
}
#endif