Skip to content

Commit

Permalink
misc: redesign to support es
Browse files Browse the repository at this point in the history
  • Loading branch information
jsm174 committed Nov 6, 2023
1 parent 511b6d0 commit 18ce081
Showing 1 changed file with 8 additions and 42 deletions.
50 changes: 8 additions & 42 deletions VPXDisplayServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,18 +229,6 @@ void VPXDisplayServer::Capture(struct mg_connection *c, void *ev_data)
NULL};
const char* environment[] = {"DISPLAY=:0.0", NULL};

std::stringstream ss;
for (int i = 0; command_line[i] != NULL; i++) {
if (i > 0) {
ss << " ";
}
ss << command_line[i];
}

std::string command = ss.str();
PLOGI << command;


struct subprocess_s subprocess;
if (!subprocess_create_ex(command_line, 0, environment, &subprocess)) {
int process_return;
Expand Down Expand Up @@ -288,22 +276,11 @@ void VPXDisplayServer::CaptureES(struct mg_connection *c, void *ev_data)

const char* environment[] = {"DISPLAY=:0.0", NULL};

std::stringstream ss;
for (int i = 0; command_line[i] != NULL; i++) {
if (i > 0) {
ss << " ";
}
ss << command_line[i];
}

std::string command = ss.str();
PLOGI << command;

struct subprocess_s subprocess;
if (!subprocess_create_ex(command_line, 0, environment, &subprocess)) {
int process_return;
if (!subprocess_join(&subprocess, &process_return)) {
PLOGI.printf("process return: %d", process_return);
PLOGI.printf("process returned: %d", process_return);
if (!process_return) {
struct mg_http_serve_opts opts = {};
mg_http_serve_file(c, hm, szPath.c_str(), &opts);
Expand All @@ -327,31 +304,20 @@ void VPXDisplayServer::CaptureES(struct mg_connection *c, void *ev_data)
"-framerate", "30",
"-i", ":0.0",
"-c:v", "libx264",
"-preset", "ultrafast",
"-preset", "slow",
"-profile:v", "main",
"-level", "3.1",
"-pix_fmt", "yuv420p",
"-t", "10",
"-t", "5",
szPath.c_str(),
NULL};
const char* environment[] = {"DISPLAY=:0.0", NULL};

std::stringstream ss;
for (int i = 0; command_line[i] != NULL; i++) {
if (i > 0) {
ss << " ";
}
ss << command_line[i];
}

std::string command = ss.str();
PLOGI << command;

struct subprocess_s subprocess;
if (!subprocess_create_ex(command_line, 0, environment, &subprocess)) {
int process_return;
if (!subprocess_join(&subprocess, &process_return)) {
PLOGI.printf("process return: %d", process_return);
PLOGI.printf("process returned: %d", process_return);
if (!process_return) {
struct mg_http_serve_opts opts = {};
mg_http_serve_file(c, hm, szPath.c_str(), &opts);
Expand All @@ -362,9 +328,9 @@ void VPXDisplayServer::CaptureES(struct mg_connection *c, void *ev_data)

mg_http_reply(c, 500, "", "Server error");
}

mg_http_reply(c, 400, "", "Bad request");
return;
else {
mg_http_reply(c, 400, "", "Bad request");
}
}

int VPXDisplayServer::OpenDisplay(const string& szName, VPXDisplay* pDisplay)
Expand Down Expand Up @@ -562,4 +528,4 @@ int VPXDisplayServer::Start()
mg_mgr_free(&mgr);

return 0;
}
}

0 comments on commit 18ce081

Please sign in to comment.