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-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  * Jim Hodapp <jim.hodapp@canonical.com>
18  */
19 
20 #ifndef CODEC_H_
21 #define CODEC_H_
22 
23 #include <core/media/player.h>
24 #include <core/media/track.h>
25 
26 #include <core/dbus/codec.h>
27 
28 namespace core
29 {
30 namespace dbus
31 {
32 namespace helper
33 {
34 template<>
36 {
37  constexpr static ArgumentType type_value()
38  {
39  return ArgumentType::floating_point;
40  }
41  constexpr static bool is_basic_type()
42  {
43  return false;
44  }
45  constexpr static bool requires_signature()
46  {
47  return false;
48  }
49 
50  static std::string signature()
51  {
52  static const std::string s = TypeMapper<double>::signature();
53  return s;
54  }
55 };
56 }
57 
58 template<>
60 {
61  static void encode_argument(core::dbus::Message::Writer& out, const core::ubuntu::media::Track::MetaData& in)
62  {
63  (void) out;
64  (void) in;
65  }
66 
67  static void decode_argument(core::dbus::Message::Reader& out, core::ubuntu::media::Track::MetaData& in)
68  {
69  (void) out;
70  (void) in;
71  }
72 };
73 
74 namespace helper
75 {
76 template<>
78 {
79  constexpr static ArgumentType type_value()
80  {
81  return core::dbus::ArgumentType::int16;
82  }
83  constexpr static bool is_basic_type()
84  {
85  return false;
86  }
87  constexpr static bool requires_signature()
88  {
89  return false;
90  }
91 
92  static std::string signature()
93  {
94  static const std::string s = TypeMapper<std::int16_t>::signature();
95  return s;
96  }
97 };
98 }
99 
100 template<>
102 {
103  static void encode_argument(core::dbus::Message::Writer& out, const core::ubuntu::media::Player::PlaybackStatus& in)
104  {
105  out.push_int16(static_cast<std::int16_t>(in));
106  }
107 
108  static void decode_argument(core::dbus::Message::Reader& out, core::ubuntu::media::Player::PlaybackStatus& in)
109  {
110  in = static_cast<core::ubuntu::media::Player::PlaybackStatus>(out.pop_int16());
111  }
112 };
113 namespace helper
114 {
115 template<>
117 {
118  constexpr static ArgumentType type_value()
119  {
120  return core::dbus::ArgumentType::int16;
121  }
122  constexpr static bool is_basic_type()
123  {
124  return false;
125  }
126  constexpr static bool requires_signature()
127  {
128  return false;
129  }
130 
131  static std::string signature()
132  {
133  static const std::string s = TypeMapper<std::int16_t>::signature();
134  return s;
135  }
136 };
137 }
138 
139 template<>
141 {
142  static void encode_argument(core::dbus::Message::Writer& out, const core::ubuntu::media::Player::LoopStatus& in)
143  {
144  out.push_int16(static_cast<std::int16_t>(in));
145  }
146 
147  static void decode_argument(core::dbus::Message::Reader& out, core::ubuntu::media::Player::LoopStatus& in)
148  {
149  in = static_cast<core::ubuntu::media::Player::LoopStatus>(out.pop_int16());
150  }
151 };
152 
153 namespace helper
154 {
155 template<>
157 {
158  constexpr static ArgumentType type_value()
159  {
160  return core::dbus::ArgumentType::int16;
161  }
162  constexpr static bool is_basic_type()
163  {
164  return false;
165  }
166  constexpr static bool requires_signature()
167  {
168  return false;
169  }
170 
171  static std::string signature()
172  {
173  static const std::string s = TypeMapper<std::int16_t>::signature();
174  return s;
175  }
176 };
177 }
178 
179 template<>
181 {
182  static void encode_argument(core::dbus::Message::Writer& out, const core::ubuntu::media::Player::AudioStreamRole& in)
183  {
184  out.push_int16(static_cast<std::int16_t>(in));
185  }
186 
187  static void decode_argument(core::dbus::Message::Reader& out, core::ubuntu::media::Player::AudioStreamRole& in)
188  {
189  in = static_cast<core::ubuntu::media::Player::AudioStreamRole>(out.pop_int16());
190  }
191 };
192 
193 namespace helper
194 {
195 template<>
197 {
198  constexpr static ArgumentType type_value()
199  {
200  return core::dbus::ArgumentType::int16;
201  }
202  constexpr static bool is_basic_type()
203  {
204  return false;
205  }
206  constexpr static bool requires_signature()
207  {
208  return false;
209  }
210 
211  static std::string signature()
212  {
213  static const std::string s = TypeMapper<std::int16_t>::signature();
214  return s;
215  }
216 };
217 }
218 
219 template<>
221 {
222  static void encode_argument(core::dbus::Message::Writer& out, const core::ubuntu::media::Player::Orientation& in)
223  {
224  out.push_int16(static_cast<std::int16_t>(in));
225  }
226 
227  static void decode_argument(core::dbus::Message::Reader& out, core::ubuntu::media::Player::Orientation& in)
228  {
229  in = static_cast<core::ubuntu::media::Player::Orientation>(out.pop_int16());
230  }
231 };
232 
233 namespace helper
234 {
235 template<>
237 {
238  constexpr static ArgumentType type_value()
239  {
240  return core::dbus::ArgumentType::int16;
241  }
242  constexpr static bool is_basic_type()
243  {
244  return false;
245  }
246  constexpr static bool requires_signature()
247  {
248  return false;
249  }
250 
251  static std::string signature()
252  {
253  static const std::string s = TypeMapper<std::int16_t>::signature();
254  return s;
255  }
256 };
257 }
258 
259 template<>
261 {
262  static void encode_argument(core::dbus::Message::Writer& out, const core::ubuntu::media::Player::Lifetime& in)
263  {
264  out.push_int16(static_cast<std::int16_t>(in));
265  }
266 
267  static void decode_argument(core::dbus::Message::Reader& out, core::ubuntu::media::Player::Lifetime& in)
268  {
269  in = static_cast<core::ubuntu::media::Player::Lifetime>(out.pop_int16());
270  }
271 };
272 
273 }
274 }
275 
276 #endif // CODEC_H_
static void encode_argument(core::dbus::Message::Writer &out, const core::ubuntu::media::Track::MetaData &in)
Definition: codec.h:61
static void decode_argument(core::dbus::Message::Reader &out, core::ubuntu::media::Player::Orientation &in)
Definition: codec.h:227
static void decode_argument(core::dbus::Message::Reader &out, core::ubuntu::media::Player::PlaybackStatus &in)
Definition: codec.h:108
static void decode_argument(core::dbus::Message::Reader &out, core::ubuntu::media::Player::AudioStreamRole &in)
Definition: codec.h:187
static void encode_argument(core::dbus::Message::Writer &out, const core::ubuntu::media::Player::AudioStreamRole &in)
Definition: codec.h:182
Definition: player.h:29
static void decode_argument(core::dbus::Message::Reader &out, core::ubuntu::media::Player::Lifetime &in)
Definition: codec.h:267
static void encode_argument(core::dbus::Message::Writer &out, const core::ubuntu::media::Player::Lifetime &in)
Definition: codec.h:262
static void encode_argument(core::dbus::Message::Writer &out, const core::ubuntu::media::Player::PlaybackStatus &in)
Definition: codec.h:103
static void decode_argument(core::dbus::Message::Reader &out, core::ubuntu::media::Player::LoopStatus &in)
Definition: codec.h:147
static void encode_argument(core::dbus::Message::Writer &out, const core::ubuntu::media::Player::Orientation &in)
Definition: codec.h:222
static void decode_argument(core::dbus::Message::Reader &out, core::ubuntu::media::Track::MetaData &in)
Definition: codec.h:67
static void encode_argument(core::dbus::Message::Writer &out, const core::ubuntu::media::Player::LoopStatus &in)
Definition: codec.h:142