GstBuffer * buffer);
static void gst_rtmp_connection_handle_message (GstRtmpConnection * sc,
GstBuffer * buffer);
+static void gst_rtmp_connection_handle_set_chunk_size (GstRtmpConnection * self,
+ guint32 in_chunk_size);
+static void gst_rtmp_connection_handle_window_ack_size (GstRtmpConnection *
+ self, guint32 in_chunk_size);
static void gst_rtmp_connection_send_ack (GstRtmpConnection * connection);
static void
switch (pc.type) {
case GST_RTMP_MESSAGE_TYPE_SET_CHUNK_SIZE:
- GST_INFO_OBJECT (connection, "new chunk size %" G_GUINT32_FORMAT,
+ GST_INFO_OBJECT (connection, "incoming chunk size %" G_GUINT32_FORMAT,
pc.param);
- connection->in_chunk_size = pc.param;
+ gst_rtmp_connection_handle_set_chunk_size (connection, pc.param);
break;
case GST_RTMP_MESSAGE_TYPE_ABORT_MESSAGE:
break;
case GST_RTMP_MESSAGE_TYPE_WINDOW_ACK_SIZE:
- GST_INFO_OBJECT (connection, "window ack size: %" G_GUINT32_FORMAT,
- pc.param);
- connection->in_window_ack_size = pc.param;
+ GST_INFO_OBJECT (connection,
+ "incoming window ack size: %" G_GUINT32_FORMAT, pc.param);
+ gst_rtmp_connection_handle_window_ack_size (connection, pc.param);
break;
case GST_RTMP_MESSAGE_TYPE_SET_PEER_BANDWIDTH:
}
}
+static void
+gst_rtmp_connection_handle_set_chunk_size (GstRtmpConnection * self,
+ guint32 chunk_size)
+{
+ if (chunk_size < GST_RTMP_MINIMUM_CHUNK_SIZE) {
+ GST_ERROR_OBJECT (self,
+ "peer requested chunk size %" G_GUINT32_FORMAT "; too small",
+ chunk_size);
+ return;
+ }
+
+ if (chunk_size > GST_RTMP_MAXIMUM_CHUNK_SIZE) {
+ GST_ERROR_OBJECT (self,
+ "peer requested chunk size %" G_GUINT32_FORMAT "; too large",
+ chunk_size);
+ return;
+ }
+
+ if (chunk_size < GST_RTMP_DEFAULT_CHUNK_SIZE) {
+ GST_WARNING_OBJECT (self,
+ "peer requested small chunk size %" G_GUINT32_FORMAT, chunk_size);
+ }
+
+ self->in_chunk_size = chunk_size;
+}
+
+static void
+gst_rtmp_connection_handle_window_ack_size (GstRtmpConnection * self,
+ guint32 window_ack_size)
+{
+ if (window_ack_size < GST_RTMP_DEFAULT_WINDOW_ACK_SIZE) {
+ GST_WARNING_OBJECT (self,
+ "peer requested small window ack size %" G_GUINT32_FORMAT,
+ window_ack_size);
+ }
+
+ self->in_window_ack_size = window_ack_size;
+}
+
static gboolean
is_command_response (const gchar * command_name)
{
#define GST_RTMP_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_RTMP_CONNECTION,GstRtmpConnection))
#define GST_IS_RTMP_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_RTMP_CONNECTION))
+#define GST_RTMP_DEFAULT_CHUNK_SIZE 128
+#define GST_RTMP_MINIMUM_CHUNK_SIZE 1
+#define GST_RTMP_MAXIMUM_CHUNK_SIZE 0x7FFFFFFF
+
+/* Matches librtmp */
+#define GST_RTMP_DEFAULT_WINDOW_ACK_SIZE 2500000
+
typedef struct _GstRtmpConnection GstRtmpConnection;
typedef void (*GstRtmpConnectionFunc)