in kinesis_manager/src/kinesis_stream_manager.cpp [324:366]
KinesisManagerStatus KinesisStreamManager::ProcessCodecPrivateDataForStream(
const std::string & stream_name, std::vector<uint8_t> codec_private_data)
{
if (0 < video_streams_codec_data_.count(stream_name) &&
video_streams_codec_data_.at(stream_name) == codec_private_data) {
/* Codec data is already up to date */
return KINESIS_MANAGER_STATUS_SUCCESS;
}
AWS_LOGSTREAM_INFO(__func__, "Updating new codec data for " << stream_name);
/* Get stream configuration ID */
int video_stream_count = 0, stream_idx = 0;
KinesisManagerStatus status = KINESIS_MANAGER_STATUS_PROCESS_CODEC_DATA_STREAM_CONFIG_NOT_FOUND;
parameter_reader_->ReadParam(GetKinesisVideoParameter(kStreamParameters.stream_count),
video_stream_count);
for (int stream_idx = 0; stream_idx < video_stream_count; stream_idx++) {
std::string configured_stream_name;
parameter_reader_->ReadParam(
GetStreamParameterPath(stream_idx, kStreamParameters.stream_name),
configured_stream_name);
if (configured_stream_name == stream_name) {
status = KINESIS_MANAGER_STATUS_SUCCESS;
break;
}
}
if (KINESIS_MANAGER_STATUS_FAILED(status)) {
return status;
}
/* Re-create the stream with the new codec data */
FreeStream(stream_name);
status = KinesisVideoStreamSetup(stream_idx, codec_private_data.data(), codec_private_data.size(),
nullptr);
if (KINESIS_MANAGER_STATUS_FAILED(status)) {
/* At this point we have an active subscription without the ability to stream data; need to
* unsubscribe */
std::string topic_name;
parameter_reader_->ReadParam(
GetStreamParameterPath(stream_idx, kStreamParameters.topic_name), topic_name);
AWS_LOGSTREAM_ERROR(__func__, "KinesisVideoStreamSetup failed, uninstalling subscriptions to "
<< topic_name << " Error code: " << status);
subscription_installer_->Uninstall(topic_name);
}
return status;
}