Agora RTC Objective-C API Reference Refactor

Data Structures | Public Types | Public Member Functions
ILocalAudioTrack Class Referenceabstract

Inherits IAudioTrack.

## Data Structures
struct | LocalAudioTrackStats

## Public Types
enum | AudioFilterPosition { RecordingLocalPlayback, PostAudioProcessing, RemoteUserPlayback, PcmSource, PcmSourceSending, PcmSourceLocalPlayback, RemoteMixedPlayback }

## Public Member Functions
virtual int | setEnabled (bool enable, aosl_ref_t ares=AOSL_REF_INVALID)=0
virtual bool | isEnabled () const =0
virtual LOCAL_AUDIO_STREAM_STATE | getState ()=0
virtual LocalAudioTrackStats | GetStats ()=0
virtual int | adjustPublishVolume (int volume, aosl_ref_t ares=AOSL_REF_INVALID)=0
virtual int | getPublishVolume (int *volume)=0
virtual int | enableLocalPlayback (bool enable, bool sync=true, aosl_ref_t ares=AOSL_REF_INVALID)=0
virtual int | enableEarMonitor (bool enable, int includeAudioFilters, aosl_ref_t ares=AOSL_REF_INVALID)=0
virtual int | registerTrackObserver (ILocalAudioTrackObserver *observer, aosl_ref_t ares=AOSL_REF_INVALID)=0
virtual int | unregisterTrackObserver (ILocalAudioTrackObserver *observer)=0
virtual void | setMaxBufferedAudioFrameNumber (int number, aosl_ref_t ares=AOSL_REF_INVALID)=0
virtual int | ClearSenderBuffer ()=0
virtual int | adjustPlayoutVolume (int volume, aosl_ref_t ares=AOSL_REF_INVALID)=0
virtual int | getPlayoutVolume (int *volume)=0
virtual bool | addAudioFilter (agora_refptr< IAudioFilter > filter, AudioFilterPosition position, ExtensionContext *extContext=NULL, aosl_ref_t ares=AOSL_REF_INVALID)=0
virtual bool | removeAudioFilter (agora_refptr< IAudioFilter > filter, AudioFilterPosition position, aosl_ref_t ares=AOSL_REF_INVALID)=0
virtual int | enableAudioFilter (const char *id, bool enable, AudioFilterPosition position, aosl_ref_t ares=AOSL_REF_INVALID)
virtual int | setFilterProperty (const char *id, const char *key, const char *jsonValue, AudioFilterPosition position, aosl_ref_t ares=AOSL_REF_INVALID)
virtual int | getFilterProperty (const char *id, const char *key, char *jsonValue, size_t bufSize, AudioFilterPosition position)
virtual agora_refptr< IAudioFilter > | getAudioFilter (const char *name, AudioFilterPosition position) const =0
virtual bool | addAudioSink (agora_refptr< IAudioSinkBase > sink, const AudioSinkWants &wants, aosl_ref_t ares=AOSL_REF_INVALID)=0
virtual bool | removeAudioSink (agora_refptr< IAudioSinkBase > sink, aosl_ref_t ares=AOSL_REF_INVALID)=0

## Detailed Description

`ILocalAudioTrack` is the basic class for local audio tracks, providing main methods of local audio tracks.

You can create a local audio track by calling one of the following methods:

- `createLocalAudioTrack`
- `createCustomAudioTrack`
- `createMediaPlayerAudioTrack` You can also use the APIs in the IAudioDeviceManager class if multiple recording devices are available in the system.

After creating local audio tracks, you can publish one or more local audio tracks by calling publishAudio.

## Member Enumeration Documentation

## ◆ AudioFilterPosition

enum AudioFilterPosition
| inherited

The position of the audio filter in audio frame.

Enumerator
RecordingLocalPlayback | Work on the local playback
PostAudioProcessing | Work on the post audio processing.
RemoteUserPlayback | Work on the remote audio before mixing.
PcmSource | Work on the pcm source.
PcmSourceSending | Work on the sending branch of the pcm source.
PcmSourceLocalPlayback | Work on the local playback branch of the pcm source.
RemoteMixedPlayback | Work on the playback after remote-audio mix.

## Constructor & Destructor Documentation

## ◆ ~ILocalAudioTrack()

~ILocalAudioTrack | ( |  | ) |
| inline protected

## Member Function Documentation

## ◆ setEnabled()

virtual int setEnabled | ( | bool | enable,
|  | aosl_ref_t | ares = `AOSL_REF_INVALID`
| ) |  |
| pure virtual

Enables or disables the local audio track.

Once the local audio is enabled, the SDK allows for local audio capturing, processing, and encoding.

Parameters

  enable | Whether to enable the audio track: `true`: Enable the local audio track. `false`: Disable the local audio track.

## ◆ isEnabled()

virtual bool isEnabled | ( |  | ) | const
| pure virtual

Gets whether the local audio track is enabled.

Returns
  Whether the local audio track is enabled:
  - `true`: The local track is enabled.
  - `false`: The local track is disabled.

## ◆ getState()

virtual LOCAL_AUDIO_STREAM_STATE getState | ( |  | ) |
| pure virtual

Gets the state of the local audio.

Returns
  The state of the local audio: LOCAL_AUDIO_STREAM_STATE: Success.

## ◆ GetStats()

virtual LocalAudioTrackStats GetStats | ( |  | ) |
| pure virtual

Gets the statistics of the local audio track: LocalAudioTrackStats.

Returns
  The statistics of the local audio: LocalAudioTrackStats: Success.

## ◆ adjustPublishVolume()

virtual int adjustPublishVolume | ( | int | volume,
|  | aosl_ref_t | ares = `AOSL_REF_INVALID`
| ) |  |
| pure virtual

Adjusts the audio volume for publishing.

Parameters

  volume | The volume for publishing. The value ranges between 0 and 100 (default).

Returns
  - 0: Success.
  - < 0: Failure.

## ◆ getPublishVolume()

virtual int getPublishVolume | ( | int * | volume | ) |
| pure virtual

Gets the current volume for publishing.

Parameters

  volume | A pointer to the publishing volume.

Returns
  - 0: Success.
  - < 0: Failure.

## ◆ enableLocalPlayback()

virtual int enableLocalPlayback | ( | bool | enable,
|  | bool | sync = `true`,
|  | aosl_ref_t | ares = `AOSL_REF_INVALID`
| ) |  |
| pure virtual

Enables or disables local playback.

Parameters

  enable | Whether to enable local playback: `true`: Enable local playback. `false`: Disable local playback.
  sync | Whether to destroy local playback synchronously: `true`: Destroy local playback synchronously. `false`: Destroy local playback asynchronously.

Returns
  - 0: Success.
  - < 0: Failure.

## ◆ enableEarMonitor()

virtual int enableEarMonitor | ( | bool | enable,
|  | int | includeAudioFilters,
|  | aosl_ref_t | ares = `AOSL_REF_INVALID`
| ) |  |
| pure virtual

Enables in-ear monitoring (for Android and iOS only).

Parameters

  enabled | Determines whether to enable in-ear monitoring. true: Enable. false: (Default) Disable.
  includeAudioFilters | The type of the ear monitoring: EAR_MONITORING_FILTER_TYPE

Returns
  - 0: Success.
  - < 0: Failure.

## ◆ registerTrackObserver()

virtual int registerTrackObserver | ( | ILocalAudioTrackObserver * | observer,
|  | aosl_ref_t | ares = `AOSL_REF_INVALID`
| ) |  |
| pure virtual

Register an local audio track observer

Parameters

  observer | A pointer to the local audio track observer: ILocalAudioTrackObserver.

Returns
  - 0: Success.
  - < 0: Failure.

## ◆ unregisterTrackObserver()

virtual int unregisterTrackObserver | ( | ILocalAudioTrackObserver * | observer | ) |
| pure virtual

Releases the local audio track observer

Parameters

  observer | A pointer to the local audio track observer: ILocalAudioTrackObserver.

Returns
  - 0: Success.
  - < 0: Failure.

## ◆ setMaxBufferedAudioFrameNumber()

virtual void setMaxBufferedAudioFrameNumber | ( | int | number,
|  | aosl_ref_t | ares = `AOSL_REF_INVALID`
| ) |  |
| pure virtual

set Max buffered audio frame number

Parameters

  number | : the buffer number set，unit is 10ms

## ◆ ClearSenderBuffer()

virtual int ClearSenderBuffer | ( |  | ) |
| pure virtual

clear sender buffer

Returns
  - >= 0: Frame number in sender buffer.
  - < 0: Failure.

## ◆ adjustPlayoutVolume()

virtual int adjustPlayoutVolume | ( | int | volume,
|  | aosl_ref_t | ares = `AOSL_REF_INVALID`
| ) |  |
| pure virtual inherited

Adjusts the playback volume.

Parameters

  volume | The playback volume. The value ranges between 0 and 100 (default).

Returns
  - 0: Success.
  - < 0: Failure.

## ◆ getPlayoutVolume()

virtual int getPlayoutVolume | ( | int * | volume | ) |
| pure virtual inherited

Gets the current playback volume.

Parameters

  volume | A pointer to the playback volume.

Returns
  - 0: Success.
  - < 0: Failure.

## ◆ addAudioFilter()

virtual bool addAudioFilter | ( | agora_refptr< IAudioFilter > | filter,
|  | AudioFilterPosition | position,
|  | ExtensionContext * | extContext = `NULL`,
|  | aosl_ref_t | ares = `AOSL_REF_INVALID`
| ) |  |
| pure virtual inherited

Adds an audio filter.

By adding an audio filter, you can apply various audio effects to the audio, for example, voice change.

Parameters

  filter | A pointer to the audio filter. See IAudioFilter.
  position | The position of the audio filter. See AudioFilterPosition.
  extContext | The context of current filter. See ExtensionContext.

Returns
  - `true`: Success.
  - `false`: Failure.

## ◆ removeAudioFilter()

virtual bool removeAudioFilter | ( | agora_refptr< IAudioFilter > | filter,
|  | AudioFilterPosition | position,
|  | aosl_ref_t | ares = `AOSL_REF_INVALID`
| ) |  |
| pure virtual inherited

Removes the audio filter added by callling `addAudioFilter`.

Parameters

  filter | The pointer to the audio filter that you want to remove. See IAudioFilter.
  position | The position of the audio filter. See AudioFilterPosition.

Returns
  - `true`: Success.
  - `false`: Failure.

## ◆ enableAudioFilter()

virtual int enableAudioFilter | ( | const char * | id,
|  | bool | enable,
|  | AudioFilterPosition | position,
|  | aosl_ref_t | ares = `AOSL_REF_INVALID`
| ) |  |
| inline virtual inherited

Enable / Disable specified audio filter

Parameters

  id | id of the filter
  enable | enable / disable the filter with given id
  position | The position of the audio filter. See AudioFilterPosition.

Returns
  - 0: success
  - <0: failure

## ◆ setFilterProperty()

virtual int setFilterProperty | ( | const char * | id,
|  | const char * | key,
|  | const char * | jsonValue,
|  | AudioFilterPosition | position,
|  | aosl_ref_t | ares = `AOSL_REF_INVALID`
| ) |  |
| inline virtual inherited

set the properties of the specified audio filter

Parameters

  id | id of the filter
  key | key of the property
  jsonValue | json str value of the property
  position | The position of the audio filter. See AudioFilterPosition.

Returns
  - 0: success
  - <0: failure

## ◆ getFilterProperty()

virtual int getFilterProperty | ( | const char * | id,
|  | const char * | key,
|  | char * | jsonValue,
|  | size_t | bufSize,
|  | AudioFilterPosition | position
| ) |  |
| inline virtual inherited

get the properties of the specified video filter

Parameters

  id | id of the filter
  key | key of the property
  jsonValue | json str value of the property
  bufSize | max length of the json value buffer
  position | The position of the audio filter. See AudioFilterPosition.

Returns
  - 0: success
  - <0: failure

## ◆ getAudioFilter()

virtual agora_refptr<IAudioFilter> getAudioFilter | ( | const char * | name,
|  | AudioFilterPosition | position
| ) |  | const
| pure virtual inherited

Gets the audio filter by its name.

Parameters

  name | The name of the audio filter.
  position | The position of the audio filter. See AudioFilterPosition.

Returns
  - The pointer to the audio filter: Success.
  - A null pointer: Failure.

## ◆ addAudioSink()

virtual bool addAudioSink | ( | agora_refptr< IAudioSinkBase > | sink,
|  | const AudioSinkWants & | wants,
|  | aosl_ref_t | ares = `AOSL_REF_INVALID`
| ) |  |
| pure virtual inherited

Adds an audio sink to get PCM data from the audio track.

Parameters

  sink | The pointer to the audio sink. See IAudioSinkBase.
  wants | The properties an audio frame should have when it is delivered to the sink. See AudioSinkWants.

Returns
  - `true`: Success.
  - `false`: Failure.

## ◆ removeAudioSink()

virtual bool removeAudioSink | ( | agora_refptr< IAudioSinkBase > | sink,
|  | aosl_ref_t | ares = `AOSL_REF_INVALID`
| ) |  |
| pure virtual inherited

Removes an audio sink.

Parameters

  sink | The pointer to the audio sink to be removed. See IAudioSinkBase.

Returns
  - `true`: Success.
  - `false`: Failure.

## ◆ AddRef()

virtual void AddRef | ( |  | ) | const
| pure virtual inherited

## ◆ Release()

virtual RefCountReleaseStatus Release | ( |  | ) | const
| pure virtual inherited

## ◆ HasOneRef()

virtual bool HasOneRef | ( |  | ) | const
| pure virtual inherited