Package com.google.android.exoplayer2

## Class Format.Builder

- java.lang.Object
- - com.google.android.exoplayer2.Format.Builder

- Enclosing class:
    Format

      public static final class Format.Builder
      extends Object

  Builds `Format` instances.

  Use Format#buildUpon() to obtain a builder representing an existing `Format`.

  When building formats, populate all fields whose values are known and relevant to the type of format being constructed. See the `Format` Javadoc for information about which fields should be set for different types of format.

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `Builder()` | Creates a new instance with default values.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `Format` | `build()` |
    `Format.Builder` | `setAccessibilityChannel​(int accessibilityChannel)` | Sets `Format.accessibilityChannel`.
    `Format.Builder` | `setAverageBitrate​(int averageBitrate)` | Sets `Format.averageBitrate`.
    `Format.Builder` | `setChannelCount​(int channelCount)` | Sets `Format.channelCount`.
    `Format.Builder` | `setCodecs​(String codecs)` | Sets `Format.codecs`.
    `Format.Builder` | `setColorInfo​(ColorInfo colorInfo)` | Sets `Format.colorInfo`.
    `Format.Builder` | `setContainerMimeType​(String containerMimeType)` | Sets `Format.containerMimeType`.
    `Format.Builder` | `setCryptoType​(@com.google.android.exoplayer2.C.CryptoType int cryptoType)` | Sets `Format.cryptoType`.
    `Format.Builder` | `setDrmInitData​(DrmInitData drmInitData)` | Sets `Format.drmInitData`.
    `Format.Builder` | `setEncoderDelay​(int encoderDelay)` | Sets `Format.encoderDelay`.
    `Format.Builder` | `setEncoderPadding​(int encoderPadding)` | Sets `Format.encoderPadding`.
    `Format.Builder` | `setFrameRate​(float frameRate)` | Sets `Format.frameRate`.
    `Format.Builder` | `setHeight​(int height)` | Sets `Format.height`.
    `Format.Builder` | `setId​(int id)` | Sets `Format.id` to `Integer.toString(id)`.
    `Format.Builder` | `setId​(String id)` | Sets `Format.id`.
    `Format.Builder` | `setInitializationData​(List<byte[]> initializationData)` | Sets `Format.initializationData`.
    `Format.Builder` | `setLabel​(String label)` | Sets `Format.label`.
    `Format.Builder` | `setLanguage​(String language)` | Sets `Format.language`.
    `Format.Builder` | `setMaxInputSize​(int maxInputSize)` | Sets `Format.maxInputSize`.
    `Format.Builder` | `setMetadata​(Metadata metadata)` | Sets `Format.metadata`.
    `Format.Builder` | `setPcmEncoding​(@com.google.android.exoplayer2.C.PcmEncoding int pcmEncoding)` | Sets `Format.pcmEncoding`.
    `Format.Builder` | `setPeakBitrate​(int peakBitrate)` | Sets `Format.peakBitrate`.
    `Format.Builder` | `setPixelWidthHeightRatio​(float pixelWidthHeightRatio)` | Sets `Format.pixelWidthHeightRatio`.
    `Format.Builder` | `setProjectionData​(byte[] projectionData)` | Sets `Format.projectionData`.
    `Format.Builder` | `setRoleFlags​(@com.google.android.exoplayer2.C.RoleFlags int roleFlags)` | Sets `Format.roleFlags`.
    `Format.Builder` | `setRotationDegrees​(int rotationDegrees)` | Sets `Format.rotationDegrees`.
    `Format.Builder` | `setSampleMimeType​(String sampleMimeType)` | Sets `Format.sampleMimeType`.
    `Format.Builder` | `setSampleRate​(int sampleRate)` | Sets `Format.sampleRate`.
    `Format.Builder` | `setSelectionFlags​(@com.google.android.exoplayer2.C.SelectionFlags int selectionFlags)` | Sets `Format.selectionFlags`.
    `Format.Builder` | `setStereoMode​(@com.google.android.exoplayer2.C.StereoMode int stereoMode)` | Sets `Format.stereoMode`.
    `Format.Builder` | `setSubsampleOffsetUs​(long subsampleOffsetUs)` | Sets `Format.subsampleOffsetUs`.
    `Format.Builder` | `setTileCountHorizontal​(int tileCountHorizontal)` | Sets `Format.tileCountHorizontal`.
    `Format.Builder` | `setTileCountVertical​(int tileCountVertical)` | Sets `Format.tileCountVertical`.
    `Format.Builder` | `setWidth​(int width)` | Sets `Format.width`.

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

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

- - ### Constructor Detail

    - #### Builder

          public Builder()

      Creates a new instance with default values.

  - ### Method Detail

    - #### setId

          @CanIgnoreReturnValue
          public Format.Builder setId​(@Nullable
                                      String id)

      Sets `Format.id`. The default value is `null`.
      Parameters:
        `id` - The `Format.id`.
      Returns:
        The builder.

    - #### setId

          @CanIgnoreReturnValue
          public Format.Builder setId​(int id)

      Sets `Format.id` to `Integer.toString(id)`. The default value is `null`.
      Parameters:
        `id` - The `Format.id`.
      Returns:
        The builder.

    - #### setLabel

          @CanIgnoreReturnValue
          public Format.Builder setLabel​(@Nullable
                                         String label)

      Sets `Format.label`. The default value is `null`.
      Parameters:
        `label` - The `Format.label`.
      Returns:
        The builder.

    - #### setLanguage

          @CanIgnoreReturnValue
          public Format.Builder setLanguage​(@Nullable
                                            String language)

      Sets `Format.language`. The default value is `null`.
      Parameters:
        `language` - The `Format.language`.
      Returns:
        The builder.

    - #### setSelectionFlags

          @CanIgnoreReturnValue
          public Format.Builder setSelectionFlags​(@SelectionFlags
                                                  @com.google.android.exoplayer2.C.SelectionFlags int selectionFlags)

      Sets `Format.selectionFlags`. The default value is 0.
      Parameters:
        `selectionFlags` - The `Format.selectionFlags`.
      Returns:
        The builder.

    - #### setRoleFlags

          @CanIgnoreReturnValue
          public Format.Builder setRoleFlags​(@RoleFlags
                                             @com.google.android.exoplayer2.C.RoleFlags int roleFlags)

      Sets `Format.roleFlags`. The default value is 0.
      Parameters:
        `roleFlags` - The `Format.roleFlags`.
      Returns:
        The builder.

    - #### setAverageBitrate

          @CanIgnoreReturnValue
          public Format.Builder setAverageBitrate​(int averageBitrate)

      Sets `Format.averageBitrate`. The default value is `Format.NO_VALUE`.
      Parameters:
        `averageBitrate` - The `Format.averageBitrate`.
      Returns:
        The builder.

    - #### setPeakBitrate

          @CanIgnoreReturnValue
          public Format.Builder setPeakBitrate​(int peakBitrate)

      Sets `Format.peakBitrate`. The default value is `Format.NO_VALUE`.
      Parameters:
        `peakBitrate` - The `Format.peakBitrate`.
      Returns:
        The builder.

    - #### setCodecs

          @CanIgnoreReturnValue
          public Format.Builder setCodecs​(@Nullable
                                          String codecs)

      Sets `Format.codecs`. The default value is `null`.
      Parameters:
        `codecs` - The `Format.codecs`.
      Returns:
        The builder.

    - #### setMetadata

          @CanIgnoreReturnValue
          public Format.Builder setMetadata​(@Nullable
                                            Metadata metadata)

      Sets `Format.metadata`. The default value is `null`.
      Parameters:
        `metadata` - The `Format.metadata`.
      Returns:
        The builder.

    - #### setContainerMimeType

          @CanIgnoreReturnValue
          public Format.Builder setContainerMimeType​(@Nullable
                                                     String containerMimeType)

      Sets `Format.containerMimeType`. The default value is `null`.
      Parameters:
        `containerMimeType` - The `Format.containerMimeType`.
      Returns:
        The builder.

    - #### setSampleMimeType

          @CanIgnoreReturnValue
          public Format.Builder setSampleMimeType​(@Nullable
                                                  String sampleMimeType)

      Sets `Format.sampleMimeType`. The default value is `null`.
      Parameters:
        `sampleMimeType` - `Format.sampleMimeType`.
      Returns:
        The builder.

    - #### setMaxInputSize

          @CanIgnoreReturnValue
          public Format.Builder setMaxInputSize​(int maxInputSize)

      Sets `Format.maxInputSize`. The default value is `Format.NO_VALUE`.
      Parameters:
        `maxInputSize` - The `Format.maxInputSize`.
      Returns:
        The builder.

    - #### setInitializationData

          @CanIgnoreReturnValue
          public Format.Builder setInitializationData​(@Nullable
                                                      List<byte[]> initializationData)

      Sets `Format.initializationData`. The default value is `null`.
      Parameters:
        `initializationData` - The `Format.initializationData`.
      Returns:
        The builder.

    - #### setDrmInitData

          @CanIgnoreReturnValue
          public Format.Builder setDrmInitData​(@Nullable
                                               DrmInitData drmInitData)

      Sets `Format.drmInitData`. The default value is `null`.
      Parameters:
        `drmInitData` - The `Format.drmInitData`.
      Returns:
        The builder.

    - #### setSubsampleOffsetUs

          @CanIgnoreReturnValue
          public Format.Builder setSubsampleOffsetUs​(long subsampleOffsetUs)

      Sets `Format.subsampleOffsetUs`. The default value is `Format.OFFSET_SAMPLE_RELATIVE`.
      Parameters:
        `subsampleOffsetUs` - The `Format.subsampleOffsetUs`.
      Returns:
        The builder.

    - #### setWidth

          @CanIgnoreReturnValue
          public Format.Builder setWidth​(int width)

      Sets `Format.width`. The default value is `Format.NO_VALUE`.
      Parameters:
        `width` - The `Format.width`.
      Returns:
        The builder.

    - #### setHeight

          @CanIgnoreReturnValue
          public Format.Builder setHeight​(int height)

      Sets `Format.height`. The default value is `Format.NO_VALUE`.
      Parameters:
        `height` - The `Format.height`.
      Returns:
        The builder.

    - #### setFrameRate

          @CanIgnoreReturnValue
          public Format.Builder setFrameRate​(float frameRate)

      Sets `Format.frameRate`. The default value is `Format.NO_VALUE`.
      Parameters:
        `frameRate` - The `Format.frameRate`.
      Returns:
        The builder.

    - #### setRotationDegrees

          @CanIgnoreReturnValue
          public Format.Builder setRotationDegrees​(int rotationDegrees)

      Sets `Format.rotationDegrees`. The default value is 0.
      Parameters:
        `rotationDegrees` - The `Format.rotationDegrees`.
      Returns:
        The builder.

    - #### setPixelWidthHeightRatio

          @CanIgnoreReturnValue
          public Format.Builder setPixelWidthHeightRatio​(float pixelWidthHeightRatio)

      Sets `Format.pixelWidthHeightRatio`. The default value is 1.0f.
      Parameters:
        `pixelWidthHeightRatio` - The `Format.pixelWidthHeightRatio`.
      Returns:
        The builder.

    - #### setProjectionData

          @CanIgnoreReturnValue
          public Format.Builder setProjectionData​(@Nullable
                                                  byte[] projectionData)

      Sets `Format.projectionData`. The default value is `null`.
      Parameters:
        `projectionData` - The `Format.projectionData`.
      Returns:
        The builder.

    - #### setStereoMode

          @CanIgnoreReturnValue
          public Format.Builder setStereoMode​(@com.google.android.exoplayer2.C.StereoMode int stereoMode)

      Sets `Format.stereoMode`. The default value is `Format.NO_VALUE`.
      Parameters:
        `stereoMode` - The `Format.stereoMode`.
      Returns:
        The builder.

    - #### setColorInfo

          @CanIgnoreReturnValue
          public Format.Builder setColorInfo​(@Nullable
                                             ColorInfo colorInfo)

      Sets `Format.colorInfo`. The default value is `null`.
      Parameters:
        `colorInfo` - The `Format.colorInfo`.
      Returns:
        The builder.

    - #### setChannelCount

          @CanIgnoreReturnValue
          public Format.Builder setChannelCount​(int channelCount)

      Sets `Format.channelCount`. The default value is `Format.NO_VALUE`.
      Parameters:
        `channelCount` - The `Format.channelCount`.
      Returns:
        The builder.

    - #### setSampleRate

          @CanIgnoreReturnValue
          public Format.Builder setSampleRate​(int sampleRate)

      Sets `Format.sampleRate`. The default value is `Format.NO_VALUE`.
      Parameters:
        `sampleRate` - The `Format.sampleRate`.
      Returns:
        The builder.

    - #### setPcmEncoding

          @CanIgnoreReturnValue
          public Format.Builder setPcmEncoding​(@com.google.android.exoplayer2.C.PcmEncoding int pcmEncoding)

      Sets `Format.pcmEncoding`. The default value is `Format.NO_VALUE`.
      Parameters:
        `pcmEncoding` - The `Format.pcmEncoding`.
      Returns:
        The builder.

    - #### setEncoderDelay

          @CanIgnoreReturnValue
          public Format.Builder setEncoderDelay​(int encoderDelay)

      Sets `Format.encoderDelay`. The default value is 0.
      Parameters:
        `encoderDelay` - The `Format.encoderDelay`.
      Returns:
        The builder.

    - #### setEncoderPadding

          @CanIgnoreReturnValue
          public Format.Builder setEncoderPadding​(int encoderPadding)

      Sets `Format.encoderPadding`. The default value is 0.
      Parameters:
        `encoderPadding` - The `Format.encoderPadding`.
      Returns:
        The builder.

    - #### setAccessibilityChannel

          @CanIgnoreReturnValue
          public Format.Builder setAccessibilityChannel​(int accessibilityChannel)

      Sets `Format.accessibilityChannel`. The default value is `Format.NO_VALUE`.
      Parameters:
        `accessibilityChannel` - The `Format.accessibilityChannel`.
      Returns:
        The builder.

    - #### setTileCountHorizontal

          @CanIgnoreReturnValue
          public Format.Builder setTileCountHorizontal​(int tileCountHorizontal)

      Sets `Format.tileCountHorizontal`. The default value is `Format.NO_VALUE`.
      Parameters:
        `tileCountHorizontal` - The `Format.accessibilityChannel`.
      Returns:
        The builder.

    - #### setTileCountVertical

          @CanIgnoreReturnValue
          public Format.Builder setTileCountVertical​(int tileCountVertical)

      Sets `Format.tileCountVertical`. The default value is `Format.NO_VALUE`.
      Parameters:
        `tileCountVertical` - The `Format.accessibilityChannel`.
      Returns:
        The builder.

    - #### setCryptoType

          @CanIgnoreReturnValue
          public Format.Builder setCryptoType​(@com.google.android.exoplayer2.C.CryptoType int cryptoType)

      Sets `Format.cryptoType`. The default value is `C.CRYPTO_TYPE_NONE`.
      Parameters:
        `cryptoType` - The `C.CryptoType`.
      Returns:
        The builder.

    - #### build

          public Format build()