sink: Automatically draw black when going to NULL state

Remove all workarounds including ignore_textures prop and draw black functions and handle that automatically in sink when going into NULL state.
This commit is contained in:
Rafał Dzięgiel
2021-06-02 20:28:24 +02:00
parent 0b7f31b7c2
commit 8fc64eaf73
5 changed files with 14 additions and 53 deletions

View File

@@ -40,7 +40,6 @@ GST_DEBUG_CATEGORY (gst_debug_clapper_gl_sink);
#define DEFAULT_FORCE_ASPECT_RATIO TRUE #define DEFAULT_FORCE_ASPECT_RATIO TRUE
#define DEFAULT_PAR_N 0 #define DEFAULT_PAR_N 0
#define DEFAULT_PAR_D 1 #define DEFAULT_PAR_D 1
#define DEFAULT_IGNORE_TEXTURES FALSE
static GstStaticPadTemplate gst_clapper_gl_sink_template = static GstStaticPadTemplate gst_clapper_gl_sink_template =
GST_STATIC_PAD_TEMPLATE ("sink", GST_STATIC_PAD_TEMPLATE ("sink",
@@ -86,7 +85,6 @@ enum
PROP_WIDGET, PROP_WIDGET,
PROP_FORCE_ASPECT_RATIO, PROP_FORCE_ASPECT_RATIO,
PROP_PIXEL_ASPECT_RATIO, PROP_PIXEL_ASPECT_RATIO,
PROP_IGNORE_TEXTURES,
}; };
#define gst_clapper_gl_sink_parent_class parent_class #define gst_clapper_gl_sink_parent_class parent_class
@@ -133,11 +131,6 @@ gst_clapper_gl_sink_class_init (GstClapperGLSinkClass * klass)
"The pixel aspect ratio of the device", DEFAULT_PAR_N, DEFAULT_PAR_D, "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)); G_MAXINT, 1, 1, 1, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class, PROP_IGNORE_TEXTURES,
g_param_spec_boolean ("ignore-textures", "Ignore Textures",
"When enabled, textures will be ignored and not drawn",
DEFAULT_IGNORE_TEXTURES, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
gobject_class->finalize = gst_clapper_gl_sink_finalize; 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;
@@ -173,7 +166,6 @@ gst_clapper_gl_sink_init (GstClapperGLSink * clapper_sink)
clapper_sink->force_aspect_ratio = DEFAULT_FORCE_ASPECT_RATIO; clapper_sink->force_aspect_ratio = DEFAULT_FORCE_ASPECT_RATIO;
clapper_sink->par_n = DEFAULT_PAR_N; clapper_sink->par_n = DEFAULT_PAR_N;
clapper_sink->par_d = DEFAULT_PAR_D; clapper_sink->par_d = DEFAULT_PAR_D;
clapper_sink->ignore_textures = DEFAULT_IGNORE_TEXTURES;
} }
static void static void
@@ -242,9 +234,6 @@ gst_clapper_gl_sink_get_widget (GstClapperGLSink * clapper_sink)
clapper_sink->bind_pixel_aspect_ratio = clapper_sink->bind_pixel_aspect_ratio =
g_object_bind_property (clapper_sink, "pixel-aspect-ratio", clapper_sink->widget, g_object_bind_property (clapper_sink, "pixel-aspect-ratio", clapper_sink->widget,
"pixel-aspect-ratio", G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE); "pixel-aspect-ratio", G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
clapper_sink->bind_ignore_textures =
g_object_bind_property (clapper_sink, "ignore-textures", clapper_sink->widget,
"ignore-textures", G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
/* Take the floating ref, other wise the destruction of the container will /* Take the floating ref, other wise the destruction of the container will
* make this widget disappear possibly before we are done. */ * make this widget disappear possibly before we are done. */
@@ -290,9 +279,6 @@ gst_clapper_gl_sink_get_property (GObject * object, guint prop_id,
case PROP_PIXEL_ASPECT_RATIO: case PROP_PIXEL_ASPECT_RATIO:
gst_value_set_fraction (value, clapper_sink->par_n, clapper_sink->par_d); gst_value_set_fraction (value, clapper_sink->par_n, clapper_sink->par_d);
break; break;
case PROP_IGNORE_TEXTURES:
g_value_set_boolean (value, clapper_sink->ignore_textures);
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break; break;
@@ -313,9 +299,6 @@ gst_clapper_gl_sink_set_property (GObject * object, guint prop_id,
clapper_sink->par_n = gst_value_get_fraction_numerator (value); clapper_sink->par_n = gst_value_get_fraction_numerator (value);
clapper_sink->par_d = gst_value_get_fraction_denominator (value); clapper_sink->par_d = gst_value_get_fraction_denominator (value);
break; break;
case PROP_IGNORE_TEXTURES:
clapper_sink->ignore_textures = g_value_get_boolean (value);
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break; break;
@@ -606,12 +589,14 @@ gst_clapper_gl_sink_change_state (GstElement * element, GstStateChange transitio
switch (transition) { switch (transition) {
case GST_STATE_CHANGE_NULL_TO_READY: case GST_STATE_CHANGE_NULL_TO_READY:
GST_OBJECT_LOCK (clapper_sink); GST_OBJECT_LOCK (clapper_sink);
if (clapper_sink->widget) if (clapper_sink->widget) {
clapper_sink->widget->ignore_textures = FALSE; GTK_CLAPPER_GL_WIDGET_LOCK (clapper_sink->widget);
clapper_sink->widget->ignore_buffers = FALSE;
GTK_CLAPPER_GL_WIDGET_UNLOCK (clapper_sink->widget);
}
GST_OBJECT_UNLOCK (clapper_sink); GST_OBJECT_UNLOCK (clapper_sink);
break; break;
case GST_STATE_CHANGE_READY_TO_PAUSED: case GST_STATE_CHANGE_READY_TO_PAUSED:{
{
GtkWindow *window = NULL; GtkWindow *window = NULL;
GST_OBJECT_LOCK (clapper_sink); GST_OBJECT_LOCK (clapper_sink);
@@ -627,8 +612,11 @@ gst_clapper_gl_sink_change_state (GstElement * element, GstStateChange transitio
} }
case GST_STATE_CHANGE_READY_TO_NULL: case GST_STATE_CHANGE_READY_TO_NULL:
GST_OBJECT_LOCK (clapper_sink); GST_OBJECT_LOCK (clapper_sink);
if (clapper_sink->widget) if (clapper_sink->widget) {
clapper_sink->widget->ignore_textures = TRUE; GTK_CLAPPER_GL_WIDGET_LOCK (clapper_sink->widget);
clapper_sink->widget->ignore_buffers = TRUE;
GTK_CLAPPER_GL_WIDGET_UNLOCK (clapper_sink->widget);
}
GST_OBJECT_UNLOCK (clapper_sink); GST_OBJECT_UNLOCK (clapper_sink);
/* Fall through to render black bg */ /* Fall through to render black bg */
case GST_STATE_CHANGE_PAUSED_TO_READY: case GST_STATE_CHANGE_PAUSED_TO_READY:

View File

@@ -60,7 +60,6 @@ GST_DEBUG_CATEGORY (gst_debug_clapper_gl_widget);
#define DEFAULT_FORCE_ASPECT_RATIO TRUE #define DEFAULT_FORCE_ASPECT_RATIO TRUE
#define DEFAULT_PAR_N 0 #define DEFAULT_PAR_N 0
#define DEFAULT_PAR_D 1 #define DEFAULT_PAR_D 1
#define DEFAULT_IGNORE_TEXTURES FALSE
struct _GtkClapperGLWidgetPrivate struct _GtkClapperGLWidgetPrivate
{ {
@@ -100,7 +99,6 @@ enum
PROP_0, PROP_0,
PROP_FORCE_ASPECT_RATIO, PROP_FORCE_ASPECT_RATIO,
PROP_PIXEL_ASPECT_RATIO, PROP_PIXEL_ASPECT_RATIO,
PROP_IGNORE_TEXTURES,
}; };
static void static void
@@ -176,9 +174,6 @@ gtk_clapper_gl_widget_set_property (GObject * object, guint prop_id,
clapper_widget->par_n = gst_value_get_fraction_numerator (value); clapper_widget->par_n = gst_value_get_fraction_numerator (value);
clapper_widget->par_d = gst_value_get_fraction_denominator (value); clapper_widget->par_d = gst_value_get_fraction_denominator (value);
break; break;
case PROP_IGNORE_TEXTURES:
clapper_widget->ignore_textures = g_value_get_boolean (value);
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break; break;
@@ -198,9 +193,6 @@ gtk_clapper_gl_widget_get_property (GObject * object, guint prop_id,
case PROP_PIXEL_ASPECT_RATIO: case PROP_PIXEL_ASPECT_RATIO:
gst_value_set_fraction (value, clapper_widget->par_n, clapper_widget->par_d); gst_value_set_fraction (value, clapper_widget->par_n, clapper_widget->par_d);
break; break;
case PROP_IGNORE_TEXTURES:
g_value_set_boolean (value, clapper_widget->ignore_textures);
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break; break;
@@ -581,7 +573,7 @@ gtk_clapper_gl_widget_render (GtkGLArea * widget, GdkGLContext * context)
/* Draw black with GDK context when priv is not available yet. /* Draw black with GDK context when priv is not available yet.
GTK calls render with GDK context already active. */ GTK calls render with GDK context already active. */
if (!priv->context || !priv->other_context || clapper_widget->ignore_textures) { if (!priv->context || !priv->other_context || clapper_widget->ignore_buffers) {
_draw_black_with_gdk (context); _draw_black_with_gdk (context);
goto done; goto done;
} }
@@ -937,11 +929,6 @@ gtk_clapper_gl_widget_class_init (GtkClapperGLWidgetClass * klass)
"The pixel aspect ratio of the device", DEFAULT_PAR_N, DEFAULT_PAR_D, "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)); G_MAXINT, 1, 1, 1, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_klass, PROP_IGNORE_TEXTURES,
g_param_spec_boolean ("ignore-textures", "Ignore Textures",
"When enabled, textures will be ignored and not drawn",
DEFAULT_IGNORE_TEXTURES, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
widget_klass->measure = gtk_clapper_gl_widget_measure; widget_klass->measure = gtk_clapper_gl_widget_measure;
widget_klass->size_allocate = gtk_clapper_gl_widget_size_allocate; widget_klass->size_allocate = gtk_clapper_gl_widget_size_allocate;
@@ -958,7 +945,7 @@ gtk_clapper_gl_widget_init (GtkClapperGLWidget * clapper_widget)
clapper_widget->force_aspect_ratio = DEFAULT_FORCE_ASPECT_RATIO; clapper_widget->force_aspect_ratio = DEFAULT_FORCE_ASPECT_RATIO;
clapper_widget->par_n = DEFAULT_PAR_N; clapper_widget->par_n = DEFAULT_PAR_N;
clapper_widget->par_d = DEFAULT_PAR_D; clapper_widget->par_d = DEFAULT_PAR_D;
clapper_widget->ignore_textures = DEFAULT_IGNORE_TEXTURES; clapper_widget->ignore_buffers = FALSE;
clapper_widget->last_pos_x = 0; clapper_widget->last_pos_x = 0;
clapper_widget->last_pos_y = 0; clapper_widget->last_pos_y = 0;

View File

@@ -52,7 +52,6 @@ struct _GtkClapperGLWidget
/* properties */ /* properties */
gboolean force_aspect_ratio; gboolean force_aspect_ratio;
gint par_n, par_d; gint par_n, par_d;
gboolean ignore_textures;
gint display_width; gint display_width;
gint display_height; gint display_height;
@@ -66,6 +65,7 @@ struct _GtkClapperGLWidget
gdouble last_pos_y; gdouble last_pos_y;
gboolean negotiated; gboolean negotiated;
gboolean ignore_buffers;
GstBuffer *pending_buffer; GstBuffer *pending_buffer;
GstBuffer *buffer; GstBuffer *buffer;
GstVideoInfo v_info; GstVideoInfo v_info;

6
src/controls.js vendored
View File

@@ -247,9 +247,6 @@ class ClapperControls extends Gtk.Box
} }
if(checkButton.activeId < 0) { if(checkButton.activeId < 0) {
if(checkButton.type === 'video')
clapperWidget.player.draw_black(true);
return clapperWidget.player[ return clapperWidget.player[
`set_${checkButton.type}_track_enabled` `set_${checkButton.type}_track_enabled`
](false); ](false);
@@ -259,9 +256,6 @@ class ClapperControls extends Gtk.Box
clapperWidget.player[setTrack](checkButton.activeId); clapperWidget.player[setTrack](checkButton.activeId);
clapperWidget.player[`${setTrack}_enabled`](true); clapperWidget.player[`${setTrack}_enabled`](true);
if(checkButton.type === 'video')
clapperWidget.player.draw_black(false);
} }
_handleVisualizationChange(checkButton) _handleVisualizationChange(checkButton)

View File

@@ -133,14 +133,6 @@ class ClapperPlayer extends GstClapper.Clapper
debug(`changed rank: ${oldRank} -> ${rank} for ${name}`); debug(`changed rank: ${oldRank} -> ${rank} for ${name}`);
} }
draw_black(isEnabled)
{
this.widget.ignore_textures = isEnabled;
if(this.state !== GstClapper.ClapperState.PLAYING)
this.widget.queue_render();
}
set_uri(uri) set_uri(uri)
{ {
this.customVideoTitle = null; this.customVideoTitle = null;