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

Proposed by Robert Bruce Park
Status: Merged
Approved by: Robert Bruce Park
Approved revision: 151
Merged at revision: 153
Proposed branch: lp:~robru/media-hub/get-selected-streams
Merge into: lp:media-hub/stable
Diff against target: 256 lines (+111/-13)
6 files modified
debian/changelog (+7/-6)
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)
To merge this branch: bzr merge lp:~robru/media-hub/get-selected-streams
Reviewer Review Type Date Requested Status
Ubuntu Phablet Team Pending
Review via email: mp+270210@code.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/changelog'
--- debian/changelog 2015-08-28 13:51:58 +0000
+++ debian/changelog 2015-09-04 18:47:31 +0000
@@ -1,15 +1,16 @@
1media-hub (3.1.0+15.04.20150901-0ubuntu1) UNRELEASED; urgency=medium
2
3 * Gather information about missing codecs and selected streams from gstreamer
4 so we have more information on whether we should play the video or not.
5
6 -- Alfonso Sanchez-Beato (email Canonical) <alfonso.sanchez-beato@canonical.com> Mon, 10 Aug 2015 15:04:18 +0200
7
1media-hub (3.1.0+15.04.20150828-0ubuntu1) vivid; urgency=medium8media-hub (3.1.0+15.04.20150828-0ubuntu1) vivid; urgency=medium
29
3 * New rebuild forced.10 * New rebuild forced.
411
5 -- CI Train Bot <ci-train-bot@canonical.com> Fri, 28 Aug 2015 13:51:58 +000012 -- CI Train Bot <ci-train-bot@canonical.com> Fri, 28 Aug 2015 13:51:58 +0000
613
7media-hub (3.1.0+15.04.20150819-0ubuntu1) vivid; urgency=medium
8
9 *
10
11 -- CI Train Bot <ci-train-bot@canonical.com> Wed, 19 Aug 2015 07:39:04 +0000
12
13media-hub (3.1.0+15.04.20150818-0ubuntu1) vivid; urgency=medium14media-hub (3.1.0+15.04.20150818-0ubuntu1) vivid; urgency=medium
1415
15 * Add HTTPS to the list of supported URL schemes (courtesy Justin McPherson)16 * Add HTTPS to the list of supported URL schemes (courtesy Justin McPherson)
1617
=== modified file 'debian/control'
--- debian/control 2015-03-12 11:38:32 +0000
+++ debian/control 2015-09-04 18:47:31 +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-07-02 12:30:09 +0000
+++ src/core/media/CMakeLists.txt 2015-09-04 18:47:31 +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-08-11 15:25:50 +0000
+++ src/core/media/gstreamer/engine.cpp 2015-09-04 18:47:31 +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-06-12 18:14:05 +0000
+++ src/core/media/gstreamer/playbin.cpp 2015-09-04 18:47:31 +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>
@@ -105,7 +107,11 @@
105 core::ubuntu::media::video::Width{0}},107 core::ubuntu::media::video::Width{0}},
106 player_lifetime(media::Player::Lifetime::normal),108 player_lifetime(media::Player::Lifetime::normal),
107 about_to_finish_handler_id(0),109 about_to_finish_handler_id(0),
108 source_setup_handler_id(0)110 source_setup_handler_id(0),
111 is_missing_audio_codec(false),
112 is_missing_video_codec(false),
113 audio_stream_id(-1),
114 video_stream_id(-1)
109{115{
110 if (!pipeline)116 if (!pipeline)
111 throw std::runtime_error("Could not create pipeline for playbin.");117 throw std::runtime_error("Could not create pipeline for playbin.");
@@ -170,6 +176,44 @@
170 std::cout << "Failed to reset the pipeline state. Client reconnect may not function properly." << std::endl;176 std::cout << "Failed to reset the pipeline state. Client reconnect may not function properly." << std::endl;
171 }177 }
172 file_type = MEDIA_FILE_TYPE_NONE;178 file_type = MEDIA_FILE_TYPE_NONE;
179 is_missing_audio_codec = false;
180 is_missing_video_codec = false;
181 audio_stream_id = -1;
182 video_stream_id = -1;
183}
184
185void gstreamer::Playbin::process_message_element(GstMessage *message)
186{
187 if (!gst_is_missing_plugin_message(message))
188 return;
189
190 gchar *desc = gst_missing_plugin_message_get_description(message);
191 std::cerr << "Missing plugin: " << desc << std::endl;
192 g_free(desc);
193
194 const GstStructure *msg_data = gst_message_get_structure(message);
195 if (g_strcmp0("decoder", gst_structure_get_string(msg_data, "type")) != 0)
196 return;
197
198 GstCaps *caps;
199 if (!gst_structure_get(msg_data, "detail", GST_TYPE_CAPS, &caps, NULL)) {
200 std::cerr << __PRETTY_FUNCTION__ << ": No detail" << std::endl;
201 return;
202 }
203
204 GstStructure *caps_data = gst_caps_get_structure(caps, 0);
205 if (!caps_data) {
206 std::cerr << __PRETTY_FUNCTION__ << ": No caps data" << std::endl;
207 return;
208 }
209
210 const gchar *mime = gst_structure_get_name(caps_data);
211 if (strstr(mime, "audio"))
212 is_missing_audio_codec = true;
213 else if (strstr(mime, "video"))
214 is_missing_video_codec = true;
215
216 std::cerr << "Missing decoder for " << mime << std::endl;
173}217}
174218
175void gstreamer::Playbin::on_new_message_async(const Bus::Message& message)219void gstreamer::Playbin::on_new_message_async(const Bus::Message& message)
@@ -186,8 +230,15 @@
186 signals.on_info(message.detail.error_warning_info);230 signals.on_info(message.detail.error_warning_info);
187 break;231 break;
188 case GST_MESSAGE_STATE_CHANGED:232 case GST_MESSAGE_STATE_CHANGED:
233 if (message.source == "playbin") {
234 g_object_get(G_OBJECT(pipeline), "current-audio", &audio_stream_id, NULL);
235 g_object_get(G_OBJECT(pipeline), "current-video", &video_stream_id, NULL);
236 }
189 signals.on_state_changed(std::make_pair(message.detail.state_changed, message.source));237 signals.on_state_changed(std::make_pair(message.detail.state_changed, message.source));
190 break;238 break;
239 case GST_MESSAGE_ELEMENT:
240 process_message_element(message.message);
241 break;
191 case GST_MESSAGE_TAG:242 case GST_MESSAGE_TAG:
192 {243 {
193 gchar *orientation;244 gchar *orientation;
@@ -591,3 +642,22 @@
591{642{
592 return file_type;643 return file_type;
593}644}
645
646bool gstreamer::Playbin::can_play_streams() const
647{
648 /*
649 * We do not consider that we can play the video when
650 * 1. No audio stream selected due to missing decoder
651 * 2. No video stream selected due to missing decoder
652 * 3. No stream selected at all
653 * Note that if there are several, say, audio streams, we will play the file
654 * provided that we can decode just one of them, even if there are missing
655 * audio codecs. We will also play files with only one type of stream.
656 */
657 if ((is_missing_audio_codec && audio_stream_id == -1) ||
658 (is_missing_video_codec && video_stream_id == -1) ||
659 (audio_stream_id == -1 && video_stream_id == -1))
660 return false;
661 else
662 return true;
663}
594664
=== 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-09-04 18:47:31 +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