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 
22 
23 namespace media = core::ubuntu::media;
25 
26 namespace
27 {
28 struct NullSink : public video::Sink
29 {
30  // The signal is emitted whenever a new frame is available and a subsequent
31  // call to swap_buffers will not block and return true.
32  const core::Signal<void>& frame_available() const
33  {
34  return signal_frame_available;
35  }
36 
37  // Queries the transformation matrix for the current frame, placing the data into 'matrix'
38  // and returns true or returns false and leaves 'matrix' unchanged in case
39  // of issues.
40  bool transformation_matrix(float*) const
41  {
42  return true;
43  }
44 
45  // Releases the current buffer, and consumes the next buffer in the queue,
46  // making it available for consumption by consumers of this API in an
47  // implementation-specific way. Clients will usually rely on a GL texture
48  // to receive the latest buffer.
49  bool swap_buffers() const
50  {
51  return true;
52  }
53 
54  core::Signal<void> signal_frame_available;
55 };
56 }
57 
58 #if defined(MEDIA_HUB_HAVE_HYBRIS_MEDIA_COMPAT_LAYER)
60 
63 {
64  switch (b)
65  {
66  case media::AVBackend::Backend::hybris:
67  MH_DEBUG("Using hybris video sink");
69  case media::AVBackend::Backend::none:
70  MH_WARNING(
71  "No video backend selected. Video rendering functionality won't work."
72  );
73  return [](std::uint32_t) { return video::Sink::Ptr{}; };
74  default:
75  MH_INFO("Invalid or no A/V backend specified, using \"hybris\" as a default.");
77  }
78 }
79 #else // MEDIA_HUB_HAVE_HYBRIS_MEDIA_COMPAT_LAYER
81 {
82  return [](std::uint32_t) { return video::Sink::Ptr{}; };
83 }
84 #endif // MEDIA_HUB_HAVE_HYBRIS_MEDIA_COMPAT_LAYER
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
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...