Search in sources :

Example 6 with KinesisVideoCredentialsProvider

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);
}
Also used : StreamDescription(com.amazonaws.kinesisvideo.producer.StreamDescription) ProducerException(com.amazonaws.kinesisvideo.producer.ProducerException) KinesisVideoCredentialsProvider(com.amazonaws.kinesisvideo.auth.KinesisVideoCredentialsProvider) KinesisVideoException(com.amazonaws.kinesisvideo.common.exception.KinesisVideoException)

Example 7 with KinesisVideoCredentialsProvider

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);
}
Also used : ProducerException(com.amazonaws.kinesisvideo.producer.ProducerException) Tag(com.amazonaws.kinesisvideo.producer.Tag) KinesisVideoCredentialsProvider(com.amazonaws.kinesisvideo.auth.KinesisVideoCredentialsProvider) KinesisVideoException(com.amazonaws.kinesisvideo.common.exception.KinesisVideoException)

Aggregations

KinesisVideoCredentialsProvider (com.amazonaws.kinesisvideo.auth.KinesisVideoCredentialsProvider)7 KinesisVideoException (com.amazonaws.kinesisvideo.common.exception.KinesisVideoException)6 ProducerException (com.amazonaws.kinesisvideo.producer.ProducerException)6 KinesisVideoCredentials (com.amazonaws.kinesisvideo.auth.KinesisVideoCredentials)1 KinesisVideoClientConfiguration (com.amazonaws.kinesisvideo.client.KinesisVideoClientConfiguration)1 Log (com.amazonaws.kinesisvideo.common.logging.Log)1 OutputChannel (com.amazonaws.kinesisvideo.common.logging.OutputChannel)1 StreamDescription (com.amazonaws.kinesisvideo.producer.StreamDescription)1 Tag (com.amazonaws.kinesisvideo.producer.Tag)1 DefaultStorageCallbacks (com.amazonaws.kinesisvideo.storage.DefaultStorageCallbacks)1 KinesisVideoCredentialsProviderImpl (com.amazonaws.mobileconnectors.kinesisvideo.auth.KinesisVideoCredentialsProviderImpl)1 AndroidLogOutputChannel (com.amazonaws.mobileconnectors.kinesisvideo.util.AndroidLogOutputChannel)1 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)1