1 /* GStreamer RTMP Library 2 * Copyright (C) 2013 David Schleef <ds@schleef.org> 3 * Copyright (C) 2017 Make.TV, Inc. <info@make.tv> 4 * Contact: Jan Alexander Steffens (heftig) <jsteffens@make.tv> 5 * 6 * This library is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU Library General Public 8 * License as published by the Free Software Foundation; either 9 * version 2 of the License, or (at your option) any later version. 10 * 11 * This library is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * Library General Public License for more details. 15 * 16 * You should have received a copy of the GNU Library General Public 17 * License along with this library; if not, write to the 18 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, 19 * Boston, MA 02110-1301, USA. 20 */ 21 22 #ifndef _GST_RTMP_CONNECTION_H_ 23 #define _GST_RTMP_CONNECTION_H_ 24 25 #include <gio/gio.h> 26 #include <gst/gst.h> 27 #include "amf.h" 28 29 G_BEGIN_DECLS 30 31 #define GST_TYPE_RTMP_CONNECTION (gst_rtmp_connection_get_type()) 32 #define GST_RTMP_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_RTMP_CONNECTION,GstRtmpConnection)) 33 #define GST_IS_RTMP_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_RTMP_CONNECTION)) 34 35 #define GST_RTMP_DEFAULT_CHUNK_SIZE 128 36 #define GST_RTMP_MINIMUM_CHUNK_SIZE 1 37 #define GST_RTMP_MAXIMUM_CHUNK_SIZE 0x7FFFFFFF 38 39 /* Matches librtmp */ 40 #define GST_RTMP_DEFAULT_WINDOW_ACK_SIZE 2500000 41 42 typedef struct _GstRtmpConnection GstRtmpConnection; 43 44 typedef void (*GstRtmpConnectionFunc) 45 (GstRtmpConnection * connection, gpointer user_data); 46 typedef void (*GstRtmpConnectionMessageFunc) 47 (GstRtmpConnection * connection, GstBuffer * buffer, gpointer user_data); 48 49 typedef void (*GstRtmpCommandCallback) (const gchar * command_name, 50 GPtrArray * arguments, gpointer user_data); 51 52 GType gst_rtmp_connection_get_type (void); 53 54 GstRtmpConnection *gst_rtmp_connection_new (GSocketConnection * connection, GCancellable * cancellable); 55 56 GSocket *gst_rtmp_connection_get_socket (GstRtmpConnection * connection); 57 58 void gst_rtmp_connection_close (GstRtmpConnection * connection); 59 void gst_rtmp_connection_close_and_unref (gpointer ptr); 60 61 void gst_rtmp_connection_set_input_handler (GstRtmpConnection * connection, 62 GstRtmpConnectionMessageFunc callback, gpointer user_data, 63 GDestroyNotify user_data_destroy); 64 65 void gst_rtmp_connection_set_output_handler (GstRtmpConnection * connection, 66 GstRtmpConnectionFunc callback, gpointer user_data, 67 GDestroyNotify user_data_destroy); 68 69 void gst_rtmp_connection_queue_bytes (GstRtmpConnection *self, 70 GBytes * bytes); 71 void gst_rtmp_connection_queue_message (GstRtmpConnection * connection, 72 GstBuffer * buffer); 73 guint gst_rtmp_connection_get_num_queued (GstRtmpConnection * connection); 74 75 guint gst_rtmp_connection_send_command (GstRtmpConnection * connection, 76 GstRtmpCommandCallback response_command, gpointer user_data, 77 guint32 stream_id, const gchar * command_name, const GstAmfNode * argument, 78 ...) G_GNUC_NULL_TERMINATED; 79 80 void gst_rtmp_connection_expect_command (GstRtmpConnection * connection, 81 GstRtmpCommandCallback response_command, gpointer user_data, 82 guint32 stream_id, const gchar * command_name); 83 84 void gst_rtmp_connection_set_chunk_size (GstRtmpConnection * connection, 85 guint32 chunk_size); 86 void gst_rtmp_connection_request_window_size (GstRtmpConnection * connection, 87 guint32 window_ack_size); 88 89 void gst_rtmp_connection_set_data_frame (GstRtmpConnection * connection, 90 GstBuffer * buffer); 91 92 GstStructure * gst_rtmp_connection_get_null_stats (void); 93 GstStructure * gst_rtmp_connection_get_stats (GstRtmpConnection * connection); 94 95 G_END_DECLS 96 97 #endif 98