After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 765314 - player: Add way to override HTTP (+RTSP, etc) user agent
player: Add way to override HTTP (+RTSP, etc) user agent
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-bad
unspecified
Other Linux
: Normal enhancement
: 1.9.2
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks: 769144
 
 
Reported: 2016-04-20 10:59 UTC by Sebastian Dröge (slomo)
Modified: 2016-07-25 10:03 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
player: add API to change http user agent (7.88 KB, patch)
2016-07-19 12:51 UTC, Guillaume Desmottes
none Details | Review
player: add API to change http user agent (7.97 KB, patch)
2016-07-19 14:06 UTC, Guillaume Desmottes
none Details | Review
player: add API to change http user agent (10.52 KB, patch)
2016-07-22 15:39 UTC, Guillaume Desmottes
none Details | Review
player: add API to change http user agent (11.60 KB, patch)
2016-07-25 08:07 UTC, Guillaume Desmottes
committed Details | Review

Description Sebastian Dröge (slomo) 2016-04-20 10:59:53 UTC
See https://github.com/sdroege/gst-player/issues/96
Comment 1 Guillaume Desmottes 2016-07-19 12:51:15 UTC
Created attachment 331770 [details] [review]
player: add API to change http user agent
Comment 2 Guillaume Desmottes 2016-07-19 12:51:40 UTC
Note that the unit test is racy atm (see FIXME); not sure of the proper way to test this.
Comment 3 Guillaume Desmottes 2016-07-19 14:06:02 UTC
Created attachment 331784 [details] [review]
player: add API to change http user agent
Comment 4 Sebastian Dröge (slomo) 2016-07-22 11:24:37 UTC
Review of attachment 331784 [details] [review]:

::: gst-libs/gst/player/gstplayer.h
@@ +195,3 @@
+const gchar * gst_player_get_http_user_agent          (GstPlayer    * player);
+void          gst_player_set_http_user_agent          (GstPlayer    * player,
+                                                       const gchar *agent);

This is not only for HTTP but also for RTSP and probably others.

I think it would also be nice to not add a million such configuration functions, but maybe create some kind of "configuration object" instead (could be based on a GstStructure like the GstBufferPoolConfig for example) for the things that you configure once and don't change during playback.

::: tests/check/libs/player.c
@@ +1649,3 @@
+  src = gst_bin_get_by_interface (GST_BIN (pipeline), GST_TYPE_URI_HANDLER);
+  /* FIXME: this test is racy: the souphttpsrc element may be destroyed before
+   * the error is reported from the player. */

You could connect to source-setup of the pipeline instead maybe
Comment 5 Sebastian Dröge (slomo) 2016-07-22 11:25:35 UTC
(In reply to Sebastian Dröge (slomo) from comment #4)

> I think it would also be nice to not add a million such configuration
> functions, but maybe create some kind of "configuration object" instead
> (could be based on a GstStructure like the GstBufferPoolConfig for example)
> for the things that you configure once and don't change during playback.

Other such configurations I'm thinking of would be for example the latency property on rtspsrc, cookies, username/password
Comment 6 Guillaume Desmottes 2016-07-22 13:42:14 UTC
(In reply to Sebastian Dröge (slomo) from comment #4)
> Review of attachment 331784 [details] [review] [review]:
> 
> ::: gst-libs/gst/player/gstplayer.h
> @@ +195,3 @@
> +const gchar * gst_player_get_http_user_agent          (GstPlayer    *
> player);
> +void          gst_player_set_http_user_agent          (GstPlayer    *
> player,
> +                                                       const gchar *agent);
> 
> This is not only for HTTP but also for RTSP and probably others.
> 
> I think it would also be nice to not add a million such configuration
> functions, but maybe create some kind of "configuration object" instead
> (could be based on a GstStructure like the GstBufferPoolConfig for example)
> for the things that you configure once and don't change during playback.

Makes sense yeah.

Something like this then?

void gst_player_config_set_user_agent (GstStructure *config, const gchar *user_name);
const gchar * gst_player_config_get_user_agent (GstStructure *config);

void gst_player_set_config (GstPlayer *player, GstStructure *config);

Or something every more generic based on key/value? That would save us from adding API for each new option but maybe kinda defeat the purpose of GstPlayer of being a very high level easy API.

> ::: tests/check/libs/player.c
> @@ +1649,3 @@
> +  src = gst_bin_get_by_interface (GST_BIN (pipeline), GST_TYPE_URI_HANDLER);
> +  /* FIXME: this test is racy: the souphttpsrc element may be destroyed
> before
> +   * the error is reported from the player. */
> 
> You could connect to source-setup of the pipeline instead maybe

Good idea, that seems to work. Thanks!
Comment 7 Sebastian Dröge (slomo) 2016-07-22 13:50:48 UTC
(In reply to Guillaume Desmottes from comment #6)
>  
> Something like this then?
> 
> void gst_player_config_set_user_agent (GstStructure *config, const gchar
> *user_name);
> const gchar * gst_player_config_get_user_agent (GstStructure *config);
> 
> void gst_player_set_config (GstPlayer *player, GstStructure *config);
> [...]

That's exactly what I was thinking of, yes. Just also add a get_config(). Basically mirror the buffer pool configuration API ;)

Setting the config should only be allowed when the player is stopped.
Comment 8 Guillaume Desmottes 2016-07-22 15:39:21 UTC
Created attachment 332008 [details] [review]
player: add API to change http user agent

Introducing a new 'config' API similar to GstBufferPoolConfig.
Comment 9 Sebastian Dröge (slomo) 2016-07-25 07:18:10 UTC
Review of attachment 332008 [details] [review]:

::: gst-libs/gst/player/gstplayer.c
@@ +2540,3 @@
+  if (user_agent) {
+    if (g_object_class_find_property (G_OBJECT_GET_CLASS (source),
+            "user-agent")) {

You should check if it actually takes a string :)

@@ +4141,3 @@
+ *
+ * Returns: %TRUE when the configuration could be set.
+ * Since 1.12

Since: with colon, and this seems like it will go into 1.10 ;)
Comment 10 Guillaume Desmottes 2016-07-25 08:06:54 UTC
(In reply to Sebastian Dröge (slomo) from comment #9)
> Review of attachment 332008 [details] [review] [review]:
> 
> ::: gst-libs/gst/player/gstplayer.c
> @@ +2540,3 @@
> +  if (user_agent) {
> +    if (g_object_class_find_property (G_OBJECT_GET_CLASS (source),
> +            "user-agent")) {
> 
> You should check if it actually takes a string :)

Indeed. Done.

> @@ +4141,3 @@
> + *
> + * Returns: %TRUE when the configuration could be set.
> + * Since 1.12
> 
> Since: with colon, and this seems like it will go into 1.10 ;)

ooops; fixed.
Comment 11 Guillaume Desmottes 2016-07-25 08:07:04 UTC
Created attachment 332076 [details] [review]
player: add API to change http user agent

Introducing a new 'config' API similar to GstBufferPoolConfig.
Comment 12 Sebastian Dröge (slomo) 2016-07-25 10:02:50 UTC
Attachment 332076 [details] pushed as 6e39cef - player: add API to change http user agent