Search in sources :

Example 1 with StreamDescription

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());
}
Also used : DeleteStreamRequest(com.amazonaws.services.kinesisvideo.model.DeleteStreamRequest) DeleteStreamResult(com.amazonaws.services.kinesisvideo.model.DeleteStreamResult) AWSKinesisVideoClient(com.amazonaws.services.kinesisvideo.AWSKinesisVideoClient) StreamDescription(com.amazonaws.kinesisvideo.producer.StreamDescription) AmazonClientException(com.amazonaws.AmazonClientException) KinesisVideoException(com.amazonaws.kinesisvideo.common.exception.KinesisVideoException)

Example 2 with StreamDescription

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);
}
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)

Aggregations

KinesisVideoException (com.amazonaws.kinesisvideo.common.exception.KinesisVideoException)2 StreamDescription (com.amazonaws.kinesisvideo.producer.StreamDescription)2 AmazonClientException (com.amazonaws.AmazonClientException)1 KinesisVideoCredentialsProvider (com.amazonaws.kinesisvideo.auth.KinesisVideoCredentialsProvider)1 ProducerException (com.amazonaws.kinesisvideo.producer.ProducerException)1 AWSKinesisVideoClient (com.amazonaws.services.kinesisvideo.AWSKinesisVideoClient)1 DeleteStreamRequest (com.amazonaws.services.kinesisvideo.model.DeleteStreamRequest)1 DeleteStreamResult (com.amazonaws.services.kinesisvideo.model.DeleteStreamResult)1