OBSRemoteProtocol: rely only on event data when encoding an event

This commit is contained in:
Stéphane Lepin 2020-02-25 15:24:26 +01:00
parent a0dce77a2f
commit 4338cf57e6

View File

@ -67,13 +67,15 @@ std::string OBSRemoteProtocol::encodeEvent(const RpcEvent& event)
QString updateType = event.updateType(); QString updateType = event.updateType();
obs_data_set_string(eventData, "update-type", updateType.toUtf8().constData()); obs_data_set_string(eventData, "update-type", updateType.toUtf8().constData());
if (obs_frontend_streaming_active()) { std::optional<uint64_t> streamTime = event.streamTime();
QString streamingTimecode = Utils::nsToTimestamp(event.streamTime().value()); if (streamTime.has_value()) {
QString streamingTimecode = Utils::nsToTimestamp(streamTime.value());
obs_data_set_string(eventData, "stream-timecode", streamingTimecode.toUtf8().constData()); obs_data_set_string(eventData, "stream-timecode", streamingTimecode.toUtf8().constData());
} }
if (obs_frontend_recording_active()) { std::optional<uint64_t> recordingTime = event.recordingTime();
QString recordingTimecode = Utils::nsToTimestamp(event.recordingTime().value()); if (recordingTime.has_value()) {
QString recordingTimecode = Utils::nsToTimestamp(recordingTime.value());
obs_data_set_string(eventData, "rec-timecode", recordingTimecode.toUtf8().constData()); obs_data_set_string(eventData, "rec-timecode", recordingTimecode.toUtf8().constData());
} }