Preliminary work on event timestamping

This commit is contained in:
Palakis 2017-02-05 02:00:21 +01:00
parent 78e6ad0f59
commit 3bd600ed52
2 changed files with 10 additions and 4 deletions

View File

@ -25,6 +25,9 @@ WSEvents::WSEvents(WSServer *server) {
QTimer *statusTimer = new QTimer(); QTimer *statusTimer = new QTimer();
connect(statusTimer, SIGNAL(timeout()), this, SLOT(StreamStatus())); connect(statusTimer, SIGNAL(timeout()), this, SLOT(StreamStatus()));
statusTimer->start(2000); // equal to frontend's constant BITRATE_UPDATE_SECONDS statusTimer->start(2000); // equal to frontend's constant BITRATE_UPDATE_SECONDS
_stream_starttime = 0;
_rec_starttime = 0;
} }
WSEvents::~WSEvents() { WSEvents::~WSEvents() {
@ -157,7 +160,7 @@ void WSEvents::OnStreamStarting() {
void WSEvents::OnStreamStarted() { void WSEvents::OnStreamStarted() {
// New update type specific to OBS Studio // New update type specific to OBS Studio
_streamStartTime = os_gettime_ns(); _stream_starttime = os_gettime_ns();
_lastBytesSent = 0; _lastBytesSent = 0;
broadcastUpdate("StreamStarted"); broadcastUpdate("StreamStarted");
} }
@ -174,7 +177,7 @@ void WSEvents::OnStreamStopping() {
void WSEvents::OnStreamStopped() { void WSEvents::OnStreamStopped() {
// New update type specific to OBS Studio // New update type specific to OBS Studio
_streamStartTime = 0; _stream_starttime = 0;
broadcastUpdate("StreamStopped"); broadcastUpdate("StreamStopped");
} }
@ -185,6 +188,7 @@ void WSEvents::OnRecordingStarting() {
void WSEvents::OnRecordingStarted() { void WSEvents::OnRecordingStarted() {
// New update type specific to OBS Studio // New update type specific to OBS Studio
_rec_starttime = os_gettime_ns();
broadcastUpdate("RecordingStarted"); broadcastUpdate("RecordingStarted");
} }
@ -195,6 +199,7 @@ void WSEvents::OnRecordingStopping() {
void WSEvents::OnRecordingStopped() { void WSEvents::OnRecordingStopped() {
// New update type specific to OBS Studio // New update type specific to OBS Studio
_rec_starttime = 0;
broadcastUpdate("RecordingStopped"); broadcastUpdate("RecordingStopped");
} }
@ -234,7 +239,7 @@ void WSEvents::StreamStatus() {
_lastBytesSent = bytes_sent; _lastBytesSent = bytes_sent;
_lastBytesSentTime = bytes_sent_time; _lastBytesSentTime = bytes_sent_time;
uint64_t totalStreamTime = (os_gettime_ns() - _streamStartTime) / 1000000000; uint64_t totalStreamTime = (os_gettime_ns() - _stream_starttime) / 1000000000;
int total_frames = obs_output_get_total_frames(stream_output); int total_frames = obs_output_get_total_frames(stream_output);
int dropped_frames = obs_output_get_frames_dropped(stream_output); int dropped_frames = obs_output_get_frames_dropped(stream_output);

View File

@ -39,7 +39,8 @@ class WSEvents : public QObject
private: private:
WSServer *_srv; WSServer *_srv;
uint64_t _streamStartTime; uint64_t _stream_starttime;
uint64_t _rec_starttime;
uint64_t _lastBytesSent; uint64_t _lastBytesSent;
uint64_t _lastBytesSentTime; uint64_t _lastBytesSentTime;
void broadcastUpdate(const char *updateType, obs_data_t *additionalFields); void broadcastUpdate(const char *updateType, obs_data_t *additionalFields);