# RtpPayloadReader

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

*** ** * ** ***


```
@UnstableApi
public interface RtpPayloadReader
```

<br />

Known direct subclasses [RtpAc3Reader](https://developer.android.com/reference/androidx/media3/exoplayer/rtsp/reader/RtpAc3Reader), [RtpPcmReader](https://developer.android.com/reference/androidx/media3/exoplayer/rtsp/reader/RtpPcmReader)

|---|---|
| `https://developer.android.com/reference/androidx/media3/exoplayer/rtsp/reader/RtpAc3Reader` | Parses an AC3 byte stream carried on RTP packets, and extracts AC3 frames. |
| `https://developer.android.com/reference/androidx/media3/exoplayer/rtsp/reader/RtpPcmReader` | Parses byte stream carried on RTP packets, and extracts PCM frames. |

*** ** * ** ***

Extracts media samples from the payload of received RTP packets.

## Summary

| ### Nested types |
|---|
| `public interface https://developer.android.com/reference/androidx/media3/exoplayer/rtsp/reader/RtpPayloadReader.Factory` Factory of `https://developer.android.com/reference/androidx/media3/exoplayer/rtsp/reader/RtpPayloadReader` instances. |

| ### Public methods |
|---|---|
| `abstract void` | `https://developer.android.com/reference/androidx/media3/exoplayer/rtsp/reader/RtpPayloadReader#consume(androidx.media3.common.util.ParsableByteArray,long,int,boolean)( https://developer.android.com/reference/androidx/media3/common/util/ParsableByteArray data, long timestamp, int sequenceNumber, boolean rtpMarker )` Consumes the payload from the an RTP packet. |
| `abstract void` | `https://developer.android.com/reference/androidx/media3/exoplayer/rtsp/reader/RtpPayloadReader#createTracks(androidx.media3.extractor.ExtractorOutput,int)(https://developer.android.com/reference/androidx/media3/extractor/ExtractorOutput extractorOutput, int trackId)` Initializes the reader by providing its output and track id. |
| `abstract void` | `https://developer.android.com/reference/androidx/media3/exoplayer/rtsp/reader/RtpPayloadReader#onReceivingFirstPacket(long,int)(long timestamp, int sequenceNumber)` This method should be called on reading the first packet in a stream of incoming packets. |
| `abstract void` | `https://developer.android.com/reference/androidx/media3/exoplayer/rtsp/reader/RtpPayloadReader#seek(long,long)(long nextRtpTimestamp, long timeUs)` Seeks the reader. |

## Public methods

### consume

```
abstract void consume(
    ParsableByteArray data,
    long timestamp,
    int sequenceNumber,
    boolean rtpMarker
)
```

Consumes the payload from the an RTP packet.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/util/ParsableByteArray data` | The RTP payload to consume. |
| `long timestamp` | The timestamp of the RTP packet that transmitted the data. This number has no unit, the duration conveyed by it depends on the frequency of the media that the RTP packet is carrying. |
| `int sequenceNumber` | The sequence number of the RTP packet. |
| `boolean rtpMarker` | The marker bit of the RTP packet. The interpretation of this bit is specific to each payload format. |

| Throws |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/ParserException` | If the data could not be parsed. |

### createTracks

```
abstract void createTracks(ExtractorOutput extractorOutput, int trackId)
```

Initializes the reader by providing its output and track id.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/extractor/ExtractorOutput extractorOutput` | The `https://developer.android.com/reference/androidx/media3/extractor/ExtractorOutput` instance that receives the extracted data. |
| `int trackId` | The track identifier to set on the format. |

### onReceivingFirstPacket

```
abstract void onReceivingFirstPacket(long timestamp, int sequenceNumber)
```

This method should be called on reading the first packet in a stream of incoming packets.

| Parameters |
|---|---|
| `long timestamp` | The timestamp associated with the first received RTP packet. This number has no unit, the duration conveyed by it depends on the frequency of the media that the RTP packet is carrying. |
| `int sequenceNumber` | The sequence associated with the first received RTP packet. |

### seek

```
abstract void seek(long nextRtpTimestamp, long timeUs)
```

Seeks the reader.

This method must only be invoked after the PLAY request for seeking is acknowledged by the RTSP server.

| Parameters |
|---|---|
| `long nextRtpTimestamp` | The timestamp of the first packet to arrive after seek. |
| `long timeUs` | The server acknowledged seek time in microseconds. |