Format implements Parcelable { @Override public void writeToParcel(Parcel dest, int flags) { dest.writeString(id); dest.writeString(label); dest.writeInt(selectionFlags); dest.writeInt(roleFlags); dest.writeInt(bitrate); dest.writeString(codecs); dest.writeParcelable(metadata, 0); dest.writeString(containerMimeType); dest.writeString(sampleMimeType); dest.writeInt(maxInputSize); int initializationDataSize = initializationData.size(); dest.writeInt(initializationDataSize); for (int i = 0; i < initializationDataSize; i++) { dest.writeByteArray(initializationData.get(i)); } dest.writeParcelable(drmInitData, 0); dest.writeLong(subsampleOffsetUs); dest.writeInt(width); dest.writeInt(height); dest.writeFloat(frameRate); dest.writeInt(rotationDegrees); dest.writeFloat(pixelWidthHeightRatio); Util.writeBoolean(dest, projectionData != null); if (projectionData != null) { dest.writeByteArray(projectionData); } dest.writeInt(stereoMode); dest.writeParcelable(colorInfo, flags); dest.writeInt(channelCount); dest.writeInt(sampleRate); dest.writeInt(pcmEncoding); dest.writeInt(encoderDelay); dest.writeInt(encoderPadding); dest.writeString(language); dest.writeInt(accessibilityChannel); } Format(
      @Nullable String id,
      @Nullable String label,
      @C.SelectionFlags int selectionFlags,
      @C.RoleFlags int roleFlags,
      int bitrate,
      @Nullable String codecs,
      @Nullable Metadata metadata,
      // Container specific.
      @Nullable String containerMimeType,
      // Elementary stream specific.
      @Nullable String sampleMimeType,
      int maxInputSize,
      @Nullable List<byte[]> initializationData,
      @Nullable DrmInitData drmInitData,
      long subsampleOffsetUs,
      // Video specific.
      int width,
      int height,
      float frameRate,
      int rotationDegrees,
      float pixelWidthHeightRatio,
      @Nullable byte[] projectionData,
      @C.StereoMode int stereoMode,
      @Nullable ColorInfo colorInfo,
      // Audio specific.
      int channelCount,
      int sampleRate,
      @C.PcmEncoding int pcmEncoding,
      int encoderDelay,
      int encoderPadding,
      // Audio and text specific.
      @Nullable String language,
      int accessibilityChannel,
      // Provided by source.
      @Nullable Class<? extends ExoMediaCrypto> exoMediaCryptoType); @SuppressWarnings("ResourceType")  Format(Parcel in); @Deprecated static Format createVideoContainerFormat(
      @Nullable String id,
      @Nullable String containerMimeType,
      @Nullable String sampleMimeType,
      @Nullable String codecs,
      int bitrate,
      int width,
      int height,
      float frameRate,
      @Nullable List<byte[]> initializationData,
      @C.SelectionFlags int selectionFlags); static Format createVideoContainerFormat(
      @Nullable String id,
      @Nullable String label,
      @Nullable String containerMimeType,
      @Nullable String sampleMimeType,
      @Nullable String codecs,
      @Nullable Metadata metadata,
      int bitrate,
      int width,
      int height,
      float frameRate,
      @Nullable List<byte[]> initializationData,
      @C.SelectionFlags int selectionFlags,
      @C.RoleFlags int roleFlags); static Format createVideoSampleFormat(
      @Nullable String id,
      @Nullable String sampleMimeType,
      @Nullable String codecs,
      int bitrate,
      int maxInputSize,
      int width,
      int height,
      float frameRate,
      @Nullable List<byte[]> initializationData,
      @Nullable DrmInitData drmInitData); static Format createVideoSampleFormat(
      @Nullable String id,
      @Nullable String sampleMimeType,
      @Nullable String codecs,
      int bitrate,
      int maxInputSize,
      int width,
      int height,
      float frameRate,
      @Nullable List<byte[]> initializationData,
      int rotationDegrees,
      float pixelWidthHeightRatio,
      @Nullable DrmInitData drmInitData); static Format createVideoSampleFormat(
      @Nullable String id,
      @Nullable String sampleMimeType,
      @Nullable String codecs,
      int bitrate,
      int maxInputSize,
      int width,
      int height,
      float frameRate,
      @Nullable List<byte[]> initializationData,
      int rotationDegrees,
      float pixelWidthHeightRatio,
      @Nullable byte[] projectionData,
      @C.StereoMode int stereoMode,
      @Nullable ColorInfo colorInfo,
      @Nullable DrmInitData drmInitData); @Deprecated static Format createAudioContainerFormat(
      @Nullable String id,
      @Nullable String containerMimeType,
      @Nullable String sampleMimeType,
      @Nullable String codecs,
      int bitrate,
      int channelCount,
      int sampleRate,
      @Nullable List<byte[]> initializationData,
      @C.SelectionFlags int selectionFlags,
      @Nullable String language); static Format createAudioContainerFormat(
      @Nullable String id,
      @Nullable String label,
      @Nullable String containerMimeType,
      @Nullable String sampleMimeType,
      @Nullable String codecs,
      @Nullable Metadata metadata,
      int bitrate,
      int channelCount,
      int sampleRate,
      @Nullable List<byte[]> initializationData,
      @C.SelectionFlags int selectionFlags,
      @C.RoleFlags int roleFlags,
      @Nullable String language); static Format createAudioSampleFormat(
      @Nullable String id,
      @Nullable String sampleMimeType,
      @Nullable String codecs,
      int bitrate,
      int maxInputSize,
      int channelCount,
      int sampleRate,
      @Nullable List<byte[]> initializationData,
      @Nullable DrmInitData drmInitData,
      @C.SelectionFlags int selectionFlags,
      @Nullable String language); static Format createAudioSampleFormat(
      @Nullable String id,
      @Nullable String sampleMimeType,
      @Nullable String codecs,
      int bitrate,
      int maxInputSize,
      int channelCount,
      int sampleRate,
      @C.PcmEncoding int pcmEncoding,
      @Nullable List<byte[]> initializationData,
      @Nullable DrmInitData drmInitData,
      @C.SelectionFlags int selectionFlags,
      @Nullable String language); static Format createAudioSampleFormat(
      @Nullable String id,
      @Nullable String sampleMimeType,
      @Nullable String codecs,
      int bitrate,
      int maxInputSize,
      int channelCount,
      int sampleRate,
      @C.PcmEncoding int pcmEncoding,
      int encoderDelay,
      int encoderPadding,
      @Nullable List<byte[]> initializationData,
      @Nullable DrmInitData drmInitData,
      @C.SelectionFlags int selectionFlags,
      @Nullable String language,
      @Nullable Metadata metadata); static Format createTextContainerFormat(
      @Nullable String id,
      @Nullable String label,
      @Nullable String containerMimeType,
      @Nullable String sampleMimeType,
      @Nullable String codecs,
      int bitrate,
      @C.SelectionFlags int selectionFlags,
      @C.RoleFlags int roleFlags,
      @Nullable String language); static Format createTextContainerFormat(
      @Nullable String id,
      @Nullable String label,
      @Nullable String containerMimeType,
      @Nullable String sampleMimeType,
      @Nullable String codecs,
      int bitrate,
      @C.SelectionFlags int selectionFlags,
      @C.RoleFlags int roleFlags,
      @Nullable String language,
      int accessibilityChannel); static Format createTextSampleFormat(
      @Nullable String id,
      @Nullable String sampleMimeType,
      @C.SelectionFlags int selectionFlags,
      @Nullable String language); static Format createTextSampleFormat(
      @Nullable String id,
      @Nullable String sampleMimeType,
      @C.SelectionFlags int selectionFlags,
      @Nullable String language,
      @Nullable DrmInitData drmInitData); static Format createTextSampleFormat(
      @Nullable String id,
      @Nullable String sampleMimeType,
      @Nullable String codecs,
      int bitrate,
      @C.SelectionFlags int selectionFlags,
      @Nullable String language,
      int accessibilityChannel,
      @Nullable DrmInitData drmInitData); static Format createTextSampleFormat(
      @Nullable String id,
      @Nullable String sampleMimeType,
      @Nullable String codecs,
      int bitrate,
      @C.SelectionFlags int selectionFlags,
      @Nullable String language,
      @Nullable DrmInitData drmInitData,
      long subsampleOffsetUs); static Format createTextSampleFormat(
      @Nullable String id,
      @Nullable String sampleMimeType,
      @Nullable String codecs,
      int bitrate,
      @C.SelectionFlags int selectionFlags,
      @Nullable String language,
      int accessibilityChannel,
      @Nullable DrmInitData drmInitData,
      long subsampleOffsetUs,
      @Nullable List<byte[]> initializationData); static Format createImageSampleFormat(
      @Nullable String id,
      @Nullable String sampleMimeType,
      @Nullable String codecs,
      int bitrate,
      @C.SelectionFlags int selectionFlags,
      @Nullable List<byte[]> initializationData,
      @Nullable String language,
      @Nullable DrmInitData drmInitData); @Deprecated static Format createContainerFormat(
      @Nullable String id,
      @Nullable String containerMimeType,
      @Nullable String sampleMimeType,
      @Nullable String codecs,
      int bitrate,
      @C.SelectionFlags int selectionFlags,
      @Nullable String language); static Format createContainerFormat(
      @Nullable String id,
      @Nullable String label,
      @Nullable String containerMimeType,
      @Nullable String sampleMimeType,
      @Nullable String codecs,
      int bitrate,
      @C.SelectionFlags int selectionFlags,
      @C.RoleFlags int roleFlags,
      @Nullable String language); static Format createSampleFormat(
      @Nullable String id, @Nullable String sampleMimeType, long subsampleOffsetUs); static Format createSampleFormat(
      @Nullable String id,
      @Nullable String sampleMimeType,
      @Nullable String codecs,
      int bitrate,
      @Nullable DrmInitData drmInitData); Format copyWithMaxInputSize(int maxInputSize); Format copyWithSubsampleOffsetUs(long subsampleOffsetUs); Format copyWithLabel(@Nullable String label); Format copyWithContainerInfo(
      @Nullable String id,
      @Nullable String label,
      @Nullable String sampleMimeType,
      @Nullable String codecs,
      @Nullable Metadata metadata,
      int bitrate,
      int width,
      int height,
      int channelCount,
      @C.SelectionFlags int selectionFlags,
      @Nullable String language); @SuppressWarnings("ReferenceEquality") Format copyWithManifestFormatInfo(Format manifestFormat); Format copyWithGaplessInfo(int encoderDelay, int encoderPadding); Format copyWithFrameRate(float frameRate); Format copyWithDrmInitData(@Nullable DrmInitData drmInitData); Format copyWithMetadata(@Nullable Metadata metadata); @SuppressWarnings("ReferenceEquality") Format copyWithAdjustments(
      @Nullable DrmInitData drmInitData, @Nullable Metadata metadata); Format copyWithRotationDegrees(int rotationDegrees); Format copyWithBitrate(int bitrate); Format copyWithVideoSize(int width, int height); Format copyWithExoMediaCryptoType(
      @Nullable Class<? extends ExoMediaCrypto> exoMediaCryptoType); int getPixelCount(); @Override String toString(); @Override int hashCode(); @Override boolean equals(@Nullable Object obj); boolean initializationDataEquals(Format other); static String toLogString(@Nullable Format format); @Override int describeContents(); @Override void writeToParcel(Parcel dest, int flags); static final int NO_VALUE; static final long OFFSET_SAMPLE_RELATIVE; @Nullable final String id; @Nullable final String label; @C.SelectionFlags final int selectionFlags; @C.RoleFlags final int roleFlags; final int bitrate; @Nullable final String codecs; @Nullable final Metadata metadata; @Nullable final String containerMimeType; @Nullable final String sampleMimeType; final int maxInputSize; final List<byte[]> initializationData; @Nullable final DrmInitData drmInitData; final long subsampleOffsetUs; final int width; final int height; final float frameRate; final int rotationDegrees; final float pixelWidthHeightRatio; @C.StereoMode
  final int stereoMode; @Nullable final byte[] projectionData; @Nullable final ColorInfo colorInfo; final int channelCount; final int sampleRate; final @C.PcmEncoding int pcmEncoding; final int encoderDelay; final int encoderPadding; @Nullable final String language; final int accessibilityChannel; @Nullable final Class<? extends ExoMediaCrypto> exoMediaCryptoType; static final Creator<Format> CREATOR; }
@Test public void testParcelable() { DrmInitData.SchemeData drmData1 = new DrmInitData.SchemeData(WIDEVINE_UUID, VIDEO_MP4, TestUtil.buildTestData(128, 1 )); DrmInitData.SchemeData drmData2 = new DrmInitData.SchemeData(C.UUID_NIL, VIDEO_WEBM, TestUtil.buildTestData(128, 1 )); DrmInitData drmInitData = new DrmInitData(drmData1, drmData2); byte[] projectionData = new byte[] {1, 2, 3}; Metadata metadata = new Metadata( new TextInformationFrame("id1", "description1", "value1"), new TextInformationFrame("id2", "description2", "value2")); ColorInfo colorInfo = new ColorInfo(C.COLOR_SPACE_BT709, C.COLOR_RANGE_LIMITED, C.COLOR_TRANSFER_SDR, new byte[] {1, 2, 3, 4, 5, 6, 7}); Format formatToParcel = new Format( "id", "label", C.SELECTION_FLAG_DEFAULT, C.ROLE_FLAG_MAIN, 1024, "codec", metadata, MimeTypes.VIDEO_MP4, MimeTypes.VIDEO_H264, 2048, initData, drmInitData, Format.OFFSET_SAMPLE_RELATIVE, 1920, 1080, 24, 90, 2, projectionData, C.STEREO_MODE_TOP_BOTTOM, colorInfo, 6, 44100, C.ENCODING_PCM_24BIT, 1001, 1002, "language", Format.NO_VALUE, null); Parcel parcel = Parcel.obtain(); formatToParcel.writeToParcel(parcel, 0); parcel.setDataPosition(0); Format formatFromParcel = Format.CREATOR.createFromParcel(parcel); assertThat(formatFromParcel).isEqualTo(formatToParcel); parcel.recycle(); }