1 /* GStreamer RTMP Library
2 * Copyright (C) 2017 Make.TV, Inc. <info@make.tv>
3 * Contact: Jan Alexander Steffens (heftig) <jsteffens@make.tv>
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
21 #ifndef _GST_RTMP_MESSAGE_H_
22 #define _GST_RTMP_MESSAGE_H_
28 #define GST_RTMP_MAXIMUM_MESSAGE_SIZE 0xFFFFFF
31 GST_RTMP_MESSAGE_TYPE_INVALID = 0,
32 GST_RTMP_MESSAGE_TYPE_SET_CHUNK_SIZE = 1,
33 GST_RTMP_MESSAGE_TYPE_ABORT_MESSAGE = 2,
34 GST_RTMP_MESSAGE_TYPE_ACKNOWLEDGEMENT = 3,
35 GST_RTMP_MESSAGE_TYPE_USER_CONTROL = 4,
36 GST_RTMP_MESSAGE_TYPE_WINDOW_ACK_SIZE = 5,
37 GST_RTMP_MESSAGE_TYPE_SET_PEER_BANDWIDTH = 6,
38 GST_RTMP_MESSAGE_TYPE_AUDIO = 8,
39 GST_RTMP_MESSAGE_TYPE_VIDEO = 9,
40 GST_RTMP_MESSAGE_TYPE_DATA_AMF3 = 15,
41 GST_RTMP_MESSAGE_TYPE_SHARED_OBJECT_AMF3 = 16,
42 GST_RTMP_MESSAGE_TYPE_COMMAND_AMF3 = 17,
43 GST_RTMP_MESSAGE_TYPE_DATA_AMF0 = 18,
44 GST_RTMP_MESSAGE_TYPE_SHARED_OBJECT_AMF0 = 19,
45 GST_RTMP_MESSAGE_TYPE_COMMAND_AMF0 = 20,
46 GST_RTMP_MESSAGE_TYPE_AGGREGATE = 22,
49 gboolean gst_rtmp_message_type_is_valid (GstRtmpMessageType type);
50 gboolean gst_rtmp_message_type_is_protocol_control (GstRtmpMessageType type);
51 const gchar * gst_rtmp_message_type_get_nick (GstRtmpMessageType type);
55 GST_RTMP_USER_CONTROL_TYPE_STREAM_BEGIN = 0,
56 GST_RTMP_USER_CONTROL_TYPE_STREAM_EOF = 1,
57 GST_RTMP_USER_CONTROL_TYPE_STREAM_DRY = 2,
58 GST_RTMP_USER_CONTROL_TYPE_SET_BUFFER_LENGTH = 3,
59 GST_RTMP_USER_CONTROL_TYPE_STREAM_IS_RECORDED = 4,
60 GST_RTMP_USER_CONTROL_TYPE_PING_REQUEST = 6,
61 GST_RTMP_USER_CONTROL_TYPE_PING_RESPONSE = 7,
64 GST_RTMP_USER_CONTROL_TYPE_SWF_VERIFICATION_REQUEST = 26,
65 GST_RTMP_USER_CONTROL_TYPE_SWF_VERIFICATION_RESPONSE = 27,
66 GST_RTMP_USER_CONTROL_TYPE_BUFFER_EMPTY = 31,
67 GST_RTMP_USER_CONTROL_TYPE_BUFFER_READY = 32,
68 } GstRtmpUserControlType;
70 const gchar * gst_rtmp_user_control_type_get_nick (
71 GstRtmpUserControlType type);
73 #define GST_RTMP_META_API_TYPE (gst_rtmp_meta_api_get_type())
74 #define GST_RTMP_META_INFO (gst_rtmp_meta_get_info())
75 typedef struct _GstRtmpMeta GstRtmpMeta;
82 GstRtmpMessageType type;
86 GType gst_rtmp_meta_api_get_type (void);
87 const GstMetaInfo * gst_rtmp_meta_get_info (void);
89 GstRtmpMeta * gst_buffer_add_rtmp_meta (GstBuffer * buffer);
91 static inline GstRtmpMeta *
92 gst_buffer_get_rtmp_meta (GstBuffer * buffer)
94 return (GstRtmpMeta *) gst_buffer_get_meta (buffer, GST_RTMP_META_API_TYPE);
97 GstBuffer * gst_rtmp_message_new (GstRtmpMessageType type, guint32 cstream,
99 GstBuffer * gst_rtmp_message_new_wrapped (GstRtmpMessageType type, guint32 cstream,
100 guint32 mstream, guint8 * data, gsize size);
102 void gst_rtmp_buffer_dump (GstBuffer * buffer, const gchar * prefix);
104 GstRtmpMessageType gst_rtmp_message_get_type (GstBuffer * buffer);
105 gboolean gst_rtmp_message_is_protocol_control (GstBuffer * buffer);
106 gboolean gst_rtmp_message_is_user_control (GstBuffer * buffer);
109 GstRtmpMessageType type;
111 /* for SET_CHUNK_SIZE: chunk size */
112 /* for ABORT_MESSAGE: chunk stream ID */
113 /* for ACKNOWLEDGEMENT: acknowledged byte count */
114 /* for WINDOW_ACK_SIZE and SET_PEER_BANDWIDTH: acknowledgement window size */
117 /* for SET_PEER_BANDWIDTH: limit type */
119 } GstRtmpProtocolControl;
121 gboolean gst_rtmp_message_parse_protocol_control (GstBuffer * buffer,
122 GstRtmpProtocolControl * out);
124 GstBuffer * gst_rtmp_message_new_protocol_control (GstRtmpProtocolControl * pc);
127 GstRtmpUserControlType type;
129 /* for STREAM_BEGIN to STREAM_IS_RECORDED: message stream ID */
130 /* for PING_REQUEST and PING_RESPONSE: timestamp of request */
133 /* for SET_BUFFER_LENGTH: buffer length in ms */
135 } GstRtmpUserControl;
137 gboolean gst_rtmp_message_parse_user_control (GstBuffer * buffer,
138 GstRtmpUserControl * out);
140 GstBuffer * gst_rtmp_message_new_user_control (GstRtmpUserControl * uc);
142 gboolean gst_rtmp_message_is_metadata (GstBuffer * buffer);