-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
decode: added ability to decoder to resuse device in multisession dec…
…ode mode
- Loading branch information
Showing
7 changed files
with
584 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
#include <vector> | ||
#include <string> | ||
#include <iostream> | ||
#include <sstream> | ||
|
||
enum IPC_TYPE { UNIX_DOMAIN_SOCKETS = 0 }; | ||
constexpr int DEFAULT_BUFLEN = 512; | ||
|
||
int usoc_manager(int isNoPresent, std::string& inputCmdsList); | ||
int clientConnectServer(std::string& recvbuf, const char* usocfilename = NULL); | ||
|
||
#ifdef _WIN32 | ||
|
||
static int cloneTheProcess(int argc, const char** argv, PROCESS_INFORMATION& pi, STARTUPINFO& si) | ||
{ | ||
// Start the child process. | ||
ZeroMemory( &si, sizeof(si) ); | ||
si.cb = sizeof(si); | ||
ZeroMemory( &pi, sizeof(pi) ); | ||
std::string argsToPass; | ||
for (int i = 0; i < argc; i++) { | ||
argsToPass += argv[i]; | ||
argsToPass += " "; | ||
} | ||
argsToPass += "spawn"; | ||
// std::cout << argsToPass; | ||
if( !CreateProcess( NULL, // No module name (use command line) | ||
(LPTSTR)argsToPass.c_str(), // Command line | ||
NULL, // Process handle not inheritable | ||
NULL, // Thread handle not inheritable | ||
FALSE, // Set handle inheritance to FALSE | ||
0, // No creation flags //debug: NORMAL_PRIORITY_CLASS | CREATE_NEW_CONSOLE | CREATE_NEW_PROCESS_GROUP, | ||
NULL, // Use parent's environment block | ||
NULL, // Use parent's starting directory | ||
&si, // Pointer to STARTUPINFO structure | ||
&pi ) // Pointer to PROCESS_INFORMATION structure | ||
) | ||
{ | ||
printf( "CreateProcess failed (%d).\n", GetLastError() ); | ||
return -1; | ||
} | ||
return 0; | ||
} | ||
#endif | ||
|
||
static int parseCharArray(std::vector<std::string>& w, const char* messageString, int& argc, const char **argv) { | ||
std::stringstream ss(messageString); | ||
std::string word; | ||
argc = 0; | ||
std::cout << std::endl; | ||
while (ss >> w[argc]) { | ||
if (w[argc][0] == '~') { | ||
w[argc] = getenv("HOME") + w[argc].substr(1); | ||
// printf("\n argv[%d] is %s", argc, w[argc].c_str()); | ||
} | ||
if (w[argc].substr(0, 6) == "finish") { | ||
printf("Received a request to finish this decode worker. The worker process is terminated (completed).\n"); | ||
return 0; | ||
} | ||
if (w[argc].substr(0, 6) == "nodata") { | ||
printf("Received a request to wait for a data...\n"); | ||
return 0; | ||
} | ||
argv[argc] = w[argc].c_str(); | ||
argc++; | ||
} | ||
return argc >= 1;//3; | ||
} | ||
|
||
static int receiveNewBitstream(IPC_TYPE ipcType, bool enableWorkerProcessesPoll, std::string& receivedMessage) | ||
{ | ||
if (!enableWorkerProcessesPoll) { | ||
return 0; | ||
} | ||
int isDataReceived = 0; | ||
if (ipcType == IPC_TYPE::UNIX_DOMAIN_SOCKETS) { | ||
isDataReceived = clientConnectServer(receivedMessage); | ||
} | ||
return isDataReceived; | ||
} |
Oops, something went wrong.