1 /* 2 * Copyright (c) 2025 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 /** 18 * @addtogroup LowPowerAudioSink 19 * @{ 20 * 21 * @brief The LowPowerAudioSink sub module provides variables, properties, 22 * and functions for lowpower audio sink. 23 * 24 * @since 20 25 */ 26 27 /** 28 * @file lowpower_audio_sink_base.h 29 * 30 * @brief Declare the Native API used for lowpower audio sink. 31 * 32 * @library liblowpower_avsink.so 33 * @kit MediaKit 34 * @syscap SystemCapability.Multimedia.Media.LowPowerAVSink 35 * @since 20 36 */ 37 38 #ifndef NATIVE_LOWERPOWER_AUDIOSINK_BASH_H 39 #define NATIVE_LOWERPOWER_AUDIOSINK_BASH_H 40 41 #include <stdint.h> 42 #include "lowpower_avsink_base.h" 43 #include "native_audiostream_base.h" 44 45 #ifdef __cplusplus 46 extern "C" { 47 #endif 48 49 /** 50 * @brief Forward declaration of OH_LowPowerAudioSink. 51 * 52 * @since 20 53 */ 54 typedef struct OH_LowPowerAudioSink OH_LowPowerAudioSink; 55 56 /** 57 * @brief Forward declaration of OH_LowPowerAudioSinkCallback. 58 * 59 * @since 20 60 */ 61 typedef struct OH_LowPowerAudioSinkCallback OH_LowPowerAudioSinkCallback; 62 63 /** 64 * @brief When an error occurs in the running of the OH_LowPowerAudioSink instance, the function pointer will be called 65 * to report specific error information. 66 * 67 * @param {OH_LowPowerAudioSink*} sink OH_LowPowerAudioSink instance 68 * @param {OH_AVErrCode} errorCode Error code when an error occurs 69 * @param {const char*} errorMsg Error description information 70 * @param {void*} userData User specific data 71 * @since 20 72 */ 73 typedef void (*OH_LowPowerAudioSink_OnError)( 74 OH_LowPowerAudioSink* sink, 75 OH_AVErrCode errCode, 76 const char* errorMsg, 77 void* userData); 78 79 /** 80 * @brief When the OH_LowPowerAudioSink instance report current play position, the function pointer will be called 81 * to report position information. 82 * 83 * @param {OH_LowPowerAudioSink*} sink OH_LowPowerAudioSink instance 84 * @param {int64_t} currentPosition Returns the current playback progress value of the service 85 * @param {void*} userData User specific data 86 * @since 20 87 */ 88 typedef void (*OH_LowPowerAudioSink_OnPositionUpdated)( 89 OH_LowPowerAudioSink* sink, 90 int64_t currentPosition, 91 void* userData); 92 93 /** 94 * @brief When the OH_LowPowerAudioSink instance report to need data, the function pointer will be called 95 * to request data. 96 * 97 * @param {OH_LowPowerAudioSink*} sink OH_LowPowerAudioSink instance 98 * @param {OH_AVSamplesBuffer*} samples OH_AVSamplesBuffer instance that will be written in 99 * @param {void*} userData User specific data 100 * @since 20 101 */ 102 typedef void (*OH_LowPowerAudioSink_OnDataNeeded)( 103 OH_LowPowerAudioSink* sink, 104 OH_AVSamplesBuffer* samples, 105 void* userData); 106 107 /** 108 * @brief This function pointer will point to the callback function that 109 * is used to handle audio interrupt events. 110 * 111 * @param {OH_LowPowerAudioSink*} sink OH_LowPowerAudioSink instance 112 * @param {OH_AudioInterrupt_ForceType} type The audio interrupt type, 113 * please refer to {@link OH_AudioInterrupt_ForceType} 114 * @param {OH_AudioInterrupt_Hint} hint The audio interrupt hint type, please refer to {@link OH_AudioInterrupt_Hint} 115 * @param {void*} userData User specific data 116 * @since 20 117 */ 118 typedef void (*OH_LowPowerAudioSink_OnInterrupted)( 119 OH_LowPowerAudioSink* sink, 120 OH_AudioInterrupt_ForceType type, 121 OH_AudioInterrupt_Hint hint, 122 void* userData); 123 124 /** 125 * @brief When the output device of an audio renderer changed, the function pointer will be called 126 * to report device change reason. 127 * 128 * @param {OH_LowPowerAudioSink*} sink OH_LowPowerAudioSink instance 129 * @param {OH_AudioStream_DeviceChangeReason} reason Indicates that why does the output device changes, 130 * please refer to {@link OH_AudioStream_DeviceChangeReason} 131 * @param {void*} userData User specific data 132 * @since 20 133 */ 134 typedef void (*OH_LowPowerAudioSink_OnDeviceChanged)( 135 OH_LowPowerAudioSink* sink, 136 OH_AudioStream_DeviceChangeReason reason, 137 void* userData); 138 139 /** 140 * @brief When the lowpower audio sink play to end of stream, the function pointer will be called 141 * to report play completed event. 142 * 143 * @param {OH_LowPowerAudioSink*} sink OH_LowPowerAudioSinkinstance 144 * @param {void*} userData User specific data 145 * @since 20 146 */ 147 typedef void (*OH_LowPowerAudioSink_OnEos)(OH_LowPowerAudioSink* sink, void* userData); 148 149 #ifdef __cplusplus 150 } 151 #endif 152 #endif // NATIVE_LOWERPOWER_AUDIOSINK_BASH_H 153 154 /** @} */