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