1 /* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef DISTRIBUTED_AUDIO_TEST_H 17 #define DISTRIBUTED_AUDIO_TEST_H 18 19 #include <chrono> 20 #include <iostream> 21 #include <string> 22 #include <cstdlib> 23 #include <sys/stat.h> 24 #include <thread> 25 #include <vector> 26 27 #include <v1_0/iaudio_adapter.h> 28 #include <v1_0/iaudio_manager.h> 29 #include <v1_0/iaudio_callback.h> 30 #include <v1_0/audio_types.h> 31 32 enum class DeviceStatus : uint32_t { 33 DEVICE_IDLE = 0, 34 DEVICE_OPEN = 1, 35 DEVICE_START = 2, 36 DEVICE_STOP = 3, 37 }; 38 39 struct WAV_HEADER { 40 /* RIFF Chunk Descriptor */ 41 uint8_t riff[4] = {'R', 'I', 'F', 'F'}; 42 uint32_t chunkSize = 0; 43 uint8_t wave[4] = {'W', 'A', 'V', 'E'}; 44 /* "fmt" sub-chunk */ 45 uint8_t fmt[4] = {'f', 'm', 't', ' '}; 46 uint32_t subchunk1Size = 16; 47 uint16_t audioFormat = 1; 48 uint16_t numOfChan = 2; 49 uint32_t samplesPerSec = 44100; 50 uint32_t bytesPerSec = 176400; 51 uint16_t blockAlign = 2; 52 uint16_t bitsPerSample = 16; 53 /* "data" sub-chunk */ 54 uint8_t subchunk2ID[4] = {'d', 'a', 't', 'a'}; 55 uint32_t subchunk2Size = 0; 56 }; 57 using WavHdr = struct WAV_HEADER; 58 59 #endif