Qt 6.x
The Qt SDK
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
qgstreamerbufferprobe.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 Jolla Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
5#include "qgstutils_p.h"
6
8
10 : m_flags(flags)
11{
12}
13
15
16void QGstreamerBufferProbe::addProbeToPad(GstPad *pad, bool downstream)
17{
18 if (GstCaps *caps = gst_pad_get_current_caps(pad)) {
19 probeCaps(caps);
20 gst_caps_unref(caps);
21 }
22 if (m_flags & ProbeCaps) {
23 m_capsProbeId = gst_pad_add_probe(
24 pad,
25 downstream
26 ? GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM
27 : GST_PAD_PROBE_TYPE_EVENT_UPSTREAM,
28 capsProbe,
29 this,
30 nullptr);
31 }
32 if (m_flags & ProbeBuffers) {
33 m_bufferProbeId = gst_pad_add_probe(
34 pad, GST_PAD_PROBE_TYPE_BUFFER, bufferProbe, this, nullptr);
35 }
36}
37
39{
40 if (m_capsProbeId != -1) {
41 gst_pad_remove_probe(pad, m_capsProbeId);
42 m_capsProbeId = -1;
43 }
44 if (m_bufferProbeId != -1) {
45 gst_pad_remove_probe(pad, m_bufferProbeId);
46 m_bufferProbeId = -1;
47 }
48}
49
51{
52}
53
55{
56 return true;
57}
58
59GstPadProbeReturn QGstreamerBufferProbe::capsProbe(GstPad *, GstPadProbeInfo *info, gpointer user_data)
60{
61 QGstreamerBufferProbe * const control = static_cast<QGstreamerBufferProbe *>(user_data);
62
63 if (GstEvent * const event = gst_pad_probe_info_get_event(info)) {
64 if (GST_EVENT_TYPE(event) == GST_EVENT_CAPS) {
65 GstCaps *caps;
66 gst_event_parse_caps(event, &caps);
67
68 control->probeCaps(caps);
69 }
70 }
71 return GST_PAD_PROBE_OK;
72}
73
74GstPadProbeReturn QGstreamerBufferProbe::bufferProbe(
75 GstPad *, GstPadProbeInfo *info, gpointer user_data)
76{
77 QGstreamerBufferProbe * const control = static_cast<QGstreamerBufferProbe *>(user_data);
78 if (GstBuffer * const buffer = gst_pad_probe_info_get_buffer(info))
79 return control->probeBuffer(buffer) ? GST_PAD_PROBE_OK : GST_PAD_PROBE_DROP;
80 return GST_PAD_PROBE_OK;
81}
82
virtual bool probeBuffer(GstBuffer *buffer)
QGstreamerBufferProbe(Flags flags=ProbeAll)
virtual ~QGstreamerBufferProbe()
void removeProbeFromPad(GstPad *pad)
virtual void probeCaps(GstCaps *caps)
void addProbeToPad(GstPad *pad, bool downstream=true)
Combined button and popup list for selecting options.
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void * user_data
GLenum GLuint buffer
GLbitfield flags
struct _cl_event * event
QFileInfo info(fileName)
[8]