Search in sources :

Example 1 with CameraMediaSourceConfiguration

use of com.amazonaws.kinesisvideo.client.mediasource.CameraMediaSourceConfiguration in project amazon-kinesis-video-streams-parser-library by aws.

the class ProducerStreamUtil method getCameraStreamInfo.

private static StreamInfo getCameraStreamInfo(final String streamName, final MediaSourceConfiguration mediaSourceConfiguration) throws KinesisVideoException {
    final CameraMediaSourceConfiguration configuration = (CameraMediaSourceConfiguration) mediaSourceConfiguration;
    // Need to fix-up the content type as the Console playback only accepts video/h264 and will fail
    // if the mime type is video/avc which is the default in Android.
    String contentType = configuration.getEncoderMimeType();
    if (contentType.equals("video/avc")) {
        contentType = "video/h264";
    }
    return new StreamInfo(VERSION_ZERO, streamName, StreamInfo.StreamingType.STREAMING_TYPE_REALTIME, contentType, NO_KMS_KEY_ID, configuration.getRetentionPeriodInHours() * HUNDREDS_OF_NANOS_IN_AN_HOUR, NOT_ADAPTIVE, MAX_LATENCY_ZERO, DEFAULT_GOP_DURATION * HUNDREDS_OF_NANOS_IN_A_MILLISECOND, KEYFRAME_FRAGMENTATION, USE_FRAME_TIMECODES, configuration.getIsAbsoluteTimecode(), REQUEST_FRAGMENT_ACKS, RECOVER_ON_FAILURE, StreamInfo.codecIdFromContentType(configuration.getEncoderMimeType()), StreamInfo.createTrackName(configuration.getEncoderMimeType()), configuration.getBitRate(), configuration.getFrameRate(), DEFAULT_BUFFER_DURATION_IN_SECONDS * HUNDREDS_OF_NANOS_IN_A_SECOND, DEFAULT_REPLAY_DURATION_IN_SECONDS * HUNDREDS_OF_NANOS_IN_A_SECOND, DEFAULT_STALENESS_DURATION_IN_SECONDS * HUNDREDS_OF_NANOS_IN_A_SECOND, configuration.getTimeScale() / NANOS_IN_A_TIME_UNIT, RECALCULATE_METRICS, configuration.getCodecPrivateData(), getTags(), configuration.getNalAdaptationFlags());
}
Also used : CameraMediaSourceConfiguration(com.amazonaws.kinesisvideo.client.mediasource.CameraMediaSourceConfiguration) StreamInfo(com.amazonaws.kinesisvideo.producer.StreamInfo)

Example 2 with CameraMediaSourceConfiguration

use of com.amazonaws.kinesisvideo.client.mediasource.CameraMediaSourceConfiguration in project aws-sdk-android by aws-amplify.

the class CameraUtils method getCameras.

/**
 * Lists only cameras by getting known media sources known to the KinesisVideoClient
 */
public static List<CameraMediaSourceConfiguration> getCameras(final KinesisVideoClient kinesisVideoClient) {
    final List<CameraMediaSourceConfiguration> cameras = new ArrayList<CameraMediaSourceConfiguration>();
    for (final MediaSourceConfiguration.Builder mediaSourceConfiguration : kinesisVideoClient.listSupportedConfigurations()) {
        if (!(mediaSourceConfiguration instanceof CameraMediaSourceConfiguration.Builder)) {
            continue;
        }
        final CameraMediaSourceConfiguration configuration = ((CameraMediaSourceConfiguration.Builder) mediaSourceConfiguration).build();
        cameras.add(configuration);
    }
    return cameras;
}
Also used : CameraMediaSourceConfiguration(com.amazonaws.kinesisvideo.client.mediasource.CameraMediaSourceConfiguration) ArrayList(java.util.ArrayList) MediaSourceConfiguration(com.amazonaws.kinesisvideo.internal.client.mediasource.MediaSourceConfiguration) CameraMediaSourceConfiguration(com.amazonaws.kinesisvideo.client.mediasource.CameraMediaSourceConfiguration)

Example 3 with CameraMediaSourceConfiguration

use of com.amazonaws.kinesisvideo.client.mediasource.CameraMediaSourceConfiguration in project amazon-kinesis-video-streams-parser-library by aws.

the class H264FrameProcessor method initializeKinesisVideoProducer.

private void initializeKinesisVideoProducer(final int width, final int height, final byte[] cpd) {
    try {
        log.info("Initializing KVS Producer with stream name {} and region : {}", outputKvsStreamName, regionName);
        final KinesisVideoClient kinesisVideoClient = KinesisVideoJavaClientFactory.createKinesisVideoClient(regionName, credentialsProvider);
        final CameraMediaSourceConfiguration configuration = new CameraMediaSourceConfiguration.Builder().withFrameRate(30).withRetentionPeriodInHours(1).withCameraId("/dev/video0").withIsEncoderHardwareAccelerated(false).withEncodingMimeType("video/avc").withNalAdaptationFlags(StreamInfo.NalAdaptationFlags.NAL_ADAPTATION_ANNEXB_NALS).withIsAbsoluteTimecode(true).withEncodingBitRate(200000).withHorizontalResolution(width).withVerticalResolution(height).withCodecPrivateData(cpd).build();
        this.KVSMediaSource = new KVSMediaSource(ProducerStreamUtil.toStreamInfo(outputKvsStreamName, configuration));
        this.KVSMediaSource.configure(configuration);
        // register media source with Kinesis Video Client
        kinesisVideoClient.registerMediaSource(KVSMediaSource);
    } catch (final KinesisVideoException e) {
        log.error("Exception while initialize KVS Producer !", e);
    }
}
Also used : CameraMediaSourceConfiguration(com.amazonaws.kinesisvideo.client.mediasource.CameraMediaSourceConfiguration) KinesisVideoClient(com.amazonaws.kinesisvideo.client.KinesisVideoClient) KinesisVideoException(com.amazonaws.kinesisvideo.common.exception.KinesisVideoException)

Aggregations

CameraMediaSourceConfiguration (com.amazonaws.kinesisvideo.client.mediasource.CameraMediaSourceConfiguration)3 KinesisVideoClient (com.amazonaws.kinesisvideo.client.KinesisVideoClient)1 KinesisVideoException (com.amazonaws.kinesisvideo.common.exception.KinesisVideoException)1 MediaSourceConfiguration (com.amazonaws.kinesisvideo.internal.client.mediasource.MediaSourceConfiguration)1 StreamInfo (com.amazonaws.kinesisvideo.producer.StreamInfo)1 ArrayList (java.util.ArrayList)1