# FlacStreamMetadata

Artifact: [androidx.media3:media3-extractor](https://developer.android.com/jetpack/androidx/releases/media3) [View Source](https://cs.android.com/search?q=file:androidx/media3/extractor/FlacStreamMetadata.java+class:androidx.media3.extractor.FlacStreamMetadata)

*** ** * ** ***


```
@UnstableApi
public final class FlacStreamMetadata
```

<br />

*** ** * ** ***

Holder for FLAC metadata.

See the following sections of RFC 9639:

- [8.2 Streaminfo](https://www.rfc-editor.org/rfc/rfc9639.html#name-streaminfo)
- [8.5 Seek Table](https://www.rfc-editor.org/rfc/rfc9639.html#name-seek-table)
- [8.6 Vorbis Comment](https://www.rfc-editor.org/rfc/rfc9639.html#name-vorbis-comment)
- [8.8 Picture](https://www.rfc-editor.org/rfc/rfc9639.html#name-picture)

## Summary

| ### Nested types |
|---|
| `public class https://developer.android.com/reference/androidx/media3/extractor/FlacStreamMetadata.SeekTable` A FLAC seek table. |

| ### Constants |
|---|---|
| `static final int` | `https://developer.android.com/reference/androidx/media3/extractor/FlacStreamMetadata#NOT_IN_LOOKUP_TABLE() = -1` Indicates that a value is not in the corresponding lookup table. |

| ### Public fields |
|---|---|
| `final int` | `https://developer.android.com/reference/androidx/media3/extractor/FlacStreamMetadata#bitsPerSample()` Number of bits per sample. |
| `final int` | `https://developer.android.com/reference/androidx/media3/extractor/FlacStreamMetadata#bitsPerSampleLookupKey()` Lookup key corresponding to the number of bits per sample of the stream, or `https://developer.android.com/reference/androidx/media3/extractor/FlacStreamMetadata#NOT_IN_LOOKUP_TABLE()` if it is not in the lookup table. |
| `final int` | `https://developer.android.com/reference/androidx/media3/extractor/FlacStreamMetadata#channels()` Number of audio channels. |
| `final int` | `https://developer.android.com/reference/androidx/media3/extractor/FlacStreamMetadata#maxBlockSizeSamples()` Maximum number of samples per block. |
| `final int` | `https://developer.android.com/reference/androidx/media3/extractor/FlacStreamMetadata#maxFrameSize()` Maximum frame size in bytes, or 0 if the value is unknown. |
| `final int` | `https://developer.android.com/reference/androidx/media3/extractor/FlacStreamMetadata#minBlockSizeSamples()` Minimum number of samples per block. |
| `final int` | `https://developer.android.com/reference/androidx/media3/extractor/FlacStreamMetadata#minFrameSize()` Minimum frame size in bytes, or 0 if the value is unknown. |
| `final int` | `https://developer.android.com/reference/androidx/media3/extractor/FlacStreamMetadata#sampleRate()` Sample rate in Hertz. |
| `final int` | `https://developer.android.com/reference/androidx/media3/extractor/FlacStreamMetadata#sampleRateLookupKey()` Lookup key corresponding to the stream sample rate, or `https://developer.android.com/reference/androidx/media3/extractor/FlacStreamMetadata#NOT_IN_LOOKUP_TABLE()` if it is not in the lookup table. |
| `final @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/extractor/FlacStreamMetadata.SeekTable` | `https://developer.android.com/reference/androidx/media3/extractor/FlacStreamMetadata#seekTable()` Seek table, or `null` if it is not provided. |
| `final long` | `https://developer.android.com/reference/androidx/media3/extractor/FlacStreamMetadata#totalSamples()` Total number of samples, or 0 if the value is unknown. |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/media3/extractor/FlacStreamMetadata#FlacStreamMetadata(byte[],int)(byte[] data, int offset)` Parses binary FLAC stream info metadata. |
| `https://developer.android.com/reference/androidx/media3/extractor/FlacStreamMetadata#FlacStreamMetadata(int,int,int,int,int,int,int,long,java.util.ArrayList<java.lang.String>,java.util.ArrayList<androidx.media3.extractor.metadata.flac.PictureFrame>)( int minBlockSizeSamples, int maxBlockSizeSamples, int minFrameSize, int maxFrameSize, int sampleRate, int channels, int bitsPerSample, long totalSamples, https://developer.android.com/reference/java/util/ArrayList.html<https://developer.android.com/reference/java/lang/String.html> vorbisComments, https://developer.android.com/reference/java/util/ArrayList.html<https://developer.android.com/reference/androidx/media3/extractor/metadata/flac/PictureFrame> pictureFrames )` |

| ### Public methods |
|---|---|
| `https://developer.android.com/reference/androidx/media3/extractor/FlacStreamMetadata` | `https://developer.android.com/reference/androidx/media3/extractor/FlacStreamMetadata#copyWithPictureFrames(java.util.List<androidx.media3.extractor.metadata.flac.PictureFrame>)(https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/media3/extractor/metadata/flac/PictureFrame> pictureFrames)` Returns a copy of `this` with the given picture frames added to the metadata. |
| `https://developer.android.com/reference/androidx/media3/extractor/FlacStreamMetadata` | `https://developer.android.com/reference/androidx/media3/extractor/FlacStreamMetadata#copyWithSeekTable(androidx.media3.extractor.FlacStreamMetadata.SeekTable)(@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/extractor/FlacStreamMetadata.SeekTable seekTable)` Returns a copy of `this` with the seek table replaced by the one given. |
| `https://developer.android.com/reference/androidx/media3/extractor/FlacStreamMetadata` | `https://developer.android.com/reference/androidx/media3/extractor/FlacStreamMetadata#copyWithVorbisComments(java.util.List<java.lang.String>)(https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/java/lang/String.html> vorbisComments)` Returns a copy of `this` with the given Vorbis comments added to the metadata. |
| `long` | `https://developer.android.com/reference/androidx/media3/extractor/FlacStreamMetadata#getApproxBytesPerFrame()()` Returns the approximate number of bytes per frame for the current FLAC stream. |
| `int` | `https://developer.android.com/reference/androidx/media3/extractor/FlacStreamMetadata#getDecodedBitrate()()` Returns the bitrate of the stream after it's decoded into PCM. |
| `long` | `https://developer.android.com/reference/androidx/media3/extractor/FlacStreamMetadata#getDurationUs()()` Returns the duration of the FLAC stream in microseconds, or `https://developer.android.com/reference/androidx/media3/common/C#TIME_UNSET()` if the total number of samples if unknown. |
| `https://developer.android.com/reference/androidx/media3/common/Format` | `https://developer.android.com/reference/androidx/media3/extractor/FlacStreamMetadata#getFormat(byte[],androidx.media3.common.Metadata)( byte[] streamMarkerAndInfoBlock, @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/common/Metadata id3Metadata )` Returns a `https://developer.android.com/reference/androidx/media3/common/Format` extracted from the FLAC stream metadata. |
| `int` | `https://developer.android.com/reference/androidx/media3/extractor/FlacStreamMetadata#getMaxDecodedFrameSize()()` Returns the maximum size for a decoded frame from the FLAC stream. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/common/Metadata` | `https://developer.android.com/reference/androidx/media3/extractor/FlacStreamMetadata#getMetadataCopyWithAppendedEntriesFrom(androidx.media3.common.Metadata)(@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/common/Metadata other)` Returns a copy of the content metadata with entries from `other` appended. |
| `long` | `https://developer.android.com/reference/androidx/media3/extractor/FlacStreamMetadata#getSampleNumber(long)(long timeUs)` Returns the sample number of the sample at a given time. |

## Constants

### NOT_IN_LOOKUP_TABLE

```
public static final int NOT_IN_LOOKUP_TABLE = -1
```

Indicates that a value is not in the corresponding lookup table.

## Public fields

### bitsPerSample

```
public final int bitsPerSample
```

Number of bits per sample.

### bitsPerSampleLookupKey

```
public final int bitsPerSampleLookupKey
```

Lookup key corresponding to the number of bits per sample of the stream, or `https://developer.android.com/reference/androidx/media3/extractor/FlacStreamMetadata#NOT_IN_LOOKUP_TABLE()` if it is not in the lookup table.

This key is used to indicate the number of bits per sample in the frame header for the most common values.

The sample size lookup table is described in https://xiph.org/flac/format.html#frame_header.

### channels

```
public final int channels
```

Number of audio channels.

### maxBlockSizeSamples

```
public final int maxBlockSizeSamples
```

Maximum number of samples per block.

### maxFrameSize

```
public final int maxFrameSize
```

Maximum frame size in bytes, or 0 if the value is unknown.

### minBlockSizeSamples

```
public final int minBlockSizeSamples
```

Minimum number of samples per block.

### minFrameSize

```
public final int minFrameSize
```

Minimum frame size in bytes, or 0 if the value is unknown.

### sampleRate

```
public final int sampleRate
```

Sample rate in Hertz.

### sampleRateLookupKey

```
public final int sampleRateLookupKey
```

Lookup key corresponding to the stream sample rate, or `https://developer.android.com/reference/androidx/media3/extractor/FlacStreamMetadata#NOT_IN_LOOKUP_TABLE()` if it is not in the lookup table.

This key is used to indicate the sample rate in the frame header for the most common values.

The sample rate lookup table is described in https://xiph.org/flac/format.html#frame_header.

### seekTable

```
public final @Nullable FlacStreamMetadata.SeekTable seekTable
```

Seek table, or `null` if it is not provided.

### totalSamples

```
public final long totalSamples
```

Total number of samples, or 0 if the value is unknown.

## Public constructors

### FlacStreamMetadata

```
public FlacStreamMetadata(byte[] data, int offset)
```

Parses binary FLAC stream info metadata.

| Parameters |
|---|---|
| `byte[] data` | An array containing binary FLAC stream info block. |
| `int offset` | The offset of the stream info block in `data`, excluding the header (i.e. the offset points to the first byte of the minimum block size). |

### FlacStreamMetadata

```
public FlacStreamMetadata(
    int minBlockSizeSamples,
    int maxBlockSizeSamples,
    int minFrameSize,
    int maxFrameSize,
    int sampleRate,
    int channels,
    int bitsPerSample,
    long totalSamples,
    ArrayList<String> vorbisComments,
    ArrayList<PictureFrame> pictureFrames
)
```

## Public methods

### copyWithPictureFrames

```
public FlacStreamMetadata copyWithPictureFrames(List<PictureFrame> pictureFrames)
```

Returns a copy of `this` with the given picture frames added to the metadata.

### copyWithSeekTable

```
public FlacStreamMetadata copyWithSeekTable(@Nullable FlacStreamMetadata.SeekTable seekTable)
```

Returns a copy of `this` with the seek table replaced by the one given.

### copyWithVorbisComments

```
public FlacStreamMetadata copyWithVorbisComments(List<String> vorbisComments)
```

Returns a copy of `this` with the given Vorbis comments added to the metadata.

### getApproxBytesPerFrame

```
public long getApproxBytesPerFrame()
```

Returns the approximate number of bytes per frame for the current FLAC stream.

### getDecodedBitrate

```
public int getDecodedBitrate()
```

Returns the bitrate of the stream after it's decoded into PCM.

### getDurationUs

```
public long getDurationUs()
```

Returns the duration of the FLAC stream in microseconds, or `https://developer.android.com/reference/androidx/media3/common/C#TIME_UNSET()` if the total number of samples if unknown.

### getFormat

```
public Format getFormat(
    byte[] streamMarkerAndInfoBlock,
    @Nullable Metadata id3Metadata
)
```

Returns a `https://developer.android.com/reference/androidx/media3/common/Format` extracted from the FLAC stream metadata.

`streamMarkerAndInfoBlock` is updated to set the bit corresponding to the stream info last metadata block flag to true.

| Parameters |
|---|---|
| `byte[] streamMarkerAndInfoBlock` | An array containing the FLAC stream marker followed by the stream info block. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/common/Metadata id3Metadata` | The ID3 metadata of the stream, or `null` if there is no such data. |

| Returns |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/Format` | The extracted `https://developer.android.com/reference/androidx/media3/common/Format`. |

### getMaxDecodedFrameSize

```
public int getMaxDecodedFrameSize()
```

Returns the maximum size for a decoded frame from the FLAC stream.

### getMetadataCopyWithAppendedEntriesFrom

```
public @Nullable Metadata getMetadataCopyWithAppendedEntriesFrom(@Nullable Metadata other)
```

Returns a copy of the content metadata with entries from `other` appended.

### getSampleNumber

```
public long getSampleNumber(long timeUs)
```

Returns the sample number of the sample at a given time.

| Parameters |
|---|---|
| `long timeUs` | Time position in microseconds in the FLAC stream. |

| Returns |
|---|---|
| `long` | The sample number corresponding to the time position. |