Music Hub  ..
A session-wide music playback service
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
codec.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2013 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 
19 #ifndef CODEC_H_
20 #define CODEC_H_
21 
22 #include <core/media/player.h>
23 #include <core/media/track.h>
24 
25 #include <core/dbus/codec.h>
26 
27 namespace core
28 {
29 namespace dbus
30 {
31 namespace helper
32 {
33 template<>
34 struct TypeMapper<core::ubuntu::media::Track::MetaData>
35 {
36  constexpr static ArgumentType type_value()
37  {
38  return ArgumentType::floating_point;
39  }
40  constexpr static bool is_basic_type()
41  {
42  return false;
43  }
44  constexpr static bool requires_signature()
45  {
46  return false;
47  }
48 
49  static std::string signature()
50  {
51  static const std::string s = TypeMapper<double>::signature();
52  return s;
53  }
54 };
55 }
56 
57 template<>
58 struct Codec<core::ubuntu::media::Track::MetaData>
59 {
60  static void encode_argument(core::dbus::Message::Writer& out, const core::ubuntu::media::Track::MetaData& in)
61  {
62  (void) out;
63  (void) in;
64  }
65 
66  static void decode_argument(core::dbus::Message::Reader& out, core::ubuntu::media::Track::MetaData& in)
67  {
68  (void) out;
69  (void) in;
70  }
71 };
72 
73 namespace helper
74 {
75 template<>
76 struct TypeMapper<core::ubuntu::media::Player::PlaybackStatus>
77 {
78  constexpr static ArgumentType type_value()
79  {
80  return core::dbus::ArgumentType::int16;
81  }
82  constexpr static bool is_basic_type()
83  {
84  return false;
85  }
86  constexpr static bool requires_signature()
87  {
88  return false;
89  }
90 
91  static std::string signature()
92  {
93  static const std::string s = TypeMapper<std::int16_t>::signature();
94  return s;
95  }
96 };
97 }
98 
99 template<>
101 {
102  static void encode_argument(core::dbus::Message::Writer& out, const core::ubuntu::media::Player::PlaybackStatus& in)
103  {
104  out.push_int16(static_cast<std::int16_t>(in));
105  }
106 
107  static void decode_argument(core::dbus::Message::Reader& out, core::ubuntu::media::Player::PlaybackStatus& in)
108  {
109  in = static_cast<core::ubuntu::media::Player::PlaybackStatus>(out.pop_int16());
110  }
111 };
112 namespace helper
113 {
114 template<>
115 struct TypeMapper<core::ubuntu::media::Player::LoopStatus>
116 {
117  constexpr static ArgumentType type_value()
118  {
119  return core::dbus::ArgumentType::int16;
120  }
121  constexpr static bool is_basic_type()
122  {
123  return false;
124  }
125  constexpr static bool requires_signature()
126  {
127  return false;
128  }
129 
130  static std::string signature()
131  {
132  static const std::string s = TypeMapper<std::int16_t>::signature();
133  return s;
134  }
135 };
136 }
137 
138 template<>
140 {
141  static void encode_argument(core::dbus::Message::Writer& out, const core::ubuntu::media::Player::LoopStatus& in)
142  {
143  out.push_int16(static_cast<std::int16_t>(in));
144  }
145 
146  static void decode_argument(core::dbus::Message::Reader& out, core::ubuntu::media::Player::LoopStatus& in)
147  {
148  in = static_cast<core::ubuntu::media::Player::LoopStatus>(out.pop_int16());
149  }
150 };
151 
152 }
153 }
154 
155 #endif // CODEC_H_
static void encode_argument(core::dbus::Message::Writer &out, const core::ubuntu::media::Track::MetaData &in)
Definition: codec.h:60
static void decode_argument(core::dbus::Message::Reader &out, core::ubuntu::media::Player::PlaybackStatus &in)
Definition: codec.h:107
static void encode_argument(core::dbus::Message::Writer &out, const core::ubuntu::media::Player::PlaybackStatus &in)
Definition: codec.h:102
static void decode_argument(core::dbus::Message::Reader &out, core::ubuntu::media::Player::LoopStatus &in)
Definition: codec.h:146
static void decode_argument(core::dbus::Message::Reader &out, core::ubuntu::media::Track::MetaData &in)
Definition: codec.h:66
static void encode_argument(core::dbus::Message::Writer &out, const core::ubuntu::media::Player::LoopStatus &in)
Definition: codec.h:141