Merge lp:~justinmcp/media-hub/oxide-support into lp:~phablet-team/media-hub/oxide-support

Proposed by Justin McPherson
Status: Merged
Approved by: Jim Hodapp
Approved revision: 45
Merged at revision: 43
Proposed branch: lp:~justinmcp/media-hub/oxide-support
Merge into: lp:~phablet-team/media-hub/oxide-support
Diff against target: 209 lines (+87/-8)
8 files modified
src/core/media/engine.h (+3/-0)
src/core/media/gstreamer/bus.h (+3/-1)
src/core/media/gstreamer/engine.cpp (+7/-0)
src/core/media/gstreamer/engine.h (+3/-0)
src/core/media/gstreamer/playbin.h (+44/-1)
src/core/media/player_implementation.cpp (+1/-5)
src/core/media/player_stub.cpp (+1/-1)
tests/unit-tests/test-gstreamer-engine.cpp (+25/-0)
To merge this branch: bzr merge lp:~justinmcp/media-hub/oxide-support
Reviewer Review Type Date Requested Status
Jim Hodapp (community) code Approve
Review via email: mp+233152@code.launchpad.net

Commit message

Support user-agent and cookies headers in http(s) source.

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

Just one fix needed.

review: Needs Fixing (code)
45. By Justin McPherson <justin@phablet-dev>

Check for a null source in callback.

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

Looks good, thanks.

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/core/media/engine.h'
--- src/core/media/engine.h 2014-04-25 17:53:00 +0000
+++ src/core/media/engine.h 2014-09-15 01:19:37 +0000
@@ -98,6 +98,9 @@
98 virtual const core::Property<State>& state() const = 0;98 virtual const core::Property<State>& state() const = 0;
9999
100 virtual bool open_resource_for_uri(const Track::UriType& uri) = 0;100 virtual bool open_resource_for_uri(const Track::UriType& uri) = 0;
101 virtual bool open_resource_for_uri(const core::ubuntu::media::Track::UriType& uri,
102 const std::string& cookies,
103 const std::string& user_agent) = 0;
101 virtual void create_video_sink(uint32_t texture_id) = 0;104 virtual void create_video_sink(uint32_t texture_id) = 0;
102105
103 virtual bool play() = 0;106 virtual bool play() = 0;
104107
=== modified file 'src/core/media/gstreamer/bus.h'
--- src/core/media/gstreamer/bus.h 2014-02-12 15:53:57 +0000
+++ src/core/media/gstreamer/bus.h 2014-09-15 01:19:37 +0000
@@ -208,7 +208,9 @@
208 break;208 break;
209 case GST_MESSAGE_ANY:209 case GST_MESSAGE_ANY:
210 break;210 break;
211 }211 default:
212 break;
213 }
212 }214 }
213215
214 GstMessage* message;216 GstMessage* message;
215217
=== modified file 'src/core/media/gstreamer/engine.cpp'
--- src/core/media/gstreamer/engine.cpp 2014-04-25 17:53:00 +0000
+++ src/core/media/gstreamer/engine.cpp 2014-09-15 01:19:37 +0000
@@ -271,6 +271,13 @@
271 return true;271 return true;
272}272}
273273
274bool gstreamer::Engine::open_resource_for_uri(const media::Track::UriType& uri, const std::string& cookies,
275 const std::string& user_agent)
276{
277 d->playbin.set_uri(uri, cookies, user_agent);
278 return true;
279}
280
274void gstreamer::Engine::create_video_sink(uint32_t texture_id)281void gstreamer::Engine::create_video_sink(uint32_t texture_id)
275{282{
276 d->playbin.create_video_sink(texture_id);283 d->playbin.create_video_sink(texture_id);
277284
=== modified file 'src/core/media/gstreamer/engine.h'
--- src/core/media/gstreamer/engine.h 2014-04-25 17:53:00 +0000
+++ src/core/media/gstreamer/engine.h 2014-09-15 01:19:37 +0000
@@ -33,6 +33,9 @@
33 const core::Property<State>& state() const;33 const core::Property<State>& state() const;
3434
35 bool open_resource_for_uri(const core::ubuntu::media::Track::UriType& uri);35 bool open_resource_for_uri(const core::ubuntu::media::Track::UriType& uri);
36 bool open_resource_for_uri(const core::ubuntu::media::Track::UriType& uri,
37 const std::string& cookies,
38 const std::string& user_agent);
36 void create_video_sink(uint32_t texture_id);39 void create_video_sink(uint32_t texture_id);
3740
38 bool play();41 bool play();
3942
=== modified file 'src/core/media/gstreamer/playbin.h'
--- src/core/media/gstreamer/playbin.h 2014-04-25 21:23:10 +0000
+++ src/core/media/gstreamer/playbin.h 2014-09-15 01:19:37 +0000
@@ -64,6 +64,13 @@
64 thiz->signals.about_to_finish();64 thiz->signals.about_to_finish();
65 }65 }
6666
67 static void source_setup(GstElement*,
68 GstElement *source,
69 gpointer user_data)
70 {
71 static_cast<Playbin*>(user_data)->setup_source(source);
72 }
73
67 Playbin()74 Playbin()
68 : pipeline(gst_element_factory_make("playbin", pipeline_name().c_str())),75 : pipeline(gst_element_factory_make("playbin", pipeline_name().c_str())),
69 bus{gst_element_get_bus(pipeline)},76 bus{gst_element_get_bus(pipeline)},
@@ -90,6 +97,13 @@
90 this97 this
91 );98 );
9299
100 g_signal_connect(
101 pipeline,
102 "source-setup",
103 G_CALLBACK(source_setup),
104 this
105 );
106
93 // When a client of media-hub dies, call on_client_died107 // When a client of media-hub dies, call on_client_died
94 decoding_service_set_client_death_cb(&Playbin::on_client_died_cb, static_cast<void*>(this));108 decoding_service_set_client_death_cb(&Playbin::on_client_died_cb, static_cast<void*>(this));
95 }109 }
@@ -258,13 +272,40 @@
258 return static_cast<uint64_t>(dur);272 return static_cast<uint64_t>(dur);
259 }273 }
260274
261 void set_uri(const std::string& uri)275 void set_uri(const std::string& uri,
276 const std::string& cookies = std::string(),
277 const std::string& user_agent = std::string())
262 {278 {
263 g_object_set(pipeline, "uri", uri.c_str(), NULL);279 g_object_set(pipeline, "uri", uri.c_str(), NULL);
264 if (is_video_file(uri))280 if (is_video_file(uri))
265 file_type = MEDIA_FILE_TYPE_VIDEO;281 file_type = MEDIA_FILE_TYPE_VIDEO;
266 else if (is_audio_file(uri))282 else if (is_audio_file(uri))
267 file_type = MEDIA_FILE_TYPE_AUDIO;283 file_type = MEDIA_FILE_TYPE_AUDIO;
284
285 request_cookies = cookies;
286 request_user_agent = user_agent;
287 }
288
289 void setup_source(GstElement *source)
290 {
291 if (source == NULL)
292 return;
293
294 if (!request_cookies.empty()) {
295 if (g_object_class_find_property(G_OBJECT_GET_CLASS(source),
296 "cookies") != NULL) {
297 gchar ** cookies = g_strsplit(request_cookies.c_str(), ";", 0);
298 g_object_set(source, "cookies", cookies, NULL);
299 g_strfreev(cookies);
300 }
301 }
302
303 if (!request_user_agent.empty()) {
304 if (g_object_class_find_property(G_OBJECT_GET_CLASS(source),
305 "user-agent") != NULL) {
306 g_object_set(source, "user-agent", request_user_agent.c_str(), NULL);
307 }
308 }
268 }309 }
269310
270 std::string uri() const311 std::string uri() const
@@ -400,6 +441,8 @@
400 SurfaceTextureClientHybris stc_hybris;441 SurfaceTextureClientHybris stc_hybris;
401 core::Connection on_new_message_connection;442 core::Connection on_new_message_connection;
402 bool is_seeking;443 bool is_seeking;
444 std::string request_cookies;
445 std::string request_user_agent;
403 struct446 struct
404 {447 {
405 core::Signal<void> about_to_finish;448 core::Signal<void> about_to_finish;
406449
=== modified file 'src/core/media/player_implementation.cpp'
--- src/core/media/player_implementation.cpp 2014-07-22 15:03:36 +0000
+++ src/core/media/player_implementation.cpp 2014-09-15 01:19:37 +0000
@@ -279,11 +279,7 @@
279bool media::PlayerImplementation::open_uri(const Track::UriType& uri, const std::string& cookies,279bool media::PlayerImplementation::open_uri(const Track::UriType& uri, const std::string& cookies,
280 const std::string& user_agent)280 const std::string& user_agent)
281{281{
282 // TODO: Implement this for proper Oxide media playback support282 return d->engine->open_resource_for_uri(uri, cookies, user_agent);
283 (void)uri;
284 (void)cookies;
285 (void)user_agent;
286 return true;
287}283}
288284
289void media::PlayerImplementation::create_video_sink(uint32_t texture_id)285void media::PlayerImplementation::create_video_sink(uint32_t texture_id)
290286
=== modified file 'src/core/media/player_stub.cpp'
--- src/core/media/player_stub.cpp 2014-07-22 15:03:36 +0000
+++ src/core/media/player_stub.cpp 2014-09-15 01:19:37 +0000
@@ -275,7 +275,7 @@
275 return op.value();275 return op.value();
276}276}
277277
278bool media::PlayerStub::open_uri(const Track::UriType& uri, std::string& cookies,278bool media::PlayerStub::open_uri(const Track::UriType& uri, const std::string& cookies,
279 const std::string& user_agent)279 const std::string& user_agent)
280{280{
281 auto op = d->object->invoke_method_synchronously<mpris::Player::OpenUriExtended, bool>(uri, cookies, user_agent);281 auto op = d->object->invoke_method_synchronously<mpris::Player::OpenUriExtended, bool>(uri, cookies, user_agent);
282282
=== modified file 'tests/unit-tests/test-gstreamer-engine.cpp'
--- tests/unit-tests/test-gstreamer-engine.cpp 2014-06-24 20:37:44 +0000
+++ tests/unit-tests/test-gstreamer-engine.cpp 2014-09-15 01:19:37 +0000
@@ -151,6 +151,31 @@
151 std::chrono::seconds{10}));151 std::chrono::seconds{10}));
152}152}
153153
154TEST(GStreamerEngine, setting_uri_and_audio_playback_with_http_headers_works)
155{
156 const std::string test_audio_uri{"http://stream-dc1.radioparadise.com/mp3-32"};
157
158 core::testing::WaitableStateTransition<core::ubuntu::media::Engine::State> wst(
159 core::ubuntu::media::Engine::State::ready);
160
161 gstreamer::Engine engine;
162
163 engine.state().changed().connect(
164 std::bind(
165 &core::testing::WaitableStateTransition<core::ubuntu::media::Engine::State>::trigger,
166 std::ref(wst),
167 std::placeholders::_1));
168
169 EXPECT_TRUE(engine.open_resource_for_uri(test_audio_uri, "", "MediaHub"));
170 EXPECT_TRUE(engine.play());
171 EXPECT_TRUE(wst.wait_for_state_for(
172 core::ubuntu::media::Engine::State::playing,
173 std::chrono::seconds{10}));
174 EXPECT_TRUE(wst.wait_for_state_for(
175 core::ubuntu::media::Engine::State::ready,
176 std::chrono::seconds{10}));
177}
178
154TEST(GStreamerEngine, stop_pause_play_seek_audio_only_works)179TEST(GStreamerEngine, stop_pause_play_seek_audio_only_works)
155{180{
156 const std::string test_file{"/tmp/test.ogg"};181 const std::string test_file{"/tmp/test.ogg"};

Subscribers

People subscribed via source and target branches