Skip to content

Commit

Permalink
Add check for calling describeMediaStorageConfiguration outside of us…
Browse files Browse the repository at this point in the history
…-west-2 preview region
  • Loading branch information
sirknightj authored and niyatim23 committed Aug 24, 2023
1 parent feba6d0 commit 204c04a
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 23 deletions.
35 changes: 21 additions & 14 deletions examples/master.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,23 +74,30 @@ async function startMaster(localView, remoteView, formValues, onStatsReport, onR

const protocols = ['WSS', 'HTTPS'];

const describeMediaStorageConfigurationResponse = await kinesisVideoClient
.describeMediaStorageConfiguration({
ChannelARN: master.channelARN,
})
.promise();
const mediaStorageConfiguration = describeMediaStorageConfigurationResponse.MediaStorageConfiguration;
if (formValues.region?.toLowerCase() === 'us-west-2') {
console.log('[MASTER] Attempting to use media ingestion feature.');
const describeMediaStorageConfigurationResponse = await kinesisVideoClient
.describeMediaStorageConfiguration({
ChannelARN: master.channelARN,
})
.promise();
const mediaStorageConfiguration = describeMediaStorageConfigurationResponse.MediaStorageConfiguration;

const mediaServiceMode = mediaStorageConfiguration.Status === 'ENABLED' || mediaStorageConfiguration.StreamARN !== null;
if (mediaServiceMode) {
if (!formValues.sendAudio || !formValues.sendVideo) {
console.error('[MASTER] Both Send Video and Send Audio checkboxes need to be checked to ingest and store media.');
return;
const mediaServiceMode = mediaStorageConfiguration.Status === 'ENABLED' || mediaStorageConfiguration.StreamARN !== null;
if (mediaServiceMode) {
if (!formValues.sendAudio || !formValues.sendVideo) {
console.error('[MASTER] Both Send Video and Send Audio checkboxes need to be checked to ingest and store media.');
return;
}
protocols.push('WEBRTC');
master.streamARN = mediaStorageConfiguration.StreamARN;
console.log(`[MASTER] Using media ingestion feature. Stream ARN: ${master.streamARN}`);
} else {
console.log('[MASTER] Not using media ingestion feature.');
master.streamARN = null;
}
protocols.push('WEBRTC');
master.streamARN = mediaStorageConfiguration.StreamARN;
console.log(`[MASTER] Stream ARN: ${master.streamARN}`);
} else {
console.log('[MASTER] Not using media ingestion feature.');
master.streamARN = null;
}

Expand Down
25 changes: 16 additions & 9 deletions examples/viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,22 @@ async function startViewer(localView, remoteView, formValues, onStatsReport, onR
const channelARN = describeSignalingChannelResponse.ChannelInfo.ChannelARN;
console.log('[VIEWER] Channel ARN:', channelARN);

const mediaStorageConfiguration = await kinesisVideoClient
.describeMediaStorageConfiguration({
ChannelName: formValues.channelName,
})
.promise();

if (mediaStorageConfiguration.MediaStorageConfiguration.Status !== 'DISABLED') {
console.error('[VIEWER] Media storage and ingestion is ENABLED for this channel. Only the WebRTC Ingestion and Storage peer can join as a viewer.');
return;
if (formValues.region?.toLowerCase() === 'us-west-2') {
console.log('[VIEWER] Using media ingestion feature');
const mediaStorageConfiguration = await kinesisVideoClient
.describeMediaStorageConfiguration({
ChannelName: formValues.channelName,
})
.promise();

if (mediaStorageConfiguration.MediaStorageConfiguration.Status !== 'DISABLED') {
console.error(
'[VIEWER] Media storage and ingestion is ENABLED for this channel. Only the WebRTC Ingestion and Storage peer can join as a viewer.',
);
return;
}
} else {
console.log('[VIEWER] Not using media ingestion feature');
}

// Get signaling channel endpoints
Expand Down

0 comments on commit 204c04a

Please sign in to comment.