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 gint video_par_n, video_par_d; 51 gboolean ignore_alpha; 52 53 gint display_width; 54 gint display_height; 55 56 gboolean negotiated; 57 GstBuffer *pending_buffer; 58 GstBuffer *buffer; 59 GstVideoInfo v_info; 60 61 /* resize */ 62 gboolean pending_resize; 63 GstVideoInfo pending_v_info; 64 guint display_ratio_num; 65 guint display_ratio_den; 66 67 /*< private >*/ 68 GMutex lock; 69 GWeakRef element; 70 71 /* Pending draw idles callback */ 72 guint draw_id; 73 }; 74 75 struct _GtkGstBaseWidgetClass 76 { 77 union { 78 GtkDrawingAreaClass drawing_area_class; 79 #if GTK_CHECK_VERSION(3, 15, 0) 80 GtkGLAreaClass gl_area_class; 81 #endif 82 } parent_class; 83 }; 84 85 /* For implementer */ 86 void gtk_gst_base_widget_class_init (GtkGstBaseWidgetClass * klass); 87 void gtk_gst_base_widget_init (GtkGstBaseWidget * widget); 88 89 void gtk_gst_base_widget_finalize (GObject * object); 90 91 /* API */ 92 gboolean gtk_gst_base_widget_set_format (GtkGstBaseWidget * widget, GstVideoInfo * v_info); 93 void gtk_gst_base_widget_set_buffer (GtkGstBaseWidget * widget, GstBuffer * buffer); 94 void gtk_gst_base_widget_queue_draw (GtkGstBaseWidget * widget); 95 void gtk_gst_base_widget_set_element (GtkGstBaseWidget * widget, GstElement * element); 96 void gtk_gst_base_widget_display_size_to_stream_size (GtkGstBaseWidget * base_widget, 97 gdouble x, gdouble y, 98 gdouble * stream_x, gdouble * stream_y); 99 100 G_END_DECLS 101 102 #endif /* __GTK_GST_BASE_WIDGET_H__ */ 103