Merge lp:~jhodapp/media-hub/audio-stream-role into lp:media-hub
- audio-stream-role
- Merge into trunk
Status: | Merged | ||||||||
---|---|---|---|---|---|---|---|---|---|
Approved by: | Ricardo Salveti | ||||||||
Approved revision: | 59 | ||||||||
Merged at revision: | 57 | ||||||||
Proposed branch: | lp:~jhodapp/media-hub/audio-stream-role | ||||||||
Merge into: | lp:media-hub | ||||||||
Diff against target: |
629 lines (+209/-24) 15 files modified
include/core/media/player.h (+16/-0) src/core/media/codec.h (+42/-1) src/core/media/engine.cpp (+2/-1) src/core/media/engine.h (+5/-1) src/core/media/gstreamer/engine.cpp (+26/-2) src/core/media/gstreamer/engine.h (+4/-0) src/core/media/gstreamer/playbin.h (+46/-1) src/core/media/mpris/player.h (+2/-0) src/core/media/player_implementation.cpp (+9/-0) src/core/media/player_skeleton.cpp (+12/-0) src/core/media/player_skeleton.h (+3/-0) src/core/media/player_stub.cpp (+15/-2) src/core/media/player_stub.h (+2/-0) src/core/media/player_traits.h (+1/-1) src/core/media/service_implementation.cpp (+24/-15) |
||||||||
To merge this branch: | bzr merge lp:~jhodapp/media-hub/audio-stream-role | ||||||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ricardo Salveti (community) | Approve | ||
PS Jenkins bot | continuous-integration | Needs Fixing | |
Review via email: mp+232741@code.launchpad.net |
Commit message
* Add an audio stream role that allows the client app to categorize what type of audio stream it's requesting playback for
* Pause playback of playing Players only if the requesting Player and other Player are both of role multimedia
Description of the change
* Add an audio stream role that allows the client app to categorize what type of audio stream it's requesting playback for
* Pause playback of playing Players only if the requesting Player and other Player are both of role multimedia
PS Jenkins bot (ps-jenkins) wrote : | # |
- 59. By Jim Hodapp
-
Make sure the default role gets applied to pulsesink when a new Player is first created
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:59
http://
Executed test runs:
FAILURE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Ricardo Salveti (rsalveti) wrote : | # |
Looks good, works fine.
Preview Diff
1 | === modified file 'include/core/media/player.h' |
2 | --- include/core/media/player.h 2014-04-25 17:53:00 +0000 |
3 | +++ include/core/media/player.h 2014-08-29 21:46:11 +0000 |
4 | @@ -14,6 +14,7 @@ |
5 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
6 | * |
7 | * Authored by: Thomas Voß <thomas.voss@canonical.com> |
8 | + * Jim Hodapp <jim.hodapp@canonical.com> |
9 | */ |
10 | #ifndef CORE_UBUNTU_MEDIA_PLAYER_H_ |
11 | #define CORE_UBUNTU_MEDIA_PLAYER_H_ |
12 | @@ -72,6 +73,19 @@ |
13 | playlist |
14 | }; |
15 | |
16 | + /** |
17 | + * Audio stream role types used to categorize audio playback. |
18 | + * multimedia is the default role type and will be automatically |
19 | + * paused by media-hub when other types need to play. |
20 | + */ |
21 | + enum AudioStreamRole |
22 | + { |
23 | + alarm, |
24 | + alert, |
25 | + multimedia, |
26 | + phone |
27 | + }; |
28 | + |
29 | Player(const Player&) = delete; |
30 | virtual ~Player(); |
31 | |
32 | @@ -112,11 +126,13 @@ |
33 | virtual const core::Property<PlaybackRate>& maximum_playback_rate() const = 0; |
34 | virtual const core::Property<uint64_t>& position() const = 0; |
35 | virtual const core::Property<uint64_t>& duration() const = 0; |
36 | + virtual const core::Property<AudioStreamRole>& audio_stream_role() const = 0; |
37 | |
38 | virtual core::Property<LoopStatus>& loop_status() = 0; |
39 | virtual core::Property<PlaybackRate>& playback_rate() = 0; |
40 | virtual core::Property<bool>& is_shuffle() = 0; |
41 | virtual core::Property<Volume>& volume() = 0; |
42 | + virtual core::Property<AudioStreamRole>& audio_stream_role() = 0; |
43 | |
44 | virtual const core::Signal<uint64_t>& seeked_to() const = 0; |
45 | virtual const core::Signal<void>& end_of_stream() const = 0; |
46 | |
47 | === modified file 'src/core/media/codec.h' |
48 | --- src/core/media/codec.h 2014-02-12 15:53:57 +0000 |
49 | +++ src/core/media/codec.h 2014-08-29 21:46:11 +0000 |
50 | @@ -1,5 +1,5 @@ |
51 | /* |
52 | - * Copyright © 2013 Canonical Ltd. |
53 | + * Copyright © 2013-2014 Canonical Ltd. |
54 | * |
55 | * This program is free software: you can redistribute it and/or modify it |
56 | * under the terms of the GNU Lesser General Public License version 3, |
57 | @@ -14,6 +14,7 @@ |
58 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
59 | * |
60 | * Authored by: Thomas Voß <thomas.voss@canonical.com> |
61 | + * Jim Hodapp <jim.hodapp@canonical.com> |
62 | */ |
63 | |
64 | #ifndef CODEC_H_ |
65 | @@ -149,6 +150,46 @@ |
66 | } |
67 | }; |
68 | |
69 | +namespace helper |
70 | +{ |
71 | +template<> |
72 | +struct TypeMapper<core::ubuntu::media::Player::AudioStreamRole> |
73 | +{ |
74 | + constexpr static ArgumentType type_value() |
75 | + { |
76 | + return core::dbus::ArgumentType::int16; |
77 | + } |
78 | + constexpr static bool is_basic_type() |
79 | + { |
80 | + return false; |
81 | + } |
82 | + constexpr static bool requires_signature() |
83 | + { |
84 | + return false; |
85 | + } |
86 | + |
87 | + static std::string signature() |
88 | + { |
89 | + static const std::string s = TypeMapper<std::int16_t>::signature(); |
90 | + return s; |
91 | + } |
92 | +}; |
93 | +} |
94 | + |
95 | +template<> |
96 | +struct Codec<core::ubuntu::media::Player::AudioStreamRole> |
97 | +{ |
98 | + static void encode_argument(core::dbus::Message::Writer& out, const core::ubuntu::media::Player::AudioStreamRole& in) |
99 | + { |
100 | + out.push_int16(static_cast<std::int16_t>(in)); |
101 | + } |
102 | + |
103 | + static void decode_argument(core::dbus::Message::Reader& out, core::ubuntu::media::Player::AudioStreamRole& in) |
104 | + { |
105 | + in = static_cast<core::ubuntu::media::Player::AudioStreamRole>(out.pop_int16()); |
106 | + } |
107 | +}; |
108 | + |
109 | } |
110 | } |
111 | |
112 | |
113 | === modified file 'src/core/media/engine.cpp' |
114 | --- src/core/media/engine.cpp 2014-02-12 15:53:57 +0000 |
115 | +++ src/core/media/engine.cpp 2014-08-29 21:46:11 +0000 |
116 | @@ -1,5 +1,5 @@ |
117 | /* |
118 | - * Copyright © 2013 Canonical Ltd. |
119 | + * Copyright © 2013-2014 Canonical Ltd. |
120 | * |
121 | * This program is free software: you can redistribute it and/or modify it |
122 | * under the terms of the GNU Lesser General Public License version 3, |
123 | @@ -14,6 +14,7 @@ |
124 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
125 | * |
126 | * Authored by: Thomas Voß <thomas.voss@canonical.com> |
127 | + * Jim Hodapp <jim.hodapp@canonical.com> |
128 | */ |
129 | |
130 | #include "engine.h" |
131 | |
132 | === modified file 'src/core/media/engine.h' |
133 | --- src/core/media/engine.h 2014-08-12 22:33:18 +0000 |
134 | +++ src/core/media/engine.h 2014-08-29 21:46:11 +0000 |
135 | @@ -1,5 +1,5 @@ |
136 | /* |
137 | - * Copyright © 2013 Canonical Ltd. |
138 | + * Copyright © 2013-2014 Canonical Ltd. |
139 | * |
140 | * This program is free software: you can redistribute it and/or modify it |
141 | * under the terms of the GNU Lesser General Public License version 3, |
142 | @@ -14,6 +14,7 @@ |
143 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
144 | * |
145 | * Authored by: Thomas Voß <thomas.voss@canonical.com> |
146 | + * Jim Hodapp <jim.hodapp@canonical.com> |
147 | */ |
148 | #ifndef CORE_UBUNTU_MEDIA_ENGINE_H_ |
149 | #define CORE_UBUNTU_MEDIA_ENGINE_H_ |
150 | @@ -114,6 +115,9 @@ |
151 | virtual const core::Property<Volume>& volume() const = 0; |
152 | virtual core::Property<Volume>& volume() = 0; |
153 | |
154 | + virtual const core::Property<core::ubuntu::media::Player::AudioStreamRole>& audio_stream_role() const = 0; |
155 | + virtual core::Property<core::ubuntu::media::Player::AudioStreamRole>& audio_stream_role() = 0; |
156 | + |
157 | virtual const core::Property<std::tuple<Track::UriType, Track::MetaData>>& track_meta_data() const = 0; |
158 | |
159 | virtual const core::Signal<void>& about_to_finish_signal() const = 0; |
160 | |
161 | === modified file 'src/core/media/gstreamer/engine.cpp' |
162 | --- src/core/media/gstreamer/engine.cpp 2014-08-12 22:33:18 +0000 |
163 | +++ src/core/media/gstreamer/engine.cpp 2014-08-29 21:46:11 +0000 |
164 | @@ -14,6 +14,7 @@ |
165 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
166 | * |
167 | * Authored by: Thomas Voß <thomas.voss@canonical.com> |
168 | + * Jim Hodapp <jim.hodapp@canonical.com> |
169 | */ |
170 | |
171 | #include <stdio.h> |
172 | @@ -164,6 +165,11 @@ |
173 | playbin.set_volume(new_volume.value); |
174 | } |
175 | |
176 | + void on_audio_stream_role_changed(const media::Player::AudioStreamRole& new_audio_role) |
177 | + { |
178 | + playbin.set_audio_stream_role(new_audio_role); |
179 | + } |
180 | + |
181 | void on_about_to_finish() |
182 | { |
183 | state = Engine::State::ready; |
184 | @@ -213,6 +219,12 @@ |
185 | &Private::on_volume_changed, |
186 | this, |
187 | std::placeholders::_1))), |
188 | + on_audio_stream_role_changed_connection( |
189 | + audio_role.changed().connect( |
190 | + std::bind( |
191 | + &Private::on_audio_stream_role_changed, |
192 | + this, |
193 | + std::placeholders::_1))), |
194 | on_seeked_to_connection( |
195 | playbin.signals.on_seeked_to.connect( |
196 | std::bind( |
197 | @@ -238,6 +250,7 @@ |
198 | core::Property<uint64_t> position; |
199 | core::Property<uint64_t> duration; |
200 | core::Property<media::Engine::Volume> volume; |
201 | + core::Property<media::Player::AudioStreamRole> audio_role; |
202 | core::Property<bool> is_video_source; |
203 | core::Property<bool> is_audio_source; |
204 | gstreamer::Playbin playbin; |
205 | @@ -245,6 +258,7 @@ |
206 | core::ScopedConnection on_state_changed_connection; |
207 | core::ScopedConnection on_tag_available_connection; |
208 | core::ScopedConnection on_volume_changed_connection; |
209 | + core::ScopedConnection on_audio_stream_role_changed_connection; |
210 | core::ScopedConnection on_seeked_to_connection; |
211 | core::ScopedConnection client_disconnected_connection; |
212 | core::ScopedConnection on_end_of_stream_connection; |
213 | @@ -295,11 +309,10 @@ |
214 | if (result) |
215 | { |
216 | d->state = media::Engine::State::playing; |
217 | + cout << "play" << endl; |
218 | d->playback_status_changed(media::Player::PlaybackStatus::playing); |
219 | } |
220 | |
221 | - cout << "Engine: " << this << endl; |
222 | - |
223 | return result; |
224 | } |
225 | |
226 | @@ -310,6 +323,7 @@ |
227 | if (result) |
228 | { |
229 | d->state = media::Engine::State::stopped; |
230 | + cout << "stop" << endl; |
231 | d->playback_status_changed(media::Player::PlaybackStatus::stopped); |
232 | } |
233 | |
234 | @@ -379,6 +393,16 @@ |
235 | return d->volume; |
236 | } |
237 | |
238 | +const core::Property<core::ubuntu::media::Player::AudioStreamRole>& gstreamer::Engine::audio_stream_role() const |
239 | +{ |
240 | + return d->audio_role; |
241 | +} |
242 | + |
243 | +core::Property<core::ubuntu::media::Player::AudioStreamRole>& gstreamer::Engine::audio_stream_role() |
244 | +{ |
245 | + return d->audio_role; |
246 | +} |
247 | + |
248 | const core::Property<std::tuple<media::Track::UriType, media::Track::MetaData>>& |
249 | gstreamer::Engine::track_meta_data() const |
250 | { |
251 | |
252 | === modified file 'src/core/media/gstreamer/engine.h' |
253 | --- src/core/media/gstreamer/engine.h 2014-08-12 22:33:18 +0000 |
254 | +++ src/core/media/gstreamer/engine.h 2014-08-29 21:46:11 +0000 |
255 | @@ -14,6 +14,7 @@ |
256 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
257 | * |
258 | * Authored by: Thomas Voß <thomas.voss@canonical.com> |
259 | + * Jim Hodapp <jim.hodapp@canonical.com> |
260 | */ |
261 | #ifndef CORE_UBUNTU_MEDIA_GSTREAMER_ENGINE_H_ |
262 | #define CORE_UBUNTU_MEDIA_GSTREAMER_ENGINE_H_ |
263 | @@ -49,6 +50,9 @@ |
264 | const core::Property<core::ubuntu::media::Engine::Volume>& volume() const; |
265 | core::Property<core::ubuntu::media::Engine::Volume>& volume(); |
266 | |
267 | + const core::Property<core::ubuntu::media::Player::AudioStreamRole>& audio_stream_role() const; |
268 | + core::Property<core::ubuntu::media::Player::AudioStreamRole>& audio_stream_role(); |
269 | + |
270 | const core::Property<std::tuple<core::ubuntu::media::Track::UriType, core::ubuntu::media::Track::MetaData>>& track_meta_data() const; |
271 | |
272 | const core::Signal<void>& about_to_finish_signal() const; |
273 | |
274 | === modified file 'src/core/media/gstreamer/playbin.h' |
275 | --- src/core/media/gstreamer/playbin.h 2014-08-12 22:33:18 +0000 |
276 | +++ src/core/media/gstreamer/playbin.h 2014-08-29 21:46:11 +0000 |
277 | @@ -239,7 +239,52 @@ |
278 | |
279 | void set_volume(double new_volume) |
280 | { |
281 | - g_object_set(pipeline, "volume", new_volume, NULL); |
282 | + g_object_set (pipeline, "volume", new_volume, NULL); |
283 | + } |
284 | + |
285 | + /** Translate the AudioStreamRole enum into a string */ |
286 | + static std::string get_audio_role_str(media::Player::AudioStreamRole audio_role) |
287 | + { |
288 | + switch (audio_role) |
289 | + { |
290 | + case media::Player::AudioStreamRole::alarm: |
291 | + return "alarm"; |
292 | + break; |
293 | + case media::Player::AudioStreamRole::alert: |
294 | + return "alert"; |
295 | + break; |
296 | + case media::Player::AudioStreamRole::multimedia: |
297 | + return "multimedia"; |
298 | + break; |
299 | + case media::Player::AudioStreamRole::phone: |
300 | + return "phone"; |
301 | + break; |
302 | + default: |
303 | + return "multimedia"; |
304 | + break; |
305 | + } |
306 | + } |
307 | + |
308 | + /** Sets the new audio stream role on the pulsesink in playbin */ |
309 | + void set_audio_stream_role(media::Player::AudioStreamRole new_audio_role) |
310 | + { |
311 | + GstElement *audio_sink = NULL; |
312 | + g_object_get (pipeline, "audio_sink", &audio_sink, NULL); |
313 | + |
314 | + std::string role_str("props,media.role=" + get_audio_role_str(new_audio_role)); |
315 | + std::cout << "Audio stream role: " << role_str << std::endl; |
316 | + |
317 | + GstStructure *props = gst_structure_from_string (role_str.c_str(), NULL); |
318 | + if (audio_sink != nullptr && props != nullptr) |
319 | + g_object_set (audio_sink, "stream-properties", props, NULL); |
320 | + else |
321 | + { |
322 | + std::cerr << |
323 | + "Warning: couldn't set audio stream role - couldn't get audio_sink from pipeline" << |
324 | + std::endl; |
325 | + } |
326 | + |
327 | + gst_structure_free (props); |
328 | } |
329 | |
330 | uint64_t position() const |
331 | |
332 | === modified file 'src/core/media/mpris/player.h' |
333 | --- src/core/media/mpris/player.h 2014-07-10 12:19:48 +0000 |
334 | +++ src/core/media/mpris/player.h 2014-08-29 21:46:11 +0000 |
335 | @@ -14,6 +14,7 @@ |
336 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
337 | * |
338 | * Authored by: Thomas Voß <thomas.voss@canonical.com> |
339 | + * Jim Hodapp <jim.hodapp@canonical.com> |
340 | */ |
341 | |
342 | #ifndef MPRIS_PLAYER_H_ |
343 | @@ -76,6 +77,7 @@ |
344 | WRITABLE_PROPERTY(Volume, Player, double) |
345 | READABLE_PROPERTY(Position, Player, uint64_t) |
346 | READABLE_PROPERTY(Duration, Player, uint64_t) |
347 | + WRITABLE_PROPERTY(AudioStreamRole, Player, core::ubuntu::media::Player::AudioStreamRole) |
348 | READABLE_PROPERTY(MinimumRate, Player, double) |
349 | READABLE_PROPERTY(MaximumRate, Player, double) |
350 | READABLE_PROPERTY(IsVideoSource, Player, bool) |
351 | |
352 | === modified file 'src/core/media/player_implementation.cpp' |
353 | --- src/core/media/player_implementation.cpp 2014-08-13 01:41:00 +0000 |
354 | +++ src/core/media/player_implementation.cpp 2014-08-29 21:46:11 +0000 |
355 | @@ -308,6 +308,8 @@ |
356 | loop_status().set(Player::LoopStatus::none); |
357 | position().set(0); |
358 | duration().set(0); |
359 | + audio_stream_role().set(Player::AudioStreamRole::multimedia); |
360 | + d->engine->audio_stream_role().set(Player::AudioStreamRole::multimedia); |
361 | |
362 | // Make sure that the Position property gets updated from the Engine |
363 | // every time the client requests position |
364 | @@ -337,6 +339,13 @@ |
365 | }; |
366 | is_audio_source().install(audio_type_getter); |
367 | |
368 | + // Make sure that the audio_stream_role property gets updated on the Engine side |
369 | + // whenever the client side sets the role |
370 | + audio_stream_role().changed().connect([this](media::Player::AudioStreamRole new_role) |
371 | + { |
372 | + d->engine->audio_stream_role().set(new_role); |
373 | + }); |
374 | + |
375 | d->engine->about_to_finish_signal().connect([this]() |
376 | { |
377 | if (d->track_list->has_next()) |
378 | |
379 | === modified file 'src/core/media/player_skeleton.cpp' |
380 | --- src/core/media/player_skeleton.cpp 2014-08-18 18:05:40 +0000 |
381 | +++ src/core/media/player_skeleton.cpp 2014-08-29 21:46:11 +0000 |
382 | @@ -58,6 +58,7 @@ |
383 | object->get_property<mpris::Player::Properties::Volume>(), |
384 | object->get_property<mpris::Player::Properties::Position>(), |
385 | object->get_property<mpris::Player::Properties::Duration>(), |
386 | + object->get_property<mpris::Player::Properties::AudioStreamRole>(), |
387 | object->get_property<mpris::Player::Properties::MinimumRate>(), |
388 | object->get_property<mpris::Player::Properties::MaximumRate>() |
389 | }, |
390 | @@ -272,6 +273,7 @@ |
391 | std::shared_ptr<core::dbus::Property<mpris::Player::Properties::Volume>> volume; |
392 | std::shared_ptr<core::dbus::Property<mpris::Player::Properties::Position>> position; |
393 | std::shared_ptr<core::dbus::Property<mpris::Player::Properties::Duration>> duration; |
394 | + std::shared_ptr<core::dbus::Property<mpris::Player::Properties::AudioStreamRole>> audio_role; |
395 | std::shared_ptr<core::dbus::Property<mpris::Player::Properties::MinimumRate>> minimum_playback_rate; |
396 | std::shared_ptr<core::dbus::Property<mpris::Player::Properties::MaximumRate>> maximum_playback_rate; |
397 | } properties; |
398 | @@ -450,6 +452,11 @@ |
399 | return *d->properties.duration; |
400 | } |
401 | |
402 | +const core::Property<media::Player::AudioStreamRole>& media::PlayerSkeleton::audio_stream_role() const |
403 | +{ |
404 | + return *d->properties.audio_role; |
405 | +} |
406 | + |
407 | const core::Property<media::Player::PlaybackRate>& media::PlayerSkeleton::minimum_playback_rate() const |
408 | { |
409 | return *d->properties.minimum_playback_rate; |
410 | @@ -490,6 +497,11 @@ |
411 | return *d->properties.duration; |
412 | } |
413 | |
414 | +core::Property<media::Player::AudioStreamRole>& media::PlayerSkeleton::audio_stream_role() |
415 | +{ |
416 | + return *d->properties.audio_role; |
417 | +} |
418 | + |
419 | core::Property<media::Player::PlaybackStatus>& media::PlayerSkeleton::playback_status() |
420 | { |
421 | return *d->properties.playback_status; |
422 | |
423 | === modified file 'src/core/media/player_skeleton.h' |
424 | --- src/core/media/player_skeleton.h 2014-04-25 17:53:00 +0000 |
425 | +++ src/core/media/player_skeleton.h 2014-08-29 21:46:11 +0000 |
426 | @@ -14,6 +14,7 @@ |
427 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
428 | * |
429 | * Authored by: Thomas Voß <thomas.voss@canonical.com> |
430 | + * Jim Hodapp <jim.hodapp@canonical.com> |
431 | */ |
432 | |
433 | #ifndef CORE_UBUNTU_MEDIA_PLAYER_SKELETON_H_ |
434 | @@ -60,11 +61,13 @@ |
435 | virtual const core::Property<PlaybackRate>& maximum_playback_rate() const; |
436 | virtual const core::Property<uint64_t>& position() const; |
437 | virtual const core::Property<uint64_t>& duration() const; |
438 | + virtual const core::Property<AudioStreamRole>& audio_stream_role() const; |
439 | |
440 | virtual core::Property<LoopStatus>& loop_status(); |
441 | virtual core::Property<PlaybackRate>& playback_rate(); |
442 | virtual core::Property<bool>& is_shuffle(); |
443 | virtual core::Property<Volume>& volume(); |
444 | + virtual core::Property<AudioStreamRole>& audio_stream_role(); |
445 | |
446 | virtual const core::Signal<uint64_t>& seeked_to() const; |
447 | virtual const core::Signal<void>& end_of_stream() const; |
448 | |
449 | === modified file 'src/core/media/player_stub.cpp' |
450 | --- src/core/media/player_stub.cpp 2014-04-28 21:10:03 +0000 |
451 | +++ src/core/media/player_stub.cpp 2014-08-29 21:46:11 +0000 |
452 | @@ -14,6 +14,7 @@ |
453 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
454 | * |
455 | * Authored by: Thomas Voß <thomas.voss@canonical.com> |
456 | + * Jim Hodapp <jim.hodapp@canonical.com> |
457 | */ |
458 | |
459 | #include <core/media/service.h> |
460 | @@ -74,6 +75,7 @@ |
461 | object->get_property<mpris::Player::Properties::Volume>(), |
462 | object->get_property<mpris::Player::Properties::Position>(), |
463 | object->get_property<mpris::Player::Properties::Duration>(), |
464 | + object->get_property<mpris::Player::Properties::AudioStreamRole>(), |
465 | object->get_property<mpris::Player::Properties::MinimumRate>(), |
466 | object->get_property<mpris::Player::Properties::MaximumRate>() |
467 | }, |
468 | @@ -97,7 +99,7 @@ |
469 | p->on_frame_available(); |
470 | } |
471 | else |
472 | - std::cout << "context is nullptr, can't call on_frame_available()" << std::endl; |
473 | + std::cerr << "context is nullptr, can't call on_frame_available()" << std::endl; |
474 | } |
475 | |
476 | void on_frame_available() |
477 | @@ -106,7 +108,7 @@ |
478 | frame_available_cb(frame_available_context); |
479 | } |
480 | else |
481 | - std::cout << "frame_available_cb is nullptr, can't call frame_available_cb()" << std::endl; |
482 | + std::cerr << "frame_available_cb is nullptr, can't call frame_available_cb()" << std::endl; |
483 | } |
484 | |
485 | void set_frame_available_cb(FrameAvailableCb cb, void *context) |
486 | @@ -161,6 +163,7 @@ |
487 | std::shared_ptr<core::dbus::Property<mpris::Player::Properties::Volume>> volume; |
488 | std::shared_ptr<core::dbus::Property<mpris::Player::Properties::Position>> position; |
489 | std::shared_ptr<core::dbus::Property<mpris::Player::Properties::Duration>> duration; |
490 | + std::shared_ptr<core::dbus::Property<mpris::Player::Properties::AudioStreamRole>> audio_role; |
491 | std::shared_ptr<core::dbus::Property<mpris::Player::Properties::MinimumRate>> minimum_playback_rate; |
492 | std::shared_ptr<core::dbus::Property<mpris::Player::Properties::MaximumRate>> maximum_playback_rate; |
493 | } properties; |
494 | @@ -423,6 +426,11 @@ |
495 | return *d->properties.duration; |
496 | } |
497 | |
498 | +const core::Property<media::Player::AudioStreamRole>& media::PlayerStub::audio_stream_role() const |
499 | +{ |
500 | + return *d->properties.audio_role; |
501 | +} |
502 | + |
503 | const core::Property<media::Player::PlaybackRate>& media::PlayerStub::minimum_playback_rate() const |
504 | { |
505 | return *d->properties.minimum_playback_rate; |
506 | @@ -453,6 +461,11 @@ |
507 | return *d->properties.volume; |
508 | } |
509 | |
510 | +core::Property<media::Player::AudioStreamRole>& media::PlayerStub::audio_stream_role() |
511 | +{ |
512 | + return *d->properties.audio_role; |
513 | +} |
514 | + |
515 | const core::Signal<uint64_t>& media::PlayerStub::seeked_to() const |
516 | { |
517 | return d->signals.seeked_to; |
518 | |
519 | === modified file 'src/core/media/player_stub.h' |
520 | --- src/core/media/player_stub.h 2014-04-25 17:53:00 +0000 |
521 | +++ src/core/media/player_stub.h 2014-08-29 21:46:11 +0000 |
522 | @@ -75,11 +75,13 @@ |
523 | virtual const core::Property<PlaybackRate>& maximum_playback_rate() const; |
524 | virtual const core::Property<uint64_t>& position() const; |
525 | virtual const core::Property<uint64_t>& duration() const; |
526 | + virtual const core::Property<AudioStreamRole>& audio_stream_role() const; |
527 | |
528 | virtual core::Property<LoopStatus>& loop_status(); |
529 | virtual core::Property<PlaybackRate>& playback_rate(); |
530 | virtual core::Property<bool>& is_shuffle(); |
531 | virtual core::Property<Volume>& volume(); |
532 | + virtual core::Property<AudioStreamRole>& audio_stream_role(); |
533 | |
534 | virtual const core::Signal<uint64_t>& seeked_to() const; |
535 | virtual const core::Signal<void>& end_of_stream() const; |
536 | |
537 | === modified file 'src/core/media/player_traits.h' |
538 | --- src/core/media/player_traits.h 2014-02-12 15:53:57 +0000 |
539 | +++ src/core/media/player_traits.h 2014-08-29 21:46:11 +0000 |
540 | @@ -1,5 +1,5 @@ |
541 | /* |
542 | - * Copyright © 2013 Canonical Ltd. |
543 | + * Copyright © 2013-2014 Canonical Ltd. |
544 | * |
545 | * This program is free software: you can redistribute it and/or modify it |
546 | * under the terms of the GNU Lesser General Public License version 3, |
547 | |
548 | === modified file 'src/core/media/service_implementation.cpp' |
549 | --- src/core/media/service_implementation.cpp 2014-04-23 19:00:55 +0000 |
550 | +++ src/core/media/service_implementation.cpp 2014-08-29 21:46:11 +0000 |
551 | @@ -1,5 +1,5 @@ |
552 | /* |
553 | - * Copyright © 2013 Canonical Ltd. |
554 | + * Copyright © 2013-2014 Canonical Ltd. |
555 | * |
556 | * This program is free software: you can redistribute it and/or modify it |
557 | * under the terms of the GNU Lesser General Public License version 3, |
558 | @@ -14,6 +14,7 @@ |
559 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
560 | * |
561 | * Authored by: Thomas Voß <thomas.voss@canonical.com> |
562 | + * Jim Hodapp <jim.hodapp@canonical.com> |
563 | */ |
564 | |
565 | #include "service_implementation.h" |
566 | @@ -29,6 +30,8 @@ |
567 | |
568 | struct media::ServiceImplementation::Private |
569 | { |
570 | + typedef map<media::Player::PlayerKey, std::shared_ptr<media::Player>> player_map_t; |
571 | + |
572 | Private() |
573 | : key_(0) |
574 | { |
575 | @@ -36,8 +39,6 @@ |
576 | |
577 | void track_player(const std::shared_ptr<media::Player>& player) |
578 | { |
579 | - cout << __PRETTY_FUNCTION__ << endl; |
580 | - cout << "key: " << key_ << endl; |
581 | player_map.insert( |
582 | std::pair<media::Player::PlayerKey, |
583 | std::shared_ptr<media::Player>>(key_, player)); |
584 | @@ -52,25 +53,33 @@ |
585 | |
586 | void pause_other_sessions(media::Player::PlayerKey key) |
587 | { |
588 | - cout << __PRETTY_FUNCTION__ << endl; |
589 | - cout << "key: " << key << endl; |
590 | - |
591 | - // TODO: Add a field to Player that is the type of player so that certain |
592 | - // types of playback aren't paused below. E.g. a camera click sound shouldn't |
593 | - // pause, nor should it pause background music sessions |
594 | - for (auto& player_pair : player_map) |
595 | + auto player_it = player_map.find(key); |
596 | + if (player_it != player_map.end()) |
597 | { |
598 | - if (player_pair.second->playback_status() == Player::playing |
599 | - && player_pair.first != key) |
600 | + auto ¤t_player = (*player_it).second; |
601 | + for (auto& player_pair : player_map) |
602 | { |
603 | - cout << "Pausing player with key: " << player_pair.first << endl; |
604 | - player_pair.second->pause(); |
605 | + // Only pause a Player if all of the following criteria are met: |
606 | + // 1) currently playing |
607 | + // 2) not the same player as the one passed in my key |
608 | + // 3) new Player has an audio stream role set to multimedia |
609 | + // 4) has an audio stream role set to multimedia |
610 | + if (player_pair.second->playback_status() == Player::playing |
611 | + && player_pair.first != key |
612 | + && current_player->audio_stream_role() == media::Player::multimedia |
613 | + && player_pair.second->audio_stream_role() == media::Player::multimedia) |
614 | + { |
615 | + cout << "Pausing Player with key: " << player_pair.first << endl; |
616 | + player_pair.second->pause(); |
617 | + } |
618 | } |
619 | } |
620 | + else |
621 | + cerr << "Could not find Player by key: " << key << endl; |
622 | } |
623 | |
624 | // Used for Player instance management |
625 | - std::map<media::Player::PlayerKey, std::shared_ptr<media::Player>> player_map; |
626 | + player_map_t player_map; |
627 | media::Player::PlayerKey key_; |
628 | |
629 | }; |
PASSED: Continuous integration, rev:58 jenkins. qa.ubuntu. com/job/ media-hub- ci/106/ jenkins. qa.ubuntu. com/job/ media-hub- utopic- amd64-ci/ 48 jenkins. qa.ubuntu. com/job/ media-hub- utopic- armhf-ci/ 47 jenkins. qa.ubuntu. com/job/ media-hub- utopic- armhf-ci/ 47/artifact/ work/output/ *zip*/output. zip jenkins. qa.ubuntu. com/job/ media-hub- utopic- i386-ci/ 46
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/media- hub-ci/ 106/rebuild
http://