Search in sources :

Example 6 with AckEvent

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();
        }
    };
}
Also used : KvsStreamingException(com.aws.iot.edgeconnectorforkvs.videouploader.model.exceptions.KvsStreamingException) PutMediaAckResponseHandler(com.amazonaws.services.kinesisvideo.PutMediaAckResponseHandler) AckEvent(com.amazonaws.services.kinesisvideo.model.AckEvent)

Aggregations

PutMediaAckResponseHandler (com.amazonaws.services.kinesisvideo.PutMediaAckResponseHandler)6 AckEvent (com.amazonaws.services.kinesisvideo.model.AckEvent)6 PutMediaRequest (com.amazonaws.services.kinesisvideo.model.PutMediaRequest)5 GetDataEndpointRequest (com.amazonaws.services.kinesisvideo.model.GetDataEndpointRequest)4 GetDataEndpointResult (com.amazonaws.services.kinesisvideo.model.GetDataEndpointResult)4 Test (org.junit.jupiter.api.Test)4 UploadCallBack (com.aws.iot.edgeconnectorforkvs.videouploader.callback.UploadCallBack)3 Date (java.util.Date)3 KvsStreamingException (com.aws.iot.edgeconnectorforkvs.videouploader.model.exceptions.KvsStreamingException)2 CountDownLatch (java.util.concurrent.CountDownLatch)1