webrtc lib: Make the datachannel struct private
authorOlivier CrĂȘte <olivier.crete@collabora.com>
Wed, 21 Apr 2021 20:24:00 +0000 (16:24 -0400)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Mon, 21 Jun 2021 20:53:09 +0000 (20:53 +0000)
This will prevent any unsafe access.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2241>

ext/webrtc/webrtcdatachannel.h
gst-libs/gst/webrtc/datachannel.c
gst-libs/gst/webrtc/datachannel.h
gst-libs/gst/webrtc/webrtc-priv.h

index 53c11f2f574637770fcce0d29c1441607c2d6e8f..463e6ce12f0309ddd2b09b62d6febeaff8db1bd5 100644 (file)
@@ -26,6 +26,8 @@
 #include <gst/webrtc/datachannel.h>
 #include "sctptransport.h"
 
+#include "gst/webrtc/webrtc-priv.h"
+
 G_BEGIN_DECLS
 
 GType webrtc_data_channel_get_type(void);
index ee0be60304c6656d91e1342079d50d9ef1bcf98c..4c0d2f28639275c9ce78e334b149a11bef21d174 100644 (file)
@@ -33,6 +33,7 @@
 #endif
 
 #include "datachannel.h"
+#include "webrtc-priv.h"
 
 #define GST_CAT_DEFAULT gst_webrtc_data_channel_debug
 GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
index 79b536f5b5bb0f0acf97b71cb930f53ab97f5a61..8146c6598119aaeb3c9014abd6cfc28692630510 100644 (file)
@@ -36,69 +36,6 @@ GType gst_webrtc_data_channel_get_type(void);
 #define GST_IS_WEBRTC_DATA_CHANNEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass) ,GST_TYPE_WEBRTC_DATA_CHANNEL))
 #define GST_WEBRTC_DATA_CHANNEL_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS((obj) ,GST_TYPE_WEBRTC_DATA_CHANNEL,GstWebRTCDataChannelClass))
 
-#define GST_WEBRTC_DATA_CHANNEL_LOCK(channel) g_mutex_lock(&((GstWebRTCDataChannel *)(channel))->lock)
-#define GST_WEBRTC_DATA_CHANNEL_UNLOCK(channel) g_mutex_unlock(&((GstWebRTCDataChannel *)(channel))->lock)
-
-/**
- * GstWebRTCDataChannel:
- *
- * Since: 1.18
- */
-struct _GstWebRTCDataChannel
-{
-  GObject                           parent;
-
-  GMutex                            lock;
-
-  gchar                            *label;
-  gboolean                          ordered;
-  guint                             max_packet_lifetime;
-  guint                             max_retransmits;
-  gchar                            *protocol;
-  gboolean                          negotiated;
-  gint                              id;
-  GstWebRTCPriorityType             priority;
-  GstWebRTCDataChannelState         ready_state;
-  guint64                           buffered_amount;
-  guint64                           buffered_amount_low_threshold;
-
-  gpointer                         _padding[GST_PADDING];
-};
-
-/**
- * GstWebRTCDataChannelClass:
- *
- * Since: 1.18
- */
-struct _GstWebRTCDataChannelClass
-{
-  GObjectClass        parent_class;
-
-  void              (*send_data)   (GstWebRTCDataChannel * channel, GBytes *data);
-  void              (*send_string) (GstWebRTCDataChannel * channel, const gchar *str);
-  void              (*close)       (GstWebRTCDataChannel * channel);
-
-  gpointer           _padding[GST_PADDING];
-};
-
-GST_WEBRTC_API
-void gst_webrtc_data_channel_on_open (GstWebRTCDataChannel * channel);
-
-GST_WEBRTC_API
-void gst_webrtc_data_channel_on_close (GstWebRTCDataChannel * channel);
-
-GST_WEBRTC_API
-void gst_webrtc_data_channel_on_error (GstWebRTCDataChannel * channel, GError * error);
-
-GST_WEBRTC_API
-void gst_webrtc_data_channel_on_message_data (GstWebRTCDataChannel * channel, GBytes * data);
-
-GST_WEBRTC_API
-void gst_webrtc_data_channel_on_message_string (GstWebRTCDataChannel * channel, const gchar * str);
-
-GST_WEBRTC_API
-void gst_webrtc_data_channel_on_buffered_amount_low (GstWebRTCDataChannel * channel);
-
 GST_WEBRTC_API
 void gst_webrtc_data_channel_send_data (GstWebRTCDataChannel * channel, GBytes * data);
 
index 3e9bf3816087b748ec04b5211edc91503c03d5a5..203f852fa1d0e0cae9f1e9cabc82def0e824a1ac 100644 (file)
@@ -231,6 +231,69 @@ GST_WEBRTC_API
 void                        gst_webrtc_dtls_transport_set_transport     (GstWebRTCDTLSTransport * transport,
                                                                          GstWebRTCICETransport * ice);
 
+#define GST_WEBRTC_DATA_CHANNEL_LOCK(channel) g_mutex_lock(&((GstWebRTCDataChannel *)(channel))->lock)
+#define GST_WEBRTC_DATA_CHANNEL_UNLOCK(channel) g_mutex_unlock(&((GstWebRTCDataChannel *)(channel))->lock)
+
+/**
+ * GstWebRTCDataChannel:
+ *
+ * Since: 1.18
+ */
+struct _GstWebRTCDataChannel
+{
+  GObject                           parent;
+
+  GMutex                            lock;
+
+  gchar                            *label;
+  gboolean                          ordered;
+  guint                             max_packet_lifetime;
+  guint                             max_retransmits;
+  gchar                            *protocol;
+  gboolean                          negotiated;
+  gint                              id;
+  GstWebRTCPriorityType             priority;
+  GstWebRTCDataChannelState         ready_state;
+  guint64                           buffered_amount;
+  guint64                           buffered_amount_low_threshold;
+
+  gpointer                         _padding[GST_PADDING];
+};
+
+/**
+ * GstWebRTCDataChannelClass:
+ *
+ * Since: 1.18
+ */
+struct _GstWebRTCDataChannelClass
+{
+  GObjectClass        parent_class;
+
+  void              (*send_data)   (GstWebRTCDataChannel * channel, GBytes *data);
+  void              (*send_string) (GstWebRTCDataChannel * channel, const gchar *str);
+  void              (*close)       (GstWebRTCDataChannel * channel);
+
+  gpointer           _padding[GST_PADDING];
+};
+
+GST_WEBRTC_API
+void gst_webrtc_data_channel_on_open (GstWebRTCDataChannel * channel);
+
+GST_WEBRTC_API
+void gst_webrtc_data_channel_on_close (GstWebRTCDataChannel * channel);
+
+GST_WEBRTC_API
+void gst_webrtc_data_channel_on_error (GstWebRTCDataChannel * channel, GError * error);
+
+GST_WEBRTC_API
+void gst_webrtc_data_channel_on_message_data (GstWebRTCDataChannel * channel, GBytes * data);
+
+GST_WEBRTC_API
+void gst_webrtc_data_channel_on_message_string (GstWebRTCDataChannel * channel, const gchar * str);
+
+GST_WEBRTC_API
+void gst_webrtc_data_channel_on_buffered_amount_low (GstWebRTCDataChannel * channel);
+
 
 G_END_DECLS