Merge lp:~thomas-voss/media-hub/introduce-recorder-observer-interface into lp:media-hub

Proposed by Thomas Voß
Status: Merged
Approved by: Ricardo Mendoza
Approved revision: 108
Merged at revision: 117
Proposed branch: lp:~thomas-voss/media-hub/introduce-recorder-observer-interface
Merge into: lp:media-hub
Prerequisite: lp:~thomas-voss/media-hub/introduce-client-death-observer-interface
Diff against target: 359 lines (+255/-17)
6 files modified
src/core/media/CMakeLists.txt (+2/-0)
src/core/media/hybris_recorder_observer.cpp (+99/-0)
src/core/media/hybris_recorder_observer.h (+52/-0)
src/core/media/recorder_observer.cpp (+28/-0)
src/core/media/recorder_observer.h (+64/-0)
src/core/media/service_implementation.cpp (+10/-17)
To merge this branch: bzr merge lp:~thomas-voss/media-hub/introduce-recorder-observer-interface
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Jim Hodapp (community) code Approve
Review via email: mp+242889@code.launchpad.net

Commit message

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.

Description of the change

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.

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

Remerge prereq branch.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Jim Hodapp (jhodapp) wrote :

Looks good, thanks!

review: Approve (code)
104. By Thomas Voß

[ Jim Hodapp ]
* Resubmitting with prerequisite branch (LP: #1331041)
[ Justin McPherson ]
* Resubmitting with prerequisite branch (LP: #1331041)

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

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

Merge prereq branch.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Francis Ginther (fginther) wrote :

The jenkins node for the i386 build failed, I've restarted a new ci run.

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

Merge prereq branch.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
108. 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
1=== modified file 'src/core/media/CMakeLists.txt'
2--- src/core/media/CMakeLists.txt 2015-03-12 11:41:17 +0000
3+++ src/core/media/CMakeLists.txt 2015-03-12 11:41:17 +0000
4@@ -90,6 +90,8 @@
5 hybris_client_death_observer.cpp
6 cover_art_resolver.cpp
7 engine.cpp
8+ recorder_observer.cpp
9+ hybris_recorder_observer.cpp
10 gstreamer/engine.cpp
11
12 player_skeleton.cpp
13
14=== added file 'src/core/media/hybris_recorder_observer.cpp'
15--- src/core/media/hybris_recorder_observer.cpp 1970-01-01 00:00:00 +0000
16+++ src/core/media/hybris_recorder_observer.cpp 2015-03-12 11:41:17 +0000
17@@ -0,0 +1,99 @@
18+/*
19+ * Copyright © 2014 Canonical Ltd.
20+ *
21+ * This program is free software: you can redistribute it and/or modify it
22+ * under the terms of the GNU Lesser General Public License version 3,
23+ * as published by the Free Software Foundation.
24+ *
25+ * This program is distributed in the hope that it will be useful,
26+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
27+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28+ * GNU Lesser General Public License for more details.
29+ *
30+ * You should have received a copy of the GNU Lesser General Public License
31+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
32+ *
33+ * Authored by: Thomas Voß <thomas.voss@canonical.com>
34+ */
35+
36+#include <core/media/hybris_recorder_observer.h>
37+
38+namespace media = core::ubuntu::media;
39+
40+#if defined(MEDIA_HUB_HAVE_HYBRIS_MEDIA_COMPAT_LAYER)
41+#include <hybris/media/media_recorder_layer.h>
42+
43+struct media::HybrisRecorderObserver::Private
44+{
45+ struct Holder
46+ {
47+ std::weak_ptr<media::HybrisRecorderObserver::Private> wp;
48+ };
49+
50+ // The fringe that we hand over to hybris.
51+ static void on_media_recording_state_changed(bool started, void* context)
52+ {
53+ if (auto holder = static_cast<Holder*>(context))
54+ {
55+ if (auto sp = holder->wp.lock())
56+ {
57+ sp->recording_state = started ? media::RecordingState::started : media::RecordingState::stopped;
58+ }
59+ }
60+ }
61+
62+ // TODO: We have no way of freeing the observer and thus leak
63+ // an instance here.
64+ MediaRecorderObserver* observer
65+ {
66+ android_media_recorder_observer_new()
67+ };
68+
69+ core::Property<media::RecordingState> recording_state
70+ {
71+ media::RecordingState::stopped
72+ };
73+
74+ Holder* holder
75+ {
76+ nullptr
77+ };
78+};
79+
80+media::HybrisRecorderObserver::HybrisRecorderObserver() : d{new Private{}}
81+{
82+ android_media_recorder_observer_set_cb(
83+ d->observer,
84+ &Private::on_media_recording_state_changed,
85+ d->holder = new Private::Holder{d});
86+}
87+
88+media::HybrisRecorderObserver::~HybrisRecorderObserver()
89+{
90+ // We first reset the context of the callback.
91+ android_media_recorder_observer_set_cb(
92+ d->observer,
93+ &Private::on_media_recording_state_changed,
94+ nullptr);
95+
96+ delete d->holder;
97+}
98+
99+const core::Property<media::RecordingState>& media::HybrisRecorderObserver::recording_state() const
100+{
101+ return d->recording_state;
102+}
103+
104+media::RecorderObserver::Ptr media::HybrisRecorderObserver::create()
105+{
106+ return media::RecorderObserver::Ptr{new media::HybrisRecorderObserver{}};
107+}
108+#else // MEDIA_HUB_HAVE_HYBRIS_MEDIA_COMPAT_LAYER
109+media::RecorderObserver::Ptr media::HybrisRecorderObserver::create()
110+{
111+ throw std::logic_error
112+ {
113+ "Hybris-based recorder observer implementation not supported on this platform."
114+ };
115+}
116+#endif // MEDIA_HUB_HAVE_HYBRIS_MEDIA_COMPAT_LAYER
117
118=== added file 'src/core/media/hybris_recorder_observer.h'
119--- src/core/media/hybris_recorder_observer.h 1970-01-01 00:00:00 +0000
120+++ src/core/media/hybris_recorder_observer.h 2015-03-12 11:41:17 +0000
121@@ -0,0 +1,52 @@
122+/*
123+ * Copyright © 2014 Canonical Ltd.
124+ *
125+ * This program is free software: you can redistribute it and/or modify it
126+ * under the terms of the GNU Lesser General Public License version 3,
127+ * as published by the Free Software Foundation.
128+ *
129+ * This program is distributed in the hope that it will be useful,
130+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
131+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
132+ * GNU Lesser General Public License for more details.
133+ *
134+ * You should have received a copy of the GNU Lesser General Public License
135+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
136+ *
137+ * Authored by: Thomas Voß <thomas.voss@canonical.com>
138+ */
139+
140+#ifndef CORE_UBUNTU_MEDIA_HYBRIS_RECORDER_OBSERVER_H_
141+#define CORE_UBUNTU_MEDIA_HYBRIS_RECORDER_OBSERVER_H_
142+
143+#include <core/media/recorder_observer.h>
144+
145+namespace core
146+{
147+namespace ubuntu
148+{
149+namespace media
150+{
151+class HybrisRecorderObserver : public RecorderObserver
152+{
153+public:
154+ // Creates a new instance of the HybrisRecorderObserver or throws
155+ // if hybris is not available.
156+ static RecorderObserver::Ptr create();
157+
158+ ~HybrisRecorderObserver();
159+
160+ // Getable/observable property describing the recording state of the system.
161+ const core::Property<RecordingState>& recording_state() const override;
162+
163+private:
164+ struct Private;
165+
166+ HybrisRecorderObserver();
167+ std::shared_ptr<Private> d;
168+};
169+}
170+}
171+}
172+
173+#endif // CORE_UBUNTU_MEDIA_HYBRIS_RECORDER_OBSERVER_H_
174
175=== added file 'src/core/media/recorder_observer.cpp'
176--- src/core/media/recorder_observer.cpp 1970-01-01 00:00:00 +0000
177+++ src/core/media/recorder_observer.cpp 2015-03-12 11:41:17 +0000
178@@ -0,0 +1,28 @@
179+/*
180+ * Copyright © 2014 Canonical Ltd.
181+ *
182+ * This program is free software: you can redistribute it and/or modify it
183+ * under the terms of the GNU Lesser General Public License version 3,
184+ * as published by the Free Software Foundation.
185+ *
186+ * This program is distributed in the hope that it will be useful,
187+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
188+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
189+ * GNU Lesser General Public License for more details.
190+ *
191+ * You should have received a copy of the GNU Lesser General Public License
192+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
193+ *
194+ * Authored by: Thomas Voß <thomas.voss@canonical.com>
195+ */
196+
197+#include <core/media/recorder_observer.h>
198+
199+#include <core/media/hybris_recorder_observer.h>
200+
201+namespace media = core::ubuntu::media;
202+
203+media::RecorderObserver::Ptr media::make_platform_default_recorder_observer()
204+{
205+ return media::HybrisRecorderObserver::create();
206+}
207
208=== added file 'src/core/media/recorder_observer.h'
209--- src/core/media/recorder_observer.h 1970-01-01 00:00:00 +0000
210+++ src/core/media/recorder_observer.h 2015-03-12 11:41:17 +0000
211@@ -0,0 +1,64 @@
212+/*
213+ * Copyright © 2014 Canonical Ltd.
214+ *
215+ * This program is free software: you can redistribute it and/or modify it
216+ * under the terms of the GNU Lesser General Public License version 3,
217+ * as published by the Free Software Foundation.
218+ *
219+ * This program is distributed in the hope that it will be useful,
220+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
221+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
222+ * GNU Lesser General Public License for more details.
223+ *
224+ * You should have received a copy of the GNU Lesser General Public License
225+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
226+ *
227+ * Authored by: Thomas Voß <thomas.voss@canonical.com>
228+ */
229+
230+#ifndef CORE_UBUNTU_MEDIA_RECORDER_OBSERVER_H_
231+#define CORE_UBUNTU_MEDIA_RECORDER_OBSERVER_H_
232+
233+#include <core/property.h>
234+
235+#include <memory>
236+
237+namespace core
238+{
239+namespace ubuntu
240+{
241+namespace media
242+{
243+// All known states of the recorder
244+enum class RecordingState
245+{
246+ // No active recording
247+ stopped,
248+ // We have an active recording session
249+ started
250+};
251+
252+// A RecorderObserver allows for monitoring the recording state
253+// of the service.
254+struct RecorderObserver
255+{
256+ // To save us some typing.
257+ typedef std::shared_ptr<RecorderObserver> Ptr;
258+
259+ RecorderObserver() = default;
260+ RecorderObserver(const RecorderObserver&) = delete;
261+ virtual ~RecorderObserver() = default;
262+ RecorderObserver& operator=(const RecorderObserver&) = delete;
263+
264+ // Getable/observable property describing the recording state of the system.
265+ virtual const core::Property<RecordingState>& recording_state() const = 0;
266+};
267+
268+// Creates an instance of interface RecorderObserver relying on
269+// default services offered by the platform we are currently running on.
270+RecorderObserver::Ptr make_platform_default_recorder_observer();
271+}
272+}
273+}
274+
275+#endif // CORE_UBUNTU_MEDIA_RECORDER_OBSERVER_H_
276
277=== modified file 'src/core/media/service_implementation.cpp'
278--- src/core/media/service_implementation.cpp 2015-01-16 17:17:30 +0000
279+++ src/core/media/service_implementation.cpp 2015-03-12 11:41:17 +0000
280@@ -26,6 +26,7 @@
281 #include "call-monitor/call_monitor.h"
282 #include "player_configuration.h"
283 #include "player_implementation.h"
284+#include "recorder_observer.h"
285
286 #include <boost/asio.hpp>
287
288@@ -40,7 +41,6 @@
289
290 #include "util/timeout.h"
291 #include "unity_screen_service.h"
292-#include <hybris/media/media_recorder_layer.h>
293
294 namespace media = core::ubuntu::media;
295
296@@ -141,8 +141,11 @@
297 auto uscreen_stub_service = dbus::Service::use_service(bus, dbus::traits::Service<core::UScreen>::interface_name());
298 uscreen_session = uscreen_stub_service->object_for_path(dbus::types::ObjectPath("/com/canonical/Unity/Screen"));
299
300- observer = android_media_recorder_observer_new();
301- android_media_recorder_observer_set_cb(observer, &Private::media_recording_started_callback, this);
302+ recorder_observer = media::make_platform_default_recorder_observer();
303+ recorder_observer->recording_state().changed().connect([this](media::RecordingState state)
304+ {
305+ media_recording_state_changed(state);
306+ });
307 }
308
309 ~Private()
310@@ -165,12 +168,12 @@
311 pulse_worker.join();
312 }
313
314- void media_recording_started(bool started)
315+ void media_recording_state_changed(media::RecordingState state)
316 {
317 if (uscreen_session == nullptr)
318 return;
319
320- if (started)
321+ if (state == media::RecordingState::started)
322 {
323 if (disp_cookie > 0)
324 return;
325@@ -183,7 +186,7 @@
326 throw std::runtime_error(result.error().print());
327 disp_cookie = result.value();
328 }
329- else
330+ else if (state == media::RecordingState::stopped)
331 {
332 if (disp_cookie != -1)
333 {
334@@ -195,15 +198,6 @@
335 }
336 }
337
338- static void media_recording_started_callback(bool started, void *context)
339- {
340- if (context == nullptr)
341- return;
342-
343- auto p = static_cast<Private*>(context);
344- p->media_recording_started(started);
345- }
346-
347 pa_threaded_mainloop *mainloop()
348 {
349 return pulse_mainloop;
350@@ -459,8 +453,7 @@
351 std::shared_ptr<core::dbus::Property<core::IndicatorPower::IsWarning>> is_warning;
352 int disp_cookie;
353 std::shared_ptr<dbus::Object> uscreen_session;
354- MediaRecorderObserver *observer;
355-
356+ media::RecorderObserver::Ptr recorder_observer;
357 // Pulse-specific
358 pa_mainloop_api *pulse_mainloop_api;
359 pa_threaded_mainloop *pulse_mainloop;

Subscribers

People subscribed via source and target branches