gtk: implement GstNavigation interface
[platform/upstream/gst-plugins-good.git] / ext / gtk / gtkgstbasewidget.h
1 /*
2  * GStreamer
3  * Copyright (C) 2015 Matthew Waters <matthew@centricular.com>
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 __GTK_GST_BASE_WIDGET_H__
22 #define __GTK_GST_BASE_WIDGET_H__
23
24 #include <gtk/gtk.h>
25 #include <gst/gst.h>
26 #include <gst/video/video.h>
27
28 #define GTK_GST_BASE_WIDGET(w)         ((GtkGstBaseWidget *)(w))
29 #define GTK_GST_BASE_WIDGET_CLASS(k)   ((GtkGstBaseWidgetClass *)(k))
30 #define GTK_GST_BASE_WIDGET_LOCK(w)    g_mutex_lock(&((GtkGstBaseWidget*)(w))->lock)
31 #define GTK_GST_BASE_WIDGET_UNLOCK(w)  g_mutex_unlock(&((GtkGstBaseWidget*)(w))->lock)
32
33 G_BEGIN_DECLS
34
35 typedef struct _GtkGstBaseWidget GtkGstBaseWidget;
36 typedef struct _GtkGstBaseWidgetClass GtkGstBaseWidgetClass;
37
38 struct _GtkGstBaseWidget
39 {
40   union {
41     GtkDrawingArea drawing_area;
42 #if GTK_CHECK_VERSION(3, 15, 0)
43     GtkGLArea gl_area;
44 #endif
45   } parent;
46
47   /* properties */
48   gboolean force_aspect_ratio;
49   gint par_n, par_d;
50   gboolean ignore_alpha;
51
52   gint display_width;
53   gint display_height;
54
55   gboolean negotiated;
56   GstBuffer *buffer;
57   GstVideoInfo v_info;
58   gboolean new_buffer;
59
60   /* resize */
61   gboolean pending_resize;
62   GstVideoInfo pending_v_info;
63   guint display_ratio_num;
64   guint display_ratio_den;
65
66   /* Poor-man virtual */
67   void (*reset) (GtkGstBaseWidget * widget);
68
69   /*< private >*/
70   GMutex lock;
71   GWeakRef element;
72
73   /* Pending draw idles callback */
74   guint draw_id;
75 };
76
77 struct _GtkGstBaseWidgetClass
78 {
79   union {
80     GtkDrawingAreaClass drawing_area_class;
81 #if GTK_CHECK_VERSION(3, 15, 0)
82     GtkGLAreaClass gl_area_class;
83 #endif
84   } parent_class;
85 };
86
87 /* For implementer */
88 void            gtk_gst_base_widget_class_init           (GtkGstBaseWidgetClass * klass);
89 void            gtk_gst_base_widget_init                 (GtkGstBaseWidget * widget);
90
91 void            gtk_gst_base_widget_finalize             (GObject * object);
92
93 /* API */
94 gboolean        gtk_gst_base_widget_set_format           (GtkGstBaseWidget * widget, GstVideoInfo * v_info);
95 void            gtk_gst_base_widget_set_buffer           (GtkGstBaseWidget * widget, GstBuffer * buffer);
96 void            gtk_gst_base_widget_set_element          (GtkGstBaseWidget * widget, GstElement * element);
97
98 G_END_DECLS
99
100 #endif /* __GTK_GST_BASE_WIDGET_H__ */