[totem/gnome-2-28] Set the user agent and referrer on the existing source
- From: Bastien Nocera <hadess src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [totem/gnome-2-28] Set the user agent and referrer on the existing source
- Date: Thu, 12 Nov 2009 13:46:26 +0000 (UTC)
commit 409e913d4f12755a9685d4c3201b6c66df0c6b8a
Author: Christian Persch <chpe gnome org>
Date: Thu Oct 22 13:07:28 2009 +0200
Set the user agent and referrer on the existing source
When changing the user agent or the referrer while a source already
exists, change them on the existing source.
src/backend/bacon-video-widget-gst-0.10.c | 36 ++++++++++++++++++++---------
1 files changed, 25 insertions(+), 11 deletions(-)
---
diff --git a/src/backend/bacon-video-widget-gst-0.10.c b/src/backend/bacon-video-widget-gst-0.10.c
index fd78712..117c51d 100644
--- a/src/backend/bacon-video-widget-gst-0.10.c
+++ b/src/backend/bacon-video-widget-gst-0.10.c
@@ -156,6 +156,7 @@ struct BaconVideoWidgetPrivate
BvwAspectRatio ratio_type;
GstElement *play;
+ GstElement *source;
GstXOverlay *xoverlay; /* protect with lock */
GstColorBalance *balance; /* protect with lock */
GstNavigation *navigation; /* protect with lock */
@@ -2049,13 +2050,11 @@ bvw_set_user_agent_on_element (BaconVideoWidget * bvw, GstElement * element)
{
BaconVideoWidgetPrivate *priv = bvw->priv;
- if (priv->user_agent == NULL)
+ if (g_object_class_find_property (G_OBJECT_GET_CLASS (element), "user-agent") == NULL)
return;
- if (g_object_class_find_property (G_OBJECT_GET_CLASS (element), "user-agent")) {
- GST_DEBUG ("Setting HTTP user-agent to '%s'", priv->user_agent);
- g_object_set (element, "user-agent", priv->user_agent, NULL);
- }
+ GST_DEBUG ("Setting HTTP user-agent to '%s'", priv->user_agent ? priv->user_agent : "(default)");
+ g_object_set (element, "user-agent", priv->user_agent, NULL);
}
static void
@@ -2093,6 +2092,7 @@ bvw_set_referrer_on_element (BaconVideoWidget * bvw, GstElement * element)
static void
playbin_source_notify_cb (GObject *play, GParamSpec *p, BaconVideoWidget *bvw)
{
+ BaconVideoWidgetPrivate *priv = bvw->priv;
GstElement *source = NULL;
/* CHECKME: do we really need these taglist frees here (tpm)? */
@@ -2110,6 +2110,12 @@ playbin_source_notify_cb (GObject *play, GParamSpec *p, BaconVideoWidget *bvw)
}
g_object_get (play, "source", &source, NULL);
+
+ if (priv->source != NULL) {
+ g_object_unref (priv->source);
+ }
+
+ priv->source = source;
if (source == NULL)
return;
@@ -2117,7 +2123,6 @@ playbin_source_notify_cb (GObject *play, GParamSpec *p, BaconVideoWidget *bvw)
bvw_set_device_on_element (bvw, source);
bvw_set_user_agent_on_element (bvw, source);
bvw_set_referrer_on_element (bvw, source);
- g_object_unref (source);
}
static gboolean
@@ -2311,6 +2316,11 @@ bacon_video_widget_finalize (GObject * object)
bvw->priv->vis_plugins_list = NULL;
}
+ if (bvw->priv->source != NULL) {
+ g_object_unref (bvw->priv->source);
+ bvw->priv->source = NULL;
+ }
+
if (bvw->priv->play != NULL && GST_IS_ELEMENT (bvw->priv->play)) {
gst_element_set_state (bvw->priv->play, GST_STATE_NULL);
gst_object_unref (bvw->priv->play);
@@ -3942,9 +3952,11 @@ bacon_video_widget_set_user_agent (BaconVideoWidget *bvw,
g_free (priv->user_agent);
priv->user_agent = g_strdup (user_agent);
- g_object_notify (G_OBJECT (bvw), "user-agent");
+ if (priv->source) {
+ bvw_set_user_agent_on_element (bvw, priv->source);
+ }
- /* FIXME: set the new UA on the source element if it already exists */
+ g_object_notify (G_OBJECT (bvw), "user-agent");
}
/**
@@ -3974,10 +3986,12 @@ bacon_video_widget_set_referrer (BaconVideoWidget *bvw,
/* Referrer URIs must not have a fragment */
if ((frag = strchr (priv->referrer, '#')) != NULL)
*frag = '\0';
-
- g_object_notify (G_OBJECT (bvw), "referrer");
- /* FIXME: set the new referrer on the source element if it already exists */
+ if (priv->source) {
+ bvw_set_referrer_on_element (bvw, priv->source);
+ }
+
+ g_object_notify (G_OBJECT (bvw), "referrer");
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]