token: Fix bug when creating empty token
authorSebastian Rasmussen <sebras@hotmail.com>
Sat, 19 Oct 2013 17:21:53 +0000 (19:21 +0200)
committerWim Taymans <wim.taymans@gmail.com>
Tue, 12 Nov 2013 09:37:45 +0000 (10:37 +0100)
We always want to have a valid GstStructure in the token.

Fixes https://bugzilla.gnome.org/show_bug.cgi?id=710520

gst/rtsp-server/rtsp-token.c

index 26cf54e..f07f1c2 100644 (file)
@@ -105,7 +105,16 @@ gst_rtsp_token_init (GstRTSPTokenImpl * token, GstStructure * structure)
 GstRTSPToken *
 gst_rtsp_token_new_empty (void)
 {
-  return gst_rtsp_token_new (NULL, NULL);
+  GstRTSPTokenImpl *token;
+  GstStructure *s;
+
+  s = gst_structure_new_empty ("GstRTSPToken");
+  g_return_val_if_fail (s != NULL, NULL);
+
+  token = g_slice_new0 (GstRTSPTokenImpl);
+  gst_rtsp_token_init (token, s);
+
+  return (GstRTSPToken *) token;
 }
 
 /**
@@ -144,18 +153,16 @@ gst_rtsp_token_new (const gchar * firstfield, ...)
 GstRTSPToken *
 gst_rtsp_token_new_valist (const gchar * firstfield, va_list var_args)
 {
-  GstRTSPTokenImpl *token;
+  GstRTSPToken *token;
   GstStructure *s;
 
   g_return_val_if_fail (firstfield != NULL, NULL);
 
-  s = gst_structure_new_valist ("GstRTSPToken", firstfield, var_args);
-  g_return_val_if_fail (s != NULL, NULL);
+  token = gst_rtsp_token_new_empty ();
+  s = GST_RTSP_TOKEN_STRUCTURE (token);
+  gst_structure_set_valist (s, firstfield, var_args);
 
-  token = g_slice_new0 (GstRTSPTokenImpl);
-  gst_rtsp_token_init (token, s);
-
-  return (GstRTSPToken *) token;
+  return token;
 }