From ee01676c0d23b8ab0426a14306a1f0d1cefdc750 Mon Sep 17 00:00:00 2001 From: Thomas Green Date: Sun, 9 Sep 2007 19:05:19 +0000 Subject: ext/neon/gstneonhttpsrc.c: With libneon 2.6, we need to set the NE_SESSFLAG_ICYPROTO flag if we want ICY streams to b... Original commit message from CVS: Patch by: Thomas Green * ext/neon/gstneonhttpsrc.c: With libneon 2.6, we need to set the NE_SESSFLAG_ICYPROTO flag if we want ICY streams to be handled too, otherwise libneon will error out with a 'can't parse reponse' error. Fixes #474696. * tests/check/elements/neonhttpsrc.c: Unit test for the above by Yours Truly. --- ChangeLog | 13 ++++++ ext/neon/gstneonhttpsrc.c | 4 ++ tests/check/elements/neonhttpsrc.c | 82 +++++++++++++++++++++++++++++++++++++- 3 files changed, 98 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 77f7aa4c..20e7af4f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2007-09-09 Tim-Philipp Müller + + Patch by: Thomas Green + + * ext/neon/gstneonhttpsrc.c: + With libneon 2.6, we need to set the NE_SESSFLAG_ICYPROTO + flag if we want ICY streams to be handled too, otherwise + libneon will error out with a 'can't parse reponse' error. + Fixes #474696. + + * tests/check/elements/neonhttpsrc.c: + Unit test for the above by Yours Truly. + 2007-09-09 Tim-Philipp Müller * configure.ac: diff --git a/ext/neon/gstneonhttpsrc.c b/ext/neon/gstneonhttpsrc.c index c29cd1c2..2c1c6c3a 100644 --- a/ext/neon/gstneonhttpsrc.c +++ b/ext/neon/gstneonhttpsrc.c @@ -800,6 +800,10 @@ gst_neonhttp_src_send_request_and_redirect (GstNeonhttpSrc * src, ne_session_create (src->uri.scheme, src->uri.host, src->uri.port); } +#ifdef NEON_026_OR_LATER + ne_set_session_flag (session, NE_SESSFLAG_ICYPROTO, 1); +#endif + request = ne_request_create (session, "GET", src->uri.path); if (src->user_agent) { diff --git a/tests/check/elements/neonhttpsrc.c b/tests/check/elements/neonhttpsrc.c index c5fc79bc..c5fda84b 100644 --- a/tests/check/elements/neonhttpsrc.c +++ b/tests/check/elements/neonhttpsrc.c @@ -1,5 +1,5 @@ /* GStreamer unit tests for the neonhttpsrc element - * Copyright (C) 2006 Tim-Philipp Müller + * Copyright (C) 2006-2007 Tim-Philipp Müller * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -88,6 +88,85 @@ done: GST_END_TEST; +GST_START_TEST (test_icy_stream) +{ + GstElement *pipe, *src, *sink; + GstMessage *msg; + + pipe = gst_pipeline_new (NULL); + + src = gst_element_factory_make ("neonhttpsrc", NULL); + fail_unless (src != NULL); + + sink = gst_element_factory_make ("fakesink", NULL); + fail_unless (sink != NULL); + + gst_bin_add (GST_BIN (pipe), src); + gst_bin_add (GST_BIN (pipe), sink); + fail_unless (gst_element_link (src, sink)); + + /* First try Virgin Radio Ogg stream, to see if there's connectivity and all + * (which is an attempt to work around the completely horrid error reporting + * and that we can't distinguish different types of failures here). + * Note that neonhttpsrc does the whole connect + session initiation all in + * the state change function. */ + + g_object_set (src, "location", "http://ogg2.smgradio.com/vr32.ogg", NULL); + g_object_set (src, "automatic-redirect", FALSE, NULL); + g_object_set (src, "num-buffers", 1, NULL); + gst_element_set_state (pipe, GST_STATE_PLAYING); + + msg = gst_bus_poll (GST_ELEMENT_BUS (pipe), + GST_MESSAGE_EOS | GST_MESSAGE_ERROR, -1); + if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_ERROR) { + GST_INFO ("looks like there's no net connectivity or sgmradio.com is " + "down. In any case, let's just skip this test"); + gst_message_unref (msg); + goto done; + } + gst_message_unref (msg); + msg = NULL; + gst_element_set_state (pipe, GST_STATE_NULL); + + /* Now, if the ogg stream works, the mp3 shoutcast stream should work as + * well (time will tell if that's true) */ + + /* Virgin Radio 32kbps mp3 shoutcast stream */ + g_object_set (src, "location", "http://mp3-vr-32.smgradio.com:80/", NULL); + g_object_set (src, "automatic-redirect", FALSE, NULL); + + /* g_object_set (src, "neon-http-debug", TRUE, NULL); */ + + /* EOS after the first buffer */ + g_object_set (src, "num-buffers", 1, NULL); + + gst_element_set_state (pipe, GST_STATE_PLAYING); + msg = gst_bus_poll (GST_ELEMENT_BUS (pipe), + GST_MESSAGE_EOS | GST_MESSAGE_ERROR, -1); + + if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_EOS) { + GST_DEBUG ("success, we're done here"); + gst_message_unref (msg); + goto done; + } + + { + GError *err = NULL; + + gst_message_parse_error (msg, &err, NULL); + gst_message_unref (msg); + g_error ("Error with ICY mp3 shoutcast stream: %s", err->message); + g_error_free (err); + } + +done: + + gst_element_set_state (pipe, GST_STATE_NULL); + gst_object_unref (pipe); +} + +GST_END_TEST; + static Suite * neonhttpsrc_suite (void) { @@ -96,6 +175,7 @@ neonhttpsrc_suite (void) suite_add_tcase (s, tc_chain); tcase_add_test (tc_chain, test_first_buffer_has_offset); + tcase_add_test (tc_chain, test_icy_stream); return s; } -- cgit v1.2.1