Class DefaultStreamCallbacks
- java.lang.Object
-
- com.amazonaws.kinesisvideo.streaming.DefaultStreamCallbacks
-
- All Implemented Interfaces:
StreamCallbacks
public class DefaultStreamCallbacks extends Object implements StreamCallbacks
No-op implementation of stream callbacks. Extending this class allows convenient implementation of certain callbacks while leaving the rest as no-op.For example:
StreamCallbacks streamCallbacks = new DefaultStreamCallbacks() { @Override public void fragmentAckReceived(final long uploadHandle, @Nonnull final KinesisVideoFragmentAck fragmentAck) throws ProducerException { super.fragmentAckReceived(uploadHandle, fragmentAck); // Stop submitting frames on user errors if (fragmentAck.getAckType().getIntType() == FragmentAckType.FRAGMENT_ACK_TYPE_ERROR && 4000 <= fragmentAck.getResult() && fragmentAck.getResult() < 5000) { log.error("{} - Received an error ack: {}", streamName, fragmentAck); mediaSource.stop(); // Other logic... } } @Override public void streamErrorReport(final long uploadHandle, final long frameTimecode, final long statusCode) throws ProducerException { super.streamErrorReport(uploadHandle, frameTimecode, statusCode); log.error("{} Encountered a streaming error with status code: 0x{}", streamName, Long.toHexString(statusCode)); mediaSource.stop(); // Other logic... } };
-
-
Constructor Summary
Constructors Constructor Description DefaultStreamCallbacks()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.voidfragmentAckReceived(long uploadHandle, KinesisVideoFragmentAck fragmentAck)Reports the received ACK.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 frameTimecode, long statusCode)Reports an error for the stream.voidstreamLatencyPressure(long duration)Reports the stream latency pressure.voidstreamReady()Ready to stream data.voidstreamUnderflowReport()Reports the stream underflow.
-
-
-
Method Detail
-
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
-
streamErrorReport
public void streamErrorReport(long uploadHandle, long frameTimecode, 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.frameTimecode- Fragment time code of the errored fragment.statusCode- Status code of the failure.- 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
-
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
-
-