use of com.amazonaws.kinesisvideo.common.exception.KinesisVideoException in project aws-sdk-android by aws-amplify.
the class KinesisVideoCredentialsProviderImpl method updateCredentials.
@Override
protected KinesisVideoCredentials updateCredentials() throws KinesisVideoException {
// Refresh the token first
log.debug("Refreshing credentials");
credentialsProvider.refresh();
// Get the AWS credentials and create Kinesis Video Credentials
final AWSCredentials awsCredentials = credentialsProvider.getCredentials();
String sessionToken = null;
if (awsCredentials instanceof AWSSessionCredentials) {
final AWSSessionCredentials sessionCredentials = (AWSSessionCredentials) awsCredentials;
sessionToken = sessionCredentials.getSessionToken();
}
Date expiration = KinesisVideoCredentials.CREDENTIALS_NEVER_EXPIRE;
if (credentialsProvider instanceof CognitoCredentialsProvider) {
final CognitoCredentialsProvider cognitoCredentialsProvider = (CognitoCredentialsProvider) credentialsProvider;
expiration = cognitoCredentialsProvider.getSessionCredentialsExpiration();
log.debug("Refreshed token expiration is %s", expiration);
} else if (credentialsProvider instanceof AWSMobileClient) {
AWSMobileClient awsMobileClient = (AWSMobileClient) credentialsProvider;
try {
expiration = awsMobileClient.getTokens().getAccessToken().getExpiration();
log.debug("Refreshed token expiration is %s", expiration);
} catch (Exception e) {
throw new KinesisVideoException("Failed to refresh! " + e.getMessage());
}
}
log.debug("Returning %scredentials with expiration %s", sessionToken == null ? "" : "session ", expiration);
return new KinesisVideoCredentials(awsCredentials.getAWSAccessKeyId(), awsCredentials.getAWSSecretKey(), sessionToken, expiration);
}
use of com.amazonaws.kinesisvideo.common.exception.KinesisVideoException in project aws-sdk-android by aws-amplify.
the class CameraAdapter method adaptCameraStateCallback.
private CameraDevice.StateCallback adaptCameraStateCallback(final OpenCameraCallback cameraOpenCameraCallback) {
return new CameraDevice.StateCallback() {
@Override
public void onOpened(final CameraDevice cameraDevice) {
Log.i(TAG, "opened" + threadId());
mCameraDevice = cameraDevice;
mCameraOpenCloseLock.release();
cameraOpenCameraCallback.onOpened();
}
@Override
public void onDisconnected(final CameraDevice cameraDevice) {
Log.i(TAG, "disconnected" + threadId());
mCameraOpenCloseLock.release();
cameraDevice.close();
mCameraDevice = null;
}
@Override
public void onError(final CameraDevice cameraDevice, final int error) {
Log.i(TAG, "error" + threadId());
mCameraOpenCloseLock.release();
cameraDevice.close();
mCameraDevice = null;
cameraOpenCameraCallback.onError(new KinesisVideoException("blah"));
}
};
}
use of com.amazonaws.kinesisvideo.common.exception.KinesisVideoException 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.common.exception.KinesisVideoException 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.kinesisvideo.common.exception.KinesisVideoException in project aws-sdk-android by aws-amplify.
the class KinesisVideoAndroidServiceClient method describeStream.
@Override
public StreamDescription describeStream(@NonNull final String streamName, long timeoutInMillis, @Nullable final KinesisVideoCredentialsProvider credentialsProvider) throws KinesisVideoException {
final AWSKinesisVideoClient serviceClient = createAwsKinesisVideoClient(credentialsProvider, Region.getRegion(Regions.fromName(configuration.getRegion())), configuration.getEndpoint(), (int) timeoutInMillis);
final DescribeStreamRequest describeStreamRequest = new DescribeStreamRequest().withStreamName(streamName);
log.debug("calling describe stream: " + describeStreamRequest.toString());
final DescribeStreamResult describeStreamResult;
try {
describeStreamResult = serviceClient.describeStream(describeStreamRequest);
} catch (final AmazonClientException e) {
log.exception(e, "Service call failed.");
throw new KinesisVideoException(e);
}
if (null == describeStreamResult) {
log.debug("describe stream returned null");
return null;
}
log.debug("describe stream result: " + describeStreamResult.toString());
return toStreamDescription(describeStreamResult);
}
Aggregations