io.agora.rtc.utils

## Class VadDumpUtils

- java.lang.Object
- - io.agora.rtc.utils.VadDumpUtils

-     public class VadDumpUtils
      extends java.lang.Object

  Utility class for VAD dump operations.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `private int` | `count` Segment count
    `private java.lang.String` | `filePath` File path for dump
    `private int` | `frameCount` Frame count
    `private java.io.PrintWriter` | `labelFile` Label file writer
    `private java.lang.String` | `rootPath` Root path for dump
    `private int` | `sessionCount` Session count
    `private java.io.FileOutputStream` | `sourceFile` Source file output stream
    `private java.io.FileOutputStream` | `vadFile` VAD file output stream
    `private java.io.PrintWriter` | `vadInfoFile` VAD info file writer
    `private AgoraAudioVadV2` | `vadInstance` VAD instance for adaptive threshold info
    `private java.util.concurrent.ExecutorService` | `writeFileExecutorService` Executor service for file writing

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `VadDumpUtils(java.lang.String path)` Constructs VadDumpUtils with path.
    `VadDumpUtils(java.lang.String path, AgoraAudioVadV2 vadInstance)` Constructs VadDumpUtils with path and VAD instance.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `private void` | `closeVadFile()` Closes the current VAD file and logs adaptive threshold info.
    `private void` | `createVadFile()` Creates a new VAD file for the current session.
    `private void` | `createVadInfoFile()` Creates the VAD info file.
    `private java.lang.String` | `getStateName(Constants.VadState state)` Get state name for better readability
    `private boolean` | `open()` Opens source and label files.
    `void` | `release()` Releases all resources and closes all files.
    `void` | `setVadInstance(AgoraAudioVadV2 vadInstance)` Set VAD instance for adaptive threshold info dumping.
    `void` | `write(AudioFrame frame, byte[] vadResultBytes, Constants.VadState vadResultState)` Writes audio frame and VAD result to dump files.

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

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

- - ### Field Detail

    - #### filePath

          private java.lang.String filePath

      File path for dump

    - #### rootPath

          private java.lang.String rootPath

      Root path for dump

    - #### count

          private int count

      Segment count

    - #### frameCount

          private int frameCount

      Frame count

    - #### sessionCount

          private int sessionCount

      Session count

    - #### sourceFile

          private java.io.FileOutputStream sourceFile

      Source file output stream

    - #### labelFile

          private java.io.PrintWriter labelFile

      Label file writer

    - #### vadFile

          private java.io.FileOutputStream vadFile

      VAD file output stream

    - #### vadInfoFile

          private java.io.PrintWriter vadInfoFile

      VAD info file writer

    - #### writeFileExecutorService

          private final java.util.concurrent.ExecutorService writeFileExecutorService

      Executor service for file writing

    - #### vadInstance

          private AgoraAudioVadV2 vadInstance

      VAD instance for adaptive threshold info

  - ### Constructor Detail

    - #### VadDumpUtils

          public VadDumpUtils(java.lang.String path)

      Constructs VadDumpUtils with path.
      Parameters:
        `path` - The dump path

    - #### VadDumpUtils

          public VadDumpUtils(java.lang.String path,
                              AgoraAudioVadV2 vadInstance)

      Constructs VadDumpUtils with path and VAD instance.
      Parameters:
        `path` - The dump path
        `vadInstance` - The VAD instance for adaptive threshold tracking

  - ### Method Detail

    - #### setVadInstance

          public void setVadInstance(AgoraAudioVadV2 vadInstance)

      Set VAD instance for adaptive threshold info dumping.
      Parameters:
        `vadInstance` - the VAD instance to use for threshold tracking

    - #### createVadInfoFile

          private void createVadInfoFile()

      Creates the VAD info file.

    - #### createVadFile

          private void createVadFile()

      Creates a new VAD file for the current session.

    - #### closeVadFile

          private void closeVadFile()

      Closes the current VAD file and logs adaptive threshold info.

    - #### open

          private boolean open()

      Opens source and label files.
      Returns:
        true if files were opened successfully, false otherwise

    - #### write

          public void write(AudioFrame frame,
                            byte[] vadResultBytes,
                            Constants.VadState vadResultState)

      Writes audio frame and VAD result to dump files.
      Parameters:
        `frame` - The audio frame
        `vadResultBytes` - The VAD result bytes
        `vadResultState` - The VAD result state

    - #### getStateName

          private java.lang.String getStateName(Constants.VadState state)

      Get state name for better readability
      Parameters:
        `state` - the VAD state
      Returns:
        the human-readable state name

    - #### release

          public void release()

      Releases all resources and closes all files.