mirror of
https://github.com/Rafostar/clapper.git
synced 2025-08-29 23:32:04 +02:00
sink: Avoid props code duplication
This commit is contained in:
@@ -37,10 +37,6 @@
|
|||||||
GST_DEBUG_CATEGORY (gst_debug_clapper_gl_sink);
|
GST_DEBUG_CATEGORY (gst_debug_clapper_gl_sink);
|
||||||
#define GST_CAT_DEFAULT gst_debug_clapper_gl_sink
|
#define GST_CAT_DEFAULT gst_debug_clapper_gl_sink
|
||||||
|
|
||||||
#define DEFAULT_FORCE_ASPECT_RATIO TRUE
|
|
||||||
#define DEFAULT_PAR_N 0
|
|
||||||
#define DEFAULT_PAR_D 1
|
|
||||||
|
|
||||||
static GstStaticPadTemplate gst_clapper_gl_sink_template =
|
static GstStaticPadTemplate gst_clapper_gl_sink_template =
|
||||||
GST_STATIC_PAD_TEMPLATE ("sink",
|
GST_STATIC_PAD_TEMPLATE ("sink",
|
||||||
GST_PAD_SINK,
|
GST_PAD_SINK,
|
||||||
@@ -79,14 +75,6 @@ static GstFlowReturn gst_clapper_gl_sink_show_frame (GstVideoSink * bsink,
|
|||||||
static void
|
static void
|
||||||
gst_clapper_gl_sink_navigation_interface_init (GstNavigationInterface * iface);
|
gst_clapper_gl_sink_navigation_interface_init (GstNavigationInterface * iface);
|
||||||
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
PROP_0,
|
|
||||||
PROP_WIDGET,
|
|
||||||
PROP_FORCE_ASPECT_RATIO,
|
|
||||||
PROP_PIXEL_ASPECT_RATIO,
|
|
||||||
};
|
|
||||||
|
|
||||||
#define gst_clapper_gl_sink_parent_class parent_class
|
#define gst_clapper_gl_sink_parent_class parent_class
|
||||||
G_DEFINE_TYPE_WITH_CODE (GstClapperGLSink, gst_clapper_gl_sink,
|
G_DEFINE_TYPE_WITH_CODE (GstClapperGLSink, gst_clapper_gl_sink,
|
||||||
GST_TYPE_VIDEO_SINK,
|
GST_TYPE_VIDEO_SINK,
|
||||||
@@ -112,6 +100,7 @@ gst_clapper_gl_sink_class_init (GstClapperGLSinkClass * klass)
|
|||||||
|
|
||||||
gobject_class->set_property = gst_clapper_gl_sink_set_property;
|
gobject_class->set_property = gst_clapper_gl_sink_set_property;
|
||||||
gobject_class->get_property = gst_clapper_gl_sink_get_property;
|
gobject_class->get_property = gst_clapper_gl_sink_get_property;
|
||||||
|
gobject_class->finalize = gst_clapper_gl_sink_finalize;
|
||||||
|
|
||||||
g_object_class_install_property (gobject_class, PROP_WIDGET,
|
g_object_class_install_property (gobject_class, PROP_WIDGET,
|
||||||
g_param_spec_object ("widget", "GTK Widget",
|
g_param_spec_object ("widget", "GTK Widget",
|
||||||
@@ -119,19 +108,7 @@ gst_clapper_gl_sink_class_init (GstClapperGLSinkClass * klass)
|
|||||||
"(must only be get from the GTK main thread)",
|
"(must only be get from the GTK main thread)",
|
||||||
GTK_TYPE_WIDGET, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
GTK_TYPE_WIDGET, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
||||||
|
|
||||||
g_object_class_install_property (gobject_class, PROP_FORCE_ASPECT_RATIO,
|
gst_gtk_install_shared_properties (gobject_class);
|
||||||
g_param_spec_boolean ("force-aspect-ratio",
|
|
||||||
"Force aspect ratio",
|
|
||||||
"When enabled, scaling will respect original aspect ratio",
|
|
||||||
DEFAULT_FORCE_ASPECT_RATIO,
|
|
||||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
|
||||||
|
|
||||||
g_object_class_install_property (gobject_class, PROP_PIXEL_ASPECT_RATIO,
|
|
||||||
gst_param_spec_fraction ("pixel-aspect-ratio", "Pixel Aspect Ratio",
|
|
||||||
"The pixel aspect ratio of the device", DEFAULT_PAR_N, DEFAULT_PAR_D,
|
|
||||||
G_MAXINT, 1, 1, 1, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
|
||||||
|
|
||||||
gobject_class->finalize = gst_clapper_gl_sink_finalize;
|
|
||||||
|
|
||||||
gstelement_class->change_state = gst_clapper_gl_sink_change_state;
|
gstelement_class->change_state = gst_clapper_gl_sink_change_state;
|
||||||
|
|
||||||
|
@@ -19,6 +19,7 @@
|
|||||||
* Boston, MA 02110-1301, USA.
|
* Boston, MA 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <gst/gst.h>
|
||||||
#include "gstgtkutils.h"
|
#include "gstgtkutils.h"
|
||||||
|
|
||||||
struct invoke_context
|
struct invoke_context
|
||||||
@@ -69,3 +70,19 @@ gst_gtk_invoke_on_main (GThreadFunc func, gpointer data)
|
|||||||
|
|
||||||
return info.res;
|
return info.res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gst_gtk_install_shared_properties (GObjectClass *gobject_class)
|
||||||
|
{
|
||||||
|
g_object_class_install_property (gobject_class, PROP_FORCE_ASPECT_RATIO,
|
||||||
|
g_param_spec_boolean ("force-aspect-ratio",
|
||||||
|
"Force aspect ratio",
|
||||||
|
"When enabled, scaling will respect original aspect ratio",
|
||||||
|
DEFAULT_FORCE_ASPECT_RATIO,
|
||||||
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||||
|
|
||||||
|
g_object_class_install_property (gobject_class, PROP_PIXEL_ASPECT_RATIO,
|
||||||
|
gst_param_spec_fraction ("pixel-aspect-ratio", "Pixel Aspect Ratio",
|
||||||
|
"The pixel aspect ratio of the device", DEFAULT_PAR_N, DEFAULT_PAR_D,
|
||||||
|
G_MAXINT, 1, 1, 1, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||||
|
}
|
||||||
|
@@ -22,8 +22,23 @@
|
|||||||
#ifndef __GST_GTK_UTILS_H__
|
#ifndef __GST_GTK_UTILS_H__
|
||||||
#define __GST_GTK_UTILS_H__
|
#define __GST_GTK_UTILS_H__
|
||||||
|
|
||||||
|
#define DEFAULT_FORCE_ASPECT_RATIO TRUE
|
||||||
|
#define DEFAULT_PAR_N 0
|
||||||
|
#define DEFAULT_PAR_D 1
|
||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
#include <glib-object.h>
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
PROP_0,
|
||||||
|
PROP_WIDGET,
|
||||||
|
PROP_FORCE_ASPECT_RATIO,
|
||||||
|
PROP_PIXEL_ASPECT_RATIO,
|
||||||
|
};
|
||||||
|
|
||||||
gpointer gst_gtk_invoke_on_main (GThreadFunc func, gpointer data);
|
gpointer gst_gtk_invoke_on_main (GThreadFunc func, gpointer data);
|
||||||
|
|
||||||
|
void gst_gtk_install_shared_properties (GObjectClass *gobject_class);
|
||||||
|
|
||||||
#endif /* __GST_GTK_UTILS_H__ */
|
#endif /* __GST_GTK_UTILS_H__ */
|
||||||
|
@@ -57,10 +57,6 @@
|
|||||||
GST_DEBUG_CATEGORY (gst_debug_clapper_gl_widget);
|
GST_DEBUG_CATEGORY (gst_debug_clapper_gl_widget);
|
||||||
#define GST_CAT_DEFAULT gst_debug_clapper_gl_widget
|
#define GST_CAT_DEFAULT gst_debug_clapper_gl_widget
|
||||||
|
|
||||||
#define DEFAULT_FORCE_ASPECT_RATIO TRUE
|
|
||||||
#define DEFAULT_PAR_N 0
|
|
||||||
#define DEFAULT_PAR_D 1
|
|
||||||
|
|
||||||
struct _GtkClapperGLWidgetPrivate
|
struct _GtkClapperGLWidgetPrivate
|
||||||
{
|
{
|
||||||
gboolean initiated;
|
gboolean initiated;
|
||||||
@@ -94,13 +90,6 @@ G_DEFINE_TYPE_WITH_CODE (GtkClapperGLWidget, gtk_clapper_gl_widget, GTK_TYPE_GL_
|
|||||||
GST_DEBUG_CATEGORY_INIT (GST_CAT_DEFAULT, "gtkclapperglwidget", 0,
|
GST_DEBUG_CATEGORY_INIT (GST_CAT_DEFAULT, "gtkclapperglwidget", 0,
|
||||||
"GTK Clapper GL Widget"));
|
"GTK Clapper GL Widget"));
|
||||||
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
PROP_0,
|
|
||||||
PROP_FORCE_ASPECT_RATIO,
|
|
||||||
PROP_PIXEL_ASPECT_RATIO,
|
|
||||||
};
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_clapper_gl_widget_get_preferred_width (GtkWidget * widget, gint * min,
|
gtk_clapper_gl_widget_get_preferred_width (GtkWidget * widget, gint * min,
|
||||||
gint * natural)
|
gint * natural)
|
||||||
@@ -909,30 +898,20 @@ _get_gl_context (GtkClapperGLWidget * clapper_widget)
|
|||||||
static void
|
static void
|
||||||
gtk_clapper_gl_widget_class_init (GtkClapperGLWidgetClass * klass)
|
gtk_clapper_gl_widget_class_init (GtkClapperGLWidgetClass * klass)
|
||||||
{
|
{
|
||||||
GObjectClass *gobject_klass = (GObjectClass *) klass;
|
GObjectClass *gobject_class = (GObjectClass *) klass;
|
||||||
GtkWidgetClass *widget_klass = (GtkWidgetClass *) klass;
|
GtkWidgetClass *widget_class = (GtkWidgetClass *) klass;
|
||||||
GtkGLAreaClass *gl_area_klass = (GtkGLAreaClass *) klass;
|
GtkGLAreaClass *gl_area_class = (GtkGLAreaClass *) klass;
|
||||||
|
|
||||||
gobject_klass->set_property = gtk_clapper_gl_widget_set_property;
|
gobject_class->set_property = gtk_clapper_gl_widget_set_property;
|
||||||
gobject_klass->get_property = gtk_clapper_gl_widget_get_property;
|
gobject_class->get_property = gtk_clapper_gl_widget_get_property;
|
||||||
gobject_klass->finalize = gtk_clapper_gl_widget_finalize;
|
gobject_class->finalize = gtk_clapper_gl_widget_finalize;
|
||||||
|
|
||||||
g_object_class_install_property (gobject_klass, PROP_FORCE_ASPECT_RATIO,
|
gst_gtk_install_shared_properties (gobject_class);
|
||||||
g_param_spec_boolean ("force-aspect-ratio",
|
|
||||||
"Force aspect ratio",
|
|
||||||
"When enabled, scaling will respect original aspect ratio",
|
|
||||||
DEFAULT_FORCE_ASPECT_RATIO,
|
|
||||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
|
||||||
|
|
||||||
g_object_class_install_property (gobject_klass, PROP_PIXEL_ASPECT_RATIO,
|
widget_class->measure = gtk_clapper_gl_widget_measure;
|
||||||
gst_param_spec_fraction ("pixel-aspect-ratio", "Pixel Aspect Ratio",
|
widget_class->size_allocate = gtk_clapper_gl_widget_size_allocate;
|
||||||
"The pixel aspect ratio of the device", DEFAULT_PAR_N, DEFAULT_PAR_D,
|
|
||||||
G_MAXINT, 1, 1, 1, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
|
||||||
|
|
||||||
widget_klass->measure = gtk_clapper_gl_widget_measure;
|
gl_area_class->render = gtk_clapper_gl_widget_render;
|
||||||
widget_klass->size_allocate = gtk_clapper_gl_widget_size_allocate;
|
|
||||||
|
|
||||||
gl_area_klass->render = gtk_clapper_gl_widget_render;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Reference in New Issue
Block a user