rtmp Protocol
Real Time messaging Protocol (Real-time Messaging Protocol protocol) is a private protocol developed by Adobe for Audio, video, and data transmission between flash players and servers. The RTMP protocol is an application layer protocol in the TCP/IP five-tier architecture.
The basic data unit in the RTMP protocol is called a message, and when the RTMP protocol transmits data over the network, the message will be split into smaller data units called Message Fast (CHUNK). RTMP Message Structure
Messages are the most basic protocol data units in the RTMP protocol, and different message type IDs represent different types of messages and have different functions. The following is the basic structure of the RTMP message.
rtmp protocol Push Flow Step
To use the RTMP protocol to push the flow, we must follow the RTMP protocol standards, according to the corresponding RTMP push process!
Rtmpdump official website rtmp Push the flow step
The relevant APIs are as follows:
Rtmp_alloc ()
rtmp_init () Rtmp_setupurl () rtmp_connect ()
rtmp_connectstream
() Rtmp_read ()
Rtmp_enablewrite ()
Rtmp_connect ()
rtmp_write () rtmp_pause () Rtmp_seek ()
rtmp_read
() rtmp_close () Rtmp_free ()
rtmp Push Stream
At the end of this article, the Android-side data has been transferred to JNI for conversion, then H.264 encoded and read Sps,pps frame information, now we need to encapsulate the data into RTMP packet, and then push! rtmp Data padding
The first is to construct the Rtmppacket, which is populated according to the RTMP Basic Protocol Data unit:
Populating rtmp Information
Fill in the previous rtmp information:
Message type, rtmp_packet_type_video:0x09
packet->m_packettype = rtmp_packet_type_video;
Payload Length
packet->m_nbodysize = body_size;
Time Stamp:4 byte
packet->m_ntimestamp = 0;
Packet->m_hasabstimestamp = 0;
Channel Id,audio and Vidio channel
packet->m_nchannel = 0x04;
There are several types that specify a