mirror of
git://nv-tegra.nvidia.com/tegra/gst-src/libgstnvvideosinks.git
synced 2025-12-22 09:22:49 +03:00
Updating prebuilts and/or headers
da5475c4506f0f70011e5723f4f3e1e7368a0554 - nvbufsurface.h 9a172f748a2b8f4d6d15648ea353989ccc7aeba6 - gst-plugins-nv-video-sinks/Makefile 9825d8a113dbf7dd16f791ff1ca66f2de3047b22 - gst-plugins-nv-video-sinks/LICENSE.libgstnvvideosinks 7ef56486c9e6b3e354473a2959d274517dd709da - gst-plugins-nv-video-sinks/gstnvvideosinks.c de3e1e648709f765fbe78b5c365017f573ca1988 - gst-plugins-nv-video-sinks/common/context.c b38008a552820bac7742888cd4bc2610bca722eb - gst-plugins-nv-video-sinks/common/display.c 3b014cb69f5042fd9752fd4bf06a5873fe08b41c - gst-plugins-nv-video-sinks/common/renderer.c 96b0b4d38692a0aecf70944749684ac938ff192f - gst-plugins-nv-video-sinks/common/display.h 6e77d54ffc5d1a49d5bad768cdf5cfadf458f1f7 - gst-plugins-nv-video-sinks/common/window.h d48e1dae85e3c6a0ba7623be7ee306b8e1ef6695 - gst-plugins-nv-video-sinks/common/gstnvvideofwd.h 835dc89a20f2a95bea9c4033e40bf6787148ab08 - gst-plugins-nv-video-sinks/common/window.c 72f9a4b823c4162c9f22cedb7c1cb1764d06fcb6 - gst-plugins-nv-video-sinks/common/renderer.h 5e13200e9cba5f45d74cf6899dd3356d5f5d1c8e - gst-plugins-nv-video-sinks/common/context.h 638b0da4ea65d02818289e89bc1d635ddbcdaec5 - gst-plugins-nv-video-sinks/common/x11/window_x11.h b3f1b67cae0b4643f6a676b362ceaa61abc9c40f - gst-plugins-nv-video-sinks/common/x11/display_x11.c d692399c6d94dbc7814770b08baf9271ed97f8e0 - gst-plugins-nv-video-sinks/common/x11/display_x11.h c98945083e215dff26507c1e10b0ebf62a2c6fb7 - gst-plugins-nv-video-sinks/common/x11/window_x11.c 536a072a8ef84b3c91307777f88121fb88df2c4f - gst-plugins-nv-video-sinks/common/egl/context_egl.h ad6be303e104ee7fbe2845a7697bc39e575a3e52 - gst-plugins-nv-video-sinks/common/egl/context_egl.c 707a36267f329bb22afdd19b947be5a99478ec7a - gst-plugins-nv-video-sinks/common/renderer/renderer_gl.c f528404a796de5a23dab281588feb72f42343e59 - gst-plugins-nv-video-sinks/common/renderer/renderer_gl.h 9b7125a2d7ebe2ea647c43d2eb43e8d04cd16c47 - gst-plugins-nv-video-sinks/nv3dsink/gstnv3dsink.h f8cd771fc3695e957a02665e9eb1a1c6fb9b0572 - gst-plugins-nv-video-sinks/nv3dsink/gstnv3dsink.c Change-Id: I134b1430c8464c60910e39aa4929e4b769639c51
This commit is contained in:
157
gst-plugins-nv-video-sinks/common/x11/window_x11.c
Normal file
157
gst-plugins-nv-video-sinks/common/x11/window_x11.c
Normal file
@@ -0,0 +1,157 @@
|
||||
/**
|
||||
* Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
|
||||
*
|
||||
* NVIDIA Corporation and its licensors retain all intellectual property
|
||||
* and proprietary rights in and to this software, related documentation
|
||||
* and any modifications thereto. Any use, reproduction, disclosure or
|
||||
* distribution of this software and related documentation without an express
|
||||
* license agreement from NVIDIA Corporation is strictly prohibited.
|
||||
*/
|
||||
|
||||
#include "context.h"
|
||||
#include "display_x11.h"
|
||||
#include "window_x11.h"
|
||||
#include <X11/Xutil.h>
|
||||
|
||||
G_GNUC_INTERNAL extern GstDebugCategory *gst_debug_nv_video_window;
|
||||
#define GST_CAT_DEFAULT gst_debug_nv_video_window
|
||||
|
||||
#define gst_nv_video_window_x11_parent_class parent_class
|
||||
G_DEFINE_TYPE (GstNvVideoWindowX11, gst_nv_video_window_x11,
|
||||
GST_TYPE_NV_VIDEO_WINDOW);
|
||||
|
||||
static void
|
||||
gst_nv_video_window_x11_destroy (GstNvVideoWindow * window)
|
||||
{
|
||||
GstNvVideoWindowX11 *window_x11 = GST_NV_VIDEO_WINDOW_X11 (window);
|
||||
GstNvVideoDisplayX11 *display_x11 = (GstNvVideoDisplayX11 *) window->display;
|
||||
|
||||
if (window_x11->internal_window) {
|
||||
GST_DEBUG_OBJECT (window, "destroy internal window %" G_GUINTPTR_FORMAT,
|
||||
window_x11->handle);
|
||||
|
||||
XUnmapWindow (display_x11->dpy, window_x11->handle);
|
||||
XDestroyWindow (display_x11->dpy, window_x11->handle);
|
||||
XSync (display_x11->dpy, FALSE);
|
||||
window_x11->internal_window = FALSE;
|
||||
window_x11->handle = 0;
|
||||
} else {
|
||||
GST_DEBUG_OBJECT (window, "unset foreign window handle %" G_GUINTPTR_FORMAT,
|
||||
window_x11->handle);
|
||||
window_x11->handle = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gst_nv_video_window_x11_finalize (GObject * object)
|
||||
{
|
||||
GstNvVideoWindow *window = GST_NV_VIDEO_WINDOW (object);
|
||||
|
||||
GST_DEBUG_OBJECT (window, "finalize begin");
|
||||
|
||||
gst_nv_video_window_x11_destroy (window);
|
||||
|
||||
G_OBJECT_CLASS (gst_nv_video_window_x11_parent_class)->finalize (object);
|
||||
|
||||
GST_DEBUG_OBJECT (window, "finalize end");
|
||||
}
|
||||
|
||||
static guintptr
|
||||
gst_nv_video_window_x11_get_handle (GstNvVideoWindow * window)
|
||||
{
|
||||
GstNvVideoWindowX11 *window_x11 = GST_NV_VIDEO_WINDOW_X11 (window);
|
||||
|
||||
return window_x11->handle;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_nv_video_window_x11_set_handle (GstNvVideoWindow * window, guintptr id)
|
||||
{
|
||||
GstNvVideoWindowX11 *window_x11 = GST_NV_VIDEO_WINDOW_X11 (window);
|
||||
|
||||
gst_nv_video_window_x11_destroy (window);
|
||||
window_x11->handle = id;
|
||||
|
||||
GST_DEBUG_OBJECT (window, "set window handle to %" G_GUINTPTR_FORMAT, id);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_nv_video_window_x11_create (GstNvVideoWindow * window, gint x,
|
||||
gint y, gint width, gint height)
|
||||
{
|
||||
GstNvVideoWindowX11 *window_x11 = GST_NV_VIDEO_WINDOW_X11 (window);
|
||||
GstNvVideoDisplayX11 *display_x11 = (GstNvVideoDisplayX11 *) window->display;
|
||||
Display *dpy = display_x11->dpy;
|
||||
int screen = DefaultScreen (dpy);
|
||||
|
||||
XSizeHints hints = {0};
|
||||
hints.flags = PPosition ;
|
||||
hints.x = x;
|
||||
hints.y = y;
|
||||
// GstNvVideoWindow doesn't have destroy_winow method (like create_window)
|
||||
// and GstNvVideoWindow object can't have multiple X windows. So if
|
||||
// upper layer has existing window (foreign or internal), unset/destroy it.
|
||||
//
|
||||
// TODO: In case of existing internal window, we might able to re-use it
|
||||
// with XResizeWindow.
|
||||
gst_nv_video_window_x11_destroy (window);
|
||||
|
||||
window_x11->handle = XCreateSimpleWindow (dpy, RootWindow (dpy, screen),
|
||||
hints.x, hints.y, width, height, 1,
|
||||
BlackPixel (dpy, screen), WhitePixel (dpy, screen));
|
||||
|
||||
if (!window_x11->handle) {
|
||||
GST_ERROR_OBJECT (window, "failed to create internal window\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
window_x11->internal_window = TRUE;
|
||||
|
||||
XSetWindowBackgroundPixmap (dpy, window_x11->handle, None);
|
||||
XSetNormalHints(dpy, window_x11->handle, &hints);
|
||||
XMapRaised (dpy, window_x11->handle);
|
||||
XSync (dpy, FALSE);
|
||||
|
||||
GST_DEBUG_OBJECT (window,
|
||||
"created internal window %dx%d, handle=%" G_GUINTPTR_FORMAT, width,
|
||||
height, window_x11->handle);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_nv_video_window_x11_class_init (GstNvVideoWindowX11Class * klass)
|
||||
{
|
||||
GstNvVideoWindowClass *window_class = (GstNvVideoWindowClass *) klass;
|
||||
|
||||
window_class->create_window =
|
||||
GST_DEBUG_FUNCPTR (gst_nv_video_window_x11_create);
|
||||
window_class->get_handle =
|
||||
GST_DEBUG_FUNCPTR (gst_nv_video_window_x11_get_handle);
|
||||
window_class->set_handle =
|
||||
GST_DEBUG_FUNCPTR (gst_nv_video_window_x11_set_handle);
|
||||
|
||||
G_OBJECT_CLASS (klass)->finalize = gst_nv_video_window_x11_finalize;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_nv_video_window_x11_init (GstNvVideoWindowX11 * window)
|
||||
{
|
||||
window->handle = 0;
|
||||
window->internal_window = FALSE;
|
||||
|
||||
GST_DEBUG_OBJECT (window, "init done");
|
||||
}
|
||||
|
||||
GstNvVideoWindowX11 *
|
||||
gst_nv_video_window_x11_new (const gchar * name)
|
||||
{
|
||||
GstNvVideoWindowX11 *ret;
|
||||
|
||||
ret = g_object_new (GST_TYPE_NV_VIDEO_WINDOW_X11, NULL);
|
||||
gst_object_ref_sink (ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
Reference in New Issue
Block a user