About
Contact
QtCreator
KDevelop
Solarized
1
// Copyright (C) 2022 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4
#include
"qgstreamerintegration_p.h"
5
#include
"qgstreamervideodevices_p.h"
6
#include
"qgstreamermediaplayer_p.h"
7
#include
"qgstreamermediacapture_p.h"
8
#include
"qgstreameraudiodecoder_p.h"
9
#include
"qgstreamercamera_p.h"
10
#include
"qgstreamermediaencoder_p.h"
11
#include
"qgstreamerimagecapture_p.h"
12
#include
"qgstreamerformatinfo_p.h"
13
#include
"qgstreamervideosink_p.h"
14
#include
"qgstreameraudioinput_p.h"
15
#include
"qgstreameraudiooutput_p.h"
16
#include <QtMultimedia/private/qplatformmediaplugin_p.h>
17
18
#include
<memory>
19
20
QT_BEGIN_NAMESPACE
21
22
class
QGstreamerMediaPlugin
:
public
QPlatformMediaPlugin
23
{
24
Q_OBJECT
25
Q_PLUGIN_METADATA
(IID
QPlatformMediaPlugin_iid
FILE
"gstreamer.json"
)
26
27
public
:
28
QGstreamerMediaPlugin
()
29
:
QPlatformMediaPlugin
(
)
30
{}
31
32
QPlatformMediaIntegration
*
create
(
const
QString
&
name
) override
33
{
34
if
(
name
==
QLatin1String
(
"gstreamer"
))
35
return
new
QGstreamerIntegration
;
36
return
nullptr
;
37
}
38
};
39
40
QGstreamerIntegration
::
QGstreamerIntegration
()
41
{
42
gst_init
(
argc:
nullptr
,
argv:
nullptr
);
43
m_videoDevices
=
std::
make_unique
<
QGstreamerVideoDevices
>(
args:
this
);
44
}
45
46
QPlatformMediaFormatInfo
*
QGstreamerIntegration
::
createFormatInfo
()
47
{
48
return
new
QGstreamerFormatInfo
(
);
49
}
50
51
const
QGstreamerFormatInfo
*
QGstreamerIntegration
::
gstFormatsInfo
()
52
{
53
return
static_cast
<
const
QGstreamerFormatInfo
*>(
formatInfo
());
54
}
55
56
QMaybe
<
QPlatformAudioDecoder
*>
QGstreamerIntegration
::
createAudioDecoder
(
QAudioDecoder
*
decoder
)
57
{
58
return
QGstreamerAudioDecoder
::
create
(
parent:
decoder
);
59
}
60
61
QMaybe
<
QPlatformMediaCaptureSession
*>
QGstreamerIntegration
::
createCaptureSession
()
62
{
63
return
QGstreamerMediaCapture
::
create
();
64
}
65
66
QMaybe
<
QPlatformMediaPlayer
*>
QGstreamerIntegration
::
createPlayer
(
QMediaPlayer
*
player
)
67
{
68
return
QGstreamerMediaPlayer
::
create
(
parent:
player
);
69
}
70
71
QMaybe
<
QPlatformCamera
*>
QGstreamerIntegration
::
createCamera
(
QCamera
*
camera
)
72
{
73
return
QGstreamerCamera
::
create
(
camera
);
74
}
75
76
QMaybe
<
QPlatformMediaRecorder
*>
QGstreamerIntegration
::
createRecorder
(
QMediaRecorder
*
recorder
)
77
{
78
return
new
QGstreamerMediaEncoder
(
recorder
);
79
}
80
81
QMaybe
<
QPlatformImageCapture
*>
QGstreamerIntegration
::
createImageCapture
(
QImageCapture
*
imageCapture
)
82
{
83
return
QGstreamerImageCapture
::
create
(
parent:
imageCapture
);
84
}
85
86
QMaybe
<
QPlatformVideoSink
*>
QGstreamerIntegration
::
createVideoSink
(
QVideoSink
*
sink
)
87
{
88
return
new
QGstreamerVideoSink
(
sink
);
89
}
90
91
QMaybe
<
QPlatformAudioInput
*>
QGstreamerIntegration
::
createAudioInput
(
QAudioInput
*
q
)
92
{
93
return
QGstreamerAudioInput
::
create
(
parent:
q
);
94
}
95
96
QMaybe
<
QPlatformAudioOutput
*>
QGstreamerIntegration
::
createAudioOutput
(
QAudioOutput
*
q
)
97
{
98
return
QGstreamerAudioOutput
::
create
(
parent:
q
);
99
}
100
101
GstDevice
*
QGstreamerIntegration
::
videoDevice
(
const
QByteArray
&
id
)
const
102
{
103
return
m_videoDevices
104
?
static_cast
<
QGstreamerVideoDevices
*>(
m_videoDevices
.
get
())->
videoDevice
(
id
)
105
:
nullptr
;
106
}
107
108
QT_END_NAMESPACE
109
110
#include
"qgstreamerintegration.moc"
111