public abstract class

Buffer

extends java.lang.Object

 java.lang.Object

↳androidx.media3.decoder.Buffer

Subclasses:

ImageOutputBuffer, MetadataInputBuffer, SubtitleInputBuffer, SubtitleOutputBuffer, DecoderInputBuffer, SimpleDecoderOutputBuffer, DecoderOutputBuffer, VideoDecoderOutputBuffer

Gradle dependencies

compile group: 'androidx.media3', name: 'media3-decoder', version: '1.5.0-alpha01'

  • groupId: androidx.media3
  • artifactId: media3-decoder
  • version: 1.5.0-alpha01

Artifact androidx.media3:media3-decoder:1.5.0-alpha01 it located at Google repository (https://maven.google.com/)

Overview

Base class for buffers with flags.

Summary

Constructors
publicBuffer()

Methods
public final voidaddFlag(int flag)

Adds the flag to this buffer's flags.

public voidclear()

Clears the buffer.

public final voidclearFlag(int flag)

Removes the flag from this buffer's flags, if it is set.

protected final booleangetFlag(int flag)

Returns whether the specified flag has been set on this buffer.

public final booleanhasSupplementalData()

Returns whether the C.BUFFER_FLAG_HAS_SUPPLEMENTAL_DATA flag is set.

public final booleanisEndOfStream()

Returns whether the C.BUFFER_FLAG_END_OF_STREAM flag is set.

public final booleanisFirstSample()

Returns whether the C.BUFFER_FLAG_FIRST_SAMPLE flag is set.

public final booleanisKeyFrame()

Returns whether the C.BUFFER_FLAG_KEY_FRAME flag is set.

public final booleanisLastSample()

Returns whether the C.BUFFER_FLAG_LAST_SAMPLE flag is set.

public final booleannotDependedOn()

Returns whether the C.BUFFER_FLAG_NOT_DEPENDED_ON flag is set.

public final voidsetFlags(int flags)

Replaces this buffer's flags with flags.

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

Constructors

public Buffer()

Methods

public void clear()

Clears the buffer.

public final boolean isFirstSample()

Returns whether the C.BUFFER_FLAG_FIRST_SAMPLE flag is set.

public final boolean isEndOfStream()

Returns whether the C.BUFFER_FLAG_END_OF_STREAM flag is set.

If this is set, all other attributes of the buffer should be ignored.

public final boolean isKeyFrame()

Returns whether the C.BUFFER_FLAG_KEY_FRAME flag is set.

public final boolean isLastSample()

Returns whether the C.BUFFER_FLAG_LAST_SAMPLE flag is set.

public final boolean hasSupplementalData()

Returns whether the C.BUFFER_FLAG_HAS_SUPPLEMENTAL_DATA flag is set.

public final boolean notDependedOn()

Returns whether the C.BUFFER_FLAG_NOT_DEPENDED_ON flag is set.

public final void setFlags(int flags)

Replaces this buffer's flags with flags.

Parameters:

flags: The flags to set, which should be a combination of the C.BUFFER_FLAG_* constants.

public final void addFlag(int flag)

Adds the flag to this buffer's flags.

Parameters:

flag: The flag to add to this buffer's flags, which should be one of the C.BUFFER_FLAG_* constants.

public final void clearFlag(int flag)

Removes the flag from this buffer's flags, if it is set.

Parameters:

flag: The flag to remove.

protected final boolean getFlag(int flag)

Returns whether the specified flag has been set on this buffer.

Parameters:

flag: The flag to check.

Returns:

Whether the flag is set.

Source

/*
 * Copyright (C) 2016 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package androidx.media3.decoder;

import androidx.annotation.CallSuper;
import androidx.media3.common.C;
import androidx.media3.common.util.UnstableApi;

/** Base class for buffers with flags. */
@UnstableApi
public abstract class Buffer {

  private @C.BufferFlags int flags;

  /** Clears the buffer. */
  @CallSuper
  public void clear() {
    flags = 0;
  }

  /** Returns whether the {@link C#BUFFER_FLAG_FIRST_SAMPLE} flag is set. */
  public final boolean isFirstSample() {
    return getFlag(C.BUFFER_FLAG_FIRST_SAMPLE);
  }

  /**
   * Returns whether the {@link C#BUFFER_FLAG_END_OF_STREAM} flag is set.
   *
   * <p>If this is set, all other attributes of the buffer should be ignored.
   */
  public final boolean isEndOfStream() {
    return getFlag(C.BUFFER_FLAG_END_OF_STREAM);
  }

  /** Returns whether the {@link C#BUFFER_FLAG_KEY_FRAME} flag is set. */
  public final boolean isKeyFrame() {
    return getFlag(C.BUFFER_FLAG_KEY_FRAME);
  }

  /** Returns whether the {@link C#BUFFER_FLAG_LAST_SAMPLE} flag is set. */
  public final boolean isLastSample() {
    return getFlag(C.BUFFER_FLAG_LAST_SAMPLE);
  }

  /** Returns whether the {@link C#BUFFER_FLAG_HAS_SUPPLEMENTAL_DATA} flag is set. */
  public final boolean hasSupplementalData() {
    return getFlag(C.BUFFER_FLAG_HAS_SUPPLEMENTAL_DATA);
  }

  /** Returns whether the {@link C#BUFFER_FLAG_NOT_DEPENDED_ON} flag is set. */
  public final boolean notDependedOn() {
    return getFlag(C.BUFFER_FLAG_NOT_DEPENDED_ON);
  }

  /**
   * Replaces this buffer's flags with {@code flags}.
   *
   * @param flags The flags to set, which should be a combination of the {@code C.BUFFER_FLAG_*}
   *     constants.
   */
  public final void setFlags(@C.BufferFlags int flags) {
    this.flags = flags;
  }

  /**
   * Adds the {@code flag} to this buffer's flags.
   *
   * @param flag The flag to add to this buffer's flags, which should be one of the {@code
   *     C.BUFFER_FLAG_*} constants.
   */
  public final void addFlag(@C.BufferFlags int flag) {
    flags |= flag;
  }

  /**
   * Removes the {@code flag} from this buffer's flags, if it is set.
   *
   * @param flag The flag to remove.
   */
  public final void clearFlag(@C.BufferFlags int flag) {
    flags &= ~flag;
  }

  /**
   * Returns whether the specified flag has been set on this buffer.
   *
   * @param flag The flag to check.
   * @return Whether the flag is set.
   */
  protected final boolean getFlag(@C.BufferFlags int flag) {
    return (flags & flag) == flag;
  }
}