Skip to content

Commit 183e389

Browse files
committed
JNI namespace change
Improve kvssink plugin retry behavior Unify GetTimeFunc in C++ producer for override Support for custom user agent string
1 parent 80c6ce9 commit 183e389

File tree

71 files changed

+889
-718
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+889
-718
lines changed

README.md

+6
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ This library is licensed under the Amazon Software License.
4444

4545
----
4646
### Release notes
47+
#### Release 1.6.0 (3rd Dec 2018)
48+
* JNI namespace change
49+
* Improve kvssink plugin retry behavior
50+
* Unify GetTimeFunc in C++ producer for override
51+
* Support for custom user agent string
52+
4753
#### Release 1.5.1 (28th Sep 2018)
4854
* Fragment Metadata Support for Producer SDK
4955
* Add fallback frame rate to avoid negotiation issue on certain machines like macbook air

kinesis-video-gst-demo/kinesis_video_gstreamer_sample_app.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ LOGGER_TAG("com.amazonaws.kinesis.video.gstreamer");
4343
#define DEFAULT_RECALCULATE_METRICS TRUE
4444
#define DEFAULT_STREAM_FRAMERATE 25
4545
#define DEFAULT_AVG_BANDWIDTH_BPS (4 * 1024 * 1024)
46-
#define DEFAULT_BUFFER_DURATION_SECONDS 180
46+
#define DEFAULT_BUFFER_DURATION_SECONDS 120
4747
#define DEFAULT_REPLAY_DURATION_SECONDS 40
4848
#define DEFAULT_CONNECTION_STALENESS_SECONDS 60
4949
#define DEFAULT_CODEC_ID "V_MPEG4/ISO/AVC"
@@ -111,7 +111,7 @@ class SampleCredentialProvider : public StaticCredentialProvider {
111111

112112
// Update only the expiration
113113
auto now_time = std::chrono::duration_cast<std::chrono::seconds>(
114-
std::chrono::system_clock::now().time_since_epoch());
114+
systemCurrentTime().time_since_epoch());
115115
auto expiration_seconds = now_time + ROTATION_PERIOD;
116116
credentials.setExpiration(std::chrono::seconds(expiration_seconds.count()));
117117
LOG_INFO("New credentials expiration is " << credentials.getExpiration().count());
@@ -122,8 +122,8 @@ class SampleDeviceInfoProvider : public DefaultDeviceInfoProvider {
122122
public:
123123
device_info_t getDeviceInfo() override {
124124
auto device_info = DefaultDeviceInfoProvider::getDeviceInfo();
125-
// Set the storage size to 256mb
126-
device_info.storageInfo.storageSize = 512 * 1024 * 1024;
125+
// Set the storage size to 128mb
126+
device_info.storageInfo.storageSize = 128 * 1024 * 1024;
127127
return device_info;
128128
}
129129
};

kinesis-video-gst-demo/kinesis_video_gstreamer_sample_multistream_app.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,14 @@ LOGGER_TAG("com.amazonaws.kinesis.video.gstreamer");
4747
#define DEFAULT_RECALCULATE_METRICS TRUE
4848
#define DEFAULT_STREAM_FRAMERATE 25
4949
#define DEFAULT_AVG_BANDWIDTH_BPS (4 * 1024 * 1024)
50-
#define DEFAULT_BUFFER_DURATION_SECONDS 180
50+
#define DEFAULT_BUFFER_DURATION_SECONDS 120
5151
#define DEFAULT_REPLAY_DURATION_SECONDS 40
5252
#define DEFAULT_CONNECTION_STALENESS_SECONDS 60
5353
#define DEFAULT_CODEC_ID "V_MPEG4/ISO/AVC"
5454
#define DEFAULT_TRACKNAME "kinesis_video"
5555
#define APP_SINK_BASE_NAME "appsink"
5656
#define DEFAULT_BUFFER_SIZE (1 * 1024 * 1024)
57-
#define DEFAULT_STORAGE_SIZE (512 * 1024 * 1024)
57+
#define DEFAULT_STORAGE_SIZE (128 * 1024 * 1024)
5858
#define DEFAULT_ROTATION_TIME_SECONDS 2400
5959

6060
namespace com {
@@ -122,7 +122,7 @@ namespace com {
122122

123123
// Update only the expiration
124124
auto now_time = std::chrono::duration_cast<std::chrono::seconds>(
125-
std::chrono::system_clock::now().time_since_epoch());
125+
systemCurrentTime().time_since_epoch());
126126
auto expiration_seconds = now_time + ROTATION_PERIOD;
127127
credentials.setExpiration(std::chrono::seconds(expiration_seconds.count()));
128128
LOG_INFO("New credentials expiration is " << credentials.getExpiration().count());
@@ -133,7 +133,7 @@ namespace com {
133133
public:
134134
device_info_t getDeviceInfo() override {
135135
auto device_info = DefaultDeviceInfoProvider::getDeviceInfo();
136-
// Set the storage size to 512MB
136+
// Set the storage size to 64MB
137137
device_info.storageInfo.storageSize = DEFAULT_STORAGE_SIZE;
138138
return device_info;
139139
}

kinesis-video-gst-demo/kinesis_video_gstreamer_sample_rtsp_app.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ LOGGER_TAG("com.amazonaws.kinesis.video.gstreamer");
4242
#define DEFAULT_RECALCULATE_METRICS TRUE
4343
#define DEFAULT_STREAM_FRAMERATE 25
4444
#define DEFAULT_AVG_BANDWIDTH_BPS (4 * 1024 * 1024)
45-
#define DEFAULT_BUFFER_DURATION_SECONDS 180
45+
#define DEFAULT_BUFFER_DURATION_SECONDS 120
4646
#define DEFAULT_REPLAY_DURATION_SECONDS 40
4747
#define DEFAULT_CONNECTION_STALENESS_SECONDS 60
4848
#define DEFAULT_CODEC_ID "V_MPEG4/ISO/AVC"
@@ -113,7 +113,7 @@ namespace com {
113113

114114
// Update only the expiration
115115
auto now_time = std::chrono::duration_cast<std::chrono::seconds>(
116-
std::chrono::system_clock::now().time_since_epoch());
116+
systemCurrentTime().time_since_epoch());
117117
auto expiration_seconds = now_time + ROTATION_PERIOD;
118118
credentials.setExpiration(std::chrono::seconds(expiration_seconds.count()));
119119
LOG_INFO("New credentials expiration is " << credentials.getExpiration().count());
@@ -124,8 +124,8 @@ namespace com {
124124
public:
125125
device_info_t getDeviceInfo() override {
126126
auto device_info = DefaultDeviceInfoProvider::getDeviceInfo();
127-
// Set the storage size to 512MB
128-
device_info.storageInfo.storageSize = 512 * 1024 * 1024;
127+
// Set the storage size to 128MB
128+
device_info.storageInfo.storageSize = 128 * 1024 * 1024;
129129
return device_info;
130130
}
131131
};

kinesis-video-gstreamer-plugin/demo-src/kvs_producer_plugin_demo.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ int gstreamer_init(int argc, char *argv[]) {
206206
g_object_set(G_OBJECT (data.source), "do-timestamp", TRUE, "device", "/dev/video0", NULL);
207207
}
208208

209-
g_object_set(G_OBJECT (data.kvsproducer), "stream-name", "plugin-test-stream", "frame-timestamp", KVS_SINK_TIMESTAMP_DEFAULT, "storage-size", 512, NULL);
209+
g_object_set(G_OBJECT (data.kvsproducer), "stream-name", "plugin-test-stream", "frame-timestamp", KVS_SINK_TIMESTAMP_DEFAULT, "storage-size", 128, NULL);
210210

211211
// Iot certificate sample usage.
212212
// const char* iot_g_struct = "iot-certificate,endpoint=endpoint,"

kinesis-video-gstreamer-plugin/demo-src/kvs_producer_plugin_rtsp_demo.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ int gstreamer_init(int argc, char *argv[]) {
136136
return 1;
137137
}
138138

139-
g_object_set(G_OBJECT (data.kvsproducer), "stream-name", stream_name, "storage-size", 512, NULL);
139+
g_object_set(G_OBJECT (data.kvsproducer), "stream-name", stream_name, "storage-size", 128, NULL);
140140

141141

142142
g_object_set(G_OBJECT (data.source),

kinesis-video-gstreamer-plugin/plugin-src/ConnectionStaleStateMachine.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ void ConnectionStaleStateMachine::update_timestamp() {
2727

2828
void ConnectionStaleStateMachine::handleConnectionStale() {
2929
curr_time = std::chrono::duration_cast<std::chrono::milliseconds>(
30-
std::chrono::system_clock::now().time_since_epoch());
30+
systemCurrentTime().time_since_epoch());
3131
LOG_INFO("curr_time: " << curr_time.count() << ", quiet_time: " << quiet_time.count()
3232
<< ", back_to_normal_time: " << back_to_normal_time.count());
3333
if (quiet_time < curr_time){

kinesis-video-gstreamer-plugin/plugin-src/KvsSinkIotCertCredentialProvider.h

-37
This file was deleted.

kinesis-video-gstreamer-plugin/plugin-src/KvsSinkRotatingCredentialProvider.h

-24
This file was deleted.

kinesis-video-gstreamer-plugin/plugin-src/KvsSinkStreamCallbackProvider.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,12 @@ KvsSinkStreamCallbackProvider::streamErrorReportHandler(UINT64 custom_data, STRE
2424
UINT64 errored_timecode, STATUS status_code) {
2525
LOG_ERROR("Reporting stream error. Errored timecode: " << errored_timecode << " Status: 0x" << std::hex << status_code);
2626
auto customDataObj = reinterpret_cast<CustomData*>(custom_data);
27-
if (status_code == static_cast<UINT32>(STATUS_DESCRIBE_STREAM_CALL_FAILED)) {
27+
if (status_code == STATUS_DESCRIBE_STREAM_CALL_FAILED ||
28+
status_code == STATUS_GET_STREAMING_ENDPOINT_CALL_FAILED) {
2829
std::lock_guard<std::mutex> lk(customDataObj->closing_stream_handles_queue_mtx);
2930
customDataObj->closing_stream_handles_queue.push(stream_handle);
31+
} else {
32+
customDataObj->stream_status = status_code;
3033
}
3134

3235
return STATUS_SUCCESS;

kinesis-video-gstreamer-plugin/plugin-src/StreamLatencyStateMachine.cpp

+8-2
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ void StreamLatencyStateMachine::doInfiniteRetry() {
5858

5959
void StreamLatencyStateMachine::handleStreamLatency() {
6060
curr_time = std::chrono::duration_cast<std::chrono::milliseconds>(
61-
std::chrono::system_clock::now().time_since_epoch());
61+
systemCurrentTime().time_since_epoch());
6262
LOG_INFO("curr_time: " << curr_time.count() << ", quiet_time: " << quiet_time.count()
6363
<< ", back_to_normal_time: " << back_to_normal_time.count());
6464
if (curr_time > back_to_normal_time) {
@@ -85,4 +85,10 @@ void StreamLatencyStateMachine::handleStreamLatency() {
8585
break;
8686
}
8787
}
88-
}
88+
}
89+
90+
StreamLatencyStateMachine::~StreamLatencyStateMachine() {
91+
if (undo_throttle.joinable()){
92+
undo_throttle.join();
93+
}
94+
}

kinesis-video-gstreamer-plugin/plugin-src/StreamLatencyStateMachine.h

+3
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ class StreamLatencyStateMachine {
2727
StreamLatencyStateMachine(std::shared_ptr<CustomData> data, STREAM_HANDLE stream_handle): current_state(StreamLatencyHandlingState::NORMAL_STATE),
2828
data(data), stream_handle(stream_handle) {}
2929
void handleStreamLatency();
30+
31+
~StreamLatencyStateMachine();
32+
3033
private:
3134
void toResetConnectionState();
3235
void toThrottlePipelineState();

kinesis-video-gstreamer-plugin/plugin-src/Util/KvsSinkUtil.cpp

-24
Original file line numberDiff line numberDiff line change
@@ -77,28 +77,4 @@ gboolean parseIotCredentialGstructure(GstStructure *g_struct, std::map<std::stri
7777
CleanUp:
7878
return ret;
7979
}
80-
81-
bool parseTimeStr(std::string time_str, std::chrono::duration<uint64_t> &time_obj){
82-
bool res = true;
83-
std::tm timeinfo = std::tm();
84-
85-
#if defined(__GNUC__) && (__GNUC__ < 5) && !defined(__APPLE__)
86-
res = strptime(time_str.c_str(), "%Y-%m-%dT%H:%M:%SZ", &timeinfo) != NULL ? true : false;
87-
#else
88-
std::istringstream iss(time_str);
89-
res = iss >> std::get_time(&timeinfo, "%Y-%m-%dT%H:%M:%SZ") ? true : false;
90-
#endif
91-
92-
if (res) {
93-
std::time_t tt = std::mktime(&timeinfo);
94-
// the expiration string from aws credential is in UTC, but get interpreted as local time when mktime.
95-
// Thus minus timezone to convert back to UTC.
96-
tt -= timezone_offset;
97-
std::chrono::system_clock::time_point tp = std::chrono::system_clock::from_time_t (tt);
98-
time_obj = std::chrono::duration_cast<std::chrono::seconds>(tp.time_since_epoch());
99-
LOG_DEBUG("Credential expiration epoch: " << time_obj.count() << " seconds");
100-
}
101-
102-
return res;
103-
}
10480
}

kinesis-video-gstreamer-plugin/plugin-src/Util/KvsSinkUtil.h

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ namespace kvs_sink_util{
2121
gboolean parseIotCredentialGstructure(GstStructure *g_struct,
2222
std::map<std::string, std::string> &iot_cert_params);
2323

24-
bool parseTimeStr(std::string time_str, std::chrono::duration<uint64_t> &time_obj);
2524
}
2625

2726
#endif //__KVS_SINK_UTIL_H__

0 commit comments

Comments
 (0)