Skip to content

Commit

Permalink
BugFix Shmdata sink broadcasting Shared Memory
Browse files Browse the repository at this point in the history
Fix termination of shmdatasink, improved UI and doc.
  • Loading branch information
brunoherbelin committed May 18, 2024
1 parent b38017e commit 12bff7a
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 9 deletions.
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,16 @@ Optionnal:

apt-get install libglm-dev libstb-dev libtinyxml2-dev ableton-link-dev

+ Follow the instructions to [install Shmdata](https://gitlab.com/sat-mtl/tools/shmdata).
+ Follow the instructions to [install Shmdata](https://github.com/nicobou/shmdata/blob/develop/doc/install-from-sources.md).

git clone https://gitlab.com/sat-metalab/shmdata.git
mkdir shmdata-build
cd shmdata-build
cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr -DCMAKE_BUILD_TYPE=Release -DWITH_PYTHON=0 -DWITH_SDCRASH=0 -DWITH_SDFLOW=0 ../shmdata-build
cmake --build . --target package
sudo dpkg -i ./libshmdata_1.3*_amd64.deb

#### OSX with Brew

~$ brew install cmake libpng glfw gstreamer icu4c
brew install cmake libpng glfw gstreamer icu4c

2 changes: 2 additions & 0 deletions src/Settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ void Settings::Save(uint64_t runtime, const std::string &filename)
applicationNode->SetAttribute("broadcast_port", application.broadcast_port);
applicationNode->SetAttribute("loopback_camera", application.loopback_camera);
applicationNode->SetAttribute("shm_socket_path", application.shm_socket_path.c_str());
applicationNode->SetAttribute("shm_method", application.shm_method);
applicationNode->SetAttribute("accept_audio", application.accept_audio);
pRoot->InsertEndChild(applicationNode);

Expand Down Expand Up @@ -462,6 +463,7 @@ void Settings::Load(const string &filename)
applicationNode->QueryIntAttribute("broadcast_port", &application.broadcast_port);
applicationNode->QueryIntAttribute("loopback_camera", &application.loopback_camera);
applicationNode->QueryBoolAttribute("accept_audio", &application.accept_audio);
applicationNode->QueryIntAttribute("shm_method", &application.shm_method);

// text attributes
const char *tmpstr = applicationNode->Attribute("shm_socket_path");
Expand Down
5 changes: 4 additions & 1 deletion src/ShmdataBroadcast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ std::string ShmdataBroadcast::init(GstCaps *caps)

void ShmdataBroadcast::terminate()
{
// end src
gst_app_src_end_of_stream (src_);

// force finished
endofstream_ = true;
active_ = false;
Expand All @@ -188,9 +191,9 @@ std::string ShmdataBroadcast::gst_pipeline() const
pipeline += (method_ == SHM_SHMDATASINK) ? "shmdatasrc" : "shmsrc";
pipeline += " socket-path=";
pipeline += socket_path_;
pipeline += " is-live=true";

if (method_ == SHM_SHMSINK){
pipeline += " is-live=true";
pipeline += " ! ";
pipeline += std::string( gst_caps_to_string(caps_) );
pipeline = std::regex_replace(pipeline, std::regex("\\(int\\)"), "");
Expand Down
12 changes: 6 additions & 6 deletions src/UserInterfaceManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5772,24 +5772,24 @@ void Navigator::RenderMainPannelSettings()
ImFormatString(msg, IM_ARRAYSIZE(msg), "Shared Memory\n\n"
"vimix can share to RAM with "
"gstreamer default 'shmsink' "
"and with 'shmdatasink'.\n"
"and with 'shmdatasink'.\n\n"
"Socket file to connect to:\n%s\n",
_shm_socket_file.c_str());
}
else {
ImFormatString(msg, IM_ARRAYSIZE(msg), "Shared Memory\n\n"
"vimix can share to RAM with "
"gstreamer 'shmsink'.\n"
"gstreamer 'shmsink'.\n\n"
"Socket file to connect to:\n%s\n",
_shm_socket_file.c_str());
}
ImGuiToolkit::Indication(msg, ICON_FA_MEMORY);
ImGui::SameLine(0);
ImGui::SetCursorPosX(width_);
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
char bufsocket[64] = "";
snprintf(bufsocket, 64, "%s", Settings::application.shm_socket_path.c_str());
ImGui::InputTextWithHint("##SHM path", SystemToolkit::home_path().c_str(), bufsocket, 64);
char bufsocket[128] = "";
snprintf(bufsocket, 128, "%s", Settings::application.shm_socket_path.c_str());
ImGui::InputTextWithHint("##SHM path", SystemToolkit::home_path().c_str(), bufsocket, 128);
if (ImGui::IsItemDeactivatedAfterEdit()) {
Settings::application.shm_socket_path = bufsocket;
}
Expand All @@ -5799,7 +5799,7 @@ void Navigator::RenderMainPannelSettings()
if (ShmdataBroadcast::available(ShmdataBroadcast::SHM_SHMDATASINK)) {
ImGui::SetCursorPosX(width_);
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
ImGui::Combo("SHM plugin", &Settings::application.shm_method, "shmsink\0shmdatasink\0");
ImGui::Combo("SHM sink", &Settings::application.shm_method, "shmsink\0shmdatasink\0");
}
}

Expand Down

0 comments on commit 12bff7a

Please sign in to comment.