Class LocalAudioTrack

  • All Implemented Interfaces:
    Track

    public class LocalAudioTrack
    extends AudioTrack
    Represents a local audio source.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addSink​(AudioSink audioSink)
      Adds a sink to the Track.
      static LocalAudioTrack create​(android.content.Context context, boolean enabled)
      Creates an audio track.
      static LocalAudioTrack create​(android.content.Context context, boolean enabled, AudioOptions audioOptions)
      Creates an audio track.
      static LocalAudioTrack create​(android.content.Context context, boolean enabled, AudioOptions audioOptions, java.lang.String name)
      Creates an audio track.
      static LocalAudioTrack create​(android.content.Context context, boolean enabled, java.lang.String name)
      Creates an audio track.
      void enable​(boolean enable)
      Sets the state of the local audio track.
      java.lang.String getName()
      Returns the local audio track name.
      boolean isEnabled()
      Check if the local audio track is enabled.
      void release()
      Releases native memory owned by audio track.
      void removeSink​(AudioSink audioSink)
      Removes a sink from the Track.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • create

        @Nullable
        public static LocalAudioTrack create​(@NonNull
                                             android.content.Context context,
                                             boolean enabled)
        Creates an audio track. Note that the RECORD_AUDIO permission must be granted in order for this operation to succeed. If RECORD_AUDIO is not granted null is returned.
        Parameters:
        context - application context.
        enabled - initial state of audio track.
        Returns:
        local audio track if successfully added or null if audio track could not be created.
      • create

        @Nullable
        public static LocalAudioTrack create​(@NonNull
                                             android.content.Context context,
                                             boolean enabled,
                                             @Nullable
                                             AudioOptions audioOptions)
        Creates an audio track. Note that the RECORD_AUDIO permission must be granted in order for this operation to succeed. If RECORD_AUDIO is not granted null is returned.
        Parameters:
        context - application context.
        enabled - initial state of audio track.
        audioOptions - audio options to be applied to the track.
        Returns:
        local audio track if successfully added or null if audio track could not be created.
      • create

        @Nullable
        public static LocalAudioTrack create​(@NonNull
                                             android.content.Context context,
                                             boolean enabled,
                                             @Nullable
                                             java.lang.String name)
        Creates an audio track. Note that the RECORD_AUDIO permission must be granted in order for this operation to succeed. If RECORD_AUDIO is not granted null is returned.
        Parameters:
        context - application context.
        enabled - initial state of audio track.
        name - audio track name.
        Returns:
        local audio track if successfully added or null if audio track could not be created.
      • create

        @Nullable
        public static LocalAudioTrack create​(@NonNull
                                             android.content.Context context,
                                             boolean enabled,
                                             @Nullable
                                             AudioOptions audioOptions,
                                             @Nullable
                                             java.lang.String name)
        Creates an audio track. Note that the RECORD_AUDIO permission must be granted in order for this operation to succeed. If RECORD_AUDIO is not granted null is returned.
        Parameters:
        context - application context.
        enabled - initial state of audio track.
        audioOptions - audio options to be applied to track.
        name - audio track name.
        Returns:
        local audio track if successfully added or null if audio track could not be created.
      • isEnabled

        public boolean isEnabled()
        Check if the local audio track is enabled.

        When the value is false, the local audio track is muted. When the value is true the local audio track is live.

        Specified by:
        isEnabled in interface Track
        Overrides:
        isEnabled in class AudioTrack
        Returns:
        true if the local audio is enabled.
      • getName

        @NonNull
        public java.lang.String getName()
        Returns the local audio track name. A pseudo random string is returned if no track name was specified.
        Specified by:
        getName in interface Track
        Overrides:
        getName in class AudioTrack
      • enable

        public void enable​(boolean enable)
        Sets the state of the local audio track. The results of this operation are signaled to other Participants in the same Room. When an audio track is disabled, the audio is muted.
        Parameters:
        enable - the desired state of the local audio track.
      • release

        public void release()
        Releases native memory owned by audio track.
      • addSink

        public void addSink​(@NonNull
                            AudioSink audioSink)
        Adds a sink to the Track. Sinks consume raw audio samples for further processing or storage.
        Overrides:
        addSink in class AudioTrack
      • removeSink

        public void removeSink​(@NonNull
                               AudioSink audioSink)
        Removes a sink from the Track.
        Overrides:
        removeSink in class AudioTrack
        Parameters:
        audioSink - An object that implements the `AudioSink` interface.