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: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2498>
This commit is contained in:
Philippe Normand 2021-08-29 10:30:53 +01:00 committed by GStreamer Marge Bot
parent edc04df13c
commit 2b6f0404a7

View file

@ -140,22 +140,22 @@ GST_DEBUG_CATEGORY_EXTERN (wpe_video_src_debug);
#define gst_wpe_video_src_parent_class parent_class #define gst_wpe_video_src_parent_class parent_class
G_DEFINE_TYPE(GstWpeVideoSrc, gst_wpe_video_src, GST_TYPE_GL_BASE_SRC); 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, " \ "format = (string) BGRA, " \
"width = " GST_VIDEO_SIZE_RANGE ", " \ "width = " GST_VIDEO_SIZE_RANGE ", " \
"height = " GST_VIDEO_SIZE_RANGE ", " \ "height = " GST_VIDEO_SIZE_RANGE ", " \
"framerate = " GST_VIDEO_FPS_RANGE ", " \ "framerate = " GST_VIDEO_FPS_RANGE ", " \
"pixel-aspect-ratio = (fraction)1/1" "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, " \ "format = (string) RGBA, " \
"width = " GST_VIDEO_SIZE_RANGE ", " \ "width = " GST_VIDEO_SIZE_RANGE ", " \
"height = " GST_VIDEO_SIZE_RANGE ", " \ "height = " GST_VIDEO_SIZE_RANGE ", " \
"framerate = " GST_VIDEO_FPS_RANGE ", " \ "framerate = " GST_VIDEO_FPS_RANGE ", " \
"pixel-aspect-ratio = (fraction)1/1, texture-target = (string)2D" "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_CAPS WPE_GL_CAPS "; " WPE_RAW_CAPS
#define WPE_VIDEO_SRC_DOC_CAPS WPE_BASIC_CAPS "; video/x-raw, format = (string) BGRA" #define WPE_VIDEO_SRC_DOC_CAPS WPE_GL_CAPS "; video/x-raw, format = (string) BGRA"
static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src", static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC, GST_PAD_SRC,
@ -373,13 +373,24 @@ gst_wpe_video_src_stop (GstBaseSrc * base_src)
} }
static GstCaps * 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); GstWpeVideoSrc *src = GST_WPE_VIDEO_SRC (base_src);
GstStructure *structure; GstStructure *structure;
gint width, height; 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); structure = gst_caps_get_structure (caps, 0);
gst_structure_fixate_field_nearest_int (structure, "width", DEFAULT_WIDTH); gst_structure_fixate_field_nearest_int (structure, "width", DEFAULT_WIDTH);