Using the Java Producer Library
You can use the Amazon Kinesis Video Streams provided Java Producer Library to write application code with minimal configuration, to send media data from a device to a Kinesis video stream.
Perform the following steps to integrate your code with Kinesis Video Streams so that your application can start streaming data to your Kinesis video stream:
-
Create an instance of the
KinesisVideoClient
object. -
Create a
MediaSource
object by providing media source information. For example, when creating a camera media source, you provide information such as identifying the camera and specifying the encoding the camera uses.When you want to start streaming, you must create a custom media source.
-
Register the media source with
KinesisVideoClient
.After you register the media source with
KinesisVideoClient
, whenever the data becomes available with the media source, it callsKinesisVideoClient
with the data.
Procedure: Using the Java Producer SDK
This procedure demonstrates how to use the Kinesis Video Streams Java Producer Client in your Java application to send data to your Kinesis video stream.
These steps don't require you to have a media source, such as a camera or microphone. Instead, for testing purposes, the code generates sample frames that consist of a series of bytes. You can use the same coding pattern when you send media data from real sources such as cameras and microphones.
The procedure includes the following steps:
Prerequisites
-
In the sample code, you provide credentials by specifying a profile that you set up in your Amazon credentials profile file. If you haven't already done so, first set up your credentials profile. For more information, see Set up Amazon Credentials and Region for Development
in the Amazon SDK for Java. Note
The Java example uses a
SystemPropertiesCredentialsProvider
object to obtain your credentials. The provider retrieves these credentials from theaws.accessKeyId
andaws.secretKey
Java system properties. You set these system properties in your Java development environment. For information about how to set Java system properties, see the documentation for your particular integrated development environment (IDE). -
Your
NativeLibraryPath
must contain yourKinesisVideoProducerJNI
file, available at https://github.com/awslabs/amazon-kinesis-video-streams-producer-sdk-cpp. The file name extension for this file depends on your operating system: -
KinesisVideoProducerJNI.so for Linux
-
KinesisVideoProducerJNI.dylib for macOS
-
KinesisVideoProducerJNI.dll for Windows
Note
Pre-built libraries for macOS, Ubuntu, Windows, and Raspbian are available in
src/main/resources/lib
at https://github.com/awslabs/amazon-kinesis-video-streams-producer-sdk-java.git. For other environments, compile the C++ Producer Library. -