# 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)

*** ** * ** ***

<br />

```
@UnstableApi
class TrackSampleTable
```

<br />

*** ** * ** ***

Sample table for a track in an MP4 file.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/extractor/mp4/TrackSampleTable#TrackSampleTable(androidx.media3.extractor.mp4.Track,long[],int[],int,long[],int[],int[],boolean,long,int)( track: https://developer.android.com/reference/kotlin/androidx/media3/extractor/mp4/Track!, offsets: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html>!, sizes: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html>!, maximumSize: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, timestampsUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html>!, flags: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html>!, syncSampleIndices: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html>!, hasOnlySyncSamples: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html, durationUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, sampleCount: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html )` |

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

| ### Public properties |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/extractor/mp4/TrackSampleTable#durationUs()` The duration of the track sample table in microseconds. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html>!` | `https://developer.android.com/reference/kotlin/androidx/media3/extractor/mp4/TrackSampleTable#flags()` Sample flags. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/extractor/mp4/TrackSampleTable#hasOnlySyncSamples()` Whether all samples in the track are sync samples. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/extractor/mp4/TrackSampleTable#maximumSize()` Maximum sample size in `https://developer.android.com/reference/kotlin/androidx/media3/extractor/mp4/TrackSampleTable#sizes()`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html>!` | `https://developer.android.com/reference/kotlin/androidx/media3/extractor/mp4/TrackSampleTable#offsets()` Sample offsets in bytes. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/extractor/mp4/TrackSampleTable#sampleCount()` Number of samples. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html>!` | `https://developer.android.com/reference/kotlin/androidx/media3/extractor/mp4/TrackSampleTable#sizes()` Sample sizes in bytes. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html>!` | `https://developer.android.com/reference/kotlin/androidx/media3/extractor/mp4/TrackSampleTable#syncSampleIndices()` The indices of sync samples, sorted in ascending order. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html>!` | `https://developer.android.com/reference/kotlin/androidx/media3/extractor/mp4/TrackSampleTable#timestampsUs()` Sample timestamps in microseconds. |
| `https://developer.android.com/reference/kotlin/androidx/media3/extractor/mp4/Track!` | `https://developer.android.com/reference/kotlin/androidx/media3/extractor/mp4/TrackSampleTable#track()` The track corresponding to this sample table. |

## Public constructors

### TrackSampleTable

```
TrackSampleTable(
    track: Track!,
    offsets: LongArray<Long>!,
    sizes: IntArray<Int>!,
    maximumSize: Int,
    timestampsUs: LongArray<Long>!,
    flags: IntArray<Int>!,
    syncSampleIndices: IntArray<Int>!,
    hasOnlySyncSamples: Boolean,
    durationUs: Long,
    sampleCount: Int
)
```

## Public functions

### getIndexOfEarlierOrEqualSynchronizationSample

```
fun getIndexOfEarlierOrEqualSynchronizationSample(timeUs: Long): Int
```

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

| Parameters |
|---|---|
| `timeUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | Timestamp adjacent to which to find a synchronization sample. |

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

### getIndexOfLaterOrEqualSynchronizationSample

```
fun getIndexOfLaterOrEqualSynchronizationSample(timeUs: Long): Int
```

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

| Parameters |
|---|---|
| `timeUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | Timestamp adjacent to which to find a synchronization sample. |

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

### hasSampleTableData

```
fun hasSampleTableData(): Boolean
```

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

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

## Public properties

### durationUs

```
val durationUs: Long
```

The duration of the track sample table in microseconds.

### flags

```
val flags: Array<Int>!
```

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

### hasOnlySyncSamples

```
val hasOnlySyncSamples: Boolean
```

Whether all samples in the track are sync samples.

### maximumSize

```
val maximumSize: Int
```

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

### offsets

```
val offsets: Array<Long>!
```

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

### sampleCount

```
val sampleCount: Int
```

Number of samples.

### sizes

```
val sizes: Array<Int>!
```

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

### syncSampleIndices

```
val syncSampleIndices: Array<Int>!
```

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

### timestampsUs

```
val timestampsUs: Array<Long>!
```

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

### track

```
val track: Track!
```

The track corresponding to this sample table.