我正在尝试将 v2 的代码迁移到 v3,但我无法找到如何迁移这一行:
kinesisVideoArchivedContent.endpoint = new AWS.Endpoint(DataEndpoint)
上面的代码创建了一个 obj 端点,其中包含一些要在 getHLSStreamingSessionURL 中使用的属性:
/*First you have to get de data endpoint calling getDataEndpoint*/
export const getEndPoint = (streamNme) => {
return new Promise((resolve, reject) => {
kinesisVideo.getDataEndpoint({
StreamName: streamName,
APIName: "GET_HLS_STREAMING_SESSION_URL"
}, function (err, response) {
if ( err ) {
return console.error(err);
}
// console.log('Data endpoint: ' + response.DataEndpoint);
resolve(response.DataEndpoint)
});
})
export const getStream = (StreamName, DataEndpoint) => {
return new Promise((resolve, reject) => {
kinesisVideoArchivedContent.endpoint = new AWS.Endpoint(DataEndpoint)
const PlaybackMode = 'LIVE'
const FragmentSelectorType = 'SERVER_TIMESTAMP'
const SESSION_EXPIRATION_SECONDS = 60 * 60
const params = {
StreamName,
PlaybackMode,
HLSFragmentSelector: {
FragmentSelectorType,
},
Expires: parseInt(SESSION_EXPIRATION_SECONDS),
}
kinesisVideoArchivedContent.getHLSStreamingSessionURL(params, (err, response) => {
if (err) {
reject(StreamName)
return
}
resolve(response.HLSStreamingSessionURL)
})
})
}
import { KinesisVideoArchivedMediaClient, GetHLSStreamingSessionURLCommand } from "@aws-sdk/client-kinesis-video-archived-media"; // ES Modules import
/*before the code below you have to call getDataEndpointCommand */
const client = new KinesisVideoArchivedMediaClient(config);
const command = new GetHLSStreamingSessionURLCommand(input);
const response = await client.send(command);
此版本 3 的代码似乎工作正常,并返回一个 200 和一个带有两个属性 @mediadata 和 HLSStreamingSessionURL 的未定义的 obj,总是返回未定义,因为我认为 v3 缺少这一行:
kinesisVideoArchivedContent.endpoint = new AWS.Endpoint(DataEndpoint)
先感谢您