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:
tt2468 2021-11-17 01:07:04 -08:00
parent 32be21886c
commit 7403264d42
4 changed files with 10 additions and 14 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -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 {