on how to package H264 data with RTP (send sub-packet send analysis)

Source: Internet
Author: User

Q: Why are subcontracting sent?

The reasons for the solution and network bandwidth


Sub-code, the situation is as follows:

	        else if (n->len>1500) {///Gets the Nalu required to send an int k=0,l=0 with a length of 1400 bytes of RTP packets; k=n->len/1400;//requires k 1400 bytes of RTP packet l=n->len%1400;//the last RTP packet needs to load the number of bytes int t=0;//is used to indicate that the current send is the first few shard RTP packets ts_current=
			Ts_current+timestamp_increse;
			Rtp_hdr->timestamp=htonl (ts_current); while (t<=k) {rtp_hdr->seq_no = htons (seq_num + +);//serial number, each sending one RTP packet increased by 1 if (!t)//Send a Shard to the first shard of Nalu, place Fu HEAD
					s bits of ER {//set RTP M bits; rtp_hdr->marker=0; Set the FU INDICATOR and fill this header in sendbuf[12] Fu_ind = (fu_indicator*) &sendbuf[12];
					The address of the sendbuf[12] is assigned to Fu_ind, and the write to Fu_ind is then written to SendBuf; fu_ind->f=n->forbidden_bit;
					fu_ind->nri=n->nal_reference_idc>>5; FU_IND-&GT;TYPE=28;//28 fu-a Shard unit//Set FU header and fill this header in sendbuf[13] Fu_hdr = (fu_header*) &s
					ENDBUF[13];
					fu_hdr->e=0;
					fu_hdr->r=0;
					fu_hdr->s=1;
					
				
					fu_hdr->type=n->nal_unit_type; nalu_payload=&sendbuf[14];//SENDBUF[14] assigned to Nalu_payload memcpy (nalu_payload,n->buf+1,1400);//Remove Nalu head bytes=1400+14; 
					Get the length of the sendbuf, for the length of the Nalu (except the starting prefix and Nalu header) plus the fixed length of Rtp_header,fu_ind,fu_hdr 14 bytes Send (socket1, sendbuf, Bytes, 0);//Send RTP Packets
					
				t++; }//Send a non-first shard of the nalu that needs to be fragmented, clear the s-bit of the 0 Fu header, and if the Shard is the last shard of the Nalu, the e-bit else if (k==t)//Of the FU header is sent the last shard, noting that the last Shard may be longer than
				1400 bytes (when l>1386).
					{//Set RTP M bit; the last Shard is currently transmitted when the position is 1 rtp_hdr->marker=1; Set the FU INDICATOR and fill this header in sendbuf[12] Fu_ind = (fu_indicator*) &sendbuf[12];
					The address of the sendbuf[12] is assigned to Fu_ind, and the write to Fu_ind is then written to SendBuf; fu_ind->f=n->forbidden_bit;
					fu_ind->nri=n->nal_reference_idc>>5;
						
					fu_ind->type=28;
					Set the FU header and fill in the header with sendbuf[13] Fu_hdr = (fu_header*) &sendbuf[13];
					fu_hdr->r=0;
					fu_hdr->s=0;
					fu_hdr->type=n->nal_unit_type;

					fu_hdr->e=1; nalu_payload=&sendbuf[14];//the same as the sendbuf[14] address assigned to Nalu_payloAd memcpy (NALU_PAYLOAD,N-&GT;BUF+T*1400+1,L-1);//The string that will nalu the last remaining l-1 (minus the Nalu header of a byte) to the beginning of the byte content written to sendbuf[14].		bytes=l-1+14; 
					Get the length of the sendbuf, the length of the remaining Nalu l-1 plus rtp_header,fu_indicator,fu_header three headers total 14 bytes Send (socket1, sendbuf, Bytes, 0);//Send RTP Packets
				t++;
				Sleep (100);
					} else if (t<k&&0!=t) {//Set RTP M bit; rtp_hdr->marker=0; Set the FU INDICATOR and fill this header in sendbuf[12] Fu_ind = (fu_indicator*) &sendbuf[12];
					The address of the sendbuf[12] is assigned to Fu_ind, and the write to Fu_ind is then written to SendBuf; fu_ind->f=n->forbidden_bit;
					fu_ind->nri=n->nal_reference_idc>>5;
						
					fu_ind->type=28;
					Set the FU header and fill in the header with sendbuf[13] Fu_hdr = (fu_header*) &sendbuf[13];
					fu_hdr->e=0;
					fu_hdr->r=0;
					fu_hdr->s=0;
					fu_hdr->e=0;
				
					fu_hdr->type=n->nal_unit_type; nalu_payload=&sendbuf[14];//the same sendbuf[14] address assigned to Nalu_payload memcpy (nalu_payload,n->buf+t*1400+1,1400);// Nalu the remaining content of the starting prefix is written to sendbUF[14] begins the string.						bytes=1400+14;
					Get the length of the sendbuf, for the length of the Nalu (except the original NALU header) plus the fixed length of Rtp_header,fu_ind,fu_hdr 14 bytes Send (socket1, sendbuf, Bytes, 0);//Send RTP Packets
				t++; }
			}


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.