# TrackSampleTable

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/mp4/TrackSampleTable.java+class:androidx.media3.extractor.mp4.TrackSampleTable)

*** ** * ** ***


```
@UnstableApi
public final class TrackSampleTable
```

<br />

*** ** * ** ***

Sample table for a track in an MP4 file.

## Summary

| ### Public fields |
|---|---|
| `final long` | `https://developer.android.com/reference/androidx/media3/extractor/mp4/TrackSampleTable#durationUs()` The duration of the track sample table in microseconds. |
| `final int[]` | `https://developer.android.com/reference/androidx/media3/extractor/mp4/TrackSampleTable#flags()` Sample flags. |
| `final boolean` | `https://developer.android.com/reference/androidx/media3/extractor/mp4/TrackSampleTable#hasOnlySyncSamples()` Whether all samples in the track are sync samples. |
| `final int` | `https://developer.android.com/reference/androidx/media3/extractor/mp4/TrackSampleTable#maximumSize()` Maximum sample size in `https://developer.android.com/reference/androidx/media3/extractor/mp4/TrackSampleTable#sizes()`. |
| `final long[]` | `https://developer.android.com/reference/androidx/media3/extractor/mp4/TrackSampleTable#offsets()` Sample offsets in bytes. |
| `final int` | `https://developer.android.com/reference/androidx/media3/extractor/mp4/TrackSampleTable#sampleCount()` Number of samples. |
| `final int[]` | `https://developer.android.com/reference/androidx/media3/extractor/mp4/TrackSampleTable#sizes()` Sample sizes in bytes. |
| `final int[]` | `https://developer.android.com/reference/androidx/media3/extractor/mp4/TrackSampleTable#syncSampleIndices()` The indices of sync samples, sorted in ascending order. |
| `final long[]` | `https://developer.android.com/reference/androidx/media3/extractor/mp4/TrackSampleTable#timestampsUs()` Sample timestamps in microseconds. |
| `final https://developer.android.com/reference/androidx/media3/extractor/mp4/Track` | `https://developer.android.com/reference/androidx/media3/extractor/mp4/TrackSampleTable#track()` The track corresponding to this sample table. |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/media3/extractor/mp4/TrackSampleTable#TrackSampleTable(androidx.media3.extractor.mp4.Track,long[],int[],int,long[],int[],int[],boolean,long,int)( https://developer.android.com/reference/androidx/media3/extractor/mp4/Track track, long[] offsets, int[] sizes, int maximumSize, long[] timestampsUs, int[] flags, int[] syncSampleIndices, boolean hasOnlySyncSamples, long durationUs, int sampleCount )` |

| ### Public methods |
|---|---|
| `int` | `https://developer.android.com/reference/androidx/media3/extractor/mp4/TrackSampleTable#getIndexOfEarlierOrEqualSynchronizationSample(long)(long timeUs)` Returns the sample index of the closest synchronization sample at or before the given timestamp, if one is available. |
| `int` | `https://developer.android.com/reference/androidx/media3/extractor/mp4/TrackSampleTable#getIndexOfLaterOrEqualSynchronizationSample(long)(long timeUs)` Returns the sample index of the closest synchronization sample at or after the given timestamp, if one is available. |
| `boolean` | `https://developer.android.com/reference/androidx/media3/extractor/mp4/TrackSampleTable#hasSampleTableData()()` Returns whether the per-sample mapping arrays (such as `https://developer.android.com/reference/androidx/media3/extractor/mp4/TrackSampleTable#offsets()`, `https://developer.android.com/reference/androidx/media3/extractor/mp4/TrackSampleTable#sizes()`, `https://developer.android.com/reference/androidx/media3/extractor/mp4/TrackSampleTable#timestampsUs()`, and `https://developer.android.com/reference/androidx/media3/extractor/mp4/TrackSampleTable#flags()`) are populated. |

## Public fields

### durationUs

```
public final long durationUs
```

The duration of the track sample table in microseconds.

### flags

```
public final int[] flags
```

Sample flags. Populated only if `https://developer.android.com/reference/androidx/media3/extractor/mp4/TrackSampleTable#hasSampleTableData()` is `true`.

### hasOnlySyncSamples

```
public final boolean hasOnlySyncSamples
```

Whether all samples in the track are sync samples.

### maximumSize

```
public final int maximumSize
```

Maximum sample size in `https://developer.android.com/reference/androidx/media3/extractor/mp4/TrackSampleTable#sizes()`.

### offsets

```
public final long[] offsets
```

Sample offsets in bytes. Populated only if `https://developer.android.com/reference/androidx/media3/extractor/mp4/TrackSampleTable#hasSampleTableData()` is `true`.

### sampleCount

```
public final int sampleCount
```

Number of samples.

### sizes

```
public final int[] sizes
```

Sample sizes in bytes. Populated only if `https://developer.android.com/reference/androidx/media3/extractor/mp4/TrackSampleTable#hasSampleTableData()` is `true`.

### syncSampleIndices

```
public final int[] syncSampleIndices
```

The indices of sync samples, sorted in ascending order. This array is only populated if `https://developer.android.com/reference/androidx/media3/extractor/mp4/TrackSampleTable#hasOnlySyncSamples()` is `false`.

### timestampsUs

```
public final long[] timestampsUs
```

Sample timestamps in microseconds. Populated only if `https://developer.android.com/reference/androidx/media3/extractor/mp4/TrackSampleTable#hasSampleTableData()` is `
true`.

### track

```
public final Track track
```

The track corresponding to this sample table.

## Public constructors

### TrackSampleTable

```
public TrackSampleTable(
    Track track,
    long[] offsets,
    int[] sizes,
    int maximumSize,
    long[] timestampsUs,
    int[] flags,
    int[] syncSampleIndices,
    boolean hasOnlySyncSamples,
    long durationUs,
    int sampleCount
)
```

## Public methods

### getIndexOfEarlierOrEqualSynchronizationSample

```
public int getIndexOfEarlierOrEqualSynchronizationSample(long timeUs)
```

Returns the sample index of the closest synchronization sample at or before the given timestamp, if one is available.

| Parameters |
|---|---|
| `long timeUs` | Timestamp adjacent to which to find a synchronization sample. |

| Returns |
|---|---|
| `int` | Index of the synchronization sample, or `https://developer.android.com/reference/androidx/media3/common/C#INDEX_UNSET()` if none. |

### getIndexOfLaterOrEqualSynchronizationSample

```
public int getIndexOfLaterOrEqualSynchronizationSample(long timeUs)
```

Returns the sample index of the closest synchronization sample at or after the given timestamp, if one is available.

| Parameters |
|---|---|
| `long timeUs` | Timestamp adjacent to which to find a synchronization sample. |

| Returns |
|---|---|
| `int` | index Index of the synchronization sample, or `https://developer.android.com/reference/androidx/media3/common/C#INDEX_UNSET()` if none. |

### hasSampleTableData

```
public boolean hasSampleTableData()
```

Returns whether the per-sample mapping arrays (such as `https://developer.android.com/reference/androidx/media3/extractor/mp4/TrackSampleTable#offsets()`, `https://developer.android.com/reference/androidx/media3/extractor/mp4/TrackSampleTable#sizes()`, `https://developer.android.com/reference/androidx/media3/extractor/mp4/TrackSampleTable#timestampsUs()`, and `https://developer.android.com/reference/androidx/media3/extractor/mp4/TrackSampleTable#flags()`) are populated.

When `https://developer.android.com/reference/androidx/media3/extractor/mp4/Mp4Extractor#FLAG_OMIT_TRACK_SAMPLE_TABLE()` is set, this returns `false` while `https://developer.android.com/reference/androidx/media3/extractor/mp4/TrackSampleTable#sampleCount()` may still be greater than `0`.