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