use of com.amazonaws.kinesisvideo.producer.StreamDescription in project aws-sdk-android by aws-amplify.
the class KinesisVideoAndroidServiceClient method deleteStream.
@Override
public void deleteStream(@NonNull final String streamName, @NonNull final String version, final Date creationTime, long timeoutInMillis, @Nullable final KinesisVideoCredentialsProvider credentialsProvider) throws KinesisVideoException {
final AWSKinesisVideoClient serviceClient = createAwsKinesisVideoClient(credentialsProvider, Region.getRegion(Regions.fromName(configuration.getRegion())), configuration.getEndpoint(), (int) timeoutInMillis);
final StreamDescription streamDescription = describeStream(streamName, timeoutInMillis, credentialsProvider);
final DeleteStreamRequest deleteStreamRequest = new DeleteStreamRequest().withStreamARN(streamDescription.getStreamArn()).withCurrentVersion(streamDescription.getUpdateVersion());
log.debug("calling delete stream: " + deleteStreamRequest.toString());
final DeleteStreamResult deleteStreamResult;
try {
deleteStreamResult = serviceClient.deleteStream(deleteStreamRequest);
} catch (final AmazonClientException e) {
log.exception(e, "Service call failed.");
throw new KinesisVideoException(e);
}
log.debug("delete stream result: " + deleteStreamResult.toString());
}
use of com.amazonaws.kinesisvideo.producer.StreamDescription in project aws-sdk-android by aws-amplify.
the class DefaultServiceCallbacksImpl method describeStream.
@Override
public void describeStream(@NonNull final String streamName, final long callAfter, final long timeout, @Nullable final byte[] authData, final int authType, final long streamHandle, final KinesisVideoProducerStream stream) throws ProducerException {
Preconditions.checkState(isInitialized(), "Service callbacks object should be initialized first");
final long delay = calculateRelativeServiceCallAfter(callAfter);
final Runnable task = new Runnable() {
@Override
public void run() {
int statusCode;
StreamDescription streamDescription = null;
final KinesisVideoCredentialsProvider credentialsProvider = getCredentialsProvider(authData, log);
final long timeoutInMillis = timeout / Time.HUNDREDS_OF_NANOS_IN_A_MILLISECOND;
try {
streamDescription = kinesisVideoServiceClient.describeStream(streamName, timeoutInMillis, credentialsProvider);
statusCode = HTTP_OK;
} catch (final KinesisVideoException e) {
statusCode = getStatusCodeFromException(e);
log.error("Kinesis Video service client returned an error " + e.getMessage() + ". Reporting to Kinesis Video PIC.");
}
try {
kinesisVideoProducer.describeStreamResult(stream, streamHandle, streamDescription, statusCode);
} catch (final ProducerException e) {
throw new RuntimeException(e);
}
}
};
executor.schedule(task, delay, TimeUnit.NANOSECONDS);
}
Aggregations