16 #include <com/amazonaws/kinesis/video/utils/Include.h> 23 #define STREAM_DEFINITION_MAX_CODEC_PRIVATE_DATA_SIZE (1024) 34 PBYTE * out_codec_private_data, uint32_t * out_codec_private_data_size)
const 36 if (
nullptr == out_codec_private_data ||
37 nullptr == out_codec_private_data_size) {
40 std::string b64_encoded_codec_private_data;
41 reader.
ReadParam(prefix +
"codecPrivateData", b64_encoded_codec_private_data);
42 if (!b64_encoded_codec_private_data.empty()) {
44 uint32_t decoded_buffer_size =
sizeof(temp_codec_data);
45 if (STATUS_SUCCESS != base64Decode(const_cast<char *>(b64_encoded_codec_private_data.c_str()),
46 temp_codec_data, &decoded_buffer_size)) {
49 PBYTE codec_private_data = (PBYTE)malloc(decoded_buffer_size);
50 if (
nullptr == codec_private_data) {
53 memset(codec_private_data, 0, decoded_buffer_size);
54 memcpy(codec_private_data, temp_codec_data, decoded_buffer_size);
55 *out_codec_private_data = codec_private_data;
56 *out_codec_private_data_size = decoded_buffer_size;
61 unique_ptr<StreamDefinition> StreamDefinitionProvider::GetStreamDefinition(
63 const PBYTE codec_private_data, uint32_t codec_private_data_size)
const 65 if (
nullptr == codec_private_data && 0 != codec_private_data_size) {
66 return unique_ptr<StreamDefinition>{};
70 reader.
ReadParam(prefix +
"stream_name", stream_name);
72 map<string, string> tags;
75 int retention_period = 2;
76 reader.
ReadParam(prefix +
"retention_period", retention_period);
78 std::string kms_key_id;
79 reader.
ReadParam(prefix +
"kms_key_id", kms_key_id);
81 int streaming_type_id = 0;
82 reader.
ReadParam(prefix +
"streaming_type", streaming_type_id);
83 STREAMING_TYPE streaming_type =
static_cast<STREAMING_TYPE
>(streaming_type_id);
85 std::string content_type =
"video/h264";
86 reader.
ReadParam(prefix +
"content_type", content_type);
90 reader.
ReadParam(prefix +
"max_latency", max_latency);
92 int fragment_duration = 2;
93 reader.
ReadParam(prefix +
"fragment_duration", fragment_duration);
95 int timecode_scale = 1;
96 reader.
ReadParam(prefix +
"timecode_scale", timecode_scale);
98 bool key_frame_fragmentation =
true;
99 reader.
ReadParam(prefix +
"key_frame_fragmentation", key_frame_fragmentation);
101 bool frame_timecodes =
true;
102 reader.
ReadParam(prefix +
"frame_timecodes", frame_timecodes);
104 bool absolute_fragment_time =
true;
105 reader.
ReadParam(prefix +
"absolute_fragment_time", absolute_fragment_time);
107 bool fragment_acks =
true;
108 reader.
ReadParam(prefix +
"fragment_acks", fragment_acks);
110 bool restart_on_error =
true;
111 reader.
ReadParam(prefix +
"restart_on_error", restart_on_error);
113 bool recalculate_metrics =
true;
114 reader.
ReadParam(prefix +
"recalculate_metrics", recalculate_metrics);
116 int nal_adaptation_flag_id = NAL_ADAPTATION_ANNEXB_NALS | NAL_ADAPTATION_ANNEXB_CPD_NALS;
117 reader.
ReadParam(prefix +
"nal_adaptation_flags", nal_adaptation_flag_id);
118 NAL_ADAPTATION_FLAGS nal_adaptation_flags =
119 static_cast<NAL_ADAPTATION_FLAGS
>(nal_adaptation_flag_id);
122 reader.
ReadParam(prefix +
"frame_rate", frame_rate);
124 int avg_bandwidth_bps = 4 * 1024 * 1024;
125 reader.
ReadParam(prefix +
"avg_bandwidth_bps", avg_bandwidth_bps);
127 int buffer_duration = 120;
128 reader.
ReadParam(prefix +
"buffer_duration", buffer_duration);
130 int replay_duration = 40;
131 reader.
ReadParam(prefix +
"replay_duration", replay_duration);
133 int connection_staleness = 30;
134 reader.
ReadParam(prefix +
"connection_staleness", connection_staleness);
136 std::string codec_id =
"V_MPEG4/ISO/AVC";
137 reader.
ReadParam(prefix +
"codec_id", codec_id);
139 std::string track_name =
"kinesis_video";
140 reader.
ReadParam(prefix +
"track_name", track_name);
143 auto stream_definition = make_unique<StreamDefinition>(
144 stream_name, hours(retention_period), &tags, kms_key_id, streaming_type, content_type,
145 milliseconds(max_latency), seconds(fragment_duration), milliseconds(timecode_scale),
146 key_frame_fragmentation, frame_timecodes, absolute_fragment_time, fragment_acks,
147 restart_on_error, recalculate_metrics, nal_adaptation_flags, frame_rate, avg_bandwidth_bps,
148 seconds(buffer_duration), seconds(replay_duration), seconds(connection_staleness), codec_id,
149 track_name, codec_private_data, codec_private_data_size);
150 return stream_definition;
enum Aws::Kinesis::kinesis_manager_status_e KinesisManagerStatus
#define STREAM_DEFINITION_MAX_CODEC_PRIVATE_DATA_SIZE
virtual AwsError ReadParam(const ParameterPath ¶m_path, std::vector< std::string > &out) const =0