Music Hub  ..
A session-wide music playback service
platform_default_sink.cpp
Go to the documentation of this file.
1 /*
2  * Copyright © 2014 Canonical Ltd.
3  *
4  * This program is free software: you can redistribute it and/or modify it
5  * under the terms of the GNU Lesser General Public License version 3,
6  * as published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * Authored by: Thomas Voß <thomas.voss@canonical.com>
17  */
18 
20 
24 
25 namespace media = core::ubuntu::media;
27 
28 namespace
29 {
30 struct NullSink : public video::Sink
31 {
32  // The signal is emitted whenever a new frame is available and a subsequent
33  // call to swap_buffers will not block and return true.
34  const core::Signal<void>& frame_available() const
35  {
36  return signal_frame_available;
37  }
38 
39  // Queries the transformation matrix for the current frame, placing the data into 'matrix'
40  // and returns true or returns false and leaves 'matrix' unchanged in case
41  // of issues.
42  bool transformation_matrix(float*) const
43  {
44  return true;
45  }
46 
47  // Releases the current buffer, and consumes the next buffer in the queue,
48  // making it available for consumption by consumers of this API in an
49  // implementation-specific way. Clients will usually rely on a GL texture
50  // to receive the latest buffer.
51  bool swap_buffers() const
52  {
53  return true;
54  }
55 
56  core::Signal<void> signal_frame_available;
57 };
58 }
59 
62 {
63  switch (b)
64  {
65  case media::AVBackend::Backend::hybris:
66  MH_DEBUG("Using hybris video sink");
68  case media::AVBackend::Backend::mir:
69  MH_DEBUG("Using mir/egl video sink");
71  case media::AVBackend::Backend::none:
72  MH_WARNING(
73  "No video backend selected. Video rendering functionality won't work."
74  );
75  return [](std::uint32_t) { return video::Sink::Ptr{}; };
76  default:
77  MH_INFO("Invalid or no A/V backend specified, using \"hybris\" as a default.");
79  }
80 }
SinkFactory make_platform_default_sink_factory(const Player::PlayerKey &key, const AVBackend::Backend b)
virtual bool transformation_matrix(float *matrix) const =0
Queries the 4x4 transformation matrix for the current frame, placing the data into &#39;matrix&#39;...
#define MH_INFO(...)
Definition: logger.h:125
A video sink abstracts a queue of buffers, that receives a stream of decoded video buffers from an ar...
Definition: sink.h:36
#define MH_DEBUG(...)
Definition: logger.h:123
static std::function< video::Sink::Ptr(std::uint32_t)> factory_for_key(const media::Player::PlayerKey &)
virtual const core::Signal< void > & frame_available() const =0
The signal is emitted whenever a new frame is available and a subsequent call to swap_buffers will no...
#define MH_WARNING(...)
Definition: logger.h:127
std::shared_ptr< Sink > Ptr
To save us some typing.
Definition: sink.h:39
std::function< Sink::Ptr(std::uint32_t)> SinkFactory
static std::function< video::Sink::Ptr(std::uint32_t)> factory_for_key(const media::Player::PlayerKey &)
virtual bool swap_buffers() const =0
Releases the current buffer, and consumes the next buffer in the queue, making it available for consu...