~ricmm/media-hub/multiple-sessions

« back to all changes in this revision

Viewing changes to src/core/media/codec.h

MergedĀ lp:~thomas-voss/media-hub/switch-to-properties-cpp

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
#ifndef CODEC_H_
20
20
#define CODEC_H_
21
21
 
 
22
#include <core/media/player.h>
22
23
#include <core/media/track.h>
23
24
 
24
 
#include <org/freedesktop/dbus/codec.h>
 
25
#include <core/dbus/codec.h>
25
26
 
26
 
namespace org
27
 
{
28
 
namespace freedesktop
 
27
namespace core
29
28
{
30
29
namespace dbus
31
30
{
58
57
template<>
59
58
struct Codec<core::ubuntu::media::Track::MetaData>
60
59
{
61
 
    static void encode_argument(DBusMessageIter* out, const core::ubuntu::media::Track::MetaData& in)
62
 
    {
63
 
        Codec<typename core::ubuntu::location::units::Quantity<T>::value_type>::encode_argument(out, in.value());
64
 
    }
65
 
 
66
 
    static void decode_argument(DBusMessageIter* out, com::ubuntu::location::units::Quantity<T>& in)
67
 
    {
68
 
        typename core::ubuntu::location::units::Quantity<T>::value_type value;
69
 
        Codec<typename com::ubuntu::location::units::Quantity<T>::value_type>::decode_argument(out, value);
70
 
        in = core::ubuntu::location::units::Quantity<T>::from_value(value);
71
 
        dbus_message_iter_next(out);
72
 
    }
73
 
};
74
 
}
 
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<>
 
100
struct Codec<core::ubuntu::media::Player::PlaybackStatus>
 
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<>
 
139
struct Codec<core::ubuntu::media::Player::LoopStatus>
 
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
 
75
152
}
76
153
}
77
154