mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-12 10:49:59 +01:00
Using system wide temp directory for shared memory socket 9for linux
snaps to be able to share).
This commit is contained in:
@@ -223,7 +223,7 @@ void NetworkStream::update()
|
|||||||
// make sure the shared memory socket exists
|
// make sure the shared memory socket exists
|
||||||
if (config_.protocol == NetworkToolkit::SHM_RAW) {
|
if (config_.protocol == NetworkToolkit::SHM_RAW) {
|
||||||
// for shared memory, the parameter is a file location in settings
|
// for shared memory, the parameter is a file location in settings
|
||||||
parameter = SystemToolkit::full_filename(SystemToolkit::settings_path(), "shm") + parameter;
|
parameter = SystemToolkit::full_filename(SystemToolkit::temp_path(), "shm") + parameter;
|
||||||
// try few times to see if file exists and wait 20ms each time
|
// try few times to see if file exists and wait 20ms each time
|
||||||
for(int trial = 0; trial < 5; trial ++){
|
for(int trial = 0; trial < 5; trial ++){
|
||||||
if ( SystemToolkit::file_exists(parameter))
|
if ( SystemToolkit::file_exists(parameter))
|
||||||
@@ -232,7 +232,7 @@ void NetworkStream::update()
|
|||||||
}
|
}
|
||||||
// failed to find the shm socket file: cannot connect
|
// failed to find the shm socket file: cannot connect
|
||||||
if (!SystemToolkit::file_exists(parameter)) {
|
if (!SystemToolkit::file_exists(parameter)) {
|
||||||
Log::Warning("Cannot connect to shared memory.");
|
Log::Warning("Cannot connect to shared memory %s.", parameter.c_str());
|
||||||
failed_ = true;
|
failed_ = true;
|
||||||
}
|
}
|
||||||
parameter = "\"" + parameter + "\"";
|
parameter = "\"" + parameter + "\"";
|
||||||
|
|||||||
@@ -358,7 +358,7 @@ void VideoStreamer::addFrame (FrameBuffer *frame_buffer, float dt)
|
|||||||
}
|
}
|
||||||
else if (config_.protocol == NetworkToolkit::SHM_RAW) {
|
else if (config_.protocol == NetworkToolkit::SHM_RAW) {
|
||||||
// TODO rename SHM socket "shm_PORT"
|
// TODO rename SHM socket "shm_PORT"
|
||||||
std::string path = SystemToolkit::full_filename(SystemToolkit::settings_path(), "shm");
|
std::string path = SystemToolkit::full_filename(SystemToolkit::temp_path(), "shm");
|
||||||
path += std::to_string(config_.port);
|
path += std::to_string(config_.port);
|
||||||
g_object_set (G_OBJECT (gst_bin_get_by_name (GST_BIN (pipeline_), "sink")),
|
g_object_set (G_OBJECT (gst_bin_get_by_name (GST_BIN (pipeline_), "sink")),
|
||||||
"socket-path", path.c_str(), NULL);
|
"socket-path", path.c_str(), NULL);
|
||||||
|
|||||||
@@ -254,6 +254,20 @@ string SystemToolkit::settings_path()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string SystemToolkit::temp_path()
|
||||||
|
{
|
||||||
|
string temp;
|
||||||
|
|
||||||
|
const char *tmpdir = getenv("TMPDIR");
|
||||||
|
if (tmpdir)
|
||||||
|
temp = std::string(tmpdir);
|
||||||
|
else
|
||||||
|
temp = std::string( P_tmpdir );
|
||||||
|
|
||||||
|
temp += PATH_SEP;
|
||||||
|
return temp;
|
||||||
|
}
|
||||||
|
|
||||||
string SystemToolkit::full_filename(const std::string& path, const string &filename)
|
string SystemToolkit::full_filename(const std::string& path, const string &filename)
|
||||||
{
|
{
|
||||||
string fullfilename = path;
|
string fullfilename = path;
|
||||||
|
|||||||
@@ -27,6 +27,9 @@ namespace SystemToolkit
|
|||||||
// get the OS dependent path where to store settings
|
// get the OS dependent path where to store settings
|
||||||
std::string settings_path();
|
std::string settings_path();
|
||||||
|
|
||||||
|
// get the OS dependent path where to store temporary files
|
||||||
|
std::string temp_path();
|
||||||
|
|
||||||
// builds the OS dependent complete file name
|
// builds the OS dependent complete file name
|
||||||
std::string full_filename(const std::string& path, const std::string& filename);
|
std::string full_filename(const std::string& path, const std::string& filename);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user