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): [258/391] 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:90:76: error: ‘GstPad* gst_element_get_request_pad(GstElement*, const gchar*)’ is deprecated: Use 'gst_element_request_pad_simple' instead [-Werror=deprecated-declarations] 90 | g_autoptr(GstPad) request_pad = gst_element_get_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> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
132 lines
2.9 KiB
C++
132 lines
2.9 KiB
C++
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
/*
|
|
* Copyright (C) 2021, Vedant Paranjape
|
|
*
|
|
* gstreamer_multi_stream_test.cpp - GStreamer multi stream capture test
|
|
*/
|
|
|
|
#include <iostream>
|
|
#include <unistd.h>
|
|
|
|
#include <libcamera/libcamera.h>
|
|
|
|
#include <gst/gst.h>
|
|
|
|
#include "gstreamer_test.h"
|
|
#include "test.h"
|
|
|
|
#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
|
|
{
|
|
public:
|
|
GstreamerMultiStreamTest()
|
|
: GstreamerTest()
|
|
{
|
|
}
|
|
|
|
protected:
|
|
int init() override
|
|
{
|
|
if (status_ != TestPass)
|
|
return status_;
|
|
|
|
/* Check if platform supports multistream capture */
|
|
libcamera::CameraManager cm;
|
|
cm.start();
|
|
bool cameraFound = false;
|
|
for (auto &camera : cm.cameras()) {
|
|
if (camera->streams().size() > 1) {
|
|
cameraName_ = camera->id();
|
|
cameraFound = true;
|
|
cm.stop();
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (!cameraFound) {
|
|
cm.stop();
|
|
return TestSkip;
|
|
}
|
|
|
|
const gchar *streamDescription = "queue ! fakesink";
|
|
g_autoptr(GError) error = NULL;
|
|
|
|
stream0_ = gst_parse_bin_from_description_full(streamDescription, TRUE,
|
|
NULL,
|
|
GST_PARSE_FLAG_FATAL_ERRORS,
|
|
&error);
|
|
if (!stream0_) {
|
|
g_printerr("Stream0 could not be created (%s)\n", error->message);
|
|
return TestFail;
|
|
}
|
|
g_object_ref_sink(stream0_);
|
|
|
|
stream1_ = gst_parse_bin_from_description_full(streamDescription, TRUE,
|
|
NULL,
|
|
GST_PARSE_FLAG_FATAL_ERRORS,
|
|
&error);
|
|
if (!stream1_) {
|
|
g_printerr("Stream1 could not be created (%s)\n", error->message);
|
|
return TestFail;
|
|
}
|
|
g_object_ref_sink(stream1_);
|
|
|
|
if (createPipeline() != TestPass)
|
|
return TestFail;
|
|
|
|
return TestPass;
|
|
}
|
|
|
|
int run() override
|
|
{
|
|
g_object_set(libcameraSrc_, "camera-name", cameraName_.c_str(), NULL);
|
|
|
|
/* Build the pipeline */
|
|
gst_bin_add_many(GST_BIN(pipeline_), libcameraSrc_,
|
|
stream0_, stream1_, NULL);
|
|
|
|
g_autoptr(GstPad) src_pad = gst_element_get_static_pad(libcameraSrc_, "src");
|
|
g_autoptr(GstPad) request_pad = gst_element_request_pad_simple(libcameraSrc_, "src_%u");
|
|
|
|
{
|
|
g_autoptr(GstPad) queue0_sink_pad = gst_element_get_static_pad(stream0_, "sink");
|
|
g_autoptr(GstPad) queue1_sink_pad = gst_element_get_static_pad(stream1_, "sink");
|
|
|
|
if (gst_pad_link(src_pad, queue0_sink_pad) != GST_PAD_LINK_OK ||
|
|
gst_pad_link(request_pad, queue1_sink_pad) != GST_PAD_LINK_OK) {
|
|
g_printerr("Pads could not be linked.\n");
|
|
return TestFail;
|
|
}
|
|
}
|
|
|
|
if (startPipeline() != TestPass)
|
|
return TestFail;
|
|
|
|
if (processEvent() != TestPass)
|
|
return TestFail;
|
|
|
|
return TestPass;
|
|
}
|
|
|
|
void cleanup() override
|
|
{
|
|
g_clear_object(&stream0_);
|
|
g_clear_object(&stream1_);
|
|
}
|
|
|
|
private:
|
|
std::string cameraName_;
|
|
GstElement *stream0_;
|
|
GstElement *stream1_;
|
|
};
|
|
|
|
TEST_REGISTER(GstreamerMultiStreamTest)
|