mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-12 10:49:59 +01:00
Compilation defines to cleanup old code
This commit is contained in:
@@ -14,6 +14,7 @@ using namespace std;
|
|||||||
#include "SystemToolkit.h"
|
#include "SystemToolkit.h"
|
||||||
#include "GlmToolkit.h"
|
#include "GlmToolkit.h"
|
||||||
#include "GstToolkit.h"
|
#include "GstToolkit.h"
|
||||||
|
#include "RenderingManager.h"
|
||||||
|
|
||||||
#include "MediaPlayer.h"
|
#include "MediaPlayer.h"
|
||||||
|
|
||||||
@@ -78,12 +79,15 @@ guint MediaPlayer::texture() const
|
|||||||
return textureindex_;
|
return textureindex_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define LIMIT_DISCOVERER
|
||||||
|
|
||||||
static MediaInfo UriDiscoverer_(std::string uri)
|
static MediaInfo UriDiscoverer_(std::string uri)
|
||||||
{
|
{
|
||||||
#ifdef MEDIA_PLAYER_DEBUG
|
#ifdef MEDIA_PLAYER_DEBUG
|
||||||
Log::Info("Checking file '%s'", uri.c_str());
|
Log::Info("Checking file '%s'", uri.c_str());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef LIMIT_DISCOVERER
|
||||||
// Limiting the number of discoverer thread to TWO in parallel
|
// Limiting the number of discoverer thread to TWO in parallel
|
||||||
// Otherwise, a large number of discoverers are executed (when loading a file)
|
// Otherwise, a large number of discoverers are executed (when loading a file)
|
||||||
// leading to a peak of memory and CPU usage : this causes slow down of FPS
|
// leading to a peak of memory and CPU usage : this causes slow down of FPS
|
||||||
@@ -95,7 +99,7 @@ static MediaInfo UriDiscoverer_(std::string uri)
|
|||||||
use_primary = false;
|
use_primary = false;
|
||||||
mtx_secondary.lock(); // blocking
|
mtx_secondary.lock(); // blocking
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
MediaInfo video_stream_info;
|
MediaInfo video_stream_info;
|
||||||
GError *err = NULL;
|
GError *err = NULL;
|
||||||
GstDiscoverer *discoverer = gst_discoverer_new (15 * GST_SECOND, &err);
|
GstDiscoverer *discoverer = gst_discoverer_new (15 * GST_SECOND, &err);
|
||||||
@@ -203,11 +207,12 @@ static MediaInfo UriDiscoverer_(std::string uri)
|
|||||||
|
|
||||||
g_clear_error (&err);
|
g_clear_error (&err);
|
||||||
|
|
||||||
|
#ifdef LIMIT_DISCOVERER
|
||||||
if (use_primary)
|
if (use_primary)
|
||||||
mtx_primary.unlock();
|
mtx_primary.unlock();
|
||||||
else
|
else
|
||||||
mtx_secondary.unlock();
|
mtx_secondary.unlock();
|
||||||
|
#endif
|
||||||
// return the info
|
// return the info
|
||||||
return video_stream_info;
|
return video_stream_info;
|
||||||
}
|
}
|
||||||
@@ -367,8 +372,10 @@ void MediaPlayer::execute_open()
|
|||||||
}
|
}
|
||||||
gst_caps_unref (caps);
|
gst_caps_unref (caps);
|
||||||
|
|
||||||
|
#ifdef USE_GST_OPENGL_SYNC_HANDLER
|
||||||
// capture bus signals to force a unique opengl context for all GST elements
|
// capture bus signals to force a unique opengl context for all GST elements
|
||||||
//Rendering::LinkPipeline(GST_PIPELINE (pipeline));
|
Rendering::LinkPipeline(GST_PIPELINE (pipeline_));
|
||||||
|
#endif
|
||||||
|
|
||||||
// set to desired state (PLAY or PAUSE)
|
// set to desired state (PLAY or PAUSE)
|
||||||
GstStateChangeReturn ret = gst_element_set_state (pipeline_, desired_state_);
|
GstStateChangeReturn ret = gst_element_set_state (pipeline_, desired_state_);
|
||||||
|
|||||||
@@ -50,10 +50,56 @@
|
|||||||
#include "UserInterfaceManager.h"
|
#include "UserInterfaceManager.h"
|
||||||
#include "RenderingManager.h"
|
#include "RenderingManager.h"
|
||||||
|
|
||||||
// local statics
|
#ifdef USE_GST_OPENGL_SYNC_HANDLER
|
||||||
|
//
|
||||||
|
// Discarded because not working under OSX - kept in case it would become useful
|
||||||
|
//
|
||||||
|
// Linking pipeline to the rendering instance ensures the opengl contexts
|
||||||
|
// created by gstreamer inside plugins (e.g. glsinkbin) is the same
|
||||||
|
//
|
||||||
static GstGLContext *global_gl_context = NULL;
|
static GstGLContext *global_gl_context = NULL;
|
||||||
static GstGLDisplay *global_display = NULL;
|
static GstGLDisplay *global_display = NULL;
|
||||||
|
|
||||||
|
static GstBusSyncReply bus_sync_handler( GstBus *, GstMessage * msg, gpointer )
|
||||||
|
{
|
||||||
|
if (GST_MESSAGE_TYPE(msg) == GST_MESSAGE_NEED_CONTEXT) {
|
||||||
|
const gchar* contextType;
|
||||||
|
gst_message_parse_context_type(msg, &contextType);
|
||||||
|
|
||||||
|
if (!g_strcmp0(contextType, GST_GL_DISPLAY_CONTEXT_TYPE)) {
|
||||||
|
GstContext *displayContext = gst_context_new(GST_GL_DISPLAY_CONTEXT_TYPE, TRUE);
|
||||||
|
gst_context_set_gl_display(displayContext, global_display);
|
||||||
|
gst_element_set_context(GST_ELEMENT(msg->src), displayContext);
|
||||||
|
gst_context_unref (displayContext);
|
||||||
|
|
||||||
|
g_info ("Managed %s\n", contextType);
|
||||||
|
}
|
||||||
|
if (!g_strcmp0(contextType, "gst.gl.app_context")) {
|
||||||
|
GstContext *appContext = gst_context_new("gst.gl.app_context", TRUE);
|
||||||
|
GstStructure* structure = gst_context_writable_structure(appContext);
|
||||||
|
gst_structure_set(structure, "context", GST_TYPE_GL_CONTEXT, global_gl_context, nullptr);
|
||||||
|
gst_element_set_context(GST_ELEMENT(msg->src), appContext);
|
||||||
|
gst_context_unref (appContext);
|
||||||
|
|
||||||
|
g_info ("Managed %s\n", contextType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
gst_message_unref (msg);
|
||||||
|
|
||||||
|
return GST_BUS_DROP;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Rendering::LinkPipeline( GstPipeline *pipeline )
|
||||||
|
{
|
||||||
|
// capture bus signals to force a unique opengl context for all GST elements
|
||||||
|
GstBus* m_bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
|
||||||
|
gst_bus_set_sync_handler (m_bus, (GstBusSyncHandler) bus_sync_handler, pipeline, NULL);
|
||||||
|
gst_object_unref (m_bus);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
static std::map<GLFWwindow *, RenderingWindow*> GLFW_window_;
|
static std::map<GLFWwindow *, RenderingWindow*> GLFW_window_;
|
||||||
|
|
||||||
static void glfw_error_callback(int error, const char* description)
|
static void glfw_error_callback(int error, const char* description)
|
||||||
@@ -168,24 +214,24 @@ bool Rendering::init()
|
|||||||
Log::Info("No GPU decoding plugin found.");
|
Log::Info("No GPU decoding plugin found.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#ifdef SYNC_GSTREAMER_OPENGL_CONTEXT
|
||||||
|
#if GST_GL_HAVE_PLATFORM_WGL
|
||||||
|
global_gl_context = gst_gl_context_new_wrapped (display, (guintptr) wglGetCurrentContext (),
|
||||||
|
GST_GL_PLATFORM_WGL, GST_GL_API_OPENGL);
|
||||||
|
#elif GST_GL_HAVE_PLATFORM_CGL
|
||||||
|
// global_display = GST_GL_DISPLAY ( glfwGetCocoaMonitor(main_.window()) );
|
||||||
|
global_display = GST_GL_DISPLAY (gst_gl_display_cocoa_new ());
|
||||||
|
|
||||||
//#if GST_GL_HAVE_PLATFORM_WGL
|
global_gl_context = gst_gl_context_new_wrapped (global_display,
|
||||||
// global_gl_context = gst_gl_context_new_wrapped (display, (guintptr) wglGetCurrentContext (),
|
(guintptr) 0,
|
||||||
// GST_GL_PLATFORM_WGL, GST_GL_API_OPENGL);
|
GST_GL_PLATFORM_CGL, GST_GL_API_OPENGL);
|
||||||
//#elif GST_GL_HAVE_PLATFORM_CGL
|
#elif GST_GL_HAVE_PLATFORM_GLX
|
||||||
//// global_display = GST_GL_DISPLAY ( glfwGetCocoaMonitor(main_.window()) );
|
global_display = (GstGLDisplay*) gst_gl_display_x11_new_with_display( glfwGetX11Display() );
|
||||||
// global_display = GST_GL_DISPLAY (gst_gl_display_cocoa_new ());
|
global_gl_context = gst_gl_context_new_wrapped (global_display,
|
||||||
|
(guintptr) glfwGetGLXContext(main_.window()),
|
||||||
// global_gl_context = gst_gl_context_new_wrapped (global_display,
|
GST_GL_PLATFORM_GLX, GST_GL_API_OPENGL);
|
||||||
// (guintptr) 0,
|
#endif
|
||||||
// GST_GL_PLATFORM_CGL, GST_GL_API_OPENGL);
|
#endif
|
||||||
//#elif GST_GL_HAVE_PLATFORM_GLX
|
|
||||||
// global_display = (GstGLDisplay*) gst_gl_display_x11_new_with_display( glfwGetX11Display() );
|
|
||||||
// global_gl_context = gst_gl_context_new_wrapped (global_display,
|
|
||||||
// (guintptr) glfwGetGLXContext(main_.window()),
|
|
||||||
// GST_GL_PLATFORM_GLX, GST_GL_API_OPENGL);
|
|
||||||
//#endif
|
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// output window
|
// output window
|
||||||
@@ -847,55 +893,3 @@ void RenderingWindow::draw(FrameBuffer *fb)
|
|||||||
glfwMakeContextCurrent(master_);
|
glfwMakeContextCurrent(master_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// Discarded because not working under OSX - kept in case it would become useful
|
|
||||||
//
|
|
||||||
// Linking pipeline to the rendering instance ensures the opengl contexts
|
|
||||||
// created by gstreamer inside plugins (e.g. glsinkbin) is the same
|
|
||||||
//
|
|
||||||
|
|
||||||
static GstBusSyncReply
|
|
||||||
bus_sync_handler (GstBus *, GstMessage * msg, gpointer )
|
|
||||||
{
|
|
||||||
if (GST_MESSAGE_TYPE(msg) == GST_MESSAGE_NEED_CONTEXT) {
|
|
||||||
const gchar* contextType;
|
|
||||||
gst_message_parse_context_type(msg, &contextType);
|
|
||||||
|
|
||||||
if (!g_strcmp0(contextType, GST_GL_DISPLAY_CONTEXT_TYPE)) {
|
|
||||||
GstContext *displayContext = gst_context_new(GST_GL_DISPLAY_CONTEXT_TYPE, TRUE);
|
|
||||||
gst_context_set_gl_display(displayContext, global_display);
|
|
||||||
gst_element_set_context(GST_ELEMENT(msg->src), displayContext);
|
|
||||||
gst_context_unref (displayContext);
|
|
||||||
|
|
||||||
g_info ("Managed %s\n", contextType);
|
|
||||||
}
|
|
||||||
if (!g_strcmp0(contextType, "gst.gl.app_context")) {
|
|
||||||
GstContext *appContext = gst_context_new("gst.gl.app_context", TRUE);
|
|
||||||
GstStructure* structure = gst_context_writable_structure(appContext);
|
|
||||||
gst_structure_set(structure, "context", GST_TYPE_GL_CONTEXT, global_gl_context, nullptr);
|
|
||||||
gst_element_set_context(GST_ELEMENT(msg->src), appContext);
|
|
||||||
gst_context_unref (appContext);
|
|
||||||
|
|
||||||
g_info ("Managed %s\n", contextType);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
gst_message_unref (msg);
|
|
||||||
|
|
||||||
return GST_BUS_DROP;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Rendering::LinkPipeline( GstPipeline *pipeline )
|
|
||||||
{
|
|
||||||
// capture bus signals to force a unique opengl context for all GST elements
|
|
||||||
GstBus* m_bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
|
|
||||||
gst_bus_set_sync_handler (m_bus, (GstBusSyncHandler) bus_sync_handler, pipeline, NULL);
|
|
||||||
gst_object_unref (m_bus);
|
|
||||||
|
|
||||||
|
|
||||||
// GstBus* m_bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
|
|
||||||
// gst_bus_enable_sync_message_emission (m_bus);
|
|
||||||
// g_signal_connect (m_bus, "sync-message", G_CALLBACK (bus_sync_handler), pipeline);
|
|
||||||
// gst_object_unref (m_bus);
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
#include "Screenshot.h"
|
#include "Screenshot.h"
|
||||||
|
|
||||||
|
//#define USE_GST_OPENGL_SYNC_HANDLER
|
||||||
|
|
||||||
typedef struct GLFWmonitor GLFWmonitor;
|
typedef struct GLFWmonitor GLFWmonitor;
|
||||||
typedef struct GLFWwindow GLFWwindow;
|
typedef struct GLFWwindow GLFWwindow;
|
||||||
@@ -143,6 +144,11 @@ public:
|
|||||||
// project from scene coordinate to window
|
// project from scene coordinate to window
|
||||||
glm::vec2 project(glm::vec3 scene_coordinate, glm::mat4 modelview = glm::mat4(1.f), bool to_framebuffer = true);
|
glm::vec2 project(glm::vec3 scene_coordinate, glm::mat4 modelview = glm::mat4(1.f), bool to_framebuffer = true);
|
||||||
|
|
||||||
|
#ifdef USE_GST_OPENGL_SYNC_HANDLER
|
||||||
|
// for opengl pipeline in gstreamer
|
||||||
|
static void LinkPipeline( GstPipeline *pipeline );
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
std::string glsl_version;
|
std::string glsl_version;
|
||||||
@@ -162,8 +168,6 @@ private:
|
|||||||
Screenshot screenshot_;
|
Screenshot screenshot_;
|
||||||
bool request_screenshot_;
|
bool request_screenshot_;
|
||||||
|
|
||||||
// for opengl pipeline in gstreamer
|
|
||||||
void LinkPipeline( GstPipeline *pipeline );
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user