Merge lp:~thomas-voss/media-hub/externalize-all-dependencies into lp:media-hub

Proposed by Thomas Voß
Status: Needs review
Proposed branch: lp:~thomas-voss/media-hub/externalize-all-dependencies
Merge into: lp:media-hub
Prerequisite: lp:~thomas-voss/media-hub/decouple-player-skeleton-and-implementation
Diff against target: 710 lines (+132/-116)
7 files modified
src/core/media/player_implementation.cpp (+27/-31)
src/core/media/player_implementation.h (+3/-0)
src/core/media/server/server.cpp (+32/-10)
src/core/media/service_implementation.cpp (+21/-35)
src/core/media/service_implementation.h (+22/-0)
src/core/media/service_skeleton.cpp (+22/-35)
src/core/media/service_skeleton.h (+5/-5)
To merge this branch: bzr merge lp:~thomas-voss/media-hub/externalize-all-dependencies
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Ubuntu Phablet Team Pending
Review via email: mp+252103@code.launchpad.net

Commit message

Externalize all the functional dependencies of Player{Skeleton, Implementation} and Service{Skeleton, Implementation} to allow for easy mocking in test cases.
Adjust the server setup to instantiate platform-default implementations.

Description of the change

Externalize all the functional dependencies of Player{Skeleton, Implementation} and Service{Skeleton, Implementation} to allow for easy mocking in test cases.
Adjust the server setup to instantiate platform-default implementations.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
120. By Thomas Voß

[ Jim Hodapp ]
* Fix the bug which caused music playback to start playing again after
  a phonecall hung up after being auto-paused by disconnecting a
  headphone jack.
[ Thomas Voss ]
[ CI Train Bot ]
* New rebuild forced.
[ Jim Hodapp ]
* Disconnect playback_status_changed_signal in ~Private() to avoid a
  deadlock.
* Prevent a 0 position from being reported to the app which happens
  while seeking. Covers bad behavior that happens from GStreamer. Also
  expose the about_to_finish signal to the client. Enable playback
  again after manually seeking all the way to EOS. Also only send
  VideoDimensionsChanged signal only when necessary.
[ Ricardo Mendoza ]
* Add an interface apparmor::ubuntu::RequestAuthenticator that is used
  to authenticate incoming open uri requests. Add an interface
  apparmor::ubuntu::RequestContextResolver that is used to resolve a
  dbus name to an apparmor::ubuntu::Context. Provide an implementation
  apparmor::ubuntu::ExistingAuthenticator that takes the impl. from
  player_skeleton.cpp and uses it to implement the interface. Provide
  an implementation apparmor::ubuntu::RequestContextResolver that
  reaches out to the dbus daemon to resolve a given bus name to an
  apparmor profile. Remove obsolete query for the apparmor profile in
  ServiceSkeleton. Adjust the implementation in media::PlayerSkeleton
  to rely on Request{Authenticator, ContextResolver}. removed:
  src/core/media/apparmor.h added: src/core/media/apparmor/
  src/core/media/apparmor/context.cpp
  src/core/media/apparmor/context.h src/core/media/apparmor/dbus.h
  src/core/media/apparmor/ubuntu.cpp src/core/media/apparmor/ubuntu.h
* Introduce an interface media::audio::OutputObserver that allows the
  core classes to observer the state of external audio outputs
  (headphones/headsets). Provide an implementation of
  media::audio::OutputObserver that relies on Pulseaudio to monitor
  the availability of ports on the default sink. Adjust
  media::ServiceImplementation to use media::audio::OutputObserver,
  defaulting to media::audio::PulseAudioOutputObserver.
* Migrate all Player DBus methods to use transact_method() instead of
  invoke_method_synchronously(), to prevent bus executor deadlocks.
[ Ricardo Salveti de Araujo ]
* Add an interface apparmor::ubuntu::RequestAuthenticator that is used
  to authenticate incoming open uri requests. Add an interface
  apparmor::ubuntu::RequestContextResolver that is used to resolve a
  dbus name to an apparmor::ubuntu::Context. Provide an implementation
  apparmor::ubuntu::ExistingAuthenticator that takes the impl. from
  player_skeleton.cpp and uses it to implement the interface. Provide
  an implementation apparmor::ubuntu::RequestContextResolver that
  reaches out to the dbus daemon to resolve a given bus name to an
  apparmor profile. Remove obsolete query for the apparmor profile in
  ServiceSkeleton. Adjust the implementation in media::PlayerSkeleton
  to rely on Request{Authenticator, ContextResolver}. removed:
  src/core/media/apparmor.h added: src/core/media/apparmor/
  src/core/media/apparmor/context.cpp
  src/core/media/apparmor/context.h src/core/media/apparmor/dbus.h
  src/core/media/apparmor/ubuntu.cpp src/core/media/apparmor/ubuntu.h
* Move src/core/media/call-monitor to src/core/media/telephony.
  Introduce a proper interface media::telephony::CallMonitor. Slightly
  adjust existing implementation based on Qt. Adjust
  media::ServiceImplementation to account for changes in
  media::telephony::CallMonitor.
[ thomas-voss ]
* Add an interface apparmor::ubuntu::RequestAuthenticator that is used
  to authenticate incoming open uri requests. Add an interface
  apparmor::ubuntu::RequestContextResolver that is used to resolve a
  dbus name to an apparmor::ubuntu::Context. Provide an implementation
  apparmor::ubuntu::ExistingAuthenticator that takes the impl. from
  player_skeleton.cpp and uses it to implement the interface. Provide
  an implementation apparmor::ubuntu::RequestContextResolver that
  reaches out to the dbus daemon to resolve a given bus name to an
  apparmor profile. Remove obsolete query for the apparmor profile in
  ServiceSkeleton. Adjust the implementation in media::PlayerSkeleton
  to rely on Request{Authenticator, ContextResolver}. removed:
  src/core/media/apparmor.h added: src/core/media/apparmor/
  src/core/media/apparmor/context.cpp
  src/core/media/apparmor/context.h src/core/media/apparmor/dbus.h
  src/core/media/apparmor/ubuntu.cpp src/core/media/apparmor/ubuntu.h
* Add an interface media::ClientDeathObserver that abstracts away
  receiving key-based death notifications for clients associated to
  media::Player instances server-side Provide an implementation
  media::HybrisClientDeathObserver that relies on hybris and
  ultimately on Android's onBinderDied to receive death notifications.
  Adjust media::PlayerStub and media::PlayerImplementation to account
  for the new interface. Adjust the CMake setup for tests to link
  media-hub-service instead of recompiling large parts of the
  implementation classes.
* Decouple PlayerSkeleton and PlayerImplementation by making
  PlayerImplementation being able to inherit from arbitrary base
  classes, as long as they provide the set of properties and signals
  defined by media::Player.
* Decouple the ServiceSkeleton from the ServiceImplementation by
  introducing a common interface media::KeyedPlayerStore for storing
  running Player sessions indexed by the Player::Key. Provide a
  default implementation HashedKeyedPlayerStore relying on a hash map
  for keeping track of player instances. Adjust implementation to
  account for ServiceImplementation no longer inheriting from
  ServiceSkeleton.
* Introduce a common class media::helper::ExternalHelpers that
  provides a convenient way to:
* Introduce an interface media::RecorderObserver that allows the core
  classes to monitor the overall state of the system. Provide an
  implementation of media::RecorderObserver relying on Hybris to
  interface with the Android side. Adjust the ServiceImplementation to
  connect to the platform-default media::RecorderObserver.
* Introduce an interface media::audio::OutputObserver that allows the
  core classes to observer the state of external audio outputs
  (headphones/headsets). Provide an implementation of
  media::audio::OutputObserver that relies on Pulseaudio to monitor
  the availability of ports on the default sink. Adjust
  media::ServiceImplementation to use media::audio::OutputObserver,
  defaulting to media::audio::PulseAudioOutputObserver.
* Introduce an interface media::power::BatteryObserver to monitor the
  current battery level of the system. The core reacts to low/very low
  battery levels by pausing all multimedia playback sessions and
  resumes them whenever the user has been notified of the critical
  battery level. Provide an implementation of
  media::power::BatteryObserver using
  com.canonical.indicator.power.Battery. Adjust
  media::ServiceImplementation to use media::power::BatteryObserver.
* Move gstreamer::Playbin implementation to its own cpp file, thus
  internalizing the Hybris setup portions. Make sure that media-hub-
  service knows about
  media::Player::Error::OutOfProcessBufferStreamingNotSupported by
  linking with media-hub-client.
* Move src/core/media/call-monitor to src/core/media/telephony.
  Introduce a proper interface media::telephony::CallMonitor. Slightly
  adjust existing implementation based on Qt. Adjust
  media::ServiceImplementation to account for changes in
  media::telephony::CallMonitor.
* Replace home-grown mask type for the video size with a std::tuple,
  i.e., media::video::Dimensions. Introduce a simple TaggedInteger
  class to distinguish between Width, Height and other dimensions.
  Adjust interfaces of media::Player to rely on the new type. Adjust
  implementation classes to account for interface changes. Adjust
  Codec implementation for sending the tagged integer via the bus.
  Adjust gstreamer::Engine and gstreamer::Playbin to hand out the
  correct types.
* debian/control:
  - Removing pre-depends that are not required
  - Bumping standards-version to 3.9.6
[ Ricardo Salveti de Araujo ]
* Migrating tests to use ogg instead of mp3/avi removed:
  tests/h264.avi tests/test.mp3 added: tests/test-audio-1.ogg
  tests/test-video.ogg tests/test.mp3 renamed: tests/test.ogg =>
  tests/test-audio.ogg

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
121. By Thomas Voß

Fix FTBFS.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Unmerged revisions

121. By Thomas Voß

Fix FTBFS.

120. By Thomas Voß

[ Jim Hodapp ]
* Fix the bug which caused music playback to start playing again after
  a phonecall hung up after being auto-paused by disconnecting a
  headphone jack.
[ Thomas Voss ]
[ CI Train Bot ]
* New rebuild forced.
[ Jim Hodapp ]
* Disconnect playback_status_changed_signal in ~Private() to avoid a
  deadlock.
* Prevent a 0 position from being reported to the app which happens
  while seeking. Covers bad behavior that happens from GStreamer. Also
  expose the about_to_finish signal to the client. Enable playback
  again after manually seeking all the way to EOS. Also only send
  VideoDimensionsChanged signal only when necessary.
[ Ricardo Mendoza ]
* Add an interface apparmor::ubuntu::RequestAuthenticator that is used
  to authenticate incoming open uri requests. Add an interface
  apparmor::ubuntu::RequestContextResolver that is used to resolve a
  dbus name to an apparmor::ubuntu::Context. Provide an implementation
  apparmor::ubuntu::ExistingAuthenticator that takes the impl. from
  player_skeleton.cpp and uses it to implement the interface. Provide
  an implementation apparmor::ubuntu::RequestContextResolver that
  reaches out to the dbus daemon to resolve a given bus name to an
  apparmor profile. Remove obsolete query for the apparmor profile in
  ServiceSkeleton. Adjust the implementation in media::PlayerSkeleton
  to rely on Request{Authenticator, ContextResolver}. removed:
  src/core/media/apparmor.h added: src/core/media/apparmor/
  src/core/media/apparmor/context.cpp
  src/core/media/apparmor/context.h src/core/media/apparmor/dbus.h
  src/core/media/apparmor/ubuntu.cpp src/core/media/apparmor/ubuntu.h
* Introduce an interface media::audio::OutputObserver that allows the
  core classes to observer the state of external audio outputs
  (headphones/headsets). Provide an implementation of
  media::audio::OutputObserver that relies on Pulseaudio to monitor
  the availability of ports on the default sink. Adjust
  media::ServiceImplementation to use media::audio::OutputObserver,
  defaulting to media::audio::PulseAudioOutputObserver.
* Migrate all Player DBus methods to use transact_method() instead of
  invoke_method_synchronously(), to prevent bus executor deadlocks.
[ Ricardo Salveti de Araujo ]
* Add an interface apparmor::ubuntu::RequestAuthenticator that is used
  to authenticate incoming open uri requests. Add an interface
  apparmor::ubuntu::RequestContextResolver that is used to resolve a
  dbus name to an apparmor::ubuntu::Context. Provide an implementation
  apparmor::ubuntu::ExistingAuthenticator that takes the impl. from
  player_skeleton.cpp and uses it to implement the interface. Provide
  an implementation apparmor::ubuntu::RequestContextResolver that
  reaches out to the dbus daemon to resolve a given bus name to an
  apparmor profile. Remove obsolete query for the apparmor profile in
  ServiceSkeleton. Adjust the implementation in media::PlayerSkeleton
  to rely on Request{Authenticator, ContextResolver}. removed:
  src/core/media/apparmor.h added: src/core/media/apparmor/
  src/core/media/apparmor/context.cpp
  src/core/media/apparmor/context.h src/core/media/apparmor/dbus.h
  src/core/media/apparmor/ubuntu.cpp src/core/media/apparmor/ubuntu.h
* Move src/core/media/call-monitor to src/core/media/telephony.
  Introduce a proper interface media::telephony::CallMonitor. Slightly
  adjust existing implementation based on Qt. Adjust
  media::ServiceImplementation to account for changes in
  media::telephony::CallMonitor.
[ thomas-voss ]
* Add an interface apparmor::ubuntu::RequestAuthenticator that is used
  to authenticate incoming open uri requests. Add an interface
  apparmor::ubuntu::RequestContextResolver that is used to resolve a
  dbus name to an apparmor::ubuntu::Context. Provide an implementation
  apparmor::ubuntu::ExistingAuthenticator that takes the impl. from
  player_skeleton.cpp and uses it to implement the interface. Provide
  an implementation apparmor::ubuntu::RequestContextResolver that
  reaches out to the dbus daemon to resolve a given bus name to an
  apparmor profile. Remove obsolete query for the apparmor profile in
  ServiceSkeleton. Adjust the implementation in media::PlayerSkeleton
  to rely on Request{Authenticator, ContextResolver}. removed:
  src/core/media/apparmor.h added: src/core/media/apparmor/
  src/core/media/apparmor/context.cpp
  src/core/media/apparmor/context.h src/core/media/apparmor/dbus.h
  src/core/media/apparmor/ubuntu.cpp src/core/media/apparmor/ubuntu.h
* Add an interface media::ClientDeathObserver that abstracts away
  receiving key-based death notifications for clients associated to
  media::Player instances server-side Provide an implementation
  media::HybrisClientDeathObserver that relies on hybris and
  ultimately on Android's onBinderDied to receive death notifications.
  Adjust media::PlayerStub and media::PlayerImplementation to account
  for the new interface. Adjust the CMake setup for tests to link
  media-hub-service instead of recompiling large parts of the
  implementation classes.
* Decouple PlayerSkeleton and PlayerImplementation by making
  PlayerImplementation being able to inherit from arbitrary base
  classes, as long as they provide the set of properties and signals
  defined by media::Player.
* Decouple the ServiceSkeleton from the ServiceImplementation by
  introducing a common interface media::KeyedPlayerStore for storing
  running Player sessions indexed by the Player::Key. Provide a
  default implementation HashedKeyedPlayerStore relying on a hash map
  for keeping track of player instances. Adjust implementation to
  account for ServiceImplementation no longer inheriting from
  ServiceSkeleton.
* Introduce a common class media::helper::ExternalHelpers that
  provides a convenient way to:
* Introduce an interface media::RecorderObserver that allows the core
  classes to monitor the overall state of the system. Provide an
  implementation of media::RecorderObserver relying on Hybris to
  interface with the Android side. Adjust the ServiceImplementation to
  connect to the platform-default media::RecorderObserver.
* Introduce an interface media::audio::OutputObserver that allows the
  core classes to observer the state of external audio outputs
  (headphones/headsets). Provide an implementation of
  media::audio::OutputObserver that relies on Pulseaudio to monitor
  the availability of ports on the default sink. Adjust
  media::ServiceImplementation to use media::audio::OutputObserver,
  defaulting to media::audio::PulseAudioOutputObserver.
* Introduce an interface media::power::BatteryObserver to monitor the
  current battery level of the system. The core reacts to low/very low
  battery levels by pausing all multimedia playback sessions and
  resumes them whenever the user has been notified of the critical
  battery level. Provide an implementation of
  media::power::BatteryObserver using
  com.canonical.indicator.power.Battery. Adjust
  media::ServiceImplementation to use media::power::BatteryObserver.
* Move gstreamer::Playbin implementation to its own cpp file, thus
  internalizing the Hybris setup portions. Make sure that media-hub-
  service knows about
  media::Player::Error::OutOfProcessBufferStreamingNotSupported by
  linking with media-hub-client.
* Move src/core/media/call-monitor to src/core/media/telephony.
  Introduce a proper interface media::telephony::CallMonitor. Slightly
  adjust existing implementation based on Qt. Adjust
  media::ServiceImplementation to account for changes in
  media::telephony::CallMonitor.
* Replace home-grown mask type for the video size with a std::tuple,
  i.e., media::video::Dimensions. Introduce a simple TaggedInteger
  class to distinguish between Width, Height and other dimensions.
  Adjust interfaces of media::Player to rely on the new type. Adjust
  implementation classes to account for interface changes. Adjust
  Codec implementation for sending the tagged integer via the bus.
  Adjust gstreamer::Engine and gstreamer::Playbin to hand out the
  correct types.
* debian/control:
  - Removing pre-depends that are not required
  - Bumping standards-version to 3.9.6
[ Ricardo Salveti de Araujo ]
* Migrating tests to use ogg instead of mp3/avi removed:
  tests/h264.avi tests/test.mp3 added: tests/test-audio-1.ogg
  tests/test-video.ogg tests/test.mp3 renamed: tests/test.ogg =>
  tests/test-audio.ogg

119. By Thomas Voß

Remove obsolete Engine instance.

118. By Thomas Voß

Merge prereq branch.
Externalize all the functional dependencies of Player{Skeleton, Implementation} and Service{Skeleton, Implementation} to allow
for easy mocking in test cases.
Adjust the server setup to instantiate platform-default implementations.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/core/media/player_implementation.cpp'
2--- src/core/media/player_implementation.cpp 2015-03-19 19:08:47 +0000
3+++ src/core/media/player_implementation.cpp 2015-04-17 13:03:34 +0000
4@@ -26,8 +26,6 @@
5 #include "null_track_list.h"
6 #include "track_list_implementation.h"
7
8-#include "gstreamer/engine.h"
9-
10 #include <memory>
11 #include <exception>
12 #include <iostream>
13@@ -57,13 +55,12 @@
14 config(config),
15 display_state_lock(config.power_state_controller->display_state_lock()),
16 system_state_lock(config.power_state_controller->system_state_lock()),
17- engine(std::make_shared<gstreamer::Engine>()),
18 track_list(std::make_shared<NullTrackList>()),
19 system_wakelock_count(0),
20 display_wakelock_count(0),
21 previous_state(Engine::State::stopped),
22- engine_state_change_connection(engine->state().changed().connect(make_state_change_handler())),
23- engine_playback_status_change_connection(engine->playback_status_changed_signal().connect(make_playback_status_change_handler()))
24+ engine_state_change_connection(config.engine->state().changed().connect(make_state_change_handler())),
25+ engine_playback_status_change_connection(config.engine->playback_status_changed_signal().connect(make_playback_status_change_handler()))
26 {
27 std::cout << "Private parent instance: " << parent << std::endl;
28 // Poor man's logging of release/acquire events.
29@@ -131,7 +128,7 @@
30 {
31 // We update the track meta data prior to updating the playback status.
32 // Some MPRIS clients expect this order of events.
33- parent->meta_data_for_current_track().set(std::get<1>(engine->track_meta_data().get()));
34+ parent->meta_data_for_current_track().set(std::get<1>(config.engine->track_meta_data().get()));
35 // And update our playback status.
36 parent->playback_status().set(media::Player::playing);
37 std::cout << "Requesting power state" << std::endl;
38@@ -279,7 +276,7 @@
39
40 void on_client_died()
41 {
42- engine->reset();
43+ config.engine->reset();
44 }
45
46 // Our link back to our parent.
47@@ -289,7 +286,6 @@
48 media::power::StateController::Lock<media::power::DisplayState>::Ptr display_state_lock;
49 media::power::StateController::Lock<media::power::SystemState>::Ptr system_state_lock;
50
51- std::shared_ptr<Engine> engine;
52 std::shared_ptr<media::NullTrackList> track_list;
53 std::atomic<int> system_wakelock_count;
54 std::atomic<int> display_wakelock_count;
55@@ -319,16 +315,16 @@
56 Parent::position().set(0);
57 Parent::duration().set(0);
58 Parent::audio_stream_role().set(Player::AudioStreamRole::multimedia);
59- d->engine->audio_stream_role().set(Player::AudioStreamRole::multimedia);
60+ d->config.engine->audio_stream_role().set(Player::AudioStreamRole::multimedia);
61 Parent::orientation().set(Player::Orientation::rotate0);
62 Parent::lifetime().set(Player::Lifetime::normal);
63- d->engine->lifetime().set(Player::Lifetime::normal);
64+ d->config.engine->lifetime().set(Player::Lifetime::normal);
65
66 // Make sure that the Position property gets updated from the Engine
67 // every time the client requests position
68 std::function<uint64_t()> position_getter = [this]()
69 {
70- return d->engine->position().get();
71+ return d->config.engine->position().get();
72 };
73 Parent::position().install(position_getter);
74
75@@ -336,19 +332,19 @@
76 // every time the client requests duration
77 std::function<uint64_t()> duration_getter = [this]()
78 {
79- return d->engine->duration().get();
80+ return d->config.engine->duration().get();
81 };
82 Parent::duration().install(duration_getter);
83
84 std::function<bool()> video_type_getter = [this]()
85 {
86- return d->engine->is_video_source().get();
87+ return d->config.engine->is_video_source().get();
88 };
89 Parent::is_video_source().install(video_type_getter);
90
91 std::function<bool()> audio_type_getter = [this]()
92 {
93- return d->engine->is_audio_source().get();
94+ return d->config.engine->is_audio_source().get();
95 };
96 Parent::is_audio_source().install(audio_type_getter);
97
98@@ -356,22 +352,22 @@
99 // whenever the client side sets the role
100 Parent::audio_stream_role().changed().connect([this](media::Player::AudioStreamRole new_role)
101 {
102- d->engine->audio_stream_role().set(new_role);
103+ d->config.engine->audio_stream_role().set(new_role);
104 });
105
106 // When the value of the orientation Property is changed in the Engine by playbin,
107 // update the Player's cached value
108- d->engine->orientation().changed().connect([this](const Player::Orientation& o)
109+ d->config.engine->orientation().changed().connect([this](const Player::Orientation& o)
110 {
111 Parent::orientation().set(o);
112 });
113
114 Parent::lifetime().changed().connect([this](media::Player::Lifetime lifetime)
115 {
116- d->engine->lifetime().set(lifetime);
117+ d->config.engine->lifetime().set(lifetime);
118 });
119
120- d->engine->about_to_finish_signal().connect([this]()
121+ d->config.engine->about_to_finish_signal().connect([this]()
122 {
123 Parent::about_to_finish()();
124
125@@ -383,7 +379,7 @@
126 }
127 });
128
129- d->engine->client_disconnected_signal().connect([this]()
130+ d->config.engine->client_disconnected_signal().connect([this]()
131 {
132 // If the client disconnects, make sure both wakelock types
133 // are cleared
134@@ -392,23 +388,23 @@
135 d->on_client_disconnected();
136 });
137
138- d->engine->seeked_to_signal().connect([this](uint64_t value)
139+ d->config.engine->seeked_to_signal().connect([this](uint64_t value)
140 {
141 Parent::seeked_to()(value);
142 });
143
144- d->engine->end_of_stream_signal().connect([this]()
145+ d->config.engine->end_of_stream_signal().connect([this]()
146 {
147 Parent::end_of_stream()();
148 });
149
150- d->engine->video_dimension_changed_signal().connect([this](const media::video::Dimensions& dimensions)
151+ d->config.engine->video_dimension_changed_signal().connect([this](const media::video::Dimensions& dimensions)
152 {
153 Parent::video_dimension_changed()(dimensions);
154 });
155
156- d->engine->error_signal().connect([this](const Player::Error& e)
157- {
158+ d->config.engine->error_signal().connect([this](const Player::Error& e)
159+ {
160 Parent::error()(e);
161 });
162
163@@ -480,20 +476,20 @@
164 template<typename Parent>
165 media::video::Sink::Ptr media::PlayerImplementation<Parent>::create_gl_texture_video_sink(std::uint32_t texture_id)
166 {
167- d->engine->create_video_sink(texture_id);
168+ d->config.engine->create_video_sink(texture_id);
169 return media::video::Sink::Ptr{};
170 }
171
172 template<typename Parent>
173 bool media::PlayerImplementation<Parent>::open_uri(const Track::UriType& uri)
174 {
175- return d->engine->open_resource_for_uri(uri);
176+ return d->config.engine->open_resource_for_uri(uri);
177 }
178
179 template<typename Parent>
180 bool media::PlayerImplementation<Parent>::open_uri(const Track::UriType& uri, const Player::HeadersType& headers)
181 {
182- return d->engine->open_resource_for_uri(uri, headers);
183+ return d->config.engine->open_resource_for_uri(uri, headers);
184 }
185
186 template<typename Parent>
187@@ -509,26 +505,26 @@
188 template<typename Parent>
189 void media::PlayerImplementation<Parent>::play()
190 {
191- d->engine->play();
192+ d->config.engine->play();
193 }
194
195 template<typename Parent>
196 void media::PlayerImplementation<Parent>::pause()
197 {
198- d->engine->pause();
199+ d->config.engine->pause();
200 }
201
202 template<typename Parent>
203 void media::PlayerImplementation<Parent>::stop()
204 {
205 std::cout << __PRETTY_FUNCTION__ << std::endl;
206- d->engine->stop();
207+ d->config.engine->stop();
208 }
209
210 template<typename Parent>
211 void media::PlayerImplementation<Parent>::seek_to(const std::chrono::microseconds& ms)
212 {
213- d->engine->seek_to(ms);
214+ d->config.engine->seek_to(ms);
215 }
216
217 template<typename Parent>
218
219=== modified file 'src/core/media/player_implementation.h'
220--- src/core/media/player_implementation.h 2015-03-19 19:08:47 +0000
221+++ src/core/media/player_implementation.h 2015-04-17 13:03:34 +0000
222@@ -48,6 +48,9 @@
223 // The unique key identifying the player instance.
224 Player::PlayerKey key;
225 // Functional dependencies
226+ std::shared_ptr<Engine> engine;
227+ apparmor::ubuntu::RequestContextResolver::Ptr request_context_resolver;
228+ apparmor::ubuntu::RequestAuthenticator::Ptr request_authenticator;
229 ClientDeathObserver::Ptr client_death_observer;
230 power::StateController::Ptr power_state_controller;
231 };
232
233=== modified file 'src/core/media/server/server.cpp'
234--- src/core/media/server/server.cpp 2014-12-15 14:43:44 +0000
235+++ src/core/media/server/server.cpp 2015-04-17 13:03:34 +0000
236@@ -23,6 +23,8 @@
237 #include "core/media/hashed_keyed_player_store.h"
238 #include "core/media/service_implementation.h"
239
240+#include "core/media/gstreamer/engine.h"
241+
242 #include <core/posix/signal.h>
243
244 #include <iostream>
245@@ -104,37 +106,57 @@
246 }
247 };
248
249+ // We keep overarching instances of power::BatteryObserver and power::StateController
250+ // for the lifetime of the service.
251+ auto battery_observer = media::power::make_platform_default_battery_observer(external_services);
252+ auto state_controller = media::power::make_platform_default_state_controller(external_services);
253 // Our common player store instance for tracking player instances.
254 auto player_store = std::make_shared<media::HashedKeyedPlayerStore>();
255 // We assemble the configuration for executing the service now.
256 media::ServiceImplementation::Configuration service_config
257 {
258+ []() { return std::make_shared<gstreamer::Engine>(); },
259 std::make_shared<media::HashedKeyedPlayerStore>(),
260+ battery_observer,
261+ state_controller,
262+ media::platform_default_client_death_observer(),
263+ media::make_platform_default_recorder_observer(),
264+ media::audio::make_platform_default_output_observer(),
265+ media::apparmor::ubuntu::make_platform_default_request_context_resolver(external_services),
266+ media::apparmor::ubuntu::make_platform_default_request_authenticator(),
267+ media::telephony::make_platform_default_call_monitor(),
268 external_services
269 };
270
271- auto impl = std::make_shared<media::ServiceImplementation>(media::ServiceImplementation::Configuration
272- {
273- player_store,
274- external_services
275- });
276+ auto impl = std::make_shared<media::ServiceImplementation>(service_config);
277+
278+ // object(impl->access_service()->add_object_for_path(
279+ // dbus::traits::Service<media::Service>::object_path())),
280+
281+ // Registering our service on the bus now, and creating the top-level object.
282+ auto session = std::make_shared<core::dbus::Bus>(core::dbus::WellKnownBus::session);
283+ session->install_executor(core::dbus::asio::make_executor(session));
284+ auto service = core::dbus::Service::add_service<media::Service>(session);
285+ auto object = service->add_object_for_path(core::dbus::traits::Service<media::Service>::object_path());
286
287 auto skeleton = std::make_shared<media::ServiceSkeleton>(media::ServiceSkeleton::Configuration
288 {
289+ session,
290+ service,
291+ object,
292 impl,
293- player_store,
294-
295+ player_store
296 });
297
298 std::thread service_worker
299 {
300- [&shutdown_requested, skeleton]()
301+ [&shutdown_requested, session]()
302 {
303 while (not shutdown_requested)
304 {
305 try
306 {
307- skeleton->run();
308+ session->run();
309 }
310 catch (const std::exception& e)
311 {
312@@ -157,7 +179,7 @@
313 shutdown_requested = true;
314
315 // And stop execution of helper and actual service.
316- skeleton->stop();
317+ session->stop();
318
319 if (service_worker.joinable())
320 service_worker.join();
321
322=== modified file 'src/core/media/service_implementation.cpp'
323--- src/core/media/service_implementation.cpp 2015-04-02 14:46:52 +0000
324+++ src/core/media/service_implementation.cpp 2015-04-17 13:03:34 +0000
325@@ -54,45 +54,29 @@
326 struct media::ServiceImplementation::Private
327 {
328 Private(const ServiceImplementation::Configuration& configuration)
329- : configuration(configuration),
330- resume_key(std::numeric_limits<std::uint32_t>::max()),
331- battery_observer(media::power::make_platform_default_battery_observer(configuration.external_services)),
332- power_state_controller(media::power::make_platform_default_state_controller(configuration.external_services)),
333- display_state_lock(power_state_controller->display_state_lock()),
334- client_death_observer(media::platform_default_client_death_observer()),
335- recorder_observer(media::make_platform_default_recorder_observer()),
336- audio_output_observer(media::audio::make_platform_default_output_observer()),
337- request_context_resolver(media::apparmor::ubuntu::make_platform_default_request_context_resolver(configuration.external_services)),
338- request_authenticator(media::apparmor::ubuntu::make_platform_default_request_authenticator()),
339- audio_output_state(media::audio::OutputState::Speaker),
340- call_monitor(media::telephony::make_platform_default_call_monitor())
341+ : configuration(configuration),
342+ display_state_lock(configuration.power_state_controller->display_state_lock()),
343+ resume_key(std::numeric_limits<std::uint32_t>::max())
344 {
345 }
346
347+ // We store all creation time arguments here.
348 media::ServiceImplementation::Configuration configuration;
349+ // We rely on a display state lock to keep the screen on if the
350+ // recording state of the system changes.
351+ media::power::StateController::Lock<media::power::DisplayState>::Ptr display_state_lock;
352 // This holds the key of the multimedia role Player instance that was paused
353 // when the battery level reached 10% or 5%
354- media::Player::PlayerKey resume_key;
355- media::power::BatteryObserver::Ptr battery_observer;
356- media::power::StateController::Ptr power_state_controller;
357- media::power::StateController::Lock<media::power::DisplayState>::Ptr display_state_lock;
358- media::ClientDeathObserver::Ptr client_death_observer;
359- media::RecorderObserver::Ptr recorder_observer;
360- media::audio::OutputObserver::Ptr audio_output_observer;
361- media::apparmor::ubuntu::RequestContextResolver::Ptr request_context_resolver;
362- media::apparmor::ubuntu::RequestAuthenticator::Ptr request_authenticator;
363- media::audio::OutputState audio_output_state;
364-
365- media::telephony::CallMonitor::Ptr call_monitor;
366+ media::Player::PlayerKey resume_key;
367 // Holds a pair of a Player key denoting what player to resume playback, and a bool
368 // for if it should be resumed after a phone call is hung up
369- std::list<std::pair<media::Player::PlayerKey, bool>> paused_sessions;
370+ std::list<std::pair<media::Player::PlayerKey, bool>> paused_sessions;
371 };
372
373 media::ServiceImplementation::ServiceImplementation(const Configuration& configuration)
374 : d(new Private(configuration))
375 {
376- d->battery_observer->level().changed().connect([this](const media::power::Level& level)
377+ d->configuration.battery_observer->level().changed().connect([this](const media::power::Level& level)
378 {
379 const bool resume_play_after_phonecall = false;
380 // When the battery level hits 10% or 5%, pause all multimedia sessions.
381@@ -110,7 +94,7 @@
382 }
383 });
384
385- d->battery_observer->is_warning_active().changed().connect([this](bool active)
386+ d->configuration.battery_observer->is_warning_active().changed().connect([this](bool active)
387 {
388 // If the low battery level notification is no longer being displayed,
389 // resume what the user was previously playing
390@@ -118,7 +102,7 @@
391 resume_multimedia_session();
392 });
393
394- d->audio_output_observer->external_output_state().changed().connect([this](audio::OutputState state)
395+ d->configuration.audio_output_observer->external_output_state().changed().connect([this](audio::OutputState state)
396 {
397 const bool resume_play_after_phonecall = false;
398 switch (state)
399@@ -136,10 +120,9 @@
400 std::cout << "AudioOutputObserver reports that output is now External." << std::endl;
401 break;
402 }
403- d->audio_output_state = state;
404 });
405
406- d->call_monitor->on_call_state_changed().connect([this](media::telephony::CallMonitor::State state)
407+ d->configuration.call_monitor->on_call_state_changed().connect([this](media::telephony::CallMonitor::State state)
408 {
409 const bool resume_play_after_phonecall = true;
410 switch (state) {
411@@ -156,7 +139,7 @@
412 }
413 });
414
415- d->recorder_observer->recording_state().changed().connect([this](RecordingState state)
416+ d->configuration.recorder_observer->recording_state().changed().connect([this](RecordingState state)
417 {
418 if (state == media::RecordingState::started)
419 {
420@@ -186,12 +169,15 @@
421 {
422 conf.bus,
423 conf.session,
424- d->request_context_resolver,
425- d->request_authenticator
426+ d->configuration.request_context_resolver,
427+ d->configuration.request_authenticator
428 },
429 conf.key,
430- d->client_death_observer,
431- d->power_state_controller
432+ d->configuration.engine_factory(),
433+ d->configuration.request_context_resolver,
434+ d->configuration.request_authenticator,
435+ d->configuration.client_death_observer,
436+ d->configuration.power_state_controller
437 });
438
439 auto key = conf.key;
440
441=== modified file 'src/core/media/service_implementation.h'
442--- src/core/media/service_implementation.h 2015-04-02 14:46:52 +0000
443+++ src/core/media/service_implementation.h 2015-04-17 13:03:34 +0000
444@@ -20,7 +20,19 @@
445 #define CORE_UBUNTU_MEDIA_SERVICE_IMPLEMENTATION_H_
446
447 #include "service_skeleton.h"
448+
449+#include "client_death_observer.h"
450 #include "external_services.h"
451+#include "recorder_observer.h"
452+
453+#include "apparmor/ubuntu.h"
454+#include "audio/output_observer.h"
455+#include "power/battery_observer.h"
456+#include "power/state_controller.h"
457+#include "telephony/call_monitor.h"
458+
459+#include <functional>
460+#include <memory>
461
462 namespace core
463 {
464@@ -28,6 +40,7 @@
465 {
466 namespace media
467 {
468+class Engine;
469 class Player;
470
471 class ServiceImplementation : public Service
472@@ -36,7 +49,16 @@
473 // All creation time arguments go here.
474 struct Configuration
475 {
476+ std::function<std::shared_ptr<Engine>()> engine_factory;
477 KeyedPlayerStore::Ptr player_store;
478+ media::power::BatteryObserver::Ptr battery_observer;
479+ media::power::StateController::Ptr power_state_controller;
480+ media::ClientDeathObserver::Ptr client_death_observer;
481+ media::RecorderObserver::Ptr recorder_observer;
482+ media::audio::OutputObserver::Ptr audio_output_observer;
483+ media::apparmor::ubuntu::RequestContextResolver::Ptr request_context_resolver;
484+ media::apparmor::ubuntu::RequestAuthenticator::Ptr request_authenticator;
485+ media::telephony::CallMonitor::Ptr call_monitor;
486 helper::ExternalServices& external_services;
487 };
488
489
490=== modified file 'src/core/media/service_skeleton.cpp'
491--- src/core/media/service_skeleton.cpp 2014-12-15 14:43:44 +0000
492+++ src/core/media/service_skeleton.cpp 2015-04-17 13:03:34 +0000
493@@ -50,28 +50,26 @@
494 struct media::ServiceSkeleton::Private
495 {
496 Private(media::ServiceSkeleton* impl, const ServiceSkeleton::Configuration& config)
497- : impl(impl),
498- object(impl->access_service()->add_object_for_path(
499- dbus::traits::Service<media::Service>::object_path())),
500- exported(impl->access_bus(), config.cover_art_resolver),
501+ : impl(impl),
502+ exported(config.bus, config.cover_art_resolver),
503 configuration(config)
504 {
505- object->install_method_handler<mpris::Service::CreateSession>(
506+ config.object->install_method_handler<mpris::Service::CreateSession>(
507 std::bind(
508 &Private::handle_create_session,
509 this,
510 std::placeholders::_1));
511- object->install_method_handler<mpris::Service::CreateFixedSession>(
512+ config.object->install_method_handler<mpris::Service::CreateFixedSession>(
513 std::bind(
514 &Private::handle_create_fixed_session,
515 this,
516 std::placeholders::_1));
517- object->install_method_handler<mpris::Service::ResumeSession>(
518+ config.object->install_method_handler<mpris::Service::ResumeSession>(
519 std::bind(
520 &Private::handle_resume_session,
521 this,
522 std::placeholders::_1));
523- object->install_method_handler<mpris::Service::PauseOtherSessions>(
524+ config.object->install_method_handler<mpris::Service::PauseOtherSessions>(
525 std::bind(
526 &Private::handle_pause_other_sessions,
527 this,
528@@ -92,7 +90,7 @@
529
530 void handle_create_session(const core::dbus::Message::Ptr& msg)
531 {
532- auto session_info = create_session_info();
533+ auto session_info = create_session_info();
534
535 dbus::types::ObjectPath op{session_info.first};
536 media::Player::PlayerKey key{session_info.second};
537@@ -100,8 +98,8 @@
538 media::Player::Configuration config
539 {
540 key,
541- impl->access_bus(),
542- impl->access_service()->add_object_for_path(op)
543+ configuration.bus,
544+ configuration.service->add_object_for_path(op)
545 };
546
547 try
548@@ -110,14 +108,14 @@
549 auto reply = dbus::Message::make_method_return(msg);
550 reply->writer() << op;
551
552- impl->access_bus()->send(reply);
553+ configuration.bus->send(reply);
554 } catch(const std::runtime_error& e)
555 {
556 auto reply = dbus::Message::make_error(
557 msg,
558 mpris::Service::Errors::CreatingSession::name(),
559 e.what());
560- impl->access_bus()->send(reply);
561+ configuration.bus->send(reply);
562 }
563 }
564
565@@ -138,8 +136,8 @@
566 media::Player::Configuration config
567 {
568 key,
569- impl->access_bus(),
570- impl->access_service()->add_object_for_path(op)
571+ configuration.bus,
572+ configuration.service->add_object_for_path(op)
573 };
574
575 auto session = impl->create_session(config);
576@@ -153,7 +151,7 @@
577 auto reply = dbus::Message::make_method_return(msg);
578 reply->writer() << op;
579
580- impl->access_bus()->send(reply);
581+ configuration.bus->send(reply);
582 }
583 else {
584 // Resume previous session
585@@ -163,7 +161,7 @@
586 msg,
587 mpris::Service::Errors::CreatingFixedSession::name(),
588 "Unable to locate player session");
589- impl->access_bus()->send(reply);
590+ configuration.bus->send(reply);
591 return;
592 }
593
594@@ -174,7 +172,7 @@
595 auto reply = dbus::Message::make_method_return(msg);
596 reply->writer() << op;
597
598- impl->access_bus()->send(reply);
599+ configuration.bus->send(reply);
600 }
601 } catch(const std::runtime_error& e)
602 {
603@@ -182,7 +180,7 @@
604 msg,
605 mpris::Service::Errors::CreatingSession::name(),
606 e.what());
607- impl->access_bus()->send(reply);
608+ configuration.bus->send(reply);
609 }
610 }
611
612@@ -198,7 +196,7 @@
613 msg,
614 mpris::Service::Errors::ResumingSession::name(),
615 "Unable to locate player session");
616- impl->access_bus()->send(reply);
617+ configuration.bus->send(reply);
618 return;
619 }
620
621@@ -209,14 +207,14 @@
622 auto reply = dbus::Message::make_method_return(msg);
623 reply->writer() << op;
624
625- impl->access_bus()->send(reply);
626+ configuration.bus->send(reply);
627 } catch(const std::runtime_error& e)
628 {
629 auto reply = dbus::Message::make_error(
630 msg,
631 mpris::Service::Errors::CreatingSession::name(),
632 e.what());
633- impl->access_bus()->send(reply);
634+ configuration.bus->send(reply);
635 }
636 }
637
638@@ -228,7 +226,7 @@
639 impl->pause_other_sessions(key);
640
641 auto reply = dbus::Message::make_method_return(msg);
642- impl->access_bus()->send(reply);
643+ configuration.bus->send(reply);
644 }
645
646 media::ServiceSkeleton* impl;
647@@ -507,8 +505,7 @@
648 };
649
650 media::ServiceSkeleton::ServiceSkeleton(const Configuration& configuration)
651- : dbus::Skeleton<media::Service>(the_session_bus()),
652- d(new Private(this, configuration))
653+ : d(new Private(this, configuration))
654 {
655 }
656
657@@ -535,13 +532,3 @@
658 {
659 d->configuration.impl->pause_other_sessions(key);
660 }
661-
662-void media::ServiceSkeleton::run()
663-{
664- access_bus()->run();
665-}
666-
667-void media::ServiceSkeleton::stop()
668-{
669- access_bus()->stop();
670-}
671
672=== modified file 'src/core/media/service_skeleton.h'
673--- src/core/media/service_skeleton.h 2014-12-15 14:43:44 +0000
674+++ src/core/media/service_skeleton.h 2015-04-17 13:03:34 +0000
675@@ -25,7 +25,7 @@
676 #include "keyed_player_store.h"
677 #include "service_traits.h"
678
679-#include <core/dbus/skeleton.h>
680+#include <core/dbus/object.h>
681
682 #include <memory>
683
684@@ -35,12 +35,15 @@
685 {
686 namespace media
687 {
688-class ServiceSkeleton : public core::dbus::Skeleton<core::ubuntu::media::Service>
689+class ServiceSkeleton : public core::ubuntu::media::Service
690 {
691 public:
692 // Creation time arguments go here.
693 struct Configuration
694 {
695+ core::dbus::Bus::Ptr bus;
696+ core::dbus::Service::Ptr service;
697+ core::dbus::Object::Ptr object;
698 std::shared_ptr<Service> impl;
699 KeyedPlayerStore::Ptr player_store;
700 CoverArtResolver cover_art_resolver;
701@@ -55,9 +58,6 @@
702 std::shared_ptr<Player> resume_session(Player::PlayerKey);
703 void pause_other_sessions(Player::PlayerKey key);
704
705- void run();
706- void stop();
707-
708 private:
709 struct Private;
710 std::shared_ptr<Private> d;

Subscribers

People subscribed via source and target branches