public abstract class

Buffer

extends java.lang.Object

 java.lang.Object

↳androidx.media3.decoder.Buffer

Subclasses:

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

Gradle dependencies

compile group: 'androidx.media3', name: 'media3-decoder', version: '1.0.0-alpha03'

  • groupId: androidx.media3
  • artifactId: media3-decoder
  • version: 1.0.0-alpha03

Artifact androidx.media3:media3-decoder:1.0.0-alpha03 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 booleanisDecodeOnly()

Returns whether the C.BUFFER_FLAG_DECODE_ONLY flag is set.

public final booleanisEndOfStream()

Returns whether the C.BUFFER_FLAG_END_OF_STREAM flag is set.

public final booleanisKeyFrame()

Returns whether the C.BUFFER_FLAG_KEY_FRAME 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 isDecodeOnly()

Returns whether the C.BUFFER_FLAG_DECODE_ONLY flag is set.

public final boolean isEndOfStream()

Returns whether the C.BUFFER_FLAG_END_OF_STREAM flag is set.

public final boolean isKeyFrame()

Returns whether the C.BUFFER_FLAG_KEY_FRAME flag is set.

public final boolean hasSupplementalData()

Returns whether the C.BUFFER_FLAG_HAS_SUPPLEMENTAL_DATA 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.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. */
  public void clear() {
    flags = 0;
  }

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

  /** Returns whether the {@link C#BUFFER_FLAG_END_OF_STREAM} flag is set. */
  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_HAS_SUPPLEMENTAL_DATA} flag is set. */
  public final boolean hasSupplementalData() {
    return getFlag(C.BUFFER_FLAG_HAS_SUPPLEMENTAL_DATA);
  }

  /**
   * 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;
  }
}