Package com.google.android.exoplayer2.transformer

## Class DefaultMuxer

- java.lang.Object
- - com.google.android.exoplayer2.transformer.DefaultMuxer

- All Implemented Interfaces:
    `Muxer`

      public final class DefaultMuxer
      extends Object
      implements Muxer

  A default `Muxer` implementation.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class | Description
    --- | --- | ---
    `static class` | `DefaultMuxer.Factory` | A `Muxer.Factory` for `DefaultMuxer`.

    - ### Nested classes/interfaces inherited from interface com.google.android.exoplayer2.transformer.Muxer

      `Muxer.MuxerException`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `int` | `addTrack​(Format format)` | Adds a track with the specified format, and returns its index (to be passed in subsequent calls to `Muxer.writeSampleData(int, ByteBuffer, boolean, long)`).
    `long` | `getMaxDelayBetweenSamplesMs()` | Returns the maximum delay allowed between output samples, in milliseconds, or `C.TIME_UNSET` if there is no maximum.
    `void` | `release​(boolean forCancellation)` | Finishes writing the output and releases any resources associated with muxing.
    `void` | `writeSampleData​(int trackIndex, ByteBuffer data, boolean isKeyFrame, long presentationTimeUs)` | Writes the specified sample.

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

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

- - ### Method Detail

    - #### addTrack

          public int addTrack​(Format format)
                       throws Muxer.MuxerException

      Description copied from interface: `Muxer`
      Adds a track with the specified format, and returns its index (to be passed in subsequent calls to `Muxer.writeSampleData(int, ByteBuffer, boolean, long)`).
      Specified by:
        `addTrack` in interface `Muxer`
      Parameters:
        `format` - The `Format` of the track.
      Throws:
        `Muxer.MuxerException` - If the muxer encounters a problem while adding the track.

    - #### writeSampleData

          public void writeSampleData​(int trackIndex,
                                      ByteBuffer data,
                                      boolean isKeyFrame,
                                      long presentationTimeUs)
                               throws Muxer.MuxerException

      Description copied from interface: `Muxer`
      Writes the specified sample.
      Specified by:
        `writeSampleData` in interface `Muxer`
      Parameters:
        `trackIndex` - The index of the track, previously returned by `Muxer.addTrack(Format)`.
        `data` - A buffer containing the sample data to write to the container.
        `isKeyFrame` - Whether the sample is a key frame.
        `presentationTimeUs` - The presentation time of the sample in microseconds.
      Throws:
        `Muxer.MuxerException` - If the muxer fails to write the sample.

    - #### release

          public void release​(boolean forCancellation)
                       throws Muxer.MuxerException

      Description copied from interface: `Muxer`
      Finishes writing the output and releases any resources associated with muxing.

      The muxer cannot be used anymore once this method has been called.

      Specified by:
        `release` in interface `Muxer`
      Parameters:
        `forCancellation` - Whether the reason for releasing the resources is the transformation cancellation.
      Throws:
        `Muxer.MuxerException` - If the muxer fails to finish writing the output and `forCancellation` is false.

    - #### getMaxDelayBetweenSamplesMs

          public long getMaxDelayBetweenSamplesMs()

      Description copied from interface: `Muxer`
      Returns the maximum delay allowed between output samples, in milliseconds, or `C.TIME_UNSET` if there is no maximum.

      This is the maximum delay between samples of any track. They can be of the same or of different track types.

      This value is used to abort the transformation when the maximum delay is reached. Note that there is no guarantee that the transformation will be aborted exactly at that time.

      Specified by:
        `getMaxDelayBetweenSamplesMs` in interface `Muxer`