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 
21 namespace media = core::ubuntu::media;
23 
24 namespace
25 {
26 struct NullSink : public video::Sink
27 {
28  // The signal is emitted whenever a new frame is available and a subsequent
29  // call to swap_buffers will not block and return true.
30  const core::Signal<void>& frame_available() const
31  {
32  return signal_frame_available;
33  }
34 
35  // Queries the transformation matrix for the current frame, placing the data into 'matrix'
36  // and returns true or returns false and leaves 'matrix' unchanged in case
37  // of issues.
38  bool transformation_matrix(float*) const
39  {
40  return true;
41  }
42 
43  // Releases the current buffer, and consumes the next buffer in the queue,
44  // making it available for consumption by consumers of this API in an
45  // implementation-specific way. Clients will usually rely on a GL texture
46  // to receive the latest buffer.
47  bool swap_buffers() const
48  {
49  return true;
50  }
51 
52  core::Signal<void> signal_frame_available;
53 };
54 }
55 
56 #if defined(MEDIA_HUB_HAVE_HYBRIS_MEDIA_COMPAT_LAYER)
58 
60 {
62 }
63 #else // MEDIA_HUB_HAVE_HYBRIS_MEDIA_COMPAT_LAYER
65 {
66  return [](std::uint32_t) { return video::Sink::Ptr{}; };
67 }
68 #endif // MEDIA_HUB_HAVE_HYBRIS_MEDIA_COMPAT_LAYER
SinkFactory make_platform_default_sink_factory(const Player::PlayerKey &key)
virtual bool transformation_matrix(float *matrix) const =0
Queries the 4x4 transformation matrix for the current frame, placing the data into &#39;matrix&#39;...
A video sink abstracts a queue of buffers, that receives a stream of decoded video buffers from an ar...
Definition: sink.h:36
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...
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...