Example: Sending Data to Kinesis Video Streams Using the PutMedia
API

This example demonstrates how to use the PutMedia API. It shows how
to send data that is already in a container format (MKV). If your data needs to be
assembled into a container format before sending (for example, if you are assembling
camera video data into frames), see Kinesis Video Streams Producer Libraries.

Note

The PutMedia operation is available only in the C++ and Java SDKs,
due to the full-duplex management of connections, data flow, and acknowledgements.
It is not supported in other languages.

Create the PutMediaClient

The stream name. This example uses the stream that was created in the
Using the Java Producer Library (my-stream). To
use a different stream, change the following parameter:

private static final String STREAM_NAME="my-stream";

Note

The PutMedia API example does not create a stream.
You must create a stream either by using the test application for
the Using the Java Producer Library, by using the Kinesis Video Streams
console, or by using the AWS CLI.

The current timestamp.

The time code type. The example uses RELATIVE, indicating
that the timestamp is relative to the start of the container.

An AWSKinesisVideoV4Signer object that verifies that the
received packets were sent by the authorized sender.

Stream Media and
Pause the Thread

After the client is created, the sample starts asynchronous streaming with
putMediaInBackground. The main thread is then paused with
latch.await until the AckConsumer returns, at
which point the client is closed.