From e07a1bb48f88e662d1aeda3631e4720952cf13d7 Mon Sep 17 00:00:00 2001 From: "Jan Alexander Steffens (heftig)" Date: Wed, 27 Nov 2019 15:38:20 +0100 Subject: [PATCH] rtmp2: Add gst_rtmp_connection_set_data_frame https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/merge_requests/878 --- gst/rtmp2/rtmp/rtmpconnection.c | 31 ++++++++++++++++++++++++++++++- gst/rtmp2/rtmp/rtmpconnection.h | 3 +++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/gst/rtmp2/rtmp/rtmpconnection.c b/gst/rtmp2/rtmp/rtmpconnection.c index d895f8e5c6..b31a325b9f 100644 --- a/gst/rtmp2/rtmp/rtmpconnection.c +++ b/gst/rtmp2/rtmp/rtmpconnection.c @@ -179,12 +179,30 @@ enum static guint signals[N_SIGNALS] = { 0, }; +/* singletons */ + +static GstMemory *set_data_frame_value; + +static void +init_set_data_frame_value (void) +{ + GstAmfNode *node = gst_amf_node_new_string ("@setDataFrame", -1); + GBytes *bytes = gst_amf_node_serialize (node); + gsize size; + const gchar *data = g_bytes_get_data (bytes, &size); + + set_data_frame_value = gst_memory_new_wrapped (GST_MEMORY_FLAG_READONLY, + (gpointer) data, size, 0, size, bytes, (GDestroyNotify) g_bytes_unref); + gst_amf_node_free (node); +} + /* class initialization */ G_DEFINE_TYPE_WITH_CODE (GstRtmpConnection, gst_rtmp_connection, G_TYPE_OBJECT, GST_DEBUG_CATEGORY_INIT (gst_rtmp_connection_debug_category, - "rtmpconnection", 0, "debug category for GstRtmpConnection class")); + "rtmpconnection", 0, "debug category for GstRtmpConnection class"); + init_set_data_frame_value ()); static void gst_rtmp_connection_class_init (GstRtmpConnectionClass * klass) @@ -999,3 +1017,14 @@ gst_rtmp_connection_request_window_size (GstRtmpConnection * connection, gst_rtmp_connection_queue_message (connection, gst_rtmp_message_new_protocol_control (&pc)); } + +void +gst_rtmp_connection_set_data_frame (GstRtmpConnection * connection, + GstBuffer * buffer) +{ + g_return_if_fail (GST_IS_RTMP_CONNECTION (connection)); + g_return_if_fail (GST_IS_BUFFER (buffer)); + + gst_buffer_prepend_memory (buffer, gst_memory_ref (set_data_frame_value)); + gst_rtmp_connection_queue_message (connection, buffer); +} diff --git a/gst/rtmp2/rtmp/rtmpconnection.h b/gst/rtmp2/rtmp/rtmpconnection.h index 7b5eb6c098..517514462c 100644 --- a/gst/rtmp2/rtmp/rtmpconnection.h +++ b/gst/rtmp2/rtmp/rtmpconnection.h @@ -77,6 +77,9 @@ void gst_rtmp_connection_expect_command (GstRtmpConnection * connection, void gst_rtmp_connection_request_window_size (GstRtmpConnection * connection, guint32 window_ack_size); +void gst_rtmp_connection_set_data_frame (GstRtmpConnection * connection, + GstBuffer * buffer); + G_END_DECLS #endif