# RtpPcmReader

# RtpPcmReader

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/RtpPcmReader.java+class:androidx.media3.exoplayer.rtsp.reader.RtpPcmReader)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/media3/exoplayer/rtsp/reader/RtpPcmReader "View this page in Java")

<br />

```
@UnstableApi
class RtpPcmReader : RtpPayloadReader
```

<br />

*** ** * ** ***

Parses byte stream carried on RTP packets, and extracts PCM frames. Refer to RFC3551 for more details.

## Summary

|                                                                                                                                                 ### Public constructors                                                                                                                                                 |
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [RtpPcmReader](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/rtsp/reader/RtpPcmReader#RtpPcmReader(androidx.media3.exoplayer.rtsp.RtpPayloadFormat))`(payloadFormat: `[RtpPayloadFormat](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/rtsp/RtpPayloadFormat)`!)` |

|                             ### Public functions                              |
|-------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [consume](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/rtsp/reader/RtpPcmReader#consume(androidx.media3.common.util.ParsableByteArray,long,int,boolean))`(` ` data: `[ParsableByteArray](https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray)`!,` ` timestamp: `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)`,` ` sequenceNumber: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`,` ` rtpMarker: `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) `)` Consumes the payload from the an RTP packet. |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [createTracks](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/rtsp/reader/RtpPcmReader#createTracks(androidx.media3.extractor.ExtractorOutput,int))`(extractorOutput: `[ExtractorOutput](https://developer.android.com/reference/kotlin/androidx/media3/extractor/ExtractorOutput)`!, trackId: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` Initializes the reader by providing its output and track id.                                                                                                                                                                                                      |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [onReceivingFirstPacket](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/rtsp/reader/RtpPcmReader#onReceivingFirstPacket(long,int))`(timestamp: `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)`, sequenceNumber: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` This method should be called on reading the first packet in a stream of incoming packets.                                                                                                                                                                                                                        |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [seek](https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/rtsp/reader/RtpPcmReader#seek(long,long))`(nextRtpTimestamp: `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)`, timeUs: `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)`)` Seeks the reader.                                                                                                                                                                                                                                                                                                                                  |

## Public constructors

### RtpPcmReader

```
RtpPcmReader(payloadFormat: RtpPayloadFormat!)
```  

## Public functions

### consume

```
fun consume(
    data: ParsableByteArray!,
    timestamp: Long,
    sequenceNumber: Int,
    rtpMarker: Boolean
): Unit
```

Consumes the payload from the an RTP packet.  

|                                                          Parameters                                                          |
|------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `data: `[ParsableByteArray](https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray)`!` | The RTP payload to consume.                                                                                                                                                            |
| `timestamp: `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)                                   | 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. |
| `sequenceNumber: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)                                | The sequence number of the RTP packet.                                                                                                                                                 |
| `rtpMarker: `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)                             | The marker bit of the RTP packet. The interpretation of this bit is specific to each payload format.                                                                                   |

|                                                             Throws                                                              |
|---------------------------------------------------------------------------------------------------------------------------------|----------------------------------|
| [androidx.media3.common.ParserException](https://developer.android.com/reference/kotlin/androidx/media3/common/ParserException) | If the data could not be parsed. |

### createTracks

```
fun createTracks(extractorOutput: ExtractorOutput!, trackId: Int): Unit
```

Initializes the reader by providing its output and track id.  

|                                                            Parameters                                                             |
|-----------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------|
| `extractorOutput: `[ExtractorOutput](https://developer.android.com/reference/kotlin/androidx/media3/extractor/ExtractorOutput)`!` | The[ExtractorOutput](https://developer.android.com/reference/kotlin/androidx/media3/extractor/ExtractorOutput)instance that receives the extracted data. |
| `trackId: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)                                            | The track identifier to set on the format.                                                                                                               |

### onReceivingFirstPacket

```
fun onReceivingFirstPacket(timestamp: Long, sequenceNumber: Int): Unit
```

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

|                                          Parameters                                           |
|-----------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `timestamp: `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)    | 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. |
| `sequenceNumber: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | The sequence associated with the first received RTP packet.                                                                                                                              |

### seek

```
fun seek(nextRtpTimestamp: Long, timeUs: Long): Unit
```

Seeks the reader.

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

|                                            Parameters                                             |
|---------------------------------------------------------------------------------------------------|---------------------------------------------------------|
| `nextRtpTimestamp: `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html) | The timestamp of the first packet to arrive after seek. |
| `timeUs: `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)           | The server acknowledged seek time in microseconds.      |