Class NativeKinesisVideoProducerStream
- java.lang.Object
-
- com.amazonaws.kinesisvideo.internal.producer.jni.NativeKinesisVideoProducerStream
-
- All Implemented Interfaces:
KinesisVideoProducerStream,StreamCallbacks
public class NativeKinesisVideoProducerStream extends Object implements KinesisVideoProducerStream
Implementation ofKinesisVideoProducerStream
-
-
Field Summary
-
Fields inherited from interface com.amazonaws.kinesisvideo.internal.producer.KinesisVideoProducerStream
READY_TIMEOUT_IN_MILLISECONDS, STOPPED_TIMEOUT_IN_MILLISECONDS
-
-
Constructor Summary
Constructors Constructor Description NativeKinesisVideoProducerStream(NativeKinesisVideoProducerJni kinesisVideoProducerJni, StreamInfo streamInfo, long streamHandle, org.apache.logging.log4j.Logger log, StreamCallbacks streamCallbacks, DeviceInfo deviceInfo)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidawaitReady()Deprecated.voidawaitReady(Set<Long> readyStreamHandles)voidawaitStopped()voidbufferDurationOverflowPressure(long remainDuration)Stream temporal buffer pressure.voiddroppedFragmentReport(long fragmentTimecode)Reports a dropped fragment for the stream.voiddroppedFrameReport(long frameTimecode)Reports a dropped frame for the stream.voidfragmentAck(long uploadHandle, KinesisVideoFragmentAck kinesisVideoFragmentAck)Reports an ACK for a fragment.voidfragmentAckReceived(long uploadHandle, KinesisVideoFragmentAck fragmentAck)Reports the received ACK.InputStreamgetDataStream(long uploadHandle)Returns the input stream to retrieve the data from.KinesisVideoStreamMetricsgetMetrics()Returns stream specific metrics.voidgetStreamData(long uploadHandle, byte[] fillBuffer, int offset, int length, ReadResult readResult)Get stream data from the buffer.longgetStreamHandle()Returns the underlying native stream handleStreamInfogetStreamInfo()StringgetStreamName()Returns the stream namevoidparseFragmentAck(long uploadHandle, String kinesisVideoFragmentAck)Parses and processes a response which can contain partial/multiple fragment ACK.voidputEventMetadata(int event, StreamEventMetadata streamEventMetadata)Puts an event metadata into the stream.voidputFragmentMetadata(String metadataName, String metadataValue, boolean persistent)Puts a fragment metadata into the stream.voidputFrame(KinesisVideoFrame kinesisVideoFrame)Puts a frame into the stream.voidresetConnection()Create a new connection to continue sending data in current buffervoidstopStream()Stops the Kinesis Video stream.voidstopStreamSync()Stops the Kinesis Video stream and awaits for the stream stopped notification in a sync call.voidstreamClosed(long uploadHandle)Stream has been closed.voidstreamConnectionStale(long lastAckDuration)Reports the stream staleness when the data is read and sent but no ACKs are received.voidstreamDataAvailable(long uploadHandle, long duration, long availableSize)New data is available for the stream.voidstreamErrorReport(long uploadHandle, long fragmentTimecode, long statusCode)Reports an error for the stream.voidstreamFormatChanged(byte[] codecPrivateData, int trackId)Indicates that the stream format has changed.voidstreamFreed()Free the Kinesis Video stream.voidstreamLatencyPressure(long duration)Reports the stream latency pressure.voidstreamReady()Ready to stream data.voidstreamTerminated(long uploadHandle, int statusCode)Reports an abnormal stream terminationvoidstreamUnderflowReport()Reports the stream underflow.
-
-
-
Constructor Detail
-
NativeKinesisVideoProducerStream
public NativeKinesisVideoProducerStream(@Nonnull NativeKinesisVideoProducerJni kinesisVideoProducerJni, @Nonnull StreamInfo streamInfo, long streamHandle, @Nonnull org.apache.logging.log4j.Logger log, @Nullable StreamCallbacks streamCallbacks, @Nullable DeviceInfo deviceInfo)
-
-
Method Detail
-
getDataStream
public InputStream getDataStream(long uploadHandle) throws ProducerException
Description copied from interface:KinesisVideoProducerStreamReturns the input stream to retrieve the data from. NOTE: The returned stream should ideally be buffered likeBufferedInputStreamIMPORTANT: During the streaming token rotation or when the underlying stream gets closed the stream returned by this function will also close. The caller then should re-acquire a new stream by calling this API again.- Specified by:
getDataStreamin interfaceKinesisVideoProducerStream- Parameters:
uploadHandle- Client stream upload handle.- Returns:
InputStreamfor retrieving the data- Throws:
ProducerException
-
getStreamData
public void getStreamData(long uploadHandle, @Nonnull byte[] fillBuffer, int offset, int length, @Nonnull ReadResult readResult) throws ProducerExceptionDescription copied from interface:KinesisVideoProducerStreamGet stream data from the buffer.- Specified by:
getStreamDatain interfaceKinesisVideoProducerStream- Parameters:
uploadHandle- Client stream upload handle.fillBuffer- The buffer to filloffset- The start of the bufferlength- The number of bytes to fillreadResult- The result of the read- Throws:
ProducerException
-
putFrame
public void putFrame(@Nonnull KinesisVideoFrame kinesisVideoFrame) throws ProducerException
Description copied from interface:KinesisVideoProducerStreamPuts a frame into the stream.- Specified by:
putFramein interfaceKinesisVideoProducerStream- Throws:
ProducerException
-
putFragmentMetadata
public void putFragmentMetadata(@Nonnull String metadataName, @Nonnull String metadataValue, boolean persistent) throws ProducerException
Description copied from interface:KinesisVideoProducerStreamPuts a fragment metadata into the stream.- Specified by:
putFragmentMetadatain interfaceKinesisVideoProducerStream- Throws:
ProducerException
-
putEventMetadata
public void putEventMetadata(int event, @Nullable StreamEventMetadata streamEventMetadata) throws ProducerExceptionDescription copied from interface:KinesisVideoProducerStreamPuts an event metadata into the stream.- Specified by:
putEventMetadatain interfaceKinesisVideoProducerStream- Throws:
ProducerException
-
fragmentAck
public void fragmentAck(long uploadHandle, @Nonnull KinesisVideoFragmentAck kinesisVideoFragmentAck) throws ProducerExceptionDescription copied from interface:KinesisVideoProducerStreamReports an ACK for a fragment.- Specified by:
fragmentAckin interfaceKinesisVideoProducerStream- Parameters:
uploadHandle- Client stream upload handle.kinesisVideoFragmentAck- ACK string returned from the service.- Throws:
ProducerException
-
parseFragmentAck
public void parseFragmentAck(long uploadHandle, @Nonnull String kinesisVideoFragmentAck) throws ProducerExceptionDescription copied from interface:KinesisVideoProducerStreamParses and processes a response which can contain partial/multiple fragment ACK.- Specified by:
parseFragmentAckin interfaceKinesisVideoProducerStream- Parameters:
uploadHandle- Client stream upload handle.kinesisVideoFragmentAck- ACK string returned from the service.- Throws:
ProducerException
-
streamFormatChanged
public void streamFormatChanged(@Nullable byte[] codecPrivateData, int trackId) throws ProducerException
Description copied from interface:KinesisVideoProducerStreamIndicates that the stream format has changed. NOTE: CPD is @Nullable - specifying a null will remove the CPD. NOTE: currently, only Codec Private Data is supported while not streaming.- Specified by:
streamFormatChangedin interfaceKinesisVideoProducerStream- Throws:
ProducerException
-
streamTerminated
public void streamTerminated(long uploadHandle, int statusCode) throws ProducerExceptionDescription copied from interface:KinesisVideoProducerStreamReports an abnormal stream termination- Specified by:
streamTerminatedin interfaceKinesisVideoProducerStream- Parameters:
uploadHandle- - Client stream upload handle.statusCode- - Status code of the termination.- Throws:
ProducerException
-
stopStream
public void stopStream() throws ProducerExceptionDescription copied from interface:KinesisVideoProducerStreamStops the Kinesis Video stream. This simply kicks off stop stream operation but doesn't await for the resulting stream stopped notification.- Specified by:
stopStreamin interfaceKinesisVideoProducerStream- Throws:
ProducerException
-
stopStreamSync
public void stopStreamSync() throws ProducerExceptionDescription copied from interface:KinesisVideoProducerStreamStops the Kinesis Video stream and awaits for the stream stopped notification in a sync call.- Specified by:
stopStreamSyncin interfaceKinesisVideoProducerStream- Throws:
ProducerException
-
getMetrics
@Nonnull public KinesisVideoStreamMetrics getMetrics() throws ProducerException
Description copied from interface:KinesisVideoProducerStreamReturns stream specific metrics.- Specified by:
getMetricsin interfaceKinesisVideoProducerStream- Returns:
- Stream metrics
- Throws:
ProducerException
-
getStreamName
public String getStreamName()
Description copied from interface:KinesisVideoProducerStreamReturns the stream name- Specified by:
getStreamNamein interfaceKinesisVideoProducerStream
-
getStreamHandle
public long getStreamHandle()
Description copied from interface:KinesisVideoProducerStreamReturns the underlying native stream handle- Specified by:
getStreamHandlein interfaceKinesisVideoProducerStream- Returns:
-
streamFreed
public void streamFreed() throws ProducerExceptionDescription copied from interface:KinesisVideoProducerStreamFree the Kinesis Video stream.- Specified by:
streamFreedin interfaceKinesisVideoProducerStream- Throws:
ProducerException
-
streamUnderflowReport
public void streamUnderflowReport() throws ProducerExceptionDescription copied from interface:StreamCallbacksReports the stream underflow.- Specified by:
streamUnderflowReportin interfaceStreamCallbacks- Throws:
ProducerException
-
streamLatencyPressure
public void streamLatencyPressure(long duration) throws ProducerExceptionDescription copied from interface:StreamCallbacksReports the stream latency pressure.- Specified by:
streamLatencyPressurein interfaceStreamCallbacks- Parameters:
duration- The buffer duration in 100ns.- Throws:
ProducerException
-
streamConnectionStale
public void streamConnectionStale(long lastAckDuration) throws ProducerExceptionDescription copied from interface:StreamCallbacksReports the stream staleness when the data is read and sent but no ACKs are received.- Specified by:
streamConnectionStalein interfaceStreamCallbacks- Parameters:
lastAckDuration- The duration of time window when the last "buffering" ACK is received in 100ns.- Throws:
ProducerException
-
fragmentAckReceived
public void fragmentAckReceived(long uploadHandle, @Nonnull KinesisVideoFragmentAck fragmentAck) throws ProducerExceptionDescription copied from interface:StreamCallbacksReports the received ACK.- Specified by:
fragmentAckReceivedin interfaceStreamCallbacks- Parameters:
uploadHandle- The client stream upload handle.fragmentAck- The received fragment ACK.- Throws:
ProducerException
-
droppedFrameReport
public void droppedFrameReport(long frameTimecode) throws ProducerExceptionDescription copied from interface:StreamCallbacksReports a dropped frame for the stream.- Specified by:
droppedFrameReportin interfaceStreamCallbacks- Parameters:
frameTimecode- Frame time code of the dropped frame.- Throws:
ProducerException
-
droppedFragmentReport
public void droppedFragmentReport(long fragmentTimecode) throws ProducerExceptionDescription copied from interface:StreamCallbacksReports a dropped fragment for the stream.- Specified by:
droppedFragmentReportin interfaceStreamCallbacks- Parameters:
fragmentTimecode- Fragment time code of the dropped fragment.- Throws:
ProducerException
-
streamErrorReport
public void streamErrorReport(long uploadHandle, long fragmentTimecode, long statusCode) throws ProducerExceptionDescription copied from interface:StreamCallbacksReports an error for the stream. The client should terminate the connection as the inlet host would have/has already terminated the connection.- Specified by:
streamErrorReportin interfaceStreamCallbacks- Parameters:
uploadHandle- The client stream upload handle.fragmentTimecode- Fragment time code of the errored fragment.statusCode- Status code of the failure.- Throws:
ProducerException
-
streamDataAvailable
public void streamDataAvailable(long uploadHandle, long duration, long availableSize) throws ProducerExceptionDescription copied from interface:StreamCallbacksNew data is available for the stream.- Specified by:
streamDataAvailablein interfaceStreamCallbacks- Parameters:
uploadHandle- The client stream upload handle.duration- The duration of content available in the stream.availableSize- The size of the content available in the stream.- Throws:
ProducerException
-
streamReady
public void streamReady() throws ProducerExceptionDescription copied from interface:StreamCallbacksReady to stream data.- Specified by:
streamReadyin interfaceStreamCallbacks- Throws:
ProducerException
-
streamClosed
public void streamClosed(long uploadHandle) throws ProducerExceptionDescription copied from interface:StreamCallbacksStream has been closed.- Specified by:
streamClosedin interfaceStreamCallbacks- Parameters:
uploadHandle- The client stream upload handle.- Throws:
ProducerException
-
bufferDurationOverflowPressure
public void bufferDurationOverflowPressure(long remainDuration) throws ProducerExceptionDescription copied from interface:StreamCallbacksStream temporal buffer pressure.- Specified by:
bufferDurationOverflowPressurein interfaceStreamCallbacks- Parameters:
remainDuration- Remaining duration in the buffer in hundreds of nanos.- Throws:
ProducerException
-
resetConnection
public void resetConnection() throws ProducerExceptionCreate a new connection to continue sending data in current buffer- Specified by:
resetConnectionin interfaceKinesisVideoProducerStream- Throws:
ProducerException
-
awaitReady
@Deprecated public void awaitReady() throws ProducerException
Deprecated.- Throws:
ProducerException
-
awaitReady
public void awaitReady(@Nonnull Set<Long> readyStreamHandles) throws ProducerException
- Throws:
ProducerException
-
awaitStopped
public void awaitStopped() throws ProducerException- Throws:
ProducerException
-
getStreamInfo
@Nonnull public StreamInfo getStreamInfo()
- Specified by:
getStreamInfoin interfaceKinesisVideoProducerStream
-
-