Class Stage

java.lang.Object
com.amazonaws.ivs.broadcast.Stage
All Implemented Interfaces:
Releasable

@RequiresApi(api=28) public class Stage extends Object implements Releasable
The main interface for the host application to create a Stage and interact with the created session.
  • Constructor Details

    • Stage

      public Stage(@NonNull android.content.Context context, @NonNull String token, @NonNull Stage.Strategy strategy)
      Create a new Stage. This is the main interaction point for interacting with the Stage SDK.
      Parameters:
      context - A DisplayContext or ActivityContext. The ApplicationContext may cause issues for applications compiled against newer SDK versions.
      token - A token generated by the IVS control plane that will be used to join the Stage when join() is called.
      strategy - The Stage.Strategy to use for this Stage.
  • Method Details

    • finalize

      protected void finalize() throws Throwable
      Overrides:
      finalize in class Object
      Throws:
      Throwable
    • join

      public void join() throws BroadcastException
      Joins the Stage session associated with the token provided during initialization.
      Throws:
      BroadcastException - if this Stage has already called release(), or if the token provided in Stage constructor was invalid or expired.
    • exchangeToken

      public void exchangeToken(String token) throws BroadcastException
      Throws:
      BroadcastException
    • setAudioCallback

      public void setAudioCallback(@Nullable Stage.AudioCallback callback)
      Sets a callback to receive mixed PCM audio data from all remote participants. Must be called before join(). The callback persists across leave()/join() cycles and is automatically re-enabled on rejoin.

      Implementations must return as fast as possible to avoid audio glitches. Exceeding the internal threshold will cause a warning to be logged. Consistently slow callbacks may result in audible dropouts or increased latency.

      Parameters:
      callback - The callback to receive PCM audio buffers, or null to clear.
      Throws:
      IllegalStateException - if called after join() has been called.
    • leave

      public void leave()
      Leaves the joined Stage session. If no Stage session is joined, this call is a no-op
    • addRenderer

      public void addRenderer(StageRenderer renderer)
      Adds a renderer to the list of renderers that will be notified of updates to the Stage.
      Parameters:
      renderer - renderer delegate implementation
    • removeRenderer

      public void removeRenderer(StageRenderer renderer)
      Removes a renderer from the list of renderers that will be notified of updates to the Stage.
      Parameters:
      renderer - renderer delegate implementation
    • replaceStrategy

      public void replaceStrategy(Stage.Strategy strategy)
      Whenever strategy is changed and host application wants SDK to honor the change, this method needs to be called.
      Parameters:
      strategy - strategy delegate implementation
    • refreshStrategy

      public void refreshStrategy()
      Triggers the Stage.Strategy on this instance to refresh its state. This is how host applications will make changes to how they are interacting with a Stage.
    • release

      public void release()
      Releases the resources associated with this Stage. After calling this, the Stage will no longer be useable.
      Specified by:
      release in interface Releasable