mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-11 18:34:58 +01:00
Minor improvements in connection and IPC (multiple instances not fully
supported yet)
This commit is contained in:
@@ -61,6 +61,14 @@ bool Connection::init()
|
|||||||
std::thread(listen).detach();
|
std::thread(listen).detach();
|
||||||
// regularly check for available streaming hosts
|
// regularly check for available streaming hosts
|
||||||
std::thread(ask).detach();
|
std::thread(ask).detach();
|
||||||
|
|
||||||
|
// inform the application settings of our id
|
||||||
|
Settings::application.instance_id = connections_[0].port_handshake - HANDSHAKE_PORT;
|
||||||
|
// use or replace instance name from settings
|
||||||
|
if (Settings::application.instance_names.count(Settings::application.instance_id))
|
||||||
|
connections_[0].name = Settings::application.instance_names[Settings::application.instance_id];
|
||||||
|
else
|
||||||
|
Settings::application.instance_names[Settings::application.instance_id] = connections_[0].name;
|
||||||
// restore state of Streamer
|
// restore state of Streamer
|
||||||
Streaming::manager().enable( Settings::application.accept_connections );
|
Streaming::manager().enable( Settings::application.accept_connections );
|
||||||
|
|
||||||
@@ -78,8 +86,6 @@ void Connection::terminate()
|
|||||||
Streaming::manager().enable( false );
|
Streaming::manager().enable( false );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int Connection::numHosts () const
|
int Connection::numHosts () const
|
||||||
{
|
{
|
||||||
return connections_.size();
|
return connections_.size();
|
||||||
@@ -253,6 +259,10 @@ void ConnectionRequestListener::ProcessMessage( const osc::ReceivedMessage& m,
|
|||||||
if ( i < 0) {
|
if ( i < 0) {
|
||||||
// a new connection! Add to list
|
// a new connection! Add to list
|
||||||
Connection::manager().connections_.push_back(info);
|
Connection::manager().connections_.push_back(info);
|
||||||
|
// replace instance name in settings
|
||||||
|
int id = info.port_handshake - HANDSHAKE_PORT;
|
||||||
|
Settings::application.instance_names[id] = info.name;
|
||||||
|
|
||||||
#ifdef CONNECTION_DEBUG
|
#ifdef CONNECTION_DEBUG
|
||||||
Log::Info("List of connection updated:");
|
Log::Info("List of connection updated:");
|
||||||
Connection::manager().print();
|
Connection::manager().print();
|
||||||
|
|||||||
@@ -253,7 +253,6 @@ void NetworkStream::update()
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Log::Info("Connection rejected.");
|
Log::Info("Connection rejected.");
|
||||||
// failed_ = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,8 +77,8 @@ const std::vector<std::string> NetworkToolkit::protocol_send_pipeline {
|
|||||||
const std::vector<std::string> NetworkToolkit::protocol_receive_pipeline {
|
const std::vector<std::string> NetworkToolkit::protocol_receive_pipeline {
|
||||||
|
|
||||||
"shmsrc socket-path=XXXX ! video/x-raw, format=RGB, framerate=30/1 ! queue max-size-buffers=3",
|
"shmsrc socket-path=XXXX ! video/x-raw, format=RGB, framerate=30/1 ! queue max-size-buffers=3",
|
||||||
"udpsrc buffer-size=200000 port=XXXX ! application/x-rtp,encoding-name=JPEG,payload=26 ! queue max-size-buffers=3 ! rtpjpegdepay ! jpegdec",
|
"udpsrc buffer-size=200000 timeout=200000 port=XXXX ! application/x-rtp,encoding-name=JPEG,payload=26 ! queue max-size-buffers=3 ! rtpjitterbuffer ! rtpjpegdepay ! jpegdec",
|
||||||
"udpsrc buffer-size=200000 port=XXXX ! application/x-rtp,media=video,encoding-name=H264,payload=96,clock-rate=90000 ! queue max-size-buffers=3 ! rtph264depay ! avdec_h264",
|
"udpsrc buffer-size=200000 timeout=200000 port=XXXX ! application/x-rtp,encoding-name=H264,payload=96,clock-rate=90000 ! queue max-size-buffers=3 ! rtph264depay ! avdec_h264",
|
||||||
"tcpclientsrc timeout=1 port=XXXX ! queue max-size-buffers=3 ! application/x-rtp-stream,media=video,encoding-name=JPEG,payload=26 ! rtpstreamdepay ! rtpjpegdepay ! jpegdec",
|
"tcpclientsrc timeout=1 port=XXXX ! queue max-size-buffers=3 ! application/x-rtp-stream,media=video,encoding-name=JPEG,payload=26 ! rtpstreamdepay ! rtpjpegdepay ! jpegdec",
|
||||||
"tcpclientsrc timeout=1 port=XXXX ! queue max-size-buffers=3 ! application/x-rtp-stream,media=video,encoding-name=H264,payload=96,clock-rate=90000 ! rtpstreamdepay ! rtph264depay ! avdec_h264"
|
"tcpclientsrc timeout=1 port=XXXX ! queue max-size-buffers=3 ! application/x-rtp-stream,media=video,encoding-name=H264,payload=96,clock-rate=90000 ! rtpstreamdepay ! rtph264depay ! avdec_h264"
|
||||||
};
|
};
|
||||||
|
|||||||
31
Settings.cpp
31
Settings.cpp
@@ -107,6 +107,21 @@ void Settings::Save()
|
|||||||
SourceConfNode->SetAttribute("res", application.source.res);
|
SourceConfNode->SetAttribute("res", application.source.res);
|
||||||
pRoot->InsertEndChild(SourceConfNode);
|
pRoot->InsertEndChild(SourceConfNode);
|
||||||
|
|
||||||
|
// bloc connections
|
||||||
|
{
|
||||||
|
XMLElement *connectionsNode = xmlDoc.NewElement( "Connections" );
|
||||||
|
|
||||||
|
map<int, std::string>::iterator iter;
|
||||||
|
for (iter=application.instance_names.begin(); iter != application.instance_names.end(); iter++)
|
||||||
|
{
|
||||||
|
XMLElement *connection = xmlDoc.NewElement( "Instance" );
|
||||||
|
connection->SetAttribute("name", iter->second.c_str());
|
||||||
|
connection->SetAttribute("id", iter->first);
|
||||||
|
connectionsNode->InsertEndChild(connection);
|
||||||
|
}
|
||||||
|
pRoot->InsertEndChild(connectionsNode);
|
||||||
|
}
|
||||||
|
|
||||||
// bloc views
|
// bloc views
|
||||||
{
|
{
|
||||||
XMLElement *viewsNode = xmlDoc.NewElement( "Views" );
|
XMLElement *viewsNode = xmlDoc.NewElement( "Views" );
|
||||||
@@ -326,6 +341,22 @@ void Settings::Load()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// bloc Connections
|
||||||
|
{
|
||||||
|
XMLElement * pElement = pRoot->FirstChildElement("Connections");
|
||||||
|
if (pElement)
|
||||||
|
{
|
||||||
|
XMLElement* connectionNode = pElement->FirstChildElement("Instance");
|
||||||
|
for( ; connectionNode ; connectionNode=connectionNode->NextSiblingElement())
|
||||||
|
{
|
||||||
|
int id = 0;
|
||||||
|
connectionNode->QueryIntAttribute("id", &id);
|
||||||
|
application.instance_names[id] = connectionNode->Attribute("name");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// bloc history of recent
|
// bloc history of recent
|
||||||
{
|
{
|
||||||
XMLElement * pElement = pRoot->FirstChildElement("Recent");
|
XMLElement * pElement = pRoot->FirstChildElement("Recent");
|
||||||
|
|||||||
@@ -163,6 +163,7 @@ struct Application
|
|||||||
{
|
{
|
||||||
// instance check
|
// instance check
|
||||||
bool fresh_start;
|
bool fresh_start;
|
||||||
|
int instance_id;
|
||||||
|
|
||||||
// Verification
|
// Verification
|
||||||
std::string name;
|
std::string name;
|
||||||
@@ -175,7 +176,10 @@ struct Application
|
|||||||
bool smooth_transition;
|
bool smooth_transition;
|
||||||
bool smooth_cursor;
|
bool smooth_cursor;
|
||||||
bool action_history_follow_view;
|
bool action_history_follow_view;
|
||||||
|
|
||||||
|
// connection settings
|
||||||
bool accept_connections;
|
bool accept_connections;
|
||||||
|
std::map<int, std::string> instance_names;
|
||||||
|
|
||||||
// Settings of widgets
|
// Settings of widgets
|
||||||
WidgetsConfig widget;
|
WidgetsConfig widget;
|
||||||
|
|||||||
@@ -231,7 +231,7 @@ void Streaming::addStream(const std::string &sender, int reply_to, const std::st
|
|||||||
else {
|
else {
|
||||||
conf.protocol = NetworkToolkit::UDP_JPEG;
|
conf.protocol = NetworkToolkit::UDP_JPEG;
|
||||||
}
|
}
|
||||||
// conf.protocol = NetworkToolkit::UDP_JPEG; // force udp for testing
|
conf.protocol = NetworkToolkit::UDP_JPEG; // force udp for testing
|
||||||
|
|
||||||
// build OSC message
|
// build OSC message
|
||||||
char buffer[IP_MTU_SIZE];
|
char buffer[IP_MTU_SIZE];
|
||||||
|
|||||||
@@ -1213,13 +1213,15 @@ void UserInterface::RenderPreview()
|
|||||||
{
|
{
|
||||||
static char dummy_str[512];
|
static char dummy_str[512];
|
||||||
sprintf(dummy_str, "%s", Connection::manager().info().name.c_str());
|
sprintf(dummy_str, "%s", Connection::manager().info().name.c_str());
|
||||||
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
|
// ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
|
||||||
ImGui::InputText("Name", dummy_str, IM_ARRAYSIZE(dummy_str), ImGuiInputTextFlags_ReadOnly);
|
ImGui::InputText("Name", dummy_str, IM_ARRAYSIZE(dummy_str), ImGuiInputTextFlags_ReadOnly);
|
||||||
|
|
||||||
ImGui::Separator();
|
|
||||||
std::vector<std::string> ls = Streaming::manager().listStreams();
|
std::vector<std::string> ls = Streaming::manager().listStreams();
|
||||||
for (auto it = ls.begin(); it != ls.end(); it++)
|
if (ls.size()>0) {
|
||||||
ImGui::Text("%s", (*it).c_str() );
|
ImGui::Separator();
|
||||||
|
for (auto it = ls.begin(); it != ls.end(); it++)
|
||||||
|
ImGui::Text(" %s", (*it).c_str() );
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
ImGui::EndMenu();
|
ImGui::EndMenu();
|
||||||
|
|||||||
21
main.cpp
21
main.cpp
@@ -53,6 +53,12 @@ int main(int argc, char *argv[])
|
|||||||
/// lock to inform an instance is running
|
/// lock to inform an instance is running
|
||||||
Settings::Lock();
|
Settings::Lock();
|
||||||
|
|
||||||
|
///
|
||||||
|
/// CONNECTION INIT
|
||||||
|
///
|
||||||
|
if ( !Connection::manager().init() )
|
||||||
|
return 1;
|
||||||
|
|
||||||
///
|
///
|
||||||
/// RENDERING INIT
|
/// RENDERING INIT
|
||||||
///
|
///
|
||||||
@@ -65,10 +71,6 @@ int main(int argc, char *argv[])
|
|||||||
if ( !UserInterface::manager().Init() )
|
if ( !UserInterface::manager().Init() )
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
|
||||||
if ( !Connection::manager().init() )
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// GStreamer
|
/// GStreamer
|
||||||
///
|
///
|
||||||
@@ -99,8 +101,6 @@ int main(int argc, char *argv[])
|
|||||||
Rendering::manager().draw();
|
Rendering::manager().draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
Connection::manager().terminate();
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// UI TERMINATE
|
/// UI TERMINATE
|
||||||
///
|
///
|
||||||
@@ -112,13 +112,18 @@ int main(int argc, char *argv[])
|
|||||||
Rendering::manager().terminate();
|
Rendering::manager().terminate();
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Settings
|
/// CONNECTION TERMINATE
|
||||||
///
|
///
|
||||||
Settings::Save();
|
Connection::manager().terminate();
|
||||||
|
|
||||||
/// unlock on clean exit
|
/// unlock on clean exit
|
||||||
Settings::Unlock();
|
Settings::Unlock();
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Settings
|
||||||
|
///
|
||||||
|
Settings::Save();
|
||||||
|
|
||||||
/// ok
|
/// ok
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user