# FakeFrameWriter

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

*** ** * ** ***


```
@RequiresApi(value = 26)
@ExperimentalApi
class FakeFrameWriter : FrameWriter
```

<br />

*** ** * ** ***

A fake `https://developer.android.com/reference/kotlin/androidx/media3/common/video/FrameWriter` implementation for testing.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeFrameWriter#FakeFrameWriter()()` Creates a new instance. |

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeFrameWriter#close()()` Blocks until all resources are released. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeFrameWriter#configure(androidx.media3.common.Format,long)(format: https://developer.android.com/reference/kotlin/androidx/media3/common/Format!, @https://developer.android.com/reference/kotlin/androidx/media3/common/video/Frame.Usage usage: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` Format and usage support can be `https://developer.android.com/reference/kotlin/androidx/media3/common/video/FrameWriter.Info#isSupported(androidx.media3.common.Format,long)` on the `https://developer.android.com/reference/kotlin/androidx/media3/common/video/FrameWriter.Info` before configuring. |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/video/AsyncFrame?` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeFrameWriter#dequeueInputFrame(java.util.concurrent.Executor,java.lang.Runnable)(wakeupExecutor: https://developer.android.com/reference/java/util/concurrent/Executor.html!, wakeupListener: https://developer.android.com/reference/java/lang/Runnable.html!)` Dequeues an `https://developer.android.com/reference/kotlin/androidx/media3/common/video/AsyncFrame` storing a `https://developer.android.com/reference/kotlin/androidx/media3/common/video/Frame` of the `https://developer.android.com/reference/kotlin/androidx/media3/common/video/FrameWriter#configure(androidx.media3.common.Format,long)` format and usage, and a `https://developer.android.com/reference/kotlin/androidx/media3/common/video/SyncFenceWrapper` that must be waited on before filling the frame. |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/video/FrameWriter.Info!` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeFrameWriter#getInfo()()` Returns the `https://developer.android.com/reference/kotlin/androidx/media3/common/video/FrameWriter.Info` for this FrameWriter. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeFrameWriter#prepareInputFrame(androidx.media3.common.video.Frame)(frame: https://developer.android.com/reference/kotlin/androidx/media3/common/video/Frame!)` Makes a frame available to be returned by the next `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeFrameWriter#dequeueInputFrame(java.util.concurrent.Executor,java.lang.Runnable)` call. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeFrameWriter#queueInputFrame(androidx.media3.common.video.Frame,androidx.media3.common.video.SyncFenceWrapper)(frame: https://developer.android.com/reference/kotlin/androidx/media3/common/video/Frame!, writeCompleteFence: https://developer.android.com/reference/kotlin/androidx/media3/common/video/SyncFenceWrapper?)` Queues a filled frame for further processing. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeFrameWriter#signalEndOfStream()()` Notifies this `https://developer.android.com/reference/kotlin/androidx/media3/common/video/FrameWriter` that the current stream has ended. |

| ### Public properties |
|---|---|
| `volatile https://developer.android.com/reference/kotlin/androidx/media3/common/Format?` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeFrameWriter#configuredFormat()` |
| `https://developer.android.com/reference/java/util/concurrent/CountDownLatch.html!` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeFrameWriter#configuredLatch()` |
| `https://developer.android.com/reference/java/util/concurrent/CountDownLatch.html!` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeFrameWriter#dequeueAttemptedLatch()` |
| `https://developer.android.com/reference/java/util/concurrent/CountDownLatch.html!` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeFrameWriter#eosLatch()` |
| `https://developer.android.com/reference/java/util/concurrent/atomic/AtomicBoolean.html!` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeFrameWriter#eosSignaled()` |
| `volatile https://developer.android.com/reference/java/util/concurrent/CountDownLatch.html!` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeFrameWriter#frameLatch()` |
| `(https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/media3/common/video/Frame!>!` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeFrameWriter#queuedFrames()` |

### Inherited functions

From [java.lang.AutoCloseable](https://developer.android.com/reference/java/lang/AutoCloseable.html) `abstract https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/java/lang/AutoCloseable.html#close()()`

## Public constructors

### FakeFrameWriter

```
FakeFrameWriter()
```

Creates a new instance.

## Public functions

### close

```
fun close(): Unit
```

Blocks until all resources are released.

### configure

```
fun configure(format: Format!, @Frame.Usage usage: Long): Unit
```

Format and usage support can be `https://developer.android.com/reference/kotlin/androidx/media3/common/video/FrameWriter.Info#isSupported(androidx.media3.common.Format,long)` on the `https://developer.android.com/reference/kotlin/androidx/media3/common/video/FrameWriter.Info` before configuring.

Must be called before `https://developer.android.com/reference/kotlin/androidx/media3/common/video/FrameWriter#dequeueInputFrame(java.util.concurrent.Executor,java.lang.Runnable)`.

| Parameters |
|---|---|
| `format: https://developer.android.com/reference/kotlin/androidx/media3/common/Format!` | The format to configure. |
| `@https://developer.android.com/reference/kotlin/androidx/media3/common/video/Frame.Usage usage: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | The `@FrameUsage` flags describing how the frame will be used. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | if any frames are dequeued at the point this method is called. |
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | if the format or usage is unsupported. |

### dequeueInputFrame

```
fun dequeueInputFrame(wakeupExecutor: Executor!, wakeupListener: Runnable!): AsyncFrame?
```

Dequeues an `https://developer.android.com/reference/kotlin/androidx/media3/common/video/AsyncFrame` storing a `https://developer.android.com/reference/kotlin/androidx/media3/common/video/Frame` of the `https://developer.android.com/reference/kotlin/androidx/media3/common/video/FrameWriter#configure(androidx.media3.common.Format,long)` format and usage, and a `https://developer.android.com/reference/kotlin/androidx/media3/common/video/SyncFenceWrapper` that must be waited on before filling the frame.

The returned frame must be filled and `https://developer.android.com/reference/kotlin/androidx/media3/common/video/FrameWriter#queueInputFrame(androidx.media3.common.video.Frame,androidx.media3.common.video.SyncFenceWrapper)` back for processing.

If the `https://developer.android.com/reference/kotlin/androidx/media3/common/video/FrameWriter` is at capacity, this method returns null and will notify the listener when capacity is available, and it can be called again.

Only the most recent `wakeupListener` will be notified when capacity is available.

| Parameters |
|---|---|
| `wakeupExecutor: https://developer.android.com/reference/java/util/concurrent/Executor.html!` | The `https://developer.android.com/reference/java/util/concurrent/Executor.html` on which the `wakeupListener` is invoked. |
| `wakeupListener: https://developer.android.com/reference/java/lang/Runnable.html!` | A `https://developer.android.com/reference/java/lang/Runnable.html` to be invoked when capacity becomes available. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/common/video/AsyncFrame?` | The dequeued frame, or null if the writer is at capacity. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | if `https://developer.android.com/reference/kotlin/androidx/media3/common/video/FrameWriter#configure(androidx.media3.common.Format,long)` has not been called. |

### getInfo

```
fun getInfo(): FrameWriter.Info!
```

Returns the `https://developer.android.com/reference/kotlin/androidx/media3/common/video/FrameWriter.Info` for this FrameWriter.

### prepareInputFrame

```
fun prepareInputFrame(frame: Frame!): Unit
```

Makes a frame available to be returned by the next `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeFrameWriter#dequeueInputFrame(java.util.concurrent.Executor,java.lang.Runnable)` call.

### queueInputFrame

```
fun queueInputFrame(frame: Frame!, writeCompleteFence: SyncFenceWrapper?): Unit
```

Queues a filled frame for further processing.

The queued frame must have been previously `https://developer.android.com/reference/kotlin/androidx/media3/common/video/FrameWriter#dequeueInputFrame(java.util.concurrent.Executor,java.lang.Runnable)` from this writer.

| Parameters |
|---|---|
| `frame: https://developer.android.com/reference/kotlin/androidx/media3/common/video/Frame!` | The filled frame to queue. |
| `writeCompleteFence: https://developer.android.com/reference/kotlin/androidx/media3/common/video/SyncFenceWrapper?` | A `https://developer.android.com/reference/kotlin/androidx/media3/common/video/SyncFenceWrapper` that will signal when the caller has finished writing to the frame, or `null` if the write was synchronous. |

### signalEndOfStream

```
fun signalEndOfStream(): Unit
```

Notifies this `https://developer.android.com/reference/kotlin/androidx/media3/common/video/FrameWriter` that the current stream has ended.

More frames may be queued after calling this method, if the current stream changes.

## Public properties

### configuredFormat

```
volatile val configuredFormat: Format?
```

### configuredLatch

```
val configuredLatch: CountDownLatch!
```

### dequeueAttemptedLatch

```
val dequeueAttemptedLatch: CountDownLatch!
```

### eosLatch

```
val eosLatch: CountDownLatch!
```

### eosSignaled

```
val eosSignaled: AtomicBoolean!
```

### frameLatch

```
volatile val frameLatch: CountDownLatch!
```

### queuedFrames

```
val queuedFrames: (Mutable)List<Frame!>!
```