gboolean gtk_gst_widget_set_caps (GtkGstWidget * widget, GstCaps * caps) { GMainContext *main_context = g_main_context_default (); GstVideoInfo v_info; g_return_val_if_fail (GTK_IS_GST_WIDGET (widget), FALSE); g_return_val_if_fail (GST_IS_CAPS (caps), FALSE); g_return_val_if_fail (gst_caps_is_fixed (caps), FALSE); if (widget->priv->caps && gst_caps_is_equal_fixed (widget->priv->caps, caps)) return TRUE; if (!gst_video_info_from_caps (&v_info, caps)) return FALSE; /* FIXME: support other formats */ #if G_BYTE_ORDER == G_LITTLE_ENDIAN g_return_val_if_fail (GST_VIDEO_INFO_FORMAT (&v_info) == GST_VIDEO_FORMAT_BGRA || GST_VIDEO_INFO_FORMAT (&v_info) == GST_VIDEO_FORMAT_BGRx, FALSE); #else g_return_val_if_fail (GST_VIDEO_INFO_FORMAT (&v_info) == GST_VIDEO_FORMAT_ARGB || GST_VIDEO_INFO_FORMAT (&v_info) == GST_VIDEO_FORMAT_xRGB, FALSE); #endif g_mutex_lock (&widget->priv->lock); if (!_calculate_par (widget, &v_info)) { g_mutex_unlock (&widget->priv->lock); return FALSE; } gst_caps_replace (&widget->priv->caps, caps); widget->priv->v_info = v_info; widget->priv->negotiated = TRUE; g_mutex_unlock (&widget->priv->lock); gtk_widget_queue_resize (GTK_WIDGET (widget)); g_main_context_invoke (main_context, (GSourceFunc) _queue_resize, widget); return TRUE; }
gboolean gtk_gst_base_widget_set_format (GtkGstBaseWidget * widget, GstVideoInfo * v_info) { GTK_GST_BASE_WIDGET_LOCK (widget); if (gst_video_info_is_equal (&widget->v_info, v_info)) { GTK_GST_BASE_WIDGET_UNLOCK (widget); return TRUE; } if (!_calculate_par (widget, v_info)) { GTK_GST_BASE_WIDGET_UNLOCK (widget); return FALSE; } widget->pending_resize = TRUE; widget->pending_v_info = *v_info; GTK_GST_BASE_WIDGET_UNLOCK (widget); return TRUE; }