Notifications in Kinesis Video Streams - Amazon Kinesis Video Streams

Notifications in Kinesis Video Streams

When a media fragment is available for consumption, Kinesis Video Streams notifies customers using Amazon Simple Notification Service (Amazon SNS) notifications. The following topic explains how to get started with notifications.

UpdateNotificationConfiguration

Use this API operation to update the notification information for a stream. For more information about the UpdateNotificationConfiguration feature, see UpdateNotificationConfiguration in the Amazon Kinesis Video Streams Developer Guide.

Note

It takes at least one minute to initiate the notification after updating the notification configuration. Wait at least one minute before invoking PutMedia after the update call.

DescribeNotificationConfiguration

Use this API to describe a notification configuration attached to a stream. For more information about the DescribeNotificationConfiguration feature, see DescribeNotificationConfiguration in the Amazon Kinesis Video Streams Developer Guide.

Producer MKV tags

You can use the Kinesis Video Streams Producer SDK to tag specific fragments of interest by exposing an API operation in the SDK. See a sample of how this works in this section of code. Upon calling this API, the SDK will add a set of predefined MKV tags along with the fragment data. Kinesis Video Streams will recognize these special MKV tags and initiate notifications for the tagged fragments.

Any fragment metadata provided along with the Notification MKV tags will be published as part of the Amazon SNS topic payload.

Syntax for Producer MKV tags

|+ Tags | + Tag | // MANDATORY: Predefined MKV tag to trigger the notification for the fragment | + Simple | + Name: AWS_KINESISVIDEO_NOTIFICATION | + String | // OPTIONAL: Key value pairs that will be sent as part of the Notification payload | + Simple | + Name: CUSTOM_KEY_1 // Max 128 bytes | + String:CUSTOM_VALUE_1 // Max 256 bytes | + Simple | + Name: CUSTOM_KEY_2 // Max 128 bytes | + String: CUSTOM_VALUE_2 // Max 256 bytes

MKV tag limits

The following table lists the limitations associated with the metadata tags. If the metadata tag limit is adjustable, you can request an increase through your account manager.

Limit Max value Adjustable

Optional metadata key length

128

No

Optional metadata value length

256

No

Max number of optional metadata

10

Yes

Amazon SNS topic payload

Any notification initiated through the previous workflow will deliver the Amazon SNS topic payload, as shown in the following example. This example is an Amazon SNS message that occurs after consuming notification data from an Amazon Simple Queue Service (Amazon SQS) queue.

{ "Type" : "Notification", "MessageId" : Message ID, "TopicArn" : SNS ARN, "Subject" : "Kinesis Video Streams Notification", "Message" : "{\"StreamArn\":\Stream Arn,\"FragmentNumber\":\Fragment Number,\"FragmentStartProducerTimestamp\":FragmentStartProducerTimestamp, \"FragmentStartServerTimestamp\":FragmentStartServerTimestamp,\"NotificationType\":\"PERSISTED\",\"NotificationPayload\":{\ CUSTOM_KEY_1:\CUSTOM_VALUE_1, \CUSTOM_KEY_2:\CUSTOM_VALUE_2}}", "Timestamp" : "2022-04-25T18:36:29.194Z", "SignatureVersion" : Signature Version, "Signature" : Signature, "SigningCertURL" : Signing Cert URL, "UnsubscribeURL" : Unsubscribe URL }
Subject: "Kinesis Video Streams Notification" Message: { "StreamArn":Stream Arn, "FragmentNumber":Fragment Number, "FragmentStartProducerTimestamp":Fragment Start Producer Timestamp, "FragmentStartServerTimestamp":Fragment Start Server Timestamp, "NotificationType":"PERSISTED", "NotificationPayload":{ CUSTOM_KEY_1:CUSTOM_VALUE_1, CUSTOM_KEY_2:CUSTOM_VALUE_2 } }

Viewing your Amazon SNS messages

You cannot read messages directly from an Amazon SNS topic because there's no API for doing so. To view the messages, subscribe an SQS queue to the SNS topic, or choose any other Amazon SNS supported destination. However, the most efficient option for viewing messages is to use Amazon SQS.

To view your Amazon SNS messages using Amazon SQS
  1. Create an Amazon SQS queue.

  2. From the AWS Management Console, open the Amazon SNS topic set as a destination under NotificationConfiguration.

  3. Choose Create Subscription, and then choose the Amazon SQS queue created in the first step.

  4. Run a PutMedia session with the Notification configuration enabled and with the Notification MKV tags added to the fragments.

  5. Choose the Amazon SQS queue in the Amazon SQS console, and then select Send and receive messages for the Amazon SQS queue.

  6. Poll for messages. This command should show all notifications generated by the PutMedia session. For information about polling, see Amazon SQS short and long polling.