use of com.amazonaws.kinesisvideo.auth.KinesisVideoCredentialsProvider 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);
}
use of com.amazonaws.kinesisvideo.auth.KinesisVideoCredentialsProvider in project aws-sdk-android by aws-amplify.
the class DefaultServiceCallbacksImpl method tagResource.
@Override
public void tagResource(@NonNull final String resourceArn, @Nullable final Tag[] tags, 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() {
final KinesisVideoCredentialsProvider credentialsProvider = getCredentialsProvider(authData, log);
final long timeoutInMillis = timeout / Time.HUNDREDS_OF_NANOS_IN_A_MILLISECOND;
int statusCode = HTTP_OK;
Map<String, String> tagsMap = null;
if (null != tags) {
// Convert the tags to map
tagsMap = new HashMap<String, String>(tags.length);
for (final Tag tag : tags) {
tagsMap.put(tag.getName(), tag.getValue());
}
}
try {
kinesisVideoServiceClient.tagStream(resourceArn, tagsMap, timeoutInMillis, credentialsProvider);
} catch (final KinesisVideoException e) {
log.error("Kinesis Video service client returned an error " + e.getMessage() + ". Reporting to Kinesis Video PIC.");
statusCode = getStatusCodeFromException(e);
}
if (statusCode != HTTP_OK) {
// TODO: more URI validation
statusCode = HTTP_BAD_REQUEST;
}
try {
kinesisVideoProducer.tagResourceResult(stream, streamHandle, statusCode);
} catch (final ProducerException e) {
throw new RuntimeException(e);
}
}
};
executor.schedule(task, delay, TimeUnit.NANOSECONDS);
}
Aggregations