# MediaCodec.BufferInfo

Added in[API level 16](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

# BufferInfo

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/android/media/MediaCodec.BufferInfo "View this page in Java")  

```
class BufferInfo
```

|---|----------------------------------------------------------------------------------------------------------------------------|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)                                             ||
| ↳ | [android.media.MediaCodec.BufferInfo](https://developer.android.com/reference/kotlin/android/media/MediaCodec.BufferInfo#) |

Per buffer metadata includes an offset and size specifying the range of valid data in the associated codec (output) buffer.

## Summary

|                                                     Public constructors                                                     ||
|--------------------------------------------------------------------------------------------------------------------------|---|
| [BufferInfo](https://developer.android.com/reference/kotlin/android/media/MediaCodec.BufferInfo#BufferInfo())`()` <br /> |

|                                                                                                                                                                                                                                                                                                                     Public methods                                                                                                                                                                                                                                                                                                                      ||
|------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [set](https://developer.android.com/reference/kotlin/android/media/MediaCodec.BufferInfo#set(kotlin.Int,%20kotlin.Int,%20kotlin.Long,%20kotlin.Int))`(`newOffset:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `newSize:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `newTimeUs:` `[Long](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html)`, `newFlags:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Update the buffer metadata information. |

|                                                                                                                                    Properties                                                                                                                                    ||
|------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)   | [flags](https://developer.android.com/reference/kotlin/android/media/MediaCodec.BufferInfo#flags:kotlin.Int) Buffer flags associated with the buffer.                                              |
| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)   | [offset](https://developer.android.com/reference/kotlin/android/media/MediaCodec.BufferInfo#offset:kotlin.Int) The start-offset of the data in the buffer.                                         |
| [Long](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html) | [presentationTimeUs](https://developer.android.com/reference/kotlin/android/media/MediaCodec.BufferInfo#presentationTimeUs:kotlin.Long) The presentation timestamp in microseconds for the buffer. |
| [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)   | [size](https://developer.android.com/reference/kotlin/android/media/MediaCodec.BufferInfo#size:kotlin.Int) The amount of data (in bytes) in the buffer.                                            |

## Public constructors

### BufferInfo

```
BufferInfo()
```

## Public methods

### set

Added in[API level 16](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
fun set(
    newOffset: Int, 
    newSize: Int, 
    newTimeUs: Long, 
    newFlags: Int
): Unit
```

Update the buffer metadata information.

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               Parameters                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               ||
|-------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `newOffset` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):the start-offset of the data in the buffer.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| `newSize`   | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):the amount of data (in bytes) in the buffer.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| `newTimeUs` | [Long](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html):the presentation timestamp in microseconds.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| `newFlags`  | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html):buffer flags associated with the buffer. This should be a combination of[BUFFER_FLAG_KEY_FRAME](https://developer.android.com/reference/kotlin/android/media/MediaCodec#BUFFER_FLAG_KEY_FRAME:kotlin.Int)and[BUFFER_FLAG_END_OF_STREAM](https://developer.android.com/reference/kotlin/android/media/MediaCodec#BUFFER_FLAG_END_OF_STREAM:kotlin.Int). Value is either`0`or a combination of[android.media.MediaCodec#BUFFER_FLAG_SYNC_FRAME](https://developer.android.com/reference/kotlin/android/media/MediaCodec#BUFFER_FLAG_SYNC_FRAME:kotlin.Int),[android.media.MediaCodec#BUFFER_FLAG_KEY_FRAME](https://developer.android.com/reference/kotlin/android/media/MediaCodec#BUFFER_FLAG_KEY_FRAME:kotlin.Int),[android.media.MediaCodec#BUFFER_FLAG_CODEC_CONFIG](https://developer.android.com/reference/kotlin/android/media/MediaCodec#BUFFER_FLAG_CODEC_CONFIG:kotlin.Int),[android.media.MediaCodec#BUFFER_FLAG_END_OF_STREAM](https://developer.android.com/reference/kotlin/android/media/MediaCodec#BUFFER_FLAG_END_OF_STREAM:kotlin.Int),[android.media.MediaCodec#BUFFER_FLAG_PARTIAL_FRAME](https://developer.android.com/reference/kotlin/android/media/MediaCodec#BUFFER_FLAG_PARTIAL_FRAME:kotlin.Int), android.media.MediaCodec.BUFFER_FLAG_MUXER_DATA, and[android.media.MediaCodec#BUFFER_FLAG_DECODE_ONLY](https://developer.android.com/reference/kotlin/android/media/MediaCodec#BUFFER_FLAG_DECODE_ONLY:kotlin.Int) |

## Properties

### flags

Added in[API level 16](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
var flags: Int
```

Buffer flags associated with the buffer. A combination of[BUFFER_FLAG_KEY_FRAME](https://developer.android.com/reference/kotlin/android/media/MediaCodec#BUFFER_FLAG_KEY_FRAME:kotlin.Int)and[BUFFER_FLAG_END_OF_STREAM](https://developer.android.com/reference/kotlin/android/media/MediaCodec#BUFFER_FLAG_END_OF_STREAM:kotlin.Int).

Encoded buffers that are key frames are marked with[BUFFER_FLAG_KEY_FRAME](https://developer.android.com/reference/kotlin/android/media/MediaCodec#BUFFER_FLAG_KEY_FRAME:kotlin.Int).

The last output buffer corresponding to the input buffer marked with[BUFFER_FLAG_END_OF_STREAM](https://developer.android.com/reference/kotlin/android/media/MediaCodec#BUFFER_FLAG_END_OF_STREAM:kotlin.Int)will also be marked with[BUFFER_FLAG_END_OF_STREAM](https://developer.android.com/reference/kotlin/android/media/MediaCodec#BUFFER_FLAG_END_OF_STREAM:kotlin.Int). In some cases this could be an empty buffer, whose sole purpose is to carry the end-of-stream marker.  
Value is either`0`or a combination of[android.media.MediaCodec#BUFFER_FLAG_SYNC_FRAME](https://developer.android.com/reference/kotlin/android/media/MediaCodec#BUFFER_FLAG_SYNC_FRAME:kotlin.Int),[android.media.MediaCodec#BUFFER_FLAG_KEY_FRAME](https://developer.android.com/reference/kotlin/android/media/MediaCodec#BUFFER_FLAG_KEY_FRAME:kotlin.Int),[android.media.MediaCodec#BUFFER_FLAG_CODEC_CONFIG](https://developer.android.com/reference/kotlin/android/media/MediaCodec#BUFFER_FLAG_CODEC_CONFIG:kotlin.Int),[android.media.MediaCodec#BUFFER_FLAG_END_OF_STREAM](https://developer.android.com/reference/kotlin/android/media/MediaCodec#BUFFER_FLAG_END_OF_STREAM:kotlin.Int),[android.media.MediaCodec#BUFFER_FLAG_PARTIAL_FRAME](https://developer.android.com/reference/kotlin/android/media/MediaCodec#BUFFER_FLAG_PARTIAL_FRAME:kotlin.Int), android.media.MediaCodec.BUFFER_FLAG_MUXER_DATA, and[android.media.MediaCodec#BUFFER_FLAG_DECODE_ONLY](https://developer.android.com/reference/kotlin/android/media/MediaCodec#BUFFER_FLAG_DECODE_ONLY:kotlin.Int)  

### offset

Added in[API level 16](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
var offset: Int
```

The start-offset of the data in the buffer.  

### presentationTimeUs

Added in[API level 16](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
var presentationTimeUs: Long
```

The presentation timestamp in microseconds for the buffer. This is derived from the presentation timestamp passed in with the corresponding input buffer. This should be ignored for a 0-sized buffer.  

### size

Added in[API level 16](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
var size: Int
```

The amount of data (in bytes) in the buffer. If this is`0`, the buffer has no data in it and can be discarded. The only use of a 0-size buffer is to carry the end-of-stream marker.