Skip to content

Commit a775394

Browse files
author
awstools
committed
feat(client-kinesis-video-archived-media): Add support for GetImages API for retrieving images from a video stream
1 parent d3b2e8c commit a775394

File tree

7 files changed

+745
-19
lines changed

7 files changed

+745
-19
lines changed

clients/client-kinesis-video-archived-media/src/KinesisVideoArchivedMedia.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
GetHLSStreamingSessionURLCommandInput,
1212
GetHLSStreamingSessionURLCommandOutput,
1313
} from "./commands/GetHLSStreamingSessionURLCommand";
14+
import { GetImagesCommand, GetImagesCommandInput, GetImagesCommandOutput } from "./commands/GetImagesCommand";
1415
import {
1516
GetMediaForFragmentListCommand,
1617
GetMediaForFragmentListCommandInput,
@@ -482,6 +483,32 @@ export class KinesisVideoArchivedMedia extends KinesisVideoArchivedMediaClient {
482483
}
483484
}
484485

486+
/**
487+
* <p>Retrieves a list of Images corresponding to each timestamp for a given time range, sampling interval, and image format configuration.</p>
488+
*/
489+
public getImages(args: GetImagesCommandInput, options?: __HttpHandlerOptions): Promise<GetImagesCommandOutput>;
490+
public getImages(args: GetImagesCommandInput, cb: (err: any, data?: GetImagesCommandOutput) => void): void;
491+
public getImages(
492+
args: GetImagesCommandInput,
493+
options: __HttpHandlerOptions,
494+
cb: (err: any, data?: GetImagesCommandOutput) => void
495+
): void;
496+
public getImages(
497+
args: GetImagesCommandInput,
498+
optionsOrCb?: __HttpHandlerOptions | ((err: any, data?: GetImagesCommandOutput) => void),
499+
cb?: (err: any, data?: GetImagesCommandOutput) => void
500+
): Promise<GetImagesCommandOutput> | void {
501+
const command = new GetImagesCommand(args);
502+
if (typeof optionsOrCb === "function") {
503+
this.send(command, optionsOrCb);
504+
} else if (typeof cb === "function") {
505+
if (typeof optionsOrCb !== "object") throw new Error(`Expect http options but get ${typeof optionsOrCb}`);
506+
this.send(command, optionsOrCb || {}, cb);
507+
} else {
508+
return this.send(command, optionsOrCb);
509+
}
510+
}
511+
485512
/**
486513
* <p>Gets media for a list of fragments (specified by fragment number) from the archived
487514
* data in an Amazon Kinesis video stream.</p>

clients/client-kinesis-video-archived-media/src/KinesisVideoArchivedMediaClient.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ import {
6060
GetHLSStreamingSessionURLCommandInput,
6161
GetHLSStreamingSessionURLCommandOutput,
6262
} from "./commands/GetHLSStreamingSessionURLCommand";
63+
import { GetImagesCommandInput, GetImagesCommandOutput } from "./commands/GetImagesCommand";
6364
import {
6465
GetMediaForFragmentListCommandInput,
6566
GetMediaForFragmentListCommandOutput,
@@ -71,13 +72,15 @@ export type ServiceInputTypes =
7172
| GetClipCommandInput
7273
| GetDASHStreamingSessionURLCommandInput
7374
| GetHLSStreamingSessionURLCommandInput
75+
| GetImagesCommandInput
7476
| GetMediaForFragmentListCommandInput
7577
| ListFragmentsCommandInput;
7678

7779
export type ServiceOutputTypes =
7880
| GetClipCommandOutput
7981
| GetDASHStreamingSessionURLCommandOutput
8082
| GetHLSStreamingSessionURLCommandOutput
83+
| GetImagesCommandOutput
8184
| GetMediaForFragmentListCommandOutput
8285
| ListFragmentsCommandOutput;
8386

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
import { getSerdePlugin } from "@aws-sdk/middleware-serde";
2+
import { HttpRequest as __HttpRequest, HttpResponse as __HttpResponse } from "@aws-sdk/protocol-http";
3+
import { Command as $Command } from "@aws-sdk/smithy-client";
4+
import {
5+
FinalizeHandlerArguments,
6+
Handler,
7+
HandlerExecutionContext,
8+
HttpHandlerOptions as __HttpHandlerOptions,
9+
MetadataBearer as __MetadataBearer,
10+
MiddlewareStack,
11+
SerdeContext as __SerdeContext,
12+
} from "@aws-sdk/types";
13+
14+
import {
15+
KinesisVideoArchivedMediaClientResolvedConfig,
16+
ServiceInputTypes,
17+
ServiceOutputTypes,
18+
} from "../KinesisVideoArchivedMediaClient";
19+
import { GetImagesInput, GetImagesOutput } from "../models/models_0";
20+
import {
21+
deserializeAws_restJson1GetImagesCommand,
22+
serializeAws_restJson1GetImagesCommand,
23+
} from "../protocols/Aws_restJson1";
24+
25+
export interface GetImagesCommandInput extends GetImagesInput {}
26+
export interface GetImagesCommandOutput extends GetImagesOutput, __MetadataBearer {}
27+
28+
/**
29+
* <p>Retrieves a list of Images corresponding to each timestamp for a given time range, sampling interval, and image format configuration.</p>
30+
* @example
31+
* Use a bare-bones client and the command you need to make an API call.
32+
* ```javascript
33+
* import { KinesisVideoArchivedMediaClient, GetImagesCommand } from "@aws-sdk/client-kinesis-video-archived-media"; // ES Modules import
34+
* // const { KinesisVideoArchivedMediaClient, GetImagesCommand } = require("@aws-sdk/client-kinesis-video-archived-media"); // CommonJS import
35+
* const client = new KinesisVideoArchivedMediaClient(config);
36+
* const command = new GetImagesCommand(input);
37+
* const response = await client.send(command);
38+
* ```
39+
*
40+
* @see {@link GetImagesCommandInput} for command's `input` shape.
41+
* @see {@link GetImagesCommandOutput} for command's `response` shape.
42+
* @see {@link KinesisVideoArchivedMediaClientResolvedConfig | config} for KinesisVideoArchivedMediaClient's `config` shape.
43+
*
44+
*/
45+
export class GetImagesCommand extends $Command<
46+
GetImagesCommandInput,
47+
GetImagesCommandOutput,
48+
KinesisVideoArchivedMediaClientResolvedConfig
49+
> {
50+
// Start section: command_properties
51+
// End section: command_properties
52+
53+
constructor(readonly input: GetImagesCommandInput) {
54+
// Start section: command_constructor
55+
super();
56+
// End section: command_constructor
57+
}
58+
59+
/**
60+
* @internal
61+
*/
62+
resolveMiddleware(
63+
clientStack: MiddlewareStack<ServiceInputTypes, ServiceOutputTypes>,
64+
configuration: KinesisVideoArchivedMediaClientResolvedConfig,
65+
options?: __HttpHandlerOptions
66+
): Handler<GetImagesCommandInput, GetImagesCommandOutput> {
67+
this.middlewareStack.use(getSerdePlugin(configuration, this.serialize, this.deserialize));
68+
69+
const stack = clientStack.concat(this.middlewareStack);
70+
71+
const { logger } = configuration;
72+
const clientName = "KinesisVideoArchivedMediaClient";
73+
const commandName = "GetImagesCommand";
74+
const handlerExecutionContext: HandlerExecutionContext = {
75+
logger,
76+
clientName,
77+
commandName,
78+
inputFilterSensitiveLog: GetImagesInput.filterSensitiveLog,
79+
outputFilterSensitiveLog: GetImagesOutput.filterSensitiveLog,
80+
};
81+
const { requestHandler } = configuration;
82+
return stack.resolve(
83+
(request: FinalizeHandlerArguments<any>) =>
84+
requestHandler.handle(request.request as __HttpRequest, options || {}),
85+
handlerExecutionContext
86+
);
87+
}
88+
89+
private serialize(input: GetImagesCommandInput, context: __SerdeContext): Promise<__HttpRequest> {
90+
return serializeAws_restJson1GetImagesCommand(input, context);
91+
}
92+
93+
private deserialize(output: __HttpResponse, context: __SerdeContext): Promise<GetImagesCommandOutput> {
94+
return deserializeAws_restJson1GetImagesCommand(output, context);
95+
}
96+
97+
// Start section: command_body_extra
98+
// End section: command_body_extra
99+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export * from "./GetClipCommand";
22
export * from "./GetDASHStreamingSessionURLCommand";
33
export * from "./GetHLSStreamingSessionURLCommand";
4+
export * from "./GetImagesCommand";
45
export * from "./GetMediaForFragmentListCommand";
56
export * from "./ListFragmentsCommand";

clients/client-kinesis-video-archived-media/src/models/models_0.ts

Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -970,6 +970,172 @@ export namespace GetHLSStreamingSessionURLOutput {
970970
});
971971
}
972972

973+
export enum Format {
974+
JPEG = "JPEG",
975+
PNG = "PNG",
976+
}
977+
978+
export enum FormatConfigKey {
979+
JPEGQuality = "JPEGQuality",
980+
}
981+
982+
export enum ImageSelectorType {
983+
PRODUCER_TIMESTAMP = "PRODUCER_TIMESTAMP",
984+
SERVER_TIMESTAMP = "SERVER_TIMESTAMP",
985+
}
986+
987+
export interface GetImagesInput {
988+
/**
989+
* <p>The name of the stream from which to retrieve the images. You must specify either the <code>StreamName</code> or the <code>StreamARN</code>.</p>
990+
*/
991+
StreamName?: string;
992+
993+
/**
994+
* <p>The Amazon Resource Name (ARN) of the stream from which to retrieve the images. You must specify either the <code>StreamName</code> or the <code>StreamARN</code>.</p>
995+
*/
996+
StreamARN?: string;
997+
998+
/**
999+
* <p>The origin of the Server or Producer timestamps to use to generate the images.</p>
1000+
*/
1001+
ImageSelectorType: ImageSelectorType | string | undefined;
1002+
1003+
/**
1004+
* <p>The starting point from which the images should be generated. This <code>StartTimestamp</code> must be within an inclusive range of timestamps for an image to be returned.</p>
1005+
*/
1006+
StartTimestamp: Date | undefined;
1007+
1008+
/**
1009+
* <p>The end timestamp for the range of images to be generated.</p>
1010+
*/
1011+
EndTimestamp: Date | undefined;
1012+
1013+
/**
1014+
* <p>The time interval in milliseconds (ms) at which the images need to be generated from the stream. The minimum value that can be provided is 3000 ms. If the timestamp range is less than the sampling interval, the Image from the <code>startTimestamp</code> will be returned if available.
1015+
* </p>
1016+
* <note>
1017+
* <p>The minimum value of 3000 ms is a soft limit. If needed, a lower sampling frequency can be requested.</p>
1018+
* </note>
1019+
*/
1020+
SamplingInterval: number | undefined;
1021+
1022+
/**
1023+
* <p>The format that will be used to encode the image.</p>
1024+
*/
1025+
Format: Format | string | undefined;
1026+
1027+
/**
1028+
* <p>The list of a key-value pair structure that contains extra parameters that can be applied when the image is generated. The <code>FormatConfig</code> key is the <code>JPEGQuality</code>, which indicates the JPEG quality key to be used to generate the image.
1029+
* The <code>FormatConfig</code> value accepts ints from 1 to 100. If the value is 1, the image will be generated with less quality and the best compression.
1030+
* If the value is 100, the image will be generated with the best quality and less compression. If no value is provided, the default value of the <code>JPEGQuality</code> key will be set to 80.</p>
1031+
*/
1032+
FormatConfig?: { [key: string]: string };
1033+
1034+
/**
1035+
* <p>The width of the output image that is used in conjunction with the <code>HeightPixels</code> parameter. When both <code>WidthPixels</code> and <code>HeightPixels</code> parameters are provided,
1036+
* the image will be stretched to fit the specified aspect ratio. If only the <code>WidthPixels</code> parameter is provided or if only the <code>HeightPixels</code> is provided, a <code>ValidationException</code> will be thrown.
1037+
* If neither parameter is provided, the original image size from the stream will be returned.</p>
1038+
*/
1039+
WidthPixels?: number;
1040+
1041+
/**
1042+
* <p>The height of the output image that is used in conjunction with the <code>WidthPixels</code> parameter. When both <code>HeightPixels</code> and <code>WidthPixels</code> parameters are provided, the image will be stretched to fit the
1043+
* specified aspect ratio. If only the <code>HeightPixels</code> parameter is provided, its original aspect ratio will be used to calculate the <code>WidthPixels</code> ratio. If neither parameter is provided,
1044+
* the original image size will be returned.</p>
1045+
*/
1046+
HeightPixels?: number;
1047+
1048+
/**
1049+
* <p>The maximum number of images to be returned by the API. </p>
1050+
* <note>
1051+
* <p>The default limit is 100 images per API response. The additional results will be paginated. </p>
1052+
* </note>
1053+
*/
1054+
MaxResults?: number;
1055+
1056+
/**
1057+
* <p>A token that specifies where to start paginating the next set of Images. This is the <code>GetImages:NextToken</code> from a previously truncated response.</p>
1058+
*/
1059+
NextToken?: string;
1060+
}
1061+
1062+
export namespace GetImagesInput {
1063+
/**
1064+
* @internal
1065+
*/
1066+
export const filterSensitiveLog = (obj: GetImagesInput): any => ({
1067+
...obj,
1068+
});
1069+
}
1070+
1071+
export enum ImageError {
1072+
MEDIA_ERROR = "MEDIA_ERROR",
1073+
NO_MEDIA = "NO_MEDIA",
1074+
}
1075+
1076+
/**
1077+
* <p>A structure that contains the <code>Timestamp</code>, <code>Error</code>, and <code>ImageContent</code>.</p>
1078+
*/
1079+
export interface Image {
1080+
/**
1081+
* <p>An attribute of the <code>Image</code> object that is used to extract an image from the video stream. This field is used to manage gaps on images or to better understand the pagination
1082+
* window.</p>
1083+
*/
1084+
TimeStamp?: Date;
1085+
1086+
/**
1087+
* <p>The error message shown when the image for the provided timestamp was not extracted due to a non-tryable error. An error will be returned if: </p>
1088+
* <ul>
1089+
* <li>
1090+
* <p>There is no media that exists for the specified <code>Timestamp</code>.</p>
1091+
* </li>
1092+
* </ul>
1093+
* <ul>
1094+
* <li>
1095+
* <p>The media for the specified time does not allow an image to be extracted. In this case the media is audio only, or the incorrect
1096+
* media has been ingested.</p>
1097+
* </li>
1098+
* </ul>
1099+
*/
1100+
Error?: ImageError | string;
1101+
1102+
/**
1103+
* <p>An attribute of the <code>Image</code> object that is Base64 encoded.</p>
1104+
*/
1105+
ImageContent?: string;
1106+
}
1107+
1108+
export namespace Image {
1109+
/**
1110+
* @internal
1111+
*/
1112+
export const filterSensitiveLog = (obj: Image): any => ({
1113+
...obj,
1114+
});
1115+
}
1116+
1117+
export interface GetImagesOutput {
1118+
/**
1119+
* <p>The list of images generated from the video stream. If there is no media available for the given timestamp, the <code>NO_MEDIA</code> error will be listed in the output.
1120+
* If an error occurs while the image is being generated, the <code>MEDIA_ERROR</code> will be listed in the output as the cause of the missing image. </p>
1121+
*/
1122+
Images?: Image[];
1123+
1124+
/**
1125+
* <p>The encrypted token that was used in the request to get more images.</p>
1126+
*/
1127+
NextToken?: string;
1128+
}
1129+
1130+
export namespace GetImagesOutput {
1131+
/**
1132+
* @internal
1133+
*/
1134+
export const filterSensitiveLog = (obj: GetImagesOutput): any => ({
1135+
...obj,
1136+
});
1137+
}
1138+
9731139
export interface GetMediaForFragmentListInput {
9741140
/**
9751141
* <p>The name of the stream from which to retrieve fragment media. Specify either this parameter or the <code>StreamARN</code> parameter.</p>

0 commit comments

Comments
 (0)