UnrealVoxta 0.1.1
 
Loading...
Searching...
No Matches
Audio2FaceRESTHandler.h
Go to the documentation of this file.
1// Copyright(c) 2024 grrimgrriefer & DZnnah, see LICENSE for details.
2
3#pragma once
4
5#include "CoreMinimal.h"
6#include "Dom/JsonObject.h"
7#include "HttpModule.h"
8#include "Interfaces/IHttpRequest.h"
9#include "Interfaces/IHttpResponse.h"
10
17class VOXTAUTILITY_A2F_API Audio2FaceRESTHandler : public TSharedFromThis<Audio2FaceRESTHandler>
18{
19#pragma region public API
20public:
25 void TryInitialize();
26
36 void GetBlendshapes(const FString& wavFileName, const FString& shapesFilePath, const FString& shapesFileName,
37 TFunction<void(const FString&, bool /*success*/)> callback);
38
40 bool IsInitializing() const;
41
43 bool IsAvailable() const;
44#pragma endregion
45
46#pragma region private helper classes
47private:
49 enum class CurrentA2FState : uint8
50 {
51 NotConnected,
52 Initializing,
53 Idle,
54 Busy
55 };
56#pragma endregion
57
58#pragma region data
59private:
60 std::atomic<CurrentA2FState> m_currentState = CurrentA2FState::NotConnected;
61#pragma endregion
62
63#pragma region private API
65 void GetStatus(TFunction<void(FHttpRequestPtr, FHttpResponsePtr, bool)> callback) const;
67 void LoadUsdFile(TFunction<void(FHttpRequestPtr, FHttpResponsePtr, bool)> callback) const;
69 void SetPlayerRootPath(TFunction<void(FHttpRequestPtr, FHttpResponsePtr, bool)> callback) const;
71 void SetPlayerTrack(const FString& fileName, TFunction<void(FHttpRequestPtr, FHttpResponsePtr, bool)> callback) const;
73 void GenerateBlendShapes(const FString& filePath, const FString& fileName,
74 TFunction<void(FHttpRequestPtr, FHttpResponsePtr, bool)> callback) const;
75
76 // TODO: implement these, maybe? idk yet
77 //void GetInstance(TFunction<void(FHttpRequestPtr, FHttpResponsePtr, bool)> callback);
78 //void GetSettings(TFunction<void(FHttpRequestPtr, FHttpResponsePtr, bool)> callback);
79 //void GetPlayerInstance(TFunction<void(FHttpRequestPtr, FHttpResponsePtr, bool)> callback);
80 //void GetPlayerTracks(TFunction<void(FHttpRequestPtr, FHttpResponsePtr, bool)> callback);
81 //void GetBlendshapeSolver(TFunction<void(FHttpRequestPtr, FHttpResponsePtr, bool)> callback);
82
90 FString JsonToString(TSharedRef<FJsonObject> jsonObject) const;
91
100 TSharedRef<IHttpRequest, ESPMode::ThreadSafe> GetBaseRequest(
101 TFunction<void(FHttpRequestPtr, FHttpResponsePtr, bool)> callback) const;
102#pragma endregion
103};
Audio2FaceRESTHandler Manages the HTTP REST API for A2F_headless mode.
Definition Audio2FaceRESTHandler.h:18
void GetBlendshapes(const FString &wavFileName, const FString &shapesFilePath, const FString &shapesFileName, TFunction< void(const FString &, bool)> callback)
Use the A2F export REST API to generate a JSON file containing all blendshape curve values for ARKit ...
Definition Audio2FaceRESTHandler.cpp:109
bool IsAvailable() const
Definition Audio2FaceRESTHandler.cpp:255
bool IsInitializing() const
Definition Audio2FaceRESTHandler.cpp:250
void TryInitialize()
Check if A2F is running and attempt to initialize it.
Definition Audio2FaceRESTHandler.cpp:16