io.agora.rtc

## Class AgoraAudioFrameObserverWrapper

- java.lang.Object
- - io.agora.rtc.AgoraAudioFrameObserverWrapper

- All Implemented Interfaces:
    IAudioFrameObserver

      class AgoraAudioFrameObserverWrapper
      extends java.lang.Object
      implements IAudioFrameObserver

  Wrapper for audio frame observer that integrates VAD functionality.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `private IAudioFrameObserver` | `audioFrameObserver` The wrapped audio frame observer
    `private boolean` | `enableVad` Whether VAD is enabled
    `private AgoraAudioVadManager` | `vadManager` VAD manager instance
    `private VadProcessResult` | `vadProcessResult` VAD processing result

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AgoraAudioFrameObserverWrapper(IAudioFrameObserver observer, boolean enableVad, AgoraAudioVadConfigV2 vadConfig, AgoraServiceConfig agoraServiceConfig)` Constructs an AgoraAudioFrameObserverWrapper.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `destroy()` Destroys the wrapper and releases resources.
    `int` | `getObservedAudioFramePosition()` Gets the observed audio frame position.
    `int` | `onEarMonitoringAudioFrame(AgoraLocalUser agoraLocalUser, AudioFrame frame)` Note: To improve data transmission efficiency, the buffer of the frame object is a DirectByteBuffer.
    `int` | `onMixedAudioFrame(AgoraLocalUser agoraLocalUser, java.lang.String channelId, AudioFrame frame)` Note: To improve data transmission efficiency, the buffer of the frame object is a DirectByteBuffer.
    `int` | `onPlaybackAudioFrame(AgoraLocalUser agoraLocalUser, java.lang.String channelId, AudioFrame frame)` Note: To improve data transmission efficiency, the buffer of the frame object is a DirectByteBuffer.
    `int` | `onPlaybackAudioFrameBeforeMixing(AgoraLocalUser agoraLocalUser, java.lang.String channelId, java.lang.String userId, AudioFrame frame, VadProcessResult vadResult)` Note: To improve data transmission efficiency, the buffer of the frame object is a DirectByteBuffer.
    `int` | `onRecordAudioFrame(AgoraLocalUser agoraLocalUser, java.lang.String channelId, AudioFrame frame)` Note: To improve data transmission efficiency, the buffer of the frame object is a DirectByteBuffer.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### audioFrameObserver

          private volatile IAudioFrameObserver audioFrameObserver

      The wrapped audio frame observer

    - #### enableVad

          private volatile boolean enableVad

      Whether VAD is enabled

    - #### vadManager

          private volatile AgoraAudioVadManager vadManager

      VAD manager instance

    - #### vadProcessResult

          private volatile VadProcessResult vadProcessResult

      VAD processing result

  - ### Constructor Detail

    - #### AgoraAudioFrameObserverWrapper

          public AgoraAudioFrameObserverWrapper(IAudioFrameObserver observer,
                                                boolean enableVad,
                                                AgoraAudioVadConfigV2 vadConfig,
                                                AgoraServiceConfig agoraServiceConfig)

      Constructs an AgoraAudioFrameObserverWrapper.
      Parameters:
        `observer` - Audio frame observer
        `enableVad` - Whether to enable VAD
        `vadConfig` - VAD configuration
        `agoraServiceConfig` - Agora service configuration

  - ### Method Detail

    - #### destroy

          public void destroy()

      Destroys the wrapper and releases resources.

    - #### onRecordAudioFrame

          public int onRecordAudioFrame(AgoraLocalUser agoraLocalUser,
                                        java.lang.String channelId,
                                        AudioFrame frame)

      Description copied from interface: `IAudioFrameObserver`
      Note: To improve data transmission efficiency, the buffer of the frame object is a DirectByteBuffer. Be sure to extract the byte array value in the callback synchronously and then transfer it to the asynchronous thread for processing. You can refer to `Utils.getBytes(ByteBuffer)`.
      Specified by:
        `onRecordAudioFrame` in interface `IAudioFrameObserver`
      Parameters:
        `agoraLocalUser` - the local user
        `channelId` - the channel id
        `frame` - the audio frame
      Returns:
        0/1, the return value currently has no practical significance

    - #### onPlaybackAudioFrame

          public int onPlaybackAudioFrame(AgoraLocalUser agoraLocalUser,
                                          java.lang.String channelId,
                                          AudioFrame frame)

      Description copied from interface: `IAudioFrameObserver`
      Note: To improve data transmission efficiency, the buffer of the frame object is a DirectByteBuffer. Be sure to extract the byte array value in the callback synchronously and then transfer it to the asynchronous thread for processing. You can refer to `Utils.getBytes(ByteBuffer)`.
      Specified by:
        `onPlaybackAudioFrame` in interface `IAudioFrameObserver`
      Parameters:
        `agoraLocalUser` - the local user
        `channelId` - the channel id
        `frame` - the audio frame
      Returns:
        0/1, the return value currently has no practical significance

    - #### onMixedAudioFrame

          public int onMixedAudioFrame(AgoraLocalUser agoraLocalUser,
                                       java.lang.String channelId,
                                       AudioFrame frame)

      Description copied from interface: `IAudioFrameObserver`
      Note: To improve data transmission efficiency, the buffer of the frame object is a DirectByteBuffer. Be sure to extract the byte array value in the callback synchronously and then transfer it to the asynchronous thread for processing. You can refer to `Utils.getBytes(ByteBuffer)`.
      Specified by:
        `onMixedAudioFrame` in interface `IAudioFrameObserver`
      Parameters:
        `agoraLocalUser` - the local user
        `channelId` - the channel id
        `frame` - the audio frame
      Returns:
        0/1, the return value currently has no practical significance

    - #### onEarMonitoringAudioFrame

          public int onEarMonitoringAudioFrame(AgoraLocalUser agoraLocalUser,
                                               AudioFrame frame)

      Description copied from interface: `IAudioFrameObserver`
      Note: To improve data transmission efficiency, the buffer of the frame object is a DirectByteBuffer. Be sure to extract the byte array value in the callback synchronously and then transfer it to the asynchronous thread for processing. You can refer to `Utils.getBytes(ByteBuffer)`.
      Specified by:
        `onEarMonitoringAudioFrame` in interface `IAudioFrameObserver`
      Parameters:
        `agoraLocalUser` - the local user
        `frame` - the audio frame
      Returns:
        0/1, the return value currently has no practical significance

    - #### onPlaybackAudioFrameBeforeMixing

          public int onPlaybackAudioFrameBeforeMixing(AgoraLocalUser agoraLocalUser,
                                                      java.lang.String channelId,
                                                      java.lang.String userId,
                                                      AudioFrame frame,
                                                      VadProcessResult vadResult)

      Description copied from interface: `IAudioFrameObserver`
      Note: To improve data transmission efficiency, the buffer of the frame object is a DirectByteBuffer. Be sure to extract the byte array value in the callback synchronously and then transfer it to the asynchronous thread for processing. You can refer to `Utils.getBytes(ByteBuffer)`.
      Specified by:
        `onPlaybackAudioFrameBeforeMixing` in interface `IAudioFrameObserver`
      Parameters:
        `agoraLocalUser` - the local user
        `channelId` - the channel id
        `userId` - the user id
        `frame` - the audio frame
        `vadResult` - the vad result
      Returns:
        0/1, the return value currently has no practical significance

    - #### getObservedAudioFramePosition

          public int getObservedAudioFramePosition()

      Description copied from interface: `IAudioFrameObserver`
      Gets the observed audio frame position.
      Specified by:
        `getObservedAudioFramePosition` in interface `IAudioFrameObserver`
      Returns:
        Audio frame position