forked from arut/nginx-rtmp-module
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ngx_rtmp_amf0.h
89 lines (63 loc) · 2.12 KB
/
ngx_rtmp_amf0.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
/*
* Copyright (c) 2012 Roman Arutyunyan
*/
#ifndef _NGX_RTMP_AMF0_H_INCLUDED_
#define _NGX_RTMP_AMF0_H_INCLUDED_
#define NGX_RTMP_AMF0_NUMBER 0x00
#define NGX_RTMP_AMF0_BOOLEAN 0x01
#define NGX_RTMP_AMF0_STRING 0x02
#define NGX_RTMP_AMF0_OBJECT 0x03
#define NGX_RTMP_AMF0_NULL 0x05
#define NGX_RTMP_AMF0_ARRAY 0x08
#define NGX_RTMP_AMF0_END 0x09
#include <ngx_config.h>
#include <ngx_core.h>
typedef struct {
ngx_int_t type;
char *name;
void *data;
size_t len;
} ngx_rtmp_amf0_elt_t;
typedef struct {
ngx_chain_t **link, **free;
ngx_log_t *log;
} ngx_rtmp_amf0_ctx_t;
/*
struct {
char name[32];
double trans_id;
char app[32];
char flashver[32];
char v1[8];
int locked;
} vals;
ngx_rtmp_amf0_elt_t props[] = {
{ NGX_RTMP_AMF0_STRING, "app", vals.app, sizeof(vals.app) },
{ NGX_RTMP_AMF0_STRING, "flashver", vals.flashver, sizeof(vals.flashver) }
};
ngx_rtmp_amf0_elt_t list[] = {
{ NGX_RTMP_AMF0_STRING, 0, vals.v1, sizeof(vals.v1) },
{ NGX_RTMP_AMF0_BOOLEAN, 0, &vals.locked, sizeof(vals.locked) }
};
ngx_rtmp_amf0_elt elts[] = {
{ NGX_RTMP_AMF0_STRING, 0 vals.name, sizeof(vals.name) },
{ NGX_RTMP_AMF0_NUMBER, 0 &vals.trans_id, sizeof(vals.trans_id) },
{ NGX_RTMP_AMF0_OBJECT, 0, props, sizeof(props) },
{ NGX_RTMP_AMF0_ARRAY, 0, list, sizeof(list) },
{ NGX_RTMP_AMF0_NULL }
};
Reading:
-------
memset(&vals, 0, sizeof(vals));
ngx_rtmp_amf0_read(l, elts, sizeof(elts));
Writing:
-------
ngx_rtmp_amf0_write(l, free, elts, sizeof(elts));
*/
/* reading AMF0 */
ngx_int_t ngx_rtmp_amf0_read(ngx_rtmp_amf0_ctx_t *ctx,
ngx_rtmp_amf0_elt_t *elts, size_t nelts);
/* writing AMF0 */
ngx_int_t ngx_rtmp_amf0_write(ngx_rtmp_amf0_ctx_t *ctx,
ngx_rtmp_amf0_elt_t *elts, size_t nelts);
#endif /* _NGX_RTMP_AMF0_H_INCLUDED_ */