mirror of
https://github.com/TheRedShip/RT_GPU.git
synced 2025-09-27 18:48:36 +02:00
server now receives images and create final video. server now handles clients disconnect
This commit is contained in:
@ -6,7 +6,7 @@
|
||||
/* By: tomoron <tomoron@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/02/20 18:25:18 by tomoron #+# #+# */
|
||||
/* Updated: 2025/02/25 01:49:07 by tomoron ### ########.fr */
|
||||
/* Updated: 2025/02/25 22:26:49 by tomoron ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -38,6 +38,8 @@ typedef struct s_client
|
||||
t_job *curJob;
|
||||
uint8_t progress;
|
||||
bool ready;
|
||||
bool readyRespond;
|
||||
bool gotGo;
|
||||
} t_client;
|
||||
|
||||
typedef enum e_msg
|
||||
@ -46,7 +48,8 @@ typedef enum e_msg
|
||||
JOB,
|
||||
PROGRESS_UPDATE,
|
||||
IMG_SEND_RQ,
|
||||
IMG
|
||||
IMG,
|
||||
ABORT
|
||||
} t_msg;
|
||||
|
||||
class Clusterizer
|
||||
@ -62,6 +65,7 @@ class Clusterizer
|
||||
bool hasJobs(void);
|
||||
|
||||
void addJob(glm::vec3 pos, glm::vec2 dir, size_t samples, size_t frames, GPUDenoise &denoise);
|
||||
void abortJobs(void);
|
||||
|
||||
private:
|
||||
bool _isActive;
|
||||
@ -72,19 +76,21 @@ class Clusterizer
|
||||
|
||||
std::vector<t_job *> _jobs[3];
|
||||
|
||||
void imguiJobStat(void);
|
||||
void imguiClients(void);
|
||||
void imguiJobStat(void);
|
||||
void imguiClients(void);
|
||||
std::string clientStatus(t_client client);
|
||||
|
||||
private: //client
|
||||
void initClient(std::string &dest);
|
||||
void openClientConnection(const char *ip, int port);
|
||||
void clientHandleBuffer(void);
|
||||
void updateClient(Scene &scene, Window &win, std::vector<GLuint> &textures, ShaderProgram &denoisingProgram);
|
||||
void clientGetJob(void);
|
||||
void clientReceive(void);
|
||||
void handleCurrentJob(Scene &scene, Window &win, std::vector<GLuint> &textures, ShaderProgram &denoisingProgram);
|
||||
void sendProgress(uint8_t progress);
|
||||
void sendImageToServer(std::vector<GLuint> &textures, ShaderProgram &denoisingProgram);
|
||||
void initClient(std::string &dest);
|
||||
void openClientConnection(const char *ip, int port);
|
||||
void clientHandleBuffer(void);
|
||||
void updateClient(Scene &scene, Window &win, std::vector<GLuint> &textures, ShaderProgram &denoisingProgram);
|
||||
void clientGetJob(void);
|
||||
void clientReceive(void);
|
||||
void handleCurrentJob(Scene &scene, Window &win, std::vector<GLuint> &textures, ShaderProgram &denoisingProgram);
|
||||
void sendProgress(uint8_t progress);
|
||||
void sendImageToServer(std::vector<GLuint> &textures, ShaderProgram &denoisingProgram);
|
||||
std::vector<uint8_t> rgb32fToRgb24i(std::vector<float> &imageFloat);
|
||||
|
||||
int _serverFd;
|
||||
std::string _serverIp;
|
||||
@ -102,13 +108,16 @@ class Clusterizer
|
||||
int acceptClients(void);
|
||||
void updatePollfds(void);
|
||||
int updateBuffer(int fd);
|
||||
void handleBuffer(int fd, std::vector<uint8_t> &buf);
|
||||
bool handleBuffer(int fd, std::vector<uint8_t> &buf);
|
||||
void deleteClient(int fd);
|
||||
int handleSendRequests(void);
|
||||
void getImageFromClient(int fd, std::vector<uint8_t> &buf);
|
||||
void redistributeJob(t_job *job);
|
||||
|
||||
int dispatchJobs(void);
|
||||
|
||||
int _serverSocket;
|
||||
struct pollfd *_pollfds;
|
||||
std::map<int, t_client> _clients;
|
||||
size_t _curId;
|
||||
size_t _curFrame;
|
||||
};
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: tomoron <tomoron@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/02/23 23:41:18 by tomoron #+# #+# */
|
||||
/* Updated: 2025/02/24 00:41:00 by tomoron ### ########.fr */
|
||||
/* Updated: 2025/02/25 14:47:37 by tomoron ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -22,6 +22,7 @@ class Ffmpeg
|
||||
~Ffmpeg();
|
||||
|
||||
void addImageToVideo(Scene &scene, std::vector<GLuint> &textures, ShaderProgram &denoisingProgram);
|
||||
void addImageToVideo(std::vector<uint8_t> &buf);
|
||||
|
||||
static void updateAvailableCodecs(std::vector<const AVCodec *> &codecList, std::vector<const char *> &codecListStr, std::string filename, int mode, AVCodecID id);
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
/* By: tomoron <tomoron@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/01/22 16:29:26 by tomoron #+# #+# */
|
||||
/* Updated: 2025/02/24 17:21:08 by tomoron ### ########.fr */
|
||||
/* Updated: 2025/02/25 19:16:25 by tomoron ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@ -48,11 +48,13 @@ class Renderer
|
||||
|
||||
int rendering(void) const;
|
||||
bool shouldClose(void) const;
|
||||
void addImageToRender(std::vector<uint8_t> &buffer);
|
||||
void endRender(Clusterizer *clust);
|
||||
|
||||
private:
|
||||
void init(Scene *scene, Window *win);
|
||||
|
||||
void showRenderInfo(int isImgui);
|
||||
void showRenderInfo(int isImgui, Clusterizer *clust);
|
||||
std::string floatToTime(double timef);
|
||||
float calcTime(glm::vec3 pos);
|
||||
|
||||
@ -76,7 +78,6 @@ class Renderer
|
||||
void createClusterJobs(Clusterizer &clust);
|
||||
void fillGoodCodecList(std::vector<AVCodecID> &lst);
|
||||
void addImageToRender(std::vector<GLuint> &textures, ShaderProgram &denoisingProgram);
|
||||
void endRender(void);
|
||||
|
||||
|
||||
Scene *_scene;
|
||||
|
Reference in New Issue
Block a user