-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathamf_packet.h
166 lines (133 loc) · 4.49 KB
/
amf_packet.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
/*
librtmp
Copyright (C) 2009 ITOYANAGI Kazunori
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
ITOYANAGI Kazunori
kazunori@itoyanagi.name
*/
#ifndef _amf_packet_H_
#define _amf_packet_H_
#include "rtmp.h"
/* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus
extern "C" {
#endif
#define AMF_CHANK_SIZE 128
typedef enum amf_datatype amf_datatype_t;
enum amf_datatype
{
AMF_DATATYPE_NUMBER = 0x00,
AMF_DATATYPE_BOOLEAN = 0x01,
AMF_DATATYPE_STRING = 0x02,
AMF_DATATYPE_OBJECT = 0x03,
AMF_DATATYPE_MOVIECLIP = 0x04,
AMF_DATATYPE_NULL = 0x05,
AMF_DATATYPE_UNDEFINED = 0x06,
AMF_DATATYPE_REFERENCE = 0x07,
AMF_DATATYPE_ECMA_ARRAY = 0x08,
AMF_DATATYPE_OBJECT_END = 0x09,
AMF_DATATYPE_STRICT_ARRAY = 0x0A,
AMF_DATATYPE_DATE = 0x0B,
AMF_DATATYPE_LONG_STRING = 0x0C,
AMF_DATATYPE_UNSUPPORTED = 0x0D,
AMF_DATATYPE_RECORDSET = 0x0E,
AMF_DATATYPE_XML_DOCUMENT = 0x0F,
AMF_DATATYPE_TYPED_OBJECT = 0x10,
};
typedef struct amf_packet_number_t amf_packet_number_t;
typedef struct amf_packet_boolean_t amf_packet_boolean_t;
typedef struct amf_packet_string_t amf_packet_string_t;
typedef struct amf_packet_object_property_t amf_packet_object_property_t;
typedef struct amf_packet_object_t amf_packet_object_t;
typedef struct amf_packet_null_t amf_packet_null_t;
typedef struct amf_packet_undefined_t amf_packet_undefined_t;
typedef struct amf_packet_ecma_array_property_t amf_packet_ecma_array_property_t;
typedef struct amf_packet_ecma_array_t amf_packet_ecma_array_t;
typedef struct amf_packet_object_end_t amf_packet_object_end_t;
typedef union amf_packet_t amf_packet_t;
struct amf_packet_number_t
{
amf_datatype_t datatype;
double value;
};
struct amf_packet_boolean_t
{
amf_datatype_t datatype;
int value;
};
struct amf_packet_string_t
{
amf_datatype_t datatype;
char *value;
};
struct amf_packet_object_property_t
{
char *key;
amf_packet_t *value;
amf_packet_object_property_t *next;
};
struct amf_packet_object_t
{
amf_datatype_t datatype;
amf_packet_object_property_t *properties;
};
struct amf_packet_null_t
{
amf_datatype_t datatype;
};
struct amf_packet_undefined_t
{
amf_datatype_t datatype;
};
struct amf_packet_ecma_array_t
{
amf_datatype_t datatype;
int num;
amf_packet_object_property_t *properties;
};
struct amf_packet_object_end_t
{
amf_datatype_t datatype;
};
union amf_packet_t
{
amf_datatype_t datatype;
amf_packet_number_t number;
amf_packet_boolean_t boolean;
amf_packet_string_t string;
amf_packet_object_t object;
amf_packet_null_t null;
amf_packet_undefined_t undefined;
amf_packet_ecma_array_t ecma_array;
amf_packet_object_end_t object_end;
};
extern amf_packet_t *amf_packet_analyze_data(
unsigned char *data, size_t data_size, size_t *packet_size);
extern amf_packet_t *amf_packet_create_number(double number);
extern amf_packet_t *amf_packet_create_boolean(int boolean);
extern amf_packet_t *amf_packet_create_string(const char *string);
extern amf_packet_t *amf_packet_create_null(void);
extern amf_packet_t *amf_packet_create_undefined(void);
extern amf_packet_t *amf_packet_create_object(void);
extern rtmp_result_t amf_packet_add_property_to_object(
amf_packet_t *amf, const char *key, amf_packet_t *value);
extern size_t amf_packet_get_size(amf_packet_t *amf);
extern size_t amf_packet_serialize(
amf_packet_t *amf,
unsigned char *output_buffer, size_t output_buffer_size);
extern void amf_packet_free(amf_packet_t *amf);
/* Ends C function definitions when using C++ */
#ifdef __cplusplus
}
#endif
#endif