mirror of
https://github.com/Palakis/obs-websocket.git
synced 2024-08-30 18:12:16 +00:00
Requests/Utils: Modify utils naming/usage
A bit too niche to have a util that takes an output and returns a timecode string. Let's just make it take a duration in milliseconds.
This commit is contained in:
parent
32be21886c
commit
7403264d42
@ -4,11 +4,13 @@ RequestResult RequestHandler::GetRecordStatus(const Request& request)
|
||||
{
|
||||
OBSOutputAutoRelease recordOutput = obs_frontend_get_streaming_output();
|
||||
|
||||
uint64_t outputDuration = Utils::Obs::NumberHelper::GetOutputDuration(recordOutput);
|
||||
|
||||
json responseData;
|
||||
responseData["outputActive"] = obs_output_active(recordOutput);
|
||||
responseData["outputPaused"] = obs_output_paused(recordOutput);
|
||||
responseData["outputTimecode"] = Utils::Obs::StringHelper::GetOutputTimecodeString(recordOutput);
|
||||
responseData["outputDuration"] = Utils::Obs::NumberHelper::GetOutputDuration(recordOutput);
|
||||
responseData["outputTimecode"] = Utils::Obs::StringHelper::DurationToTimecode(outputDuration);
|
||||
responseData["outputDuration"] = outputDuration;
|
||||
responseData["outputBytes"] = (uint64_t)obs_output_get_total_bytes(recordOutput);
|
||||
|
||||
return RequestResult::Success(responseData);
|
||||
|
@ -4,11 +4,13 @@ RequestResult RequestHandler::GetStreamStatus(const Request& request)
|
||||
{
|
||||
OBSOutputAutoRelease streamOutput = obs_frontend_get_streaming_output();
|
||||
|
||||
uint64_t outputDuration = Utils::Obs::NumberHelper::GetOutputDuration(streamOutput);
|
||||
|
||||
json responseData;
|
||||
responseData["outputActive"] = obs_output_active(streamOutput);
|
||||
responseData["outputReconnecting"] = obs_output_reconnecting(streamOutput);
|
||||
responseData["outputTimecode"] = Utils::Obs::StringHelper::GetOutputTimecodeString(streamOutput);
|
||||
responseData["outputDuration"] = Utils::Obs::NumberHelper::GetOutputDuration(streamOutput);
|
||||
responseData["outputTimecode"] = Utils::Obs::StringHelper::DurationToTimecode(outputDuration);
|
||||
responseData["outputDuration"] = outputDuration;
|
||||
responseData["outputBytes"] = (uint64_t)obs_output_get_total_bytes(streamOutput);
|
||||
responseData["outputSkippedFrames"] = obs_output_get_frames_dropped(streamOutput);
|
||||
responseData["outputTotalFrames"] = obs_output_get_total_frames(streamOutput);
|
||||
|
@ -144,16 +144,8 @@ std::string Utils::Obs::StringHelper::GetSceneItemBoundsTypeString(enum obs_boun
|
||||
}
|
||||
}
|
||||
|
||||
std::string Utils::Obs::StringHelper::GetOutputTimecodeString(obs_output_t *output)
|
||||
std::string Utils::Obs::StringHelper::DurationToTimecode(uint64_t ms)
|
||||
{
|
||||
if (!output || !obs_output_active(output))
|
||||
return "00:00:00.000";
|
||||
|
||||
video_t* video = obs_output_video(output);
|
||||
uint64_t frameTimeNs = video_output_get_frame_time(video);
|
||||
int totalFrames = obs_output_get_total_frames(output);
|
||||
|
||||
uint64_t ms = util_mul_div64(totalFrames, frameTimeNs, 1000000ULL);
|
||||
uint64_t secs = ms / 1000ULL;
|
||||
uint64_t minutes = secs / 60ULL;
|
||||
|
||||
|
@ -37,7 +37,7 @@ namespace Utils {
|
||||
std::string GetMediaInputStateString(obs_source_t *input);
|
||||
std::string GetLastReplayBufferFilePath();
|
||||
std::string GetSceneItemBoundsTypeString(enum obs_bounds_type type);
|
||||
std::string GetOutputTimecodeString(obs_output_t *output);
|
||||
std::string DurationToTimecode(uint64_t);
|
||||
}
|
||||
|
||||
namespace EnumHelper {
|
||||
|
Loading…
Reference in New Issue
Block a user