node-media-server-v2读源码-Rtmp
发表于|更新于
|阅读量:
前言
RTMP(Real-Time Messaging Protocol)是由Adobe Systems开发的一种用于音视频以及数据在因特网上进行高效传输的协议,被广泛用于各种实时流媒体传输。
RtmpPacket
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| class RtmpPacket { constructor(fmt = 0, cid = 0) { this.header = { fmt: fmt, cid: cid, timestamp: 0, length: 0, type: 0, stream_id: 0 }; this.clock = 0; this.payload = Buffer.alloc(0); this.capacity = 0; this.bytes = 0; } }
|
Rtmp
RTMP
define
1 2 3 4 5 6
| const RTMP_HANDSHAKE_SIZE = 1536; const RTMP_HANDSHAKE_UNINIT = 0; const RTMP_HANDSHAKE_0 = 1; const RTMP_HANDSHAKE_1 = 2; const RTMP_HANDSHAKE_2 = 3;
|
constuctor
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| constructor() { this.handshakePayload = Buffer.alloc(RTMP_HANDSHAKE_SIZE); this.handshakeState = RTMP_HANDSHAKE_UNINIT; this.handshakeBytes = 0;
this.parserBuffer = Buffer.alloc(MAX_CHUNK_HEADER); this.parserState = RTMP_PARSE_INIT; this.parserBytes = 0; this.parserBasicBytes = 0; this.parserPacket = new RtmpPacket(); this.inPackets = new Map();
this.inChunkSize = RTMP_CHUNK_SIZE; this.outChunkSize = RTMP_MAX_CHUNK_SIZE;
this.streams = 0; this.flv = new Flv(); }
|
#