use of com.amazonaws.services.kinesisvideo.model.AckEvent in project aws-iot-greengrass-edge-connector-for-kinesis-video-stream by awslabs.
the class VideoUploaderClient method createResponseHandler.
/**
* Create a {@link PutMediaAckResponseHandler} that can handle messages while doing put media.
*
* @param latch A latch for handling asynchronous interrupt
* @return a {@link PutMediaAckResponseHandler}
*/
private PutMediaAckResponseHandler createResponseHandler(CountDownLatch latch, @SuppressWarnings("unused") Runnable statusChangedCallBack, UploadCallBack uploadCallBack) {
return new PutMediaAckResponseHandler() {
@Override
public void onAckEvent(AckEvent event) {
log.trace("onAckEvent " + event);
if (AckEventType.Values.PERSISTED.equals(event.getAckEventType().getEnumValue())) {
log.info("Fragment pushed to KVS " + event.getFragmentNumber());
if (uploadCallBack != null) {
updateUploadCallbackStatus(uploadCallBack, event);
}
}
if (AckEventType.Values.ERROR.equals(event.getAckEventType().getEnumValue())) {
lastKvsStreamingException = new KvsStreamingException(event.toString());
}
}
@Override
public void onFailure(Throwable t) {
log.info("onFailure");
lastKvsStreamingException = new KvsStreamingException(t.getMessage());
latch.countDown();
}
@Override
public void onComplete() {
log.info("onComplete");
if (uploadCallBack != null) {
uploadCallBack.onComplete();
}
latch.countDown();
}
};
}
Aggregations