1 /* 2 * Copyright (c) 2024 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 /** 17 * @addtogroup Audio 18 * @{ 19 * 20 * @brief Defines audio-related APIs, including custom data types and functions for loading drivers, 21 * accessing a driver adapter, and rendering and capturing audios. 22 * 23 * @since 1.0 24 * @version 1.0 25 */ 26 27 /** 28 * @file audio_capture.h 29 * 30 * @brief Declares APIs for audio capturing. 31 * 32 * @since 1.0 33 * @version 1.0 34 */ 35 36 #ifndef AUDIO_CAPTURE_H 37 #define AUDIO_CAPTURE_H 38 39 #include "audio_control.h" 40 #include "audio_volume.h" 41 namespace OHOS::HDI::Audio_Bluetooth { 42 /** 43 * @brief Provides capabilities for audio capturing, including controlling the capturing, setting audio attributes, 44 * scenes, and volume, obtaining hardware latency, and capturing audio frames. 45 * 46 * @see AudioControl 47 * @see AudioAttribute 48 * @since 1.0 49 * @version 1.0 50 */ 51 struct AudioCapture { 52 /** 53 * @brief Defines the audio control. For details, see {@link AudioControl}. 54 */ 55 struct AudioControl control; 56 /** 57 * @brief Defines audio volume. For details, see {@link AudioVolume}. 58 */ 59 struct AudioVolume volume; 60 61 /** 62 * @brief Reads a frame of intput data (uplink data) into the audio driver for capturing. 63 * 64 * @param capture Indicates the pointer to the <b>AudioCapture</b> object to operate. 65 * @param frame Indicates the pointer to the frame to read. 66 * @param requestBytes Indicates the size of the frame, in bytes. 67 * @param replyBytes Indicates the pointer to the actual length (in bytes) of the audio data to read. 68 * @return Returns <b>0</b> if the data is read successfully; returns a negative value otherwise. 69 */ 70 int32_t (*CaptureFrame)(struct AudioCapture *capture, void *frame, uint64_t requestBytes, uint64_t *replyBytes); 71 }; 72 } 73 #endif 74