public void getStreamingToken()

in src/main/java/com/amazonaws/kinesisvideo/java/service/CachedInfoMultiAuthServiceCallbacksImpl.java [145:199]


    public void getStreamingToken(
            @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 KinesisVideoCredentialsProvider kvsCredentialsProvider = credentialsProviderMap.get(streamName);

        // Stores the serialized credentials as a streaming token
        byte[] serializedCredentials = null;
        long expiration = 0;

        final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        try {
            final KinesisVideoCredentials credentials = kvsCredentialsProvider.getUpdatedCredentials();

            // Serialize the credentials
            expiration = credentials.getExpiration().getTime() * Time.HUNDREDS_OF_NANOS_IN_A_MILLISECOND;

            // Serialize the credentials as streaming token
            final ObjectOutput outputStream = new ObjectOutputStream(byteArrayOutputStream);
            outputStream.writeObject(credentials);
            outputStream.flush();
            serializedCredentials = byteArrayOutputStream.toByteArray();
            outputStream.close();
        } catch (final IOException e) {
            log.exception(e);
        } catch (final KinesisVideoException e) {
            log.exception(e);
        } finally {
            try {
                byteArrayOutputStream.close();
            } catch (final IOException ex) {
                // Do nothing
            }
        }

        final int statusCode = HTTP_OK;

        try {
            kinesisVideoProducer.getStreamingTokenResult(
                    stream,
                    streamHandle,
                    serializedCredentials,
                    expiration,
                    statusCode);
        } catch (final ProducerException e) {
            throw new RuntimeException(e);
        }
    }