public class

ParserException

extends java.io.IOException

 java.lang.Object

↳java.lang.Throwable

↳java.lang.Exception

↳java.io.IOException

↳androidx.media3.common.ParserException

Subclasses:

SsManifestParser.MissingFieldException, UnrecognizedInputFormatException

Gradle dependencies

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

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

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

Overview

Thrown when an error occurs parsing media data and metadata.

Summary

Fields
public final booleancontentIsMalformed

Whether the parsing error was caused by a bitstream not following the expected format.

public final intdataType

The data type of the parsed bitstream.

Constructors
protectedParserException(java.lang.String message, java.lang.Throwable cause, boolean contentIsMalformed, int dataType)

Methods
public static ParserExceptioncreateForMalformedContainer(java.lang.String message, java.lang.Throwable cause)

Creates a new instance for which ParserException.contentIsMalformed is true and ParserException.dataType is C.DATA_TYPE_MEDIA.

public static ParserExceptioncreateForMalformedDataOfUnknownType(java.lang.String message, java.lang.Throwable cause)

Creates a new instance for which ParserException.contentIsMalformed is true and ParserException.dataType is C.DATA_TYPE_UNKNOWN.

public static ParserExceptioncreateForMalformedManifest(java.lang.String message, java.lang.Throwable cause)

Creates a new instance for which ParserException.contentIsMalformed is true and ParserException.dataType is C.DATA_TYPE_MANIFEST.

public static ParserExceptioncreateForManifestWithUnsupportedFeature(java.lang.String message, java.lang.Throwable cause)

Creates a new instance for which ParserException.contentIsMalformed is false and ParserException.dataType is C.DATA_TYPE_MANIFEST.

public static ParserExceptioncreateForUnsupportedContainerFeature(java.lang.String message)

Creates a new instance for which ParserException.contentIsMalformed is false and ParserException.dataType is C.DATA_TYPE_MEDIA.

public java.lang.StringgetMessage()

from java.lang.ThrowableaddSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

Fields

public final boolean contentIsMalformed

Whether the parsing error was caused by a bitstream not following the expected format. May be false when a parser encounters a legal condition which it does not support.

public final int dataType

The data type of the parsed bitstream.

Constructors

protected ParserException(java.lang.String message, java.lang.Throwable cause, boolean contentIsMalformed, int dataType)

Methods

public static ParserException createForMalformedDataOfUnknownType(java.lang.String message, java.lang.Throwable cause)

Creates a new instance for which ParserException.contentIsMalformed is true and ParserException.dataType is C.DATA_TYPE_UNKNOWN.

Parameters:

message: See ParserException.getMessage().
cause: See getCause.

Returns:

The created instance.

public static ParserException createForMalformedContainer(java.lang.String message, java.lang.Throwable cause)

Creates a new instance for which ParserException.contentIsMalformed is true and ParserException.dataType is C.DATA_TYPE_MEDIA.

Parameters:

message: See ParserException.getMessage().
cause: See getCause.

Returns:

The created instance.

public static ParserException createForMalformedManifest(java.lang.String message, java.lang.Throwable cause)

Creates a new instance for which ParserException.contentIsMalformed is true and ParserException.dataType is C.DATA_TYPE_MANIFEST.

Parameters:

message: See ParserException.getMessage().
cause: See getCause.

Returns:

The created instance.

public static ParserException createForManifestWithUnsupportedFeature(java.lang.String message, java.lang.Throwable cause)

Creates a new instance for which ParserException.contentIsMalformed is false and ParserException.dataType is C.DATA_TYPE_MANIFEST.

Parameters:

message: See ParserException.getMessage().
cause: See getCause.

Returns:

The created instance.

public static ParserException createForUnsupportedContainerFeature(java.lang.String message)

Creates a new instance for which ParserException.contentIsMalformed is false and ParserException.dataType is C.DATA_TYPE_MEDIA.

Parameters:

message: See ParserException.getMessage().

Returns:

The created instance.

public java.lang.String getMessage()

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.common;

import androidx.annotation.Nullable;
import androidx.media3.common.C.DataType;
import androidx.media3.common.util.UnstableApi;
import java.io.IOException;

/** Thrown when an error occurs parsing media data and metadata. */
@UnstableApi
public class ParserException extends IOException {

  /**
   * Creates a new instance for which {@link #contentIsMalformed} is true and {@link #dataType} is
   * {@link C#DATA_TYPE_UNKNOWN}.
   *
   * @param message See {@link #getMessage()}.
   * @param cause See {@link #getCause()}.
   * @return The created instance.
   */
  public static ParserException createForMalformedDataOfUnknownType(
      @Nullable String message, @Nullable Throwable cause) {
    return new ParserException(message, cause, /* contentIsMalformed= */ true, C.DATA_TYPE_UNKNOWN);
  }

  /**
   * Creates a new instance for which {@link #contentIsMalformed} is true and {@link #dataType} is
   * {@link C#DATA_TYPE_MEDIA}.
   *
   * @param message See {@link #getMessage()}.
   * @param cause See {@link #getCause()}.
   * @return The created instance.
   */
  public static ParserException createForMalformedContainer(
      @Nullable String message, @Nullable Throwable cause) {
    return new ParserException(message, cause, /* contentIsMalformed= */ true, C.DATA_TYPE_MEDIA);
  }

  /**
   * Creates a new instance for which {@link #contentIsMalformed} is true and {@link #dataType} is
   * {@link C#DATA_TYPE_MANIFEST}.
   *
   * @param message See {@link #getMessage()}.
   * @param cause See {@link #getCause()}.
   * @return The created instance.
   */
  public static ParserException createForMalformedManifest(
      @Nullable String message, @Nullable Throwable cause) {
    return new ParserException(
        message, cause, /* contentIsMalformed= */ true, C.DATA_TYPE_MANIFEST);
  }

  /**
   * Creates a new instance for which {@link #contentIsMalformed} is false and {@link #dataType} is
   * {@link C#DATA_TYPE_MANIFEST}.
   *
   * @param message See {@link #getMessage()}.
   * @param cause See {@link #getCause()}.
   * @return The created instance.
   */
  public static ParserException createForManifestWithUnsupportedFeature(
      @Nullable String message, @Nullable Throwable cause) {
    return new ParserException(
        message, cause, /* contentIsMalformed= */ false, C.DATA_TYPE_MANIFEST);
  }

  /**
   * Creates a new instance for which {@link #contentIsMalformed} is false and {@link #dataType} is
   * {@link C#DATA_TYPE_MEDIA}.
   *
   * @param message See {@link #getMessage()}.
   * @return The created instance.
   */
  public static ParserException createForUnsupportedContainerFeature(@Nullable String message) {
    return new ParserException(
        message, /* cause= */ null, /* contentIsMalformed= */ false, C.DATA_TYPE_MEDIA);
  }

  /**
   * Whether the parsing error was caused by a bitstream not following the expected format. May be
   * false when a parser encounters a legal condition which it does not support.
   */
  public final boolean contentIsMalformed;

  /** The {@link DataType data type} of the parsed bitstream. */
  public final int dataType;

  protected ParserException(
      @Nullable String message,
      @Nullable Throwable cause,
      boolean contentIsMalformed,
      @DataType int dataType) {
    super(message, cause);
    this.contentIsMalformed = contentIsMalformed;
    this.dataType = dataType;
  }

  @Nullable
  @Override
  public String getMessage() {
    return super.getMessage()
        + " {contentIsMalformed="
        + contentIsMalformed
        + ", dataType="
        + dataType
        + "}";
  }
}