Using the C++ Producer Library - Amazon Kinesis Video Streams

Using the C++ Producer Library

Amazon Kinesis Video Streams provides the C++ Producer Library, which you can use to write application code to send media data from a device to a Kinesis video stream.

Object Model

The C++ library provides the following objects to manage sending data to a Kinesis video stream:

  • KinesisVideoProducer: Contains information about your media source and AWS credentials, and maintains callbacks to report on Kinesis Video Streams events.

  • KinesisVideoStream: Represents the Kinesis video stream. Contains information about the video stream's parameters, such as name, data retention period, media content type, and so on.

Putting Media into the Stream

The C++ library provides methods (for example, PutFrame) that you can use to put data into the KinesisVideoStream object. The library then manages the internal state of the data, which can include the following tasks:

  • Performing authentication.

  • Watching for network latency. If the latency is too high, the library might choose to drop frames.

  • Tracking status of streaming in progress.

Callback Interfaces

This layer exposes a set of callback interfaces, which enable it to talk to the application layer. These callback interfaces include the following:

  • Service callbacks interface (CallbackProvider): The library invokes events obtained through this interface when it creates a stream, obtains a stream description, deletes a stream, and so on.

  • Client-ready state or low storage events interface (ClientCallbackProvider): The library invokes events on this interface when the client is ready, or when it detects that it might run out of available storage or memory.

  • Stream events callback interface (StreamCallbackProvider): The library invokes events on this interface when stream events occur, such as the stream entering the ready state, dropped frames, or stream errors.

Kinesis Video Streams provides default implementations for these interfaces. You can also provide your own custom implementation—for example, if you need custom networking logic or you want to expose a low storage condition to the user interface.

For more information about callbacks in the Producer Libraries, see Producer SDK Callbacks.

Procedure: Using the C++ Producer SDK

This procedure demonstrates how to use the Kinesis Video Streams client and media sources in a C++ application to send data to your Kinesis video stream.

The procedure includes the following steps:


  • Credentials: In the sample code, you provide credentials by specifying a profile that you set up in your AWS credentials profile file. If you haven't already done so, first set up your credentials profile.

    For more information, see Set up AWS Credentials and Region for Development.

  • Certificate store integration: The Kinesis Video Streams Producer Library must establish trust with the service it calls. This is done through validating the certification authorities (CAs) in the public certificate store. On Linux-based models, this store is located in the /etc/ssl/ directory.

    Download the certificate from the following location to your certificate store:

  • Install the following build dependencies for macOS:

  • Install the following build dependencies for Ubuntu (responses to version commands are truncated):

    • Install Git: sudo apt-get install git

      $ git --version git version 2.14.1
    • Install CMake: sudo apt-get install cmake

      $ cmake --version cmake version 3.9.1
    • Install Libtool: sudo apt-get install libtool

    • Install libtool-bin: sudo apt-get install libtool-bin

      $ libtool --version libtool (GNU libtool) 2.4.6 Written by Gordon Matzigkeit, 1996
    • Install GNU Automake: sudo apt-get install automake

      $ automake --version automake (GNU automake) 1.15
    • Install GNU Bison: sudo apt-get install bison

      $ bison -V bison (GNU Bison) 3.0.4
    • Install G++: sudo apt-get install g++

      g++ --version g++ (Ubuntu 7.2.0-8ubuntu3) 7.2.0
    • Install curl: sudo apt-get install curl

      $ curl --version curl 7.55.1 (x86_64-pc-linux-gnu) libcurl/7.55.1 OpenSSL/1.0.2g zlib/1.2.11 libidn2/2.0.2 libpsl/0.18.0 (+libidn2/2.0.2) librtmp/2.3
    • Install pkg-config: sudo apt-get install pkg-config

      $ pkg-config --version 0.29.1
    • Install Flex: sudo apt-get install flex

      $ flex --version flex 2.6.1
    • Install OpenJDK: sudo apt-get install openjdk-8-jdk

      $ java -version openjdk version "1.8.0_171"
    • Set the JAVA_HOME environment variable: export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/

    • Run the build script: ./install-script

Next Step

Step 1: Download and Configure the C++ Producer Library Code