rtmp2sink: Only apply @setDataFrame to onMetaData messages
authorJan Alexander Steffens (heftig) <jsteffens@make.tv>
Wed, 27 Nov 2019 14:38:50 +0000 (15:38 +0100)
committerJan Alexander Steffens (heftig) <jsteffens@make.tv>
Tue, 3 Dec 2019 13:11:47 +0000 (14:11 +0100)
Only the metadata needs to be made "sticky". Custom data messages should
be passed on unmodified.

https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/merge_requests/878

gst/rtmp2/gstrtmp2sink.c

index eb62b173601212898b317b2cbb938265089926ff..50201e6f3f99effb0dcad9b8934c10a99c9d3b8b 100644 (file)
@@ -41,6 +41,7 @@
 #include "gstrtmp2sink.h"
 
 #include "gstrtmp2locationhandler.h"
+#include "rtmp/amf.h"
 #include "rtmp/rtmpclient.h"
 #include "rtmp/rtmpmessage.h"
 
@@ -620,21 +621,6 @@ buffer_to_message (GstRtmp2Sink * self, GstBuffer * buffer, GstBuffer ** outbuf)
 
   GST_BUFFER_DTS (message) = timestamp * GST_MSECOND;
 
-  if (type == GST_RTMP_MESSAGE_TYPE_DATA_AMF0) {
-    /* FIXME: HACK: Attach a setDataFrame header.
-     *        This should be done using a command. */
-
-    static const guint8 header[] = {
-      0x02, 0x00, 0x0d, 0x40, 0x73, 0x65, 0x74, 0x44,
-      0x61, 0x74, 0x61, 0x46, 0x72, 0x61, 0x6d, 0x65
-    };
-
-    GstMemory *memory = gst_memory_new_wrapped (GST_MEMORY_FLAG_READONLY,
-        (guint8 *) header, sizeof header, 0, sizeof header, NULL, NULL);
-
-    gst_buffer_prepend_memory (message, memory);
-  }
-
   *outbuf = message;
   return TRUE;
 }
@@ -660,10 +646,17 @@ static void
 send_message (GstRtmp2Sink * self, GstBuffer * message)
 {
   GstRtmpMeta *meta = gst_buffer_get_rtmp_meta (message);
+
   g_return_if_fail (meta != NULL);
   g_return_if_fail (self->stream_id != 0);
+
   meta->mstream = self->stream_id;
-  gst_rtmp_connection_queue_message (self->connection, message);
+
+  if (gst_rtmp_message_is_metadata (message)) {
+    gst_rtmp_connection_set_data_frame (self->connection, message);
+  } else {
+    gst_rtmp_connection_queue_message (self->connection, message);
+  }
 }
 
 static void