Music Hub  ..
A session-wide music playback service
video_sink.cpp
Go to the documentation of this file.
1 /*
2  * Copyright © 2021-2022 UBports Foundation.
3  *
4  * Contact: Alberto Mardegan <mardy@users.sourceforge.net>
5  *
6  * This program is free software: you can redistribute it and/or modify it
7  * under the terms of the GNU Lesser General Public License version 3,
8  * as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #include "video_sink_p.h"
20 
21 #include "egl_video_sink.h"
22 #include "hybris_video_sink.h"
23 
24 using namespace lomiri::MediaHub;
25 
26 class NullVideoSink: public VideoSink
27 {
28  Q_OBJECT
29 
30 public:
32  VideoSink(new VideoSinkPrivate(), parent)
33  {
34  }
35 
36  bool swapBuffers() override { return true; }
37 };
38 
40  QObject(parent),
41  d_ptr(d)
42 {
43 }
44 
45 VideoSink::~VideoSink() = default;
46 
47 const QMatrix4x4 &VideoSink::transformationMatrix() const
48 {
49  Q_D(const VideoSink);
50  return d->m_transformationMatrix;
51 }
52 
54  PlayerKey key,
55  AVBackend::Backend backend)
56 {
57  switch (backend) {
59  qDebug() << "Using Hybris video sink";
62  qDebug() << "Using Mir/EGL video sink";
63  return EglVideoSink::createFactory(key);
65  qDebug() << "No video backend selected. "
66  "Video rendering functionality won't work.";
67  return [](uint32_t textureId, QObject *parent) {
68  Q_UNUSED(textureId);
69  return new NullVideoSink(parent);
70  };
71  default:
72  qWarning() << "Invalid or no A/V backend specified, "
73  "using \"hybris\" as a default." << backend;
75  }
76 }
77 
78 #include "video_sink.moc"
lomiri::MediaHub
Definition: dbus_utils.h:25
QObject
lomiri::MediaHub::VideoSink::transformationMatrix
const QMatrix4x4 & transformationMatrix() const
Queries the 4x4 transformation matrix for the current frame.
Definition: video_sink.cpp:47
NullVideoSink
Definition: video_sink.cpp:26
hybris_video_sink.h
lomiri::MediaHub::VideoSink
A video sink abstracts a queue of buffers, that receives a stream of decoded video buffers from an ar...
Definition: video_sink.h:34
lomiri::MediaHub::VideoSink::VideoSink
VideoSink(VideoSinkPrivate *d, QObject *parent=nullptr)
Definition: video_sink.cpp:39
NullVideoSink::swapBuffers
bool swapBuffers() override
Releases the current buffer, and consumes the next buffer in the queue, making it available for consu...
Definition: video_sink.cpp:36
lomiri::MediaHub::VideoSinkFactory
std::function< VideoSink *(uint32_t textureId, QObject *parent)> VideoSinkFactory
Definition: video_sink_p.h:43
lomiri::MediaHub::createVideoSinkFactory
VideoSinkFactory createVideoSinkFactory(PlayerKey key, AVBackend::Backend backend)
Definition: video_sink.cpp:53
DBusConstants::None
@ None
Definition: dbus_constants.h:71
NullVideoSink::NullVideoSink
NullVideoSink(QObject *parent)
Definition: video_sink.cpp:31
video_sink_p.h
egl_video_sink.h
DBusConstants::Hybris
@ Hybris
Definition: dbus_constants.h:72
lomiri::MediaHub::AVBackend::Backend
Backend
Definition: video_sink_p.h:34
lomiri::MediaHub::PlayerKey
uint32_t PlayerKey
Definition: video_sink_p.h:44
DBusConstants::Mir
@ Mir
Definition: dbus_constants.h:73
lomiri::MediaHub::VideoSinkPrivate
Definition: video_sink_p.h:49
lomiri::MediaHub::VideoSink::~VideoSink
virtual ~VideoSink()
lomiri::MediaHub::HybrisVideoSink::createFactory
static VideoSinkFactory createFactory(PlayerKey playerKey)
Definition: hybris_video_sink.cpp:107
lomiri::MediaHub::EglVideoSink::createFactory
static VideoSinkFactory createFactory(PlayerKey playerKey)
Definition: egl_video_sink.cpp:294