Class DefaultServiceCallbacksImpl
- java.lang.Object
-
- com.amazonaws.kinesisvideo.internal.service.DefaultServiceCallbacksImpl
-
- All Implemented Interfaces:
ServiceCallbacks
- Direct Known Subclasses:
CachedInfoMultiAuthServiceCallbacksImpl,MultiAuthServiceCallbacksImpl
public class DefaultServiceCallbacksImpl extends Object implements ServiceCallbacks
Implementation ofServiceCallbacks
-
-
Field Summary
Fields Modifier and Type Field Description protected KinesisVideoClientConfigurationconfigurationStore the configurationprotected ScheduledExecutorServiceexecutorTask executor to schedule long-running tasks in an async way.protected KinesisVideoProducerkinesisVideoProducerImplementation of theKinesisVideoProducerobject.protected KinesisVideoServiceClientkinesisVideoServiceClientKinesis video service client to make the service calls with.protected org.apache.logging.log4j.LoggerlogLogger to use
-
Constructor Summary
Constructors Constructor Description DefaultServiceCallbacksImpl(org.apache.logging.log4j.Logger log, ScheduledExecutorService executor, KinesisVideoClientConfiguration configuration, KinesisVideoServiceClient kinesisVideoServiceClient)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddStream(KinesisVideoProducerStream kinesisVideoProducerStream)Add a producer stream to ongoing stream listvoidcreateDevice(String deviceName, long callAfter, long timeout, byte[] authData, int authType, long customData)Asynchronous call to create devicevoidcreateStream(String deviceName, String streamName, String contentType, String kmsKeyId, long retentionPeriod, long callAfter, long timeout, byte[] authData, int authType, KinesisVideoProducerStream stream)Asynchronous call to create stream with the specified parameters.voiddescribeStream(String streamName, long callAfter, long timeout, byte[] authData, int authType, long streamHandle, KinesisVideoProducerStream stream)Asynchronous call to describe stream with the specified parameters.voiddeviceCertToToken(String deviceName, long callAfter, long timeout, byte[] authData, int authType, long customData)Asynchronous call to device certificate to token API.voidfree()Frees the callbacks object.protected static KinesisVideoCredentialsProvidergetCredentialsProvider(byte[] authData, org.apache.logging.log4j.Logger log)protected static intgetStatusCodeFromException(Throwable e)Returns the status code of an exception.voidgetStreamingEndpoint(String streamName, String apiName, long callAfter, long timeout, byte[] authData, int authType, long streamHandle, KinesisVideoProducerStream stream)Asynchronous call to get streaming endpoint with the specified parameters.voidgetStreamingToken(String streamName, long callAfter, long timeout, byte[] authData, int authType, long streamHandle, KinesisVideoProducerStream stream)Asynchronous call to get streaming tokenvoidinitialize(KinesisVideoProducer kinesisVideoProducer)Initializes the objectbooleanisInitialized()Returns whether the object is initializedprotected voidnotifyCallResult(KinesisVideoProducerStream stream, String methodName, ProducerException ex)Post the exception onto theStreamCallbacks.streamErrorReport(long, long, long)callback so the application can decide what to do with the error.voidputStream(String streamName, String containerType, long streamStartTime, boolean absoluteFragmentTimes, boolean ackRequired, String dataEndpoint, long callAfter, long timeout, byte[] authData, int authType, KinesisVideoProducerStream kinesisVideoProducerStream)Asynchronous call to put stream APIvoidremoveStream(KinesisVideoProducerStream kinesisVideoProducerStream)Removes a producer stream to ongoing stream listvoidtagResource(String resourceArn, Tag[] tags, long callAfter, long timeout, byte[] authData, int authType, long streamHandle, KinesisVideoProducerStream stream)Asynchronous call to tag resource API
-
-
-
Field Detail
-
executor
protected final ScheduledExecutorService executor
Task executor to schedule long-running tasks in an async way.
-
kinesisVideoServiceClient
protected final KinesisVideoServiceClient kinesisVideoServiceClient
Kinesis video service client to make the service calls with.
-
log
protected final org.apache.logging.log4j.Logger log
Logger to use
-
configuration
protected final KinesisVideoClientConfiguration configuration
Store the configuration
-
kinesisVideoProducer
protected KinesisVideoProducer kinesisVideoProducer
Implementation of theKinesisVideoProducerobject.
-
-
Constructor Detail
-
DefaultServiceCallbacksImpl
public DefaultServiceCallbacksImpl(@Nonnull org.apache.logging.log4j.Logger log, @Nonnull ScheduledExecutorService executor, @Nonnull KinesisVideoClientConfiguration configuration, @Nonnull KinesisVideoServiceClient kinesisVideoServiceClient)
-
-
Method Detail
-
initialize
public void initialize(@Nonnull KinesisVideoProducer kinesisVideoProducer)
Initializes the object- Specified by:
initializein interfaceServiceCallbacks- Parameters:
kinesisVideoProducer- Reference toKinesisVideoProducerfor the eventing.
-
isInitialized
public boolean isInitialized()
Description copied from interface:ServiceCallbacksReturns whether the object is initialized- Specified by:
isInitializedin interfaceServiceCallbacks- Returns:
- whether the object is initialized
-
createStream
public void createStream(@Nonnull String deviceName, @Nonnull String streamName, @Nonnull String contentType, @Nullable String kmsKeyId, long retentionPeriod, long callAfter, long timeout, @Nullable byte[] authData, int authType, KinesisVideoProducerStream stream) throws ProducerException
Description copied from interface:ServiceCallbacksAsynchronous call to create stream with the specified parameters. PIC will attempt to schedule stream creation if theServiceCallbacks.describeStream(String, long, long, byte[], int, long, KinesisVideoProducerStream)posts aKinesisVideoProducer.describeStreamResult(KinesisVideoProducerStream, long, StreamDescription, int)of 404 (Resource Not Found). This call will be skipped ifStreamInfo.isAllowStreamCreation()is not allowed.This method will notify PIC the success or failure of the operation via
KinesisVideoProducer.createStreamResult(KinesisVideoProducerStream, String, int).- Specified by:
createStreamin interfaceServiceCallbacks- Parameters:
deviceName- - Device namestreamName- - Stream namecontentType- - Stream content typekmsKeyId- - KMS Key IdretentionPeriod- - Stream retention period - 100nscallAfter- - Call after this time - 100nstimeout- - Time out for the call - 100nsauthData- - Authentication bitsauthType- - Authentication type - this is the AUTH_INFO_TYPE defined in /src/client/Include.hstream- - stream object for the result event callback- Throws:
ProducerException- See Also:
- CreateStream API
-
describeStream
public void describeStream(@Nonnull String streamName, long callAfter, long timeout, @Nullable byte[] authData, int authType, long streamHandle, KinesisVideoProducerStream stream) throws ProducerException
Description copied from interface:ServiceCallbacksAsynchronous call to describe stream with the specified parameters.This method will notify PIC the success or failure of the operation via
KinesisVideoProducer.describeStreamResult(KinesisVideoProducerStream, long, StreamDescription, int)- Specified by:
describeStreamin interfaceServiceCallbacks- Parameters:
streamName- - Stream namecallAfter- - Call after this time - 100nstimeout- - Time out for the call - 100nsauthData- - Authentication bitsauthType- - Authentication type - this is the AUTH_INFO_TYPE defined in /src/client/Include.hstreamHandle- - stream handle returned by PICstream- - stream object for the result event callback- Throws:
ProducerException- See Also:
- DescribeStream API
-
getStreamingEndpoint
public void getStreamingEndpoint(@Nonnull String streamName, @Nonnull String apiName, long callAfter, long timeout, @Nullable byte[] authData, int authType, long streamHandle, KinesisVideoProducerStream stream) throws ProducerException
Description copied from interface:ServiceCallbacksAsynchronous call to get streaming endpoint with the specified parameters.This method will notify PIC the success or failure of the operation via
KinesisVideoProducer.getStreamingEndpointResult(KinesisVideoProducerStream, long, String, int).- Specified by:
getStreamingEndpointin interfaceServiceCallbacks- Parameters:
streamName- - Stream nameapiName- - API name to callcallAfter- - Call after this time - 100nstimeout- - Time out for the call - 100nsauthData- - Authentication bitsauthType- - Authentication type - this is the AUTH_INFO_TYPE defined in /src/client/Include.hstreamHandle- - stream handle returned by PICstream- - stream object for the result event callback- Throws:
ProducerException- See Also:
- GetDataEndpoint API
-
getStreamingToken
public void getStreamingToken(@Nonnull String streamName, long callAfter, long timeout, @Nullable byte[] authData, int authType, long streamHandle, KinesisVideoProducerStream stream) throws ProducerException
Description copied from interface:ServiceCallbacksAsynchronous call to get streaming token- Specified by:
getStreamingTokenin interfaceServiceCallbacks- Parameters:
streamName- - Stream namecallAfter- - Call after this time - 100nstimeout- - Time out for the call - 100nsauthData- - Authentication bitsauthType- - Authentication type - this is the AUTH_INFO_TYPE defined in /src/client/Include.hstreamHandle- - stream handle returned by PICstream- - stream object for the result event callback- Throws:
ProducerException
-
putStream
public void putStream(@Nonnull String streamName, @Nonnull String containerType, long streamStartTime, boolean absoluteFragmentTimes, boolean ackRequired, @Nonnull String dataEndpoint, long callAfter, long timeout, @Nullable byte[] authData, int authType, KinesisVideoProducerStream kinesisVideoProducerStream) throws ProducerException
Description copied from interface:ServiceCallbacksAsynchronous call to put stream API- Specified by:
putStreamin interfaceServiceCallbacks- Parameters:
streamName- - Stream namecontainerType- - Container typestreamStartTime- - Stream start timestampabsoluteFragmentTimes- - Whether to use absolute fragment timesackRequired- - Whether an application level ACK is requireddataEndpoint- - The streaming endpoint to usecallAfter- - Call after this time - 100nstimeout- - Time out for the call - 100nsauthData- - Authentication bitsauthType- - Authentication type - this is the AUTH_INFO_TYPE defined in /src/client/Include.hkinesisVideoProducerStream- - stream object for the result event callback- Throws:
ProducerException
-
tagResource
public void tagResource(@Nonnull String resourceArn, @Nullable Tag[] tags, long callAfter, long timeout, @Nullable byte[] authData, int authType, long streamHandle, KinesisVideoProducerStream stream) throws ProducerException
Description copied from interface:ServiceCallbacksAsynchronous call to tag resource API- Specified by:
tagResourcein interfaceServiceCallbacks- Parameters:
resourceArn- - Resource ARNtags- - Tags to applycallAfter- - Call after this time - 100nstimeout- - Time out for the call - 100nsauthData- - Authentication bitsauthType- - Authentication type - this is the AUTH_INFO_TYPE defined in /src/client/Include.hstreamHandle- - stream handle returned by PICstream- - stream object for the result event callback- Throws:
ProducerException
-
createDevice
public void createDevice(@Nonnull String deviceName, long callAfter, long timeout, @Nullable byte[] authData, int authType, long customData) throws ProducerException
Description copied from interface:ServiceCallbacksAsynchronous call to create device- Specified by:
createDevicein interfaceServiceCallbacks- Parameters:
deviceName- - Device namecallAfter- - Call after this time - 100nstimeout- - Time out for the call - 100nsauthData- - Authentication bitsauthType- - Authentication type - this is the AUTH_INFO_TYPE defined in /src/client/Include.hcustomData- - Custom data to use to call the event functions- Throws:
ProducerException
-
deviceCertToToken
public void deviceCertToToken(@Nonnull String deviceName, long callAfter, long timeout, @Nullable byte[] authData, int authType, long customData) throws ProducerException
Description copied from interface:ServiceCallbacksAsynchronous call to device certificate to token API. Called when AuthType is AUTH_INFO_TYPE_CERT.- Specified by:
deviceCertToTokenin interfaceServiceCallbacks- Parameters:
deviceName- - Device namecallAfter- - Call after this time - 100nstimeout- - Time out for the call - 100nsauthData- - Authentication bitsauthType- - Authentication type - this is the AUTH_INFO_TYPE defined in /src/client/Include.hcustomData- - Custom data to use to call the event functions- Throws:
ProducerException
-
free
public void free()
Description copied from interface:ServiceCallbacksFrees the callbacks object.- Specified by:
freein interfaceServiceCallbacks
-
addStream
public void addStream(@Nonnull KinesisVideoProducerStream kinesisVideoProducerStream)
Description copied from interface:ServiceCallbacksAdd a producer stream to ongoing stream list- Specified by:
addStreamin interfaceServiceCallbacks- Parameters:
kinesisVideoProducerStream- producer stream used by PIC
-
removeStream
public void removeStream(@Nonnull KinesisVideoProducerStream kinesisVideoProducerStream)
Description copied from interface:ServiceCallbacksRemoves a producer stream to ongoing stream list- Specified by:
removeStreamin interfaceServiceCallbacks- Parameters:
kinesisVideoProducerStream- producer stream used by PIC
-
getCredentialsProvider
@Nullable protected static KinesisVideoCredentialsProvider getCredentialsProvider(@Nullable byte[] authData, @Nonnull org.apache.logging.log4j.Logger log)
-
getStatusCodeFromException
protected static int getStatusCodeFromException(@Nullable Throwable e)
Returns the status code of an exception.- Parameters:
e-Throwablewhich was thrown by the service client- Returns:
- status code corresponding to the exception
-
notifyCallResult
protected void notifyCallResult(@Nonnull KinesisVideoProducerStream stream, @Nonnull String methodName, @Nonnull ProducerException ex)
Post the exception onto theStreamCallbacks.streamErrorReport(long, long, long)callback so the application can decide what to do with the error. Theupload handlewill beReadResult.INVALID_UPLOAD_HANDLE_VALUE, and thefragment timecodewill beReadResult.ZERO_FRAGMENT_TIMECODE.- Parameters:
stream- stream that encountered the errormethodName- for logging purposesex- the exception that occurred- See Also:
- Producer-C notifyCallResult
-
-