After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 703235 - [gstreamer-1.2-port] Add support for GstContext
[gstreamer-1.2-port] Add support for GstContext
Status: RESOLVED FIXED
Product: gstreamer-vaapi
Classification: Other
Component: general
git master
Other Linux
: Normal normal
: ---
Assigned To: gstreamer-vaapi maintainer(s)
gstreamer-vaapi maintainer(s)
Depends on:
Blocks: 698054
 
 
Reported: 2013-06-28 11:05 UTC by Víctor Manuel Jáquez Leal
Modified: 2013-09-28 07:34 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
initial port to GStreamer 1.2 (10.53 KB, patch)
2013-06-28 18:48 UTC, Víctor Manuel Jáquez Leal
none Details | Review
pluginutil: add gst_vaapi_create_display() (2.80 KB, patch)
2013-06-28 18:48 UTC, Víctor Manuel Jáquez Leal
accepted-commit_now Details | Review
pluginutil: add locks (1.68 KB, patch)
2013-06-28 18:48 UTC, Víctor Manuel Jáquez Leal
none Details | Review
display: add gstcontext utilities (2.49 KB, patch)
2013-06-28 18:49 UTC, Víctor Manuel Jáquez Leal
needs-work Details | Review
libs: add gstvaapivideocontext (10.76 KB, patch)
2013-06-28 18:49 UTC, Víctor Manuel Jáquez Leal
none Details | Review
postproc: set context (3.69 KB, patch)
2013-06-28 18:49 UTC, Víctor Manuel Jáquez Leal
none Details | Review
decode: set context (3.63 KB, patch)
2013-06-28 18:49 UTC, Víctor Manuel Jáquez Leal
none Details | Review
decode: query context (1.96 KB, patch)
2013-06-28 18:49 UTC, Víctor Manuel Jáquez Leal
none Details | Review
sink: set context (3.99 KB, patch)
2013-06-28 18:49 UTC, Víctor Manuel Jáquez Leal
none Details | Review
sink: handle events (2.23 KB, patch)
2013-06-28 18:49 UTC, Víctor Manuel Jáquez Leal
none Details | Review
sink: handle context query (2.16 KB, patch)
2013-06-28 18:49 UTC, Víctor Manuel Jáquez Leal
none Details | Review
enable compilation with GStreamer 1.2 (11.26 KB, patch)
2013-07-12 19:07 UTC, Víctor Manuel Jáquez Leal
none Details | Review
pluginutil: add gst_vaapi_create_display() (2.86 KB, patch)
2013-07-12 19:08 UTC, Víctor Manuel Jáquez Leal
none Details | Review
display: utilities for GstContext (2.47 KB, patch)
2013-07-12 19:08 UTC, Víctor Manuel Jáquez Leal
none Details | Review
pluginutil: compat layer for GstVideoContext (7.61 KB, patch)
2013-07-12 19:08 UTC, Víctor Manuel Jáquez Leal
none Details | Review
pluginutil: add gst_vaapi_display_found() (2.61 KB, patch)
2013-07-12 19:08 UTC, Víctor Manuel Jáquez Leal
none Details | Review
decode: add context handling (3.63 KB, patch)
2013-07-12 19:08 UTC, Víctor Manuel Jáquez Leal
none Details | Review
sink: add context handling (4.55 KB, patch)
2013-07-12 19:08 UTC, Víctor Manuel Jáquez Leal
none Details | Review
enable compilation with GStreamer 1.2 (11.24 KB, patch)
2013-07-15 16:28 UTC, Víctor Manuel Jáquez Leal
none Details | Review
display: utilities for GstContext (2.47 KB, patch)
2013-07-15 16:28 UTC, Víctor Manuel Jáquez Leal
none Details | Review
pluginutil: compat layer for GstVideoContext (7.61 KB, patch)
2013-07-15 16:28 UTC, Víctor Manuel Jáquez Leal
none Details | Review
pluginutil: add gst_vaapi_display_found() (2.61 KB, patch)
2013-07-15 16:28 UTC, Víctor Manuel Jáquez Leal
none Details | Review
decode: add context handling (3.63 KB, patch)
2013-07-15 16:28 UTC, Víctor Manuel Jáquez Leal
none Details | Review
sink: add context handling (4.55 KB, patch)
2013-07-15 16:28 UTC, Víctor Manuel Jáquez Leal
none Details | Review

Description Víctor Manuel Jáquez Leal 2013-06-28 11:05:27 UTC
This bug is to track the patches required to support GstContext (available in GStreamer 1.2) and deprecate GstVideoContext in gstreamer-vaapi
Comment 1 Víctor Manuel Jáquez Leal 2013-06-28 18:48:50 UTC
Created attachment 248020 [details] [review]
initial port to GStreamer 1.2

https://bugzilla.gnome.org/show_bug.cgi?id=698054
Comment 2 Víctor Manuel Jáquez Leal 2013-06-28 18:48:54 UTC
Created attachment 248021 [details] [review]
pluginutil: add gst_vaapi_create_display()

https://bugzilla.gnome.org/show_bug.cgi?id=698054
Comment 3 Víctor Manuel Jáquez Leal 2013-06-28 18:48:57 UTC
Created attachment 248022 [details] [review]
pluginutil: add locks

This seems to be healthy.

https://bugzilla.gnome.org/show_bug.cgi?id=698054
Comment 4 Víctor Manuel Jáquez Leal 2013-06-28 18:49:01 UTC
Created attachment 248023 [details] [review]
display: add gstcontext utilities

declared an use a boxed type for display

https://bugzilla.gnome.org/show_bug.cgi?id=698054
Comment 5 Víctor Manuel Jáquez Leal 2013-06-28 18:49:05 UTC
Created attachment 248024 [details] [review]
libs: add gstvaapivideocontext

This is thin compat layer for the deprecated GstVideoContext.

https://bugzilla.gnome.org/show_bug.cgi?id=698054
Comment 6 Víctor Manuel Jáquez Leal 2013-06-28 18:49:09 UTC
Created attachment 248025 [details] [review]
postproc: set context

https://bugzilla.gnome.org/show_bug.cgi?id=698054
Comment 7 Víctor Manuel Jáquez Leal 2013-06-28 18:49:13 UTC
Created attachment 248026 [details] [review]
decode: set context

https://bugzilla.gnome.org/show_bug.cgi?id=698054
Comment 8 Víctor Manuel Jáquez Leal 2013-06-28 18:49:16 UTC
Created attachment 248027 [details] [review]
decode: query context

https://bugzilla.gnome.org/show_bug.cgi?id=698054
Comment 9 Víctor Manuel Jáquez Leal 2013-06-28 18:49:20 UTC
Created attachment 248028 [details] [review]
sink: set context

https://bugzilla.gnome.org/show_bug.cgi?id=698054
Comment 10 Víctor Manuel Jáquez Leal 2013-06-28 18:49:25 UTC
Created attachment 248029 [details] [review]
sink: handle events

https://bugzilla.gnome.org/show_bug.cgi?id=698054
Comment 11 Víctor Manuel Jáquez Leal 2013-06-28 18:49:29 UTC
Created attachment 248030 [details] [review]
sink: handle context query

https://bugzilla.gnome.org/show_bug.cgi?id=698054
Comment 12 Víctor Manuel Jáquez Leal 2013-06-28 18:54:31 UTC
Review of attachment 248020 [details] [review]:

This patch breaks vaapipostproc: somehow prevents the caps negotiation in the vaapipostproc sink pad.
Comment 13 Gwenole Beauchesne 2013-07-02 13:17:13 UTC
Review of attachment 248021 [details] [review]:

Safe enough to be moved to master too. Thanks.
Comment 14 Gwenole Beauchesne 2013-07-02 13:18:03 UTC
Review of attachment 248020 [details] [review]:

I changed this one to disable vaapipostproc altogether.
Comment 15 Gwenole Beauchesne 2013-07-02 13:19:38 UTC
Review of attachment 248022 [details] [review]:

This looks correct, but is it actually needed? i.e. do you have cases/ways to exhaust the need of this patch, like crashes without? Thanks.
Comment 16 Gwenole Beauchesne 2013-07-02 13:23:37 UTC
Review of attachment 248023 [details] [review]:

I would like gst-libs/ (libgstvaapi) to remain independent from core GStreamer features, unless they are self-contained like simple data structures. Maybe move that to gstpluginutil too?
Comment 17 Gwenole Beauchesne 2013-07-02 13:24:30 UTC
Review of attachment 248024 [details] [review]:

I would like gst-libs/ (libgstvaapi) to remain independent from core GStreamer features, unless they are self-contained like simple data structures. Maybe move that to gstpluginutil too? [Same comment as for the previous patch] :)
Comment 18 Gwenole Beauchesne 2013-07-02 14:48:42 UTC
Review of attachment 248026 [details] [review]:

Testing the hunks-commenting feature for finer grained comments. :)

::: gst/vaapi/gstvaapidecode.c
@@ +526,3 @@
+            gst_vaapi_display_unref(decode->set_display);
+        GST_INFO_OBJECT(element, "set display = %p", display);
+        decode->set_display = display;

I think it's better to use gst_vaapi_display_replace() + gst_vaapi_display_unref() of the display we got from the GstStructure. That way, you could even get rid of the heavy GstObject locks.

@@ +549,3 @@
+        GstContext *context;
+
+        decode->display = gst_vaapi_display_ref(decode->set_display);

Are we guaranteed that display is NULL if set_display is set? If so, this means they are mutually exclusive and we can keep a single display var + possible use a signalling var instead (flag). If not, this means it's probably easier/safer to just use gst_vaapi_display_replace() here?

::: gst/vaapi/gstvaapidecode.h
@@ +71,3 @@
     GstVaapiDisplay    *display;
+#if GST_CHECK_VERSION(1,1,0)
+    GstVaapiDisplay    *set_display;

I am still looking for the exact meaning of "set_display". Is this a "foreign" display as in "some display the user asks the vaapidecode element to use"? If so, "foreign_display" is probably a more appropriate name?

wrt. the other comment about whether set_display/display are mutually exclusive. If this is the case, we could keep display + add a is_foreign_display flag?
Comment 19 Víctor Manuel Jáquez Leal 2013-07-11 17:51:17 UTC
(In reply to comment #13)
> Review of attachment 248021 [details] [review]:
> 
> Safe enough to be moved to master too. Thanks.

Did you push this? I don't see it in the gitorious repo :(
Comment 20 Víctor Manuel Jáquez Leal 2013-07-11 17:55:35 UTC
(In reply to comment #15)
> Review of attachment 248022 [details] [review]:
> 
> This looks correct, but is it actually needed? i.e. do you have cases/ways to
> exhaust the need of this patch, like crashes without? Thanks.

No, I didn't see any crash because of this, but I thought that it would be sane. Anyway I guess we could ditch this patch for the moment.
Comment 21 Víctor Manuel Jáquez Leal 2013-07-11 18:04:15 UTC
(In reply to comment #16)
> Review of attachment 248023 [details] [review]:
> 
> I would like gst-libs/ (libgstvaapi) to remain independent from core GStreamer
> features, unless they are self-contained like simple data structures. Maybe
> move that to gstpluginutil too?

I've found a problem with my approach: the bins that would like to set context, would need to create the GstVaapiDisplay. That's the reason why egl offers an external library to be linked:

http://cgit.freedesktop.org/gstreamer/gst-plugins-bad/tree/gst-libs/gst/egl/egl.h

We would need to have a thin library that offer the management of this boxed structure by the user.
Comment 22 Víctor Manuel Jáquez Leal 2013-07-11 18:08:48 UTC
(In reply to comment #17)
> Review of attachment 248024 [details] [review]:
> 
> I would like gst-libs/ (libgstvaapi) to remain independent from core GStreamer
> features, unless they are self-contained like simple data structures. Maybe
> move that to gstpluginutil too? [Same comment as for the previous patch] :)

Agree!
Comment 23 Víctor Manuel Jáquez Leal 2013-07-11 18:14:12 UTC
(In reply to comment #18)
> Review of attachment 248026 [details] [review]:
> 
> Testing the hunks-commenting feature for finer grained comments. :)
> 
> ::: gst/vaapi/gstvaapidecode.c
> @@ +526,3 @@
> +            gst_vaapi_display_unref(decode->set_display);
> +        GST_INFO_OBJECT(element, "set display = %p", display);
> +        decode->set_display = display;
> 
> I think it's better to use gst_vaapi_display_replace() +
> gst_vaapi_display_unref() of the display we got from the GstStructure. That
> way, you could even get rid of the heavy GstObject locks.

I can do that.

> 
> @@ +549,3 @@
> +        GstContext *context;
> +
> +        decode->display = gst_vaapi_display_ref(decode->set_display);
> 
> Are we guaranteed that display is NULL if set_display is set? If so, this means
> they are mutually exclusive and we can keep a single display var + possible use
> a signalling var instead (flag). If not, this means it's probably easier/safer
> to just use gst_vaapi_display_replace() here?
> 
> ::: gst/vaapi/gstvaapidecode.h
> @@ +71,3 @@
>      GstVaapiDisplay    *display;
> +#if GST_CHECK_VERSION(1,1,0)
> +    GstVaapiDisplay    *set_display;
> 
> I am still looking for the exact meaning of "set_display". Is this a "foreign"
> display as in "some display the user asks the vaapidecode element to use"? If
> so, "foreign_display" is probably a more appropriate name?

Yes, is the "foreign" display that comes from other element or from the bin, and it is going to be use as the element's display. It should be mutually exclusive, but I'm not sure that it will happen for sure.

> 
> wrt. the other comment about whether set_display/display are mutually
> exclusive. If this is the case, we could keep display + add a
> is_foreign_display flag?
Comment 24 Víctor Manuel Jáquez Leal 2013-07-12 19:07:59 UTC
Created attachment 249036 [details] [review]
enable compilation with GStreamer 1.2

This patch adds the GStreamer API version 1.2 in the configure
option. Within this API version it is mandatory:

* To avoid the use of GstSurfaceConverter API
* To avoid the use of GstVideoContext API

Also, as we find some issues with the caps negotiation, this patch
also disables the compilation vaapipostproc element.
Comment 25 Víctor Manuel Jáquez Leal 2013-07-12 19:08:05 UTC
Created attachment 249037 [details] [review]
pluginutil: add gst_vaapi_create_display()

Move out the display creation to another function:
gst_vaapi_create_display()

It makes the code more readable.
Comment 26 Víctor Manuel Jáquez Leal 2013-07-12 19:08:09 UTC
Created attachment 249038 [details] [review]
display: utilities for GstContext

Declare an use a boxed type for display sharing through GstContext.
Comment 27 Víctor Manuel Jáquez Leal 2013-07-12 19:08:13 UTC
Created attachment 249039 [details] [review]
pluginutil: compat layer for GstVideoContext

Thin compat layer for the deprecated GstVideoContext.

Add two functions only when compiled with Gstreamer v1.2:

* gst_vaapi_video_context_prepare(): queries if a context is already
  set in the pipeline

* gst_vaapi_video_context_propagate(): propagates the created context
Comment 28 Víctor Manuel Jáquez Leal 2013-07-12 19:08:17 UTC
Created attachment 249040 [details] [review]
pluginutil: add gst_vaapi_display_found()

This utility function checks if there's already an assigned display, either in
the element's structure or in its context.
Comment 29 Víctor Manuel Jáquez Leal 2013-07-12 19:08:22 UTC
Created attachment 249041 [details] [review]
decode: add context handling

Added this new function for GStreamer v1.2:

gst_vaapidecode_set_context(): handle the display context

And handle the context query from downstream.
Comment 30 Víctor Manuel Jáquez Leal 2013-07-12 19:08:27 UTC
Created attachment 249042 [details] [review]
sink: add context handling

gst_vaapisink_set_context(): set the display context
gst_vaapisink_event(): downstream event requesting a context

And also handle the context query.
Comment 31 Víctor Manuel Jáquez Leal 2013-07-15 16:28:06 UTC
Created attachment 249213 [details] [review]
enable compilation with GStreamer 1.2

This patch adds the GStreamer API version 1.2 in the configure
option. Within this API version it is mandatory:

* To avoid the use of GstSurfaceConverter API
* To avoid the use of GstVideoContext API

Also, as we find some issues with the caps negotiation, this patch
also disables the compilation vaapipostproc element.
Comment 32 Víctor Manuel Jáquez Leal 2013-07-15 16:28:13 UTC
Created attachment 249214 [details] [review]
display: utilities for GstContext

Declare an use a boxed type for display sharing through GstContext.
Comment 33 Víctor Manuel Jáquez Leal 2013-07-15 16:28:19 UTC
Created attachment 249215 [details] [review]
pluginutil: compat layer for GstVideoContext

Thin compat layer for the deprecated GstVideoContext.

Add two functions only when compiled with Gstreamer v1.2:

* gst_vaapi_video_context_prepare(): queries if a context is already
  set in the pipeline

* gst_vaapi_video_context_propagate(): propagates the created context
Comment 34 Víctor Manuel Jáquez Leal 2013-07-15 16:28:25 UTC
Created attachment 249216 [details] [review]
pluginutil: add gst_vaapi_display_found()

This utility function checks if there's already an assigned display, either in
the element's structure or in its context.
Comment 35 Víctor Manuel Jáquez Leal 2013-07-15 16:28:30 UTC
Created attachment 249218 [details] [review]
decode: add context handling

Added this new function for GStreamer v1.2:

gst_vaapidecode_set_context(): handle the display context

And handle the context query from downstream.
Comment 36 Víctor Manuel Jáquez Leal 2013-07-15 16:28:36 UTC
Created attachment 249219 [details] [review]
sink: add context handling

gst_vaapisink_set_context(): set the display context
gst_vaapisink_event(): downstream event requesting a context

And also handle the context query.
Comment 37 Gwenole Beauchesne 2013-09-26 13:50:11 UTC
Hi, I plan to merge "display: utilities for GstContext" and "pluguntil: compat layer for GstVideoContext" patches into a single one, while also providing a single file for the implementation: gstvaapivideocontext.[ch]. That should be enough then.
Comment 38 Gwenole Beauchesne 2013-09-27 12:31:33 UTC
Ported to the latest GStreamer 1.2.0 APIs. It works for me, though fill free to re-open with new patches. In particular, gst_element_get_context() is gone so we cannot perform step (1) any longer.

Tested with an explicit pipeline and I could indeed see that the GstVaapiDisplay gets propagated as described. However, through a playbin pipeline, the run_context_query() function fails to find any display from its downstream peers. Most likely normal since vaapidecode & vaapisink are not linked at that time.

Though, there is room for improvement, especially for checking for display_types[].
Comment 39 Gwenole Beauchesne 2013-09-27 12:31:54 UTC
commit 9e3d24c6696256afca1c3f382125636e1c536253
Author: Víctor Manuel Jáquez Leal <vjaquez@igalia.com>
Date:   Fri Jul 12 12:58:57 2013 -0400

    plugins: add support for GstContext API.
    
    Add support for the new GstContext API from GStreamer 1.2.x.
    - implement the GstElement::set_context() hook ;
    - reply to the `context' query from downstream elements.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=703235
    
    Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>

commit c67b783275a3b9bad1a26d6895ae2a51dd218456
Author: Víctor Manuel Jáquez Leal <vjaquez@igalia.com>
Date:   Wed May 22 12:07:52 2013 -0400

    plugins: add compat layer for GstVideoContext.
    
    Add thin compatibility layer for the deprecated GstVideoContext API.
    For GStreamer API >= 1.2, this involves the following two functions:
    - gst_vaapi_video_context_prepare(): queries if a context is already
      set in the pipeline ;
    - gst_vaapi_video_context_propagate(): propagates the newly-created
      context to the rest of the pipeline.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=703235
    
    Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>

commit f75762d910097f0fe4f730fad3dc9ff1d4985438
Author: Víctor Manuel Jáquez Leal <vjaquez@igalia.com>
Date:   Tue May 21 12:42:39 2013 -0400

    plugins: initial port to GStreamer 1.2.
    
    Port vaapidecode and vaapisink plugins to GStreamer API >= 1.2. This
    is rather minimalistic so that to test the basic functionality.
    
    Disable vaapipostproc plugin for now as further polishing is needed.
    Also disable GstVideoContext interface support since this API is now
    gone in 1.2.x. This is preparatory work for GstContext support.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=703235
    
    Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
Comment 40 Víctor Manuel Jáquez Leal 2013-09-27 13:22:33 UTC
\o/
Comment 41 Sebastian Dröge (slomo) 2013-09-28 07:34:38 UTC
(In reply to comment #38)
> Ported to the latest GStreamer 1.2.0 APIs. It works for me, though fill free to
> re-open with new patches. In particular, gst_element_get_context() is gone so
> we cannot perform step (1) any longer.

Instead of that you implement GstElement::set_context in your element now and remember if any context of your interest is set. Also the query should be sent downstream, then upstream, then the need-context message.

Just took a short look at these patches but this part seems to be missing.