...
 
Commits (1)
......@@ -105,7 +105,8 @@ enum
PROP_COOKIES,
PROP_IRADIO_MODE,
PROP_TIMEOUT,
PROP_EXTRA_HEADERS
PROP_EXTRA_HEADERS,
PROP_SOUP_SOCKET,
};
#define DEFAULT_USER_AGENT "GStreamer souphttpsrc "
......@@ -164,6 +165,8 @@ static void gst_soup_http_src_finished_cb (SoupMessage * msg,
static void gst_soup_http_src_authenticate_cb (SoupSession * session,
SoupMessage * msg, SoupAuth * auth, gboolean retrying,
GstSoupHTTPSrc * src);
static void gst_soup_http_src_request_started_cb (SoupSession * session,
SoupMessage * msg, SoupSocket * socket, GstSoupHTTPSrc * src);
#define gst_soup_http_src_parent_class parent_class
G_DEFINE_TYPE_WITH_CODE (GstSoupHTTPSrc, gst_soup_http_src, GST_TYPE_PUSH_SRC,
......@@ -243,6 +246,11 @@ gst_soup_http_src_class_init (GstSoupHTTPSrcClass * klass)
"Enable internet radio mode (ask server to send shoutcast/icecast "
"metadata interleaved with the actual stream data)",
DEFAULT_IRADIO_MODE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class, PROP_SOUP_SOCKET,
g_param_spec_object ("soup-socket", "soup-socket",
"The SoupSocket on which the current request is operating, or NULL "
"if no request is currently happening.",
SOUP_TYPE_SOCKET, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&srctemplate));
......@@ -312,6 +320,7 @@ gst_soup_http_src_init (GstSoupHTTPSrc * src)
src->context = NULL;
src->session = NULL;
src->msg = NULL;
src->socket = NULL;
proxy = g_getenv ("http_proxy");
if (proxy && !gst_soup_http_src_set_proxy (src, proxy)) {
GST_WARNING_OBJECT (src,
......@@ -498,6 +507,9 @@ gst_soup_http_src_get_property (GObject * object, guint prop_id,
case PROP_EXTRA_HEADERS:
gst_value_set_structure (value, src->extra_headers);
break;
case PROP_SOUP_SOCKET:
g_value_set_object (value, g_atomic_pointer_get (&src->socket));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
......@@ -694,6 +706,8 @@ gst_soup_http_src_session_open (GstSoupHTTPSrc * src)
g_signal_connect (src->session, "authenticate",
G_CALLBACK (gst_soup_http_src_authenticate_cb), src);
g_signal_connect (src->session, "request-started",
G_CALLBACK (gst_soup_http_src_request_started_cb), src);
return TRUE;
}
......@@ -705,6 +719,7 @@ gst_soup_http_src_session_close (GstSoupHTTPSrc * src)
g_object_unref (src->session);
src->session = NULL;
src->msg = NULL;
g_clear_object (&src->socket);
}
}
......@@ -724,6 +739,20 @@ gst_soup_http_src_authenticate_cb (SoupSession * session, SoupMessage * msg,
}
}
static void
gst_soup_http_src_request_started_cb (SoupSession * session, SoupMessage * msg,
SoupSocket * socket, GstSoupHTTPSrc * src)
{
if (G_UNLIKELY (msg != src->msg)) {
GST_DEBUG_OBJECT (src, "got request-started, but not for current message");
return;
}
g_clear_object (&src->socket);
g_atomic_pointer_set (&src->socket, g_object_ref (socket));
g_object_notify ((GObject *) src, "soup-socket");
}
static void
gst_soup_http_src_headers_foreach (const gchar * name, const gchar * val,
gpointer src)
......@@ -953,6 +982,10 @@ gst_soup_http_src_finished_cb (SoupMessage * msg, GstSoupHTTPSrc * src)
("libsoup status code %d", msg->status_code));
}
}
g_clear_object (&src->socket);
g_object_notify ((GObject *) src, "soup-socket");
if (src->loop)
g_main_loop_quit (src->loop);
g_cond_signal (&src->request_finished_cond);
......
......@@ -92,6 +92,8 @@ struct _GstSoupHTTPSrc {
GMutex mutex;
GCond request_finished_cond;
volatile SoupSocket *socket;
};
struct _GstSoupHTTPSrcClass {
......