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>
55 static const std::string&
name()
57 static const std::string s{
"org.mpris.MediaPlayer2.Player"};
69 case core::ubuntu::media::Player::LoopStatus::none:
71 case core::ubuntu::media::Player::LoopStatus::track:
73 case core::ubuntu::media::Player::LoopStatus::playlist:
80 static constexpr const char*
none{
"None"};
81 static constexpr const char*
track{
"Track"};
82 static constexpr const char*
playlist{
"Playlist"};
93 case core::ubuntu::media::Player::PlaybackStatus::null:
94 case core::ubuntu::media::Player::PlaybackStatus::ready:
95 case core::ubuntu::media::Player::PlaybackStatus::stopped:
98 case core::ubuntu::media::Player::PlaybackStatus::playing:
100 case core::ubuntu::media::Player::PlaybackStatus::paused:
107 static constexpr const char*
playing{
"Playing"};
108 static constexpr const char*
paused{
"Paused"};
109 static constexpr const char*
stopped{
"Stopped"};
116 static constexpr const char*
name
118 "mpris.Player.Error.OutOfProcessBufferStreamingNotSupported"
124 static constexpr const char*
name
126 "mpris.Player.Error.InsufficientAppArmorPermissions"
132 static constexpr const char*
name
134 "mpris.Player.Error.UriNotFound"
139 typedef std::map<std::string, core::dbus::types::Variant>
Dictionary;
141 DBUS_CPP_METHOD_DEF(Next,
Player)
142 DBUS_CPP_METHOD_DEF(Previous,
Player)
143 DBUS_CPP_METHOD_DEF(Pause,
Player)
144 DBUS_CPP_METHOD_DEF(PlayPause,
Player)
145 DBUS_CPP_METHOD_DEF(Stop,
Player)
146 DBUS_CPP_METHOD_DEF(Play,
Player)
147 DBUS_CPP_METHOD_DEF(Seek,
Player)
148 DBUS_CPP_METHOD_DEF(SetPosition,
Player)
149 DBUS_CPP_METHOD_DEF(CreateVideoSink,
Player)
150 DBUS_CPP_METHOD_DEF(Key,
Player)
151 DBUS_CPP_METHOD_DEF(OpenUri,
Player)
152 DBUS_CPP_METHOD_DEF(OpenUriExtended,
Player)
156 DBUS_CPP_SIGNAL_DEF(Seeked,
Player, std::int64_t)
157 DBUS_CPP_SIGNAL_DEF(AboutToFinish,
Player,
void)
158 DBUS_CPP_SIGNAL_DEF(EndOfStream,
Player,
void)
162 DBUS_CPP_SIGNAL_DEF(Buffering,
Player,
int)
175 DBUS_CPP_WRITABLE_PROPERTY_DEF(PlaybackRate,
Player,
double)
176 DBUS_CPP_WRITABLE_PROPERTY_DEF(Rate,
Player,
double)
177 DBUS_CPP_WRITABLE_PROPERTY_DEF(Shuffle,
Player,
bool)
179 DBUS_CPP_WRITABLE_PROPERTY_DEF(Volume,
Player,
double)
180 DBUS_CPP_READABLE_PROPERTY_DEF(Position,
Player, std::int64_t)
181 DBUS_CPP_READABLE_PROPERTY_DEF(Duration,
Player, std::int64_t)
182 DBUS_CPP_READABLE_PROPERTY_DEF(MinimumRate,
Player,
double)
183 DBUS_CPP_READABLE_PROPERTY_DEF(MaximumRate,
Player,
double)
184 DBUS_CPP_READABLE_PROPERTY_DEF(IsVideoSource,
Player,
bool)
185 DBUS_CPP_READABLE_PROPERTY_DEF(IsAudioSource,
Player,
bool)
186 DBUS_CPP_READABLE_PROPERTY_DEF(CanGoNext,
Player,
bool)
187 DBUS_CPP_READABLE_PROPERTY_DEF(CanGoPrevious,
Player,
bool)
188 DBUS_CPP_READABLE_PROPERTY_DEF(CanPlay,
Player,
bool)
189 DBUS_CPP_READABLE_PROPERTY_DEF(CanPause,
Player,
bool)
190 DBUS_CPP_READABLE_PROPERTY_DEF(CanSeek,
Player,
bool)
191 DBUS_CPP_READABLE_PROPERTY_DEF(CanControl,
Player,
bool)
199 static const std::vector<std::string> instance;
return instance;
222 Properties::TypedPlaybackStatus::ValueType
typed_playback_status{core::ubuntu::media::Player::PlaybackStatus::null};
223 Properties::TypedBackend::ValueType
typed_backend{core::ubuntu::media::AVBackend::Backend::none};
225 Properties::TypedLoopStatus::ValueType
typed_loop_status{core::ubuntu::media::Player::LoopStatus::none};
227 Properties::Shuffle::ValueType
shuffle{
false};
229 Properties::Volume::ValueType
volume{0.f};
234 Properties::Orientation::ValueType
orientation{core::ubuntu::media::Player::Orientation::rotate0};
276 configuration.
object->template get_signal<core::dbus::interfaces::Properties::Signals::PropertiesChanged>()
292 properties.audio_stream_role->set(core::ubuntu::media::Player::AudioStreamRole::multimedia);
293 properties.orientation->set(core::ubuntu::media::Player::Orientation::rotate0);
294 properties.lifetime->set(core::ubuntu::media::Player::Lifetime::normal);
306 on_property_value_changed<Properties::Orientation>(o);
311 on_property_value_changed<Properties::Position>(
position);
316 on_property_value_changed<Properties::Duration>(
duration);
319 properties.playback_status->changed().connect([
this](
const std::string& status)
321 on_property_value_changed<Properties::PlaybackStatus>(status);
324 properties.loop_status->changed().connect([
this](
const std::string& status)
326 on_property_value_changed<Properties::LoopStatus>(status);
331 on_property_value_changed<Properties::Shuffle>(
shuffle);
336 on_property_value_changed<Properties::CanPlay>(
can_play);
341 on_property_value_changed<Properties::CanPause>(
can_pause);
346 on_property_value_changed<Properties::CanGoNext>(
can_go_next);
355 template<
typename Property>
358 Dictionary dict; dict[Property::name()] = dbus::types::Variant::encode(value);
360 signals.properties_changed->emit(std::make_tuple(
361 dbus::traits::Service<Player>::interface_name(),
369 dict[Properties::CanPlay::name()] = dbus::types::Variant::encode(
properties.can_play->get());
370 dict[Properties::CanPause::name()] = dbus::types::Variant::encode(
properties.can_pause->get());
371 dict[Properties::CanSeek::name()] = dbus::types::Variant::encode(
properties.can_seek->get());
372 dict[Properties::CanControl::name()] = dbus::types::Variant::encode(
properties.can_control->get());
373 dict[Properties::CanGoNext::name()] = dbus::types::Variant::encode(
properties.can_go_next->get());
374 dict[Properties::CanGoPrevious::name()] = dbus::types::Variant::encode(
properties.can_go_previous->get());
375 dict[Properties::PlaybackStatus::name()] = dbus::types::Variant::encode(
properties.playback_status->get());
376 dict[Properties::TypedPlaybackStatus::name()] = dbus::types::Variant::encode(
properties.typed_playback_status->get());
377 dict[Properties::TypedBackend::name()] = dbus::types::Variant::encode(
properties.typed_backend->get());
378 dict[Properties::LoopStatus::name()] = dbus::types::Variant::encode(
properties.loop_status->get());
379 dict[Properties::TypedLoopStatus::name()] = dbus::types::Variant::encode(
properties.typed_loop_status->get());
380 dict[Properties::AudioStreamRole::name()] = dbus::types::Variant::encode(
properties.audio_stream_role->get());
381 dict[Properties::Orientation::name()] = dbus::types::Variant::encode(
properties.orientation->get());
382 dict[Properties::Lifetime::name()] = dbus::types::Variant::encode(
properties.lifetime->get());
383 dict[Properties::PlaybackRate::name()] = dbus::types::Variant::encode(
properties.playback_rate->get());
384 dict[Properties::Shuffle::name()] = dbus::types::Variant::encode(
properties.shuffle->get());
385 dict[Properties::Metadata::name()] = dbus::types::Variant::encode(
properties.meta_data_for_current_track->get());
386 dict[Properties::Duration::name()] = dbus::types::Variant::encode(
properties.duration->get());
387 dict[Properties::Position::name()] = dbus::types::Variant::encode(
properties.position->get());
388 dict[Properties::MinimumRate::name()] = dbus::types::Variant::encode(
properties.minimum_playback_rate->get());
389 dict[Properties::MaximumRate::name()] = dbus::types::Variant::encode(
properties.maximum_playback_rate->get());
399 std::shared_ptr<core::dbus::Property<Properties::CanPlay>>
can_play;
400 std::shared_ptr<core::dbus::Property<Properties::CanPause>>
can_pause;
401 std::shared_ptr<core::dbus::Property<Properties::CanSeek>>
can_seek;
402 std::shared_ptr<core::dbus::Property<Properties::CanControl>>
can_control;
403 std::shared_ptr<core::dbus::Property<Properties::CanGoNext>>
can_go_next;
410 std::shared_ptr<core::dbus::Property<Properties::TypedBackend>>
typed_backend;
411 std::shared_ptr<core::dbus::Property<Properties::LoopStatus>>
loop_status;
414 std::shared_ptr<core::dbus::Property<Properties::Orientation>>
orientation;
415 std::shared_ptr<core::dbus::Property<Properties::Lifetime>>
lifetime;
416 std::shared_ptr<core::dbus::Property<Properties::PlaybackRate>>
playback_rate;
417 std::shared_ptr<core::dbus::Property<Properties::Shuffle>>
shuffle;
419 std::shared_ptr<core::dbus::Property<Properties::Volume>>
volume;
420 std::shared_ptr<core::dbus::Property<Properties::Position>>
position;
421 std::shared_ptr<core::dbus::Property<Properties::Duration>>
duration;
428 typename core::dbus::Signal<Signals::Seeked, Signals::Seeked::ArgumentType>::Ptr
seeked_to;
429 typename core::dbus::Signal<Signals::AboutToFinish, Signals::AboutToFinish::ArgumentType>::Ptr
about_to_finish;
430 typename core::dbus::Signal<Signals::EndOfStream, Signals::EndOfStream::ArgumentType>::Ptr
end_of_stream;
431 typename core::dbus::Signal<Signals::PlaybackStatusChanged, Signals::PlaybackStatusChanged::ArgumentType>::Ptr
playback_status_changed;
432 typename core::dbus::Signal<Signals::VideoDimensionChanged, Signals::VideoDimensionChanged::ArgumentType>::Ptr
video_dimension_changed;
433 typename core::dbus::Signal<Signals::Error, Signals::Error::ArgumentType>::Ptr
error;
434 typename core::dbus::Signal<Signals::Buffering, Signals::Buffering::ArgumentType>::Ptr
buffering_changed;
438 core::dbus::interfaces::Properties::Signals::PropertiesChanged,
439 core::dbus::interfaces::Properties::Signals::PropertiesChanged::ArgumentType
static constexpr const char * name
static constexpr const char * name
static constexpr const char * name
static const char * from(core::ubuntu::media::Player::LoopStatus status)
static constexpr const char * none
static constexpr const char * track
static constexpr const char * playlist
static constexpr const char * paused
static const char * from(core::ubuntu::media::Player::PlaybackStatus status)
static constexpr const char * playing
static constexpr const char * stopped
Properties::IsVideoSource::ValueType is_video_source
Properties::TypedBackend::ValueType typed_backend
Properties::Shuffle::ValueType shuffle
Properties::CanPlay::ValueType can_play
Properties::Volume::ValueType volume
Properties::CanGoPrevious::ValueType can_go_previous
Properties::CanPause::ValueType can_pause
Properties::Metadata::ValueType meta_data
Properties::CanSeek::ValueType can_seek
Properties::Orientation::ValueType orientation
Properties::MinimumRate::ValueType minimum_rate
Properties::TypedLoopStatus::ValueType typed_loop_status
Properties::TypedPlaybackStatus::ValueType typed_playback_status
Properties::CanGoNext::ValueType can_go_next
Properties::MaximumRate::ValueType maximum_rate
Properties::Position::ValueType position
Properties::IsAudioSource::ValueType is_audio_source
Properties::Duration::ValueType duration
Properties::CanControl::ValueType can_control
Properties::LoopStatus::ValueType loop_status
Properties::PlaybackRate::ValueType playback_rate
Properties::PlaybackStatus::ValueType playback_status
struct mpris::Player::Skeleton::Configuration::Defaults defaults
core::dbus::Object::Ptr object
void on_property_value_changed(const typename Property::ValueType &value)
core::dbus::Signal< Signals::VideoDimensionChanged, Signals::VideoDimensionChanged::ArgumentType >::Ptr video_dimension_changed
std::shared_ptr< core::dbus::Property< Properties::PlaybackRate > > playback_rate
std::shared_ptr< core::dbus::Property< Properties::Lifetime > > lifetime
std::shared_ptr< core::dbus::Property< Properties::Metadata > > meta_data_for_current_track
std::shared_ptr< core::dbus::Property< Properties::TypedPlaybackStatus > > typed_playback_status
std::shared_ptr< core::dbus::Property< Properties::CanSeek > > can_seek
std::shared_ptr< core::dbus::Property< Properties::PlaybackStatus > > playback_status
struct mpris::Player::Skeleton::@15 properties
std::shared_ptr< core::dbus::Property< Properties::LoopStatus > > loop_status
std::shared_ptr< core::dbus::Property< Properties::CanGoNext > > can_go_next
std::shared_ptr< core::dbus::Property< Properties::Orientation > > orientation
std::shared_ptr< core::dbus::Property< Properties::Duration > > duration
core::dbus::Signal< Signals::Error, Signals::Error::ArgumentType >::Ptr error
core::dbus::Signal< Signals::Buffering, Signals::Buffering::ArgumentType >::Ptr buffering_changed
std::shared_ptr< core::dbus::Property< Properties::TypedLoopStatus > > typed_loop_status
std::shared_ptr< core::dbus::Property< Properties::MinimumRate > > minimum_playback_rate
std::shared_ptr< core::dbus::Property< Properties::IsVideoSource > > is_video_source
std::shared_ptr< core::dbus::Property< Properties::AudioStreamRole > > audio_stream_role
struct mpris::Player::Skeleton::@16 signals
std::shared_ptr< core::dbus::Property< Properties::MaximumRate > > maximum_playback_rate
std::shared_ptr< core::dbus::Property< Properties::CanControl > > can_control
core::dbus::Signal< Signals::PlaybackStatusChanged, Signals::PlaybackStatusChanged::ArgumentType >::Ptr playback_status_changed
static const std::vector< std::string > & the_empty_list_of_invalidated_properties()
core::dbus::Signal< Signals::Seeked, Signals::Seeked::ArgumentType >::Ptr seeked_to
std::shared_ptr< core::dbus::Property< Properties::IsAudioSource > > is_audio_source
Configuration configuration
std::shared_ptr< core::dbus::Property< Properties::Position > > position
core::dbus::Signal< Signals::EndOfStream, Signals::EndOfStream::ArgumentType >::Ptr end_of_stream
std::shared_ptr< core::dbus::Property< Properties::Volume > > volume
std::shared_ptr< core::dbus::Property< Properties::TypedBackend > > typed_backend
std::shared_ptr< core::dbus::Property< Properties::Shuffle > > shuffle
std::shared_ptr< core::dbus::Property< Properties::CanGoPrevious > > can_go_previous
std::shared_ptr< core::dbus::Property< Properties::CanPlay > > can_play
std::shared_ptr< core::dbus::Property< Properties::CanPause > > can_pause
dbus::Signal< core::dbus::interfaces::Properties::Signals::PropertiesChanged, core::dbus::interfaces::Properties::Signals::PropertiesChanged::ArgumentType >::Ptr properties_changed
Skeleton(const Configuration &configuration)
core::dbus::Signal< Signals::AboutToFinish, Signals::AboutToFinish::ArgumentType >::Ptr about_to_finish
Dictionary get_all_properties()
std::map< std::string, core::dbus::types::Variant > Dictionary
static const std::string & name()