Merge lp:~phablet-team/media-hub/introduce-call-monitor-interface into lp:media-hub
- introduce-call-monitor-interface
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Ricardo Mendoza |
Approved revision: | 119 |
Merged at revision: | 122 |
Proposed branch: | lp:~phablet-team/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:~phablet-team/media-hub/introduce-call-monitor-interface |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot | continuous-integration | Approve | |
Jim Hodapp | code | Pending | |
Review via email: mp+251805@code.launchpad.net |
This proposal supersedes a proposal from 2014-11-26.
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::
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal | # |
Jim Hodapp (jhodapp) wrote : Posted in a previous version of this proposal | # |
Looks good.
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal | # |
FAILED: Continuous integration, rev:110
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal | # |
FAILED: Continuous integration, rev:111
http://
Executed test runs:
FAILURE: http://
SUCCESS: http://
deb: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal | # |
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 : Posted in a previous version of this proposal | # |
PASSED: Continuous integration, rev:114
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal | # |
PASSED: Continuous integration, rev:115
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal | # |
FAILED: Continuous integration, rev:116
http://
Executed test runs:
FAILURE: http://
SUCCESS: http://
deb: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal | # |
FAILED: Continuous integration, rev:117
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
- 118. By Ricardo Salveti
-
Merge prereq
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:118
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
- 119. By Thomas Voß
-
* 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
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:119
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Preview Diff
1 | === modified file 'src/core/media/CMakeLists.txt' | |||
2 | --- src/core/media/CMakeLists.txt 2015-03-12 11:44:42 +0000 | |||
3 | +++ src/core/media/CMakeLists.txt 2015-03-12 11:44:43 +0000 | |||
4 | @@ -11,7 +11,7 @@ | |||
5 | 11 | 11 | ||
6 | 12 | message(STATUS ${MEDIA_HUB_HEADERS}) | 12 | message(STATUS ${MEDIA_HUB_HEADERS}) |
7 | 13 | 13 | ||
9 | 14 | add_subdirectory(call-monitor) | 14 | add_subdirectory(telephony) |
10 | 15 | 15 | ||
11 | 16 | add_library( | 16 | add_library( |
12 | 17 | media-hub-common SHARED | 17 | media-hub-common SHARED |
13 | 18 | 18 | ||
14 | === modified file 'src/core/media/service_implementation.cpp' | |||
15 | --- src/core/media/service_implementation.cpp 2015-03-12 11:44:42 +0000 | |||
16 | +++ src/core/media/service_implementation.cpp 2015-03-12 11:44:43 +0000 | |||
17 | @@ -24,12 +24,12 @@ | |||
18 | 24 | 24 | ||
19 | 25 | #include "audio/output_observer.h" | 25 | #include "audio/output_observer.h" |
20 | 26 | #include "client_death_observer.h" | 26 | #include "client_death_observer.h" |
21 | 27 | #include "call-monitor/call_monitor.h" | ||
22 | 28 | #include "player_configuration.h" | 27 | #include "player_configuration.h" |
23 | 29 | #include "player_implementation.h" | 28 | #include "player_implementation.h" |
24 | 30 | #include "power/battery_observer.h" | 29 | #include "power/battery_observer.h" |
25 | 31 | #include "power/state_controller.h" | 30 | #include "power/state_controller.h" |
26 | 32 | #include "recorder_observer.h" | 31 | #include "recorder_observer.h" |
27 | 32 | #include "telephony/call_monitor.h" | ||
28 | 33 | 33 | ||
29 | 34 | #include <boost/asio.hpp> | 34 | #include <boost/asio.hpp> |
30 | 35 | 35 | ||
31 | @@ -60,7 +60,7 @@ | |||
32 | 60 | recorder_observer(media::make_platform_default_recorder_observer()), | 60 | recorder_observer(media::make_platform_default_recorder_observer()), |
33 | 61 | audio_output_observer(media::audio::make_platform_default_output_observer()), | 61 | audio_output_observer(media::audio::make_platform_default_output_observer()), |
34 | 62 | audio_output_state(media::audio::OutputState::Speaker), | 62 | audio_output_state(media::audio::OutputState::Speaker), |
36 | 63 | call_monitor(new CallMonitor) | 63 | call_monitor(media::telephony::make_platform_default_call_monitor()) |
37 | 64 | { | 64 | { |
38 | 65 | } | 65 | } |
39 | 66 | 66 | ||
40 | @@ -76,7 +76,7 @@ | |||
41 | 76 | media::audio::OutputObserver::Ptr audio_output_observer; | 76 | media::audio::OutputObserver::Ptr audio_output_observer; |
42 | 77 | media::audio::OutputState audio_output_state; | 77 | media::audio::OutputState audio_output_state; |
43 | 78 | 78 | ||
45 | 79 | std::unique_ptr<CallMonitor> call_monitor; | 79 | media::telephony::CallMonitor::Ptr call_monitor; |
46 | 80 | std::list<media::Player::PlayerKey> paused_sessions; | 80 | std::list<media::Player::PlayerKey> paused_sessions; |
47 | 81 | }; | 81 | }; |
48 | 82 | 82 | ||
49 | @@ -123,15 +123,15 @@ | |||
50 | 123 | d->audio_output_state = state; | 123 | d->audio_output_state = state; |
51 | 124 | }); | 124 | }); |
52 | 125 | 125 | ||
54 | 126 | d->call_monitor->on_change([this](CallMonitor::State state) { | 126 | d->call_monitor->on_call_state_changed().connect([this](media::telephony::CallMonitor::State state) |
55 | 127 | { | ||
56 | 127 | switch (state) { | 128 | switch (state) { |
58 | 128 | case CallMonitor::OffHook: | 129 | case media::telephony::CallMonitor::State::OffHook: |
59 | 129 | std::cout << "Got call started signal, pausing all multimedia sessions" << std::endl; | 130 | std::cout << "Got call started signal, pausing all multimedia sessions" << std::endl; |
60 | 130 | pause_all_multimedia_sessions(); | 131 | pause_all_multimedia_sessions(); |
61 | 131 | break; | 132 | break; |
63 | 132 | case CallMonitor::OnHook: | 133 | case media::telephony::CallMonitor::State::OnHook: |
64 | 133 | std::cout << "Got call ended signal, resuming paused multimedia sessions" << std::endl; | 134 | std::cout << "Got call ended signal, resuming paused multimedia sessions" << std::endl; |
65 | 134 | // Don't auto-resume any paused video playback sessions | ||
66 | 135 | resume_paused_multimedia_sessions(false); | 135 | resume_paused_multimedia_sessions(false); |
67 | 136 | break; | 136 | break; |
68 | 137 | } | 137 | } |
69 | 138 | 138 | ||
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-12 11:44:43 +0000 | |||
74 | @@ -29,8 +29,12 @@ | |||
75 | 29 | #include <list> | 29 | #include <list> |
76 | 30 | #include <mutex> | 30 | #include <mutex> |
77 | 31 | 31 | ||
78 | 32 | namespace media = core::ubuntu::media; | ||
79 | 32 | 33 | ||
81 | 33 | namespace { | 34 | namespace |
82 | 35 | { | ||
83 | 36 | namespace impl | ||
84 | 37 | { | ||
85 | 34 | class TelepathyCallMonitor : public QObject | 38 | class TelepathyCallMonitor : public QObject |
86 | 35 | { | 39 | { |
87 | 36 | Q_OBJECT | 40 | Q_OBJECT |
88 | @@ -73,7 +77,7 @@ | |||
89 | 73 | } | 77 | } |
90 | 74 | } | 78 | } |
91 | 75 | 79 | ||
93 | 76 | void on_change(const std::function<void(CallMonitor::State)>& func) { | 80 | void on_change(const std::function<void(media::telephony::CallMonitor::State)>& func) { |
94 | 77 | std::lock_guard<std::mutex> l(cb_lock); | 81 | std::lock_guard<std::mutex> l(cb_lock); |
95 | 78 | cb = func; | 82 | cb = func; |
96 | 79 | } | 83 | } |
97 | @@ -131,19 +135,19 @@ | |||
98 | 131 | { | 135 | { |
99 | 132 | std::lock_guard<std::mutex> l(cb_lock); | 136 | std::lock_guard<std::mutex> l(cb_lock); |
100 | 133 | if (cb) | 137 | if (cb) |
102 | 134 | cb(CallMonitor::OffHook); | 138 | cb(media::telephony::CallMonitor::State::OffHook); |
103 | 135 | } | 139 | } |
104 | 136 | 140 | ||
105 | 137 | void onHook() | 141 | void onHook() |
106 | 138 | { | 142 | { |
107 | 139 | std::lock_guard<std::mutex> l(cb_lock); | 143 | std::lock_guard<std::mutex> l(cb_lock); |
108 | 140 | if (cb) | 144 | if (cb) |
110 | 141 | cb(CallMonitor::OnHook); | 145 | cb(media::telephony::CallMonitor::State::OnHook); |
111 | 142 | } | 146 | } |
112 | 143 | 147 | ||
113 | 144 | private: | 148 | private: |
114 | 145 | std::mutex cb_lock; | 149 | std::mutex cb_lock; |
116 | 146 | std::function<void (CallMonitor::State)> cb; | 150 | std::function<void (media::telephony::CallMonitor::State)> cb; |
117 | 147 | Tp::AccountManagerPtr mAccountManager; | 151 | Tp::AccountManagerPtr mAccountManager; |
118 | 148 | std::list<TelepathyCallMonitor*> mCallMonitors; | 152 | std::list<TelepathyCallMonitor*> mCallMonitors; |
119 | 149 | 153 | ||
120 | @@ -159,63 +163,78 @@ | |||
121 | 159 | mCallMonitors.push_back(tcm); | 163 | mCallMonitors.push_back(tcm); |
122 | 160 | } | 164 | } |
123 | 161 | }; | 165 | }; |
124 | 162 | } | ||
125 | 163 | 166 | ||
127 | 164 | class CallMonitorPrivate | 167 | struct CallMonitor : public media::telephony::CallMonitor |
128 | 165 | { | 168 | { |
136 | 166 | public: | 169 | CallMonitor() : mBridge{nullptr} |
137 | 167 | CallMonitorPrivate() { | 170 | { |
138 | 168 | mBridge = nullptr; | 171 | try |
139 | 169 | try { | 172 | { |
140 | 170 | std::thread([this]() { | 173 | qt_world = std::move(std::thread([this]() |
141 | 171 | qt::core::world::build_and_run(0, nullptr, [this]() { | 174 | { |
142 | 172 | qt::core::world::enter_with_task([this]() { | 175 | qt::core::world::build_and_run(0, nullptr, [this]() |
143 | 176 | { | ||
144 | 177 | qt::core::world::enter_with_task([this]() | ||
145 | 178 | { | ||
146 | 173 | std::cout << "CallMonitor: Creating TelepathyBridge" << std::endl; | 179 | std::cout << "CallMonitor: Creating TelepathyBridge" << std::endl; |
147 | 174 | mBridge = new TelepathyBridge(); | 180 | mBridge = new TelepathyBridge(); |
148 | 175 | cv.notify_all(); | 181 | cv.notify_all(); |
149 | 176 | }); | 182 | }); |
150 | 177 | }); | 183 | }); |
152 | 178 | }).detach(); | 184 | })); |
153 | 179 | } catch(const std::system_error& error) { | 185 | } catch(const std::system_error& error) { |
154 | 180 | std::cerr << "exception(std::system_error) in CallMonitor thread start" << error.what() << std::endl; | 186 | std::cerr << "exception(std::system_error) in CallMonitor thread start" << error.what() << std::endl; |
155 | 181 | } catch(...) { | 187 | } catch(...) { |
156 | 182 | std::cerr << "exception(...) in CallMonitor thread start" << std::endl; | 188 | std::cerr << "exception(...) in CallMonitor thread start" << std::endl; |
157 | 183 | } | 189 | } |
158 | 190 | |||
159 | 184 | // Wait until telepathy bridge is set, so we can hook up the change signals | 191 | // Wait until telepathy bridge is set, so we can hook up the change signals |
160 | 185 | std::unique_lock<std::mutex> lck(mtx); | 192 | std::unique_lock<std::mutex> lck(mtx); |
161 | 186 | cv.wait_for(lck, std::chrono::seconds(3)); | 193 | cv.wait_for(lck, std::chrono::seconds(3)); |
162 | 194 | |||
163 | 195 | if (mBridge) | ||
164 | 196 | { | ||
165 | 197 | mBridge->on_change([this](CallMonitor::State state) | ||
166 | 198 | { | ||
167 | 199 | call_state_changed(state); | ||
168 | 200 | }); | ||
169 | 201 | } | ||
170 | 187 | } | 202 | } |
171 | 188 | 203 | ||
173 | 189 | ~CallMonitorPrivate() { | 204 | ~CallMonitor() |
174 | 205 | { | ||
175 | 206 | // We first clean up the bridge instance. | ||
176 | 207 | qt::core::world::enter_with_task([this]() | ||
177 | 208 | { | ||
178 | 209 | delete mBridge; | ||
179 | 210 | }).get(); | ||
180 | 211 | |||
181 | 212 | // We then request destruction of the qt world. | ||
182 | 190 | qt::core::world::destroy(); | 213 | qt::core::world::destroy(); |
183 | 214 | |||
184 | 215 | // Before we finally join the worker. | ||
185 | 216 | if (qt_world.joinable()) | ||
186 | 217 | qt_world.join(); | ||
187 | 218 | } | ||
188 | 219 | |||
189 | 220 | const core::Signal<media::telephony::CallMonitor::State>& on_call_state_changed() const | ||
190 | 221 | { | ||
191 | 222 | return call_state_changed; | ||
192 | 191 | } | 223 | } |
193 | 192 | 224 | ||
194 | 193 | TelepathyBridge *mBridge; | 225 | TelepathyBridge *mBridge; |
195 | 226 | core::Signal<media::telephony::CallMonitor::State> call_state_changed; | ||
196 | 194 | 227 | ||
198 | 195 | private: | 228 | std::thread qt_world; |
199 | 196 | std::mutex mtx; | 229 | std::mutex mtx; |
200 | 197 | std::condition_variable cv; | 230 | std::condition_variable cv; |
201 | 198 | }; | 231 | }; |
222 | 199 | 232 | } | |
223 | 200 | 233 | } | |
224 | 201 | CallMonitor::CallMonitor(): | 234 | |
225 | 202 | d(new CallMonitorPrivate) | 235 | media::telephony::CallMonitor::Ptr media::telephony::make_platform_default_call_monitor() |
226 | 203 | { | 236 | { |
227 | 204 | } | 237 | return std::make_shared<impl::CallMonitor>(); |
208 | 205 | |||
209 | 206 | CallMonitor::~CallMonitor() | ||
210 | 207 | { | ||
211 | 208 | delete d->mBridge; | ||
212 | 209 | delete d; | ||
213 | 210 | } | ||
214 | 211 | |||
215 | 212 | void CallMonitor::on_change(const std::function<void(CallMonitor::State)>& func) | ||
216 | 213 | { | ||
217 | 214 | if (d->mBridge != nullptr) { | ||
218 | 215 | std::cout << "CallMonitor: Setting up callback for TelepathyBridge on_change" << std::endl; | ||
219 | 216 | d->mBridge->on_change(func); | ||
220 | 217 | } else | ||
221 | 218 | std::cerr << "TelepathyBridge: Failed to hook on_change signal, bridge not yet set" << std::endl; | ||
228 | 219 | } | 238 | } |
229 | 220 | 239 | ||
230 | 221 | #include "call_monitor.moc" | 240 | #include "call_monitor.moc" |
231 | 222 | 241 | ||
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-12 11:44:43 +0000 | |||
235 | @@ -17,25 +17,50 @@ | |||
236 | 17 | */ | 17 | */ |
237 | 18 | 18 | ||
238 | 19 | 19 | ||
241 | 20 | #ifndef CALLMONITOR_H | 20 | #ifndef CORE_UBUNTU_MEDIA_TELEPHONY_CALL_MONITOR_H_ |
242 | 21 | #define CALLMONITOR_H | 21 | #define CORE_UBUNTU_MEDIA_TELEPHONY_CALL_MONITOR_H_ |
243 | 22 | |||
244 | 23 | #include <core/signal.h> | ||
245 | 22 | 24 | ||
246 | 23 | #include <functional> | 25 | #include <functional> |
262 | 24 | 26 | #include <memory> | |
263 | 25 | class CallMonitorPrivate; | 27 | |
264 | 26 | 28 | namespace core | |
265 | 27 | class CallMonitor | 29 | { |
266 | 28 | { | 30 | namespace ubuntu |
267 | 29 | public: | 31 | { |
268 | 30 | enum State { OffHook, OnHook }; | 32 | namespace media |
269 | 31 | 33 | { | |
270 | 32 | CallMonitor(); | 34 | namespace telephony |
271 | 33 | ~CallMonitor(); | 35 | { |
272 | 34 | 36 | // CallMonitor models the ability to observe and react | |
273 | 35 | void on_change(const std::function<void(CallMonitor::State)>& func); | 37 | // to changes of the overall call state of the system. |
274 | 36 | 38 | struct CallMonitor | |
275 | 37 | private: | 39 | { |
276 | 38 | CallMonitorPrivate *d; | 40 | // Save us some typing. |
277 | 41 | typedef std::shared_ptr<CallMonitor> Ptr; | ||
278 | 42 | |||
279 | 43 | // All known call states | ||
280 | 44 | enum class State | ||
281 | 45 | { | ||
282 | 46 | // No current call. | ||
283 | 47 | OffHook, | ||
284 | 48 | // Call in progress. | ||
285 | 49 | OnHook | ||
286 | 50 | }; | ||
287 | 51 | |||
288 | 52 | CallMonitor() = default; | ||
289 | 53 | virtual ~CallMonitor() = default; | ||
290 | 54 | |||
291 | 55 | // Emitted whenever the current call state of the system changes. | ||
292 | 56 | virtual const core::Signal<State>& on_call_state_changed() const = 0; | ||
293 | 39 | }; | 57 | }; |
294 | 40 | 58 | ||
296 | 41 | #endif // CALLMONITOR_H | 59 | // Returns a platform default implementation of CallMonitor. |
297 | 60 | CallMonitor::Ptr make_platform_default_call_monitor(); | ||
298 | 61 | } | ||
299 | 62 | } | ||
300 | 63 | } | ||
301 | 64 | } | ||
302 | 65 | |||
303 | 66 | #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://