mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-06-05 15:08:53 +00:00
ext/neon/gstneonhttpsrc.*: Remove unlock function. start/stop will do everything needed
Original commit message from CVS: Patch by: Lutz Mueller <lutz at topfrose dot de> * ext/neon/gstneonhttpsrc.c: (gst_neonhttp_src_class_init), (gst_neonhttp_src_init), (gst_neonhttp_src_finalize), (request_dispatch), (gst_neonhttp_src_create), (gst_neonhttp_src_start), (gst_neonhttp_src_get_size), (gst_neonhttp_src_stop), (set_proxy), (set_uri), (gst_neonhttp_src_set_property), (gst_neonhttp_src_get_property), (gst_neonhttp_src_uri_set_uri), (size_header_handler): * ext/neon/gstneonhttpsrc.h: Remove unlock function. start/stop will do everything needed Removed code that was never called. Use gst_pad_alloc_buffer. Don't send EOS - parent class does that for us. Do not escape path. Fixes #346723. Additional code cleanups.
This commit is contained in:
parent
430a2ba2ad
commit
4af71bd569
3 changed files with 144 additions and 212 deletions
18
ChangeLog
18
ChangeLog
|
@ -1,3 +1,21 @@
|
||||||
|
2006-07-07 Wim Taymans <wim@fluendo.com>
|
||||||
|
|
||||||
|
Patch by: Lutz Mueller <lutz at topfrose dot de>
|
||||||
|
|
||||||
|
* ext/neon/gstneonhttpsrc.c: (gst_neonhttp_src_class_init),
|
||||||
|
(gst_neonhttp_src_init), (gst_neonhttp_src_finalize),
|
||||||
|
(request_dispatch), (gst_neonhttp_src_create),
|
||||||
|
(gst_neonhttp_src_start), (gst_neonhttp_src_get_size),
|
||||||
|
(gst_neonhttp_src_stop), (set_proxy), (set_uri),
|
||||||
|
(gst_neonhttp_src_set_property), (gst_neonhttp_src_get_property),
|
||||||
|
(gst_neonhttp_src_uri_set_uri), (size_header_handler):
|
||||||
|
* ext/neon/gstneonhttpsrc.h:
|
||||||
|
Remove unlock function. start/stop will do everything needed
|
||||||
|
Removed code that was never called.
|
||||||
|
Use gst_pad_alloc_buffer. Don't send EOS - parent class does that for us.
|
||||||
|
Do not escape path. Fixes #346723.
|
||||||
|
Additional code cleanups.
|
||||||
|
|
||||||
2006-07-03 Tim-Philipp Müller <tim at centricular dot net>
|
2006-07-03 Tim-Philipp Müller <tim at centricular dot net>
|
||||||
|
|
||||||
* gst/qtdemux/qtdemux.c: (gst_qtdemux_change_state),
|
* gst/qtdemux/qtdemux.c: (gst_qtdemux_change_state),
|
||||||
|
|
|
@ -60,10 +60,10 @@ enum
|
||||||
|
|
||||||
static void oom_callback ();
|
static void oom_callback ();
|
||||||
|
|
||||||
static gboolean set_proxy (const char *uri, ne_uri * parsed,
|
static gboolean set_proxy (GstNeonhttpSrc * src, const char *uri,
|
||||||
gboolean set_default);
|
ne_uri * parsed, gboolean set_default);
|
||||||
static gboolean set_uri (const char *uri, ne_uri * parsed, gboolean * ishttps,
|
static gboolean set_uri (GstNeonhttpSrc * src, const char *uri, ne_uri * parsed,
|
||||||
gchar ** uristr, gboolean set_default);
|
gboolean * ishttps, gchar ** uristr, gboolean set_default);
|
||||||
|
|
||||||
static void gst_neonhttp_src_finalize (GObject * gobject);
|
static void gst_neonhttp_src_finalize (GObject * gobject);
|
||||||
|
|
||||||
|
@ -71,7 +71,6 @@ static GstFlowReturn gst_neonhttp_src_create (GstPushSrc * psrc,
|
||||||
GstBuffer ** outbuf);
|
GstBuffer ** outbuf);
|
||||||
static gboolean gst_neonhttp_src_start (GstBaseSrc * bsrc);
|
static gboolean gst_neonhttp_src_start (GstBaseSrc * bsrc);
|
||||||
static gboolean gst_neonhttp_src_stop (GstBaseSrc * bsrc);
|
static gboolean gst_neonhttp_src_stop (GstBaseSrc * bsrc);
|
||||||
static gboolean gst_neonhttp_src_unlock (GstBaseSrc * bsrc);
|
|
||||||
static gboolean gst_neonhttp_src_get_size (GstBaseSrc * bsrc, guint64 * size);
|
static gboolean gst_neonhttp_src_get_size (GstBaseSrc * bsrc, guint64 * size);
|
||||||
|
|
||||||
static void gst_neonhttp_src_set_property (GObject * object, guint prop_id,
|
static void gst_neonhttp_src_set_property (GObject * object, guint prop_id,
|
||||||
|
@ -181,7 +180,6 @@ gst_neonhttp_src_class_init (GstNeonhttpSrcClass * klass)
|
||||||
|
|
||||||
gstbasesrc_class->start = gst_neonhttp_src_start;
|
gstbasesrc_class->start = gst_neonhttp_src_start;
|
||||||
gstbasesrc_class->stop = gst_neonhttp_src_stop;
|
gstbasesrc_class->stop = gst_neonhttp_src_stop;
|
||||||
gstbasesrc_class->unlock = gst_neonhttp_src_unlock;
|
|
||||||
gstbasesrc_class->get_size = gst_neonhttp_src_get_size;
|
gstbasesrc_class->get_size = gst_neonhttp_src_get_size;
|
||||||
|
|
||||||
gstpush_src_class->create = gst_neonhttp_src_create;
|
gstpush_src_class->create = gst_neonhttp_src_create;
|
||||||
|
@ -202,10 +200,8 @@ gst_neonhttp_src_init (GstNeonhttpSrc * this, GstNeonhttpSrcClass * g_class)
|
||||||
this->ishttps = FALSE;
|
this->ishttps = FALSE;
|
||||||
this->content_size = -1;
|
this->content_size = -1;
|
||||||
|
|
||||||
set_uri (NULL, &this->uri, &this->ishttps, &this->uristr, TRUE);
|
set_uri (this, NULL, &this->uri, &this->ishttps, &this->uristr, TRUE);
|
||||||
set_proxy (NULL, &this->proxy, TRUE);
|
set_proxy (this, NULL, &this->proxy, TRUE);
|
||||||
|
|
||||||
this->adapter = gst_adapter_new ();
|
|
||||||
|
|
||||||
this->user_agent = g_strdup ("neonhttpsrc");
|
this->user_agent = g_strdup ("neonhttpsrc");
|
||||||
|
|
||||||
|
@ -215,8 +211,6 @@ gst_neonhttp_src_init (GstNeonhttpSrc * this, GstNeonhttpSrcClass * g_class)
|
||||||
this->iradio_url = NULL;
|
this->iradio_url = NULL;
|
||||||
this->icy_caps = NULL;
|
this->icy_caps = NULL;
|
||||||
this->icy_metaint = 0;
|
this->icy_metaint = 0;
|
||||||
|
|
||||||
GST_OBJECT_FLAG_UNSET (this, GST_NEONHTTP_SRC_OPEN);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -227,25 +221,10 @@ gst_neonhttp_src_finalize (GObject * gobject)
|
||||||
ne_uri_free (&this->uri);
|
ne_uri_free (&this->uri);
|
||||||
ne_uri_free (&this->proxy);
|
ne_uri_free (&this->proxy);
|
||||||
|
|
||||||
if (this->user_agent) {
|
g_free (this->user_agent);
|
||||||
g_free (this->user_agent);
|
g_free (this->iradio_name);
|
||||||
this->user_agent = NULL;
|
g_free (this->iradio_genre);
|
||||||
}
|
g_free (this->iradio_url);
|
||||||
|
|
||||||
if (this->iradio_name) {
|
|
||||||
g_free (this->iradio_name);
|
|
||||||
this->iradio_name = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this->iradio_genre) {
|
|
||||||
g_free (this->iradio_genre);
|
|
||||||
this->iradio_genre = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this->iradio_url) {
|
|
||||||
g_free (this->iradio_url);
|
|
||||||
this->iradio_url = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this->icy_caps) {
|
if (this->icy_caps) {
|
||||||
gst_caps_unref (this->icy_caps);
|
gst_caps_unref (this->icy_caps);
|
||||||
|
@ -263,21 +242,15 @@ gst_neonhttp_src_finalize (GObject * gobject)
|
||||||
this->session = NULL;
|
this->session = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this->adapter) {
|
|
||||||
g_object_unref (this->adapter);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this->uristr) {
|
if (this->uristr) {
|
||||||
ne_free (this->uristr);
|
ne_free (this->uristr);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (G_OBJECT_CLASS (parent_class)->finalize)
|
G_OBJECT_CLASS (parent_class)->finalize (gobject);
|
||||||
G_OBJECT_CLASS (parent_class)->finalize (gobject);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
request_dispatch (GstNeonhttpSrc * src, GstBuffer * outbuf, gboolean * eos)
|
request_dispatch (GstNeonhttpSrc * src, GstBuffer * outbuf)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
int read = 0;
|
int read = 0;
|
||||||
|
@ -289,16 +262,6 @@ request_dispatch (GstNeonhttpSrc * src, GstBuffer * outbuf, gboolean * eos)
|
||||||
ssize_t len = 0;
|
ssize_t len = 0;
|
||||||
|
|
||||||
while (sizetoread > 0) {
|
while (sizetoread > 0) {
|
||||||
|
|
||||||
if (!GST_OBJECT_FLAG_IS_SET (src, GST_NEONHTTP_SRC_OPEN)) {
|
|
||||||
GST_BUFFER_SIZE (outbuf) = read;
|
|
||||||
ret = ne_end_request (src->request);
|
|
||||||
if (ret != NE_OK) {
|
|
||||||
GST_ERROR ("Request failed. code:%d, desc: %s\n", ret,
|
|
||||||
ne_get_error (src->session));
|
|
||||||
}
|
|
||||||
return read;
|
|
||||||
}
|
|
||||||
len = ne_read_response_block (src->request,
|
len = ne_read_response_block (src->request,
|
||||||
(char *) GST_BUFFER_DATA (outbuf) + read, sizetoread);
|
(char *) GST_BUFFER_DATA (outbuf) + read, sizetoread);
|
||||||
if (len > 0) {
|
if (len > 0) {
|
||||||
|
@ -319,20 +282,16 @@ request_dispatch (GstNeonhttpSrc * src, GstBuffer * outbuf, gboolean * eos)
|
||||||
ret = ne_end_request (src->request);
|
ret = ne_end_request (src->request);
|
||||||
if (ret != NE_RETRY) {
|
if (ret != NE_RETRY) {
|
||||||
if (ret == NE_OK) {
|
if (ret == NE_OK) {
|
||||||
*eos = TRUE;
|
src->eos = TRUE;
|
||||||
} else {
|
} else {
|
||||||
read = -3;
|
read = -3;
|
||||||
GST_ERROR ("Request failed. code:%d, desc: %s\n", ret,
|
|
||||||
ne_get_error (src->session));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
done:
|
done:
|
||||||
|
|
||||||
return read;
|
return read;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -340,53 +299,44 @@ static GstFlowReturn
|
||||||
gst_neonhttp_src_create (GstPushSrc * psrc, GstBuffer ** outbuf)
|
gst_neonhttp_src_create (GstPushSrc * psrc, GstBuffer ** outbuf)
|
||||||
{
|
{
|
||||||
GstNeonhttpSrc *src;
|
GstNeonhttpSrc *src;
|
||||||
GstFlowReturn ret = GST_FLOW_OK;
|
GstFlowReturn ret;
|
||||||
int read;
|
int read;
|
||||||
gboolean eos = FALSE;
|
|
||||||
|
|
||||||
src = GST_NEONHTTP_SRC (psrc);
|
src = GST_NEONHTTP_SRC (psrc);
|
||||||
|
|
||||||
if (!GST_OBJECT_FLAG_IS_SET (src, GST_NEONHTTP_SRC_OPEN))
|
/* The caller should know the number of bytes and not read beyond EOS. */
|
||||||
goto wrong_state;
|
if (G_UNLIKELY (src->eos))
|
||||||
|
goto eos;
|
||||||
|
|
||||||
*outbuf = gst_buffer_new_and_alloc (GST_BASE_SRC (psrc)->blocksize);
|
/* Create the buffer. */
|
||||||
|
ret = gst_pad_alloc_buffer (GST_BASE_SRC_PAD (GST_BASE_SRC (psrc)),
|
||||||
|
GST_BUFFER_OFFSET_NONE, GST_BASE_SRC (psrc)->blocksize,
|
||||||
|
src->icy_caps ? src->icy_caps :
|
||||||
|
GST_PAD_CAPS (GST_BASE_SRC_PAD (GST_BASE_SRC (psrc))), outbuf);
|
||||||
|
|
||||||
read = request_dispatch (src, *outbuf, &eos);
|
if (G_UNLIKELY (ret != GST_FLOW_OK))
|
||||||
GST_LOG ("outbuffer size = %d", read);
|
goto done;
|
||||||
|
|
||||||
if (read > 0) {
|
read = request_dispatch (src, *outbuf);
|
||||||
|
if (G_UNLIKELY (read < 0))
|
||||||
if (*outbuf) {
|
goto read_error;
|
||||||
if (src->icy_caps) {
|
|
||||||
gst_buffer_set_caps (*outbuf, src->icy_caps);
|
|
||||||
} else {
|
|
||||||
gst_buffer_set_caps (*outbuf, GST_PAD_CAPS (GST_BASE_SRC_PAD (src)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} else if (read < 0) {
|
|
||||||
ret = GST_FLOW_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (eos) {
|
|
||||||
GstPad *peer;
|
|
||||||
|
|
||||||
GST_DEBUG ("Returning EOS");
|
|
||||||
peer = gst_pad_get_peer (GST_BASE_SRC_PAD (src));
|
|
||||||
if (!gst_pad_send_event (peer, gst_event_new_eos ())) {
|
|
||||||
ret = GST_FLOW_ERROR;
|
|
||||||
}
|
|
||||||
gst_object_unref (peer);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
done:
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
wrong_state:
|
/* ERRORS */
|
||||||
|
eos:
|
||||||
{
|
{
|
||||||
GST_DEBUG ("connection to closed, cannot read data");
|
GST_DEBUG_OBJECT (src, "EOS reached");
|
||||||
return GST_FLOW_WRONG_STATE;
|
return GST_FLOW_UNEXPECTED;
|
||||||
|
}
|
||||||
|
read_error:
|
||||||
|
{
|
||||||
|
GST_ELEMENT_ERROR (src, RESOURCE, READ,
|
||||||
|
(NULL), ("Could not read any bytes (%i, %s)", read,
|
||||||
|
ne_get_error (src->session)));
|
||||||
|
return GST_FLOW_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The following two charset mangling functions were copied from gnomevfssrc.
|
/* The following two charset mangling functions were copied from gnomevfssrc.
|
||||||
|
@ -429,16 +379,14 @@ gst_neonhttp_src_unicodify (const char *str)
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_neonhttp_src_start (GstBaseSrc * bsrc)
|
gst_neonhttp_src_start (GstBaseSrc * bsrc)
|
||||||
{
|
{
|
||||||
gboolean ret = TRUE;
|
|
||||||
GstNeonhttpSrc *src = GST_NEONHTTP_SRC (bsrc);
|
GstNeonhttpSrc *src = GST_NEONHTTP_SRC (bsrc);
|
||||||
const char *content_length;
|
const char *content_length;
|
||||||
|
gint res;
|
||||||
|
|
||||||
ne_oom_callback (oom_callback);
|
ne_oom_callback (oom_callback);
|
||||||
|
|
||||||
if (0 != ne_sock_init ()) {
|
if ((res = ne_sock_init ()) != 0)
|
||||||
ret = FALSE;
|
goto init_failed;
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
|
|
||||||
src->session =
|
src->session =
|
||||||
ne_session_create (src->uri.scheme, src->uri.host, src->uri.port);
|
ne_session_create (src->uri.scheme, src->uri.host, src->uri.port);
|
||||||
|
@ -447,8 +395,7 @@ gst_neonhttp_src_start (GstBaseSrc * bsrc)
|
||||||
ne_session_proxy (src->session, src->proxy.host, src->proxy.port);
|
ne_session_proxy (src->session, src->proxy.host, src->proxy.port);
|
||||||
} else if (src->proxy.host || src->proxy.port) {
|
} else if (src->proxy.host || src->proxy.port) {
|
||||||
/* both proxy host and port must be specified or none */
|
/* both proxy host and port must be specified or none */
|
||||||
ret = FALSE;
|
goto wrong_proxy;
|
||||||
goto done;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
src->request = ne_request_create (src->session, "GET", src->uri.path);
|
src->request = ne_request_create (src->session, "GET", src->uri.path);
|
||||||
|
@ -461,18 +408,15 @@ gst_neonhttp_src_start (GstBaseSrc * bsrc)
|
||||||
ne_add_request_header (src->request, "icy-metadata", "1");
|
ne_add_request_header (src->request, "icy-metadata", "1");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NE_OK != ne_begin_request (src->request)) {
|
if ((res = ne_begin_request (src->request)) != NE_OK)
|
||||||
ret = FALSE;
|
goto begin_req_failed;
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
|
|
||||||
content_length = ne_get_response_header (src->request, "Content-Length");
|
content_length = ne_get_response_header (src->request, "Content-Length");
|
||||||
|
|
||||||
if (content_length) {
|
if (content_length)
|
||||||
src->content_size = g_ascii_strtoull (content_length, NULL, 10);
|
src->content_size = g_ascii_strtoull (content_length, NULL, 10);
|
||||||
} else {
|
else
|
||||||
src->content_size = -1;
|
src->content_size = -1;
|
||||||
}
|
|
||||||
|
|
||||||
if (src->iradio_mode) {
|
if (src->iradio_mode) {
|
||||||
/* Icecast stuff */
|
/* Icecast stuff */
|
||||||
|
@ -517,13 +461,27 @@ gst_neonhttp_src_start (GstBaseSrc * bsrc)
|
||||||
src->iradio_url = gst_neonhttp_src_unicodify (str_value);
|
src->iradio_url = gst_neonhttp_src_unicodify (str_value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
GST_OBJECT_FLAG_SET (src, GST_NEONHTTP_SRC_OPEN);
|
/* ERRORS */
|
||||||
|
init_failed:
|
||||||
done:
|
{
|
||||||
|
GST_ELEMENT_ERROR (src, LIBRARY, INIT,
|
||||||
return ret;
|
(NULL), ("Could not initialize neon library (%i)", res));
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
wrong_proxy:
|
||||||
|
{
|
||||||
|
GST_ELEMENT_ERROR (src, LIBRARY, INIT,
|
||||||
|
(NULL), ("Both proxy host and port must be specified or none"));
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
begin_req_failed:
|
||||||
|
{
|
||||||
|
GST_ELEMENT_ERROR (src, LIBRARY, INIT,
|
||||||
|
(NULL), ("Could not begin request (%i)", res));
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
@ -533,31 +491,15 @@ gst_neonhttp_src_get_size (GstBaseSrc * bsrc, guint64 * size)
|
||||||
|
|
||||||
src = GST_NEONHTTP_SRC (bsrc);
|
src = GST_NEONHTTP_SRC (bsrc);
|
||||||
|
|
||||||
if (src->content_size != -1) {
|
if (src->content_size != -1)
|
||||||
*size = src->content_size;
|
return FALSE;
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return FALSE;
|
*size = src->content_size;
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
gst_neonhttp_src_unlock (GstBaseSrc * bsrc)
|
|
||||||
{
|
|
||||||
GstNeonhttpSrc *src;
|
|
||||||
|
|
||||||
src = GST_NEONHTTP_SRC (bsrc);
|
|
||||||
|
|
||||||
GST_OBJECT_FLAG_UNSET (src, GST_NEONHTTP_SRC_OPEN);
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* close the socket and associated resources
|
/* close the socket and associated resources
|
||||||
* unset OPEN flag
|
|
||||||
* used both to recover from errors and go to NULL state */
|
* used both to recover from errors and go to NULL state */
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_neonhttp_src_stop (GstBaseSrc * bsrc)
|
gst_neonhttp_src_stop (GstBaseSrc * bsrc)
|
||||||
|
@ -597,11 +539,14 @@ gst_neonhttp_src_stop (GstBaseSrc * bsrc)
|
||||||
src->session = NULL;
|
src->session = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
src->eos = FALSE;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
static gboolean
|
||||||
set_proxy (const char *uri, ne_uri * parsed, gboolean set_default)
|
set_proxy (GstNeonhttpSrc * src, const char *uri, ne_uri * parsed,
|
||||||
|
gboolean set_default)
|
||||||
{
|
{
|
||||||
ne_uri_free (parsed);
|
ne_uri_free (parsed);
|
||||||
|
|
||||||
|
@ -609,48 +554,48 @@ set_proxy (const char *uri, ne_uri * parsed, gboolean set_default)
|
||||||
const char *str = g_getenv ("http_proxy");
|
const char *str = g_getenv ("http_proxy");
|
||||||
|
|
||||||
if (str) {
|
if (str) {
|
||||||
if (0 != ne_uri_parse (str, parsed)) {
|
if (ne_uri_parse (str, parsed) != 0)
|
||||||
GST_WARNING ("The proxy set on http_proxy env var isn't well formated");
|
goto cannot_parse;
|
||||||
ne_uri_free (parsed);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0 != ne_uri_parse (uri, parsed)) {
|
if (ne_uri_parse (uri, parsed) != 0)
|
||||||
goto clear;
|
goto error;
|
||||||
}
|
|
||||||
|
|
||||||
|
if (parsed->scheme)
|
||||||
if (parsed->scheme) {
|
|
||||||
GST_WARNING ("The proxy schema shouldn't be defined");
|
GST_WARNING ("The proxy schema shouldn't be defined");
|
||||||
}
|
|
||||||
|
|
||||||
|
if (parsed->host && !parsed->port)
|
||||||
|
goto error;
|
||||||
|
|
||||||
if (parsed->host && !parsed->port) {
|
|
||||||
goto clear;
|
|
||||||
}
|
|
||||||
#ifdef NEON_026_OR_LATER
|
#ifdef NEON_026_OR_LATER
|
||||||
if (!parsed->path || parsed->userinfo)
|
if (!parsed->path || parsed->userinfo)
|
||||||
goto clear;
|
goto error;
|
||||||
#else
|
#else
|
||||||
if (!parsed->path || parsed->authinfo)
|
if (!parsed->path || parsed->authinfo)
|
||||||
goto clear;
|
goto error;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
clear:
|
/* ERRORS */
|
||||||
|
error:
|
||||||
ne_uri_free (parsed);
|
{
|
||||||
|
ne_uri_free (parsed);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
}
|
||||||
|
cannot_parse:
|
||||||
|
{
|
||||||
|
GST_WARNING_OBJECT (src,
|
||||||
|
"The proxy set on http_proxy env var isn't well formated");
|
||||||
|
ne_uri_free (parsed);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
static gboolean
|
||||||
set_uri (const char *uri, ne_uri * parsed, gboolean * ishttps, gchar ** uristr,
|
set_uri (GstNeonhttpSrc * src, const char *uri, ne_uri * parsed,
|
||||||
gboolean set_default)
|
gboolean * ishttps, gchar ** uristr, gboolean set_default)
|
||||||
{
|
{
|
||||||
|
|
||||||
ne_uri_free (parsed);
|
ne_uri_free (parsed);
|
||||||
|
@ -668,23 +613,21 @@ set_uri (const char *uri, ne_uri * parsed, gboolean * ishttps, gchar ** uristr,
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0 != ne_uri_parse (uri, parsed)) {
|
if (ne_uri_parse (uri, parsed) != 0)
|
||||||
goto clear;
|
goto parse_error;
|
||||||
}
|
|
||||||
|
|
||||||
if (parsed->scheme == NULL) {
|
if (parsed->scheme == NULL) {
|
||||||
parsed->scheme = g_strdup ("http");
|
parsed->scheme = g_strdup ("http");
|
||||||
*ishttps = FALSE;
|
*ishttps = FALSE;
|
||||||
} else {
|
} else {
|
||||||
if (0 == strcmp (parsed->scheme, "https"))
|
if (strcmp (parsed->scheme, "https") == 0)
|
||||||
*ishttps = TRUE;
|
*ishttps = TRUE;
|
||||||
else
|
else
|
||||||
*ishttps = FALSE;
|
*ishttps = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parsed->host == NULL) {
|
if (parsed->host == NULL)
|
||||||
parsed->host = g_strdup (HTTP_DEFAULT_HOST);
|
parsed->host = g_strdup (HTTP_DEFAULT_HOST);
|
||||||
}
|
|
||||||
|
|
||||||
if (parsed->port == 0) {
|
if (parsed->port == 0) {
|
||||||
if (*ishttps)
|
if (*ishttps)
|
||||||
|
@ -693,33 +636,25 @@ set_uri (const char *uri, ne_uri * parsed, gboolean * ishttps, gchar ** uristr,
|
||||||
parsed->port = HTTP_DEFAULT_PORT;
|
parsed->port = HTTP_DEFAULT_PORT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!parsed->path) {
|
if (!parsed->path)
|
||||||
parsed->path = g_strdup ("");
|
parsed->path = g_strdup ("");
|
||||||
} else {
|
|
||||||
char *str = parsed->path;
|
|
||||||
|
|
||||||
parsed->path = ne_path_escape (parsed->path);
|
|
||||||
ne_free (str);
|
|
||||||
}
|
|
||||||
|
|
||||||
done:
|
done:
|
||||||
|
if (uristr)
|
||||||
if (uristr) {
|
|
||||||
*uristr = ne_uri_unparse (parsed);
|
*uristr = ne_uri_unparse (parsed);
|
||||||
}
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
clear:
|
/* ERRORS */
|
||||||
|
parse_error:
|
||||||
if (uristr && *uristr) {
|
{
|
||||||
ne_free (*uristr);
|
if (uristr && *uristr) {
|
||||||
*uristr = NULL;
|
ne_free (*uristr);
|
||||||
|
*uristr = NULL;
|
||||||
|
}
|
||||||
|
ne_uri_free (parsed);
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
ne_uri_free (parsed);
|
|
||||||
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -731,19 +666,16 @@ gst_neonhttp_src_set_property (GObject * object, guint prop_id,
|
||||||
switch (prop_id) {
|
switch (prop_id) {
|
||||||
case PROP_PROXY:
|
case PROP_PROXY:
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!g_value_get_string (value)) {
|
if (!g_value_get_string (value)) {
|
||||||
GST_WARNING ("proxy property cannot be NULL");
|
GST_WARNING ("proxy property cannot be NULL");
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
if (!set_proxy (this, g_value_get_string (value), &this->proxy, FALSE)) {
|
||||||
if (!set_proxy (g_value_get_string (value), &this->proxy, FALSE)) {
|
GST_WARNING ("badly formated proxy");
|
||||||
GST_WARNING ("bad formated proxy");
|
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case PROP_URI:
|
case PROP_URI:
|
||||||
case PROP_LOCATION:
|
case PROP_LOCATION:
|
||||||
{
|
{
|
||||||
|
@ -751,25 +683,22 @@ gst_neonhttp_src_set_property (GObject * object, guint prop_id,
|
||||||
GST_WARNING ("location property cannot be NULL");
|
GST_WARNING ("location property cannot be NULL");
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
if (!set_uri (this, g_value_get_string (value), &this->uri,
|
||||||
if (!set_uri (g_value_get_string (value), &this->uri, &this->ishttps,
|
&this->ishttps, &this->uristr, FALSE)) {
|
||||||
&this->uristr, FALSE)) {
|
GST_WARNING ("badly formated location");
|
||||||
GST_WARNING ("bad formated location");
|
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case PROP_USER_AGENT:
|
case PROP_USER_AGENT:
|
||||||
{
|
{
|
||||||
if (this->user_agent) {
|
if (this->user_agent) {
|
||||||
g_free (this->user_agent);
|
g_free (this->user_agent);
|
||||||
this->user_agent = NULL;
|
this->user_agent = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_value_get_string (value)) {
|
if (g_value_get_string (value)) {
|
||||||
this->user_agent = g_strdup (g_value_get_string (value));
|
this->user_agent = g_strdup (g_value_get_string (value));
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case PROP_IRADIO_MODE:
|
case PROP_IRADIO_MODE:
|
||||||
|
@ -781,11 +710,8 @@ gst_neonhttp_src_set_property (GObject * object, guint prop_id,
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
done:
|
done:
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -808,9 +734,8 @@ gst_neonhttp_src_get_property (GObject * object, guint prop_id,
|
||||||
} else {
|
} else {
|
||||||
g_value_set_string (value, "");
|
g_value_set_string (value, "");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case PROP_URI:
|
case PROP_URI:
|
||||||
case PROP_LOCATION:
|
case PROP_LOCATION:
|
||||||
{
|
{
|
||||||
|
@ -825,8 +750,8 @@ gst_neonhttp_src_get_property (GObject * object, guint prop_id,
|
||||||
} else {
|
} else {
|
||||||
g_value_set_string (value, "");
|
g_value_set_string (value, "");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case PROP_USER_AGENT:
|
case PROP_USER_AGENT:
|
||||||
{
|
{
|
||||||
g_value_set_string (value, neonhttpsrc->user_agent);
|
g_value_set_string (value, neonhttpsrc->user_agent);
|
||||||
|
@ -848,7 +773,6 @@ gst_neonhttp_src_get_property (GObject * object, guint prop_id,
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* entry point to initialize the plug-in
|
/* entry point to initialize the plug-in
|
||||||
|
@ -898,7 +822,7 @@ gst_neonhttp_src_uri_set_uri (GstURIHandler * handler, const gchar * uri)
|
||||||
{
|
{
|
||||||
GstNeonhttpSrc *src = GST_NEONHTTP_SRC (handler);
|
GstNeonhttpSrc *src = GST_NEONHTTP_SRC (handler);
|
||||||
|
|
||||||
return set_uri (uri, &src->uri, &src->ishttps, &src->uristr, FALSE);
|
return set_uri (src, uri, &src->uri, &src->ishttps, &src->uristr, FALSE);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -915,7 +839,6 @@ gst_neonhttp_src_uri_handler_init (gpointer g_iface, gpointer iface_data)
|
||||||
|
|
||||||
|
|
||||||
/* NEON CALLBACK */
|
/* NEON CALLBACK */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
oom_callback ()
|
oom_callback ()
|
||||||
{
|
{
|
||||||
|
@ -928,6 +851,6 @@ size_header_handler (void *userdata, const char *value)
|
||||||
GstNeonhttpSrc *src = GST_NEONHTTP_SRC (userdata);
|
GstNeonhttpSrc *src = GST_NEONHTTP_SRC (userdata);
|
||||||
|
|
||||||
src->content_size = g_ascii_strtoull (value, NULL, 10);
|
src->content_size = g_ascii_strtoull (value, NULL, 10);
|
||||||
GST_DEBUG ("content size = %lld bytes", src->content_size);
|
|
||||||
|
|
||||||
|
GST_DEBUG_OBJECT (src, "content size = %lld bytes", src->content_size);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
|
|
||||||
#include <gst/gst.h>
|
#include <gst/gst.h>
|
||||||
#include <gst/base/gstpushsrc.h>
|
#include <gst/base/gstpushsrc.h>
|
||||||
#include <gst/base/gstadapter.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
@ -40,12 +39,6 @@ G_BEGIN_DECLS
|
||||||
typedef struct _GstNeonhttpSrc GstNeonhttpSrc;
|
typedef struct _GstNeonhttpSrc GstNeonhttpSrc;
|
||||||
typedef struct _GstNeonhttpSrcClass GstNeonhttpSrcClass;
|
typedef struct _GstNeonhttpSrcClass GstNeonhttpSrcClass;
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
GST_NEONHTTP_SRC_OPEN = (GST_ELEMENT_FLAG_LAST << 0),
|
|
||||||
|
|
||||||
GST_NEONHTTP_SRC_FLAG_LAST = (GST_ELEMENT_FLAG_LAST << 2)
|
|
||||||
} GstTCPClientSrcFlags;
|
|
||||||
|
|
||||||
struct _GstNeonhttpSrc {
|
struct _GstNeonhttpSrc {
|
||||||
GstPushSrc element;
|
GstPushSrc element;
|
||||||
|
|
||||||
|
@ -61,8 +54,6 @@ struct _GstNeonhttpSrc {
|
||||||
|
|
||||||
guint64 content_size;
|
guint64 content_size;
|
||||||
|
|
||||||
GstAdapter *adapter;
|
|
||||||
|
|
||||||
gboolean eos;
|
gboolean eos;
|
||||||
|
|
||||||
/* icecast/audiocast metadata extraction handling */
|
/* icecast/audiocast metadata extraction handling */
|
||||||
|
|
Loading…
Reference in a new issue