• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* GStreamer RTMP Library
2  * Copyright (C) 2014 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_AMF_H_
23 #define _GST_RTMP_AMF_H_
24 
25 #include <glib.h>
26 
27 G_BEGIN_DECLS
28 
29 typedef enum
30 {
31   GST_AMF_TYPE_INVALID = -1,
32   GST_AMF_TYPE_NUMBER = 0,
33   GST_AMF_TYPE_BOOLEAN = 1,
34   GST_AMF_TYPE_STRING = 2,
35   GST_AMF_TYPE_OBJECT = 3,
36   GST_AMF_TYPE_MOVIECLIP = 4,
37   GST_AMF_TYPE_NULL = 5,
38   GST_AMF_TYPE_UNDEFINED = 6,
39   GST_AMF_TYPE_REFERENCE = 7,
40   GST_AMF_TYPE_ECMA_ARRAY = 8,
41   GST_AMF_TYPE_OBJECT_END = 9,
42   GST_AMF_TYPE_STRICT_ARRAY = 10,
43   GST_AMF_TYPE_DATE = 11,
44   GST_AMF_TYPE_LONG_STRING = 12,
45   GST_AMF_TYPE_UNSUPPORTED = 13,
46   GST_AMF_TYPE_RECORDSET = 14,
47   GST_AMF_TYPE_XML_DOCUMENT = 15,
48   GST_AMF_TYPE_TYPED_OBJECT = 16,
49   GST_AMF_TYPE_AVMPLUS_OBJECT = 17
50 } GstAmfType;
51 
52 const gchar * gst_amf_type_get_nick (GstAmfType type);
53 
54 typedef struct _GstAmfNode GstAmfNode;
55 
56 GstAmfNode * gst_amf_node_new_null (void);
57 GstAmfNode * gst_amf_node_new_number (gdouble value);
58 GstAmfNode * gst_amf_node_new_boolean (gboolean value);
59 GstAmfNode * gst_amf_node_new_string (const gchar * value, gssize size);
60 GstAmfNode * gst_amf_node_new_take_string (gchar * value, gssize size);
61 GstAmfNode * gst_amf_node_new_object (void);
62 
63 GstAmfNode * gst_amf_node_copy (const GstAmfNode * node);
64 void gst_amf_node_free (gpointer ptr);
65 
66 GstAmfType gst_amf_node_get_type (const GstAmfNode * node);
67 gdouble gst_amf_node_get_number (const GstAmfNode * node);
68 gboolean gst_amf_node_get_boolean (const GstAmfNode * node);
69 gchar * gst_amf_node_get_string (const GstAmfNode * node, gsize * size);
70 const gchar * gst_amf_node_peek_string (const GstAmfNode * node, gsize * size);
71 
72 const GstAmfNode * gst_amf_node_get_field (const GstAmfNode * node,
73     const gchar * name);
74 const GstAmfNode * gst_amf_node_get_field_by_index (const GstAmfNode * node,
75     guint index);
76 guint gst_amf_node_get_num_fields (const GstAmfNode * node);
77 
78 const GstAmfNode * gst_amf_node_get_element (const GstAmfNode * node,
79     guint index);
80 guint gst_amf_node_get_num_elements (const GstAmfNode * node);
81 
82 void gst_amf_node_set_number (GstAmfNode * node, gdouble value);
83 void gst_amf_node_set_boolean (GstAmfNode * node, gboolean value);
84 void gst_amf_node_set_string (GstAmfNode * node, const gchar * value, gssize size);
85 void gst_amf_node_take_string (GstAmfNode * node, gchar * value, gssize size);
86 
87 void gst_amf_node_append_field (GstAmfNode * node,
88     const gchar * name, const GstAmfNode * value);
89 void gst_amf_node_append_take_field (GstAmfNode * node,
90     const gchar * name, GstAmfNode * value);
91 void gst_amf_node_append_field_number (GstAmfNode * node,
92     const gchar * name, gdouble value);
93 void gst_amf_node_append_field_boolean (GstAmfNode * node,
94     const gchar * name, gboolean value);
95 void gst_amf_node_append_field_string (GstAmfNode * node,
96     const gchar * name, const gchar * value, gssize size);
97 void gst_amf_node_append_field_take_string (GstAmfNode * node,
98     const gchar * name, gchar * value, gssize size);
99 
100 void gst_amf_node_dump (const GstAmfNode * node, gint indent,
101     GString * string);
102 
103 GstAmfNode * gst_amf_node_parse (const guint8 * data, gsize size,
104     guint8 ** endptr);
105 
106 GPtrArray * gst_amf_parse_command (const guint8 * data, gsize size,
107     gdouble * transaction_id, gchar ** command_name);
108 
109 GBytes * gst_amf_node_serialize (const GstAmfNode * node);
110 
111 GBytes * gst_amf_serialize_command (gdouble transaction_id,
112     const gchar * command_name, const GstAmfNode * argument, ...) G_GNUC_NULL_TERMINATED;
113 GBytes * gst_amf_serialize_command_valist (gdouble transaction_id,
114     const gchar * command_name, const GstAmfNode * argument, va_list va_args);
115 
116 G_END_DECLS
117 #endif
118