20 #ifndef MPRIS_PLAYER_H_
21 #define MPRIS_PLAYER_H_
28 #include <core/dbus/bus.h>
29 #include <core/dbus/macros.h>
30 #include <core/dbus/object.h>
31 #include <core/dbus/property.h>
32 #include <core/dbus/interfaces/properties.h>
33 #include <core/dbus/types/any.h>
34 #include <core/dbus/types/object_path.h>
35 #include <core/dbus/types/variant.h>
37 #include <core/dbus/types/stl/tuple.h>
39 #include <boost/utility/identity_type.hpp>
53 static const std::string&
name()
55 static const std::string s{
"org.mpris.MediaPlayer2.Player"};
67 case core::ubuntu::media::Player::LoopStatus::none:
69 case core::ubuntu::media::Player::LoopStatus::track:
71 case core::ubuntu::media::Player::LoopStatus::playlist:
78 static constexpr
const char*
none{
"None"};
79 static constexpr
const char*
track{
"Track"};
80 static constexpr
const char*
playlist{
"Playlist"};
91 case core::ubuntu::media::Player::PlaybackStatus::null:
92 case core::ubuntu::media::Player::PlaybackStatus::ready:
93 case core::ubuntu::media::Player::PlaybackStatus::stopped:
96 case core::ubuntu::media::Player::PlaybackStatus::playing:
98 case core::ubuntu::media::Player::PlaybackStatus::paused:
105 static constexpr
const char*
playing{
"Playing"};
106 static constexpr
const char*
paused{
"Paused"};
107 static constexpr
const char*
stopped{
"Stopped"};
114 static constexpr
const char*
name
116 "mpris.Player.Error.OutOfProcessBufferStreamingNotSupported"
121 typedef std::map<std::string, core::dbus::types::Variant>
Dictionary;
123 DBUS_CPP_METHOD_DEF(Next,
Player)
124 DBUS_CPP_METHOD_DEF(Previous,
Player)
125 DBUS_CPP_METHOD_DEF(Pause,
Player)
126 DBUS_CPP_METHOD_DEF(PlayPause,
Player)
127 DBUS_CPP_METHOD_DEF(Stop,
Player)
128 DBUS_CPP_METHOD_DEF(Play,
Player)
129 DBUS_CPP_METHOD_DEF(Seek,
Player)
130 DBUS_CPP_METHOD_DEF(SetPosition,
Player)
131 DBUS_CPP_METHOD_DEF(CreateVideoSink,
Player)
132 DBUS_CPP_METHOD_DEF(Key,
Player)
133 DBUS_CPP_METHOD_DEF(OpenUri,
Player)
134 DBUS_CPP_METHOD_DEF(OpenUriExtended,
Player)
138 DBUS_CPP_SIGNAL_DEF(Seeked,
Player, std::int64_t)
139 DBUS_CPP_SIGNAL_DEF(AboutToFinish,
Player,
void)
140 DBUS_CPP_SIGNAL_DEF(EndOfStream,
Player,
void)
156 DBUS_CPP_WRITABLE_PROPERTY_DEF(PlaybackRate,
Player,
double)
157 DBUS_CPP_WRITABLE_PROPERTY_DEF(Rate,
Player,
double)
158 DBUS_CPP_WRITABLE_PROPERTY_DEF(Shuffle,
Player,
bool)
159 DBUS_CPP_READABLE_PROPERTY_DEF(Metadata,
Player, Dictionary)
161 DBUS_CPP_WRITABLE_PROPERTY_DEF(Volume,
Player,
double)
162 DBUS_CPP_READABLE_PROPERTY_DEF(Position,
Player, std::int64_t)
163 DBUS_CPP_READABLE_PROPERTY_DEF(Duration,
Player, std::int64_t)
164 DBUS_CPP_READABLE_PROPERTY_DEF(MinimumRate,
Player,
double)
165 DBUS_CPP_READABLE_PROPERTY_DEF(MaximumRate,
Player,
double)
166 DBUS_CPP_READABLE_PROPERTY_DEF(IsVideoSource,
Player,
bool)
167 DBUS_CPP_READABLE_PROPERTY_DEF(IsAudioSource,
Player,
bool)
168 DBUS_CPP_READABLE_PROPERTY_DEF(CanGoNext,
Player,
bool)
169 DBUS_CPP_READABLE_PROPERTY_DEF(CanGoPrevious,
Player,
bool)
170 DBUS_CPP_READABLE_PROPERTY_DEF(CanPlay,
Player,
bool)
171 DBUS_CPP_READABLE_PROPERTY_DEF(CanPause,
Player,
bool)
172 DBUS_CPP_READABLE_PROPERTY_DEF(CanSeek,
Player,
bool)
173 DBUS_CPP_READABLE_PROPERTY_DEF(CanControl,
Player,
bool)
181 static const std::vector<std::string> instance;
return instance;
204 Properties::TypedPlaybackStatus::ValueType
typed_playback_status{core::ubuntu::media::Player::PlaybackStatus::null};
206 Properties::TypedLoopStatus::ValueType
typed_loop_status{core::ubuntu::media::Player::LoopStatus::none};
208 Properties::Shuffle::ValueType
shuffle{
false};
210 Properties::Volume::ValueType
volume{0.f};
215 Properties::Orientation::ValueType
orientation{core::ubuntu::media::Player::Orientation::rotate0};
220 : configuration(configuration),
223 configuration.
object->template get_property<Properties::CanPlay>(),
224 configuration.
object->template get_property<Properties::CanPause>(),
225 configuration.
object->template get_property<Properties::CanSeek>(),
226 configuration.
object->template get_property<Properties::CanControl>(),
227 configuration.
object->template get_property<Properties::CanGoNext>(),
228 configuration.
object->template get_property<Properties::CanGoPrevious>(),
229 configuration.
object->template get_property<Properties::IsVideoSource>(),
230 configuration.
object->template get_property<Properties::IsAudioSource>(),
231 configuration.
object->template get_property<Properties::PlaybackStatus>(),
232 configuration.
object->template get_property<Properties::TypedPlaybackStatus>(),
233 configuration.
object->template get_property<Properties::LoopStatus>(),
234 configuration.
object->template get_property<Properties::TypedLoopStatus>(),
235 configuration.
object->template get_property<Properties::AudioStreamRole>(),
236 configuration.
object->template get_property<Properties::Orientation>(),
237 configuration.
object->template get_property<Properties::Lifetime>(),
238 configuration.
object->template get_property<Properties::PlaybackRate>(),
239 configuration.
object->template get_property<Properties::Shuffle>(),
240 configuration.
object->template get_property<Properties::TypedMetaData>(),
241 configuration.
object->template get_property<Properties::Volume>(),
242 configuration.
object->template get_property<Properties::Position>(),
243 configuration.
object->template get_property<Properties::Duration>(),
244 configuration.
object->template get_property<Properties::MinimumRate>(),
245 configuration.
object->template get_property<Properties::MaximumRate>()
249 configuration.
object->template get_signal<Signals::Seeked>(),
250 configuration.
object->template get_signal<Signals::AboutToFinish>(),
251 configuration.
object->template get_signal<Signals::EndOfStream>(),
252 configuration.
object->template get_signal<Signals::PlaybackStatusChanged>(),
253 configuration.
object->template get_signal<Signals::VideoDimensionChanged>(),
254 configuration.
object->template get_signal<Signals::Error>(),
255 configuration.
object->template get_signal<core::dbus::interfaces::Properties::Signals::PropertiesChanged>()
270 properties.audio_stream_role->set(core::ubuntu::media::Player::AudioStreamRole::multimedia);
271 properties.orientation->set(core::ubuntu::media::Player::Orientation::rotate0);
272 properties.lifetime->set(core::ubuntu::media::Player::Lifetime::normal);
283 on_property_value_changed<Properties::Orientation>(o);
288 on_property_value_changed<Properties::Position>(
position);
293 on_property_value_changed<Properties::Duration>(
duration);
296 properties.playback_status->changed().connect([
this](
const std::string& status)
298 on_property_value_changed<Properties::PlaybackStatus>(status);
301 properties.loop_status->changed().connect([
this](
const std::string& status)
303 on_property_value_changed<Properties::LoopStatus>(status);
307 template<
typename Property>
310 Dictionary dict; dict[Property::name()] = dbus::types::Variant::encode(value);
312 signals.properties_changed->emit(std::make_tuple(
313 dbus::traits::Service<Player>::interface_name(),
321 dict[Properties::CanPlay::name()] = dbus::types::Variant::encode(
properties.can_play->get());
322 dict[Properties::CanPause::name()] = dbus::types::Variant::encode(
properties.can_pause->get());
323 dict[Properties::CanSeek::name()] = dbus::types::Variant::encode(
properties.can_seek->get());
324 dict[Properties::CanControl::name()] = dbus::types::Variant::encode(
properties.can_control->get());
325 dict[Properties::CanGoNext::name()] = dbus::types::Variant::encode(
properties.can_go_next->get());
326 dict[Properties::CanGoPrevious::name()] = dbus::types::Variant::encode(
properties.can_go_previous->get());
327 dict[Properties::PlaybackStatus::name()] = dbus::types::Variant::encode(
properties.playback_status->get());
328 dict[Properties::TypedPlaybackStatus::name()] = dbus::types::Variant::encode(
properties.typed_playback_status->get());
329 dict[Properties::LoopStatus::name()] = dbus::types::Variant::encode(
properties.loop_status->get());
330 dict[Properties::TypedLoopStatus::name()] = dbus::types::Variant::encode(
properties.typed_loop_status->get());
331 dict[Properties::AudioStreamRole::name()] = dbus::types::Variant::encode(
properties.audio_stream_role->get());
332 dict[Properties::Orientation::name()] = dbus::types::Variant::encode(
properties.orientation->get());
333 dict[Properties::Lifetime::name()] = dbus::types::Variant::encode(
properties.lifetime->get());
334 dict[Properties::PlaybackRate::name()] = dbus::types::Variant::encode(
properties.playback_rate->get());
335 dict[Properties::Shuffle::name()] = dbus::types::Variant::encode(
properties.is_shuffle->get());
336 dict[Properties::Duration::name()] = dbus::types::Variant::encode(
properties.duration->get());
337 dict[Properties::Position::name()] = dbus::types::Variant::encode(
properties.position->get());
338 dict[Properties::MinimumRate::name()] = dbus::types::Variant::encode(
properties.minimum_playback_rate->get());
339 dict[Properties::MaximumRate::name()] = dbus::types::Variant::encode(
properties.maximum_playback_rate->get());
349 std::shared_ptr<core::dbus::Property<Properties::CanPlay>>
can_play;
350 std::shared_ptr<core::dbus::Property<Properties::CanPause>>
can_pause;
351 std::shared_ptr<core::dbus::Property<Properties::CanSeek>>
can_seek;
352 std::shared_ptr<core::dbus::Property<Properties::CanControl>>
can_control;
353 std::shared_ptr<core::dbus::Property<Properties::CanGoNext>>
can_go_next;
360 std::shared_ptr<core::dbus::Property<Properties::LoopStatus>>
loop_status;
363 std::shared_ptr<core::dbus::Property<Properties::Orientation>>
orientation;
364 std::shared_ptr<core::dbus::Property<Properties::Lifetime>>
lifetime;
365 std::shared_ptr<core::dbus::Property<Properties::PlaybackRate>>
playback_rate;
366 std::shared_ptr<core::dbus::Property<Properties::Shuffle>>
is_shuffle;
368 std::shared_ptr<core::dbus::Property<Properties::Volume>>
volume;
369 std::shared_ptr<core::dbus::Property<Properties::Position>>
position;
370 std::shared_ptr<core::dbus::Property<Properties::Duration>>
duration;
377 typename core::dbus::Signal<Signals::Seeked, Signals::Seeked::ArgumentType>::Ptr
seeked_to;
378 typename core::dbus::Signal<Signals::AboutToFinish, Signals::AboutToFinish::ArgumentType>::Ptr
about_to_finish;
379 typename core::dbus::Signal<Signals::EndOfStream, Signals::EndOfStream::ArgumentType>::Ptr
end_of_stream;
380 typename core::dbus::Signal<Signals::PlaybackStatusChanged, Signals::PlaybackStatusChanged::ArgumentType>::Ptr
playback_status_changed;
381 typename core::dbus::Signal<Signals::VideoDimensionChanged, Signals::VideoDimensionChanged::ArgumentType>::Ptr
video_dimension_changed;
382 typename core::dbus::Signal<Signals::Error, Signals::Error::ArgumentType>::Ptr
error;
386 core::dbus::interfaces::Properties::Signals::PropertiesChanged,
387 core::dbus::interfaces::Properties::Signals::PropertiesChanged::ArgumentType
394 #endif // MPRIS_PLAYER_H_
struct mpris::Player::Skeleton::@16 signals
std::shared_ptr< core::dbus::Property< Properties::Duration > > duration
void on_property_value_changed(const typename Property::ValueType &value)
std::shared_ptr< core::dbus::Property< Properties::AudioStreamRole > > audio_stream_role
Properties::CanGoPrevious::ValueType can_go_previous
std::shared_ptr< core::dbus::Property< Properties::IsAudioSource > > is_audio_source
Properties::CanControl::ValueType can_control
std::shared_ptr< core::dbus::Property< Properties::LoopStatus > > loop_status
Properties::MaximumRate::ValueType maximum_rate
Properties::Volume::ValueType volume
static const std::string & name()
static constexpr const char * none
std::shared_ptr< core::dbus::Property< Properties::MinimumRate > > minimum_playback_rate
Properties::Duration::ValueType duration
core::dbus::Object::Ptr object
static constexpr const char * playlist
static constexpr const char * paused
std::shared_ptr< core::dbus::Property< Properties::MaximumRate > > maximum_playback_rate
Properties::CanGoNext::ValueType can_go_next
static constexpr const char * stopped
struct mpris::Player::Skeleton::@15 properties
static const char * from(core::ubuntu::media::Player::PlaybackStatus status)
core::dbus::Signal< Signals::VideoDimensionChanged, Signals::VideoDimensionChanged::ArgumentType >::Ptr video_dimension_changed
Properties::CanPause::ValueType can_pause
static const std::vector< std::string > & the_empty_list_of_invalidated_properties()
std::shared_ptr< core::dbus::Property< Properties::Shuffle > > is_shuffle
Properties::TypedPlaybackStatus::ValueType typed_playback_status
Properties::PlaybackStatus::ValueType playback_status
Properties::Orientation::ValueType orientation
struct mpris::Player::Skeleton::Configuration::Defaults defaults
Properties::Position::ValueType position
std::map< std::string, core::dbus::types::Variant > Dictionary
static const char * from(core::ubuntu::media::Player::LoopStatus status)
static constexpr const char * name
Configuration configuration
core::dbus::Signal< Signals::AboutToFinish, Signals::AboutToFinish::ArgumentType >::Ptr about_to_finish
std::shared_ptr< core::dbus::Property< Properties::IsVideoSource > > is_video_source
std::shared_ptr< core::dbus::Property< Properties::TypedLoopStatus > > typed_loop_status
std::shared_ptr< core::dbus::Property< Properties::CanGoPrevious > > can_go_previous
std::shared_ptr< core::dbus::Property< Properties::CanPause > > can_pause
Properties::PlaybackRate::ValueType playback_rate
Properties::TypedLoopStatus::ValueType typed_loop_status
std::shared_ptr< core::dbus::Property< Properties::Lifetime > > lifetime
Properties::CanSeek::ValueType can_seek
Dictionary get_all_properties()
std::shared_ptr< core::dbus::Property< Properties::Volume > > volume
std::shared_ptr< core::dbus::Property< Properties::CanSeek > > can_seek
static constexpr const char * track
core::dbus::Signal< Signals::Seeked, Signals::Seeked::ArgumentType >::Ptr seeked_to
Properties::TypedMetaData::ValueType typed_meta_data
Properties::IsAudioSource::ValueType is_audio_source
std::shared_ptr< core::dbus::Property< Properties::Orientation > > orientation
Skeleton(const Configuration &configuration)
std::shared_ptr< core::dbus::Property< Properties::TypedPlaybackStatus > > typed_playback_status
Properties::MinimumRate::ValueType minimum_rate
std::shared_ptr< core::dbus::Property< Properties::PlaybackStatus > > playback_status
Properties::CanPlay::ValueType can_play
std::shared_ptr< core::dbus::Property< Properties::TypedMetaData > > typed_meta_data_for_current_track
core::dbus::Signal< Signals::EndOfStream, Signals::EndOfStream::ArgumentType >::Ptr end_of_stream
std::shared_ptr< core::dbus::Property< Properties::CanPlay > > can_play
Properties::IsVideoSource::ValueType is_video_source
std::shared_ptr< core::dbus::Property< Properties::CanControl > > can_control
static constexpr const char * playing
std::shared_ptr< core::dbus::Property< Properties::Position > > position
std::shared_ptr< core::dbus::Property< Properties::CanGoNext > > can_go_next
Properties::LoopStatus::ValueType loop_status
std::shared_ptr< core::dbus::Property< Properties::PlaybackRate > > playback_rate
dbus::Signal< core::dbus::interfaces::Properties::Signals::PropertiesChanged, core::dbus::interfaces::Properties::Signals::PropertiesChanged::ArgumentType >::Ptr properties_changed
core::dbus::Signal< Signals::PlaybackStatusChanged, Signals::PlaybackStatusChanged::ArgumentType >::Ptr playback_status_changed
core::dbus::Signal< Signals::Error, Signals::Error::ArgumentType >::Ptr error
Properties::Shuffle::ValueType shuffle