mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-19 16:21:17 +00:00
wpe: Make forwarded messages layout more like GstBinForwaded messages
Making it look more like how we do this kind of things in other places. See: https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2252#note_927653 Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2273>
This commit is contained in:
parent
f29e75d1da
commit
da150c18bb
3 changed files with 61 additions and 51 deletions
|
@ -167,12 +167,16 @@ initialize_web_extensions (WebKitWebContext *context)
|
||||||
static void
|
static void
|
||||||
webkit_extension_gerror_msg_received (GstWpeSrc *src, GVariant *params)
|
webkit_extension_gerror_msg_received (GstWpeSrc *src, GVariant *params)
|
||||||
{
|
{
|
||||||
GstMessage *message;
|
GstStructure *structure;
|
||||||
const gchar *message_type, *src_path, *error_domain, *msg, *debug_str, *details_str;
|
GstMessage *forwarded;
|
||||||
|
const gchar *src_path, *src_type, *src_name, *error_domain, *msg, *debug_str, *details_str;
|
||||||
|
gint message_type;
|
||||||
guint32 error_code;
|
guint32 error_code;
|
||||||
|
|
||||||
g_variant_get (params, "(sssusss)",
|
g_variant_get (params, "(issssusss)",
|
||||||
&message_type,
|
&message_type,
|
||||||
|
&src_type,
|
||||||
|
&src_name,
|
||||||
&src_path,
|
&src_path,
|
||||||
&error_domain,
|
&error_domain,
|
||||||
&error_code,
|
&error_code,
|
||||||
|
@ -188,37 +192,44 @@ webkit_extension_gerror_msg_received (GstWpeSrc *src, GVariant *params)
|
||||||
debug_str, src_path
|
debug_str, src_path
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!details)
|
|
||||||
details = gst_structure_new_empty("wpesrcdetails");
|
|
||||||
gst_structure_set(details,
|
|
||||||
"wpesrc_original_src_path", G_TYPE_STRING, src_path,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
if (!g_strcmp0(message_type, "error")) {
|
if (message_type == GST_MESSAGE_ERROR) {
|
||||||
message =
|
forwarded =
|
||||||
gst_message_new_error_with_details(GST_OBJECT(src), error,
|
gst_message_new_error_with_details(GST_OBJECT(src), error,
|
||||||
our_message, details);
|
our_message, details);
|
||||||
} else if (!g_strcmp0(message_type, "warning")) {
|
} else if (message_type == GST_MESSAGE_WARNING) {
|
||||||
message =
|
forwarded =
|
||||||
gst_message_new_warning_with_details(GST_OBJECT(src), error,
|
gst_message_new_warning_with_details(GST_OBJECT(src), error,
|
||||||
our_message, details);
|
our_message, details);
|
||||||
} else {
|
} else {
|
||||||
message =
|
forwarded =
|
||||||
gst_message_new_info_with_details(GST_OBJECT(src), error, our_message, details);
|
gst_message_new_info_with_details(GST_OBJECT(src), error, our_message, details);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
structure = gst_structure_new ("WpeForwarded",
|
||||||
|
"message", GST_TYPE_MESSAGE, forwarded,
|
||||||
|
"wpe-original-src-name", G_TYPE_STRING, src_name,
|
||||||
|
"wpe-original-src-type", G_TYPE_STRING, src_type,
|
||||||
|
"wpe-original-src-path", G_TYPE_STRING, src_path,
|
||||||
|
NULL
|
||||||
|
);
|
||||||
|
|
||||||
g_free (our_message);
|
g_free (our_message);
|
||||||
gst_element_post_message(GST_ELEMENT(src), message);
|
gst_element_post_message(GST_ELEMENT(src), gst_message_new_custom(GST_MESSAGE_ELEMENT,
|
||||||
|
GST_OBJECT(src), structure));
|
||||||
g_error_free(error);
|
g_error_free(error);
|
||||||
|
gst_message_unref (forwarded);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
webkit_extension_bus_message_received (GstWpeSrc *src, GVariant *params)
|
webkit_extension_bus_message_received (GstWpeSrc *src, GVariant *params)
|
||||||
{
|
{
|
||||||
GstStructure *structure;
|
GstStructure *original_structure, *structure;
|
||||||
const gchar *message_type, *src_name, *src_type, *src_path, *struct_str;
|
const gchar *src_name, *src_type, *src_path, *struct_str;
|
||||||
|
GstMessageType message_type;
|
||||||
|
GstMessage *forwarded;
|
||||||
|
|
||||||
g_variant_get (params, "(sssss)",
|
g_variant_get (params, "(issss)",
|
||||||
&message_type,
|
&message_type,
|
||||||
&src_name,
|
&src_name,
|
||||||
&src_type,
|
&src_type,
|
||||||
|
@ -226,23 +237,29 @@ webkit_extension_bus_message_received (GstWpeSrc *src, GVariant *params)
|
||||||
&struct_str
|
&struct_str
|
||||||
);
|
);
|
||||||
|
|
||||||
structure = (struct_str[0] != '\0') ? gst_structure_new_from_string(struct_str) : NULL;
|
original_structure = (struct_str[0] != '\0') ? gst_structure_new_from_string(struct_str) : NULL;
|
||||||
if (!structure)
|
if (!original_structure)
|
||||||
{
|
{
|
||||||
if (struct_str[0] != '\0')
|
if (struct_str[0] != '\0')
|
||||||
GST_ERROR_OBJECT(src, "Could not deserialize: %s", struct_str);
|
GST_ERROR_OBJECT(src, "Could not deserialize: %s", struct_str);
|
||||||
structure = gst_structure_new_empty("wpesrc");
|
original_structure = gst_structure_new_empty("wpesrc");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_structure_set(structure,
|
forwarded = gst_message_new_custom(message_type,
|
||||||
"wpesrc_original_message_type", G_TYPE_STRING, message_type,
|
GST_OBJECT (src), original_structure);
|
||||||
"wpesrc_original_src_name", G_TYPE_STRING, src_name,
|
structure = gst_structure_new ("WpeForwarded",
|
||||||
"wpesrc_original_src_type", G_TYPE_STRING, src_type,
|
"message", GST_TYPE_MESSAGE, forwarded,
|
||||||
"wpesrc_original_src_path", G_TYPE_STRING, src_path,
|
"wpe-original-src-name", G_TYPE_STRING, src_name,
|
||||||
NULL);
|
"wpe-original-src-type", G_TYPE_STRING, src_type,
|
||||||
|
"wpe-original-src-path", G_TYPE_STRING, src_path,
|
||||||
|
NULL
|
||||||
|
);
|
||||||
|
|
||||||
gst_element_post_message(GST_ELEMENT(src), gst_message_new_custom(GST_MESSAGE_ELEMENT,
|
gst_element_post_message(GST_ELEMENT(src), gst_message_new_custom(GST_MESSAGE_ELEMENT,
|
||||||
GST_OBJECT(src), structure));
|
GST_OBJECT(src), structure));
|
||||||
|
|
||||||
|
gst_message_unref (forwarded);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
|
|
@ -24,11 +24,11 @@
|
||||||
* The wpesrc element is used to produce a video texture representing a web page
|
* The wpesrc element is used to produce a video texture representing a web page
|
||||||
* rendered off-screen by WPE.
|
* rendered off-screen by WPE.
|
||||||
*
|
*
|
||||||
* Starting from WPEBackend-FDO 1.6.x, software rendering support is available. This
|
* Starting from WPEBackend-FDO 1.6.x, software rendering support is available.
|
||||||
* features allows wpesrc to be used on machines without GPU, and/or for testing
|
* This features allows wpesrc to be used on machines without GPU, and/or for
|
||||||
* purpose. To enable it, set the `LIBGL_ALWAYS_SOFTWARE=true` environment
|
* testing purpose. To enable it, set the `LIBGL_ALWAYS_SOFTWARE=true`
|
||||||
* variable and make sure `video/x-raw, format=BGRA` caps are negotiated by the
|
* environment variable and make sure `video/x-raw, format=BGRA` caps are
|
||||||
* wpesrc element.
|
* negotiated by the wpesrc element.
|
||||||
*
|
*
|
||||||
* ## Example launch lines
|
* ## Example launch lines
|
||||||
*
|
*
|
||||||
|
@ -68,25 +68,16 @@
|
||||||
* source pads.
|
* source pads.
|
||||||
*
|
*
|
||||||
* This source also relays GStreamer bus messages from the GStreamer pipelines
|
* This source also relays GStreamer bus messages from the GStreamer pipelines
|
||||||
* running inside the web pages. Error, warning and info messages are made ours
|
* running inside the web pages as [element custom](gst_message_new_custom)
|
||||||
* with the addition of the following fields into the GstMessage details (See
|
* messages which structure is called `WpeForwarded` and has the following
|
||||||
* gst_message_parse_error_details(), gst_message_parse_warning_details() and
|
* fields:
|
||||||
* gst_message_parse_info_details()):
|
|
||||||
*
|
*
|
||||||
* * `wpesrc_original_src_path`: [Path](gst_object_get_path_string) of the
|
* * `message`: The original #GstMessage
|
||||||
* original element posting the message
|
* * `wpesrc-original-src-name`: Name of the original element posting the
|
||||||
*
|
|
||||||
* Other message types are posted as [element custom](gst_message_new_custom)
|
|
||||||
* messages reusing the same GstStructure as the one from the message from the
|
|
||||||
* message posted in the web page with the addition of the following fields:
|
|
||||||
*
|
|
||||||
* * `wpesrc_original_message_type`: Type of the original message from
|
|
||||||
* gst_message_type_get_name().
|
|
||||||
* * `wpesrc_original_src_name`: Name of the original element posting the
|
|
||||||
* message
|
* message
|
||||||
* * `wpesrc_original_src_type`: Name of the GType of the original element
|
* * `wpesrc-original-src-type`: Name of the GType of the original element
|
||||||
* posting the message
|
* posting the message
|
||||||
* * `wpesrc_original_src_path`: [Path](gst_object_get_path_string) of the
|
* * `wpesrc-original-src-path`: [Path](gst_object_get_path_string) of the
|
||||||
* original element positing the message
|
* original element positing the message
|
||||||
*
|
*
|
||||||
* Note: This feature will be disabled if you disable the tracer subsystem.
|
* Note: This feature will be disabled if you disable the tracer subsystem.
|
||||||
|
|
|
@ -64,8 +64,10 @@ create_gerror_bus_msg (GstElement * element, GstMessage * message)
|
||||||
|
|
||||||
msg = webkit_user_message_new ("gstwpe.bus_gerror_message",
|
msg = webkit_user_message_new ("gstwpe.bus_gerror_message",
|
||||||
/* (message_type, src_path, error_domain, error_code, msg, debug_str, details_structure) */
|
/* (message_type, src_path, error_domain, error_code, msg, debug_str, details_structure) */
|
||||||
g_variant_new ("(sssusss)",
|
g_variant_new ("(issssusss)",
|
||||||
gst_message_type_get_name (GST_MESSAGE_TYPE (message)),
|
GST_MESSAGE_TYPE (message),
|
||||||
|
GST_MESSAGE_SRC_NAME (message),
|
||||||
|
G_OBJECT_TYPE_NAME (GST_MESSAGE_SRC (message)),
|
||||||
src_path,
|
src_path,
|
||||||
g_quark_to_string (error->domain),
|
g_quark_to_string (error->domain),
|
||||||
error->code, error->message, debug_str, details_structure)
|
error->code, error->message, debug_str, details_structure)
|
||||||
|
@ -144,8 +146,8 @@ gst_message_post_cb (GObject * object, GstClockTime ts, GstElement * element,
|
||||||
} else {
|
} else {
|
||||||
gchar *src_path = gst_object_get_path_string (GST_MESSAGE_SRC (message));
|
gchar *src_path = gst_object_get_path_string (GST_MESSAGE_SRC (message));
|
||||||
msg = webkit_user_message_new ("gstwpe.bus_message",
|
msg = webkit_user_message_new ("gstwpe.bus_message",
|
||||||
g_variant_new ("(sssss)",
|
g_variant_new ("(issss)",
|
||||||
gst_message_type_get_name (GST_MESSAGE_TYPE (message)),
|
GST_MESSAGE_TYPE (message),
|
||||||
GST_MESSAGE_SRC_NAME (message),
|
GST_MESSAGE_SRC_NAME (message),
|
||||||
G_OBJECT_TYPE_NAME (GST_MESSAGE_SRC (message)), src_path, str));
|
G_OBJECT_TYPE_NAME (GST_MESSAGE_SRC (message)), src_path, str));
|
||||||
g_free (src_path);
|
g_free (src_path);
|
||||||
|
|
Loading…
Reference in a new issue