1 /* 2 * Copyright (c) 2020-2021 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_types.h" 40 #include "audio_control.h" 41 #include "audio_attribute.h" 42 #include "audio_scene.h" 43 #include "audio_volume.h" 44 45 /** 46 * @brief Provides capabilities for audio capturing, including controlling the capturing, setting audio attributes, 47 * scenes, and volume, and capturing audio frames. 48 * 49 * @see AudioControl 50 * @see AudioAttribute 51 * @see AudioScene 52 * @see AudioVolume 53 * @since 1.0 54 * @version 1.0 55 */ 56 struct AudioCapture { 57 /** 58 * @brief Defines the audio control. For details, see {@link AudioControl}. 59 */ 60 struct AudioControl control; 61 /** 62 * @brief Defines the audio attribute. For details, see {@link AudioAttribute}. 63 */ 64 struct AudioAttribute attr; 65 /** 66 * @brief Defines the audio scene. For details, see {@link AudioScene}. 67 */ 68 struct AudioScene scene; 69 /** 70 * @brief Defines audio volume. For details, see {@link AudioVolume}. 71 */ 72 struct AudioVolume volume; 73 74 /** 75 * @brief Reads a frame of input data (uplink data) from the audio driver for capturing. 76 * 77 * @param capture Indicates the pointer to the <b>AudioCapture</b> object to operate. 78 * @param frame Indicates the pointer to the input data to read. 79 * @param requestBytes Indicates the size of the input data, in bytes. 80 * @param replyBytes Indicates the pointer to the actual length (in bytes) of the audio data to read. 81 * @return Returns <b>0</b> if the input data is read successfully; returns a negative value otherwise. 82 */ 83 int32_t (*CaptureFrame)(struct AudioCapture *capture, void *frame, uint64_t requestBytes, uint64_t *replyBytes); 84 85 /** 86 * @brief Obtains the last number of input audio frames. 87 * 88 * @param capture Indicates the pointer to the <b>AudioCapture</b> object to operate. 89 * @param frames Indicates the pointer to the last number of input audio frames. 90 * @param time Indicates the pointer to the timestamp associated with the frame. 91 * @return Returns <b>0</b> if the last number is obtained; returns a negative value otherwise. 92 * @see CaptureFrame 93 */ 94 int32_t (*GetCapturePosition)(struct AudioCapture *capture, uint64_t *frames, struct AudioTimeStamp *time); 95 }; 96 97 #endif /* AUDIO_CAPTURE_H */ 98 /** @} */ 99