Merge lp:~jhodapp/media-hub/fix-1365497 into lp:media-hub

Proposed by Jim Hodapp
Status: Merged
Approved by: Ricardo Mendoza
Approved revision: 107
Merged at revision: 108
Proposed branch: lp:~jhodapp/media-hub/fix-1365497
Merge into: lp:media-hub
Diff against target: 511 lines (+213/-13)
12 files modified
include/core/media/player.h (+15/-2)
src/core/media/codec.h (+40/-0)
src/core/media/engine.h (+1/-0)
src/core/media/gstreamer/engine.cpp (+97/-0)
src/core/media/gstreamer/engine.h (+1/-0)
src/core/media/mpris/player.h (+3/-0)
src/core/media/player_implementation.cpp (+5/-0)
src/core/media/player_implementation.h (+1/-1)
src/core/media/player_skeleton.cpp (+22/-3)
src/core/media/player_skeleton.h (+3/-1)
src/core/media/player_stub.cpp (+23/-5)
src/core/media/player_stub.h (+2/-1)
To merge this branch: bzr merge lp:~jhodapp/media-hub/fix-1365497
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Needs Fixing
Ubuntu Phablet Team Pending
Review via email: mp+246937@code.launchpad.net

Commit message

Error reporting all the way up to the app level from the playbin pipeline.

Description of the change

Error reporting all the way up to the app level from the playbin pipeline.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
lp:~jhodapp/media-hub/fix-1365497 updated
106. By Jim Hodapp

Code cleanup

107. By Jim Hodapp

Merged with upstream

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'include/core/media/player.h'
2--- include/core/media/player.h 2014-10-23 14:42:59 +0000
3+++ include/core/media/player.h 2015-01-19 23:26:12 +0000
4@@ -1,5 +1,5 @@
5 /*
6- * Copyright © 2013 Canonical Ltd.
7+ * Copyright © 2013-2015 Canonical Ltd.
8 *
9 * This program is free software: you can redistribute it and/or modify it
10 * under the terms of the GNU Lesser General Public License version 3,
11@@ -98,7 +98,17 @@
12 enum Lifetime
13 {
14 normal,
15- resumable,
16+ resumable
17+ };
18+
19+ enum Error
20+ {
21+ no_error,
22+ resource_error,
23+ format_error,
24+ network_error,
25+ access_denied_error,
26+ service_missing_error
27 };
28
29 Player(const Player&) = delete;
30@@ -161,6 +171,9 @@
31 * height in the upper 32 bits and width in the lower 32 bits (both unsigned values)
32 */
33 virtual const core::Signal<uint64_t>& video_dimension_changed() const = 0;
34+ /** Signals all errors and warnings (typically from GStreamer and below) */
35+ virtual const core::Signal<Error>& error() const = 0;
36+
37 protected:
38 Player();
39
40
41=== modified file 'src/core/media/codec.h'
42--- src/core/media/codec.h 2014-10-23 14:42:59 +0000
43+++ src/core/media/codec.h 2015-01-19 23:26:12 +0000
44@@ -270,6 +270,46 @@
45 }
46 };
47
48+namespace helper
49+{
50+template<>
51+struct TypeMapper<core::ubuntu::media::Player::Error>
52+{
53+ constexpr static ArgumentType type_value()
54+ {
55+ return core::dbus::ArgumentType::int16;
56+ }
57+ constexpr static bool is_basic_type()
58+ {
59+ return false;
60+ }
61+ constexpr static bool requires_signature()
62+ {
63+ return false;
64+ }
65+
66+ static std::string signature()
67+ {
68+ static const std::string s = TypeMapper<std::int16_t>::signature();
69+ return s;
70+ }
71+};
72+}
73+
74+template<>
75+struct Codec<core::ubuntu::media::Player::Error>
76+{
77+ static void encode_argument(core::dbus::Message::Writer& out, const core::ubuntu::media::Player::Error& in)
78+ {
79+ out.push_int16(static_cast<std::int16_t>(in));
80+ }
81+
82+ static void decode_argument(core::dbus::Message::Reader& out, core::ubuntu::media::Player::Error& in)
83+ {
84+ in = static_cast<core::ubuntu::media::Player::Error>(out.pop_int16());
85+ }
86+};
87+
88 }
89 }
90
91
92=== modified file 'src/core/media/engine.h'
93--- src/core/media/engine.h 2014-11-11 23:59:07 +0000
94+++ src/core/media/engine.h 2015-01-19 23:26:12 +0000
95@@ -109,6 +109,7 @@
96 virtual const core::Signal<void>& end_of_stream_signal() const = 0;
97 virtual const core::Signal<core::ubuntu::media::Player::PlaybackStatus>& playback_status_changed_signal() const = 0;
98 virtual const core::Signal<uint32_t, uint32_t>& video_dimension_changed_signal() const = 0;
99+ virtual const core::Signal<core::ubuntu::media::Player::Error>& error_signal() const = 0;
100
101 virtual void reset() = 0;
102 };
103
104=== modified file 'src/core/media/gstreamer/engine.cpp'
105--- src/core/media/gstreamer/engine.cpp 2014-11-11 23:59:07 +0000
106+++ src/core/media/gstreamer/engine.cpp 2015-01-19 23:26:12 +0000
107@@ -55,6 +55,76 @@
108 (void) state_change;
109 }
110
111+ // Converts from a GStreamer GError to a media::Player:Error enum
112+ media::Player::Error from_gst_errorwarning(const gstreamer::Bus::Message::Detail::ErrorWarningInfo& ewi)
113+ {
114+ if (g_strcmp0(g_quark_to_string(ewi.error->domain), "gst-core-error-quark") == 0)
115+ {
116+ switch (ewi.error->code)
117+ {
118+ case GST_CORE_ERROR_NEGOTIATION:
119+ return media::Player::Error::resource_error;
120+ case GST_CORE_ERROR_MISSING_PLUGIN:
121+ return media::Player::Error::format_error;
122+ default:
123+ std::cerr << "Got an unhandled core error: '"
124+ << ewi.debug << "' (code: " << ewi.error->code << ")" << std::endl;
125+ return media::Player::Error::no_error;
126+ }
127+ }
128+ else if (g_strcmp0(g_quark_to_string(ewi.error->domain), "gst-resource-error-quark") == 0)
129+ {
130+ switch (ewi.error->code)
131+ {
132+ case GST_RESOURCE_ERROR_NOT_FOUND:
133+ case GST_RESOURCE_ERROR_OPEN_READ:
134+ case GST_RESOURCE_ERROR_OPEN_WRITE:
135+ case GST_RESOURCE_ERROR_READ:
136+ case GST_RESOURCE_ERROR_WRITE:
137+ return media::Player::Error::resource_error;
138+ case GST_RESOURCE_ERROR_NOT_AUTHORIZED:
139+ return media::Player::Error::access_denied_error;
140+ default:
141+ std::cerr << "Got an unhandled resource error: '"
142+ << ewi.debug << "' (code: " << ewi.error->code << ")" << std::endl;
143+ return media::Player::Error::no_error;
144+ }
145+ }
146+ else if (g_strcmp0(g_quark_to_string(ewi.error->domain), "gst-stream-error-quark") == 0)
147+ {
148+ switch (ewi.error->code)
149+ {
150+ case GST_STREAM_ERROR_CODEC_NOT_FOUND:
151+ return media::Player::Error::format_error;
152+ default:
153+ std::cerr << "Got an unhandled stream error: '"
154+ << ewi.debug << "' (code: " << ewi.error->code << ")" << std::endl;
155+ return media::Player::Error::no_error;
156+ }
157+ }
158+
159+ return media::Player::Error::no_error;
160+ }
161+
162+ void on_playbin_error(const gstreamer::Bus::Message::Detail::ErrorWarningInfo& ewi)
163+ {
164+ const media::Player::Error e = from_gst_errorwarning(ewi);
165+ if (e != media::Player::Error::no_error)
166+ error(e);
167+ }
168+
169+ void on_playbin_warning(const gstreamer::Bus::Message::Detail::ErrorWarningInfo& ewi)
170+ {
171+ const media::Player::Error e = from_gst_errorwarning(ewi);
172+ if (e != media::Player::Error::no_error)
173+ error(e);
174+ }
175+
176+ void on_playbin_info(const gstreamer::Bus::Message::Detail::ErrorWarningInfo& ewi)
177+ {
178+ std::cerr << "Got a playbin info message (no action taken): " << ewi.debug << std::endl;
179+ }
180+
181 void on_tag_available(const gstreamer::Bus::Message::Detail::Tag& tag)
182 {
183 media::Track::MetaData md;
184@@ -127,6 +197,24 @@
185 &Private::on_playbin_state_changed,
186 this,
187 std::placeholders::_1))),
188+ on_error_connection(
189+ playbin.signals.on_error.connect(
190+ std::bind(
191+ &Private::on_playbin_error,
192+ this,
193+ std::placeholders::_1))),
194+ on_warning_connection(
195+ playbin.signals.on_warning.connect(
196+ std::bind(
197+ &Private::on_playbin_warning,
198+ this,
199+ std::placeholders::_1))),
200+ on_info_connection(
201+ playbin.signals.on_info.connect(
202+ std::bind(
203+ &Private::on_playbin_info,
204+ this,
205+ std::placeholders::_1))),
206 on_tag_available_connection(
207 playbin.signals.on_tag_available.connect(
208 std::bind(
209@@ -201,6 +289,9 @@
210
211 core::ScopedConnection about_to_finish_connection;
212 core::ScopedConnection on_state_changed_connection;
213+ core::ScopedConnection on_error_connection;
214+ core::ScopedConnection on_warning_connection;
215+ core::ScopedConnection on_info_connection;
216 core::ScopedConnection on_tag_available_connection;
217 core::ScopedConnection on_volume_changed_connection;
218 core::ScopedConnection on_audio_stream_role_changed_connection;
219@@ -217,6 +308,7 @@
220 core::Signal<void> end_of_stream;
221 core::Signal<media::Player::PlaybackStatus> playback_status_changed;
222 core::Signal<uint32_t, uint32_t> video_dimension_changed;
223+ core::Signal<media::Player::Error> error;
224 };
225
226 gstreamer::Engine::Engine() : d(new Private{})
227@@ -413,6 +505,11 @@
228 return d->video_dimension_changed;
229 }
230
231+const core::Signal<core::ubuntu::media::Player::Error>& gstreamer::Engine::error_signal() const
232+{
233+ return d->error;
234+}
235+
236 void gstreamer::Engine::reset()
237 {
238 d->playbin.reset();
239
240=== modified file 'src/core/media/gstreamer/engine.h'
241--- src/core/media/gstreamer/engine.h 2014-11-11 23:59:07 +0000
242+++ src/core/media/gstreamer/engine.h 2015-01-19 23:26:12 +0000
243@@ -67,6 +67,7 @@
244 const core::Signal<void>& end_of_stream_signal() const;
245 const core::Signal<core::ubuntu::media::Player::PlaybackStatus>& playback_status_changed_signal() const;
246 const core::Signal<uint32_t, uint32_t>& video_dimension_changed_signal() const;
247+ const core::Signal<core::ubuntu::media::Player::Error>& error_signal() const;
248
249 void reset();
250
251
252=== modified file 'src/core/media/mpris/player.h'
253--- src/core/media/mpris/player.h 2014-10-23 14:42:59 +0000
254+++ src/core/media/mpris/player.h 2015-01-19 23:26:12 +0000
255@@ -124,6 +124,7 @@
256 DBUS_CPP_SIGNAL_DEF(EndOfStream, Player, void)
257 DBUS_CPP_SIGNAL_DEF(PlaybackStatusChanged, Player, core::ubuntu::media::Player::PlaybackStatus)
258 DBUS_CPP_SIGNAL_DEF(VideoDimensionChanged, Player, std::uint64_t)
259+ DBUS_CPP_SIGNAL_DEF(Error, Player, core::ubuntu::media::Player::Error)
260 };
261
262 struct Properties
263@@ -233,6 +234,7 @@
264 configuration.object->template get_signal<Signals::EndOfStream>(),
265 configuration.object->template get_signal<Signals::PlaybackStatusChanged>(),
266 configuration.object->template get_signal<Signals::VideoDimensionChanged>(),
267+ configuration.object->template get_signal<Signals::Error>(),
268 configuration.object->template get_signal<core::dbus::interfaces::Properties::Signals::PropertiesChanged>()
269 }
270 {
271@@ -359,6 +361,7 @@
272 typename core::dbus::Signal<Signals::EndOfStream, Signals::EndOfStream::ArgumentType>::Ptr end_of_stream;
273 typename core::dbus::Signal<Signals::PlaybackStatusChanged, Signals::PlaybackStatusChanged::ArgumentType>::Ptr playback_status_changed;
274 typename core::dbus::Signal<Signals::VideoDimensionChanged, Signals::VideoDimensionChanged::ArgumentType>::Ptr video_dimension_changed;
275+ typename core::dbus::Signal<Signals::Error, Signals::Error::ArgumentType>::Ptr error;
276
277 dbus::Signal
278 <
279
280=== modified file 'src/core/media/player_implementation.cpp'
281--- src/core/media/player_implementation.cpp 2014-11-11 23:59:07 +0000
282+++ src/core/media/player_implementation.cpp 2015-01-19 23:26:12 +0000
283@@ -422,6 +422,11 @@
284 mask = (static_cast<uint64_t>(height) << 32) | static_cast<uint64_t>(width);
285 video_dimension_changed()(mask);
286 });
287+
288+ d->engine->error_signal().connect([this](const Player::Error& e)
289+ {
290+ error()(e);
291+ });
292 }
293
294 media::PlayerImplementation::~PlayerImplementation()
295
296=== modified file 'src/core/media/player_implementation.h'
297--- src/core/media/player_implementation.h 2014-10-01 00:48:25 +0000
298+++ src/core/media/player_implementation.h 2015-01-19 23:26:12 +0000
299@@ -1,5 +1,5 @@
300 /*
301- * Copyright © 2013-2014 Canonical Ltd.
302+ * Copyright © 2013-2015 Canonical Ltd.
303 *
304 * This program is free software: you can redistribute it and/or modify it
305 * under the terms of the GNU Lesser General Public License version 3,
306
307=== modified file 'src/core/media/player_skeleton.cpp'
308--- src/core/media/player_skeleton.cpp 2014-10-23 17:29:29 +0000
309+++ src/core/media/player_skeleton.cpp 2015-01-19 23:26:12 +0000
310@@ -1,5 +1,5 @@
311 /*
312- * Copyright © 2013-2014 Canonical Ltd.
313+ * Copyright © 2013-2015 Canonical Ltd.
314 *
315 * This program is free software: you can redistribute it and/or modify it
316 * under the terms of the GNU Lesser General Public License version 3,
317@@ -58,7 +58,8 @@
318 skeleton.signals.seeked_to,
319 skeleton.signals.end_of_stream,
320 skeleton.signals.playback_status_changed,
321- skeleton.signals.video_dimension_changed
322+ skeleton.signals.video_dimension_changed,
323+ skeleton.signals.error
324 }
325 {
326 }
327@@ -294,11 +295,13 @@
328 typedef core::dbus::Signal<mpris::Player::Signals::EndOfStream, mpris::Player::Signals::EndOfStream::ArgumentType> DBusEndOfStreamSignal;
329 typedef core::dbus::Signal<mpris::Player::Signals::PlaybackStatusChanged, mpris::Player::Signals::PlaybackStatusChanged::ArgumentType> DBusPlaybackStatusChangedSignal;
330 typedef core::dbus::Signal<mpris::Player::Signals::VideoDimensionChanged, mpris::Player::Signals::VideoDimensionChanged::ArgumentType> DBusVideoDimensionChangedSignal;
331+ typedef core::dbus::Signal<mpris::Player::Signals::Error, mpris::Player::Signals::Error::ArgumentType> DBusErrorSignal;
332
333 Signals(const std::shared_ptr<DBusSeekedToSignal>& remote_seeked,
334 const std::shared_ptr<DBusEndOfStreamSignal>& remote_eos,
335 const std::shared_ptr<DBusPlaybackStatusChangedSignal>& remote_playback_status_changed,
336- const std::shared_ptr<DBusVideoDimensionChangedSignal>& remote_video_dimension_changed)
337+ const std::shared_ptr<DBusVideoDimensionChangedSignal>& remote_video_dimension_changed,
338+ const std::shared_ptr<DBusErrorSignal>& remote_error)
339 {
340 seeked_to.connect([remote_seeked](std::uint64_t value)
341 {
342@@ -319,12 +322,18 @@
343 {
344 remote_video_dimension_changed->emit(mask);
345 });
346+
347+ error.connect([remote_error](const media::Player::Error& e)
348+ {
349+ remote_error->emit(e);
350+ });
351 }
352
353 core::Signal<int64_t> seeked_to;
354 core::Signal<void> end_of_stream;
355 core::Signal<media::Player::PlaybackStatus> playback_status_changed;
356 core::Signal<uint64_t> video_dimension_changed;
357+ core::Signal<media::Player::Error> error;
358 } signals;
359
360 };
361@@ -629,3 +638,13 @@
362 {
363 return d->signals.video_dimension_changed;
364 }
365+
366+core::Signal<media::Player::Error>& media::PlayerSkeleton::error()
367+{
368+ return d->signals.error;
369+}
370+
371+const core::Signal<media::Player::Error>& media::PlayerSkeleton::error() const
372+{
373+ return d->signals.error;
374+}
375
376=== modified file 'src/core/media/player_skeleton.h'
377--- src/core/media/player_skeleton.h 2014-10-23 14:42:59 +0000
378+++ src/core/media/player_skeleton.h 2015-01-19 23:26:12 +0000
379@@ -1,5 +1,5 @@
380 /**
381- * Copyright (C) 2013-2014 Canonical Ltd
382+ * Copyright (C) 2013-2015 Canonical Ltd
383 *
384 * This program is free software: you can redistribute it and/or modify it
385 * under the terms of the GNU Lesser General Public License version 3,
386@@ -76,6 +76,7 @@
387 virtual const core::Signal<void>& end_of_stream() const;
388 virtual core::Signal<PlaybackStatus>& playback_status_changed();
389 virtual const core::Signal<uint64_t>& video_dimension_changed() const;
390+ virtual const core::Signal<Error>& error() const;
391
392 protected:
393 // All creation time arguments go here.
394@@ -112,6 +113,7 @@
395 virtual core::Signal<int64_t>& seeked_to();
396 virtual core::Signal<void>& end_of_stream();
397 virtual core::Signal<uint64_t>& video_dimension_changed();
398+ virtual core::Signal<Error>& error();
399
400 private:
401 struct Private;
402
403=== modified file 'src/core/media/player_stub.cpp'
404--- src/core/media/player_stub.cpp 2014-11-11 23:59:07 +0000
405+++ src/core/media/player_stub.cpp 2015-01-19 23:26:12 +0000
406@@ -1,5 +1,5 @@
407 /*
408- * Copyright © 2013-2014 Canonical Ltd.
409+ * Copyright © 2013-2015 Canonical Ltd.
410 *
411 * This program is free software: you can redistribute it and/or modify it
412 * under the terms of the GNU Lesser General Public License version 3,
413@@ -85,7 +85,8 @@
414 object->get_signal<mpris::Player::Signals::Seeked>(),
415 object->get_signal<mpris::Player::Signals::EndOfStream>(),
416 object->get_signal<mpris::Player::Signals::PlaybackStatusChanged>(),
417- object->get_signal<mpris::Player::Signals::VideoDimensionChanged>()
418+ object->get_signal<mpris::Player::Signals::VideoDimensionChanged>(),
419+ object->get_signal<mpris::Player::Signals::Error>()
420 }
421 {
422 auto op = object->invoke_method_synchronously<mpris::Player::Key, media::Player::PlayerKey>();
423@@ -178,23 +179,27 @@
424 typedef core::dbus::Signal<mpris::Player::Signals::EndOfStream, mpris::Player::Signals::EndOfStream::ArgumentType> DBusEndOfStreamSignal;
425 typedef core::dbus::Signal<mpris::Player::Signals::PlaybackStatusChanged, mpris::Player::Signals::PlaybackStatusChanged::ArgumentType> DBusPlaybackStatusChangedSignal;
426 typedef core::dbus::Signal<mpris::Player::Signals::VideoDimensionChanged, mpris::Player::Signals::VideoDimensionChanged::ArgumentType> DBusVideoDimensionChangedSignal;
427+ typedef core::dbus::Signal<mpris::Player::Signals::Error, mpris::Player::Signals::Error::ArgumentType> DBusErrorSignal;
428
429 Signals(const std::shared_ptr<DBusSeekedToSignal>& seeked,
430 const std::shared_ptr<DBusEndOfStreamSignal>& eos,
431 const std::shared_ptr<DBusPlaybackStatusChangedSignal>& status,
432- const std::shared_ptr<DBusVideoDimensionChangedSignal>& d)
433+ const std::shared_ptr<DBusVideoDimensionChangedSignal>& d,
434+ const std::shared_ptr<DBusErrorSignal>& e)
435 : playback_complete_cb(nullptr),
436 playback_complete_context(nullptr),
437 seeked_to(),
438 end_of_stream(),
439 playback_status_changed(),
440 video_dimension_changed(),
441+ error(),
442 dbus
443 {
444 seeked,
445 eos,
446 status,
447- d
448+ d,
449+ e
450 }
451 {
452 dbus.seeked_to->connect([this](std::uint64_t value)
453@@ -222,7 +227,13 @@
454 std::cout << "VideoDimensionChanged signal arrived via the bus." << std::endl;
455 video_dimension_changed(mask);
456 });
457- }
458+
459+ dbus.error->connect([this](const media::Player::Error& e)
460+ {
461+ std::cout << "Error signal arrived via the bus (Error: " << e << ")" << std::endl;
462+ error(e);
463+ });
464+ }
465
466 void set_playback_complete_cb(PlaybackCompleteCb cb, void *context)
467 {
468@@ -236,6 +247,7 @@
469 core::Signal<void> end_of_stream;
470 core::Signal<media::Player::PlaybackStatus> playback_status_changed;
471 core::Signal<uint64_t> video_dimension_changed;
472+ core::Signal<media::Player::Error> error;
473
474 struct DBus
475 {
476@@ -243,6 +255,7 @@
477 std::shared_ptr<DBusEndOfStreamSignal> end_of_stream;
478 std::shared_ptr<DBusPlaybackStatusChangedSignal> playback_status_changed;
479 std::shared_ptr<DBusVideoDimensionChangedSignal> video_dimension_changed;
480+ std::shared_ptr<DBusErrorSignal> error;
481 } dbus;
482 } signals;
483 };
484@@ -512,3 +525,8 @@
485 {
486 return d->signals.video_dimension_changed;
487 }
488+
489+const core::Signal<media::Player::Error>& media::PlayerStub::error() const
490+{
491+ return d->signals.error;
492+}
493
494=== modified file 'src/core/media/player_stub.h'
495--- src/core/media/player_stub.h 2014-10-23 14:42:59 +0000
496+++ src/core/media/player_stub.h 2015-01-19 23:26:12 +0000
497@@ -1,5 +1,5 @@
498 /*
499- * Copyright © 2013 Canonical Ltd.
500+ * Copyright © 2013-2015 Canonical Ltd.
501 *
502 * This program is free software: you can redistribute it and/or modify it
503 * under the terms of the GNU Lesser General Public License version 3,
504@@ -92,6 +92,7 @@
505 virtual const core::Signal<void>& end_of_stream() const;
506 virtual core::Signal<PlaybackStatus>& playback_status_changed();
507 virtual const core::Signal<uint64_t>& video_dimension_changed() const;
508+ virtual const core::Signal<Error>& error() const;
509
510 private:
511 struct Private;

Subscribers

People subscribed via source and target branches