Merge lp:~thomas-voss/media-hub/introduce-call-monitor-interface into lp:media-hub
- introduce-call-monitor-interface
- Merge into trunk
Status: | Superseded |
---|---|
Proposed branch: | lp:~thomas-voss/media-hub/introduce-call-monitor-interface |
Merge into: | lp:media-hub |
Prerequisite: | lp:~phablet-team/media-hub/introduce-audio-output-observer-interface |
Diff against target: |
303 lines (+107/-63) 4 files modified
src/core/media/CMakeLists.txt (+1/-1) src/core/media/service_implementation.cpp (+7/-7) src/core/media/telephony/call_monitor.cpp (+56/-37) src/core/media/telephony/call_monitor.h (+43/-18) |
To merge this branch: | bzr merge lp:~thomas-voss/media-hub/introduce-call-monitor-interface |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot | continuous-integration | Needs Fixing | |
Jim Hodapp (community) | code | Approve | |
Review via email: mp+242917@code.launchpad.net |
This proposal has been superseded by a proposal from 2015-03-04.
Commit message
Move src/core/
Introduce a proper interface media::
Slightly adjust existing implementation based on Qt.
Adjust media::
Description of the change
Move src/core/
Introduce a proper interface media::
Slightly adjust existing implementation based on Qt.
Adjust media::
- 109. By Thomas Voß
-
Remerge prereq branch.
PS Jenkins bot (ps-jenkins) wrote : | # |
- 110. By Thomas Voß
-
[ Jim Hodapp ]
* Resubmitting with prerequisite branch (LP: #1331041)
[ Justin McPherson ]
* Resubmitting with prerequisite branch (LP: #1331041)
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:110
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
- 111. By Thomas Voß
-
Merge prerequisite branch.
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:111
http://
Executed test runs:
FAILURE: http://
SUCCESS: http://
deb: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
- 112. By Thomas Voß
-
[ Jim Hodapp ]
* Error reporting all the way up to the app level from the playbin
pipeline.
[ Ubuntu daily release ]
* New rebuild forced
[ Jim Hodapp ]
* Don't auto-resume playback of videos after a phone call ends. (LP:
#1411273)
[ Ubuntu daily release ]
* New rebuild forced
[ Ricardo Salveti de Araujo ]
* service_implementation: adding debug for call started/ended signals.
Make sure account and connection are available when setting up
account manager (patch from Gustavo Boiko). call_monitor: don't
check caps when hooking up on/off signals, until bug 1409125 is
fixed. Enable parallel building . (LP: #1409125)
[ Jim Hodapp ]
* Pause playback when recording begins. (LP: #1398047)
[ Ricardo Salveti de Araujo ]
* call_monitor.cpp: waiting for bridge to be up, and also protecting
the on_change call (LP: #1408137) - 113. By Thomas Voß
-
Merge prereq branch.
- 114. By Thomas Voß
-
Merge prereq branch.
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:113
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:114
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
- 115. By Thomas Voß
-
Merge prereq branch.
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:115
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
- 116. By Thomas Voß
-
Merge prereq branch.
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:116
http://
Executed test runs:
FAILURE: http://
SUCCESS: http://
deb: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
- 117. By Thomas Voß
-
Merge prereq branch.
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:117
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
Unmerged revisions
Preview Diff
1 | === modified file 'src/core/media/CMakeLists.txt' |
2 | --- src/core/media/CMakeLists.txt 2015-03-04 16:22:24 +0000 |
3 | +++ src/core/media/CMakeLists.txt 2015-03-04 16:22:24 +0000 |
4 | @@ -11,7 +11,7 @@ |
5 | |
6 | message(STATUS ${MEDIA_HUB_HEADERS}) |
7 | |
8 | -add_subdirectory(call-monitor) |
9 | +add_subdirectory(telephony) |
10 | |
11 | add_library( |
12 | media-hub-common SHARED |
13 | |
14 | === modified file 'src/core/media/service_implementation.cpp' |
15 | --- src/core/media/service_implementation.cpp 2015-03-04 16:22:24 +0000 |
16 | +++ src/core/media/service_implementation.cpp 2015-03-04 16:22:24 +0000 |
17 | @@ -24,12 +24,12 @@ |
18 | |
19 | #include "audio/output_observer.h" |
20 | #include "client_death_observer.h" |
21 | -#include "call-monitor/call_monitor.h" |
22 | #include "player_configuration.h" |
23 | #include "player_implementation.h" |
24 | #include "power/battery_observer.h" |
25 | #include "power/state_controller.h" |
26 | #include "recorder_observer.h" |
27 | +#include "telephony/call_monitor.h" |
28 | |
29 | #include <boost/asio.hpp> |
30 | |
31 | @@ -60,7 +60,7 @@ |
32 | recorder_observer(media::make_platform_default_recorder_observer()), |
33 | audio_output_observer(media::audio::make_platform_default_output_observer()), |
34 | audio_output_state(media::audio::OutputState::Speaker), |
35 | - call_monitor(new CallMonitor) |
36 | + call_monitor(media::telephony::make_platform_default_call_monitor()) |
37 | { |
38 | } |
39 | |
40 | @@ -76,7 +76,7 @@ |
41 | media::audio::OutputObserver::Ptr audio_output_observer; |
42 | media::audio::OutputObserver audio_output_state; |
43 | |
44 | - std::unique_ptr<CallMonitor> call_monitor; |
45 | + media::telephony::CallMonitor::Ptr call_monitor; |
46 | std::list<media::Player::PlayerKey> paused_sessions; |
47 | }; |
48 | |
49 | @@ -125,15 +125,15 @@ |
50 | d->audio_output_state = state; |
51 | }); |
52 | |
53 | - d->call_monitor->on_change([this](CallMonitor::State state) { |
54 | + d->call_monitor->on_call_state_changed().connect([this](media::telephony::CallMonitor::State state) |
55 | + { |
56 | switch (state) { |
57 | - case CallMonitor::OffHook: |
58 | + case media::telephony::CallMonitor::State::OffHook: |
59 | std::cout << "Got call started signal, pausing all multimedia sessions" << std::endl; |
60 | pause_all_multimedia_sessions(); |
61 | break; |
62 | - case CallMonitor::OnHook: |
63 | + case media::telephony::CallMonitor::State::OnHook: |
64 | std::cout << "Got call ended signal, resuming paused multimedia sessions" << std::endl; |
65 | - // Don't auto-resume any paused video playback sessions |
66 | resume_paused_multimedia_sessions(false); |
67 | break; |
68 | } |
69 | |
70 | === renamed directory 'src/core/media/call-monitor' => 'src/core/media/telephony' |
71 | === modified file 'src/core/media/telephony/call_monitor.cpp' |
72 | --- src/core/media/call-monitor/call_monitor.cpp 2015-01-12 21:35:36 +0000 |
73 | +++ src/core/media/telephony/call_monitor.cpp 2015-03-04 16:22:24 +0000 |
74 | @@ -29,8 +29,12 @@ |
75 | #include <list> |
76 | #include <mutex> |
77 | |
78 | +namespace media = core::ubuntu::media; |
79 | |
80 | -namespace { |
81 | +namespace |
82 | +{ |
83 | +namespace impl |
84 | +{ |
85 | class TelepathyCallMonitor : public QObject |
86 | { |
87 | Q_OBJECT |
88 | @@ -73,7 +77,7 @@ |
89 | } |
90 | } |
91 | |
92 | - void on_change(const std::function<void(CallMonitor::State)>& func) { |
93 | + void on_change(const std::function<void(media::telephony::CallMonitor::State)>& func) { |
94 | std::lock_guard<std::mutex> l(cb_lock); |
95 | cb = func; |
96 | } |
97 | @@ -131,19 +135,19 @@ |
98 | { |
99 | std::lock_guard<std::mutex> l(cb_lock); |
100 | if (cb) |
101 | - cb(CallMonitor::OffHook); |
102 | + cb(media::telephony::CallMonitor::State::OffHook); |
103 | } |
104 | |
105 | void onHook() |
106 | { |
107 | std::lock_guard<std::mutex> l(cb_lock); |
108 | if (cb) |
109 | - cb(CallMonitor::OnHook); |
110 | + cb(media::telephony::CallMonitor::State::OnHook); |
111 | } |
112 | |
113 | private: |
114 | std::mutex cb_lock; |
115 | - std::function<void (CallMonitor::State)> cb; |
116 | + std::function<void (media::telephony::CallMonitor::State)> cb; |
117 | Tp::AccountManagerPtr mAccountManager; |
118 | std::list<TelepathyCallMonitor*> mCallMonitors; |
119 | |
120 | @@ -159,63 +163,78 @@ |
121 | mCallMonitors.push_back(tcm); |
122 | } |
123 | }; |
124 | -} |
125 | |
126 | -class CallMonitorPrivate |
127 | +struct CallMonitor : public media::telephony::CallMonitor |
128 | { |
129 | -public: |
130 | - CallMonitorPrivate() { |
131 | - mBridge = nullptr; |
132 | - try { |
133 | - std::thread([this]() { |
134 | - qt::core::world::build_and_run(0, nullptr, [this]() { |
135 | - qt::core::world::enter_with_task([this]() { |
136 | + CallMonitor() : mBridge{nullptr} |
137 | + { |
138 | + try |
139 | + { |
140 | + qt_world = std::move(std::thread([this]() |
141 | + { |
142 | + qt::core::world::build_and_run(0, nullptr, [this]() |
143 | + { |
144 | + qt::core::world::enter_with_task([this]() |
145 | + { |
146 | std::cout << "CallMonitor: Creating TelepathyBridge" << std::endl; |
147 | mBridge = new TelepathyBridge(); |
148 | cv.notify_all(); |
149 | }); |
150 | }); |
151 | - }).detach(); |
152 | + })); |
153 | } catch(const std::system_error& error) { |
154 | std::cerr << "exception(std::system_error) in CallMonitor thread start" << error.what() << std::endl; |
155 | } catch(...) { |
156 | std::cerr << "exception(...) in CallMonitor thread start" << std::endl; |
157 | } |
158 | + |
159 | // Wait until telepathy bridge is set, so we can hook up the change signals |
160 | std::unique_lock<std::mutex> lck(mtx); |
161 | cv.wait_for(lck, std::chrono::seconds(3)); |
162 | + |
163 | + if (mBridge) |
164 | + { |
165 | + mBridge->on_change([this](CallMonitor::State state) |
166 | + { |
167 | + call_state_changed(state); |
168 | + }); |
169 | + } |
170 | } |
171 | |
172 | - ~CallMonitorPrivate() { |
173 | + ~CallMonitor() |
174 | + { |
175 | + // We first clean up the bridge instance. |
176 | + qt::core::world::enter_with_task([this]() |
177 | + { |
178 | + delete mBridge; |
179 | + }).get(); |
180 | + |
181 | + // We then request destruction of the qt world. |
182 | qt::core::world::destroy(); |
183 | + |
184 | + // Before we finally join the worker. |
185 | + if (qt_world.joinable()) |
186 | + qt_world.join(); |
187 | + } |
188 | + |
189 | + const core::Signal<media::telephony::CallMonitor::State>& on_call_state_changed() const |
190 | + { |
191 | + return call_state_changed; |
192 | } |
193 | |
194 | TelepathyBridge *mBridge; |
195 | + core::Signal<media::telephony::CallMonitor::State> call_state_changed; |
196 | |
197 | -private: |
198 | + std::thread qt_world; |
199 | std::mutex mtx; |
200 | std::condition_variable cv; |
201 | }; |
202 | - |
203 | - |
204 | -CallMonitor::CallMonitor(): |
205 | - d(new CallMonitorPrivate) |
206 | -{ |
207 | -} |
208 | - |
209 | -CallMonitor::~CallMonitor() |
210 | -{ |
211 | - delete d->mBridge; |
212 | - delete d; |
213 | -} |
214 | - |
215 | -void CallMonitor::on_change(const std::function<void(CallMonitor::State)>& func) |
216 | -{ |
217 | - if (d->mBridge != nullptr) { |
218 | - std::cout << "CallMonitor: Setting up callback for TelepathyBridge on_change" << std::endl; |
219 | - d->mBridge->on_change(func); |
220 | - } else |
221 | - std::cerr << "TelepathyBridge: Failed to hook on_change signal, bridge not yet set" << std::endl; |
222 | +} |
223 | +} |
224 | + |
225 | +media::telephony::CallMonitor::Ptr media::telephony::make_platform_default_call_monitor() |
226 | +{ |
227 | + return std::make_shared<impl::CallMonitor>(); |
228 | } |
229 | |
230 | #include "call_monitor.moc" |
231 | |
232 | === modified file 'src/core/media/telephony/call_monitor.h' |
233 | --- src/core/media/call-monitor/call_monitor.h 2014-10-31 07:49:33 +0000 |
234 | +++ src/core/media/telephony/call_monitor.h 2015-03-04 16:22:24 +0000 |
235 | @@ -17,25 +17,50 @@ |
236 | */ |
237 | |
238 | |
239 | -#ifndef CALLMONITOR_H |
240 | -#define CALLMONITOR_H |
241 | +#ifndef CORE_UBUNTU_MEDIA_TELEPHONY_CALL_MONITOR_H_ |
242 | +#define CORE_UBUNTU_MEDIA_TELEPHONY_CALL_MONITOR_H_ |
243 | + |
244 | +#include <core/signal.h> |
245 | |
246 | #include <functional> |
247 | - |
248 | -class CallMonitorPrivate; |
249 | - |
250 | -class CallMonitor |
251 | -{ |
252 | -public: |
253 | - enum State { OffHook, OnHook }; |
254 | - |
255 | - CallMonitor(); |
256 | - ~CallMonitor(); |
257 | - |
258 | - void on_change(const std::function<void(CallMonitor::State)>& func); |
259 | - |
260 | -private: |
261 | - CallMonitorPrivate *d; |
262 | +#include <memory> |
263 | + |
264 | +namespace core |
265 | +{ |
266 | +namespace ubuntu |
267 | +{ |
268 | +namespace media |
269 | +{ |
270 | +namespace telephony |
271 | +{ |
272 | +// CallMonitor models the ability to observe and react |
273 | +// to changes of the overall call state of the system. |
274 | +struct CallMonitor |
275 | +{ |
276 | + // Save us some typing. |
277 | + typedef std::shared_ptr<CallMonitor> Ptr; |
278 | + |
279 | + // All known call states |
280 | + enum class State |
281 | + { |
282 | + // No current call. |
283 | + OffHook, |
284 | + // Call in progress. |
285 | + OnHook |
286 | + }; |
287 | + |
288 | + CallMonitor() = default; |
289 | + virtual ~CallMonitor() = default; |
290 | + |
291 | + // Emitted whenever the current call state of the system changes. |
292 | + virtual const core::Signal<State>& on_call_state_changed() const = 0; |
293 | }; |
294 | |
295 | -#endif // CALLMONITOR_H |
296 | +// Returns a platform default implementation of CallMonitor. |
297 | +CallMonitor::Ptr make_platform_default_call_monitor(); |
298 | +} |
299 | +} |
300 | +} |
301 | +} |
302 | + |
303 | +#endif // CORE_UBUNTU_MEDIA_TELEPHONY_CALL_MONITOR_H_ |
FAILED: Continuous integration, rev:109 jenkins. qa.ubuntu. com/job/ media-hub- ci/185/ jenkins. qa.ubuntu. com/job/ media-hub- vivid-amd64- ci/25/console jenkins. qa.ubuntu. com/job/ media-hub- vivid-armhf- ci/25/console jenkins. qa.ubuntu. com/job/ media-hub- vivid-i386- ci/25/console
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/media- hub-ci/ 185/rebuild
http://