From 2b6f0404a7305ac5e1006ac280906e0be3c09e47 Mon Sep 17 00:00:00 2001 From: Philippe Normand Date: Sun, 29 Aug 2021 10:30:53 +0100 Subject: [PATCH] wpevideosrc: Implement basic heuristic for raw caps negotiation Before this patch raw caps could be negotiated already with a capsfilter, but in cases where wpesrc is being auto-plugged this approach can't be used. Part-of: --- ext/wpe/gstwpevideosrc.cpp | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/ext/wpe/gstwpevideosrc.cpp b/ext/wpe/gstwpevideosrc.cpp index 0bab056..9b00d78 100644 --- a/ext/wpe/gstwpevideosrc.cpp +++ b/ext/wpe/gstwpevideosrc.cpp @@ -140,22 +140,22 @@ GST_DEBUG_CATEGORY_EXTERN (wpe_video_src_debug); #define gst_wpe_video_src_parent_class parent_class G_DEFINE_TYPE(GstWpeVideoSrc, gst_wpe_video_src, GST_TYPE_GL_BASE_SRC); -#define WPE_RAW_CAPS "; video/x-raw, " \ +#define WPE_RAW_CAPS "video/x-raw, " \ "format = (string) BGRA, " \ "width = " GST_VIDEO_SIZE_RANGE ", " \ "height = " GST_VIDEO_SIZE_RANGE ", " \ "framerate = " GST_VIDEO_FPS_RANGE ", " \ "pixel-aspect-ratio = (fraction)1/1" -#define WPE_BASIC_CAPS "video/x-raw(memory:GLMemory), " \ +#define WPE_GL_CAPS "video/x-raw(memory:GLMemory), " \ "format = (string) RGBA, " \ "width = " GST_VIDEO_SIZE_RANGE ", " \ "height = " GST_VIDEO_SIZE_RANGE ", " \ "framerate = " GST_VIDEO_FPS_RANGE ", " \ "pixel-aspect-ratio = (fraction)1/1, texture-target = (string)2D" -#define WPE_VIDEO_SRC_CAPS WPE_BASIC_CAPS WPE_RAW_CAPS -#define WPE_VIDEO_SRC_DOC_CAPS WPE_BASIC_CAPS "; video/x-raw, format = (string) BGRA" +#define WPE_VIDEO_SRC_CAPS WPE_GL_CAPS "; " WPE_RAW_CAPS +#define WPE_VIDEO_SRC_DOC_CAPS WPE_GL_CAPS "; video/x-raw, format = (string) BGRA" static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src", GST_PAD_SRC, @@ -373,13 +373,24 @@ gst_wpe_video_src_stop (GstBaseSrc * base_src) } static GstCaps * -gst_wpe_video_src_fixate (GstBaseSrc * base_src, GstCaps * caps) +gst_wpe_video_src_fixate (GstBaseSrc * base_src, GstCaps * combined_caps) { GstWpeVideoSrc *src = GST_WPE_VIDEO_SRC (base_src); GstStructure *structure; gint width, height; + GstCaps *caps; + + /* In situation where software GL support is explicitly requested, select raw + * caps, otherwise perform default caps negotiation. Unfortunately at this + * point we don't know yet if a GL context will be usable or not, so we can't + * check the element GstContext. + */ + if (!g_strcmp0 (g_getenv ("LIBGL_ALWAYS_SOFTWARE"), "true")) { + caps = gst_caps_from_string (WPE_RAW_CAPS); + } else { + caps = gst_caps_make_writable (combined_caps); + } - caps = gst_caps_make_writable (caps); structure = gst_caps_get_structure (caps, 0); gst_structure_fixate_field_nearest_int (structure, "width", DEFAULT_WIDTH); -- 2.7.4