Merge lp:~alfonsosanchezbeato/media-hub/get-selected-streams into lp:media-hub

Proposed by Alfonso Sanchez-Beato
Status: Merged
Merged at revision: 156
Proposed branch: lp:~alfonsosanchezbeato/media-hub/get-selected-streams
Merge into: lp:media-hub
Diff against target: 291 lines (+119/-11) (has conflicts)
6 files modified
debian/changelog (+15/-4)
debian/control (+1/-0)
src/core/media/CMakeLists.txt (+2/-0)
src/core/media/gstreamer/engine.cpp (+22/-5)
src/core/media/gstreamer/playbin.cpp (+72/-2)
src/core/media/gstreamer/playbin.h (+7/-0)
Text conflict in debian/changelog
To merge this branch: bzr merge lp:~alfonsosanchezbeato/media-hub/get-selected-streams
Reviewer Review Type Date Requested Status
Jim Hodapp (community) code Approve
Review via email: mp+266251@code.launchpad.net

Commit message

Gather information about missing codecs and selected streams from gstreamer
so we have more information on whether we should play the video or not (LP: #1417950).

Description of the change

Gather information about missing codecs and selected streams from gstreamer
so we have more information on whether we should play the video or not (LP: #1417950).

To post a comment you must log in.
Revision history for this message
Jim Hodapp (jhodapp) wrote :

A few suggestions below. I like the general direction of this approach. Are you planning on adding anything else to it or is this it?

review: Needs Fixing (code)
Revision history for this message
Alfonso Sanchez-Beato (alfonsosanchezbeato) wrote :

Comments addressed. @Jim, yes, for the moment this is it until we modify media-hub's DBus interface so we can transmit more information to the client like:

* Available tracks with type and description
* Information on which tracks can be played and which not due to missing codecs
* A way to select the tracks to play
* An intermediate state in which we can access to this information but we are still not playing (gstreamer state for the stream would be "paused"). Maybe we can move to that state when media is set instead of moving from the initial gstreamer state to playing when the DBus play() method is invoked.

Revision history for this message
Jim Hodapp (jhodapp) wrote :

See my comments below.

review: Needs Fixing (code)
Revision history for this message
Alfonso Sanchez-Beato (alfonsosanchezbeato) wrote :

Comments addressed

Revision history for this message
Jim Hodapp (jhodapp) wrote :

Looks great, thanks. Let me know when you have this in a silo and I'll help test this well.

review: Approve (code)
149. By Alfonso Sanchez-Beato

Gather information about missing codecs and selected streams from gstreamer
so we have more information on whether we should play the video or not.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/changelog'
--- debian/changelog 2015-07-24 14:54:21 +0000
+++ debian/changelog 2015-08-10 13:09:04 +0000
@@ -1,3 +1,4 @@
1<<<<<<< TREE
1media-hub (3.1.0+15.10.20150724-0ubuntu1) wily; urgency=medium2media-hub (3.1.0+15.10.20150724-0ubuntu1) wily; urgency=medium
23
3 [ Alfonso Sanchez-Beato (email Canonical) ]4 [ Alfonso Sanchez-Beato (email Canonical) ]
@@ -7,6 +8,16 @@
7 -- CI Train Bot <ci-train-bot@canonical.com> Fri, 24 Jul 2015 14:54:21 +00008 -- CI Train Bot <ci-train-bot@canonical.com> Fri, 24 Jul 2015 14:54:21 +0000
89
9media-hub (3.1.0+15.10.20150710-0ubuntu1) wily; urgency=medium10media-hub (3.1.0+15.10.20150710-0ubuntu1) wily; urgency=medium
11=======
12media-hub (3.1.0+15.04.20150810-0ubuntu1) UNRELEASED; urgency=medium
13
14 * Gather information about missing codecs and selected streams from gstreamer
15 so we have more information on whether we should play the video or not.
16
17 -- Alfonso Sanchez-Beato (email Canonical) <alfonso.sanchez-beato@canonical.com> Mon, 10 Aug 2015 15:04:18 +0200
18
19media-hub (3.1.0+15.04.20150710-0ubuntu1) vivid; urgency=medium
20>>>>>>> MERGE-SOURCE
1021
11 [ CI Train Bot ]22 [ CI Train Bot ]
12 * New rebuild forced.23 * New rebuild forced.
@@ -17,7 +28,7 @@
1728
18 -- CI Train Bot <ci-train-bot@canonical.com> Fri, 10 Jul 2015 18:12:21 +000029 -- CI Train Bot <ci-train-bot@canonical.com> Fri, 10 Jul 2015 18:12:21 +0000
1930
20media-hub (3.1.0+15.10.20150604-0ubuntu1) wily; urgency=medium31media-hub (3.1.0+15.04.20150604-0ubuntu1) vivid; urgency=medium
2132
22 [ CI Train Bot ]33 [ CI Train Bot ]
23 * New rebuild forced.34 * New rebuild forced.
@@ -28,7 +39,7 @@
2839
29 -- CI Train Bot <ci-train-bot@canonical.com> Thu, 04 Jun 2015 14:18:22 +000040 -- CI Train Bot <ci-train-bot@canonical.com> Thu, 04 Jun 2015 14:18:22 +0000
3041
31media-hub (3.1.0+15.10.20150601-0ubuntu1) wily; urgency=medium42media-hub (3.1.0+15.04.20150601-0ubuntu1) vivid; urgency=medium
3243
33 [ CI Train Bot ]44 [ CI Train Bot ]
34 * New rebuild forced.45 * New rebuild forced.
@@ -39,7 +50,7 @@
3950
40 -- CI Train Bot <ci-train-bot@canonical.com> Mon, 01 Jun 2015 16:31:53 +000051 -- CI Train Bot <ci-train-bot@canonical.com> Mon, 01 Jun 2015 16:31:53 +0000
4152
42media-hub (3.1.0+15.10.20150527.1-0ubuntu1) wily; urgency=medium53media-hub (3.1.0+15.04.20150527.1-0ubuntu1) vivid; urgency=medium
4354
44 [ CI Train Bot ]55 [ CI Train Bot ]
45 * New rebuild forced.56 * New rebuild forced.
@@ -50,7 +61,7 @@
5061
51 -- CI Train Bot <ci-train-bot@canonical.com> Wed, 27 May 2015 18:38:16 +000062 -- CI Train Bot <ci-train-bot@canonical.com> Wed, 27 May 2015 18:38:16 +0000
5263
53media-hub (3.1.0+15.10.20150522-0ubuntu1) wily; urgency=medium64media-hub (3.1.0+15.04.20150522-0ubuntu1) vivid; urgency=medium
5465
55 [ Jim Hodapp ]66 [ Jim Hodapp ]
56 * Fix issues with not reporting failed decoding error to the client.67 * Fix issues with not reporting failed decoding error to the client.
5768
=== modified file 'debian/control'
--- debian/control 2015-03-12 11:38:32 +0000
+++ debian/control 2015-08-10 13:09:04 +0000
@@ -25,6 +25,7 @@
25 libprocess-cpp-dev,25 libprocess-cpp-dev,
26 libproperties-cpp-dev,26 libproperties-cpp-dev,
27 libgstreamer1.0-dev,27 libgstreamer1.0-dev,
28 libgstreamer-plugins-base1.0-dev,
28 pkg-config,29 pkg-config,
29 libpulse-dev,30 libpulse-dev,
30 qtbase5-dev,31 qtbase5-dev,
3132
=== modified file 'src/core/media/CMakeLists.txt'
--- src/core/media/CMakeLists.txt 2015-02-24 15:22:19 +0000
+++ src/core/media/CMakeLists.txt 2015-08-10 13:09:04 +0000
@@ -1,4 +1,5 @@
1pkg_check_modules(PC_GSTREAMER_1_0 REQUIRED gstreamer-1.0)1pkg_check_modules(PC_GSTREAMER_1_0 REQUIRED gstreamer-1.0)
2pkg_check_modules(PC_GSTREAMER_PBUTILS_1_0 REQUIRED gstreamer-pbutils-1.0)
2pkg_check_modules(PC_PULSE_AUDIO REQUIRED libpulse)3pkg_check_modules(PC_PULSE_AUDIO REQUIRED libpulse)
3include_directories(${PC_GSTREAMER_1_0_INCLUDE_DIRS} ${HYBRIS_MEDIA_CFLAGS} ${PC_PULSE_AUDIO_INCLUDE_DIRS})4include_directories(${PC_GSTREAMER_1_0_INCLUDE_DIRS} ${HYBRIS_MEDIA_CFLAGS} ${PC_PULSE_AUDIO_INCLUDE_DIRS})
45
@@ -126,6 +127,7 @@
126 ${DBUS_CPP_LDFLAGS}127 ${DBUS_CPP_LDFLAGS}
127 ${GLog_LIBRARY}128 ${GLog_LIBRARY}
128 ${PC_GSTREAMER_1_0_LIBRARIES}129 ${PC_GSTREAMER_1_0_LIBRARIES}
130 ${PC_GSTREAMER_PBUTILS_1_0_LIBRARIES}
129 ${PROCESS_CPP_LDFLAGS}131 ${PROCESS_CPP_LDFLAGS}
130 ${GIO_LIBRARIES}132 ${GIO_LIBRARIES}
131 ${HYBRIS_MEDIA_LIBRARIES}133 ${HYBRIS_MEDIA_LIBRARIES}
132134
=== modified file 'src/core/media/gstreamer/engine.cpp'
--- src/core/media/gstreamer/engine.cpp 2015-06-01 16:30:59 +0000
+++ src/core/media/gstreamer/engine.cpp 2015-08-10 13:09:04 +0000
@@ -67,8 +67,22 @@
67 {67 {
68 if (p.second == "playbin")68 if (p.second == "playbin")
69 {69 {
70 std::cout << "State changed on playbin: " << p.first.new_state << std::endl;70 std::cout << "State changed on playbin: "
71 playback_status_changed(gst_state_to_player_status(p.first));71 << gst_element_state_get_name(p.first.new_state) << std::endl;
72 const auto status = gst_state_to_player_status(p.first);
73 /*
74 * When state moves to "paused" the pipeline is already set. We check that we
75 * have streams to play.
76 */
77 if (status == media::Player::PlaybackStatus::paused &&
78 !playbin.can_play_streams()) {
79 std::cerr << "** Cannot play: some codecs are missing" << std::endl;
80 playbin.reset();
81 const media::Player::Error e = media::Player::Error::format_error;
82 error(e);
83 } else {
84 playback_status_changed(status);
85 }
72 }86 }
73 }87 }
7488
@@ -149,7 +163,8 @@
149 break;163 break;
150 case GST_STREAM_ERROR_CODEC_NOT_FOUND:164 case GST_STREAM_ERROR_CODEC_NOT_FOUND:
151 std::cerr << "** Encountered a GST_STREAM_ERROR_CODEC_NOT_FOUND" << std::endl;165 std::cerr << "** Encountered a GST_STREAM_ERROR_CODEC_NOT_FOUND" << std::endl;
152 ret_error = media::Player::Error::format_error;166 // Missing codecs are handled later, when state switches to "paused"
167 ret_error = media::Player::Error::no_error;
153 break;168 break;
154 case GST_STREAM_ERROR_DECODE:169 case GST_STREAM_ERROR_DECODE:
155 std::cerr << "** Encountered a GST_STREAM_ERROR_DECODE" << std::endl;170 std::cerr << "** Encountered a GST_STREAM_ERROR_DECODE" << std::endl;
@@ -163,8 +178,10 @@
163 }178 }
164 }179 }
165180
166 std::cout << "Resetting playbin pipeline after unrecoverable error" << std::endl;181 if (ret_error != media::Player::Error::no_error) {
167 playbin.reset();182 std::cerr << "Resetting playbin pipeline after unrecoverable error" << std::endl;
183 playbin.reset();
184 }
168 return ret_error;185 return ret_error;
169 }186 }
170187
171188
=== modified file 'src/core/media/gstreamer/playbin.cpp'
--- src/core/media/gstreamer/playbin.cpp 2015-07-24 14:54:19 +0000
+++ src/core/media/gstreamer/playbin.cpp 2015-08-10 13:09:04 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright © 2013 Canonical Ltd.2 * Copyright © 2013-2015 Canonical Ltd.
3 *3 *
4 * This program is free software: you can redistribute it and/or modify it4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License version 3,5 * under the terms of the GNU Lesser General Public License version 3,
@@ -20,6 +20,8 @@
2020
21#include <core/media/gstreamer/engine.h>21#include <core/media/gstreamer/engine.h>
2222
23#include <gst/pbutils/missing-plugins.h>
24
23#if defined(MEDIA_HUB_HAVE_HYBRIS_MEDIA_COMPAT_LAYER)25#if defined(MEDIA_HUB_HAVE_HYBRIS_MEDIA_COMPAT_LAYER)
24#include <hybris/media/surface_texture_client_hybris.h>26#include <hybris/media/surface_texture_client_hybris.h>
25#include <hybris/media/media_codec_layer.h>27#include <hybris/media/media_codec_layer.h>
@@ -112,7 +114,11 @@
112 core::ubuntu::media::video::Width{0}},114 core::ubuntu::media::video::Width{0}},
113 player_lifetime(media::Player::Lifetime::normal),115 player_lifetime(media::Player::Lifetime::normal),
114 about_to_finish_handler_id(0),116 about_to_finish_handler_id(0),
115 source_setup_handler_id(0)117 source_setup_handler_id(0),
118 is_missing_audio_codec(false),
119 is_missing_video_codec(false),
120 audio_stream_id(-1),
121 video_stream_id(-1)
116{122{
117 if (!pipeline)123 if (!pipeline)
118 throw std::runtime_error("Could not create pipeline for playbin.");124 throw std::runtime_error("Could not create pipeline for playbin.");
@@ -177,6 +183,44 @@
177 std::cout << "Failed to reset the pipeline state. Client reconnect may not function properly." << std::endl;183 std::cout << "Failed to reset the pipeline state. Client reconnect may not function properly." << std::endl;
178 }184 }
179 file_type = MEDIA_FILE_TYPE_NONE;185 file_type = MEDIA_FILE_TYPE_NONE;
186 is_missing_audio_codec = false;
187 is_missing_video_codec = false;
188 audio_stream_id = -1;
189 video_stream_id = -1;
190}
191
192void gstreamer::Playbin::process_message_element(GstMessage *message)
193{
194 if (!gst_is_missing_plugin_message(message))
195 return;
196
197 gchar *desc = gst_missing_plugin_message_get_description(message);
198 std::cerr << "Missing plugin: " << desc << std::endl;
199 g_free(desc);
200
201 const GstStructure *msg_data = gst_message_get_structure(message);
202 if (g_strcmp0("decoder", gst_structure_get_string(msg_data, "type")) != 0)
203 return;
204
205 GstCaps *caps;
206 if (!gst_structure_get(msg_data, "detail", GST_TYPE_CAPS, &caps, NULL)) {
207 std::cerr << __PRETTY_FUNCTION__ << ": No detail" << std::endl;
208 return;
209 }
210
211 GstStructure *caps_data = gst_caps_get_structure(caps, 0);
212 if (!caps_data) {
213 std::cerr << __PRETTY_FUNCTION__ << ": No caps data" << std::endl;
214 return;
215 }
216
217 const gchar *mime = gst_structure_get_name(caps_data);
218 if (strstr(mime, "audio"))
219 is_missing_audio_codec = true;
220 else if (strstr(mime, "video"))
221 is_missing_video_codec = true;
222
223 std::cerr << "Missing decoder for " << mime << std::endl;
180}224}
181225
182void gstreamer::Playbin::on_new_message_async(const Bus::Message& message)226void gstreamer::Playbin::on_new_message_async(const Bus::Message& message)
@@ -193,8 +237,15 @@
193 signals.on_info(message.detail.error_warning_info);237 signals.on_info(message.detail.error_warning_info);
194 break;238 break;
195 case GST_MESSAGE_STATE_CHANGED:239 case GST_MESSAGE_STATE_CHANGED:
240 if (message.source == "playbin") {
241 g_object_get(G_OBJECT(pipeline), "current-audio", &audio_stream_id, NULL);
242 g_object_get(G_OBJECT(pipeline), "current-video", &video_stream_id, NULL);
243 }
196 signals.on_state_changed(std::make_pair(message.detail.state_changed, message.source));244 signals.on_state_changed(std::make_pair(message.detail.state_changed, message.source));
197 break;245 break;
246 case GST_MESSAGE_ELEMENT:
247 process_message_element(message.message);
248 break;
198 case GST_MESSAGE_TAG:249 case GST_MESSAGE_TAG:
199 {250 {
200 gchar *orientation;251 gchar *orientation;
@@ -598,3 +649,22 @@
598{649{
599 return file_type;650 return file_type;
600}651}
652
653bool gstreamer::Playbin::can_play_streams() const
654{
655 /*
656 * We do not consider that we can play the video when
657 * 1. No audio stream selected due to missing decoder
658 * 2. No video stream selected due to missing decoder
659 * 3. No stream selected at all
660 * Note that if there are several, say, audio streams, we will play the file
661 * provided that we can decode just one of them, even if there are missing
662 * audio codecs. We will also play files with only one type of stream.
663 */
664 if ((is_missing_audio_codec && audio_stream_id == -1) ||
665 (is_missing_video_codec && video_stream_id == -1) ||
666 (audio_stream_id == -1 && video_stream_id == -1))
667 return false;
668 else
669 return true;
670}
601671
=== modified file 'src/core/media/gstreamer/playbin.h'
--- src/core/media/gstreamer/playbin.h 2015-06-12 18:14:05 +0000
+++ src/core/media/gstreamer/playbin.h 2015-08-10 13:09:04 +0000
@@ -72,6 +72,7 @@
7272
73 void on_new_message(const Bus::Message& message);73 void on_new_message(const Bus::Message& message);
74 void on_new_message_async(const Bus::Message& message);74 void on_new_message_async(const Bus::Message& message);
75 void process_message_element(GstMessage *message);
7576
76 gstreamer::Bus& message_bus();77 gstreamer::Bus& message_bus();
7778
@@ -110,6 +111,8 @@
110111
111 MediaFileType media_file_type() const;112 MediaFileType media_file_type() const;
112113
114 bool can_play_streams() const;
115
113 GstElement* pipeline;116 GstElement* pipeline;
114 gstreamer::Bus bus;117 gstreamer::Bus bus;
115 MediaFileType file_type;118 MediaFileType file_type;
@@ -137,6 +140,10 @@
137 core::Signal<core::ubuntu::media::video::Dimensions> on_video_dimensions_changed;140 core::Signal<core::ubuntu::media::video::Dimensions> on_video_dimensions_changed;
138 core::Signal<void> client_disconnected;141 core::Signal<void> client_disconnected;
139 } signals;142 } signals;
143 bool is_missing_audio_codec;
144 bool is_missing_video_codec;
145 gint audio_stream_id;
146 gint video_stream_id;
140};147};
141}148}
142149

Subscribers

People subscribed via source and target branches