[libcamera-devel] test: gstreamer: Avoid call to deprecated gst_element_get_request_pad()
diff mbox series

Message ID 20211130182943.155481-1-xavier.roumegue@oss.nxp.com
State Accepted
Headers show
Series
  • [libcamera-devel] test: gstreamer: Avoid call to deprecated gst_element_get_request_pad()
Related show

Commit Message

Xavier Roumegue Nov. 30, 2021, 6:29 p.m. UTC
From: Xavier Roumegue <xavier.roumegue@oss.nxp.com>

gst_element_get_request_pad() is being replaced by gst_element_request_simple()
since 1.19.1, throwing a warning in case of use until its definitive
replacement on 1.20.

Hence, prefer using gst_element_request_simple() in case gstreamer
version is >= 1.19.1 to avoid the compilation error below (tested on f35):

[3/88] Compiling C++ object test/gstreamer/multi_stream_test.p/gstreamer_multi_stream_test.cpp.o
FAILED: test/gstreamer/multi_stream_test.p/gstreamer_multi_stream_test.cpp.o
c++ -Itest/gstreamer/multi_stream_test.p -Itest/gstreamer -I../test/gstreamer -Itest/libtest -I../test/libtest -Iinclude -I../include -Iinclude/libcamera/ipa -Iinclude/libcamera -I/usr/include/gstreamer-1.0 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/sysprof-4 -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wnon-virtual-dtor -Wextra -Werror -std=c++17 -g -Wshadow -include config.h -pthread -DLIBCAMERA_BASE_PRIVATE -MD -MQ test/gstreamer/multi_stream_test.p/gstreamer_multi_stream_test.cpp.o -MF test/gstreamer/multi_stream_test.p/gstreamer_multi_stream_test.cpp.o.d -o test/gstreamer/multi_stream_test.p/gstreamer_multi_stream_test.cpp.o -c ../test/gstreamer/gstreamer_multi_stream_test.cpp
../test/gstreamer/gstreamer_multi_stream_test.cpp: In member function ‘virtual int GstreamerMultiStreamTest::run()’:
../test/gstreamer/gstreamer_multi_stream_test.cpp:97:72: error: ‘GstPad* gst_element_get_request_pad(GstElement*, const gchar*)’ is deprecated: Use 'gst_element_request_pad_simple' instead [-Werror=deprecated-declarations]
   97 |                 g_autoptr(GstPad) request_pad = GST_ELEMENT_REQUEST_PAD(libcameraSrc_, "src_%u");
      |                                                                        ^
In file included from /usr/include/gstreamer-1.0/gst/gstbin.h:27,
                 from /usr/include/gstreamer-1.0/gst/gst.h:35,
                 from ../test/gstreamer/gstreamer_multi_stream_test.cpp:13:
/usr/include/gstreamer-1.0/gst/gstelement.h:1042:25: note: declared here
 1042 | GstPad*                 gst_element_get_request_pad     (GstElement *element, const gchar *name);
      |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1plus: all warnings being treated as errors

Signed-off-by: Xavier Roumegue <xavier.roumegue@oss.nxp.com>
---
 test/gstreamer/gstreamer_multi_stream_test.cpp | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Comments

Laurent Pinchart Nov. 30, 2021, 8:56 p.m. UTC | #1
Hi Xavier,

(CC'ing Nicolas)

Thank you for the patch.

On Tue, Nov 30, 2021 at 07:29:43PM +0100, Xavier Roumegue (OSS) wrote:
> From: Xavier Roumegue <xavier.roumegue@oss.nxp.com>
> 
> gst_element_get_request_pad() is being replaced by gst_element_request_simple()
> since 1.19.1, throwing a warning in case of use until its definitive
> replacement on 1.20.
> 
> Hence, prefer using gst_element_request_simple() in case gstreamer
> version is >= 1.19.1 to avoid the compilation error below (tested on f35):
> 
> [3/88] Compiling C++ object test/gstreamer/multi_stream_test.p/gstreamer_multi_stream_test.cpp.o
> FAILED: test/gstreamer/multi_stream_test.p/gstreamer_multi_stream_test.cpp.o
> c++ -Itest/gstreamer/multi_stream_test.p -Itest/gstreamer -I../test/gstreamer -Itest/libtest -I../test/libtest -Iinclude -I../include -Iinclude/libcamera/ipa -Iinclude/libcamera -I/usr/include/gstreamer-1.0 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/sysprof-4 -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wnon-virtual-dtor -Wextra -Werror -std=c++17 -g -Wshadow -include config.h -pthread -DLIBCAMERA_BASE_PRIVATE -MD -MQ test/gstreamer/multi_stream_test.p/gstreamer_multi_stream_test.cpp.o -MF test/gstreamer/multi_stream_test.p/gstreamer_multi_stream_test.cpp.o.d -o test/gstreamer/multi_stream_test.p/gstreamer_multi_stream_test.cpp.o -c ../test/gstreamer/gstreamer_multi_stream_test.cpp
> ../test/gstreamer/gstreamer_multi_stream_test.cpp: In member function ‘virtual int GstreamerMultiStreamTest::run()’:
> ../test/gstreamer/gstreamer_multi_stream_test.cpp:97:72: error: ‘GstPad* gst_element_get_request_pad(GstElement*, const gchar*)’ is deprecated: Use 'gst_element_request_pad_simple' instead [-Werror=deprecated-declarations]
>    97 |                 g_autoptr(GstPad) request_pad = GST_ELEMENT_REQUEST_PAD(libcameraSrc_, "src_%u");
>       |                                                                        ^
> In file included from /usr/include/gstreamer-1.0/gst/gstbin.h:27,
>                  from /usr/include/gstreamer-1.0/gst/gst.h:35,
>                  from ../test/gstreamer/gstreamer_multi_stream_test.cpp:13:
> /usr/include/gstreamer-1.0/gst/gstelement.h:1042:25: note: declared here
>  1042 | GstPad*                 gst_element_get_request_pad     (GstElement *element, const gchar *name);
>       |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~
> cc1plus: all warnings being treated as errors
> 
> Signed-off-by: Xavier Roumegue <xavier.roumegue@oss.nxp.com>
> ---
>  test/gstreamer/gstreamer_multi_stream_test.cpp | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/test/gstreamer/gstreamer_multi_stream_test.cpp b/test/gstreamer/gstreamer_multi_stream_test.cpp
> index d3d7a9d3..1e3c9f18 100644
> --- a/test/gstreamer/gstreamer_multi_stream_test.cpp
> +++ b/test/gstreamer/gstreamer_multi_stream_test.cpp
> @@ -15,6 +15,12 @@
>  #include "gstreamer_test.h"
>  #include "test.h"
>  
> +#if GST_CHECK_VERSION(1, 19, 1)
> +#define GST_ELEMENT_REQUEST_PAD gst_element_request_pad_simple
> +#else
> +#define GST_ELEMENT_REQUEST_PAD gst_element_get_request_pad
> +#endif

I wonder if we could use the new function name unconditionally in the
code, and define a wrapper for older gstreamer versions:

#if !GST_CHECK_VERSION(1, 19, 1)
static inline GstPad *gst_element_request_pad_simple(GstElement *element,
						     const gchar *name)
{
	return gst_element_get_request_pad(element, name);
}
#endif

> +
>  using namespace std;
>  
>  class GstreamerMultiStreamTest : public GstreamerTest, public Test
> @@ -87,7 +93,7 @@ protected:
>  				 stream0_, stream1_, NULL);
>  
>  		g_autoptr(GstPad) src_pad = gst_element_get_static_pad(libcameraSrc_, "src");
> -		g_autoptr(GstPad) request_pad = gst_element_get_request_pad(libcameraSrc_, "src_%u");
> +		g_autoptr(GstPad) request_pad = GST_ELEMENT_REQUEST_PAD(libcameraSrc_, "src_%u");
>  
>  		{
>  			g_autoptr(GstPad) queue0_sink_pad = gst_element_get_static_pad(stream0_, "sink");
Nicolas Dufresne Dec. 1, 2021, 1:17 p.m. UTC | #2
Le mardi 30 novembre 2021 à 22:56 +0200, Laurent Pinchart a écrit :
> Hi Xavier,
> 
> (CC'ing Nicolas)
> 
> Thank you for the patch.
> 
> On Tue, Nov 30, 2021 at 07:29:43PM +0100, Xavier Roumegue (OSS) wrote:
> > From: Xavier Roumegue <xavier.roumegue@oss.nxp.com>
> > 
> > gst_element_get_request_pad() is being replaced by gst_element_request_simple()
> > since 1.19.1, throwing a warning in case of use until its definitive
> > replacement on 1.20.
> > 
> > Hence, prefer using gst_element_request_simple() in case gstreamer
> > version is >= 1.19.1 to avoid the compilation error below (tested on f35):
> > 
> > [3/88] Compiling C++ object test/gstreamer/multi_stream_test.p/gstreamer_multi_stream_test.cpp.o
> > FAILED: test/gstreamer/multi_stream_test.p/gstreamer_multi_stream_test.cpp.o
> > c++ -Itest/gstreamer/multi_stream_test.p -Itest/gstreamer -I../test/gstreamer -Itest/libtest -I../test/libtest -Iinclude -I../include -Iinclude/libcamera/ipa -Iinclude/libcamera -I/usr/include/gstreamer-1.0 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/sysprof-4 -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wnon-virtual-dtor -Wextra -Werror -std=c++17 -g -Wshadow -include config.h -pthread -DLIBCAMERA_BASE_PRIVATE -MD -MQ test/gstreamer/multi_stream_test.p/gstreamer_multi_stream_test.cpp.o -MF test/gstreamer/multi_stream_test.p/gstreamer_multi_stream_test.cpp.o.d -o test/gstreamer/multi_stream_test.p/gstreamer_multi_stream_test.cpp.o -c ../test/gstreamer/gstreamer_multi_stream_test.cpp
> > ../test/gstreamer/gstreamer_multi_stream_test.cpp: In member function ‘virtual int GstreamerMultiStreamTest::run()’:
> > ../test/gstreamer/gstreamer_multi_stream_test.cpp:97:72: error: ‘GstPad* gst_element_get_request_pad(GstElement*, const gchar*)’ is deprecated: Use 'gst_element_request_pad_simple' instead [-Werror=deprecated-declarations]
> >    97 |                 g_autoptr(GstPad) request_pad = GST_ELEMENT_REQUEST_PAD(libcameraSrc_, "src_%u");
> >       |                                                                        ^
> > In file included from /usr/include/gstreamer-1.0/gst/gstbin.h:27,
> >                  from /usr/include/gstreamer-1.0/gst/gst.h:35,
> >                  from ../test/gstreamer/gstreamer_multi_stream_test.cpp:13:
> > /usr/include/gstreamer-1.0/gst/gstelement.h:1042:25: note: declared here
> >  1042 | GstPad*                 gst_element_get_request_pad     (GstElement *element, const gchar *name);
> >       |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~
> > cc1plus: all warnings being treated as errors
> > 
> > Signed-off-by: Xavier Roumegue <xavier.roumegue@oss.nxp.com>
> > ---
> >  test/gstreamer/gstreamer_multi_stream_test.cpp | 8 +++++++-
> >  1 file changed, 7 insertions(+), 1 deletion(-)
> > 
> > diff --git a/test/gstreamer/gstreamer_multi_stream_test.cpp b/test/gstreamer/gstreamer_multi_stream_test.cpp
> > index d3d7a9d3..1e3c9f18 100644
> > --- a/test/gstreamer/gstreamer_multi_stream_test.cpp
> > +++ b/test/gstreamer/gstreamer_multi_stream_test.cpp
> > @@ -15,6 +15,12 @@
> >  #include "gstreamer_test.h"
> >  #include "test.h"
> >  
> > +#if GST_CHECK_VERSION(1, 19, 1)
> > +#define GST_ELEMENT_REQUEST_PAD gst_element_request_pad_simple
> > +#else
> > +#define GST_ELEMENT_REQUEST_PAD gst_element_get_request_pad
> > +#endif
> 
> I wonder if we could use the new function name unconditionally in the
> code, and define a wrapper for older gstreamer versions:

I would also prefer this, it keeps the code more readable. Notice this is a
rename, nothing have changed otherwise.

> 
> #if !GST_CHECK_VERSION(1, 19, 1)
> static inline GstPad *gst_element_request_pad_simple(GstElement *element,
> 						     const gchar *name)
> {
> 	return gst_element_get_request_pad(element, name);
> }
> #endif
> 
> > +
> >  using namespace std;
> >  
> >  class GstreamerMultiStreamTest : public GstreamerTest, public Test
> > @@ -87,7 +93,7 @@ protected:
> >  				 stream0_, stream1_, NULL);
> >  
> >  		g_autoptr(GstPad) src_pad = gst_element_get_static_pad(libcameraSrc_, "src");
> > -		g_autoptr(GstPad) request_pad = gst_element_get_request_pad(libcameraSrc_, "src_%u");
> > +		g_autoptr(GstPad) request_pad = GST_ELEMENT_REQUEST_PAD(libcameraSrc_, "src_%u");
> >  
> >  		{
> >  			g_autoptr(GstPad) queue0_sink_pad = gst_element_get_static_pad(stream0_, "sink");
>

Patch
diff mbox series

diff --git a/test/gstreamer/gstreamer_multi_stream_test.cpp b/test/gstreamer/gstreamer_multi_stream_test.cpp
index d3d7a9d3..1e3c9f18 100644
--- a/test/gstreamer/gstreamer_multi_stream_test.cpp
+++ b/test/gstreamer/gstreamer_multi_stream_test.cpp
@@ -15,6 +15,12 @@ 
 #include "gstreamer_test.h"
 #include "test.h"
 
+#if GST_CHECK_VERSION(1, 19, 1)
+#define GST_ELEMENT_REQUEST_PAD gst_element_request_pad_simple
+#else
+#define GST_ELEMENT_REQUEST_PAD gst_element_get_request_pad
+#endif
+
 using namespace std;
 
 class GstreamerMultiStreamTest : public GstreamerTest, public Test
@@ -87,7 +93,7 @@  protected:
 				 stream0_, stream1_, NULL);
 
 		g_autoptr(GstPad) src_pad = gst_element_get_static_pad(libcameraSrc_, "src");
-		g_autoptr(GstPad) request_pad = gst_element_get_request_pad(libcameraSrc_, "src_%u");
+		g_autoptr(GstPad) request_pad = GST_ELEMENT_REQUEST_PAD(libcameraSrc_, "src_%u");
 
 		{
 			g_autoptr(GstPad) queue0_sink_pad = gst_element_get_static_pad(stream0_, "sink");