public final class

Format.Builder

extends java.lang.Object

 java.lang.Object

↳androidx.media3.common.Format.Builder

Overview

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.

Summary

Constructors
publicBuilder()

Creates a new instance with default values.

Methods
public Formatbuild()

public Format.BuildersetAccessibilityChannel(int accessibilityChannel)

Sets Format.accessibilityChannel.

public Format.BuildersetAuxiliaryTrackType(int auxiliaryTrackType)

Sets Format.auxiliaryTrackType.

public Format.BuildersetAverageBitrate(int averageBitrate)

Sets Format.averageBitrate.

public Format.BuildersetChannelCount(int channelCount)

Sets Format.channelCount.

public Format.BuildersetCodecs(java.lang.String codecs)

Sets Format.codecs.

public Format.BuildersetColorInfo(ColorInfo colorInfo)

Sets Format.colorInfo.

public Format.BuildersetContainerMimeType(java.lang.String containerMimeType)

Sets Format.containerMimeType.

public Format.BuildersetCryptoType(int cryptoType)

Sets Format.cryptoType.

public Format.BuildersetCueReplacementBehavior(int cueReplacementBehavior)

Sets Format.cueReplacementBehavior.

public Format.BuildersetCustomData(java.lang.Object customData)

Sets the opaque object Format.customData.

public Format.BuildersetDrmInitData(DrmInitData drmInitData)

Sets Format.drmInitData.

public Format.BuildersetEncoderDelay(int encoderDelay)

Sets Format.encoderDelay.

public Format.BuildersetEncoderPadding(int encoderPadding)

Sets Format.encoderPadding.

public Format.BuildersetFrameRate(float frameRate)

Sets Format.frameRate.

public Format.BuildersetHeight(int height)

Sets Format.height.

public Format.BuildersetId(int id)

Sets Format.id to Integer.toString(id).

public Format.BuildersetId(java.lang.String id)

Sets Format.id.

public Format.BuildersetInitializationData(java.util.List<UnknownReference> initializationData)

Sets Format.initializationData.

public Format.BuildersetLabel(java.lang.String label)

Sets Format.label.

public Format.BuildersetLabels(java.util.List<Label> labels)

Sets Format.labels.

public Format.BuildersetLanguage(java.lang.String language)

Sets Format.language.

public Format.BuildersetMaxInputSize(int maxInputSize)

Sets Format.maxInputSize.

public Format.BuildersetMaxNumReorderSamples(int maxNumReorderSamples)

Sets Format.maxNumReorderSamples.

public Format.BuildersetMetadata(Metadata metadata)

Sets Format.metadata.

public Format.BuildersetPcmEncoding(int pcmEncoding)

Sets Format.pcmEncoding.

public Format.BuildersetPeakBitrate(int peakBitrate)

Sets Format.peakBitrate.

public Format.BuildersetPixelWidthHeightRatio(float pixelWidthHeightRatio)

Sets Format.pixelWidthHeightRatio.

public Format.BuildersetProjectionData(byte[] projectionData[])

Sets Format.projectionData.

public Format.BuildersetRoleFlags(int roleFlags)

Sets Format.roleFlags.

public Format.BuildersetRotationDegrees(int rotationDegrees)

Sets Format.rotationDegrees.

public Format.BuildersetSampleMimeType(java.lang.String sampleMimeType)

Sets Format.sampleMimeType.

public Format.BuildersetSampleRate(int sampleRate)

Sets Format.sampleRate.

public Format.BuildersetSelectionFlags(int selectionFlags)

Sets Format.selectionFlags.

public Format.BuildersetStereoMode(int stereoMode)

Sets Format.stereoMode.

public Format.BuildersetSubsampleOffsetUs(long subsampleOffsetUs)

Sets Format.subsampleOffsetUs.

public Format.BuildersetTileCountHorizontal(int tileCountHorizontal)

Sets Format.tileCountHorizontal.

public Format.BuildersetTileCountVertical(int tileCountVertical)

Sets Format.tileCountVertical.

public Format.BuildersetWidth(int width)

Sets Format.width.

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructors

public Builder()

Creates a new instance with default values.

Methods

public Format.Builder setId(java.lang.String id)

Sets Format.id. The default value is null.

Parameters:

id: The Format.id.

Returns:

The builder.

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.

public Format.Builder setLabel(java.lang.String label)

Sets Format.label. The default value is null.

If both this default label and a list of labels are set, this default label must be part of label list.

Parameters:

label: The Format.label.

Returns:

The builder.

public Format.Builder setLabels(java.util.List<Label> labels)

Sets Format.labels. The default value is an empty list.

If both the default label and this list are set, the default label must be part of this list of labels.

Parameters:

labels: The Format.labels.

Returns:

The builder.

public Format.Builder setLanguage(java.lang.String language)

Sets Format.language. The default value is null.

Parameters:

language: The Format.language.

Returns:

The builder.

public Format.Builder setSelectionFlags(int selectionFlags)

Sets Format.selectionFlags. The default value is 0.

Parameters:

selectionFlags: The Format.selectionFlags.

Returns:

The builder.

public Format.Builder setRoleFlags(int roleFlags)

Sets Format.roleFlags. The default value is 0.

When roleFlags includes C.ROLE_FLAG_AUXILIARY, then the specific C.AuxiliaryTrackType can also be set.

Parameters:

roleFlags: The Format.roleFlags.

Returns:

The builder.

public Format.Builder setAuxiliaryTrackType(int auxiliaryTrackType)

Sets Format.auxiliaryTrackType. The default value is C.AUXILIARY_TRACK_TYPE_UNDEFINED.

This must be set to a value other than C.AUXILIARY_TRACK_TYPE_UNDEFINED only when role flags contains C.ROLE_FLAG_AUXILIARY.

Parameters:

auxiliaryTrackType: The Format.auxiliaryTrackType.

Returns:

The builder.

public Format.Builder setAverageBitrate(int averageBitrate)

Sets Format.averageBitrate. The default value is Format.NO_VALUE.

Parameters:

averageBitrate: The Format.averageBitrate.

Returns:

The builder.

public Format.Builder setPeakBitrate(int peakBitrate)

Sets Format.peakBitrate. The default value is Format.NO_VALUE.

Parameters:

peakBitrate: The Format.peakBitrate.

Returns:

The builder.

public Format.Builder setCodecs(java.lang.String codecs)

Sets Format.codecs. The default value is null.

Parameters:

codecs: The Format.codecs.

Returns:

The builder.

public Format.Builder setMetadata(Metadata metadata)

Sets Format.metadata. The default value is null.

Parameters:

metadata: The Format.metadata.

Returns:

The builder.

public Format.Builder setCustomData(java.lang.Object customData)

Sets the opaque object Format.customData. The default value is null.

This value is not included in serialized instances of this class that are used to transfer data to other processes.

Parameters:

customData: The Format.customData.

Returns:

The builder.

public Format.Builder setContainerMimeType(java.lang.String containerMimeType)

Sets Format.containerMimeType. The default value is null.

Parameters:

containerMimeType: The Format.containerMimeType.

Returns:

The builder.

public Format.Builder setSampleMimeType(java.lang.String sampleMimeType)

Sets Format.sampleMimeType. The default value is null.

Parameters:

sampleMimeType: Format.sampleMimeType.

Returns:

The builder.

public Format.Builder setMaxInputSize(int maxInputSize)

Sets Format.maxInputSize. The default value is Format.NO_VALUE.

Parameters:

maxInputSize: The Format.maxInputSize.

Returns:

The builder.

public Format.Builder setMaxNumReorderSamples(int maxNumReorderSamples)

Sets Format.maxNumReorderSamples. The default value is Format.NO_VALUE.

Parameters:

maxNumReorderSamples: Format.maxNumReorderSamples.

Returns:

The builder.

public Format.Builder setInitializationData(java.util.List<UnknownReference> initializationData)

Sets Format.initializationData. The default value is null.

Parameters:

initializationData: The Format.initializationData.

Returns:

The builder.

public Format.Builder setDrmInitData(DrmInitData drmInitData)

Sets Format.drmInitData. The default value is null.

Parameters:

drmInitData: The Format.drmInitData.

Returns:

The builder.

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.

public Format.Builder setWidth(int width)

Sets Format.width. The default value is Format.NO_VALUE.

Parameters:

width: The Format.width.

Returns:

The builder.

public Format.Builder setHeight(int height)

Sets Format.height. The default value is Format.NO_VALUE.

Parameters:

height: The Format.height.

Returns:

The builder.

public Format.Builder setFrameRate(float frameRate)

Sets Format.frameRate. The default value is Format.NO_VALUE.

Parameters:

frameRate: The Format.frameRate.

Returns:

The builder.

public Format.Builder setRotationDegrees(int rotationDegrees)

Sets Format.rotationDegrees. The default value is 0.

Parameters:

rotationDegrees: The Format.rotationDegrees.

Returns:

The builder.

public Format.Builder setPixelWidthHeightRatio(float pixelWidthHeightRatio)

Sets Format.pixelWidthHeightRatio. The default value is 1.0f.

Parameters:

pixelWidthHeightRatio: The Format.pixelWidthHeightRatio.

Returns:

The builder.

public Format.Builder setProjectionData(byte[] projectionData[])

Sets Format.projectionData. The default value is null.

Parameters:

projectionData: The Format.projectionData.

Returns:

The builder.

public Format.Builder setStereoMode(int stereoMode)

Sets Format.stereoMode. The default value is Format.NO_VALUE.

Parameters:

stereoMode: The Format.stereoMode.

Returns:

The builder.

public Format.Builder setColorInfo(ColorInfo colorInfo)

Sets Format.colorInfo. The default value is null.

Parameters:

colorInfo: The Format.colorInfo.

Returns:

The builder.

public Format.Builder setChannelCount(int channelCount)

Sets Format.channelCount. The default value is Format.NO_VALUE.

Parameters:

channelCount: The Format.channelCount.

Returns:

The builder.

public Format.Builder setSampleRate(int sampleRate)

Sets Format.sampleRate. The default value is Format.NO_VALUE.

Parameters:

sampleRate: The Format.sampleRate.

Returns:

The builder.

public Format.Builder setPcmEncoding(int pcmEncoding)

Sets Format.pcmEncoding. The default value is Format.NO_VALUE.

Parameters:

pcmEncoding: The Format.pcmEncoding.

Returns:

The builder.

public Format.Builder setEncoderDelay(int encoderDelay)

Sets Format.encoderDelay. The default value is 0.

Parameters:

encoderDelay: The Format.encoderDelay.

Returns:

The builder.

public Format.Builder setEncoderPadding(int encoderPadding)

Sets Format.encoderPadding. The default value is 0.

Parameters:

encoderPadding: The Format.encoderPadding.

Returns:

The builder.

public Format.Builder setAccessibilityChannel(int accessibilityChannel)

Sets Format.accessibilityChannel. The default value is Format.NO_VALUE.

Parameters:

accessibilityChannel: The Format.accessibilityChannel.

Returns:

The builder.

public Format.Builder setCueReplacementBehavior(int cueReplacementBehavior)

Sets Format.cueReplacementBehavior. The default value is Format.CUE_REPLACEMENT_BEHAVIOR_MERGE.

Parameters:

cueReplacementBehavior: The Format.CueReplacementBehavior.

Returns:

The builder.

public Format.Builder setTileCountHorizontal(int tileCountHorizontal)

Sets Format.tileCountHorizontal. The default value is Format.NO_VALUE.

Parameters:

tileCountHorizontal: The Format.accessibilityChannel.

Returns:

The builder.

public Format.Builder setTileCountVertical(int tileCountVertical)

Sets Format.tileCountVertical. The default value is Format.NO_VALUE.

Parameters:

tileCountVertical: The Format.accessibilityChannel.

Returns:

The builder.

public Format.Builder setCryptoType(int cryptoType)

Sets Format.cryptoType. The default value is C.CRYPTO_TYPE_NONE.

Parameters:

cryptoType: The C.CryptoType.

Returns:

The builder.

public Format build()