Class NativeKinesisVideoProducerJni
- java.lang.Object
-
- com.amazonaws.kinesisvideo.internal.producer.jni.NativeKinesisVideoProducerJni
-
- All Implemented Interfaces:
KinesisVideoProducer
@ThreadSafe public class NativeKinesisVideoProducerJni extends Object implements KinesisVideoProducer
JNI interface to the native Producer SDK library wrapper
-
-
Field Summary
Fields Modifier and Type Field Description static StringEXPECTED_LIBRARY_VERSIONThe expected library version.static longINVALID_CLIENT_HANDLE_VALUESpecifying invalid client handle valuestatic longINVALID_STREAM_HANDLE_VALUESpecifying invalid stream handle valuestatic StringPRODUCER_NATIVE_LIBRARY_NAMEName of the native library-
Fields inherited from interface com.amazonaws.kinesisvideo.internal.producer.KinesisVideoProducer
READY_TIMEOUT_IN_MILLISECONDS
-
-
Constructor Summary
Constructors Constructor Description NativeKinesisVideoProducerJni(AuthCallbacks authCallbacks, StorageCallbacks storageCallbacks, ServiceCallbacks serviceCallbacks)Public constructor.NativeKinesisVideoProducerJni(AuthCallbacks authCallbacks, StorageCallbacks storageCallbacks, ServiceCallbacks serviceCallbacks, org.apache.logging.log4j.Logger log)Public constructorNativeKinesisVideoProducerJni(AuthCallbacks authCallbacks, StorageCallbacks storageCallbacks, ServiceCallbacks serviceCallbacks, org.apache.logging.log4j.Logger log, CountDownLatch readyLatch)Public constructorNativeKinesisVideoProducerJni(AuthCallbacks authCallbacks, StorageCallbacks storageCallbacks, ServiceCallbacks serviceCallbacks, org.apache.logging.log4j.Logger log, CountDownLatch readyLatch, boolean isTrackingMallocs)Public constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcreate(DeviceInfo deviceInfo)Creates the underlying Kinesis Video client objectvoidcreate(DeviceInfo deviceInfo, String nativeLibraryPath)Creates the underlying Kinesis Video client object.voidcreateDeviceResult(long customData, String deviceArn, int httpStatusCode)CreateDevice result eventKinesisVideoProducerStreamcreateStream(StreamInfo streamInfo, StreamCallbacks streamCallbacks)Creates a Kinesis Video streamvoidcreateStreamResult(KinesisVideoProducerStream stream, String streamArn, int httpStatusCode)CreateStream result eventKinesisVideoProducerStreamcreateStreamSync(StreamInfo streamInfo, StreamCallbacks streamCallbacks)Creates an Kinesis Video stream synchronouslyvoidcreateSync(DeviceInfo deviceInfo)Creates the underlying Kinesis Video client object synchronouslyvoidcreateSync(DeviceInfo deviceInfo, String nativeLibraryPath)Creates the underlying Kinesis Video client object synchronously.voiddescribeStreamResult(KinesisVideoProducerStream stream, long streamHandle, StreamDescription streamDescription, int httpStatusCode)DescribeStream result eventvoiddeviceCertToTokenResult(long customData, byte[] token, long expiration, int httpStatusCode)DeviceCertToToken result eventvoidfragmentAck(long streamHandle, long uploadHandle, KinesisVideoFragmentAck kinesisVideoFragmentAck)Report an ACK for a fragmentvoidfree()Frees the underlying Kinesis Video object.voidfreeStream(KinesisVideoProducerStream stream)Frees the specified streamvoidfreeStreams()Frees all of the underlying streamslonggetCurrentAllocationBytes()Return the current value of the allocated memory.KinesisVideoMetricsgetMetrics()voidgetStreamData(long streamHandle, long uploadHandle, byte[] fillBuffer, int offset, int length, ReadResult readResult)Get stream data from the buffer for specific upload Handle.voidgetStreamingEndpointResult(KinesisVideoProducerStream stream, long streamHandle, String endpoint, int httpStatusCode)GetStreamingEndpoint result eventvoidgetStreamingTokenResult(KinesisVideoProducerStream stream, long streamHandle, byte[] token, long expiration, int httpStatusCode)GetStreamingToken result eventvoidgetStreamMetrics(long streamHandle, KinesisVideoStreamMetrics streamMetrics)Fills in the stream metrics objectbooleanisInitialized()Returns whether the object has been initializedbooleanisReady()Returns whether the object is readyvoidlogPrint(int level, String tag, String picFmt, String message)Logs PIC logsvoidparseFragmentAck(long streamHandle, long uploadHandle, String kinesisVideoFragmentAck)Parses and processes an ACK stringvoidputEventMetadata(long streamHandle, int event, StreamEventMetadata streamEventMetadata)Put an event metadata.voidputFragmentMetadata(long streamHandle, String metadataName, String metadataValue, boolean persistent)Put a fragment metadata.voidputFrame(long streamHandle, KinesisVideoFrame kinesisVideoFrame)Put a frame.voidputStreamResult(KinesisVideoProducerStream stream, long clientStreamHandle, int httpStatusCode)PutStream result eventstatic voidsetupInstrumentedAllocators()Overrides malloc and free with a custom one for tracking purposes.voidstopStream(long streamHandle)Stops an Kinesis Video stream.voidstopStreams()Stops all Kinesis Video streams.voidstreamFormatChanged(long streamHandle, byte[] codecPrivateData, long trackId)Stream format has changed.voidstreamTerminated(long streamHandle, long uploadHandle, int statusCode)Reports an abnormal stream termination event.voidtagResourceResult(KinesisVideoProducerStream stream, long streamHandle, int httpStatusCode)TagResource result event
-
-
-
Field Detail
-
INVALID_CLIENT_HANDLE_VALUE
public static final long INVALID_CLIENT_HANDLE_VALUE
Specifying invalid client handle value- See Also:
- Constant Field Values
-
INVALID_STREAM_HANDLE_VALUE
public static final long INVALID_STREAM_HANDLE_VALUE
Specifying invalid stream handle value- See Also:
- Constant Field Values
-
PRODUCER_NATIVE_LIBRARY_NAME
public static final String PRODUCER_NATIVE_LIBRARY_NAME
Name of the native library- See Also:
- Constant Field Values
-
EXPECTED_LIBRARY_VERSION
public static final String EXPECTED_LIBRARY_VERSION
The expected library version.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
NativeKinesisVideoProducerJni
public NativeKinesisVideoProducerJni(@Nonnull AuthCallbacks authCallbacks, @Nonnull StorageCallbacks storageCallbacks, @Nonnull ServiceCallbacks serviceCallbacks) throws ProducerException
Public constructor.- Parameters:
authCallbacks- Authentication callbacksstorageCallbacks- Storage callbacksserviceCallbacks- Service call callbacks- Throws:
ProducerException
-
NativeKinesisVideoProducerJni
public NativeKinesisVideoProducerJni(@Nonnull AuthCallbacks authCallbacks, @Nonnull StorageCallbacks storageCallbacks, @Nonnull ServiceCallbacks serviceCallbacks, @Nonnull org.apache.logging.log4j.Logger log) throws ProducerException
Public constructor- Parameters:
authCallbacks- Authentication callbacksstorageCallbacks- Storage callbacksserviceCallbacks- Service call callbackslog- logger object to use for logging- Throws:
ProducerException
-
NativeKinesisVideoProducerJni
public NativeKinesisVideoProducerJni(@Nonnull AuthCallbacks authCallbacks, @Nonnull StorageCallbacks storageCallbacks, @Nonnull ServiceCallbacks serviceCallbacks, @Nonnull org.apache.logging.log4j.Logger log, @Nonnull CountDownLatch readyLatch) throws ProducerException
Public constructor- Parameters:
authCallbacks- Authentication callbacksstorageCallbacks- Storage callbacksserviceCallbacks- Service call callbackslog- log object to use for loggingreadyLatch- Ready latch for synch creation- Throws:
ProducerException
-
NativeKinesisVideoProducerJni
public NativeKinesisVideoProducerJni(@Nonnull AuthCallbacks authCallbacks, @Nonnull StorageCallbacks storageCallbacks, @Nonnull ServiceCallbacks serviceCallbacks, @Nonnull org.apache.logging.log4j.Logger log, @Nonnull CountDownLatch readyLatch, boolean isTrackingMallocs) throws ProducerException
Public constructor- Parameters:
authCallbacks- Authentication callbacksstorageCallbacks- Storage callbacksserviceCallbacks- Service call callbackslog- log object to use for loggingreadyLatch- Ready latch for synch creationisTrackingMallocs- Whether to set up PIC's instrumented allocators- Throws:
ProducerException
-
-
Method Detail
-
create
public void create(@Nonnull DeviceInfo deviceInfo) throws ProducerException
Creates the underlying Kinesis Video client object- Specified by:
createin interfaceKinesisVideoProducer- Parameters:
deviceInfo-DeviceInfoobject- Throws:
ProducerException
-
createSync
public void createSync(@Nonnull DeviceInfo deviceInfo) throws ProducerException
Creates the underlying Kinesis Video client object synchronously- Specified by:
createSyncin interfaceKinesisVideoProducer- Parameters:
deviceInfo-DeviceInfoobject- Throws:
ProducerException
-
create
public void create(@Nonnull DeviceInfo deviceInfo, @Nonnull String nativeLibraryPath) throws ProducerException
Creates the underlying Kinesis Video client object.- Parameters:
deviceInfo-DeviceInfoobjectnativeLibraryPath- Native library path- Throws:
ProducerException
-
createSync
public void createSync(@Nonnull DeviceInfo deviceInfo, @Nonnull String nativeLibraryPath) throws ProducerException
Creates the underlying Kinesis Video client object synchronously.- Parameters:
deviceInfo-DeviceInfoobjectnativeLibraryPath- Native library path- Throws:
ProducerException
-
isInitialized
public boolean isInitialized()
Returns whether the object has been initialized- Specified by:
isInitializedin interfaceKinesisVideoProducer- Returns:
- whether initialized
-
isReady
public boolean isReady()
Returns whether the object is ready- Specified by:
isReadyin interfaceKinesisVideoProducer- Returns:
- whether the object is ready
-
getMetrics
@Nonnull public KinesisVideoMetrics getMetrics() throws ProducerException
- Specified by:
getMetricsin interfaceKinesisVideoProducer- Throws:
ProducerException
-
free
public void free() throws ProducerExceptionFrees the underlying Kinesis Video object. This call is prompt and will terminate the ongoing transmission and drop the buffers.- Specified by:
freein interfaceKinesisVideoProducer- Throws:
ProducerException
-
createStream
public KinesisVideoProducerStream createStream(@Nonnull StreamInfo streamInfo, @Nullable StreamCallbacks streamCallbacks) throws ProducerException
Creates a Kinesis Video stream- Specified by:
createStreamin interfaceKinesisVideoProducer- Parameters:
streamInfo- Stream informationStreamInfoobjectstreamCallbacks- Optional stream callbacksStreamCallbacks- Returns:
- Newly create Kinesis Video stream
- Throws:
ProducerException
-
createStreamSync
public KinesisVideoProducerStream createStreamSync(@Nonnull StreamInfo streamInfo, @Nullable StreamCallbacks streamCallbacks) throws ProducerException
Creates an Kinesis Video stream synchronously- Specified by:
createStreamSyncin interfaceKinesisVideoProducer- Parameters:
streamInfo- Stream informationStreamInfoobjectstreamCallbacks- Optional stream callnbacksStreamCallbacks- Returns:
- Newly created Kinesis Video stream
- Throws:
ProducerException
-
stopStreams
public void stopStreams() throws ProducerExceptionStops all Kinesis Video streams. This is an async operation and the buffers will continue draining.- Specified by:
stopStreamsin interfaceKinesisVideoProducer- Throws:
ProducerException
-
stopStream
public void stopStream(long streamHandle) throws ProducerExceptionStops an Kinesis Video stream. This is an async operation and the buffers will continue draining until streamStopped event is received.- Parameters:
streamHandle- the handle of the stream- Throws:
ProducerException
-
freeStreams
public void freeStreams() throws ProducerExceptionDescription copied from interface:KinesisVideoProducerFrees all of the underlying streams- Specified by:
freeStreamsin interfaceKinesisVideoProducer- Throws:
ProducerException
-
freeStream
public void freeStream(@Nonnull KinesisVideoProducerStream stream) throws ProducerException
Description copied from interface:KinesisVideoProducerFrees the specified stream- Specified by:
freeStreamin interfaceKinesisVideoProducer- Parameters:
stream- Stream to free- Throws:
ProducerException
-
streamTerminated
public void streamTerminated(long streamHandle, long uploadHandle, int statusCode) throws ProducerExceptionReports an abnormal stream termination event.- Parameters:
streamHandle- the handle of the streamuploadHandle- the client stream upload handlestatusCode- the status code of the termination event.- Throws:
ProducerException
-
getStreamMetrics
public void getStreamMetrics(long streamHandle, @Nonnull KinesisVideoStreamMetrics streamMetrics) throws ProducerExceptionFills in the stream metrics object- Parameters:
streamHandle- the handle of the streamstreamMetrics- stream metrics to fill in- Throws:
ProducerException
-
putFrame
public void putFrame(long streamHandle, @Nonnull KinesisVideoFrame kinesisVideoFrame) throws ProducerExceptionPut a frame.- Parameters:
streamHandle- the handle of the streamkinesisVideoFrame- an KinesisVideoFrame object- Throws:
ProducerException
-
putFragmentMetadata
public void putFragmentMetadata(long streamHandle, @Nonnull String metadataName, @Nonnull String metadataValue, boolean persistent) throws ProducerExceptionPut a fragment metadata.- Parameters:
streamHandle- the handle of the streammetadataName- metadata namemetadataValue- metadata valuepersistent- whether this is persistent metadata or not- Throws:
ProducerException
-
putEventMetadata
public void putEventMetadata(long streamHandle, int event, @Nullable StreamEventMetadata streamEventMetadata) throws ProducerExceptionPut an event metadata.- Parameters:
streamHandle- The handle of the stream.event- The type of event(s), a value from the StreamEventType enum. If you want to submit multiple events in one call it is suggested to use bit-wise OR combination from StreamEventType enum.streamEventMetadata- Optional metadata. This metadata will be applied to all events included in THIS function call.- Throws:
ProducerException
-
fragmentAck
public void fragmentAck(long streamHandle, long uploadHandle, @Nonnull KinesisVideoFragmentAck kinesisVideoFragmentAck) throws ProducerExceptionReport an ACK for a fragment- Parameters:
streamHandle- the handle of the streamkinesisVideoFragmentAck- an KinesisVideoFragmentAck object- Throws:
ProducerException
-
parseFragmentAck
public void parseFragmentAck(long streamHandle, long uploadHandle, @Nonnull String kinesisVideoFragmentAck) throws ProducerExceptionParses and processes an ACK string- Parameters:
streamHandle- the handle of the streamkinesisVideoFragmentAck- string containing ACKs- Throws:
ProducerException
-
getStreamData
public void getStreamData(long streamHandle, long uploadHandle, @Nonnull byte[] fillBuffer, int offset, int length, @Nonnull ReadResult readResult) throws ProducerExceptionGet stream data from the buffer for specific upload Handle. Each uploadHandle correspond to a PutMedia connection to Kinesis Video Streams.- Parameters:
streamHandle- the handle of the streamuploadHandle- the client stream upload handlefillBuffer- The buffer to filloffset- The start of the bufferlength- The number of bytes to fillreadResult- The read result to fill in- Throws:
ProducerException
-
streamFormatChanged
public void streamFormatChanged(long streamHandle, @Nullable byte[] codecPrivateData, long trackId) throws ProducerExceptionStream format has changed. Currently, only supporting Codec Private Data- Parameters:
streamHandle- the handle of the streamcodecPrivateData- Codec Private Data or null to reset- Throws:
ProducerException
-
createStreamResult
public void createStreamResult(@Nonnull KinesisVideoProducerStream stream, @Nullable String streamArn, int httpStatusCode) throws ProducerException
Description copied from interface:KinesisVideoProducerCreateStream result event- Specified by:
createStreamResultin interfaceKinesisVideoProducer- Parameters:
stream- Stream object for the result event callbackstreamArn- Newly create stream ARN on successhttpStatusCode- HTTP status code- Throws:
ProducerException
-
describeStreamResult
public void describeStreamResult(KinesisVideoProducerStream stream, long streamHandle, @Nullable StreamDescription streamDescription, int httpStatusCode) throws ProducerException
Description copied from interface:KinesisVideoProducerDescribeStream result event- Specified by:
describeStreamResultin interfaceKinesisVideoProducer- Parameters:
stream- Stream object for the result event callbackstreamHandle- Stream handle returned by PICstreamDescription- Stream description objecthttpStatusCode- HTTP status code- Throws:
ProducerException
-
getStreamingEndpointResult
public void getStreamingEndpointResult(KinesisVideoProducerStream stream, long streamHandle, @Nullable String endpoint, int httpStatusCode) throws ProducerException
Description copied from interface:KinesisVideoProducerGetStreamingEndpoint result event- Specified by:
getStreamingEndpointResultin interfaceKinesisVideoProducer- Parameters:
stream- Stream object for the result event callbackstreamHandle- Stream handle returned by PICendpoint- Streaming endpoint if successfulhttpStatusCode- HTTP status code- Throws:
ProducerException
-
getStreamingTokenResult
public void getStreamingTokenResult(KinesisVideoProducerStream stream, long streamHandle, @Nullable byte[] token, long expiration, int httpStatusCode) throws ProducerException
Description copied from interface:KinesisVideoProducerGetStreamingToken result event- Specified by:
getStreamingTokenResultin interfaceKinesisVideoProducer- Parameters:
stream- Stream object for the result event callbackstreamHandle- Stream handle returned by PICtoken- Streaming token if successfulexpiration- Streaming token expiration in absolute time in 100nshttpStatusCode- HTTP status code- Throws:
ProducerException
-
putStreamResult
public void putStreamResult(KinesisVideoProducerStream stream, long clientStreamHandle, int httpStatusCode) throws ProducerException
Description copied from interface:KinesisVideoProducerPutStream result event- Specified by:
putStreamResultin interfaceKinesisVideoProducer- Parameters:
stream- Stream object for the result event callbackclientStreamHandle- A stream upload handle identifier from the client sidehttpStatusCode- HTTP status code- Throws:
ProducerException
-
tagResourceResult
public void tagResourceResult(KinesisVideoProducerStream stream, long streamHandle, int httpStatusCode) throws ProducerException
Description copied from interface:KinesisVideoProducerTagResource result event- Specified by:
tagResourceResultin interfaceKinesisVideoProducer- Parameters:
stream- Stream object for the result event callbackstreamHandle- Stream handle returned by PIChttpStatusCode- HTTP status code- Throws:
ProducerException
-
createDeviceResult
public void createDeviceResult(long customData, @Nullable String deviceArn, int httpStatusCode) throws ProducerExceptionDescription copied from interface:KinesisVideoProducerCreateDevice result event- Specified by:
createDeviceResultin interfaceKinesisVideoProducer- Parameters:
customData- Used for the result event callbackdeviceArn- Newly create device ARN on successhttpStatusCode- HTTP status code- Throws:
ProducerException
-
deviceCertToTokenResult
public void deviceCertToTokenResult(long customData, @Nullable byte[] token, long expiration, int httpStatusCode) throws ProducerExceptionDescription copied from interface:KinesisVideoProducerDeviceCertToToken result event- Specified by:
deviceCertToTokenResultin interfaceKinesisVideoProducer- Parameters:
customData- Used for the result event callbacktoken- Security token if successfulexpiration- Streaming token expiration in absolute time in 100nshttpStatusCode- HTTP status code- Throws:
ProducerException
-
logPrint
@CalledByNativeCode public void logPrint(@Nonnull int level, @Nonnull String tag, @Nonnull String picFmt, @Nonnull String message)
Logs PIC logs- Parameters:
level- - log level from PICtag- - tag from PICpicFmt- - fmt from PICmessage- - the string to be logged
-
setupInstrumentedAllocators
public static void setupInstrumentedAllocators()
Overrides malloc and free with a custom one for tracking purposes.
-
getCurrentAllocationBytes
public long getCurrentAllocationBytes()
Return the current value of the allocated memory. Note: Due to lazy memory allocation, this may not accurately reflect the current RSS usage.- Returns:
- the current memory currently malloc'd by the native codebase in bytes.
-
-