getMedia method

Future<GetMediaOutput> getMedia({
  1. required StartSelector startSelector,
  2. String? streamARN,
  3. String? streamName,
})

Use this API to retrieve media content from a Kinesis video stream. In the request, you identify the stream name or stream Amazon Resource Name (ARN), and the starting chunk. Kinesis Video Streams then returns a stream of chunks in order by fragment number. When you put media data (fragments) on a stream, Kinesis Video Streams stores each incoming fragment and related metadata in what is called a "chunk." For more information, see PutMedia. The GetMedia API returns a stream of these chunks starting from the chunk that you specify in the request.

The following limits apply when using the GetMedia API:

  • A client can call GetMedia up to five times per second per stream.
  • Kinesis Video Streams sends media data at a rate of up to 25 megabytes per second (or 200 megabits per second) during a GetMedia session.

Implementation

Future<GetMediaOutput> getMedia({
  required StartSelector startSelector,
  String? streamARN,
  String? streamName,
}) async {
  ArgumentError.checkNotNull(startSelector, 'startSelector');
  _s.validateStringLength(
    'streamARN',
    streamARN,
    1,
    1024,
  );
  _s.validateStringLength(
    'streamName',
    streamName,
    1,
    256,
  );
  final $payload = <String, dynamic>{
    'StartSelector': startSelector,
    if (streamARN != null) 'StreamARN': streamARN,
    if (streamName != null) 'StreamName': streamName,
  };
  final response = await _protocol.sendRaw(
    payload: $payload,
    method: 'POST',
    requestUri: '/getMedia',
    exceptionFnMap: _exceptionFns,
  );
  return GetMediaOutput(
    payload: await response.stream.toBytes(),
    contentType:
        _s.extractHeaderStringValue(response.headers, 'Content-Type'),
  );
}