mirror of
git://nv-tegra.nvidia.com/tegra/gst-src/libgstnvvideosinks.git
synced 2025-12-22 09:22:49 +03:00
2d40637e04ba1be9b48393f71bed54b09590ab0d - nvbufsurface.h c3f21bd4363243ad1bca5b1d434b5896402eec14 - nvbuf_utils.h 9a172f748a2b8f4d6d15648ea353989ccc7aeba6 - gst-plugins-nv-video-sinks/Makefile 7ef56486c9e6b3e354473a2959d274517dd709da - gst-plugins-nv-video-sinks/gstnvvideosinks.c 9825d8a113dbf7dd16f791ff1ca66f2de3047b22 - gst-plugins-nv-video-sinks/LICENSE.libgstnvvideosinks f8cd771fc3695e957a02665e9eb1a1c6fb9b0572 - gst-plugins-nv-video-sinks/nv3dsink/gstnv3dsink.c 9b7125a2d7ebe2ea647c43d2eb43e8d04cd16c47 - gst-plugins-nv-video-sinks/nv3dsink/gstnv3dsink.h 5e13200e9cba5f45d74cf6899dd3356d5f5d1c8e - gst-plugins-nv-video-sinks/common/context.h ad360a668f0f494ebd2bb630c3faaf93078c6e0d - gst-plugins-nv-video-sinks/common/window.c 72f9a4b823c4162c9f22cedb7c1cb1764d06fcb6 - gst-plugins-nv-video-sinks/common/renderer.h fcb1b73054a1c8ff8ce614878ee46880273656f4 - gst-plugins-nv-video-sinks/common/renderer.c 4f86ed5c7d6dfa6e6e4df4fd2945993655fc3409 - gst-plugins-nv-video-sinks/common/context.c d48e1dae85e3c6a0ba7623be7ee306b8e1ef6695 - gst-plugins-nv-video-sinks/common/gstnvvideofwd.h a0debde9b0fd5bc6ac9c5fac7f1a14745a2b0617 - gst-plugins-nv-video-sinks/common/display.c 96b0b4d38692a0aecf70944749684ac938ff192f - gst-plugins-nv-video-sinks/common/display.h 6e77d54ffc5d1a49d5bad768cdf5cfadf458f1f7 - gst-plugins-nv-video-sinks/common/window.h 638b0da4ea65d02818289e89bc1d635ddbcdaec5 - gst-plugins-nv-video-sinks/common/x11/window_x11.h d692399c6d94dbc7814770b08baf9271ed97f8e0 - gst-plugins-nv-video-sinks/common/x11/display_x11.h b3f1b67cae0b4643f6a676b362ceaa61abc9c40f - gst-plugins-nv-video-sinks/common/x11/display_x11.c c98945083e215dff26507c1e10b0ebf62a2c6fb7 - gst-plugins-nv-video-sinks/common/x11/window_x11.c f528404a796de5a23dab281588feb72f42343e59 - gst-plugins-nv-video-sinks/common/renderer/renderer_gl.h 707a36267f329bb22afdd19b947be5a99478ec7a - gst-plugins-nv-video-sinks/common/renderer/renderer_gl.c 570146fa5ab1969a0283f0f844bbcb90c71f24ed - gst-plugins-nv-video-sinks/common/egl/context_egl.c 536a072a8ef84b3c91307777f88121fb88df2c4f - gst-plugins-nv-video-sinks/common/egl/context_egl.h Change-Id: I0d186b38613c2e294d1d3b0bb4173113534203e1
126 lines
3.4 KiB
C
126 lines
3.4 KiB
C
/*
|
|
* Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
|
|
*
|
|
* This library is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
* License, version 2.1, as published by the Free Software Foundation.
|
|
*
|
|
* This library is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
* Lesser General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
* License along with this program. If not, see
|
|
* <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#include "window.h"
|
|
|
|
#if NV_VIDEO_SINKS_HAS_X11
|
|
#include "window_x11.h"
|
|
#endif
|
|
|
|
#define GST_CAT_DEFAULT gst_debug_nv_video_window
|
|
GST_DEBUG_CATEGORY (GST_CAT_DEFAULT);
|
|
|
|
#define gst_nv_video_window_parent_class parent_class
|
|
G_DEFINE_ABSTRACT_TYPE (GstNvVideoWindow, gst_nv_video_window, GST_TYPE_OBJECT);
|
|
|
|
static void
|
|
gst_nv_video_window_finalize (GObject * object)
|
|
{
|
|
GstNvVideoWindow *window = GST_NV_VIDEO_WINDOW (object);
|
|
|
|
g_weak_ref_clear (&window->context);
|
|
gst_object_unref (window->display);
|
|
|
|
G_OBJECT_CLASS (gst_nv_video_window_parent_class)->finalize (object);
|
|
}
|
|
|
|
static void
|
|
gst_nv_video_window_init (GstNvVideoWindow * window)
|
|
{
|
|
g_weak_ref_init (&window->context, NULL);
|
|
}
|
|
|
|
static void
|
|
gst_nv_video_window_class_init (GstNvVideoWindowClass * klass)
|
|
{
|
|
G_OBJECT_CLASS (klass)->finalize = gst_nv_video_window_finalize;
|
|
}
|
|
|
|
GstNvVideoWindow *
|
|
gst_nv_video_window_new (GstNvVideoDisplay * display)
|
|
{
|
|
GstNvVideoWindow *window = NULL;
|
|
static volatile gsize debug_init = 0;
|
|
const gchar *winsys_name = NULL;
|
|
|
|
if (g_once_init_enter (&debug_init)) {
|
|
GST_DEBUG_CATEGORY_INIT (gst_debug_nv_video_window, "nvvideowindow", 0,
|
|
"nvvideowindow");
|
|
g_once_init_leave (&debug_init, 1);
|
|
}
|
|
|
|
winsys_name = g_getenv ("GST_NV_VIDEO_WINSYS");
|
|
|
|
#if NV_VIDEO_SINKS_HAS_X11
|
|
if (!window && (!winsys_name || g_strstr_len (winsys_name, 3, "x11"))) {
|
|
window = GST_NV_VIDEO_WINDOW (gst_nv_video_window_x11_new (NULL));
|
|
}
|
|
#endif
|
|
|
|
if (!window) {
|
|
GST_ERROR ("couldn't create window. GST_NV_VIDEO_WINSYS = %s",
|
|
winsys_name ? winsys_name : NULL);
|
|
return NULL;
|
|
}
|
|
|
|
window->display = gst_object_ref (display);
|
|
|
|
GST_DEBUG_OBJECT (window, "created window for display %" GST_PTR_FORMAT,
|
|
display);
|
|
|
|
return window;
|
|
}
|
|
|
|
/* create new window handle after destroying existing */
|
|
gboolean
|
|
gst_nv_video_window_create_window (GstNvVideoWindow * window, gint x,
|
|
gint y, gint width, gint height)
|
|
{
|
|
GstNvVideoWindowClass *window_class;
|
|
|
|
window_class = GST_NV_VIDEO_WINDOW_GET_CLASS (window);
|
|
|
|
return window_class->create_window (window, x, y, width, height);
|
|
}
|
|
|
|
gboolean
|
|
gst_nv_video_window_set_handle (GstNvVideoWindow * window, guintptr id)
|
|
{
|
|
GstNvVideoWindowClass *window_class;
|
|
|
|
window_class = GST_NV_VIDEO_WINDOW_GET_CLASS (window);
|
|
|
|
return window_class->set_handle (window, id);
|
|
}
|
|
|
|
guintptr
|
|
gst_nv_video_window_get_handle (GstNvVideoWindow * window)
|
|
{
|
|
GstNvVideoWindowClass *window_class;
|
|
window_class = GST_NV_VIDEO_WINDOW_GET_CLASS (window);
|
|
|
|
return window_class->get_handle (window);
|
|
}
|
|
|
|
GstNvVideoContext *
|
|
gst_nv_video_window_get_context (GstNvVideoWindow * window)
|
|
{
|
|
g_return_val_if_fail (GST_IS_NV_VIDEO_WINDOW (window), NULL);
|
|
|
|
return (GstNvVideoContext *) g_weak_ref_get (&window->context);
|
|
}
|