Using the Java Producer Library - Amazon Kinesis Video Streams
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

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:

  1. Create an instance of the KinesisVideoClient object.

  2. 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.

  3. Register the media source with KinesisVideoClient.

    After you register the media source with KinesisVideoClient, whenever the data becomes available with the media source, it calls KinesisVideoClient 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 the aws.accessKeyId and aws.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 your KinesisVideoProducerJNI 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.