xref: /aosp_15_r20/external/webrtc/sdk/objc/components/audio/RTCAudioDevice.h (revision d9f758449e529ab9291ac668be2861e7a55c2422)
1*d9f75844SAndroid Build Coastguard Worker /*
2*d9f75844SAndroid Build Coastguard Worker  *  Copyright 2022 The WebRTC project authors. All Rights Reserved.
3*d9f75844SAndroid Build Coastguard Worker  *
4*d9f75844SAndroid Build Coastguard Worker  *  Use of this source code is governed by a BSD-style license
5*d9f75844SAndroid Build Coastguard Worker  *  that can be found in the LICENSE file in the root of the source
6*d9f75844SAndroid Build Coastguard Worker  *  tree. An additional intellectual property rights grant can be found
7*d9f75844SAndroid Build Coastguard Worker  *  in the file PATENTS.  All contributing project authors may
8*d9f75844SAndroid Build Coastguard Worker  *  be found in the AUTHORS file in the root of the source tree.
9*d9f75844SAndroid Build Coastguard Worker  */
10*d9f75844SAndroid Build Coastguard Worker 
11*d9f75844SAndroid Build Coastguard Worker #import <AudioUnit/AudioUnit.h>
12*d9f75844SAndroid Build Coastguard Worker #import <Foundation/Foundation.h>
13*d9f75844SAndroid Build Coastguard Worker 
14*d9f75844SAndroid Build Coastguard Worker #import "RTCMacros.h"
15*d9f75844SAndroid Build Coastguard Worker 
16*d9f75844SAndroid Build Coastguard Worker NS_ASSUME_NONNULL_BEGIN
17*d9f75844SAndroid Build Coastguard Worker 
18*d9f75844SAndroid Build Coastguard Worker typedef OSStatus (^RTC_OBJC_TYPE(RTCAudioDeviceGetPlayoutDataBlock))(
19*d9f75844SAndroid Build Coastguard Worker     AudioUnitRenderActionFlags *_Nonnull actionFlags,
20*d9f75844SAndroid Build Coastguard Worker     const AudioTimeStamp *_Nonnull timestamp,
21*d9f75844SAndroid Build Coastguard Worker     NSInteger inputBusNumber,
22*d9f75844SAndroid Build Coastguard Worker     UInt32 frameCount,
23*d9f75844SAndroid Build Coastguard Worker     AudioBufferList *_Nonnull outputData);
24*d9f75844SAndroid Build Coastguard Worker 
25*d9f75844SAndroid Build Coastguard Worker typedef OSStatus (^RTC_OBJC_TYPE(RTCAudioDeviceRenderRecordedDataBlock))(
26*d9f75844SAndroid Build Coastguard Worker     AudioUnitRenderActionFlags *_Nonnull actionFlags,
27*d9f75844SAndroid Build Coastguard Worker     const AudioTimeStamp *_Nonnull timestamp,
28*d9f75844SAndroid Build Coastguard Worker     NSInteger inputBusNumber,
29*d9f75844SAndroid Build Coastguard Worker     UInt32 frameCount,
30*d9f75844SAndroid Build Coastguard Worker     AudioBufferList *_Nonnull inputData,
31*d9f75844SAndroid Build Coastguard Worker     void *_Nullable renderContext);
32*d9f75844SAndroid Build Coastguard Worker 
33*d9f75844SAndroid Build Coastguard Worker typedef OSStatus (^RTC_OBJC_TYPE(RTCAudioDeviceDeliverRecordedDataBlock))(
34*d9f75844SAndroid Build Coastguard Worker     AudioUnitRenderActionFlags *_Nonnull actionFlags,
35*d9f75844SAndroid Build Coastguard Worker     const AudioTimeStamp *_Nonnull timestamp,
36*d9f75844SAndroid Build Coastguard Worker     NSInteger inputBusNumber,
37*d9f75844SAndroid Build Coastguard Worker     UInt32 frameCount,
38*d9f75844SAndroid Build Coastguard Worker     const AudioBufferList *_Nullable inputData,
39*d9f75844SAndroid Build Coastguard Worker     void *_Nullable renderContext,
40*d9f75844SAndroid Build Coastguard Worker     NS_NOESCAPE RTC_OBJC_TYPE(RTCAudioDeviceRenderRecordedDataBlock) _Nullable renderBlock);
41*d9f75844SAndroid Build Coastguard Worker 
42*d9f75844SAndroid Build Coastguard Worker /**
43*d9f75844SAndroid Build Coastguard Worker  * Delegate object provided by native ADM during RTCAudioDevice initialization.
44*d9f75844SAndroid Build Coastguard Worker  * Provides blocks to poll playback audio samples from native ADM and to feed
45*d9f75844SAndroid Build Coastguard Worker  * recorded audio samples into native ADM.
46*d9f75844SAndroid Build Coastguard Worker  */
47*d9f75844SAndroid Build Coastguard Worker RTC_OBJC_EXPORT @protocol RTC_OBJC_TYPE
48*d9f75844SAndroid Build Coastguard Worker (RTCAudioDeviceDelegate)<NSObject>
49*d9f75844SAndroid Build Coastguard Worker     /**
50*d9f75844SAndroid Build Coastguard Worker      * Implementation of RTCAudioSource should call this block to feed recorded PCM (16-bit integer)
51*d9f75844SAndroid Build Coastguard Worker      * into native ADM. Stereo data is expected to be interleaved starting with the left channel.
52*d9f75844SAndroid Build Coastguard Worker      * Either `inputData` with pre-filled audio data must be provided during block
53*d9f75844SAndroid Build Coastguard Worker      * call or `renderBlock` must be provided which must fill provided audio buffer with recorded
54*d9f75844SAndroid Build Coastguard Worker      * samples.
55*d9f75844SAndroid Build Coastguard Worker      *
56*d9f75844SAndroid Build Coastguard Worker      * NOTE: Implementation of RTCAudioDevice is expected to call the block on the same thread until
57*d9f75844SAndroid Build Coastguard Worker      * `notifyAudioInterrupted` is called. When `notifyAudioInterrupted` is called implementation
58*d9f75844SAndroid Build Coastguard Worker      * can call the block on a different thread.
59*d9f75844SAndroid Build Coastguard Worker      */
60*d9f75844SAndroid Build Coastguard Worker     @property(readonly, nonnull)
61*d9f75844SAndroid Build Coastguard Worker         RTC_OBJC_TYPE(RTCAudioDeviceDeliverRecordedDataBlock) deliverRecordedData;
62*d9f75844SAndroid Build Coastguard Worker 
63*d9f75844SAndroid Build Coastguard Worker /**
64*d9f75844SAndroid Build Coastguard Worker  * Provides input sample rate preference as it preferred by native ADM.
65*d9f75844SAndroid Build Coastguard Worker  */
66*d9f75844SAndroid Build Coastguard Worker @property(readonly) double preferredInputSampleRate;
67*d9f75844SAndroid Build Coastguard Worker 
68*d9f75844SAndroid Build Coastguard Worker /**
69*d9f75844SAndroid Build Coastguard Worker  * Provides input IO buffer duration preference as it preferred by native ADM.
70*d9f75844SAndroid Build Coastguard Worker  */
71*d9f75844SAndroid Build Coastguard Worker @property(readonly) NSTimeInterval preferredInputIOBufferDuration;
72*d9f75844SAndroid Build Coastguard Worker 
73*d9f75844SAndroid Build Coastguard Worker /**
74*d9f75844SAndroid Build Coastguard Worker  * Provides output sample rate preference as it preferred by native ADM.
75*d9f75844SAndroid Build Coastguard Worker  */
76*d9f75844SAndroid Build Coastguard Worker @property(readonly) double preferredOutputSampleRate;
77*d9f75844SAndroid Build Coastguard Worker 
78*d9f75844SAndroid Build Coastguard Worker /**
79*d9f75844SAndroid Build Coastguard Worker  * Provides output IO buffer duration preference as it preferred by native ADM.
80*d9f75844SAndroid Build Coastguard Worker  */
81*d9f75844SAndroid Build Coastguard Worker @property(readonly) NSTimeInterval preferredOutputIOBufferDuration;
82*d9f75844SAndroid Build Coastguard Worker 
83*d9f75844SAndroid Build Coastguard Worker /**
84*d9f75844SAndroid Build Coastguard Worker  * Implementation of RTCAudioDevice should call this block to request PCM (16-bit integer)
85*d9f75844SAndroid Build Coastguard Worker  * from native ADM to play. Stereo data is interleaved starting with the left channel.
86*d9f75844SAndroid Build Coastguard Worker  *
87*d9f75844SAndroid Build Coastguard Worker  * NOTE: Implementation of RTCAudioDevice is expected to invoke of this block on the
88*d9f75844SAndroid Build Coastguard Worker  * same thread until `notifyAudioInterrupted` is called. When `notifyAudioInterrupted` is called
89*d9f75844SAndroid Build Coastguard Worker  * implementation can call the block from a different thread.
90*d9f75844SAndroid Build Coastguard Worker  */
91*d9f75844SAndroid Build Coastguard Worker @property(readonly, nonnull) RTC_OBJC_TYPE(RTCAudioDeviceGetPlayoutDataBlock) getPlayoutData;
92*d9f75844SAndroid Build Coastguard Worker 
93*d9f75844SAndroid Build Coastguard Worker /**
94*d9f75844SAndroid Build Coastguard Worker  * Notifies native ADM that some of the audio input parameters of RTCAudioDevice like
95*d9f75844SAndroid Build Coastguard Worker  * samle rate and/or IO buffer duration and/or IO latency had possibly changed.
96*d9f75844SAndroid Build Coastguard Worker  * Native ADM will adjust its audio input buffer to match current parameters of audio device.
97*d9f75844SAndroid Build Coastguard Worker  *
98*d9f75844SAndroid Build Coastguard Worker  * NOTE: Must be called within block executed via `dispatchAsync` or `dispatchSync`.
99*d9f75844SAndroid Build Coastguard Worker  */
100*d9f75844SAndroid Build Coastguard Worker - (void)notifyAudioInputParametersChange;
101*d9f75844SAndroid Build Coastguard Worker 
102*d9f75844SAndroid Build Coastguard Worker /**
103*d9f75844SAndroid Build Coastguard Worker  * Notifies native ADM that some of the audio output parameters of RTCAudioDevice like
104*d9f75844SAndroid Build Coastguard Worker  * samle rate and/or IO buffer duration and/or IO latency had possibly changed.
105*d9f75844SAndroid Build Coastguard Worker  * Native ADM will adjust its audio output buffer to match current parameters of audio device.
106*d9f75844SAndroid Build Coastguard Worker  *
107*d9f75844SAndroid Build Coastguard Worker  * NOTE: Must be called within block executed via `dispatchAsync` or `dispatchSync`.
108*d9f75844SAndroid Build Coastguard Worker  */
109*d9f75844SAndroid Build Coastguard Worker - (void)notifyAudioOutputParametersChange;
110*d9f75844SAndroid Build Coastguard Worker 
111*d9f75844SAndroid Build Coastguard Worker /**
112*d9f75844SAndroid Build Coastguard Worker  * Notifies native ADM that audio input is interrupted and further audio playout
113*d9f75844SAndroid Build Coastguard Worker  * and recording might happen on a different thread.
114*d9f75844SAndroid Build Coastguard Worker  *
115*d9f75844SAndroid Build Coastguard Worker  * NOTE: Must be called within block executed via `dispatchAsync` or `dispatchSync`.
116*d9f75844SAndroid Build Coastguard Worker  */
117*d9f75844SAndroid Build Coastguard Worker - (void)notifyAudioInputInterrupted;
118*d9f75844SAndroid Build Coastguard Worker 
119*d9f75844SAndroid Build Coastguard Worker /**
120*d9f75844SAndroid Build Coastguard Worker  * Notifies native ADM that audio output is interrupted and further audio playout
121*d9f75844SAndroid Build Coastguard Worker  * and recording might happen on a different thread.
122*d9f75844SAndroid Build Coastguard Worker  *
123*d9f75844SAndroid Build Coastguard Worker  * NOTE: Must be called within block executed via `dispatchAsync` or `dispatchSync`.
124*d9f75844SAndroid Build Coastguard Worker  */
125*d9f75844SAndroid Build Coastguard Worker - (void)notifyAudioOutputInterrupted;
126*d9f75844SAndroid Build Coastguard Worker 
127*d9f75844SAndroid Build Coastguard Worker /**
128*d9f75844SAndroid Build Coastguard Worker  * Asynchronously execute block of code within the context of
129*d9f75844SAndroid Build Coastguard Worker  * thread which owns native ADM.
130*d9f75844SAndroid Build Coastguard Worker  *
131*d9f75844SAndroid Build Coastguard Worker  * NOTE: Intended to be used to invoke `notifyAudioInputParametersChange`,
132*d9f75844SAndroid Build Coastguard Worker  * `notifyAudioOutputParametersChange`, `notifyAudioInputInterrupted`,
133*d9f75844SAndroid Build Coastguard Worker  * `notifyAudioOutputInterrupted` on native ADM thread.
134*d9f75844SAndroid Build Coastguard Worker  * Also could be used by `RTCAudioDevice` implementation to tie
135*d9f75844SAndroid Build Coastguard Worker  * mutations of underlying audio objects (AVAudioEngine, AudioUnit, etc)
136*d9f75844SAndroid Build Coastguard Worker  * to the native ADM thread. Could be useful to handle events like audio route change, which
137*d9f75844SAndroid Build Coastguard Worker  * could lead to audio parameters change.
138*d9f75844SAndroid Build Coastguard Worker  */
139*d9f75844SAndroid Build Coastguard Worker - (void)dispatchAsync:(dispatch_block_t)block;
140*d9f75844SAndroid Build Coastguard Worker 
141*d9f75844SAndroid Build Coastguard Worker /**
142*d9f75844SAndroid Build Coastguard Worker  * Synchronously execute block of code within the context of
143*d9f75844SAndroid Build Coastguard Worker  * thread which owns native ADM. Allows reentrancy.
144*d9f75844SAndroid Build Coastguard Worker  *
145*d9f75844SAndroid Build Coastguard Worker  * NOTE: Intended to be used to invoke `notifyAudioInputParametersChange`,
146*d9f75844SAndroid Build Coastguard Worker  * `notifyAudioOutputParametersChange`, `notifyAudioInputInterrupted`,
147*d9f75844SAndroid Build Coastguard Worker  * `notifyAudioOutputInterrupted` on native ADM thread and make sure
148*d9f75844SAndroid Build Coastguard Worker  * aforementioned is completed before `dispatchSync` returns. Could be useful
149*d9f75844SAndroid Build Coastguard Worker  * when implementation of `RTCAudioDevice` tie mutation to underlying audio objects (AVAudioEngine,
150*d9f75844SAndroid Build Coastguard Worker  * AudioUnit, etc) to own thread to satisfy requirement that native ADM audio parameters
151*d9f75844SAndroid Build Coastguard Worker  * must be kept in sync with current audio parameters before audio is actually played or recorded.
152*d9f75844SAndroid Build Coastguard Worker  */
153*d9f75844SAndroid Build Coastguard Worker - (void)dispatchSync:(dispatch_block_t)block;
154*d9f75844SAndroid Build Coastguard Worker 
155*d9f75844SAndroid Build Coastguard Worker @end
156*d9f75844SAndroid Build Coastguard Worker 
157*d9f75844SAndroid Build Coastguard Worker /**
158*d9f75844SAndroid Build Coastguard Worker  * Protocol to abstract platform specific ways to implement playback and recording.
159*d9f75844SAndroid Build Coastguard Worker  *
160*d9f75844SAndroid Build Coastguard Worker  * NOTE: All the members of protocol are called by native ADM from the same thread
161*d9f75844SAndroid Build Coastguard Worker  * between calls to `initializeWithDelegate` and `terminate`.
162*d9f75844SAndroid Build Coastguard Worker  * NOTE: Implementation is fully responsible for configuring application's AVAudioSession.
163*d9f75844SAndroid Build Coastguard Worker  * An example implementation of RTCAudioDevice: https://github.com/mstyura/RTCAudioDevice
164*d9f75844SAndroid Build Coastguard Worker  * TODO(yura.yaroshevich): Implement custom RTCAudioDevice for AppRTCMobile demo app.
165*d9f75844SAndroid Build Coastguard Worker  */
166*d9f75844SAndroid Build Coastguard Worker RTC_OBJC_EXPORT @protocol RTC_OBJC_TYPE
167*d9f75844SAndroid Build Coastguard Worker (RTCAudioDevice)<NSObject>
168*d9f75844SAndroid Build Coastguard Worker 
169*d9f75844SAndroid Build Coastguard Worker     /**
170*d9f75844SAndroid Build Coastguard Worker      * Indicates current sample rate of audio recording. Changes to this property
171*d9f75844SAndroid Build Coastguard Worker      * must be notified back to native ADM via `-[RTCAudioDeviceDelegate
172*d9f75844SAndroid Build Coastguard Worker      * notifyAudioParametersChange]`.
173*d9f75844SAndroid Build Coastguard Worker      */
174*d9f75844SAndroid Build Coastguard Worker     @property(readonly) double deviceInputSampleRate;
175*d9f75844SAndroid Build Coastguard Worker 
176*d9f75844SAndroid Build Coastguard Worker /**
177*d9f75844SAndroid Build Coastguard Worker  * Indicates current size of record buffer. Changes to this property
178*d9f75844SAndroid Build Coastguard Worker  * must be notified back to native ADM via `-[RTCAudioDeviceDelegate notifyAudioParametersChange]`.
179*d9f75844SAndroid Build Coastguard Worker  */
180*d9f75844SAndroid Build Coastguard Worker @property(readonly) NSTimeInterval inputIOBufferDuration;
181*d9f75844SAndroid Build Coastguard Worker 
182*d9f75844SAndroid Build Coastguard Worker /**
183*d9f75844SAndroid Build Coastguard Worker  * Indicates current number of recorded audio channels. Changes to this property
184*d9f75844SAndroid Build Coastguard Worker  * must be notified back to native ADM via `-[RTCAudioDeviceDelegate notifyAudioParametersChange]`.
185*d9f75844SAndroid Build Coastguard Worker  */
186*d9f75844SAndroid Build Coastguard Worker @property(readonly) NSInteger inputNumberOfChannels;
187*d9f75844SAndroid Build Coastguard Worker 
188*d9f75844SAndroid Build Coastguard Worker /**
189*d9f75844SAndroid Build Coastguard Worker  * Indicates current input latency
190*d9f75844SAndroid Build Coastguard Worker  */
191*d9f75844SAndroid Build Coastguard Worker @property(readonly) NSTimeInterval inputLatency;
192*d9f75844SAndroid Build Coastguard Worker 
193*d9f75844SAndroid Build Coastguard Worker /**
194*d9f75844SAndroid Build Coastguard Worker  * Indicates current sample rate of audio playback. Changes to this property
195*d9f75844SAndroid Build Coastguard Worker  * must be notified back to native ADM via `-[RTCAudioDeviceDelegate notifyAudioParametersChange]`.
196*d9f75844SAndroid Build Coastguard Worker  */
197*d9f75844SAndroid Build Coastguard Worker @property(readonly) double deviceOutputSampleRate;
198*d9f75844SAndroid Build Coastguard Worker 
199*d9f75844SAndroid Build Coastguard Worker /**
200*d9f75844SAndroid Build Coastguard Worker  * Indicates current size of playback buffer. Changes to this property
201*d9f75844SAndroid Build Coastguard Worker  * must be notified back to native ADM via `-[RTCAudioDeviceDelegate notifyAudioParametersChange]`.
202*d9f75844SAndroid Build Coastguard Worker  */
203*d9f75844SAndroid Build Coastguard Worker @property(readonly) NSTimeInterval outputIOBufferDuration;
204*d9f75844SAndroid Build Coastguard Worker 
205*d9f75844SAndroid Build Coastguard Worker /**
206*d9f75844SAndroid Build Coastguard Worker  * Indicates current number of playback audio channels. Changes to this property
207*d9f75844SAndroid Build Coastguard Worker  * must be notified back to WebRTC via `[RTCAudioDeviceDelegate notifyAudioParametersChange]`.
208*d9f75844SAndroid Build Coastguard Worker  */
209*d9f75844SAndroid Build Coastguard Worker @property(readonly) NSInteger outputNumberOfChannels;
210*d9f75844SAndroid Build Coastguard Worker 
211*d9f75844SAndroid Build Coastguard Worker /**
212*d9f75844SAndroid Build Coastguard Worker  * Indicates current output latency
213*d9f75844SAndroid Build Coastguard Worker  */
214*d9f75844SAndroid Build Coastguard Worker @property(readonly) NSTimeInterval outputLatency;
215*d9f75844SAndroid Build Coastguard Worker 
216*d9f75844SAndroid Build Coastguard Worker /**
217*d9f75844SAndroid Build Coastguard Worker  * Indicates if invocation of `initializeWithDelegate` required before usage of RTCAudioDevice.
218*d9f75844SAndroid Build Coastguard Worker  * YES indicates that `initializeWithDelegate` was called earlier without subsequent call to
219*d9f75844SAndroid Build Coastguard Worker  * `terminate`. NO indicates that either `initializeWithDelegate` not called or `terminate` called.
220*d9f75844SAndroid Build Coastguard Worker  */
221*d9f75844SAndroid Build Coastguard Worker @property(readonly) BOOL isInitialized;
222*d9f75844SAndroid Build Coastguard Worker 
223*d9f75844SAndroid Build Coastguard Worker /**
224*d9f75844SAndroid Build Coastguard Worker  * Initializes RTCAudioDevice with RTCAudioDeviceDelegate.
225*d9f75844SAndroid Build Coastguard Worker  * Implementation must return YES if RTCAudioDevice initialized successfully and NO otherwise.
226*d9f75844SAndroid Build Coastguard Worker  */
227*d9f75844SAndroid Build Coastguard Worker - (BOOL)initializeWithDelegate:(id<RTC_OBJC_TYPE(RTCAudioDeviceDelegate)>)delegate;
228*d9f75844SAndroid Build Coastguard Worker 
229*d9f75844SAndroid Build Coastguard Worker /**
230*d9f75844SAndroid Build Coastguard Worker  * De-initializes RTCAudioDevice. Implementation should forget about `delegate` provided in
231*d9f75844SAndroid Build Coastguard Worker  * `initializeWithDelegate`.
232*d9f75844SAndroid Build Coastguard Worker  */
233*d9f75844SAndroid Build Coastguard Worker - (BOOL)terminateDevice;
234*d9f75844SAndroid Build Coastguard Worker 
235*d9f75844SAndroid Build Coastguard Worker /**
236*d9f75844SAndroid Build Coastguard Worker  * Property to indicate if `initializePlayout` call required before invocation of `startPlayout`.
237*d9f75844SAndroid Build Coastguard Worker  * YES indicates that `initializePlayout` was successfully invoked earlier or not necessary,
238*d9f75844SAndroid Build Coastguard Worker  * NO indicates that `initializePlayout` invocation required.
239*d9f75844SAndroid Build Coastguard Worker  */
240*d9f75844SAndroid Build Coastguard Worker @property(readonly) BOOL isPlayoutInitialized;
241*d9f75844SAndroid Build Coastguard Worker 
242*d9f75844SAndroid Build Coastguard Worker /**
243*d9f75844SAndroid Build Coastguard Worker  * Prepares RTCAudioDevice to play audio.
244*d9f75844SAndroid Build Coastguard Worker  * Called by native ADM before invocation of `startPlayout`.
245*d9f75844SAndroid Build Coastguard Worker  * Implementation is expected to return YES in case of successful playout initialization and NO
246*d9f75844SAndroid Build Coastguard Worker  * otherwise.
247*d9f75844SAndroid Build Coastguard Worker  */
248*d9f75844SAndroid Build Coastguard Worker - (BOOL)initializePlayout;
249*d9f75844SAndroid Build Coastguard Worker 
250*d9f75844SAndroid Build Coastguard Worker /**
251*d9f75844SAndroid Build Coastguard Worker  * Property to indicate if RTCAudioDevice should be playing according to
252*d9f75844SAndroid Build Coastguard Worker  * earlier calls of `startPlayout` and `stopPlayout`.
253*d9f75844SAndroid Build Coastguard Worker  */
254*d9f75844SAndroid Build Coastguard Worker @property(readonly) BOOL isPlaying;
255*d9f75844SAndroid Build Coastguard Worker 
256*d9f75844SAndroid Build Coastguard Worker /**
257*d9f75844SAndroid Build Coastguard Worker  * Method is called when native ADM wants to play audio.
258*d9f75844SAndroid Build Coastguard Worker  * Implementation is expected to return YES if playback start request
259*d9f75844SAndroid Build Coastguard Worker  * successfully handled and NO otherwise.
260*d9f75844SAndroid Build Coastguard Worker  */
261*d9f75844SAndroid Build Coastguard Worker - (BOOL)startPlayout;
262*d9f75844SAndroid Build Coastguard Worker 
263*d9f75844SAndroid Build Coastguard Worker /**
264*d9f75844SAndroid Build Coastguard Worker  * Method is called when native ADM no longer needs to play audio.
265*d9f75844SAndroid Build Coastguard Worker  * Implementation is expected to return YES if playback stop request
266*d9f75844SAndroid Build Coastguard Worker  * successfully handled and NO otherwise.
267*d9f75844SAndroid Build Coastguard Worker  */
268*d9f75844SAndroid Build Coastguard Worker - (BOOL)stopPlayout;
269*d9f75844SAndroid Build Coastguard Worker 
270*d9f75844SAndroid Build Coastguard Worker /**
271*d9f75844SAndroid Build Coastguard Worker  * Property to indicate if `initializeRecording` call required before usage of `startRecording`.
272*d9f75844SAndroid Build Coastguard Worker  * YES indicates that `initializeRecording` was successfully invoked earlier or not necessary,
273*d9f75844SAndroid Build Coastguard Worker  * NO indicates that `initializeRecording` invocation required.
274*d9f75844SAndroid Build Coastguard Worker  */
275*d9f75844SAndroid Build Coastguard Worker @property(readonly) BOOL isRecordingInitialized;
276*d9f75844SAndroid Build Coastguard Worker 
277*d9f75844SAndroid Build Coastguard Worker /**
278*d9f75844SAndroid Build Coastguard Worker  * Prepares RTCAudioDevice to record audio.
279*d9f75844SAndroid Build Coastguard Worker  * Called by native ADM before invocation of `startRecording`.
280*d9f75844SAndroid Build Coastguard Worker  * Implementation may use this method to prepare resources required to record audio.
281*d9f75844SAndroid Build Coastguard Worker  * Implementation is expected to return YES in case of successful record initialization and NO
282*d9f75844SAndroid Build Coastguard Worker  * otherwise.
283*d9f75844SAndroid Build Coastguard Worker  */
284*d9f75844SAndroid Build Coastguard Worker - (BOOL)initializeRecording;
285*d9f75844SAndroid Build Coastguard Worker 
286*d9f75844SAndroid Build Coastguard Worker /**
287*d9f75844SAndroid Build Coastguard Worker  * Property to indicate if RTCAudioDevice should record audio according to
288*d9f75844SAndroid Build Coastguard Worker  * earlier calls to `startRecording` and `stopRecording`.
289*d9f75844SAndroid Build Coastguard Worker  */
290*d9f75844SAndroid Build Coastguard Worker @property(readonly) BOOL isRecording;
291*d9f75844SAndroid Build Coastguard Worker 
292*d9f75844SAndroid Build Coastguard Worker /**
293*d9f75844SAndroid Build Coastguard Worker  * Method is called when native ADM wants to record audio.
294*d9f75844SAndroid Build Coastguard Worker  * Implementation is expected to return YES if recording start request
295*d9f75844SAndroid Build Coastguard Worker  * successfully handled and NO otherwise.
296*d9f75844SAndroid Build Coastguard Worker  */
297*d9f75844SAndroid Build Coastguard Worker - (BOOL)startRecording;
298*d9f75844SAndroid Build Coastguard Worker 
299*d9f75844SAndroid Build Coastguard Worker /**
300*d9f75844SAndroid Build Coastguard Worker  * Method is called when native ADM no longer needs to record audio.
301*d9f75844SAndroid Build Coastguard Worker  * Implementation is expected to return YES if recording stop request
302*d9f75844SAndroid Build Coastguard Worker  * successfully handled and NO otherwise.
303*d9f75844SAndroid Build Coastguard Worker  */
304*d9f75844SAndroid Build Coastguard Worker - (BOOL)stopRecording;
305*d9f75844SAndroid Build Coastguard Worker 
306*d9f75844SAndroid Build Coastguard Worker @end
307*d9f75844SAndroid Build Coastguard Worker 
308*d9f75844SAndroid Build Coastguard Worker NS_ASSUME_NONNULL_END
309