Search in sources :

Example 11 with VideoUploader

use of com.aws.iot.edgeconnectorforkvs.videouploader.VideoUploader in project aws-iot-greengrass-edge-connector-for-kinesis-video-stream by awslabs.

the class EdgeConnectorForKVSService method startHistoricalVideoUploading.

private void startHistoricalVideoUploading(EdgeConnectorForKVSConfiguration configuration, long startTime, long endTime) throws InterruptedException {
    log.info("Start uploading video between " + startTime + " and " + endTime + " for stream " + configuration.getKinesisVideoStreamName());
    VideoUploader videoUploader = generateVideoUploader(configuration);
    Date dStartTime = new Date(startTime);
    Date dEndTime = new Date(endTime);
    boolean isUploadingFinished = false;
    do {
        try {
            videoUploader.uploadHistoricalVideo(dStartTime, dEndTime, new StatusChangedCallBack(), new UploadCallBack(dStartTime, configuration));
            isUploadingFinished = true;
        } catch (Exception ex) {
            // Log error and retry historical uploading process
            log.error("Failed to upload historical videos: {}", ex.getMessage());
        }
    } while (retryOnFail && !isUploadingFinished);
}
Also used : VideoUploader(com.aws.iot.edgeconnectorforkvs.videouploader.VideoUploader) StatusChangedCallBack(com.aws.iot.edgeconnectorforkvs.videouploader.callback.StatusChangedCallBack) Date(java.util.Date) TimeoutException(java.util.concurrent.TimeoutException) EdgeConnectorForKVSException(com.aws.iot.edgeconnectorforkvs.model.exceptions.EdgeConnectorForKVSException) EdgeConnectorForKVSUnrecoverableException(com.aws.iot.edgeconnectorforkvs.model.exceptions.EdgeConnectorForKVSUnrecoverableException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException) UploadCallBack(com.aws.iot.edgeconnectorforkvs.videouploader.callback.UploadCallBack)

Aggregations

VideoUploader (com.aws.iot.edgeconnectorforkvs.videouploader.VideoUploader)11 VideoRecorder (com.aws.iot.edgeconnectorforkvs.videorecorder.VideoRecorder)10 EdgeConnectorForKVSConfiguration (com.aws.iot.edgeconnectorforkvs.model.EdgeConnectorForKVSConfiguration)8 ArrayList (java.util.ArrayList)8 Test (org.junit.jupiter.api.Test)8 PipedOutputStream (java.io.PipedOutputStream)6 ReentrantLock (java.util.concurrent.locks.ReentrantLock)5 PipedInputStream (java.io.PipedInputStream)4 VideoUploadRequestEvent (com.aws.iot.edgeconnectorforkvs.handler.VideoUploadRequestEvent)2 EdgeConnectorForKVSException (com.aws.iot.edgeconnectorforkvs.model.exceptions.EdgeConnectorForKVSException)2 EdgeConnectorForKVSUnrecoverableException (com.aws.iot.edgeconnectorforkvs.model.exceptions.EdgeConnectorForKVSUnrecoverableException)2 StatusChangedCallBack (com.aws.iot.edgeconnectorforkvs.videouploader.callback.StatusChangedCallBack)2 UploadCallBack (com.aws.iot.edgeconnectorforkvs.videouploader.callback.UploadCallBack)2 KvsStreamingException (com.aws.iot.edgeconnectorforkvs.videouploader.model.exceptions.KvsStreamingException)2 IOException (java.io.IOException)2 Date (java.util.Date)2 ExecutionException (java.util.concurrent.ExecutionException)2 TimeoutException (java.util.concurrent.TimeoutException)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1