Introduction to RTSP Data flow:
Rtsp_header + Rtp_header + 1, Video: Nalu_header (type*) + Fu_header
2, Audio: + audio data;
Rtsp_header Payloadlen = packet length after Rtsp_header;
dollar = (0x24);
Rtp_header payloadtype = data type (H264, g711_a, G711_u, MPEG ....) );
TimeStamp = timestamp of the current package;
Version = 2;
sequencenumber= package sequence number, increment +1;
Nalu_header type (Nal_unit_type) = 1, seq_parameter_set_rbsp (7): Keyframe, take the height and width of the frame;
2, slice_layer_without_partitioning_rbsp to Single_time_aggregation_packet_a, before the data need to add rtp_start_code;
Fu_header start_bit = 1, first package, need to add Rtp_start_code + (Fu_header.nri << 5) | (fu_header.forbidden_zero_bit << 6) | Fu_header.type;
Audio data: Add Rtp_audio_code before each package;
Class Rtsp_header
{
public byte dollar; /* 8, $:d ollar sign (in decimal) */
public byte Channelid; /* 8, Channel ID */
public short Payloadlen; /*, Payload length */
}
Class Rtp_header
{
Public byte csrccount;//4 bit;
Public byte extension;//1 bit;
Public byte padding;//1 bit;
Public byte version;//2 bit;
Public byte payloadtype;//7 bit;
Public byte marker;//1 bit;
public short SequenceNumber;
public long TimeStamp;
public int ssrc;
}
Class Nalu_header
{
Public byte type;//: 5 bit;
Public byte nri;//: 2 bit;
Public byte forbidden_zero_bit;//: 1 bit;
}
Class Fu_header
{
Public byte type;//: 5 bit; Same as the type in Nalu in the original data
Public byte reserve_bit;//: 1 bit; Reserved bit, must be 0
Public byte end_bit;//: 1 bit; Indicates whether the last shard of this frame
Public byte start_bit;//: 1 bit; Indicates whether the first shard of this frame
}
Public final byte[] Rtp_start_code = new byte[] {0x00, 0x00, 0x00, 0x01};
Public final byte[] Rtp_audio_code = new byte[] {0x00, 0x01, (byte) 0xA0, 0x00};
Introduction to Rtps Streaming media