Merge lp:~phablet-team/media-hub/introduce-call-monitor-interface into lp:media-hub

Proposed by Ricardo Salveti
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
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/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.

Description of the change

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.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Jim Hodapp (jhodapp) wrote : Posted in a previous version of this proposal

Looks good.

review: Approve (code)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
118. By Ricardo Salveti

Merge prereq

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
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

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/core/media/CMakeLists.txt'
--- src/core/media/CMakeLists.txt 2015-03-12 11:44:42 +0000
+++ src/core/media/CMakeLists.txt 2015-03-12 11:44:43 +0000
@@ -11,7 +11,7 @@
1111
12message(STATUS ${MEDIA_HUB_HEADERS})12message(STATUS ${MEDIA_HUB_HEADERS})
1313
14add_subdirectory(call-monitor)14add_subdirectory(telephony)
1515
16add_library(16add_library(
17 media-hub-common SHARED17 media-hub-common SHARED
1818
=== modified file 'src/core/media/service_implementation.cpp'
--- src/core/media/service_implementation.cpp 2015-03-12 11:44:42 +0000
+++ src/core/media/service_implementation.cpp 2015-03-12 11:44:43 +0000
@@ -24,12 +24,12 @@
2424
25#include "audio/output_observer.h"25#include "audio/output_observer.h"
26#include "client_death_observer.h"26#include "client_death_observer.h"
27#include "call-monitor/call_monitor.h"
28#include "player_configuration.h"27#include "player_configuration.h"
29#include "player_implementation.h"28#include "player_implementation.h"
30#include "power/battery_observer.h"29#include "power/battery_observer.h"
31#include "power/state_controller.h"30#include "power/state_controller.h"
32#include "recorder_observer.h"31#include "recorder_observer.h"
32#include "telephony/call_monitor.h"
3333
34#include <boost/asio.hpp>34#include <boost/asio.hpp>
3535
@@ -60,7 +60,7 @@
60 recorder_observer(media::make_platform_default_recorder_observer()),60 recorder_observer(media::make_platform_default_recorder_observer()),
61 audio_output_observer(media::audio::make_platform_default_output_observer()),61 audio_output_observer(media::audio::make_platform_default_output_observer()),
62 audio_output_state(media::audio::OutputState::Speaker),62 audio_output_state(media::audio::OutputState::Speaker),
63 call_monitor(new CallMonitor)63 call_monitor(media::telephony::make_platform_default_call_monitor())
64 {64 {
65 }65 }
6666
@@ -76,7 +76,7 @@
76 media::audio::OutputObserver::Ptr audio_output_observer;76 media::audio::OutputObserver::Ptr audio_output_observer;
77 media::audio::OutputState audio_output_state;77 media::audio::OutputState audio_output_state;
7878
79 std::unique_ptr<CallMonitor> call_monitor;79 media::telephony::CallMonitor::Ptr call_monitor;
80 std::list<media::Player::PlayerKey> paused_sessions;80 std::list<media::Player::PlayerKey> paused_sessions;
81};81};
8282
@@ -123,15 +123,15 @@
123 d->audio_output_state = state;123 d->audio_output_state = state;
124 });124 });
125125
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)
127 {
127 switch (state) {128 switch (state) {
128 case CallMonitor::OffHook:129 case media::telephony::CallMonitor::State::OffHook:
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;
130 pause_all_multimedia_sessions();131 pause_all_multimedia_sessions();
131 break;132 break;
132 case CallMonitor::OnHook:133 case media::telephony::CallMonitor::State::OnHook:
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;
134 // Don't auto-resume any paused video playback sessions
135 resume_paused_multimedia_sessions(false);135 resume_paused_multimedia_sessions(false);
136 break;136 break;
137 }137 }
138138
=== renamed directory 'src/core/media/call-monitor' => 'src/core/media/telephony'
=== modified file 'src/core/media/telephony/call_monitor.cpp'
--- src/core/media/call-monitor/call_monitor.cpp 2015-01-12 21:35:36 +0000
+++ src/core/media/telephony/call_monitor.cpp 2015-03-12 11:44:43 +0000
@@ -29,8 +29,12 @@
29#include <list>29#include <list>
30#include <mutex>30#include <mutex>
3131
32namespace media = core::ubuntu::media;
3233
33namespace {34namespace
35{
36namespace impl
37{
34class TelepathyCallMonitor : public QObject38class TelepathyCallMonitor : public QObject
35{39{
36 Q_OBJECT40 Q_OBJECT
@@ -73,7 +77,7 @@
73 }77 }
74 }78 }
7579
76 void on_change(const std::function<void(CallMonitor::State)>& func) {80 void on_change(const std::function<void(media::telephony::CallMonitor::State)>& func) {
77 std::lock_guard<std::mutex> l(cb_lock);81 std::lock_guard<std::mutex> l(cb_lock);
78 cb = func;82 cb = func;
79 }83 }
@@ -131,19 +135,19 @@
131 {135 {
132 std::lock_guard<std::mutex> l(cb_lock);136 std::lock_guard<std::mutex> l(cb_lock);
133 if (cb)137 if (cb)
134 cb(CallMonitor::OffHook);138 cb(media::telephony::CallMonitor::State::OffHook);
135 }139 }
136140
137 void onHook()141 void onHook()
138 {142 {
139 std::lock_guard<std::mutex> l(cb_lock);143 std::lock_guard<std::mutex> l(cb_lock);
140 if (cb)144 if (cb)
141 cb(CallMonitor::OnHook);145 cb(media::telephony::CallMonitor::State::OnHook);
142 }146 }
143147
144private:148private:
145 std::mutex cb_lock;149 std::mutex cb_lock;
146 std::function<void (CallMonitor::State)> cb;150 std::function<void (media::telephony::CallMonitor::State)> cb;
147 Tp::AccountManagerPtr mAccountManager;151 Tp::AccountManagerPtr mAccountManager;
148 std::list<TelepathyCallMonitor*> mCallMonitors;152 std::list<TelepathyCallMonitor*> mCallMonitors;
149153
@@ -159,63 +163,78 @@
159 mCallMonitors.push_back(tcm);163 mCallMonitors.push_back(tcm);
160 }164 }
161};165};
162}
163166
164class CallMonitorPrivate167struct CallMonitor : public media::telephony::CallMonitor
165{168{
166public:169 CallMonitor() : mBridge{nullptr}
167 CallMonitorPrivate() {170 {
168 mBridge = nullptr;171 try
169 try {172 {
170 std::thread([this]() {173 qt_world = std::move(std::thread([this]()
171 qt::core::world::build_and_run(0, nullptr, [this]() {174 {
172 qt::core::world::enter_with_task([this]() {175 qt::core::world::build_and_run(0, nullptr, [this]()
176 {
177 qt::core::world::enter_with_task([this]()
178 {
173 std::cout << "CallMonitor: Creating TelepathyBridge" << std::endl;179 std::cout << "CallMonitor: Creating TelepathyBridge" << std::endl;
174 mBridge = new TelepathyBridge();180 mBridge = new TelepathyBridge();
175 cv.notify_all();181 cv.notify_all();
176 });182 });
177 });183 });
178 }).detach();184 }));
179 } catch(const std::system_error& error) {185 } catch(const std::system_error& error) {
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;
181 } catch(...) {187 } catch(...) {
182 std::cerr << "exception(...) in CallMonitor thread start" << std::endl;188 std::cerr << "exception(...) in CallMonitor thread start" << std::endl;
183 }189 }
190
184 // Wait until telepathy bridge is set, so we can hook up the change signals191 // Wait until telepathy bridge is set, so we can hook up the change signals
185 std::unique_lock<std::mutex> lck(mtx);192 std::unique_lock<std::mutex> lck(mtx);
186 cv.wait_for(lck, std::chrono::seconds(3));193 cv.wait_for(lck, std::chrono::seconds(3));
194
195 if (mBridge)
196 {
197 mBridge->on_change([this](CallMonitor::State state)
198 {
199 call_state_changed(state);
200 });
201 }
187 }202 }
188203
189 ~CallMonitorPrivate() {204 ~CallMonitor()
205 {
206 // We first clean up the bridge instance.
207 qt::core::world::enter_with_task([this]()
208 {
209 delete mBridge;
210 }).get();
211
212 // We then request destruction of the qt world.
190 qt::core::world::destroy();213 qt::core::world::destroy();
214
215 // Before we finally join the worker.
216 if (qt_world.joinable())
217 qt_world.join();
218 }
219
220 const core::Signal<media::telephony::CallMonitor::State>& on_call_state_changed() const
221 {
222 return call_state_changed;
191 }223 }
192224
193 TelepathyBridge *mBridge;225 TelepathyBridge *mBridge;
226 core::Signal<media::telephony::CallMonitor::State> call_state_changed;
194227
195private:228 std::thread qt_world;
196 std::mutex mtx;229 std::mutex mtx;
197 std::condition_variable cv;230 std::condition_variable cv;
198};231};
199232}
200233}
201CallMonitor::CallMonitor():234
202 d(new CallMonitorPrivate)235media::telephony::CallMonitor::Ptr media::telephony::make_platform_default_call_monitor()
203{236{
204}237 return std::make_shared<impl::CallMonitor>();
205
206CallMonitor::~CallMonitor()
207{
208 delete d->mBridge;
209 delete d;
210}
211
212void CallMonitor::on_change(const std::function<void(CallMonitor::State)>& func)
213{
214 if (d->mBridge != nullptr) {
215 std::cout << "CallMonitor: Setting up callback for TelepathyBridge on_change" << std::endl;
216 d->mBridge->on_change(func);
217 } else
218 std::cerr << "TelepathyBridge: Failed to hook on_change signal, bridge not yet set" << std::endl;
219}238}
220239
221#include "call_monitor.moc"240#include "call_monitor.moc"
222241
=== modified file 'src/core/media/telephony/call_monitor.h'
--- src/core/media/call-monitor/call_monitor.h 2014-10-31 07:49:33 +0000
+++ src/core/media/telephony/call_monitor.h 2015-03-12 11:44:43 +0000
@@ -17,25 +17,50 @@
17 */17 */
1818
1919
20#ifndef CALLMONITOR_H20#ifndef CORE_UBUNTU_MEDIA_TELEPHONY_CALL_MONITOR_H_
21#define CALLMONITOR_H21#define CORE_UBUNTU_MEDIA_TELEPHONY_CALL_MONITOR_H_
22
23#include <core/signal.h>
2224
23#include <functional>25#include <functional>
2426#include <memory>
25class CallMonitorPrivate;27
2628namespace core
27class CallMonitor29{
28{30namespace ubuntu
29public:31{
30 enum State { OffHook, OnHook };32namespace media
3133{
32 CallMonitor();34namespace telephony
33 ~CallMonitor();35{
3436// CallMonitor models the ability to observe and react
35 void on_change(const std::function<void(CallMonitor::State)>& func);37// to changes of the overall call state of the system.
3638struct CallMonitor
37private:39{
38 CallMonitorPrivate *d;40 // Save us some typing.
41 typedef std::shared_ptr<CallMonitor> Ptr;
42
43 // All known call states
44 enum class State
45 {
46 // No current call.
47 OffHook,
48 // Call in progress.
49 OnHook
50 };
51
52 CallMonitor() = default;
53 virtual ~CallMonitor() = default;
54
55 // Emitted whenever the current call state of the system changes.
56 virtual const core::Signal<State>& on_call_state_changed() const = 0;
39};57};
4058
41#endif // CALLMONITOR_H59// Returns a platform default implementation of CallMonitor.
60CallMonitor::Ptr make_platform_default_call_monitor();
61}
62}
63}
64}
65
66#endif // CORE_UBUNTU_MEDIA_TELEPHONY_CALL_MONITOR_H_

Subscribers

People subscribed via source and target branches

to all changes: