use of com.amazonaws.services.kinesisvideo.model.GetDataEndpointResult in project aws-sdk-android by aws-amplify.
the class KinesisVideoAndroidServiceClient method getDataEndpoint.
@Override
public String getDataEndpoint(@NonNull final String streamName, @NonNull final String apiName, long timeoutInMillis, @Nullable final KinesisVideoCredentialsProvider credentialsProvider) throws KinesisVideoException {
final AWSKinesisVideoClient serviceClient = createAwsKinesisVideoClient(credentialsProvider, Region.getRegion(Regions.fromName(configuration.getRegion())), configuration.getEndpoint(), (int) timeoutInMillis);
final GetDataEndpointRequest getDataEndpointRequest = new GetDataEndpointRequest().withStreamName(streamName).withAPIName(apiName);
log.debug("calling get data endpoint: " + getDataEndpointRequest.toString());
final GetDataEndpointResult getDataEndpointResult;
try {
getDataEndpointResult = serviceClient.getDataEndpoint(getDataEndpointRequest);
} catch (final AmazonClientException e) {
log.exception(e, "Service call failed.");
throw new KinesisVideoException(e);
}
log.debug("get data endpoint result: " + getDataEndpointResult.toString());
return getDataEndpointResult.getDataEndpoint();
}
use of com.amazonaws.services.kinesisvideo.model.GetDataEndpointResult in project aws-iot-greengrass-edge-connector-for-kinesis-video-stream by awslabs.
the class VideoUploaderClientTest method uploadStream_mockAckResponseFailure_runCallbacks.
@Test
public void uploadStream_mockAckResponseFailure_runCallbacks() throws InterruptedException {
Assumptions.assumeTrue(setPrivateMember(videoUploaderClient, "kvsFrontendClient", mockKvsFrontendClient));
Assumptions.assumeTrue(setPrivateMember(videoUploaderClient, "kvsDataClient", mockKvsDataClient));
final boolean[] isStatusChanged = { false };
final Runnable statusChangedCallBack = () -> isStatusChanged[0] = true;
final UploadCallBack uploadCallBack = new UploadCallBack(Date.from(Instant.now()), edgeConnectorForKVSConfiguration);
ArgumentCaptor<PutMediaAckResponseHandler> putMediaAckResponseArgumentCaptor = ArgumentCaptor.forClass(PutMediaAckResponseHandler.class);
ArgumentCaptor<PutMediaRequest> putMediaRequestArgumentCaptor = ArgumentCaptor.forClass(PutMediaRequest.class);
when(mockKvsFrontendClient.getDataEndpoint(any(GetDataEndpointRequest.class))).thenReturn(new GetDataEndpointResult().withDataEndpoint(DATA_ENDPOINT));
doNothing().when(mockKvsDataClient).putMedia(any(PutMediaRequest.class), any(PutMediaAckResponseHandler.class));
// Since we make putMedia do nothing, so it won't end until we close it.
new Thread(() -> {
Assertions.assertThrows(KvsStreamingException.class, () -> videoUploaderClient.uploadStream(inputStream, Date.from(Instant.now()), statusChangedCallBack, uploadCallBack));
}).start();
// wait until task start
while (!videoUploaderClient.isOpen()) {
System.out.println("task is not running");
Thread.sleep(STATUS_CHANGED_TIME);
}
verify(mockKvsDataClient).putMedia(putMediaRequestArgumentCaptor.capture(), putMediaAckResponseArgumentCaptor.capture());
AckEvent event = new AckEvent().withAckEventType(AckEventType.Values.ERROR);
putMediaAckResponseArgumentCaptor.getValue().onAckEvent(event);
putMediaAckResponseArgumentCaptor.getValue().onFailure(new RuntimeException("Mock failure"));
// wait until task end
while (videoUploaderClient.isOpen()) {
System.out.println("task is running");
Thread.sleep(STATUS_CHANGED_TIME);
}
Assertions.assertFalse(isStatusChanged[0]);
verify(streamManager, times(0)).pushData(any(), any(), any(), any());
}
use of com.amazonaws.services.kinesisvideo.model.GetDataEndpointResult in project aws-iot-greengrass-edge-connector-for-kinesis-video-stream by awslabs.
the class VideoUploaderClientTest method uploadHistoricalVideo_uploadAndTaskIsTerminating_runCallbacks.
@Test
public void uploadHistoricalVideo_uploadAndTaskIsTerminating_runCallbacks() throws InterruptedException {
Assumptions.assumeTrue(setPrivateMember(videoUploaderClient, "kvsFrontendClient", mockKvsFrontendClient));
Assumptions.assumeTrue(setPrivateMember(videoUploaderClient, "kvsDataClient", mockKvsDataClient));
Assumptions.assumeTrue(setPrivateMember(videoUploaderClient, "isTaskTerminating", true));
Assumptions.assumeTrue(tempVideoFilesPresent());
final boolean[] isStatusChanged = { false };
final Runnable statusChangedCallBack = () -> isStatusChanged[0] = true;
final UploadCallBack uploadCallBack = new UploadCallBack(Date.from(Instant.now()), edgeConnectorForKVSConfiguration);
when(mockKvsFrontendClient.getDataEndpoint(any(GetDataEndpointRequest.class))).thenReturn(new GetDataEndpointResult().withDataEndpoint(DATA_ENDPOINT));
doNothing().when(mockKvsDataClient).putMedia(any(PutMediaRequest.class), any(PutMediaAckResponseHandler.class));
// Since we make putMedia do nothing, so it won't end until we close it.
new Thread(() -> {
videoUploaderClient.uploadHistoricalVideo(Date.from(instantNow.minusSeconds(600)), Date.from(instantNow.minusSeconds(200)), statusChangedCallBack, uploadCallBack);
}).start();
// wait until task start
if (!videoUploaderClient.isOpen()) {
System.out.println("task is not running");
Thread.sleep(STATUS_CHANGED_TIME);
}
videoUploaderClient.close();
// wait until task end
while (videoUploaderClient.isOpen()) {
System.out.println("task is running");
Thread.sleep(STATUS_CHANGED_TIME);
}
Assertions.assertFalse(isStatusChanged[0]);
verify(streamManager, times(0)).pushData(any(), any(), any(), any());
}
Aggregations