1 /* GStreamer 2 * Copyright (C) 2009 Carl-Anton Ingmarsson <ca.ingmarsson@gmail.com> 3 * Copyright (C) 2005 Julien Moutte <julien@moutte.net> 4 * 5 * This library is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU Library General Public 7 * License as published by the Free Software Foundation; either 8 * version 2 of the License, or (at your option) any later version. 9 * 10 * This library is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * Library General Public License for more details. 14 * 15 * You should have received a copy of the GNU Library General Public 16 * License along with this library; if not, write to the 17 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, 18 * Boston, MA 02110-1301, USA. 19 */ 20 21 #ifndef __GST_VDP_SINK_H__ 22 #define __GST_VDP_SINK_H__ 23 24 #include <gst/video/gstvideosink.h> 25 26 #include <X11/Xlib.h> 27 #include <X11/Xutil.h> 28 29 #include <string.h> 30 #include <math.h> 31 32 #include "gstvdpdevice.h" 33 34 G_BEGIN_DECLS 35 36 #define GST_TYPE_VDP_SINK \ 37 (gst_vdp_sink_get_type()) 38 #define GST_VDP_SINK(obj) \ 39 (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_VDP_SINK, VdpSink)) 40 #define GST_VDP_SINK_CLASS(klass) \ 41 (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_VDP_SINK, VdpSinkClass)) 42 #define GST_IS_VDP_SINK(obj) \ 43 (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_VDP_SINK)) 44 #define GST_IS_VDP_SINK_CLASS(klass) \ 45 (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_VDP_SINK)) 46 47 typedef struct _GstXContext GstXContext; 48 typedef struct _GstVdpWindow GstVdpWindow; 49 50 typedef struct _VdpSink VdpSink; 51 typedef struct _VdpSinkClass VdpSinkClass; 52 53 /* 54 * GstVdpWindow: 55 * @win: the Window ID of this X11 window 56 * @target the VdpPresentationQueueTarget of this window 57 * @queue the VdpPresentationQueue of this window 58 * @width: the width in pixels of Window @win 59 * @height: the height in pixels of Window @win 60 * @internal: used to remember if Window @win was created internally or passed 61 * through the #GstXOverlay interface 62 * 63 * Structure used to store informations about a Window. 64 */ 65 struct _GstVdpWindow { 66 Window win; 67 VdpPresentationQueueTarget target; 68 VdpPresentationQueue queue; 69 gint width, height; 70 gboolean internal; 71 }; 72 73 /** 74 * VdpSink: 75 * @display_name: the name of the Display we want to render to 76 * @device: the GstVdpDevice associated with the display_name 77 * @window: the #GstVdpWindow we are rendering to 78 * @cur_image: a reference to the last #GstBuffer that was put to @window. It 79 * is used when Expose events are received to redraw the latest video frame 80 * @event_thread: a thread listening for events on @window and handling them 81 * @running: used to inform @event_thread if it should run/shutdown 82 * @fps_n: the framerate fraction numerator 83 * @fps_d: the framerate fraction denominator 84 * @x_lock: used to protect X calls as we are not using the XLib in threaded 85 * mode 86 * @flow_lock: used to protect data flow routines from external calls such as 87 * events from @event_thread or methods from the #GstXOverlay interface 88 * @par: used to override calculated pixel aspect ratio from @xcontext 89 * @synchronous: used to store if XSynchronous should be used or not (for 90 * debugging purpose only) 91 * @handle_events: used to know if we should handle select XEvents or not 92 * 93 * The #VdpSink data structure. 94 */ 95 struct _VdpSink { 96 /* Our element stuff */ 97 GstVideoSink videosink; 98 99 char *display_name; 100 101 GstVdpDevice *device; 102 GstBufferPool *bpool; 103 GstCaps *caps; 104 105 GstVdpWindow *window; 106 GstBuffer *cur_image; 107 108 GThread *event_thread; 109 gboolean running; 110 111 /* Framerate numerator and denominator */ 112 gint fps_n; 113 gint fps_d; 114 115 GMutex *device_lock; 116 GMutex *x_lock; 117 GMutex *flow_lock; 118 119 /* object-set pixel aspect ratio */ 120 GValue *par; 121 122 gboolean synchronous; 123 gboolean handle_events; 124 gboolean handle_expose; 125 126 /* stream metadata */ 127 gchar *media_title; 128 }; 129 130 struct _VdpSinkClass { 131 GstVideoSinkClass parent_class; 132 }; 133 134 GType gst_vdp_sink_get_type(void); 135 136 G_END_DECLS 137 138 #endif /* __GST_VDP_SINK_H__ */ 139