aboutsummaryrefslogtreecommitdiff
path: root/rtmp.h
blob: bdc97cc5de8ffc70f7607baa117598fc6b2edb7f (plain)
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
/**
 * @file rtmp.h
 * @author Dean Zou (zoudingyuan@junjietech.com)
 * @brief 
 * @version 1.0
 * @date 2019-06-27
 * 
 * @copyright Copyright (c) - 2019 JunJie Intelligence(Shenzhen) Co.,LTD
 * 
 */

#ifndef RTMP_H_
#define RTMP_H_

#include <stdint.h>

#define PORT	1935

#define DEFAULT_CHUNK_LEN	128

#define PACKED	__attribute__((packed))

#define HANDSHAKE_PLAINTEXT	0x03

#define RANDOM_LEN		(1536 - 8)

#define MSG_SET_CHUNK		0x01
#define MSG_BYTES_READ		0x03
#define MSG_USER_CONTROL	0x04
#define MSG_RESPONSE		0x05
#define MSG_REQUEST		    0x06
#define MSG_AUDIO		    0x08
#define MSG_VIDEO		    0x09
#define MSG_INVOKE3		    0x11	/* AMF3 */
#define MSG_NOTIFY		    0x12
#define MSG_OBJECT		    0x13
#define MSG_INVOKE		    0x14	/* AMF0 */
#define MSG_FLASH_VIDEO		0x16

#define CONTROL_CLEAR_STREAM	0x00
#define CONTROL_CLEAR_BUFFER	0x01
#define CONTROL_STREAM_DRY	0x02
#define CONTROL_BUFFER_TIME	0x03
#define CONTROL_RESET_STREAM	0x04
#define CONTROL_PING		0x06
#define CONTROL_REQUEST_VERIFY	0x1a
#define CONTROL_RESPOND_VERIFY	0x1b
#define CONTROL_BUFFER_EMPTY	0x1f
#define CONTROL_BUFFER_READY	0x20

#define CONTROL_ID		0
#define STREAM_ID		1337

#define CHAN_CONTROL		2
#define CHAN_RESULT		3
#define CHAN_STREAM		4

#define FLV_KEY_FRAME		0x01
#define FLV_INTER_FRAME		0x02

struct Handshake {
	uint8_t flags[8];
	uint8_t random[RANDOM_LEN];
} PACKED;

struct RTMP_Header {
	uint8_t flags;
	char timestamp[3];
	char msg_len[3];
	uint8_t msg_type;
	char endpoint[4]; /* Note, this is little-endian while others are BE */
} PACKED;

#endif