Search in sources :

Example 1 with StreamManager

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

the class FragmentStatusUpdater method run.

public void run() {
    StreamManager streamManager = edgeConnectorForKVSConfiguration.getStreamManager();
    streamManager.pushData(edgeConnectorForKVSConfiguration.getSiteWiseAssetId(), edgeConnectorForKVSConfiguration.getVideoUploadedTimeRangePropertyId(), (double) lastUpdatedFragmentTimeCode / (double) Constants.MILLI_SECOND_TO_SECOND, Optional.of(dateBegin));
    log.trace("lastUpdatedFragment: " + lastUpdatedFragmentTimeCode + ", lastUpdatedVideoFile: " + ((lastUpdatedVideoFile == null) ? "null" : lastUpdatedVideoFile.getName()));
}
Also used : StreamManager(com.aws.iot.edgeconnectorforkvs.dataaccessor.StreamManager)

Example 2 with StreamManager

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

the class EdgeConnectorForKVSService method initStreamManagers.

private void initStreamManagers() {
    edgeConnectorForKVSConfigurationList.forEach(configuration -> {
        StreamManager streamManager = streamManagerBuilder.build();
        String msgStreamName = configuration.getKinesisVideoStreamName() + "-" + UUID.randomUUID().toString();
        log.info("Creating Message Stream: " + msgStreamName);
        streamManager.createMessageStream(msgStreamName);
        configuration.setStreamManager(streamManager);
    });
}
Also used : StreamManager(com.aws.iot.edgeconnectorforkvs.dataaccessor.StreamManager)

Example 3 with StreamManager

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

the class VideoFileManager method sendHeartBeatMessageToSiteWise.

/**
 * Method to update SiteWise CachedVideoAgeOutOnEdge property, used as heart beat measurement.
 * If given directory path has recorded video file, the updated property value will be the timestamp from the file
 * name;
 * If given directory path does not have recorded video file, the updated property value will be 0.
 *
 * @param directoryPath            {@link Path} for the video recording directory
 * @param edgeConnectorForKVSConfiguration   EdgeConnectorForKVSConfiguration
 */
private void sendHeartBeatMessageToSiteWise(@NonNull Path directoryPath, @NonNull EdgeConnectorForKVSConfiguration edgeConnectorForKVSConfiguration) {
    StreamManager streamManager = edgeConnectorForKVSConfiguration.getStreamManager();
    double cachedVideoAgeOutOnEdgeTime = 0;
    if (!diskManagerUtil.getRecordedFilesMap().isEmpty() && diskManagerUtil.getRecordedFilesMap().get(directoryPath) != null && !diskManagerUtil.getRecordedFilesMap().get(directoryPath).isEmpty()) {
        Path oldestVideoFilePath = diskManagerUtil.getRecordedFilesMap().get(directoryPath).peek();
        if (oldestVideoFilePath != null) {
            Date oldestVideoFileDate = VideoRecordVisitor.getDateFromFilePath(oldestVideoFilePath);
            cachedVideoAgeOutOnEdgeTime = oldestVideoFileDate.toInstant().getEpochSecond();
        }
    }
    streamManager.pushData(edgeConnectorForKVSConfiguration.getSiteWiseAssetId(), edgeConnectorForKVSConfiguration.getCachedVideoAgeOutOnEdgePropertyId(), cachedVideoAgeOutOnEdgeTime, Optional.empty());
}
Also used : Path(java.nio.file.Path) StreamManager(com.aws.iot.edgeconnectorforkvs.dataaccessor.StreamManager) Date(java.util.Date)

Example 4 with StreamManager

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

the class FileHandlingCallBack method handleWatchEvent.

// Thread safe method
// 1. add new added file to the recordedFilesMap in DiskManagerUtil
// 2. compute video recording period timestamp, then update SiteWise with new added file time stamp
public void handleWatchEvent(@NonNull Path directoryPath, @NonNull WatchEvent<?> event, @NonNull DiskManagerUtil diskManagerUtil) {
    synchronized (diskManagementLock) {
        Path videoFilePath = directoryPath.resolve((Path) event.context());
        diskManagerUtil.appendRecordFileToDirPath(directoryPath, videoFilePath);
        EdgeConnectorForKVSConfiguration edgeConnectorForKVSConfiguration = diskManagerUtil.getEdgeConnectorForKVSConfigurationFromPath(directoryPath);
        StreamManager streamManager = edgeConnectorForKVSConfiguration.getStreamManager();
        if (streamManager != null) {
            streamManager.pushData(edgeConnectorForKVSConfiguration.getSiteWiseAssetId(), edgeConnectorForKVSConfiguration.getVideoRecordedTimeRangePropertyId(), (double) VideoRecordVisitor.getDateFromFilePath(videoFilePath).toInstant().getEpochSecond(), Optional.of(diskManagerUtil.getVideoRecordingPeriodStartTime(directoryPath, videoFilePath)));
        }
    }
}
Also used : Path(java.nio.file.Path) StreamManager(com.aws.iot.edgeconnectorforkvs.dataaccessor.StreamManager) EdgeConnectorForKVSConfiguration(com.aws.iot.edgeconnectorforkvs.model.EdgeConnectorForKVSConfiguration)

Aggregations

StreamManager (com.aws.iot.edgeconnectorforkvs.dataaccessor.StreamManager)4 Path (java.nio.file.Path)2 EdgeConnectorForKVSConfiguration (com.aws.iot.edgeconnectorforkvs.model.EdgeConnectorForKVSConfiguration)1 Date (java.util.Date)1