nice: Sync with libnice 0.1.21's 60/287460/2
authorSangchul Lee <sc11.lee@samsung.com>
Mon, 30 Jan 2023 02:17:45 +0000 (11:17 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Mon, 30 Jan 2023 08:02:50 +0000 (17:02 +0900)
Change-Id: I9eb5533bff65b614045d08bd8f4d5bf6551f536e

packaging/gstreamer.spec
subprojects/gst-plugins-bad/ext/nice/gstnice.c
subprojects/gst-plugins-bad/ext/nice/gstnicesink.c
subprojects/gst-plugins-bad/ext/nice/gstnicesink.h
subprojects/gst-plugins-bad/ext/nice/gstnicesrc.c
subprojects/gst-plugins-bad/ext/nice/gstnicesrc.h

index 0c10182..584fa2c 100644 (file)
@@ -62,7 +62,7 @@
 
 Name:           %{_name}
 Version:        1.22.0
-Release:        3
+Release:        4
 Summary:        Streaming-Media Framework Runtime
 License:        LGPL-2.0+
 Group:          Multimedia/Framework
index 1f0d1e7..183c446 100644 (file)
 static gboolean
 plugin_init (GstPlugin *plugin)
 {
-  if (!gst_element_register (plugin, "nicesrc",
-        GST_RANK_NONE, GST_TYPE_NICE_SRC))
+  if (!gst_element_register_nicesrc (plugin))
     return FALSE;
 
-  if (!gst_element_register (plugin, "nicesink",
-        GST_RANK_NONE, GST_TYPE_NICE_SINK))
+  if (!gst_element_register_nicesink (plugin))
     return FALSE;
 
   return TRUE;
 }
 
-#if GST_CHECK_VERSION (1,0,0)
-#define PLUGIN_NAME nice
-#else
-#define PLUGIN_NAME "nice"
-#endif
-
 GST_PLUGIN_DEFINE (
     GST_VERSION_MAJOR,
     GST_VERSION_MINOR,
-    PLUGIN_NAME,
+    nice,
     "Interactive UDP connectivity establishment",
     plugin_init, VERSION, "LGPL", GST_PACKAGE_NAME,
     "https://nice.freedesktop.org/");
-
index ab71358..ced4bd0 100644 (file)
@@ -49,12 +49,10 @@ static GstFlowReturn
 gst_nice_sink_render (
   GstBaseSink *basesink,
   GstBuffer *buffer);
-#if GST_CHECK_VERSION (1,0,0)
 static GstFlowReturn
 gst_nice_sink_render_list (
   GstBaseSink *basesink,
   GstBufferList *buffer_list);
-#endif
 
 static gboolean
 gst_nice_sink_unlock (GstBaseSink *basesink);
@@ -85,10 +83,8 @@ gst_nice_sink_get_property (
 
 static void
 gst_nice_sink_dispose (GObject *object);
-#if GST_CHECK_VERSION (1,0,0)
 static void
 gst_nice_sink_finalize (GObject *object);
-#endif
 
 static GstStateChangeReturn
 gst_nice_sink_change_state (
@@ -123,9 +119,7 @@ gst_nice_sink_class_init (GstNiceSinkClass *klass)
 
   gstbasesink_class = (GstBaseSinkClass *) klass;
   gstbasesink_class->render = GST_DEBUG_FUNCPTR (gst_nice_sink_render);
-#if GST_CHECK_VERSION (1,0,0)
   gstbasesink_class->render_list = GST_DEBUG_FUNCPTR (gst_nice_sink_render_list);
-#endif
   gstbasesink_class->unlock = GST_DEBUG_FUNCPTR (gst_nice_sink_unlock);
   gstbasesink_class->unlock_stop = GST_DEBUG_FUNCPTR (gst_nice_sink_unlock_stop);
 
@@ -133,20 +127,14 @@ gst_nice_sink_class_init (GstNiceSinkClass *klass)
   gobject_class->set_property = gst_nice_sink_set_property;
   gobject_class->get_property = gst_nice_sink_get_property;
   gobject_class->dispose = gst_nice_sink_dispose;
-#if GST_CHECK_VERSION (1,0,0)
   gobject_class->finalize = gst_nice_sink_finalize;
-#endif
 
   gstelement_class = (GstElementClass *) klass;
   gstelement_class->change_state = gst_nice_sink_change_state;
 
   gst_element_class_add_pad_template (gstelement_class,
       gst_static_pad_template_get (&gst_nice_sink_sink_template));
-#if GST_CHECK_VERSION (1,0,0)
   gst_element_class_set_metadata (gstelement_class,
-#else
-  gst_element_class_set_details_simple (gstelement_class,
-#endif
     "ICE sink",
     "Sink",
     "Interactive UDP connectivity establishment",
@@ -185,13 +173,10 @@ gst_nice_sink_class_init (GstNiceSinkClass *klass)
 static void
 gst_nice_sink_init (GstNiceSink *sink)
 {
-#if GST_CHECK_VERSION (1,0,0)
   guint max_mem;
-#endif
 
   g_cond_init (&sink->writable_cond);
 
-#if GST_CHECK_VERSION (1,0,0)
   /* pre-allocate OutputVector, MapInfo and OutputMessage arrays
    * for use in the render and render_list functions */
   max_mem = gst_buffer_get_max_memory ();
@@ -204,7 +189,6 @@ gst_nice_sink_init (GstNiceSink *sink)
 
   sink->n_messages = 1;
   sink->messages = g_new (NiceOutputMessage, sink->n_messages);
-#endif
 
 #if GST_CHECK_VERSION (1,12,0)
   gst_base_sink_set_drop_out_of_segment (GST_BASE_SINK (sink), FALSE);
@@ -222,7 +206,6 @@ _reliable_transport_writable (NiceAgent *agent, guint stream_id,
   GST_OBJECT_UNLOCK (sink);
 }
 
-#if GST_CHECK_VERSION (1,0,0)
 static gsize
 fill_vectors (GOutputVector * vecs, GstMapInfo * maps, guint n, GstBuffer * buf)
 {
@@ -319,14 +302,12 @@ gst_nice_sink_render_buffers (GstNiceSink * sink, GstBuffer ** buffers,
 
   return flow_ret;
 }
-#endif
 
 static GstFlowReturn
 gst_nice_sink_render (GstBaseSink *basesink, GstBuffer *buffer)
 {
   GstNiceSink *nicesink = GST_NICE_SINK (basesink);
   GstFlowReturn flow_ret = GST_FLOW_OK;
-#if GST_CHECK_VERSION (1,0,0)
   guint8 n_mem;
 
   n_mem = gst_buffer_n_memory (buffer);
@@ -336,36 +317,9 @@ gst_nice_sink_render (GstBaseSink *basesink, GstBuffer *buffer)
         n_mem);
   }
 
-#else
-  guint written = 0;
-  gint ret;
-  gchar *data = NULL;
-  guint size = 0;
-
-  data = (gchar *) GST_BUFFER_DATA (buffer);
-  size = GST_BUFFER_SIZE (buffer);
-
-  GST_OBJECT_LOCK (nicesink);
-  do {
-    ret = nice_agent_send (nicesink->agent, nicesink->stream_id,
-        nicesink->component_id, size - written, data + written);
-    if (ret > 0)
-      written += ret;
-
-    if (nicesink->reliable && written < size)
-      g_cond_wait (&nicesink->writable_cond, GST_OBJECT_GET_LOCK (nicesink));
-    if (nicesink->flushing) {
-      flow_ret = GST_FLOW_WRONG_STATE;
-      break;
-    }
-  } while (nicesink->reliable && written < size);
-  GST_OBJECT_UNLOCK (nicesink);
-
-#endif
   return flow_ret;
 }
 
-#if GST_CHECK_VERSION (1,0,0)
 static GstFlowReturn
 gst_nice_sink_render_list (GstBaseSink *basesink, GstBufferList *buffer_list)
 {
@@ -401,7 +355,6 @@ no_data:
 
   return flow_ret;
 }
-#endif
 
 static gboolean gst_nice_sink_unlock (GstBaseSink *basesink)
 {
@@ -441,7 +394,6 @@ gst_nice_sink_dispose (GObject *object)
   G_OBJECT_CLASS (gst_nice_sink_parent_class)->dispose (object);
 }
 
-#if GST_CHECK_VERSION (1,0,0)
 static void
 gst_nice_sink_finalize (GObject *object)
 {
@@ -459,7 +411,6 @@ gst_nice_sink_finalize (GObject *object)
 
   G_OBJECT_CLASS (gst_nice_sink_parent_class)->finalize (object);
 }
-#endif
 
 static void
 gst_nice_sink_set_property (
@@ -586,3 +537,10 @@ gst_nice_sink_change_state (GstElement * element, GstStateChange transition)
 
   return ret;
 }
+
+gboolean
+gst_element_register_nicesink (GstPlugin * plugin)
+{
+  return gst_element_register (plugin, "nicesink", GST_RANK_NONE,
+      GST_TYPE_NICE_SINK);
+}
index 3c8edbb..b9e6e6c 100644 (file)
@@ -70,7 +70,6 @@ struct _GstNiceSink
   gulong writable_id;
   gboolean flushing;
 
-#if GST_CHECK_VERSION (1,0,0)
   /* pre-allocated scrap space for render function */
   GOutputVector *vecs;
   guint n_vecs;
@@ -78,7 +77,6 @@ struct _GstNiceSink
   guint n_maps;
   NiceOutputMessage *messages;
   guint n_messages;
-#endif
 };
 
 typedef struct _GstNiceSinkClass GstNiceSinkClass;
@@ -90,6 +88,8 @@ struct _GstNiceSinkClass
 
 GType gst_nice_sink_get_type (void);
 
+gboolean gst_element_register_nicesink (GstPlugin * plugin);
+
 G_END_DECLS
 
 #endif
index 424f449..ed9b22b 100644 (file)
@@ -129,11 +129,7 @@ gst_nice_src_class_init (GstNiceSrcClass *klass)
 
   gst_element_class_add_pad_template (gstelement_class,
       gst_static_pad_template_get (&gst_nice_src_src_template));
-#if GST_CHECK_VERSION (1,0,0)
   gst_element_class_set_metadata (gstelement_class,
-#else
-  gst_element_class_set_details_simple (gstelement_class,
-#endif
       "ICE source",
       "Source",
       "Interactive UDP connectivity establishment",
@@ -198,13 +194,8 @@ gst_nice_src_read_callback (NiceAgent *agent,
 
   GST_LOG_OBJECT (agent, "Got buffer, getting out of the main loop");
 
-#if GST_CHECK_VERSION (1,0,0)
   buffer = gst_buffer_new_allocate (NULL, len, NULL);
   gst_buffer_fill (buffer, 0, buf, len);
-#else
-  buffer = gst_buffer_new_and_alloc (len);
-  memcpy (GST_BUFFER_DATA (buffer), buf, len);
-#endif
   GST_OBJECT_LOCK (nicesrc);
   g_queue_push_tail (nicesrc->outbufs, buffer);
   g_main_loop_quit (nicesrc->mainloop);
@@ -280,11 +271,7 @@ gst_nice_src_create (
   GST_OBJECT_LOCK (basesrc);
   if (nicesrc->unlocked) {
     GST_OBJECT_UNLOCK (basesrc);
-#if GST_CHECK_VERSION (1,0,0)
     return GST_FLOW_FLUSHING;
-#else
-    return GST_FLOW_WRONG_STATE;
-#endif
   }
   if (g_queue_is_empty (nicesrc->outbufs)) {
     GST_OBJECT_UNLOCK (basesrc);
@@ -300,11 +287,7 @@ gst_nice_src_create (
     return GST_FLOW_OK;
   } else {
     GST_LOG_OBJECT (nicesrc, "Got interrupting, returning wrong-state");
-#if GST_CHECK_VERSION (1,0,0)
     return GST_FLOW_FLUSHING;
-#else
-    return GST_FLOW_WRONG_STATE;
-#endif
   }
 
 }
@@ -467,4 +450,9 @@ gst_nice_src_change_state (GstElement * element, GstStateChange transition)
   return ret;
 }
 
-
+gboolean
+gst_element_register_nicesrc (GstPlugin * plugin)
+{
+  return gst_element_register (plugin, "nicesrc", GST_RANK_NONE,
+      GST_TYPE_NICE_SRC);
+}
index 5d3f554..9d00bfa 100644 (file)
@@ -81,6 +81,8 @@ struct _GstNiceSrcClass
 
 GType gst_nice_src_get_type (void);
 
+gboolean gst_element_register_nicesrc (GstPlugin * plugin);
+
 G_END_DECLS
 
 #endif // _GSTNICESRC_H